@maxim_mazurok/gapi.client.datastore-v1 0.0.20220715

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.datastore-v1",
3
+ "version": "0.0.20220715",
4
+ "description": "TypeScript typings for Cloud Datastore 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,116 @@
1
+ # TypeScript typings for Cloud Datastore API v1
2
+
3
+ Accesses the schemaless NoSQL database to provide fully managed, robust, scalable storage for your application.
4
+ For detailed description please check [documentation](https://cloud.google.com/datastore/).
5
+
6
+ ## Installing
7
+
8
+ Install typings for Cloud Datastore API:
9
+
10
+ ```
11
+ npm install @types/gapi.client.datastore-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://datastore.googleapis.com/$discovery/rest?version=v1', () => {
29
+ // now we can use:
30
+ // gapi.client.datastore
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('datastore', 'v1', () => {
37
+ // now we can use:
38
+ // gapi.client.datastore
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
+ // See, edit, configure, and delete your Google Cloud data and see the email address for your Google Account.
49
+ 'https://www.googleapis.com/auth/cloud-platform',
50
+
51
+ // View and manage your Google Cloud Datastore data
52
+ 'https://www.googleapis.com/auth/datastore',
53
+ ],
54
+ immediate = true;
55
+ // ...
56
+
57
+ gapi.auth.authorize(
58
+ { client_id: client_id, scope: scope, immediate: immediate },
59
+ authResult => {
60
+ if (authResult && !authResult.error) {
61
+ /* handle successful authorization */
62
+ } else {
63
+ /* handle authorization error */
64
+ }
65
+ });
66
+ ```
67
+
68
+ After that you can use Cloud Datastore API resources: <!-- TODO: make this work for multiple namespaces -->
69
+
70
+ ```typescript
71
+
72
+ /*
73
+ Allocates IDs for the given keys, which is useful for referencing an entity before it is inserted.
74
+ */
75
+ await gapi.client.datastore.projects.allocateIds({ projectId: "projectId", });
76
+
77
+ /*
78
+ Begins a new transaction.
79
+ */
80
+ await gapi.client.datastore.projects.beginTransaction({ projectId: "projectId", });
81
+
82
+ /*
83
+ Commits a transaction, optionally creating, deleting or modifying some entities.
84
+ */
85
+ await gapi.client.datastore.projects.commit({ projectId: "projectId", });
86
+
87
+ /*
88
+ Exports a copy of all or a subset of entities from Google Cloud Datastore to another storage system, such as Google Cloud Storage. Recent updates to entities may not be reflected in the export. The export occurs in the background and its progress can be monitored and managed via the Operation resource that is created. The output of an export may only be used once the associated operation is done. If an export operation is cancelled before completion it may leave partial data behind in Google Cloud Storage.
89
+ */
90
+ await gapi.client.datastore.projects.export({ projectId: "projectId", });
91
+
92
+ /*
93
+ Imports entities into Google Cloud Datastore. Existing entities with the same key are overwritten. The import occurs in the background and its progress can be monitored and managed via the Operation resource that is created. If an ImportEntities operation is cancelled, it is possible that a subset of the data has already been imported to Cloud Datastore.
94
+ */
95
+ await gapi.client.datastore.projects.import({ projectId: "projectId", });
96
+
97
+ /*
98
+ Looks up entities by key.
99
+ */
100
+ await gapi.client.datastore.projects.lookup({ projectId: "projectId", });
101
+
102
+ /*
103
+ Prevents the supplied keys' IDs from being auto-allocated by Cloud Datastore.
104
+ */
105
+ await gapi.client.datastore.projects.reserveIds({ projectId: "projectId", });
106
+
107
+ /*
108
+ Rolls back a transaction.
109
+ */
110
+ await gapi.client.datastore.projects.rollback({ projectId: "projectId", });
111
+
112
+ /*
113
+ Queries for entities.
114
+ */
115
+ await gapi.client.datastore.projects.runQuery({ projectId: "projectId", });
116
+ ```