@maxim_mazurok/gapi.client.indexing-v3 0.0.20220726
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/index.d.ts +133 -0
- package/package.json +20 -0
- package/readme.md +78 -0
- package/tests.ts +47 -0
- package/tsconfig.json +18 -0
- package/tslint.json +6 -0
package/index.d.ts
ADDED
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
/* Type definitions for non-npm package Indexing API v3 0.0 */
|
|
2
|
+
// Project: https://developers.google.com/search/apis/indexing-api/
|
|
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
|
+
// TypeScript Version: 2.8
|
|
8
|
+
|
|
9
|
+
// IMPORTANT
|
|
10
|
+
// This file was generated by https://github.com/Maxim-Mazurok/google-api-typings-generator. Please do not edit it manually.
|
|
11
|
+
// In case of any problems please post issue to https://github.com/Maxim-Mazurok/google-api-typings-generator
|
|
12
|
+
// Generated from: https://indexing.googleapis.com/$discovery/rest?version=v3
|
|
13
|
+
// Revision: 20220726
|
|
14
|
+
|
|
15
|
+
/// <reference types="gapi.client" />
|
|
16
|
+
|
|
17
|
+
declare namespace gapi.client {
|
|
18
|
+
/** Load Indexing API v3 */
|
|
19
|
+
function load(urlOrObject: "https://indexing.googleapis.com/$discovery/rest?version=v3"): Promise<void>;
|
|
20
|
+
/** @deprecated Please load APIs with discovery documents. */
|
|
21
|
+
function load(name: "indexing", version: "v3"): Promise<void>;
|
|
22
|
+
/** @deprecated Please load APIs with discovery documents. */
|
|
23
|
+
function load(name: "indexing", version: "v3", callback: () => any): void;
|
|
24
|
+
|
|
25
|
+
namespace indexing {
|
|
26
|
+
interface PublishUrlNotificationResponse {
|
|
27
|
+
/** Description of the notification events received for this URL. */
|
|
28
|
+
urlNotificationMetadata?: UrlNotificationMetadata;
|
|
29
|
+
}
|
|
30
|
+
interface UrlNotification {
|
|
31
|
+
/** Creation timestamp for this notification. Users should _not_ specify it, the field is ignored at the request time. */
|
|
32
|
+
notifyTime?: string;
|
|
33
|
+
/** The URL life cycle event that Google is being notified about. */
|
|
34
|
+
type?: string;
|
|
35
|
+
/** The object of this notification. The URL must be owned by the publisher of this notification and, in case of `URL_UPDATED` notifications, it _must_ be crawlable by Google. */
|
|
36
|
+
url?: string;
|
|
37
|
+
}
|
|
38
|
+
interface UrlNotificationMetadata {
|
|
39
|
+
/** Latest notification received with type `URL_REMOVED`. */
|
|
40
|
+
latestRemove?: UrlNotification;
|
|
41
|
+
/** Latest notification received with type `URL_UPDATED`. */
|
|
42
|
+
latestUpdate?: UrlNotification;
|
|
43
|
+
/** URL to which this metadata refers. */
|
|
44
|
+
url?: string;
|
|
45
|
+
}
|
|
46
|
+
interface UrlNotificationsResource {
|
|
47
|
+
/**
|
|
48
|
+
* Gets metadata about a Web Document. This method can _only_ be used to query URLs that were previously seen in successful Indexing API notifications. Includes the latest
|
|
49
|
+
* `UrlNotification` received via this API.
|
|
50
|
+
*/
|
|
51
|
+
getMetadata(request?: {
|
|
52
|
+
/** V1 error format. */
|
|
53
|
+
"$.xgafv"?: string;
|
|
54
|
+
/** OAuth access token. */
|
|
55
|
+
access_token?: string;
|
|
56
|
+
/** Data format for response. */
|
|
57
|
+
alt?: string;
|
|
58
|
+
/** JSONP */
|
|
59
|
+
callback?: string;
|
|
60
|
+
/** Selector specifying which fields to include in a partial response. */
|
|
61
|
+
fields?: string;
|
|
62
|
+
/** 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. */
|
|
63
|
+
key?: string;
|
|
64
|
+
/** OAuth 2.0 token for the current user. */
|
|
65
|
+
oauth_token?: string;
|
|
66
|
+
/** Returns response with indentations and line breaks. */
|
|
67
|
+
prettyPrint?: boolean;
|
|
68
|
+
/** 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. */
|
|
69
|
+
quotaUser?: string;
|
|
70
|
+
/** Upload protocol for media (e.g. "raw", "multipart"). */
|
|
71
|
+
upload_protocol?: string;
|
|
72
|
+
/** Legacy upload protocol for media (e.g. "media", "multipart"). */
|
|
73
|
+
uploadType?: string;
|
|
74
|
+
/** URL that is being queried. */
|
|
75
|
+
url?: string;
|
|
76
|
+
}): Request<UrlNotificationMetadata>;
|
|
77
|
+
/** Notifies that a URL has been updated or deleted. */
|
|
78
|
+
publish(request: {
|
|
79
|
+
/** V1 error format. */
|
|
80
|
+
"$.xgafv"?: string;
|
|
81
|
+
/** OAuth access token. */
|
|
82
|
+
access_token?: string;
|
|
83
|
+
/** Data format for response. */
|
|
84
|
+
alt?: string;
|
|
85
|
+
/** JSONP */
|
|
86
|
+
callback?: string;
|
|
87
|
+
/** Selector specifying which fields to include in a partial response. */
|
|
88
|
+
fields?: string;
|
|
89
|
+
/** 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. */
|
|
90
|
+
key?: string;
|
|
91
|
+
/** OAuth 2.0 token for the current user. */
|
|
92
|
+
oauth_token?: string;
|
|
93
|
+
/** Returns response with indentations and line breaks. */
|
|
94
|
+
prettyPrint?: boolean;
|
|
95
|
+
/** 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. */
|
|
96
|
+
quotaUser?: string;
|
|
97
|
+
/** Upload protocol for media (e.g. "raw", "multipart"). */
|
|
98
|
+
upload_protocol?: string;
|
|
99
|
+
/** Legacy upload protocol for media (e.g. "media", "multipart"). */
|
|
100
|
+
uploadType?: string;
|
|
101
|
+
/** Request body */
|
|
102
|
+
resource: UrlNotification;
|
|
103
|
+
}): Request<PublishUrlNotificationResponse>;
|
|
104
|
+
publish(request: {
|
|
105
|
+
/** V1 error format. */
|
|
106
|
+
"$.xgafv"?: string;
|
|
107
|
+
/** OAuth access token. */
|
|
108
|
+
access_token?: string;
|
|
109
|
+
/** Data format for response. */
|
|
110
|
+
alt?: string;
|
|
111
|
+
/** JSONP */
|
|
112
|
+
callback?: string;
|
|
113
|
+
/** Selector specifying which fields to include in a partial response. */
|
|
114
|
+
fields?: string;
|
|
115
|
+
/** 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. */
|
|
116
|
+
key?: string;
|
|
117
|
+
/** OAuth 2.0 token for the current user. */
|
|
118
|
+
oauth_token?: string;
|
|
119
|
+
/** Returns response with indentations and line breaks. */
|
|
120
|
+
prettyPrint?: boolean;
|
|
121
|
+
/** 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. */
|
|
122
|
+
quotaUser?: string;
|
|
123
|
+
/** Upload protocol for media (e.g. "raw", "multipart"). */
|
|
124
|
+
upload_protocol?: string;
|
|
125
|
+
/** Legacy upload protocol for media (e.g. "media", "multipart"). */
|
|
126
|
+
uploadType?: string;
|
|
127
|
+
},
|
|
128
|
+
body: UrlNotification): Request<PublishUrlNotificationResponse>;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
const urlNotifications: UrlNotificationsResource;
|
|
132
|
+
}
|
|
133
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@maxim_mazurok/gapi.client.indexing-v3",
|
|
3
|
+
"version": "0.0.20220726",
|
|
4
|
+
"description": "TypeScript typings for Indexing API v3",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": {
|
|
7
|
+
"email": "maxim@mazurok.com",
|
|
8
|
+
"name": "Maxim Mazurok",
|
|
9
|
+
"url": "https://maxim.mazurok.com"
|
|
10
|
+
},
|
|
11
|
+
"repository": {
|
|
12
|
+
"type": "git",
|
|
13
|
+
"url": "https://github.com/Maxim-Mazurok/google-api-typings-generator.git"
|
|
14
|
+
},
|
|
15
|
+
"types": "index.d.ts",
|
|
16
|
+
"dependencies": {
|
|
17
|
+
"@types/gapi.client": "*",
|
|
18
|
+
"@types/gapi.client.discovery": "*"
|
|
19
|
+
}
|
|
20
|
+
}
|
package/readme.md
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# TypeScript typings for Indexing API v3
|
|
2
|
+
|
|
3
|
+
Notifies Google when your web pages change.
|
|
4
|
+
For detailed description please check [documentation](https://developers.google.com/search/apis/indexing-api/).
|
|
5
|
+
|
|
6
|
+
## Installing
|
|
7
|
+
|
|
8
|
+
Install typings for Indexing API:
|
|
9
|
+
|
|
10
|
+
```
|
|
11
|
+
npm install @types/gapi.client.indexing-v3 --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('https://indexing.googleapis.com/$discovery/rest?version=v3', () => {
|
|
29
|
+
// now we can use:
|
|
30
|
+
// gapi.client.indexing
|
|
31
|
+
});
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
```typescript
|
|
35
|
+
// Deprecated, use discovery document URL, see https://github.com/google/google-api-javascript-client/blob/master/docs/reference.md#----gapiclientloadname----version----callback--
|
|
36
|
+
gapi.client.load('indexing', 'v3', () => {
|
|
37
|
+
// now we can use:
|
|
38
|
+
// gapi.client.indexing
|
|
39
|
+
});
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Don't forget to authenticate your client before sending any request to resources:
|
|
43
|
+
|
|
44
|
+
```typescript
|
|
45
|
+
// declare client_id registered in Google Developers Console
|
|
46
|
+
var client_id = '',
|
|
47
|
+
scope = [
|
|
48
|
+
// Submit data to Google for indexing
|
|
49
|
+
'https://www.googleapis.com/auth/indexing',
|
|
50
|
+
],
|
|
51
|
+
immediate = true;
|
|
52
|
+
// ...
|
|
53
|
+
|
|
54
|
+
gapi.auth.authorize(
|
|
55
|
+
{ client_id: client_id, scope: scope, immediate: immediate },
|
|
56
|
+
authResult => {
|
|
57
|
+
if (authResult && !authResult.error) {
|
|
58
|
+
/* handle successful authorization */
|
|
59
|
+
} else {
|
|
60
|
+
/* handle authorization error */
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
After that you can use Indexing API resources: <!-- TODO: make this work for multiple namespaces -->
|
|
66
|
+
|
|
67
|
+
```typescript
|
|
68
|
+
|
|
69
|
+
/*
|
|
70
|
+
Gets metadata about a Web Document. This method can _only_ be used to query URLs that were previously seen in successful Indexing API notifications. Includes the latest `UrlNotification` received via this API.
|
|
71
|
+
*/
|
|
72
|
+
await gapi.client.indexing.urlNotifications.getMetadata({ });
|
|
73
|
+
|
|
74
|
+
/*
|
|
75
|
+
Notifies that a URL has been updated or deleted.
|
|
76
|
+
*/
|
|
77
|
+
await gapi.client.indexing.urlNotifications.publish({ });
|
|
78
|
+
```
|
package/tests.ts
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/* This is stub file for gapi.client.indexing-v3 definition tests */
|
|
2
|
+
// IMPORTANT
|
|
3
|
+
// This file was generated by https://github.com/Maxim-Mazurok/google-api-typings-generator. Please do not edit it manually.
|
|
4
|
+
// In case of any problems please post issue to https://github.com/Maxim-Mazurok/google-api-typings-generator
|
|
5
|
+
|
|
6
|
+
// Revision: 20220726
|
|
7
|
+
|
|
8
|
+
gapi.load('client', async () => {
|
|
9
|
+
/** now we can use gapi.client */
|
|
10
|
+
|
|
11
|
+
await gapi.client.load('https://indexing.googleapis.com/$discovery/rest?version=v3');
|
|
12
|
+
/** now we can use gapi.client.indexing */
|
|
13
|
+
|
|
14
|
+
/** don't forget to authenticate your client before sending any request to resources: */
|
|
15
|
+
/** declare client_id registered in Google Developers Console */
|
|
16
|
+
const client_id = '<<PUT YOUR CLIENT ID HERE>>';
|
|
17
|
+
const scope = [
|
|
18
|
+
/** Submit data to Google for indexing */
|
|
19
|
+
'https://www.googleapis.com/auth/indexing',
|
|
20
|
+
];
|
|
21
|
+
const immediate = false;
|
|
22
|
+
gapi.auth.authorize({ client_id, scope, immediate }, authResult => {
|
|
23
|
+
if (authResult && !authResult.error) {
|
|
24
|
+
/** handle successful authorization */
|
|
25
|
+
run();
|
|
26
|
+
} else {
|
|
27
|
+
/** handle authorization error */
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
async function run() {
|
|
32
|
+
/**
|
|
33
|
+
* Gets metadata about a Web Document. This method can _only_ be used to query URLs that were previously seen in successful Indexing API notifications. Includes the latest
|
|
34
|
+
* `UrlNotification` received via this API.
|
|
35
|
+
*/
|
|
36
|
+
await gapi.client.indexing.urlNotifications.getMetadata({
|
|
37
|
+
url: "Test string",
|
|
38
|
+
});
|
|
39
|
+
/** Notifies that a URL has been updated or deleted. */
|
|
40
|
+
await gapi.client.indexing.urlNotifications.publish({
|
|
41
|
+
}, {
|
|
42
|
+
notifyTime: "Test string",
|
|
43
|
+
type: "Test string",
|
|
44
|
+
url: "Test string",
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
});
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"module": "commonjs",
|
|
4
|
+
"lib": ["es6", "dom"],
|
|
5
|
+
"noImplicitAny": true,
|
|
6
|
+
"noImplicitThis": true,
|
|
7
|
+
"strictNullChecks": true,
|
|
8
|
+
"baseUrl": "../",
|
|
9
|
+
"typeRoots": [
|
|
10
|
+
"../"
|
|
11
|
+
],
|
|
12
|
+
"types": [],
|
|
13
|
+
"noEmit": true,
|
|
14
|
+
"forceConsistentCasingInFileNames": true,
|
|
15
|
+
"strictFunctionTypes": true
|
|
16
|
+
},
|
|
17
|
+
"files": ["index.d.ts", "tests.ts"]
|
|
18
|
+
}
|