@maxim_mazurok/gapi.client.dataportability-v1 0.0.20240308

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 (3) hide show
  1. package/index.d.ts +260 -0
  2. package/package.json +20 -0
  3. package/readme.md +198 -0
package/index.d.ts ADDED
@@ -0,0 +1,260 @@
1
+ /* Type definitions for non-npm package Data Portability API v1 0.0 */
2
+ // Project: https://developers.google.com/data-portability
3
+ // Definitions by: Maxim Mazurok <https://github.com/Maxim-Mazurok>
4
+ // Nick Amoscato <https://github.com/namoscato>
5
+ // Declan Vong <https://github.com/declanvong>
6
+ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
7
+
8
+ // IMPORTANT
9
+ // This file was generated by https://github.com/Maxim-Mazurok/google-api-typings-generator. Please do not edit it manually.
10
+ // In case of any problems please post issue to https://github.com/Maxim-Mazurok/google-api-typings-generator
11
+ // Generated from: https://dataportability.googleapis.com/$discovery/rest?version=v1
12
+ // Revision: 20240308
13
+
14
+ /// <reference types="gapi.client" />
15
+
16
+ declare namespace gapi.client {
17
+ /** Load Data Portability API v1 */
18
+ function load(
19
+ urlOrObject: 'https://dataportability.googleapis.com/$discovery/rest?version=v1'
20
+ ): Promise<void>;
21
+ /** @deprecated Please load APIs with discovery documents. */
22
+ function load(name: 'dataportability', version: 'v1'): Promise<void>;
23
+ /** @deprecated Please load APIs with discovery documents. */
24
+ function load(
25
+ name: 'dataportability',
26
+ version: 'v1',
27
+ callback: () => any
28
+ ): void;
29
+
30
+ namespace dataportability {
31
+ interface Empty {}
32
+ interface InitiatePortabilityArchiveRequest {
33
+ /** The resources from which you're exporting data. These values have a 1:1 correspondence with the OAuth scopes. */
34
+ resources?: string[];
35
+ }
36
+ interface InitiatePortabilityArchiveResponse {
37
+ /** The archive job ID that is initiated in the API. This can be used to get the state of the job. */
38
+ archiveJobId?: string;
39
+ }
40
+ interface PortabilityArchiveState {
41
+ /** The resource name of ArchiveJob's PortabilityArchiveState singleton. The format is: archiveJobs/{archive_job}/portabilityArchiveState. archive_job is the job ID provided in the request. */
42
+ name?: string;
43
+ /** Resource that represents the state of the Archive job. */
44
+ state?: string;
45
+ /** If the state is complete, this method returns the signed URLs of the objects in the Cloud Storage bucket. */
46
+ urls?: string[];
47
+ }
48
+ interface ResetAuthorizationRequest {}
49
+ interface RetryPortabilityArchiveRequest {}
50
+ interface RetryPortabilityArchiveResponse {
51
+ /** The archive job ID that is initiated by the retry endpoint. This can be used to get the state of the new job. */
52
+ archiveJobId?: string;
53
+ }
54
+ interface ArchiveJobsResource {
55
+ /** Retrieves the state of an Archive job for the Portability API. */
56
+ getPortabilityArchiveState(request?: {
57
+ /** V1 error format. */
58
+ '$.xgafv'?: string;
59
+ /** OAuth access token. */
60
+ access_token?: string;
61
+ /** Data format for response. */
62
+ alt?: string;
63
+ /** JSONP */
64
+ callback?: string;
65
+ /** Selector specifying which fields to include in a partial response. */
66
+ fields?: string;
67
+ /** API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. */
68
+ key?: string;
69
+ /** Required. The archive job ID that is returned when you request the state of the job. The format is: archiveJobs/{archive_job}/portabilityArchiveState. archive_job is the job ID returned by the InitiatePortabilityArchiveResponse. */
70
+ name: string;
71
+ /** OAuth 2.0 token for the current user. */
72
+ oauth_token?: string;
73
+ /** Returns response with indentations and line breaks. */
74
+ prettyPrint?: boolean;
75
+ /** Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. */
76
+ quotaUser?: string;
77
+ /** Upload protocol for media (e.g. "raw", "multipart"). */
78
+ upload_protocol?: string;
79
+ /** Legacy upload protocol for media (e.g. "media", "multipart"). */
80
+ uploadType?: string;
81
+ }): Request<PortabilityArchiveState>;
82
+ /** Retries a failed Portability Archive job. */
83
+ retry(request: {
84
+ /** V1 error format. */
85
+ '$.xgafv'?: string;
86
+ /** OAuth access token. */
87
+ access_token?: string;
88
+ /** Data format for response. */
89
+ alt?: string;
90
+ /** JSONP */
91
+ callback?: string;
92
+ /** Selector specifying which fields to include in a partial response. */
93
+ fields?: string;
94
+ /** API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. */
95
+ key?: string;
96
+ /** Required. The Archive job ID you're retrying. This is returned by the InitiatePortabilityArchiveResponse. Retrying is only executed if the initial job failed. */
97
+ name: string;
98
+ /** OAuth 2.0 token for the current user. */
99
+ oauth_token?: string;
100
+ /** Returns response with indentations and line breaks. */
101
+ prettyPrint?: boolean;
102
+ /** Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. */
103
+ quotaUser?: string;
104
+ /** Upload protocol for media (e.g. "raw", "multipart"). */
105
+ upload_protocol?: string;
106
+ /** Legacy upload protocol for media (e.g. "media", "multipart"). */
107
+ uploadType?: string;
108
+ /** Request body */
109
+ resource: RetryPortabilityArchiveRequest;
110
+ }): Request<RetryPortabilityArchiveResponse>;
111
+ retry(
112
+ request: {
113
+ /** V1 error format. */
114
+ '$.xgafv'?: string;
115
+ /** OAuth access token. */
116
+ access_token?: string;
117
+ /** Data format for response. */
118
+ alt?: string;
119
+ /** JSONP */
120
+ callback?: string;
121
+ /** Selector specifying which fields to include in a partial response. */
122
+ fields?: string;
123
+ /** API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. */
124
+ key?: string;
125
+ /** Required. The Archive job ID you're retrying. This is returned by the InitiatePortabilityArchiveResponse. Retrying is only executed if the initial job failed. */
126
+ name: string;
127
+ /** OAuth 2.0 token for the current user. */
128
+ oauth_token?: string;
129
+ /** Returns response with indentations and line breaks. */
130
+ prettyPrint?: boolean;
131
+ /** Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. */
132
+ quotaUser?: string;
133
+ /** Upload protocol for media (e.g. "raw", "multipart"). */
134
+ upload_protocol?: string;
135
+ /** Legacy upload protocol for media (e.g. "media", "multipart"). */
136
+ uploadType?: string;
137
+ },
138
+ body: RetryPortabilityArchiveRequest
139
+ ): Request<RetryPortabilityArchiveResponse>;
140
+ }
141
+ interface AuthorizationResource {
142
+ /** Revokes OAuth tokens and resets exhausted scopes for a user/project pair. This method allows you to initiate a request after a new consent is granted. This method also indicates that previous archives can be garbage collected. You should call this method when all jobs are complete and all archives are downloaded. Do not call it only when you start a new job. */
143
+ reset(request: {
144
+ /** V1 error format. */
145
+ '$.xgafv'?: string;
146
+ /** OAuth access token. */
147
+ access_token?: string;
148
+ /** Data format for response. */
149
+ alt?: string;
150
+ /** JSONP */
151
+ callback?: string;
152
+ /** Selector specifying which fields to include in a partial response. */
153
+ fields?: string;
154
+ /** API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. */
155
+ key?: string;
156
+ /** OAuth 2.0 token for the current user. */
157
+ oauth_token?: string;
158
+ /** Returns response with indentations and line breaks. */
159
+ prettyPrint?: boolean;
160
+ /** Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. */
161
+ quotaUser?: string;
162
+ /** Upload protocol for media (e.g. "raw", "multipart"). */
163
+ upload_protocol?: string;
164
+ /** Legacy upload protocol for media (e.g. "media", "multipart"). */
165
+ uploadType?: string;
166
+ /** Request body */
167
+ resource: ResetAuthorizationRequest;
168
+ }): Request<{}>;
169
+ reset(
170
+ request: {
171
+ /** V1 error format. */
172
+ '$.xgafv'?: string;
173
+ /** OAuth access token. */
174
+ access_token?: string;
175
+ /** Data format for response. */
176
+ alt?: string;
177
+ /** JSONP */
178
+ callback?: string;
179
+ /** Selector specifying which fields to include in a partial response. */
180
+ fields?: string;
181
+ /** API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. */
182
+ key?: string;
183
+ /** OAuth 2.0 token for the current user. */
184
+ oauth_token?: string;
185
+ /** Returns response with indentations and line breaks. */
186
+ prettyPrint?: boolean;
187
+ /** Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. */
188
+ quotaUser?: string;
189
+ /** Upload protocol for media (e.g. "raw", "multipart"). */
190
+ upload_protocol?: string;
191
+ /** Legacy upload protocol for media (e.g. "media", "multipart"). */
192
+ uploadType?: string;
193
+ },
194
+ body: ResetAuthorizationRequest
195
+ ): Request<{}>;
196
+ }
197
+ interface PortabilityArchiveResource {
198
+ /** Initiates a new Archive job for the Portability API. */
199
+ initiate(request: {
200
+ /** V1 error format. */
201
+ '$.xgafv'?: string;
202
+ /** OAuth access token. */
203
+ access_token?: string;
204
+ /** Data format for response. */
205
+ alt?: string;
206
+ /** JSONP */
207
+ callback?: string;
208
+ /** Selector specifying which fields to include in a partial response. */
209
+ fields?: string;
210
+ /** API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. */
211
+ key?: string;
212
+ /** OAuth 2.0 token for the current user. */
213
+ oauth_token?: string;
214
+ /** Returns response with indentations and line breaks. */
215
+ prettyPrint?: boolean;
216
+ /** Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. */
217
+ quotaUser?: string;
218
+ /** Upload protocol for media (e.g. "raw", "multipart"). */
219
+ upload_protocol?: string;
220
+ /** Legacy upload protocol for media (e.g. "media", "multipart"). */
221
+ uploadType?: string;
222
+ /** Request body */
223
+ resource: InitiatePortabilityArchiveRequest;
224
+ }): Request<InitiatePortabilityArchiveResponse>;
225
+ initiate(
226
+ request: {
227
+ /** V1 error format. */
228
+ '$.xgafv'?: string;
229
+ /** OAuth access token. */
230
+ access_token?: string;
231
+ /** Data format for response. */
232
+ alt?: string;
233
+ /** JSONP */
234
+ callback?: string;
235
+ /** Selector specifying which fields to include in a partial response. */
236
+ fields?: string;
237
+ /** API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. */
238
+ key?: string;
239
+ /** OAuth 2.0 token for the current user. */
240
+ oauth_token?: string;
241
+ /** Returns response with indentations and line breaks. */
242
+ prettyPrint?: boolean;
243
+ /** Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. */
244
+ quotaUser?: string;
245
+ /** Upload protocol for media (e.g. "raw", "multipart"). */
246
+ upload_protocol?: string;
247
+ /** Legacy upload protocol for media (e.g. "media", "multipart"). */
248
+ uploadType?: string;
249
+ },
250
+ body: InitiatePortabilityArchiveRequest
251
+ ): Request<InitiatePortabilityArchiveResponse>;
252
+ }
253
+
254
+ const archiveJobs: ArchiveJobsResource;
255
+
256
+ const authorization: AuthorizationResource;
257
+
258
+ const portabilityArchive: PortabilityArchiveResource;
259
+ }
260
+ }
package/package.json ADDED
@@ -0,0 +1,20 @@
1
+ {
2
+ "name": "@maxim_mazurok/gapi.client.dataportability-v1",
3
+ "version": "0.0.20240308",
4
+ "description": "TypeScript typings for Data Portability API v1",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "https://github.com/Maxim-Mazurok/google-api-typings-generator.git"
8
+ },
9
+ "license": "MIT",
10
+ "author": {
11
+ "name": "Maxim Mazurok",
12
+ "email": "maxim@mazurok.com",
13
+ "url": "https://maxim.mazurok.com"
14
+ },
15
+ "types": "index.d.ts",
16
+ "dependencies": {
17
+ "@types/gapi.client": "*",
18
+ "@types/gapi.client.discovery-v1": "*"
19
+ }
20
+ }
package/readme.md ADDED
@@ -0,0 +1,198 @@
1
+ # TypeScript typings for Data Portability API v1
2
+
3
+ The Data Portability API lets you build applications that request authorization from a user to move a copy of data from Google services into your application. This enables data portability and facilitates switching services.
4
+ For detailed description please check [documentation](https://developers.google.com/data-portability).
5
+
6
+ ## Installing
7
+
8
+ Install typings for Data Portability API:
9
+
10
+ ```
11
+ npm install @types/gapi.client.dataportability-v1 --save-dev
12
+ ```
13
+
14
+ ## Usage
15
+
16
+ You need to initialize Google API client in your code:
17
+
18
+ ```typescript
19
+ gapi.load('client', () => {
20
+ // now we can use gapi.client
21
+ // ...
22
+ });
23
+ ```
24
+
25
+ Then load api client wrapper:
26
+
27
+ ```typescript
28
+ gapi.client.load(
29
+ 'https://dataportability.googleapis.com/$discovery/rest?version=v1',
30
+ () => {
31
+ // now we can use:
32
+ // gapi.client.dataportability
33
+ }
34
+ );
35
+ ```
36
+
37
+ ```typescript
38
+ // Deprecated, use discovery document URL, see https://github.com/google/google-api-javascript-client/blob/master/docs/reference.md#----gapiclientloadname----version----callback--
39
+ gapi.client.load('dataportability', 'v1', () => {
40
+ // now we can use:
41
+ // gapi.client.dataportability
42
+ });
43
+ ```
44
+
45
+ Don't forget to authenticate your client before sending any request to resources:
46
+
47
+ ```typescript
48
+ // declare client_id registered in Google Developers Console
49
+ var client_id = '',
50
+ scope = [
51
+ // Move a copy of messages between you and the businesses you have conversations with across Google services.
52
+ 'https://www.googleapis.com/auth/dataportability.businessmessaging.conversations',
53
+
54
+ // Move a copy of the information you entered into online forms in Chrome.
55
+ 'https://www.googleapis.com/auth/dataportability.chrome.autofill',
56
+
57
+ // Move a copy of pages you bookmarked in Chrome.
58
+ 'https://www.googleapis.com/auth/dataportability.chrome.bookmarks',
59
+
60
+ // Move a copy of words you added to Chrome's dictionary.
61
+ 'https://www.googleapis.com/auth/dataportability.chrome.dictionary',
62
+
63
+ // Move a copy of extensions you installed from the Chrome Web Store.
64
+ 'https://www.googleapis.com/auth/dataportability.chrome.extensions',
65
+
66
+ // Move a copy of sites you visited in Chrome.
67
+ 'https://www.googleapis.com/auth/dataportability.chrome.history',
68
+
69
+ // Move a copy of pages you added to your reading list in Chrome.
70
+ 'https://www.googleapis.com/auth/dataportability.chrome.reading_list',
71
+
72
+ // Move a copy of your settings in Chrome.
73
+ 'https://www.googleapis.com/auth/dataportability.chrome.settings',
74
+
75
+ // Move a copy of your pinned trips on Maps.
76
+ 'https://www.googleapis.com/auth/dataportability.maps.commute_routes',
77
+
78
+ // Move a copy of your commute settings on Maps.
79
+ 'https://www.googleapis.com/auth/dataportability.maps.commute_settings',
80
+
81
+ // Move a copy of your electric vehicle profile on Maps.
82
+ 'https://www.googleapis.com/auth/dataportability.maps.ev_profile',
83
+
84
+ // Move a copy of your updates to places on Maps.
85
+ 'https://www.googleapis.com/auth/dataportability.maps.offering_contributions',
86
+
87
+ // Move a copy of the photos and videos you posted on Maps.
88
+ 'https://www.googleapis.com/auth/dataportability.maps.photos_videos',
89
+
90
+ // Move a copy of your reviews and posts on Maps.
91
+ 'https://www.googleapis.com/auth/dataportability.maps.reviews',
92
+
93
+ // Move a copy of your Starred places list on Maps.
94
+ 'https://www.googleapis.com/auth/dataportability.maps.starred_places',
95
+
96
+ // Move a copy of your Maps activity.
97
+ 'https://www.googleapis.com/auth/dataportability.myactivity.maps',
98
+
99
+ // Move a copy of your Google Search activity.
100
+ 'https://www.googleapis.com/auth/dataportability.myactivity.search',
101
+
102
+ // Move a copy of your Shopping activity.
103
+ 'https://www.googleapis.com/auth/dataportability.myactivity.shopping',
104
+
105
+ // Move a copy of your YouTube activity.
106
+ 'https://www.googleapis.com/auth/dataportability.myactivity.youtube',
107
+
108
+ // Move a copy of your saved links, images, places, and collections from your use of Google services.
109
+ 'https://www.googleapis.com/auth/dataportability.saved.collections',
110
+
111
+ // Move a copy of your shipping information on Shopping.
112
+ 'https://www.googleapis.com/auth/dataportability.shopping.addresses',
113
+
114
+ // Move a copy of reviews you wrote about products or online stores on Google Search.
115
+ 'https://www.googleapis.com/auth/dataportability.shopping.reviews',
116
+
117
+ // Move a copy of information about your YouTube channel.
118
+ 'https://www.googleapis.com/auth/dataportability.youtube.channel',
119
+
120
+ // Move a copy of your YouTube comments.
121
+ 'https://www.googleapis.com/auth/dataportability.youtube.comments',
122
+
123
+ // Move a copy of your YouTube messages in live chat.
124
+ 'https://www.googleapis.com/auth/dataportability.youtube.live_chat',
125
+
126
+ // Move a copy of your uploaded YouTube music tracks and your YouTube music library.
127
+ 'https://www.googleapis.com/auth/dataportability.youtube.music',
128
+
129
+ // Move a copy of your YouTube playables saved game progress files.
130
+ 'https://www.googleapis.com/auth/dataportability.youtube.playable',
131
+
132
+ // Move a copy of your YouTube posts.
133
+ 'https://www.googleapis.com/auth/dataportability.youtube.posts',
134
+
135
+ // Move a copy of your YouTube private playlists.
136
+ 'https://www.googleapis.com/auth/dataportability.youtube.private_playlists',
137
+
138
+ // Move a copy of your private YouTube videos and information about them.
139
+ 'https://www.googleapis.com/auth/dataportability.youtube.private_videos',
140
+
141
+ // Move a copy of your public YouTube playlists.
142
+ 'https://www.googleapis.com/auth/dataportability.youtube.public_playlists',
143
+
144
+ // Move a copy of your public YouTube videos and information about them.
145
+ 'https://www.googleapis.com/auth/dataportability.youtube.public_videos',
146
+
147
+ // Move a copy of your YouTube shopping wishlists, and wishlist items.
148
+ 'https://www.googleapis.com/auth/dataportability.youtube.shopping',
149
+
150
+ // Move a copy of your YouTube channel subscriptions, even if they're private.
151
+ 'https://www.googleapis.com/auth/dataportability.youtube.subscriptions',
152
+
153
+ // Move a copy of your unlisted YouTube playlists.
154
+ 'https://www.googleapis.com/auth/dataportability.youtube.unlisted_playlists',
155
+
156
+ // Move a copy of your unlisted YouTube videos and information about them.
157
+ 'https://www.googleapis.com/auth/dataportability.youtube.unlisted_videos',
158
+ ],
159
+ immediate = true;
160
+ // ...
161
+
162
+ gapi.auth.authorize(
163
+ {client_id: client_id, scope: scope, immediate: immediate},
164
+ authResult => {
165
+ if (authResult && !authResult.error) {
166
+ /* handle successful authorization */
167
+ } else {
168
+ /* handle authorization error */
169
+ }
170
+ }
171
+ );
172
+ ```
173
+
174
+ After that you can use Data Portability API resources: <!-- TODO: make this work for multiple namespaces -->
175
+
176
+ ```typescript
177
+ /*
178
+ Retrieves the state of an Archive job for the Portability API.
179
+ */
180
+ await gapi.client.dataportability.archiveJobs.getPortabilityArchiveState({
181
+ name: 'name',
182
+ });
183
+
184
+ /*
185
+ Retries a failed Portability Archive job.
186
+ */
187
+ await gapi.client.dataportability.archiveJobs.retry({name: 'name'});
188
+
189
+ /*
190
+ Revokes OAuth tokens and resets exhausted scopes for a user/project pair. This method allows you to initiate a request after a new consent is granted. This method also indicates that previous archives can be garbage collected. You should call this method when all jobs are complete and all archives are downloaded. Do not call it only when you start a new job.
191
+ */
192
+ await gapi.client.dataportability.authorization.reset({});
193
+
194
+ /*
195
+ Initiates a new Archive job for the Portability API.
196
+ */
197
+ await gapi.client.dataportability.portabilityArchive.initiate({});
198
+ ```