@twin.org/entity-storage-connector-gcp-firestore 0.0.1-next.12

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.
@@ -0,0 +1,235 @@
1
+ # Class: FirestoreEntityStorageConnector\<T\>
2
+
3
+ Class for performing entity storage operations using Firestore.
4
+
5
+ ## Type Parameters
6
+
7
+ • **T** = `unknown`
8
+
9
+ ## Implements
10
+
11
+ - `IEntityStorageConnector`\<`T`\>
12
+
13
+ ## Constructors
14
+
15
+ ### new FirestoreEntityStorageConnector()
16
+
17
+ > **new FirestoreEntityStorageConnector**\<`T`\>(`options`): [`FirestoreEntityStorageConnector`](FirestoreEntityStorageConnector.md)\<`T`\>
18
+
19
+ Create a new instance of FirestoreEntityStorageConnector.
20
+
21
+ #### Parameters
22
+
23
+ • **options**
24
+
25
+ The options for the connector.
26
+
27
+ • **options.entitySchema**: `string`
28
+
29
+ The schema for the entity.
30
+
31
+ • **options.loggingConnectorType?**: `string`
32
+
33
+ The type of logging connector to use, defaults to no logging.
34
+
35
+ • **options.config**: [`IFirestoreEntityStorageConnectorConfig`](../interfaces/IFirestoreEntityStorageConnectorConfig.md)
36
+
37
+ The configuration for the connector.
38
+
39
+ #### Returns
40
+
41
+ [`FirestoreEntityStorageConnector`](FirestoreEntityStorageConnector.md)\<`T`\>
42
+
43
+ ## Properties
44
+
45
+ ### CLASS\_NAME
46
+
47
+ > `readonly` **CLASS\_NAME**: `string`
48
+
49
+ Runtime name for the class.
50
+
51
+ #### Implementation of
52
+
53
+ `IEntityStorageConnector.CLASS_NAME`
54
+
55
+ ## Methods
56
+
57
+ ### bootstrap()
58
+
59
+ > **bootstrap**(`nodeLoggingConnectorType`?): `Promise`\<`boolean`\>
60
+
61
+ Bootstrap the component by creating and initializing any resources it needs.
62
+
63
+ #### Parameters
64
+
65
+ • **nodeLoggingConnectorType?**: `string`
66
+
67
+ The node logging connector type, defaults to "node-logging".
68
+
69
+ #### Returns
70
+
71
+ `Promise`\<`boolean`\>
72
+
73
+ True if the bootstrapping process was successful.
74
+
75
+ #### Implementation of
76
+
77
+ `IEntityStorageConnector.bootstrap`
78
+
79
+ ***
80
+
81
+ ### getSchema()
82
+
83
+ > **getSchema**(): `IEntitySchema`\<`unknown`\>
84
+
85
+ Get the schema for the entities.
86
+
87
+ #### Returns
88
+
89
+ `IEntitySchema`\<`unknown`\>
90
+
91
+ The schema for the entities.
92
+
93
+ #### Implementation of
94
+
95
+ `IEntityStorageConnector.getSchema`
96
+
97
+ ***
98
+
99
+ ### get()
100
+
101
+ > **get**(`id`, `secondaryIndex`?, `conditions`?): `Promise`\<`undefined` \| `T`\>
102
+
103
+ Get an entity.
104
+
105
+ #### Parameters
106
+
107
+ • **id**: `string`
108
+
109
+ The id of the entity to get.
110
+
111
+ • **secondaryIndex?**: keyof `T`
112
+
113
+ The optional secondary index to use.
114
+
115
+ • **conditions?**: `object`[]
116
+
117
+ The optional conditions to apply to the query.
118
+
119
+ #### Returns
120
+
121
+ `Promise`\<`undefined` \| `T`\>
122
+
123
+ The object if it can be found or undefined.
124
+
125
+ #### Implementation of
126
+
127
+ `IEntityStorageConnector.get`
128
+
129
+ ***
130
+
131
+ ### set()
132
+
133
+ > **set**(`entity`, `conditions`?): `Promise`\<`void`\>
134
+
135
+ Set an entity.
136
+
137
+ #### Parameters
138
+
139
+ • **entity**: `T`
140
+
141
+ The entity to set.
142
+
143
+ • **conditions?**: `object`[]
144
+
145
+ The optional conditions to apply to the update.
146
+
147
+ #### Returns
148
+
149
+ `Promise`\<`void`\>
150
+
151
+ Nothing.
152
+
153
+ #### Implementation of
154
+
155
+ `IEntityStorageConnector.set`
156
+
157
+ ***
158
+
159
+ ### remove()
160
+
161
+ > **remove**(`id`, `conditions`?): `Promise`\<`void`\>
162
+
163
+ Remove the entity.
164
+
165
+ #### Parameters
166
+
167
+ • **id**: `string`
168
+
169
+ The id of the entity to remove.
170
+
171
+ • **conditions?**: `object`[]
172
+
173
+ The optional conditions to apply to the delete.
174
+
175
+ #### Returns
176
+
177
+ `Promise`\<`void`\>
178
+
179
+ Nothing.
180
+
181
+ #### Implementation of
182
+
183
+ `IEntityStorageConnector.remove`
184
+
185
+ ***
186
+
187
+ ### query()
188
+
189
+ > **query**(`conditions`?, `sortProperties`?, `properties`?, `cursor`?, `pageSize`?): `Promise`\<`object`\>
190
+
191
+ Find all the entities which match the conditions.
192
+
193
+ #### Parameters
194
+
195
+ • **conditions?**: `EntityCondition`\<`T`\>
196
+
197
+ The conditions to match for the entities.
198
+
199
+ • **sortProperties?**: `object`[]
200
+
201
+ The optional sort order.
202
+
203
+ • **properties?**: keyof `T`[]
204
+
205
+ The optional properties to return, defaults to all.
206
+
207
+ • **cursor?**: `string`
208
+
209
+ The cursor to request the next page of entities.
210
+
211
+ • **pageSize?**: `number`
212
+
213
+ The suggested number of entities to return in each chunk.
214
+
215
+ #### Returns
216
+
217
+ `Promise`\<`object`\>
218
+
219
+ The matching entities and a cursor for the next page.
220
+
221
+ ##### entities
222
+
223
+ > **entities**: `Partial`\<`T`\>[]
224
+
225
+ The entities, which can be partial if a limited keys list was provided.
226
+
227
+ ##### cursor?
228
+
229
+ > `optional` **cursor**: `string`
230
+
231
+ An optional cursor, when defined can be used to call find to get more entities.
232
+
233
+ #### Implementation of
234
+
235
+ `IEntityStorageConnector.query`
@@ -0,0 +1,9 @@
1
+ # @twin.org/entity-storage-connector-gcp-firestore
2
+
3
+ ## Classes
4
+
5
+ - [FirestoreEntityStorageConnector](classes/FirestoreEntityStorageConnector.md)
6
+
7
+ ## Interfaces
8
+
9
+ - [IFirestoreEntityStorageConnectorConfig](interfaces/IFirestoreEntityStorageConnectorConfig.md)
@@ -0,0 +1,63 @@
1
+ # Interface: IFirestoreEntityStorageConnectorConfig
2
+
3
+ Configuration for the Firestore Entity Storage Connector.
4
+
5
+ ## Properties
6
+
7
+ ### projectId
8
+
9
+ > **projectId**: `string`
10
+
11
+ The GCP project ID.
12
+
13
+ ***
14
+
15
+ ### databaseId?
16
+
17
+ > `optional` **databaseId**: `string`
18
+
19
+ The database ID, if omitted default database will be used.
20
+
21
+ ***
22
+
23
+ ### collectionName
24
+
25
+ > **collectionName**: `string`
26
+
27
+ The name of the collection for the storage.
28
+
29
+ ***
30
+
31
+ ### credentials?
32
+
33
+ > `optional` **credentials**: `string`
34
+
35
+ The GCP credentials, a base64 encoded version of the JWTInput data type.
36
+
37
+ ***
38
+
39
+ ### endpoint?
40
+
41
+ > `optional` **endpoint**: `string`
42
+
43
+ It's usually only used with an emulator (e.g., "localhost:8080").
44
+
45
+ ***
46
+
47
+ ### settings?
48
+
49
+ > `optional` **settings**: `object`
50
+
51
+ Optional settings for Firestore client initialization.
52
+
53
+ #### maxIdleChannels?
54
+
55
+ > `optional` **maxIdleChannels**: `number`
56
+
57
+ The maximum number of idle channels to keep open.
58
+
59
+ #### timeout?
60
+
61
+ > `optional` **timeout**: `number`
62
+
63
+ The custom timeout for requests (in milliseconds).
@@ -0,0 +1,23 @@
1
+ {
2
+ "info": {
3
+ "firestoreEntityStorageConnector": {
4
+ "firestoreCreating": "Creating Firestore",
5
+ "firestoreCreated": "Created Firestore"
6
+ }
7
+ },
8
+ "error": {
9
+ "firestoreEntityStorageConnector": {
10
+ "firestoreCreationFailed": "Failed to connect to Firestore",
11
+ "setEntityFailed": "Failed to set entity \"{id}\"",
12
+ "getEntityFailed": "Failed to get entity \"{id}\"",
13
+ "removeEntityFailed": "Failed to remove entity \"{id}\"",
14
+ "queryFailed": "The query failed when issuing the following command \"{queryDescription}\"",
15
+ "collectionDeleteFailed": "Failed to delete collection \"{collectionName}\"",
16
+ "unsupportedComparisonOperator": "Comparison operator \"{comparison}\" is not supported",
17
+ "firestoreClientNotInitialized": "Firestore client not initialized",
18
+ "undefinedProperty": "Property \"{key}\" is undefined. Firestore does not support undefined values.",
19
+ "missingProjectId": "Project ID is required",
20
+ "documentDoesNotExist": "The document with id {id} does not exist."
21
+ }
22
+ }
23
+ }
package/package.json ADDED
@@ -0,0 +1,42 @@
1
+ {
2
+ "name": "@twin.org/entity-storage-connector-gcp-firestore",
3
+ "version": "0.0.1-next.12",
4
+ "description": "Entity Storage connector implementation using GCP Firestore storage",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "git+https://github.com/twinfoundation/entity-storage.git",
8
+ "directory": "packages/entity-storage-connector-gcp-firestore"
9
+ },
10
+ "author": "cornel.filip@iota.org",
11
+ "license": "Apache-2.0",
12
+ "type": "module",
13
+ "engines": {
14
+ "node": ">=20.0.0"
15
+ },
16
+ "dependencies": {
17
+ "@google-cloud/firestore": "^7.10.0",
18
+ "@twin.org/core": "next",
19
+ "@twin.org/entity": "next",
20
+ "@twin.org/entity-storage-models": "0.0.1-next.6",
21
+ "@twin.org/logging-models": "next",
22
+ "@twin.org/nameof": "next"
23
+ },
24
+ "main": "./dist/cjs/index.cjs",
25
+ "module": "./dist/esm/index.mjs",
26
+ "types": "./dist/types/index.d.ts",
27
+ "exports": {
28
+ ".": {
29
+ "require": "./dist/cjs/index.cjs",
30
+ "import": "./dist/esm/index.mjs",
31
+ "types": "./dist/types/index.d.ts"
32
+ },
33
+ "./locales": "./locales"
34
+ },
35
+ "files": [
36
+ "dist/cjs",
37
+ "dist/esm",
38
+ "dist/types",
39
+ "locales",
40
+ "docs"
41
+ ]
42
+ }