@anmiles/google-api-wrapper 9.0.0 → 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.
- package/.eslintrc.js +3 -0
- package/CHANGELOG.md +33 -0
- package/README.md +12 -7
- package/dist/index.d.ts +1 -3
- package/dist/index.js +3 -7
- package/dist/index.js.map +1 -1
- package/dist/lib/api.d.ts +306 -0
- package/dist/lib/api.js +336 -0
- package/dist/lib/api.js.map +1 -0
- package/dist/lib/secrets.d.ts +3 -1
- package/dist/lib/secrets.js +30 -10
- package/dist/lib/secrets.js.map +1 -1
- package/package.json +3 -1
- package/src/index.ts +1 -3
- package/src/lib/__tests__/api.test.ts +206 -0
- package/src/lib/__tests__/secrets.test.ts +132 -114
- package/src/lib/api.ts +365 -0
- package/src/lib/secrets.ts +34 -11
- package/tsconfig.json +1 -0
- package/dist/lib/api/calendar.d.ts +0 -3
- package/dist/lib/api/calendar.js +0 -14
- package/dist/lib/api/calendar.js.map +0 -1
- package/dist/lib/api/shared.d.ts +0 -23
- package/dist/lib/api/shared.js +0 -27
- package/dist/lib/api/shared.js.map +0 -1
- package/dist/lib/api/youtube.d.ts +0 -3
- package/dist/lib/api/youtube.js +0 -14
- package/dist/lib/api/youtube.js.map +0 -1
- package/src/lib/api/__tests__/calendar.test.ts +0 -45
- package/src/lib/api/__tests__/shared.test.ts +0 -93
- package/src/lib/api/__tests__/youtube.test.ts +0 -45
- package/src/lib/api/calendar.ts +0 -13
- package/src/lib/api/shared.ts +0 -44
- package/src/lib/api/youtube.ts +0 -13
package/src/lib/api.ts
ADDED
|
@@ -0,0 +1,365 @@
|
|
|
1
|
+
import { google } from 'googleapis';
|
|
2
|
+
import type GoogleApis from 'googleapis';
|
|
3
|
+
import { log } from '@anmiles/logger';
|
|
4
|
+
import sleep from '@anmiles/sleep';
|
|
5
|
+
import type { AuthOptions, CommonOptions } from '../types';
|
|
6
|
+
import { getAuth } from './auth';
|
|
7
|
+
import { deleteCredentials } from './secrets';
|
|
8
|
+
|
|
9
|
+
const requestInterval = 300;
|
|
10
|
+
|
|
11
|
+
type CommonApi<TItem> = {
|
|
12
|
+
list: {
|
|
13
|
+
(params?: { pageToken: string | undefined }, options?: GoogleApis.Common.MethodOptions): Promise<GoogleApis.Common.GaxiosResponse<CommonResponse<TItem>>>;
|
|
14
|
+
(callback: (err: Error | null, res?: GoogleApis.Common.GaxiosResponse<CommonResponse<TItem>> | null) => void): void;
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
type CommonResponse<TItem> = {
|
|
19
|
+
items?: TItem[],
|
|
20
|
+
pageInfo?: {
|
|
21
|
+
totalResults?: number | null | undefined
|
|
22
|
+
},
|
|
23
|
+
nextPageToken?: string | null | undefined
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
class Api<TApi extends keyof typeof allApis> {
|
|
27
|
+
api: ReturnType<typeof allApis[TApi]>;
|
|
28
|
+
private auth: GoogleApis.Common.OAuth2Client;
|
|
29
|
+
|
|
30
|
+
private apiName: TApi;
|
|
31
|
+
private profile: string;
|
|
32
|
+
private authOptions?: AuthOptions;
|
|
33
|
+
|
|
34
|
+
constructor(apiName: TApi, profile: string, authOptions?: AuthOptions) {
|
|
35
|
+
this.apiName = apiName;
|
|
36
|
+
this.profile = profile;
|
|
37
|
+
this.authOptions = authOptions;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
async init() {
|
|
41
|
+
this.auth = await getAuth(this.profile, this.authOptions);
|
|
42
|
+
this.api = allApis[this.apiName](this.auth) as ReturnType<typeof allApis[TApi]>;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
async getItems<TItem>(selectAPI: (api: ReturnType<typeof allApis[TApi]>) => CommonApi<TItem>, params: any, options?: CommonOptions): Promise<TItem[]> {
|
|
46
|
+
const items: TItem[] = [];
|
|
47
|
+
|
|
48
|
+
let pageToken: string | null | undefined = undefined;
|
|
49
|
+
|
|
50
|
+
do {
|
|
51
|
+
let response: GoogleApis.Common.GaxiosResponse<CommonResponse<TItem>>;
|
|
52
|
+
|
|
53
|
+
try {
|
|
54
|
+
response = await selectAPI(this.api).list({ ...params, pageToken });
|
|
55
|
+
} catch (ex) {
|
|
56
|
+
if (ex.message === 'invalid_grant') {
|
|
57
|
+
deleteCredentials(this.profile);
|
|
58
|
+
await this.init();
|
|
59
|
+
return this.getItems(selectAPI, params, options);
|
|
60
|
+
} else {
|
|
61
|
+
throw ex;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
response.data.items?.forEach((item) => items.push(item));
|
|
66
|
+
|
|
67
|
+
if (!options?.hideProgress) {
|
|
68
|
+
log(`Getting items (${items.length} of ${response.data.pageInfo?.totalResults || 'many'})...`);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
await sleep(requestInterval);
|
|
72
|
+
pageToken = response.data.nextPageToken;
|
|
73
|
+
} while (pageToken);
|
|
74
|
+
|
|
75
|
+
return items;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
async revoke() {
|
|
79
|
+
deleteCredentials(this.profile);
|
|
80
|
+
return this.auth.revokeCredentials();
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
async function getApi<TApi extends keyof typeof allApis>(apiName: TApi, profile: string, authOptions?: AuthOptions): Promise<Api<TApi>> {
|
|
85
|
+
const instance = new Api<TApi>(apiName, profile, authOptions);
|
|
86
|
+
await instance.init();
|
|
87
|
+
return instance;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/* istanbul ignore next */
|
|
91
|
+
const allApis = {
|
|
92
|
+
abusiveexperiencereport : (auth: GoogleApis.Common.OAuth2Client) => google.abusiveexperiencereport({ version : 'v1', auth }),
|
|
93
|
+
acceleratedmobilepageurl : (auth: GoogleApis.Common.OAuth2Client) => google.acceleratedmobilepageurl({ version : 'v1', auth }),
|
|
94
|
+
accessapproval : (auth: GoogleApis.Common.OAuth2Client) => google.accessapproval({ version : 'v1', auth }),
|
|
95
|
+
accesscontextmanager : (auth: GoogleApis.Common.OAuth2Client) => google.accesscontextmanager({ version : 'v1', auth }),
|
|
96
|
+
acmedns : (auth: GoogleApis.Common.OAuth2Client) => google.acmedns({ version : 'v1', auth }),
|
|
97
|
+
adexchangebuyer : (auth: GoogleApis.Common.OAuth2Client) => google.adexchangebuyer({ version : 'v1.2', auth }),
|
|
98
|
+
adexchangebuyer2 : (auth: GoogleApis.Common.OAuth2Client) => google.adexchangebuyer2({ version : 'v2beta1', auth }),
|
|
99
|
+
adexperiencereport : (auth: GoogleApis.Common.OAuth2Client) => google.adexperiencereport({ version : 'v1', auth }),
|
|
100
|
+
admin : (auth: GoogleApis.Common.OAuth2Client) => google.admin({ version : 'datatransfer_v1', auth }),
|
|
101
|
+
admob : (auth: GoogleApis.Common.OAuth2Client) => google.admob({ version : 'v1', auth }),
|
|
102
|
+
adsense : (auth: GoogleApis.Common.OAuth2Client) => google.adsense({ version : 'v1.4', auth }),
|
|
103
|
+
adsensehost : (auth: GoogleApis.Common.OAuth2Client) => google.adsensehost({ version : 'v4.1', auth }),
|
|
104
|
+
advisorynotifications : (auth: GoogleApis.Common.OAuth2Client) => google.advisorynotifications({ version : 'v1', auth }),
|
|
105
|
+
alertcenter : (auth: GoogleApis.Common.OAuth2Client) => google.alertcenter({ version : 'v1beta1', auth }),
|
|
106
|
+
analytics : (auth: GoogleApis.Common.OAuth2Client) => google.analytics({ version : 'v3', auth }),
|
|
107
|
+
analyticsadmin : (auth: GoogleApis.Common.OAuth2Client) => google.analyticsadmin({ version : 'v1alpha', auth }),
|
|
108
|
+
analyticsdata : (auth: GoogleApis.Common.OAuth2Client) => google.analyticsdata({ version : 'v1alpha', auth }),
|
|
109
|
+
analyticshub : (auth: GoogleApis.Common.OAuth2Client) => google.analyticshub({ version : 'v1', auth }),
|
|
110
|
+
analyticsreporting : (auth: GoogleApis.Common.OAuth2Client) => google.analyticsreporting({ version : 'v4', auth }),
|
|
111
|
+
androiddeviceprovisioning : (auth: GoogleApis.Common.OAuth2Client) => google.androiddeviceprovisioning({ version : 'v1', auth }),
|
|
112
|
+
androidenterprise : (auth: GoogleApis.Common.OAuth2Client) => google.androidenterprise({ version : 'v1', auth }),
|
|
113
|
+
androidmanagement : (auth: GoogleApis.Common.OAuth2Client) => google.androidmanagement({ version : 'v1', auth }),
|
|
114
|
+
androidpublisher : (auth: GoogleApis.Common.OAuth2Client) => google.androidpublisher({ version : 'v1.1', auth }),
|
|
115
|
+
apigateway : (auth: GoogleApis.Common.OAuth2Client) => google.apigateway({ version : 'v1', auth }),
|
|
116
|
+
apigeeregistry : (auth: GoogleApis.Common.OAuth2Client) => google.apigeeregistry({ version : 'v1', auth }),
|
|
117
|
+
apikeys : (auth: GoogleApis.Common.OAuth2Client) => google.apikeys({ version : 'v2', auth }),
|
|
118
|
+
appengine : (auth: GoogleApis.Common.OAuth2Client) => google.appengine({ version : 'v1', auth }),
|
|
119
|
+
appsactivity : (auth: GoogleApis.Common.OAuth2Client) => google.appsactivity({ version : 'v1', auth }),
|
|
120
|
+
area120tables : (auth: GoogleApis.Common.OAuth2Client) => google.area120tables({ version : 'v1alpha1', auth }),
|
|
121
|
+
artifactregistry : (auth: GoogleApis.Common.OAuth2Client) => google.artifactregistry({ version : 'v1', auth }),
|
|
122
|
+
assuredworkloads : (auth: GoogleApis.Common.OAuth2Client) => google.assuredworkloads({ version : 'v1', auth }),
|
|
123
|
+
authorizedbuyersmarketplace : (auth: GoogleApis.Common.OAuth2Client) => google.authorizedbuyersmarketplace({ version : 'v1', auth }),
|
|
124
|
+
baremetalsolution : (auth: GoogleApis.Common.OAuth2Client) => google.baremetalsolution({ version : 'v1', auth }),
|
|
125
|
+
batch : (auth: GoogleApis.Common.OAuth2Client) => google.batch({ version : 'v1', auth }),
|
|
126
|
+
beyondcorp : (auth: GoogleApis.Common.OAuth2Client) => google.beyondcorp({ version : 'v1', auth }),
|
|
127
|
+
bigquery : (auth: GoogleApis.Common.OAuth2Client) => google.bigquery({ version : 'v2', auth }),
|
|
128
|
+
bigqueryconnection : (auth: GoogleApis.Common.OAuth2Client) => google.bigqueryconnection({ version : 'v1beta1', auth }),
|
|
129
|
+
bigquerydatatransfer : (auth: GoogleApis.Common.OAuth2Client) => google.bigquerydatatransfer({ version : 'v1', auth }),
|
|
130
|
+
bigqueryreservation : (auth: GoogleApis.Common.OAuth2Client) => google.bigqueryreservation({ version : 'v1', auth }),
|
|
131
|
+
bigtableadmin : (auth: GoogleApis.Common.OAuth2Client) => google.bigtableadmin({ version : 'v1', auth }),
|
|
132
|
+
billingbudgets : (auth: GoogleApis.Common.OAuth2Client) => google.billingbudgets({ version : 'v1', auth }),
|
|
133
|
+
binaryauthorization : (auth: GoogleApis.Common.OAuth2Client) => google.binaryauthorization({ version : 'v1', auth }),
|
|
134
|
+
blogger : (auth: GoogleApis.Common.OAuth2Client) => google.blogger({ version : 'v2', auth }),
|
|
135
|
+
books : (auth: GoogleApis.Common.OAuth2Client) => google.books({ version : 'v1', auth }),
|
|
136
|
+
businessprofileperformance : (auth: GoogleApis.Common.OAuth2Client) => google.businessprofileperformance({ version : 'v1', auth }),
|
|
137
|
+
calendar : (auth: GoogleApis.Common.OAuth2Client) => google.calendar({ version : 'v3', auth }),
|
|
138
|
+
certificatemanager : (auth: GoogleApis.Common.OAuth2Client) => google.certificatemanager({ version : 'v1', auth }),
|
|
139
|
+
chat : (auth: GoogleApis.Common.OAuth2Client) => google.chat({ version : 'v1', auth }),
|
|
140
|
+
chromemanagement : (auth: GoogleApis.Common.OAuth2Client) => google.chromemanagement({ version : 'v1', auth }),
|
|
141
|
+
chromepolicy : (auth: GoogleApis.Common.OAuth2Client) => google.chromepolicy({ version : 'v1', auth }),
|
|
142
|
+
chromeuxreport : (auth: GoogleApis.Common.OAuth2Client) => google.chromeuxreport({ version : 'v1', auth }),
|
|
143
|
+
civicinfo : (auth: GoogleApis.Common.OAuth2Client) => google.civicinfo({ version : 'v2', auth }),
|
|
144
|
+
classroom : (auth: GoogleApis.Common.OAuth2Client) => google.classroom({ version : 'v1', auth }),
|
|
145
|
+
cloudasset : (auth: GoogleApis.Common.OAuth2Client) => google.cloudasset({ version : 'v1', auth }),
|
|
146
|
+
cloudbilling : (auth: GoogleApis.Common.OAuth2Client) => google.cloudbilling({ version : 'v1', auth }),
|
|
147
|
+
cloudbuild : (auth: GoogleApis.Common.OAuth2Client) => google.cloudbuild({ version : 'v1', auth }),
|
|
148
|
+
cloudchannel : (auth: GoogleApis.Common.OAuth2Client) => google.cloudchannel({ version : 'v1', auth }),
|
|
149
|
+
clouddebugger : (auth: GoogleApis.Common.OAuth2Client) => google.clouddebugger({ version : 'v2', auth }),
|
|
150
|
+
clouddeploy : (auth: GoogleApis.Common.OAuth2Client) => google.clouddeploy({ version : 'v1', auth }),
|
|
151
|
+
clouderrorreporting : (auth: GoogleApis.Common.OAuth2Client) => google.clouderrorreporting({ version : 'v1beta1', auth }),
|
|
152
|
+
cloudfunctions : (auth: GoogleApis.Common.OAuth2Client) => google.cloudfunctions({ version : 'v1', auth }),
|
|
153
|
+
cloudidentity : (auth: GoogleApis.Common.OAuth2Client) => google.cloudidentity({ version : 'v1', auth }),
|
|
154
|
+
cloudiot : (auth: GoogleApis.Common.OAuth2Client) => google.cloudiot({ version : 'v1', auth }),
|
|
155
|
+
cloudkms : (auth: GoogleApis.Common.OAuth2Client) => google.cloudkms({ version : 'v1', auth }),
|
|
156
|
+
cloudprofiler : (auth: GoogleApis.Common.OAuth2Client) => google.cloudprofiler({ version : 'v2', auth }),
|
|
157
|
+
cloudresourcemanager : (auth: GoogleApis.Common.OAuth2Client) => google.cloudresourcemanager({ version : 'v1', auth }),
|
|
158
|
+
cloudscheduler : (auth: GoogleApis.Common.OAuth2Client) => google.cloudscheduler({ version : 'v1', auth }),
|
|
159
|
+
cloudsearch : (auth: GoogleApis.Common.OAuth2Client) => google.cloudsearch({ version : 'v1', auth }),
|
|
160
|
+
cloudshell : (auth: GoogleApis.Common.OAuth2Client) => google.cloudshell({ version : 'v1', auth }),
|
|
161
|
+
cloudsupport : (auth: GoogleApis.Common.OAuth2Client) => google.cloudsupport({ version : 'v2beta', auth }),
|
|
162
|
+
cloudtasks : (auth: GoogleApis.Common.OAuth2Client) => google.cloudtasks({ version : 'v2', auth }),
|
|
163
|
+
cloudtrace : (auth: GoogleApis.Common.OAuth2Client) => google.cloudtrace({ version : 'v1', auth }),
|
|
164
|
+
composer : (auth: GoogleApis.Common.OAuth2Client) => google.composer({ version : 'v1', auth }),
|
|
165
|
+
compute : (auth: GoogleApis.Common.OAuth2Client) => google.compute({ version : 'alpha', auth }),
|
|
166
|
+
connectors : (auth: GoogleApis.Common.OAuth2Client) => google.connectors({ version : 'v1', auth }),
|
|
167
|
+
contactcenteraiplatform : (auth: GoogleApis.Common.OAuth2Client) => google.contactcenteraiplatform({ version : 'v1alpha1', auth }),
|
|
168
|
+
contactcenterinsights : (auth: GoogleApis.Common.OAuth2Client) => google.contactcenterinsights({ version : 'v1', auth }),
|
|
169
|
+
container : (auth: GoogleApis.Common.OAuth2Client) => google.container({ version : 'v1', auth }),
|
|
170
|
+
containeranalysis : (auth: GoogleApis.Common.OAuth2Client) => google.containeranalysis({ version : 'v1', auth }),
|
|
171
|
+
content : (auth: GoogleApis.Common.OAuth2Client) => google.content({ version : 'v2.1', auth }),
|
|
172
|
+
contentwarehouse : (auth: GoogleApis.Common.OAuth2Client) => google.contentwarehouse({ version : 'v1', auth }),
|
|
173
|
+
customsearch : (auth: GoogleApis.Common.OAuth2Client) => google.customsearch({ version : 'v1', auth }),
|
|
174
|
+
datacatalog : (auth: GoogleApis.Common.OAuth2Client) => google.datacatalog({ version : 'v1', auth }),
|
|
175
|
+
dataflow : (auth: GoogleApis.Common.OAuth2Client) => google.dataflow({ version : 'v1b3', auth }),
|
|
176
|
+
dataform : (auth: GoogleApis.Common.OAuth2Client) => google.dataform({ version : 'v1beta1', auth }),
|
|
177
|
+
datafusion : (auth: GoogleApis.Common.OAuth2Client) => google.datafusion({ version : 'v1', auth }),
|
|
178
|
+
datalabeling : (auth: GoogleApis.Common.OAuth2Client) => google.datalabeling({ version : 'v1beta1', auth }),
|
|
179
|
+
datalineage : (auth: GoogleApis.Common.OAuth2Client) => google.datalineage({ version : 'v1', auth }),
|
|
180
|
+
datamigration : (auth: GoogleApis.Common.OAuth2Client) => google.datamigration({ version : 'v1', auth }),
|
|
181
|
+
datapipelines : (auth: GoogleApis.Common.OAuth2Client) => google.datapipelines({ version : 'v1', auth }),
|
|
182
|
+
dataplex : (auth: GoogleApis.Common.OAuth2Client) => google.dataplex({ version : 'v1', auth }),
|
|
183
|
+
dataproc : (auth: GoogleApis.Common.OAuth2Client) => google.dataproc({ version : 'v1', auth }),
|
|
184
|
+
datastore : (auth: GoogleApis.Common.OAuth2Client) => google.datastore({ version : 'v1', auth }),
|
|
185
|
+
datastream : (auth: GoogleApis.Common.OAuth2Client) => google.datastream({ version : 'v1', auth }),
|
|
186
|
+
deploymentmanager : (auth: GoogleApis.Common.OAuth2Client) => google.deploymentmanager({ version : 'alpha', auth }),
|
|
187
|
+
dfareporting : (auth: GoogleApis.Common.OAuth2Client) => google.dfareporting({ version : 'v3.3', auth }),
|
|
188
|
+
dialogflow : (auth: GoogleApis.Common.OAuth2Client) => google.dialogflow({ version : 'v2', auth }),
|
|
189
|
+
digitalassetlinks : (auth: GoogleApis.Common.OAuth2Client) => google.digitalassetlinks({ version : 'v1', auth }),
|
|
190
|
+
discovery : (auth: GoogleApis.Common.OAuth2Client) => google.discovery({ version : 'v1', auth }),
|
|
191
|
+
discoveryengine : (auth: GoogleApis.Common.OAuth2Client) => google.discoveryengine({ version : 'v1alpha', auth }),
|
|
192
|
+
displayvideo : (auth: GoogleApis.Common.OAuth2Client) => google.displayvideo({ version : 'v1', auth }),
|
|
193
|
+
dlp : (auth: GoogleApis.Common.OAuth2Client) => google.dlp({ version : 'v2', auth }),
|
|
194
|
+
dns : (auth: GoogleApis.Common.OAuth2Client) => google.dns({ version : 'v1', auth }),
|
|
195
|
+
docs : (auth: GoogleApis.Common.OAuth2Client) => google.docs({ version : 'v1', auth }),
|
|
196
|
+
documentai : (auth: GoogleApis.Common.OAuth2Client) => google.documentai({ version : 'v1', auth }),
|
|
197
|
+
domains : (auth: GoogleApis.Common.OAuth2Client) => google.domains({ version : 'v1', auth }),
|
|
198
|
+
domainsrdap : (auth: GoogleApis.Common.OAuth2Client) => google.domainsrdap({ version : 'v1', auth }),
|
|
199
|
+
doubleclickbidmanager : (auth: GoogleApis.Common.OAuth2Client) => google.doubleclickbidmanager({ version : 'v1.1', auth }),
|
|
200
|
+
doubleclicksearch : (auth: GoogleApis.Common.OAuth2Client) => google.doubleclicksearch({ version : 'v2', auth }),
|
|
201
|
+
drive : (auth: GoogleApis.Common.OAuth2Client) => google.drive({ version : 'v2', auth }),
|
|
202
|
+
driveactivity : (auth: GoogleApis.Common.OAuth2Client) => google.driveactivity({ version : 'v2', auth }),
|
|
203
|
+
drivelabels : (auth: GoogleApis.Common.OAuth2Client) => google.drivelabels({ version : 'v2', auth }),
|
|
204
|
+
essentialcontacts : (auth: GoogleApis.Common.OAuth2Client) => google.essentialcontacts({ version : 'v1', auth }),
|
|
205
|
+
eventarc : (auth: GoogleApis.Common.OAuth2Client) => google.eventarc({ version : 'v1', auth }),
|
|
206
|
+
factchecktools : (auth: GoogleApis.Common.OAuth2Client) => google.factchecktools({ version : 'v1alpha1', auth }),
|
|
207
|
+
fcm : (auth: GoogleApis.Common.OAuth2Client) => google.fcm({ version : 'v1', auth }),
|
|
208
|
+
fcmdata : (auth: GoogleApis.Common.OAuth2Client) => google.fcmdata({ version : 'v1beta1', auth }),
|
|
209
|
+
file : (auth: GoogleApis.Common.OAuth2Client) => google.file({ version : 'v1', auth }),
|
|
210
|
+
firebase : (auth: GoogleApis.Common.OAuth2Client) => google.firebase({ version : 'v1beta1', auth }),
|
|
211
|
+
firebaseappcheck : (auth: GoogleApis.Common.OAuth2Client) => google.firebaseappcheck({ version : 'v1', auth }),
|
|
212
|
+
firebaseappdistribution : (auth: GoogleApis.Common.OAuth2Client) => google.firebaseappdistribution({ version : 'v1', auth }),
|
|
213
|
+
firebasedatabase : (auth: GoogleApis.Common.OAuth2Client) => google.firebasedatabase({ version : 'v1beta', auth }),
|
|
214
|
+
firebasedynamiclinks : (auth: GoogleApis.Common.OAuth2Client) => google.firebasedynamiclinks({ version : 'v1', auth }),
|
|
215
|
+
firebasehosting : (auth: GoogleApis.Common.OAuth2Client) => google.firebasehosting({ version : 'v1', auth }),
|
|
216
|
+
firebaseml : (auth: GoogleApis.Common.OAuth2Client) => google.firebaseml({ version : 'v1', auth }),
|
|
217
|
+
firebaserules : (auth: GoogleApis.Common.OAuth2Client) => google.firebaserules({ version : 'v1', auth }),
|
|
218
|
+
firebasestorage : (auth: GoogleApis.Common.OAuth2Client) => google.firebasestorage({ version : 'v1beta', auth }),
|
|
219
|
+
firestore : (auth: GoogleApis.Common.OAuth2Client) => google.firestore({ version : 'v1', auth }),
|
|
220
|
+
fitness : (auth: GoogleApis.Common.OAuth2Client) => google.fitness({ version : 'v1', auth }),
|
|
221
|
+
forms : (auth: GoogleApis.Common.OAuth2Client) => google.forms({ version : 'v1', auth }),
|
|
222
|
+
games : (auth: GoogleApis.Common.OAuth2Client) => google.games({ version : 'v1', auth }),
|
|
223
|
+
gamesConfiguration : (auth: GoogleApis.Common.OAuth2Client) => google.gamesConfiguration({ version : 'v1configuration', auth }),
|
|
224
|
+
gameservices : (auth: GoogleApis.Common.OAuth2Client) => google.gameservices({ version : 'v1', auth }),
|
|
225
|
+
gamesManagement : (auth: GoogleApis.Common.OAuth2Client) => google.gamesManagement({ version : 'v1management', auth }),
|
|
226
|
+
genomics : (auth: GoogleApis.Common.OAuth2Client) => google.genomics({ version : 'v1', auth }),
|
|
227
|
+
gkebackup : (auth: GoogleApis.Common.OAuth2Client) => google.gkebackup({ version : 'v1', auth }),
|
|
228
|
+
gkehub : (auth: GoogleApis.Common.OAuth2Client) => google.gkehub({ version : 'v1', auth }),
|
|
229
|
+
gmail : (auth: GoogleApis.Common.OAuth2Client) => google.gmail({ version : 'v1', auth }),
|
|
230
|
+
gmailpostmastertools : (auth: GoogleApis.Common.OAuth2Client) => google.gmailpostmastertools({ version : 'v1', auth }),
|
|
231
|
+
groupsmigration : (auth: GoogleApis.Common.OAuth2Client) => google.groupsmigration({ version : 'v1', auth }),
|
|
232
|
+
groupssettings : (auth: GoogleApis.Common.OAuth2Client) => google.groupssettings({ version : 'v1', auth }),
|
|
233
|
+
healthcare : (auth: GoogleApis.Common.OAuth2Client) => google.healthcare({ version : 'v1', auth }),
|
|
234
|
+
homegraph : (auth: GoogleApis.Common.OAuth2Client) => google.homegraph({ version : 'v1', auth }),
|
|
235
|
+
iam : (auth: GoogleApis.Common.OAuth2Client) => google.iam({ version : 'v1', auth }),
|
|
236
|
+
iamcredentials : (auth: GoogleApis.Common.OAuth2Client) => google.iamcredentials({ version : 'v1', auth }),
|
|
237
|
+
iap : (auth: GoogleApis.Common.OAuth2Client) => google.iap({ version : 'v1', auth }),
|
|
238
|
+
ideahub : (auth: GoogleApis.Common.OAuth2Client) => google.ideahub({ version : 'v1alpha', auth }),
|
|
239
|
+
identitytoolkit : (auth: GoogleApis.Common.OAuth2Client) => google.identitytoolkit({ version : 'v2', auth }),
|
|
240
|
+
ids : (auth: GoogleApis.Common.OAuth2Client) => google.ids({ version : 'v1', auth }),
|
|
241
|
+
indexing : (auth: GoogleApis.Common.OAuth2Client) => google.indexing({ version : 'v3', auth }),
|
|
242
|
+
integrations : (auth: GoogleApis.Common.OAuth2Client) => google.integrations({ version : 'v1alpha', auth }),
|
|
243
|
+
jobs : (auth: GoogleApis.Common.OAuth2Client) => google.jobs({ version : 'v2', auth }),
|
|
244
|
+
kgsearch : (auth: GoogleApis.Common.OAuth2Client) => google.kgsearch({ version : 'v1', auth }),
|
|
245
|
+
kmsinventory : (auth: GoogleApis.Common.OAuth2Client) => google.kmsinventory({ version : 'v1', auth }),
|
|
246
|
+
language : (auth: GoogleApis.Common.OAuth2Client) => google.language({ version : 'v1', auth }),
|
|
247
|
+
libraryagent : (auth: GoogleApis.Common.OAuth2Client) => google.libraryagent({ version : 'v1', auth }),
|
|
248
|
+
licensing : (auth: GoogleApis.Common.OAuth2Client) => google.licensing({ version : 'v1', auth }),
|
|
249
|
+
lifesciences : (auth: GoogleApis.Common.OAuth2Client) => google.lifesciences({ version : 'v2beta', auth }),
|
|
250
|
+
localservices : (auth: GoogleApis.Common.OAuth2Client) => google.localservices({ version : 'v1', auth }),
|
|
251
|
+
logging : (auth: GoogleApis.Common.OAuth2Client) => google.logging({ version : 'v2', auth }),
|
|
252
|
+
managedidentities : (auth: GoogleApis.Common.OAuth2Client) => google.managedidentities({ version : 'v1', auth }),
|
|
253
|
+
manufacturers : (auth: GoogleApis.Common.OAuth2Client) => google.manufacturers({ version : 'v1', auth }),
|
|
254
|
+
memcache : (auth: GoogleApis.Common.OAuth2Client) => google.memcache({ version : 'v1', auth }),
|
|
255
|
+
metastore : (auth: GoogleApis.Common.OAuth2Client) => google.metastore({ version : 'v1', auth }),
|
|
256
|
+
migrationcenter : (auth: GoogleApis.Common.OAuth2Client) => google.migrationcenter({ version : 'v1alpha1', auth }),
|
|
257
|
+
ml : (auth: GoogleApis.Common.OAuth2Client) => google.ml({ version : 'v1', auth }),
|
|
258
|
+
monitoring : (auth: GoogleApis.Common.OAuth2Client) => google.monitoring({ version : 'v1', auth }),
|
|
259
|
+
mybusinessaccountmanagement : (auth: GoogleApis.Common.OAuth2Client) => google.mybusinessaccountmanagement({ version : 'v1', auth }),
|
|
260
|
+
mybusinessbusinesscalls : (auth: GoogleApis.Common.OAuth2Client) => google.mybusinessbusinesscalls({ version : 'v1', auth }),
|
|
261
|
+
mybusinessbusinessinformation : (auth: GoogleApis.Common.OAuth2Client) => google.mybusinessbusinessinformation({ version : 'v1', auth }),
|
|
262
|
+
mybusinesslodging : (auth: GoogleApis.Common.OAuth2Client) => google.mybusinesslodging({ version : 'v1', auth }),
|
|
263
|
+
mybusinessnotifications : (auth: GoogleApis.Common.OAuth2Client) => google.mybusinessnotifications({ version : 'v1', auth }),
|
|
264
|
+
mybusinessplaceactions : (auth: GoogleApis.Common.OAuth2Client) => google.mybusinessplaceactions({ version : 'v1', auth }),
|
|
265
|
+
mybusinessqanda : (auth: GoogleApis.Common.OAuth2Client) => google.mybusinessqanda({ version : 'v1', auth }),
|
|
266
|
+
mybusinessverifications : (auth: GoogleApis.Common.OAuth2Client) => google.mybusinessverifications({ version : 'v1', auth }),
|
|
267
|
+
networkconnectivity : (auth: GoogleApis.Common.OAuth2Client) => google.networkconnectivity({ version : 'v1', auth }),
|
|
268
|
+
networkmanagement : (auth: GoogleApis.Common.OAuth2Client) => google.networkmanagement({ version : 'v1', auth }),
|
|
269
|
+
networksecurity : (auth: GoogleApis.Common.OAuth2Client) => google.networksecurity({ version : 'v1', auth }),
|
|
270
|
+
networkservices : (auth: GoogleApis.Common.OAuth2Client) => google.networkservices({ version : 'v1', auth }),
|
|
271
|
+
notebooks : (auth: GoogleApis.Common.OAuth2Client) => google.notebooks({ version : 'v1', auth }),
|
|
272
|
+
oauth2 : (auth: GoogleApis.Common.OAuth2Client) => google.oauth2({ version : 'v2', auth }),
|
|
273
|
+
ondemandscanning : (auth: GoogleApis.Common.OAuth2Client) => google.ondemandscanning({ version : 'v1', auth }),
|
|
274
|
+
orgpolicy : (auth: GoogleApis.Common.OAuth2Client) => google.orgpolicy({ version : 'v2', auth }),
|
|
275
|
+
osconfig : (auth: GoogleApis.Common.OAuth2Client) => google.osconfig({ version : 'v1', auth }),
|
|
276
|
+
oslogin : (auth: GoogleApis.Common.OAuth2Client) => google.oslogin({ version : 'v1', auth }),
|
|
277
|
+
pagespeedonline : (auth: GoogleApis.Common.OAuth2Client) => google.pagespeedonline({ version : 'v5', auth }),
|
|
278
|
+
paymentsresellersubscription : (auth: GoogleApis.Common.OAuth2Client) => google.paymentsresellersubscription({ version : 'v1', auth }),
|
|
279
|
+
people : (auth: GoogleApis.Common.OAuth2Client) => google.people({ version : 'v1', auth }),
|
|
280
|
+
playablelocations : (auth: GoogleApis.Common.OAuth2Client) => google.playablelocations({ version : 'v3', auth }),
|
|
281
|
+
playcustomapp : (auth: GoogleApis.Common.OAuth2Client) => google.playcustomapp({ version : 'v1', auth }),
|
|
282
|
+
playdeveloperreporting : (auth: GoogleApis.Common.OAuth2Client) => google.playdeveloperreporting({ version : 'v1alpha1', auth }),
|
|
283
|
+
playintegrity : (auth: GoogleApis.Common.OAuth2Client) => google.playintegrity({ version : 'v1', auth }),
|
|
284
|
+
plus : (auth: GoogleApis.Common.OAuth2Client) => google.plus({ version : 'v1', auth }),
|
|
285
|
+
policyanalyzer : (auth: GoogleApis.Common.OAuth2Client) => google.policyanalyzer({ version : 'v1', auth }),
|
|
286
|
+
policysimulator : (auth: GoogleApis.Common.OAuth2Client) => google.policysimulator({ version : 'v1', auth }),
|
|
287
|
+
policytroubleshooter : (auth: GoogleApis.Common.OAuth2Client) => google.policytroubleshooter({ version : 'v1', auth }),
|
|
288
|
+
poly : (auth: GoogleApis.Common.OAuth2Client) => google.poly({ version : 'v1', auth }),
|
|
289
|
+
privateca : (auth: GoogleApis.Common.OAuth2Client) => google.privateca({ version : 'v1', auth }),
|
|
290
|
+
// eslint-disable-next-line camelcase
|
|
291
|
+
prod_tt_sasportal : (auth: GoogleApis.Common.OAuth2Client) => google.prod_tt_sasportal({ version : 'v1alpha1', auth }),
|
|
292
|
+
publicca : (auth: GoogleApis.Common.OAuth2Client) => google.publicca({ version : 'v1alpha1', auth }),
|
|
293
|
+
pubsub : (auth: GoogleApis.Common.OAuth2Client) => google.pubsub({ version : 'v1', auth }),
|
|
294
|
+
pubsublite : (auth: GoogleApis.Common.OAuth2Client) => google.pubsublite({ version : 'v1', auth }),
|
|
295
|
+
readerrevenuesubscriptionlinking : (auth: GoogleApis.Common.OAuth2Client) => google.readerrevenuesubscriptionlinking({ version : 'v1', auth }),
|
|
296
|
+
realtimebidding : (auth: GoogleApis.Common.OAuth2Client) => google.realtimebidding({ version : 'v1', auth }),
|
|
297
|
+
recaptchaenterprise : (auth: GoogleApis.Common.OAuth2Client) => google.recaptchaenterprise({ version : 'v1', auth }),
|
|
298
|
+
recommendationengine : (auth: GoogleApis.Common.OAuth2Client) => google.recommendationengine({ version : 'v1beta1', auth }),
|
|
299
|
+
recommender : (auth: GoogleApis.Common.OAuth2Client) => google.recommender({ version : 'v1', auth }),
|
|
300
|
+
redis : (auth: GoogleApis.Common.OAuth2Client) => google.redis({ version : 'v1', auth }),
|
|
301
|
+
remotebuildexecution : (auth: GoogleApis.Common.OAuth2Client) => google.remotebuildexecution({ version : 'v1', auth }),
|
|
302
|
+
reseller : (auth: GoogleApis.Common.OAuth2Client) => google.reseller({ version : 'v1', auth }),
|
|
303
|
+
resourcesettings : (auth: GoogleApis.Common.OAuth2Client) => google.resourcesettings({ version : 'v1', auth }),
|
|
304
|
+
retail : (auth: GoogleApis.Common.OAuth2Client) => google.retail({ version : 'v2', auth }),
|
|
305
|
+
run : (auth: GoogleApis.Common.OAuth2Client) => google.run({ version : 'v1', auth }),
|
|
306
|
+
runtimeconfig : (auth: GoogleApis.Common.OAuth2Client) => google.runtimeconfig({ version : 'v1', auth }),
|
|
307
|
+
safebrowsing : (auth: GoogleApis.Common.OAuth2Client) => google.safebrowsing({ version : 'v4', auth }),
|
|
308
|
+
sasportal : (auth: GoogleApis.Common.OAuth2Client) => google.sasportal({ version : 'v1alpha1', auth }),
|
|
309
|
+
script : (auth: GoogleApis.Common.OAuth2Client) => google.script({ version : 'v1', auth }),
|
|
310
|
+
searchads360 : (auth: GoogleApis.Common.OAuth2Client) => google.searchads360({ version : 'v0', auth }),
|
|
311
|
+
searchconsole : (auth: GoogleApis.Common.OAuth2Client) => google.searchconsole({ version : 'v1', auth }),
|
|
312
|
+
secretmanager : (auth: GoogleApis.Common.OAuth2Client) => google.secretmanager({ version : 'v1', auth }),
|
|
313
|
+
securitycenter : (auth: GoogleApis.Common.OAuth2Client) => google.securitycenter({ version : 'v1', auth }),
|
|
314
|
+
serviceconsumermanagement : (auth: GoogleApis.Common.OAuth2Client) => google.serviceconsumermanagement({ version : 'v1', auth }),
|
|
315
|
+
servicecontrol : (auth: GoogleApis.Common.OAuth2Client) => google.servicecontrol({ version : 'v1', auth }),
|
|
316
|
+
servicedirectory : (auth: GoogleApis.Common.OAuth2Client) => google.servicedirectory({ version : 'v1', auth }),
|
|
317
|
+
servicemanagement : (auth: GoogleApis.Common.OAuth2Client) => google.servicemanagement({ version : 'v1', auth }),
|
|
318
|
+
servicenetworking : (auth: GoogleApis.Common.OAuth2Client) => google.servicenetworking({ version : 'v1', auth }),
|
|
319
|
+
serviceusage : (auth: GoogleApis.Common.OAuth2Client) => google.serviceusage({ version : 'v1', auth }),
|
|
320
|
+
sheets : (auth: GoogleApis.Common.OAuth2Client) => google.sheets({ version : 'v4', auth }),
|
|
321
|
+
siteVerification : (auth: GoogleApis.Common.OAuth2Client) => google.siteVerification({ version : 'v1', auth }),
|
|
322
|
+
slides : (auth: GoogleApis.Common.OAuth2Client) => google.slides({ version : 'v1', auth }),
|
|
323
|
+
smartdevicemanagement : (auth: GoogleApis.Common.OAuth2Client) => google.smartdevicemanagement({ version : 'v1', auth }),
|
|
324
|
+
sourcerepo : (auth: GoogleApis.Common.OAuth2Client) => google.sourcerepo({ version : 'v1', auth }),
|
|
325
|
+
spanner : (auth: GoogleApis.Common.OAuth2Client) => google.spanner({ version : 'v1', auth }),
|
|
326
|
+
speech : (auth: GoogleApis.Common.OAuth2Client) => google.speech({ version : 'v1', auth }),
|
|
327
|
+
sql : (auth: GoogleApis.Common.OAuth2Client) => google.sql({ version : 'v1beta4', auth }),
|
|
328
|
+
sqladmin : (auth: GoogleApis.Common.OAuth2Client) => google.sqladmin({ version : 'v1', auth }),
|
|
329
|
+
storage : (auth: GoogleApis.Common.OAuth2Client) => google.storage({ version : 'v1', auth }),
|
|
330
|
+
storagetransfer : (auth: GoogleApis.Common.OAuth2Client) => google.storagetransfer({ version : 'v1', auth }),
|
|
331
|
+
streetviewpublish : (auth: GoogleApis.Common.OAuth2Client) => google.streetviewpublish({ version : 'v1', auth }),
|
|
332
|
+
sts : (auth: GoogleApis.Common.OAuth2Client) => google.sts({ version : 'v1', auth }),
|
|
333
|
+
tagmanager : (auth: GoogleApis.Common.OAuth2Client) => google.tagmanager({ version : 'v1', auth }),
|
|
334
|
+
tasks : (auth: GoogleApis.Common.OAuth2Client) => google.tasks({ version : 'v1', auth }),
|
|
335
|
+
testing : (auth: GoogleApis.Common.OAuth2Client) => google.testing({ version : 'v1', auth }),
|
|
336
|
+
texttospeech : (auth: GoogleApis.Common.OAuth2Client) => google.texttospeech({ version : 'v1', auth }),
|
|
337
|
+
toolresults : (auth: GoogleApis.Common.OAuth2Client) => google.toolresults({ version : 'v1beta3', auth }),
|
|
338
|
+
tpu : (auth: GoogleApis.Common.OAuth2Client) => google.tpu({ version : 'v1', auth }),
|
|
339
|
+
trafficdirector : (auth: GoogleApis.Common.OAuth2Client) => google.trafficdirector({ version : 'v2', auth }),
|
|
340
|
+
transcoder : (auth: GoogleApis.Common.OAuth2Client) => google.transcoder({ version : 'v1', auth }),
|
|
341
|
+
translate : (auth: GoogleApis.Common.OAuth2Client) => google.translate({ version : 'v2', auth }),
|
|
342
|
+
travelimpactmodel : (auth: GoogleApis.Common.OAuth2Client) => google.travelimpactmodel({ version : 'v1', auth }),
|
|
343
|
+
vault : (auth: GoogleApis.Common.OAuth2Client) => google.vault({ version : 'v1', auth }),
|
|
344
|
+
vectortile : (auth: GoogleApis.Common.OAuth2Client) => google.vectortile({ version : 'v1', auth }),
|
|
345
|
+
verifiedaccess : (auth: GoogleApis.Common.OAuth2Client) => google.verifiedaccess({ version : 'v1', auth }),
|
|
346
|
+
versionhistory : (auth: GoogleApis.Common.OAuth2Client) => google.versionhistory({ version : 'v1', auth }),
|
|
347
|
+
videointelligence : (auth: GoogleApis.Common.OAuth2Client) => google.videointelligence({ version : 'v1', auth }),
|
|
348
|
+
vision : (auth: GoogleApis.Common.OAuth2Client) => google.vision({ version : 'v1', auth }),
|
|
349
|
+
vmmigration : (auth: GoogleApis.Common.OAuth2Client) => google.vmmigration({ version : 'v1', auth }),
|
|
350
|
+
vpcaccess : (auth: GoogleApis.Common.OAuth2Client) => google.vpcaccess({ version : 'v1', auth }),
|
|
351
|
+
webfonts : (auth: GoogleApis.Common.OAuth2Client) => google.webfonts({ version : 'v1', auth }),
|
|
352
|
+
webmasters : (auth: GoogleApis.Common.OAuth2Client) => google.webmasters({ version : 'v3', auth }),
|
|
353
|
+
webrisk : (auth: GoogleApis.Common.OAuth2Client) => google.webrisk({ version : 'v1', auth }),
|
|
354
|
+
websecurityscanner : (auth: GoogleApis.Common.OAuth2Client) => google.websecurityscanner({ version : 'v1', auth }),
|
|
355
|
+
workflowexecutions : (auth: GoogleApis.Common.OAuth2Client) => google.workflowexecutions({ version : 'v1', auth }),
|
|
356
|
+
workflows : (auth: GoogleApis.Common.OAuth2Client) => google.workflows({ version : 'v1', auth }),
|
|
357
|
+
workloadmanager : (auth: GoogleApis.Common.OAuth2Client) => google.workloadmanager({ version : 'v1', auth }),
|
|
358
|
+
workstations : (auth: GoogleApis.Common.OAuth2Client) => google.workstations({ version : 'v1beta', auth }),
|
|
359
|
+
youtube : (auth: GoogleApis.Common.OAuth2Client) => google.youtube({ version : 'v3', auth }),
|
|
360
|
+
youtubeAnalytics : (auth: GoogleApis.Common.OAuth2Client) => google.youtubeAnalytics({ version : 'v1', auth }),
|
|
361
|
+
youtubereporting : (auth: GoogleApis.Common.OAuth2Client) => google.youtubereporting({ version : 'v1', auth }),
|
|
362
|
+
} as const;
|
|
363
|
+
|
|
364
|
+
export { getApi };
|
|
365
|
+
export default { getApi, Api };
|
package/src/lib/secrets.ts
CHANGED
|
@@ -10,13 +10,15 @@ import { getScopesFile, getSecretsFile, getCredentialsFile } from './paths';
|
|
|
10
10
|
|
|
11
11
|
import secrets from './secrets';
|
|
12
12
|
|
|
13
|
-
export { getSecrets, getCredentials };
|
|
14
|
-
export default { getScopes, getSecrets, getCredentials, validateCredentials, createCredentials, checkSecrets, getSecretsError, getScopesError };
|
|
13
|
+
export { getSecrets, getCredentials, deleteCredentials };
|
|
14
|
+
export default { getScopes, getSecrets, getCredentials, validateCredentials, createCredentials, deleteCredentials, checkSecrets, getSecretsError, getScopesError };
|
|
15
15
|
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
const
|
|
19
|
-
const
|
|
16
|
+
const port = 6006;
|
|
17
|
+
const host = `localhost:${port}`;
|
|
18
|
+
const startURI = `http://${host}/`;
|
|
19
|
+
const callbackURI = `http://${host}/oauthcallback`;
|
|
20
|
+
const tokenExpiration = 7 * 24 * 60 * 60 * 1000;
|
|
21
|
+
const serverRetryInterval = 1000;
|
|
20
22
|
|
|
21
23
|
function getScopes(): string[] {
|
|
22
24
|
const scopesFile = getScopesFile();
|
|
@@ -81,7 +83,10 @@ async function createCredentials(profile: string, auth: GoogleApis.Auth.OAuth2Cl
|
|
|
81
83
|
scope,
|
|
82
84
|
});
|
|
83
85
|
|
|
84
|
-
const server = http.createServer(
|
|
86
|
+
const server = http.createServer();
|
|
87
|
+
enableDestroy(server);
|
|
88
|
+
|
|
89
|
+
server.on('request', async (request, response) => {
|
|
85
90
|
if (!request.url) {
|
|
86
91
|
response.end('');
|
|
87
92
|
return;
|
|
@@ -102,13 +107,31 @@ async function createCredentials(profile: string, auth: GoogleApis.Auth.OAuth2Cl
|
|
|
102
107
|
resolve(tokens);
|
|
103
108
|
});
|
|
104
109
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
110
|
+
server.on('error', (error: NodeJS.ErrnoException) => {
|
|
111
|
+
if (error.code === 'EADDRINUSE') {
|
|
112
|
+
setTimeout(() => server.listen(port), serverRetryInterval);
|
|
113
|
+
} else {
|
|
114
|
+
throw error;
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
server.once('listening', () => {
|
|
119
|
+
warn('Please check your browser for further actions');
|
|
120
|
+
open(startURI);
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
server.listen(port);
|
|
109
124
|
});
|
|
110
125
|
}
|
|
111
126
|
|
|
127
|
+
function deleteCredentials(profile: string): void {
|
|
128
|
+
const credentialsFile = getCredentialsFile(profile);
|
|
129
|
+
|
|
130
|
+
if (fs.existsSync(credentialsFile)) {
|
|
131
|
+
fs.rmSync(credentialsFile);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
112
135
|
function formatMessage(message: string): string {
|
|
113
136
|
return [
|
|
114
137
|
'<div style="width: 100%;height: 100%;display: flex;align-items: start;justify-content: center">',
|
package/tsconfig.json
CHANGED
package/dist/lib/api/calendar.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getAPI = void 0;
|
|
4
|
-
const googleapis_1 = require("googleapis");
|
|
5
|
-
const auth_1 = require("../auth");
|
|
6
|
-
async function getAPI(profile, options) {
|
|
7
|
-
const googleAuth = await (0, auth_1.getAuth)(profile, options);
|
|
8
|
-
return googleapis_1.google.calendar({
|
|
9
|
-
version: 'v3',
|
|
10
|
-
auth: googleAuth,
|
|
11
|
-
});
|
|
12
|
-
}
|
|
13
|
-
exports.getAPI = getAPI;
|
|
14
|
-
//# sourceMappingURL=calendar.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"calendar.js","sourceRoot":"","sources":["../../../src/lib/api/calendar.ts"],"names":[],"mappings":";;;AAAA,2CAAoC;AAGpC,kCAAkC;AAE3B,KAAK,UAAU,MAAM,CAAC,OAAe,EAAE,OAAqB;IAClE,MAAM,UAAU,GAAG,MAAM,IAAA,cAAO,EAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAEnD,OAAO,mBAAM,CAAC,QAAQ,CAAC;QACtB,OAAO,EAAG,IAAI;QACd,IAAI,EAAM,UAAU;KACpB,CAAC,CAAC;AACJ,CAAC;AAPD,wBAOC"}
|
package/dist/lib/api/shared.d.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import type GoogleApis from 'googleapis';
|
|
2
|
-
import type { CommonOptions } from '../../types';
|
|
3
|
-
export { getItems };
|
|
4
|
-
declare const _default: {
|
|
5
|
-
getItems: typeof getItems;
|
|
6
|
-
};
|
|
7
|
-
export default _default;
|
|
8
|
-
type CommonApi<TItem> = {
|
|
9
|
-
list: {
|
|
10
|
-
(params?: {
|
|
11
|
-
pageToken: string | undefined;
|
|
12
|
-
}, options?: GoogleApis.Common.MethodOptions): Promise<GoogleApis.Common.GaxiosResponse<CommonResponse<TItem>>>;
|
|
13
|
-
(callback: (err: Error | null, res?: GoogleApis.Common.GaxiosResponse<CommonResponse<TItem>> | null) => void): void;
|
|
14
|
-
};
|
|
15
|
-
};
|
|
16
|
-
type CommonResponse<TItem> = {
|
|
17
|
-
items?: TItem[];
|
|
18
|
-
pageInfo?: {
|
|
19
|
-
totalResults?: number | null | undefined;
|
|
20
|
-
};
|
|
21
|
-
nextPageToken?: string | null | undefined;
|
|
22
|
-
};
|
|
23
|
-
declare function getItems<TItem>(api: CommonApi<TItem>, params: any, options?: CommonOptions): Promise<TItem[]>;
|
package/dist/lib/api/shared.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.getItems = void 0;
|
|
7
|
-
const logger_1 = require("@anmiles/logger");
|
|
8
|
-
const sleep_1 = __importDefault(require("@anmiles/sleep"));
|
|
9
|
-
exports.default = { getItems };
|
|
10
|
-
const requestInterval = 300;
|
|
11
|
-
async function getItems(api, params, options) {
|
|
12
|
-
var _a, _b;
|
|
13
|
-
const items = [];
|
|
14
|
-
let pageToken = undefined;
|
|
15
|
-
do {
|
|
16
|
-
const response = await api.list({ ...params, pageToken });
|
|
17
|
-
(_a = response.data.items) === null || _a === void 0 ? void 0 : _a.forEach((item) => items.push(item));
|
|
18
|
-
if (!(options === null || options === void 0 ? void 0 : options.hideProgress)) {
|
|
19
|
-
(0, logger_1.log)(`Getting items (${items.length} of ${((_b = response.data.pageInfo) === null || _b === void 0 ? void 0 : _b.totalResults) || 'many'})...`);
|
|
20
|
-
}
|
|
21
|
-
await (0, sleep_1.default)(requestInterval);
|
|
22
|
-
pageToken = response.data.nextPageToken;
|
|
23
|
-
} while (pageToken);
|
|
24
|
-
return items;
|
|
25
|
-
}
|
|
26
|
-
exports.getItems = getItems;
|
|
27
|
-
//# sourceMappingURL=shared.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"shared.js","sourceRoot":"","sources":["../../../src/lib/api/shared.ts"],"names":[],"mappings":";;;;;;AACA,4CAAsC;AACtC,2DAAmC;AAInC,kBAAe,EAAE,QAAQ,EAAE,CAAC;AAE5B,MAAM,eAAe,GAAG,GAAG,CAAC;AAiB5B,KAAK,UAAU,QAAQ,CAAQ,GAAqB,EAAE,MAAW,EAAE,OAAuB;;IACzF,MAAM,KAAK,GAAY,EAAE,CAAC;IAE1B,IAAI,SAAS,GAA8B,SAAS,CAAC;IAErD,GAAG;QACF,MAAM,QAAQ,GAA4D,MAAM,GAAG,CAAC,IAAI,CAAC,EAAE,GAAG,MAAM,EAAE,SAAS,EAAE,CAAC,CAAC;QACnH,MAAA,QAAQ,CAAC,IAAI,CAAC,KAAK,0CAAE,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QAEzD,IAAI,CAAC,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,YAAY,CAAA,EAAE;YAC3B,IAAA,YAAG,EAAC,kBAAkB,KAAK,CAAC,MAAM,OAAO,CAAA,MAAA,QAAQ,CAAC,IAAI,CAAC,QAAQ,0CAAE,YAAY,KAAI,MAAM,MAAM,CAAC,CAAC;SAC/F;QAED,MAAM,IAAA,eAAK,EAAC,eAAe,CAAC,CAAC;QAC7B,SAAS,GAAG,QAAQ,CAAC,IAAI,CAAC,aAAa,CAAC;KACxC,QAAQ,SAAS,EAAE;IAEpB,OAAO,KAAK,CAAC;AACd,CAAC;AAtCQ,4BAAQ"}
|
package/dist/lib/api/youtube.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getAPI = void 0;
|
|
4
|
-
const googleapis_1 = require("googleapis");
|
|
5
|
-
const auth_1 = require("../auth");
|
|
6
|
-
async function getAPI(profile, options) {
|
|
7
|
-
const googleAuth = await (0, auth_1.getAuth)(profile, options);
|
|
8
|
-
return googleapis_1.google.youtube({
|
|
9
|
-
version: 'v3',
|
|
10
|
-
auth: googleAuth,
|
|
11
|
-
});
|
|
12
|
-
}
|
|
13
|
-
exports.getAPI = getAPI;
|
|
14
|
-
//# sourceMappingURL=youtube.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"youtube.js","sourceRoot":"","sources":["../../../src/lib/api/youtube.ts"],"names":[],"mappings":";;;AAAA,2CAAoC;AAGpC,kCAAkC;AAE3B,KAAK,UAAU,MAAM,CAAC,OAAe,EAAE,OAAqB;IAClE,MAAM,UAAU,GAAG,MAAM,IAAA,cAAO,EAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAEnD,OAAO,mBAAM,CAAC,OAAO,CAAC;QACrB,OAAO,EAAG,IAAI;QACd,IAAI,EAAM,UAAU;KACpB,CAAC,CAAC;AACJ,CAAC;AAPD,wBAOC"}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { google } from 'googleapis';
|
|
2
|
-
import auth from '../../auth';
|
|
3
|
-
import { getAPI } from '../calendar';
|
|
4
|
-
|
|
5
|
-
jest.mock('googleapis', () => ({
|
|
6
|
-
google : {
|
|
7
|
-
calendar : jest.fn().mockImplementation(() => api),
|
|
8
|
-
},
|
|
9
|
-
}));
|
|
10
|
-
|
|
11
|
-
jest.mock<Partial<typeof auth>>('../../auth', () => ({
|
|
12
|
-
getAuth : jest.fn().mockImplementation(() => googleAuth),
|
|
13
|
-
}));
|
|
14
|
-
|
|
15
|
-
const profile = 'username';
|
|
16
|
-
const api = 'api';
|
|
17
|
-
const googleAuth = 'googleAuth';
|
|
18
|
-
|
|
19
|
-
describe('src/lib/api/calendar', () => {
|
|
20
|
-
describe('getAPI', () => {
|
|
21
|
-
it('should call getAuth', async () => {
|
|
22
|
-
await getAPI(profile);
|
|
23
|
-
|
|
24
|
-
expect(auth.getAuth).toHaveBeenCalledWith(profile, undefined);
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
it('should pass temporariness', async () => {
|
|
28
|
-
await getAPI(profile, { temporary : true });
|
|
29
|
-
|
|
30
|
-
expect(auth.getAuth).toHaveBeenCalledWith(profile, { temporary : true });
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
it('should get calendar api', async () => {
|
|
34
|
-
await getAPI(profile);
|
|
35
|
-
|
|
36
|
-
expect(google.calendar).toHaveBeenCalledWith({ version : 'v3', auth : googleAuth });
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
it('should return calendar api', async () => {
|
|
40
|
-
const result = await getAPI(profile);
|
|
41
|
-
|
|
42
|
-
expect(result).toEqual(api);
|
|
43
|
-
});
|
|
44
|
-
});
|
|
45
|
-
});
|