@maxim_mazurok/gapi.client.script-v1 0.0.20220806

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/package.json ADDED
@@ -0,0 +1,20 @@
1
+ {
2
+ "name": "@maxim_mazurok/gapi.client.script-v1",
3
+ "version": "0.0.20220806",
4
+ "description": "TypeScript typings for Apps Script API v1",
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,159 @@
1
+ # TypeScript typings for Apps Script API v1
2
+
3
+ Manages and executes Google Apps Script projects.
4
+ For detailed description please check [documentation](https://developers.google.com/apps-script/api/).
5
+
6
+ ## Installing
7
+
8
+ Install typings for Apps Script API:
9
+
10
+ ```
11
+ npm install @types/gapi.client.script-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('https://script.googleapis.com/$discovery/rest?version=v1', () => {
29
+ // now we can use:
30
+ // gapi.client.script
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('script', 'v1', () => {
37
+ // now we can use:
38
+ // gapi.client.script
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
+ // Read, compose, send, and permanently delete all your email from Gmail
49
+ 'https://mail.google.com/',
50
+
51
+ // See, edit, share, and permanently delete all the calendars you can access using Google Calendar
52
+ 'https://www.google.com/calendar/feeds',
53
+
54
+ // See, edit, download, and permanently delete your contacts
55
+ 'https://www.google.com/m8/feeds',
56
+
57
+ // View and manage the provisioning of groups on your domain
58
+ 'https://www.googleapis.com/auth/admin.directory.group',
59
+
60
+ // View and manage the provisioning of users on your domain
61
+ 'https://www.googleapis.com/auth/admin.directory.user',
62
+
63
+ // See, edit, create, and delete all your Google Docs documents
64
+ 'https://www.googleapis.com/auth/documents',
65
+
66
+ // See, edit, create, and delete all of your Google Drive files
67
+ 'https://www.googleapis.com/auth/drive',
68
+
69
+ // View and manage your forms in Google Drive
70
+ 'https://www.googleapis.com/auth/forms',
71
+
72
+ // View and manage forms that this application has been installed in
73
+ 'https://www.googleapis.com/auth/forms.currentonly',
74
+
75
+ // View and manage your Google Groups
76
+ 'https://www.googleapis.com/auth/groups',
77
+
78
+ // Create and update Google Apps Script deployments
79
+ 'https://www.googleapis.com/auth/script.deployments',
80
+
81
+ // View Google Apps Script deployments
82
+ 'https://www.googleapis.com/auth/script.deployments.readonly',
83
+
84
+ // View Google Apps Script project's metrics
85
+ 'https://www.googleapis.com/auth/script.metrics',
86
+
87
+ // View Google Apps Script processes
88
+ 'https://www.googleapis.com/auth/script.processes',
89
+
90
+ // Create and update Google Apps Script projects
91
+ 'https://www.googleapis.com/auth/script.projects',
92
+
93
+ // View Google Apps Script projects
94
+ 'https://www.googleapis.com/auth/script.projects.readonly',
95
+
96
+ // See, edit, create, and delete all your Google Sheets spreadsheets
97
+ 'https://www.googleapis.com/auth/spreadsheets',
98
+
99
+ // See your primary Google Account email address
100
+ 'https://www.googleapis.com/auth/userinfo.email',
101
+ ],
102
+ immediate = true;
103
+ // ...
104
+
105
+ gapi.auth.authorize(
106
+ { client_id: client_id, scope: scope, immediate: immediate },
107
+ authResult => {
108
+ if (authResult && !authResult.error) {
109
+ /* handle successful authorization */
110
+ } else {
111
+ /* handle authorization error */
112
+ }
113
+ });
114
+ ```
115
+
116
+ After that you can use Apps Script API resources: <!-- TODO: make this work for multiple namespaces -->
117
+
118
+ ```typescript
119
+
120
+ /*
121
+ List information about processes made by or on behalf of a user, such as process type and current status.
122
+ */
123
+ await gapi.client.script.processes.list({ });
124
+
125
+ /*
126
+ List information about a script's executed processes, such as process type and current status.
127
+ */
128
+ await gapi.client.script.processes.listScriptProcesses({ });
129
+
130
+ /*
131
+ Creates a new, empty script project with no script files and a base manifest file.
132
+ */
133
+ await gapi.client.script.projects.create({ });
134
+
135
+ /*
136
+ Gets a script project's metadata.
137
+ */
138
+ await gapi.client.script.projects.get({ scriptId: "scriptId", });
139
+
140
+ /*
141
+ Gets the content of the script project, including the code source and metadata for each script file.
142
+ */
143
+ await gapi.client.script.projects.getContent({ scriptId: "scriptId", });
144
+
145
+ /*
146
+ Get metrics data for scripts, such as number of executions and active users.
147
+ */
148
+ await gapi.client.script.projects.getMetrics({ scriptId: "scriptId", });
149
+
150
+ /*
151
+ Updates the content of the specified script project. This content is stored as the HEAD version, and is used when the script is executed as a trigger, in the script editor, in add-on preview mode, or as a web app or Apps Script API in development mode. This clears all the existing files in the project.
152
+ */
153
+ await gapi.client.script.projects.updateContent({ scriptId: "scriptId", });
154
+
155
+ /*
156
+ Runs a function in an Apps Script project. The script project must be deployed for use with the Apps Script API and the calling application must share the same Cloud Platform project. This method requires authorization with an OAuth 2.0 token that includes at least one of the scopes listed in the [Authorization](#authorization-scopes) section; script projects that do not require authorization cannot be executed through this API. To find the correct scopes to include in the authentication token, open the script project **Overview** page and scroll down to "Project OAuth Scopes." The error `403, PERMISSION_DENIED: The caller does not have permission` indicates that the Cloud Platform project used to authorize the request is not the same as the one used by the script.
157
+ */
158
+ await gapi.client.script.scripts.run({ scriptId: "scriptId", });
159
+ ```
package/tests.ts ADDED
@@ -0,0 +1,223 @@
1
+ /* This is stub file for gapi.client.script-v1 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: 20220806
7
+
8
+ gapi.load('client', async () => {
9
+ /** now we can use gapi.client */
10
+
11
+ await gapi.client.load('https://script.googleapis.com/$discovery/rest?version=v1');
12
+ /** now we can use gapi.client.script */
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
+ /** Read, compose, send, and permanently delete all your email from Gmail */
19
+ 'https://mail.google.com/',
20
+ /** See, edit, share, and permanently delete all the calendars you can access using Google Calendar */
21
+ 'https://www.google.com/calendar/feeds',
22
+ /** See, edit, download, and permanently delete your contacts */
23
+ 'https://www.google.com/m8/feeds',
24
+ /** View and manage the provisioning of groups on your domain */
25
+ 'https://www.googleapis.com/auth/admin.directory.group',
26
+ /** View and manage the provisioning of users on your domain */
27
+ 'https://www.googleapis.com/auth/admin.directory.user',
28
+ /** See, edit, create, and delete all your Google Docs documents */
29
+ 'https://www.googleapis.com/auth/documents',
30
+ /** See, edit, create, and delete all of your Google Drive files */
31
+ 'https://www.googleapis.com/auth/drive',
32
+ /** View and manage your forms in Google Drive */
33
+ 'https://www.googleapis.com/auth/forms',
34
+ /** View and manage forms that this application has been installed in */
35
+ 'https://www.googleapis.com/auth/forms.currentonly',
36
+ /** View and manage your Google Groups */
37
+ 'https://www.googleapis.com/auth/groups',
38
+ /** Create and update Google Apps Script deployments */
39
+ 'https://www.googleapis.com/auth/script.deployments',
40
+ /** View Google Apps Script deployments */
41
+ 'https://www.googleapis.com/auth/script.deployments.readonly',
42
+ /** View Google Apps Script project's metrics */
43
+ 'https://www.googleapis.com/auth/script.metrics',
44
+ /** View Google Apps Script processes */
45
+ 'https://www.googleapis.com/auth/script.processes',
46
+ /** Create and update Google Apps Script projects */
47
+ 'https://www.googleapis.com/auth/script.projects',
48
+ /** View Google Apps Script projects */
49
+ 'https://www.googleapis.com/auth/script.projects.readonly',
50
+ /** See, edit, create, and delete all your Google Sheets spreadsheets */
51
+ 'https://www.googleapis.com/auth/spreadsheets',
52
+ /** See your primary Google Account email address */
53
+ 'https://www.googleapis.com/auth/userinfo.email',
54
+ ];
55
+ const immediate = false;
56
+ gapi.auth.authorize({ client_id, scope, immediate }, authResult => {
57
+ if (authResult && !authResult.error) {
58
+ /** handle successful authorization */
59
+ run();
60
+ } else {
61
+ /** handle authorization error */
62
+ }
63
+ });
64
+
65
+ async function run() {
66
+ /** List information about processes made by or on behalf of a user, such as process type and current status. */
67
+ await gapi.client.script.processes.list({
68
+ pageSize: 42,
69
+ pageToken: "Test string",
70
+ "userProcessFilter.deploymentId": "Test string",
71
+ "userProcessFilter.endTime": "Test string",
72
+ "userProcessFilter.functionName": "Test string",
73
+ "userProcessFilter.projectName": "Test string",
74
+ "userProcessFilter.scriptId": "Test string",
75
+ "userProcessFilter.startTime": "Test string",
76
+ "userProcessFilter.statuses": "Test string",
77
+ "userProcessFilter.types": "Test string",
78
+ "userProcessFilter.userAccessLevels": "Test string",
79
+ });
80
+ /** List information about a script's executed processes, such as process type and current status. */
81
+ await gapi.client.script.processes.listScriptProcesses({
82
+ pageSize: 42,
83
+ pageToken: "Test string",
84
+ scriptId: "Test string",
85
+ "scriptProcessFilter.deploymentId": "Test string",
86
+ "scriptProcessFilter.endTime": "Test string",
87
+ "scriptProcessFilter.functionName": "Test string",
88
+ "scriptProcessFilter.startTime": "Test string",
89
+ "scriptProcessFilter.statuses": "Test string",
90
+ "scriptProcessFilter.types": "Test string",
91
+ "scriptProcessFilter.userAccessLevels": "Test string",
92
+ });
93
+ /** Creates a new, empty script project with no script files and a base manifest file. */
94
+ await gapi.client.script.projects.create({
95
+ }, {
96
+ parentId: "Test string",
97
+ title: "Test string",
98
+ });
99
+ /** Gets a script project's metadata. */
100
+ await gapi.client.script.projects.get({
101
+ scriptId: "Test string",
102
+ });
103
+ /** Gets the content of the script project, including the code source and metadata for each script file. */
104
+ await gapi.client.script.projects.getContent({
105
+ scriptId: "Test string",
106
+ versionNumber: 42,
107
+ });
108
+ /** Get metrics data for scripts, such as number of executions and active users. */
109
+ await gapi.client.script.projects.getMetrics({
110
+ "metricsFilter.deploymentId": "Test string",
111
+ metricsGranularity: "Test string",
112
+ scriptId: "Test string",
113
+ });
114
+ /**
115
+ * Updates the content of the specified script project. This content is stored as the HEAD version, and is used when the script is executed as a trigger, in the script editor, in add-on
116
+ * preview mode, or as a web app or Apps Script API in development mode. This clears all the existing files in the project.
117
+ */
118
+ await gapi.client.script.projects.updateContent({
119
+ scriptId: "Test string",
120
+ }, {
121
+ files: [
122
+ {
123
+ createTime: "Test string",
124
+ functionSet: {
125
+ values: [
126
+ {
127
+ name: "Test string",
128
+ parameters: [
129
+ "Test string"
130
+ ],
131
+ }
132
+ ],
133
+ },
134
+ lastModifyUser: {
135
+ domain: "Test string",
136
+ email: "Test string",
137
+ name: "Test string",
138
+ photoUrl: "Test string",
139
+ },
140
+ name: "Test string",
141
+ source: "Test string",
142
+ type: "Test string",
143
+ updateTime: "Test string",
144
+ }
145
+ ],
146
+ scriptId: "Test string",
147
+ });
148
+ /** Creates a deployment of an Apps Script project. */
149
+ await gapi.client.script.projects.deployments.create({
150
+ scriptId: "Test string",
151
+ }, {
152
+ description: "Test string",
153
+ manifestFileName: "Test string",
154
+ scriptId: "Test string",
155
+ versionNumber: 42,
156
+ });
157
+ /** Deletes a deployment of an Apps Script project. */
158
+ await gapi.client.script.projects.deployments.delete({
159
+ deploymentId: "Test string",
160
+ scriptId: "Test string",
161
+ });
162
+ /** Gets a deployment of an Apps Script project. */
163
+ await gapi.client.script.projects.deployments.get({
164
+ deploymentId: "Test string",
165
+ scriptId: "Test string",
166
+ });
167
+ /** Lists the deployments of an Apps Script project. */
168
+ await gapi.client.script.projects.deployments.list({
169
+ pageSize: 42,
170
+ pageToken: "Test string",
171
+ scriptId: "Test string",
172
+ });
173
+ /** Updates a deployment of an Apps Script project. */
174
+ await gapi.client.script.projects.deployments.update({
175
+ deploymentId: "Test string",
176
+ scriptId: "Test string",
177
+ }, {
178
+ deploymentConfig: {
179
+ description: "Test string",
180
+ manifestFileName: "Test string",
181
+ scriptId: "Test string",
182
+ versionNumber: 42,
183
+ },
184
+ });
185
+ /** Creates a new immutable version using the current code, with a unique version number. */
186
+ await gapi.client.script.projects.versions.create({
187
+ scriptId: "Test string",
188
+ }, {
189
+ createTime: "Test string",
190
+ description: "Test string",
191
+ scriptId: "Test string",
192
+ versionNumber: 42,
193
+ });
194
+ /** Gets a version of a script project. */
195
+ await gapi.client.script.projects.versions.get({
196
+ scriptId: "Test string",
197
+ versionNumber: 42,
198
+ });
199
+ /** List the versions of a script project. */
200
+ await gapi.client.script.projects.versions.list({
201
+ pageSize: 42,
202
+ pageToken: "Test string",
203
+ scriptId: "Test string",
204
+ });
205
+ /**
206
+ * Runs a function in an Apps Script project. The script project must be deployed for use with the Apps Script API and the calling application must share the same Cloud Platform project.
207
+ * This method requires authorization with an OAuth 2.0 token that includes at least one of the scopes listed in the [Authorization](#authorization-scopes) section; script projects that do
208
+ * not require authorization cannot be executed through this API. To find the correct scopes to include in the authentication token, open the script project **Overview** page and scroll
209
+ * down to "Project OAuth Scopes." The error `403, PERMISSION_DENIED: The caller does not have permission` indicates that the Cloud Platform project used to authorize the request is not
210
+ * the same as the one used by the script.
211
+ */
212
+ await gapi.client.script.scripts.run({
213
+ scriptId: "Test string",
214
+ }, {
215
+ devMode: true,
216
+ function: "Test string",
217
+ parameters: [
218
+ 42
219
+ ],
220
+ sessionState: "Test string",
221
+ });
222
+ }
223
+ });
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
+ }
package/tslint.json ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "extends": "dtslint/dtslint.json",
3
+ "rules": {
4
+ "no-redundant-jsdoc": false
5
+ }
6
+ }