@cocreate/firestore 1.1.0 → 1.3.0
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/CHANGELOG.md +14 -0
- package/README.md +139 -51
- package/package.json +13 -10
- package/src/index.js +25 -9
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
# [1.3.0](https://github.com/CoCreate-app/CoCreate-firestore/compare/v1.2.0...v1.3.0) (2026-07-19)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* Revamp README.md to reflect Firestore integration and enhance documentation ([63573db](https://github.com/CoCreate-app/CoCreate-firestore/commit/63573db61f4744e7d2cd7f104a35de23ffd2534e))
|
|
7
|
+
|
|
8
|
+
# [1.2.0](https://github.com/CoCreate-app/CoCreate-firestore/compare/v1.1.0...v1.2.0) (2026-07-18)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Features
|
|
12
|
+
|
|
13
|
+
* Update package.json description and keywords; refactor index.js to use ES modules ([1764e13](https://github.com/CoCreate-app/CoCreate-firestore/commit/1764e13f050671a8d2b55609bf118bcf9c510e17))
|
|
14
|
+
|
|
1
15
|
# [1.1.0](https://github.com/CoCreate-app/CoCreate-firestore/compare/v1.0.0...v1.1.0) (2026-07-18)
|
|
2
16
|
|
|
3
17
|
|
package/README.md
CHANGED
|
@@ -1,88 +1,176 @@
|
|
|
1
|
-
#
|
|
1
|
+
# firestore
|
|
2
2
|
|
|
3
|
-
A
|
|
3
|
+
A highly efficient, enterprise-grade Cloud Firestore NoSQL document database CRUD wrapper and state-routing backend client for the collaborative CoCreate ecosystem. This wrapper maps Firestore's real-time, serverless document-syncing capabilities into CoCreate's unified JSON interface.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-

|
|
7
|
-

|
|
5
|
+
## Documentation
|
|
8
6
|
|
|
9
|
-
|
|
7
|
+
For a complete guide and working integration examples, refer to the [CoCreate Firestore Documentation](https://cocreatejs.com/docs/firestore).
|
|
10
8
|
|
|
11
|
-
|
|
9
|
+
---
|
|
12
10
|
|
|
13
|
-
|
|
11
|
+
## Table of Contents
|
|
12
|
+
* [The Power of the CoCreate Unified Ecosystem](#the-power-of-the-cocreate-unified-ecosystem)
|
|
13
|
+
* [Why Cloud Firestore?](#why-cloud-firestore)
|
|
14
|
+
* [Installation](#installation)
|
|
15
|
+
* [Unified JSON Payload Examples](#unified-json-payload-examples)
|
|
16
|
+
* [Announcements](#announcements)
|
|
17
|
+
* [Roadmap](#roadmap)
|
|
18
|
+
* [How to Contribute](#how-to-contribute)
|
|
19
|
+
* [About](#about)
|
|
14
20
|
|
|
15
|
-
|
|
21
|
+
---
|
|
16
22
|
|
|
17
|
-
|
|
18
|
-
<script src="https://cdn.cocreate.app/mongodb/latest/CoCreate-mongodb.min.js"></script>
|
|
19
|
-
```
|
|
23
|
+
## The Power of the CoCreate Unified Ecosystem
|
|
20
24
|
|
|
21
|
-
|
|
22
|
-
<script src="https://cdn.cocreate.app/mongodb/latest/CoCreate-mongodb.min.css"></script>
|
|
23
|
-
```
|
|
25
|
+
This is not just another database driver. By wrapping Cloud Firestore into the CoCreate state-routing pipeline, you unlock the full power of a multi-cloud, multi-model data orchestration mesh:
|
|
24
26
|
|
|
25
|
-
|
|
27
|
+
* **Unified JSON Interface (MongoDB-like Syntax):** You don't need to learn custom Google Cloud Firestore SDK formatting or worry about structural path mutations. CoCreate translates standard NoSQL JSON CRUD operations (such as `object.create` or `object.read`) transparently into native Firestore collections and document references under the hood.
|
|
28
|
+
* **Parallel Multi-Database Writing:** Write to many target databases simultaneously with a single API call. You can stream transactional data to MongoDB (for instant operational state), vectorize it into Qdrant (for real-time semantic search), and persist it in Cloud Firestore (for instant serverless client syncing) in perfect parallel harmony:
|
|
26
29
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
+
$$\text{Write Command} \xrightarrow{\text{Parallel Mesh}} \begin{cases} \text{MongoDB} & \text{(ACID Transaction Store)} \\ \text{Qdrant} & \text{(Semantic Vector Search)} \\ \text{Cloud Firestore} & \text{(Serverless Document Sync)} \end{cases}$$
|
|
31
|
+
|
|
32
|
+
* **Dynamic State-Routing:** Isolate multi-tenant environments effortlessly. The routing mesh automatically injects tenant metadata and organization boundaries, ensuring isolated database processing within your shared Firestore collection hierarchy.
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## Why Cloud Firestore?
|
|
37
|
+
|
|
38
|
+
Cloud Firestore is a flexible, scalable database for mobile, web, and server development from Firebase and Google Cloud. It keeps your data in sync across client apps through realtime listeners and offers mobile offline support so you can build responsive apps that work regardless of network latency or Internet connectivity.
|
|
30
39
|
|
|
31
|
-
|
|
40
|
+
By routing real-time user-facing features, offline-first application modules, and fast event pipelines straight to Firestore via this wrapper, you leverage Google's planetary serverless scale and low-latency client synchronization while maintaining a zero-friction JSON pipeline.
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
## Installation
|
|
45
|
+
|
|
46
|
+
### NPM Installation
|
|
47
|
+
```bash
|
|
48
|
+
npm i @cocreate/firestore
|
|
32
49
|
|
|
33
|
-
```shell
|
|
34
|
-
$ yarn install @cocreate/mongodb
|
|
35
50
|
```
|
|
36
51
|
|
|
37
|
-
|
|
52
|
+
### Yarn Installation
|
|
38
53
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
- [Roadmap](#roadmap)
|
|
42
|
-
- [How to Contribute](#how-to-contribute)
|
|
43
|
-
- [About](#about)
|
|
44
|
-
- [License](#license)
|
|
54
|
+
```bash
|
|
55
|
+
yarn add @cocreate/firestore
|
|
45
56
|
|
|
46
|
-
|
|
57
|
+
```
|
|
47
58
|
|
|
48
|
-
|
|
59
|
+
---
|
|
60
|
+
|
|
61
|
+
## Unified JSON Payload Examples
|
|
62
|
+
|
|
63
|
+
Here are the complete, real-world JSON objects representing raw payloads routed through the CoCreate system. By declaring an array in the `storage` key, CoCreate fires the write operations to all specified backends simultaneously in parallel.
|
|
64
|
+
|
|
65
|
+
### 1. Writing a Full Transaction Object (`object.create`)
|
|
66
|
+
|
|
67
|
+
When this operational payload is sent, CoCreate registers it, processes the nested JSON fields, and automatically warehouses it across all listed parallel storage platforms.
|
|
68
|
+
|
|
69
|
+
```json
|
|
70
|
+
{
|
|
71
|
+
"method": "object.create",
|
|
72
|
+
"storage": ["firestore", "mongodb", "qdrant"], // Array of storages to store in parallel!
|
|
73
|
+
"database": "sales_analytics",
|
|
74
|
+
"array": "order_events",
|
|
75
|
+
"object": {
|
|
76
|
+
"_id": "order_77c8f2a9_3b01",
|
|
77
|
+
"customer": {
|
|
78
|
+
"id": "cust_88301",
|
|
79
|
+
"email": "customer@example.com",
|
|
80
|
+
"region": "North America",
|
|
81
|
+
"acquisition_channel": "Google Search"
|
|
82
|
+
},
|
|
83
|
+
"transaction": {
|
|
84
|
+
"payment_method": "Credit Card",
|
|
85
|
+
"currency": "USD",
|
|
86
|
+
"subtotal": 249.99,
|
|
87
|
+
"discount": 15.00,
|
|
88
|
+
"tax": 18.80,
|
|
89
|
+
"total": 253.79
|
|
90
|
+
},
|
|
91
|
+
"items": [
|
|
92
|
+
{
|
|
93
|
+
"product_id": "prod_head_009",
|
|
94
|
+
"name": "Wireless Noise-Cancelling Headphones",
|
|
95
|
+
"category": "Electronics",
|
|
96
|
+
"quantity": 1,
|
|
97
|
+
"unit_price": 199.99
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
"product_id": "prod_stand_012",
|
|
101
|
+
"name": "Aluminum Headphone Stand",
|
|
102
|
+
"category": "Accessories",
|
|
103
|
+
"quantity": 2,
|
|
104
|
+
"unit_price": 25.00
|
|
105
|
+
}
|
|
106
|
+
],
|
|
107
|
+
"shipping": {
|
|
108
|
+
"carrier": "FedEx",
|
|
109
|
+
"service": "2-Day Air",
|
|
110
|
+
"estimated_delivery": "2026-07-20T12:00:00.000Z"
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
"organization_id": "org_enterprise_99x",
|
|
114
|
+
"user_id": "usr_sales_runner_402",
|
|
115
|
+
"timeStamp": "2026-07-18T18:40:43.000Z"
|
|
116
|
+
}
|
|
49
117
|
|
|
50
|
-
|
|
118
|
+
```
|
|
51
119
|
|
|
52
|
-
|
|
120
|
+
### 2. Reading and Filtering Warehoused Data (`object.read`)
|
|
121
|
+
|
|
122
|
+
Querying targets a single database engine via a string filter syntax. The query below retrieves high-value orders handled by a specific shipping carrier from Firestore, sorting them by total sale volume.
|
|
123
|
+
|
|
124
|
+
```json
|
|
125
|
+
{
|
|
126
|
+
"method": "object.read",
|
|
127
|
+
"storage": "firestore",
|
|
128
|
+
"database": "sales_analytics",
|
|
129
|
+
"array": "order_events",
|
|
130
|
+
"$filter": {
|
|
131
|
+
"query": {
|
|
132
|
+
"transaction.total": { "$gte": 100.00 },
|
|
133
|
+
"shipping.carrier": "FedEx"
|
|
134
|
+
},
|
|
135
|
+
"sort": [
|
|
136
|
+
{ "key": "transaction.total", "direction": "desc" }
|
|
137
|
+
],
|
|
138
|
+
"limit": 50,
|
|
139
|
+
"index": 0
|
|
140
|
+
},
|
|
141
|
+
"organization_id": "org_enterprise_99x"
|
|
142
|
+
}
|
|
53
143
|
|
|
54
|
-
|
|
144
|
+
```
|
|
55
145
|
|
|
56
|
-
|
|
146
|
+
---
|
|
57
147
|
|
|
58
|
-
|
|
148
|
+
## Announcements
|
|
59
149
|
|
|
60
|
-
|
|
150
|
+
All updates to this library are documented in our `CHANGELOG` and releases. You may also subscribe to email for releases and breaking changes.
|
|
61
151
|
|
|
62
|
-
|
|
152
|
+
---
|
|
63
153
|
|
|
64
|
-
|
|
154
|
+
## Roadmap
|
|
65
155
|
|
|
66
|
-
|
|
156
|
+
If you are interested in the future direction of this project, please take a look at our open issues and pull requests. We would love to hear your feedback.
|
|
67
157
|
|
|
68
|
-
|
|
158
|
+
---
|
|
69
159
|
|
|
70
|
-
|
|
160
|
+
## How to Contribute
|
|
71
161
|
|
|
72
|
-
We encourage contribution to our libraries (you might even score some nifty swag), please see our
|
|
162
|
+
We encourage contribution to our libraries (you might even score some nifty swag), please see our `CONTRIBUTING` guide for details.
|
|
73
163
|
|
|
74
|
-
We want this library to be community-driven, and CoCreate led. We need your help to realize this goal. To help make sure we are building the right things in the right order, we ask that you create
|
|
164
|
+
We want this library to be community-driven, and CoCreate led. We need your help to realize this goal. To help make sure we are building the right things in the right order, we ask that you create issues and pull requests or merely upvote or comment on existing issues or pull requests.
|
|
75
165
|
|
|
76
166
|
We appreciate your continued support, thank you!
|
|
77
167
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
# License
|
|
168
|
+
---
|
|
81
169
|
|
|
82
|
-
|
|
170
|
+
## About
|
|
83
171
|
|
|
84
|
-
-
|
|
172
|
+
`CoCreate-firestore` is guided and supported by the **CoCreate Developer Experience Team**.
|
|
85
173
|
|
|
86
|
-
|
|
174
|
+
> Please Email the Developer Experience Team here in case of any queries.
|
|
87
175
|
|
|
88
|
-
|
|
176
|
+
`CoCreate-firestore` is maintained and funded by CoCreate. The names and logos for CoCreate are trademarks of CoCreate, LLC.
|
package/package.json
CHANGED
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cocreate/firestore",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "1.3.0",
|
|
4
|
+
"description": "Lightweight Google Cloud Firestore CRUD wrapper and multi-tenant state routing client for the CoCreate ecosystem.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"firestore",
|
|
7
|
-
"
|
|
8
|
-
"
|
|
9
|
-
"
|
|
10
|
-
"
|
|
11
|
-
"
|
|
12
|
-
"
|
|
13
|
-
"
|
|
7
|
+
"firebase",
|
|
8
|
+
"google-cloud-firestore",
|
|
9
|
+
"nosql",
|
|
10
|
+
"crud-api",
|
|
11
|
+
"abstract-crud",
|
|
12
|
+
"database-abstraction",
|
|
13
|
+
"multi-tenant",
|
|
14
|
+
"multi-tenant-routing",
|
|
15
|
+
"realtime-sync",
|
|
16
|
+
"state-synchronization"
|
|
14
17
|
],
|
|
15
18
|
"publishConfig": {
|
|
16
19
|
"access": "public"
|
|
@@ -38,6 +41,6 @@
|
|
|
38
41
|
"main": "./src/index.js",
|
|
39
42
|
"dependencies": {
|
|
40
43
|
"@cocreate/utils": "^1.44.0",
|
|
41
|
-
"firestore": "^7.5.0"
|
|
44
|
+
"@google-cloud/firestore": "^7.5.0"
|
|
42
45
|
}
|
|
43
46
|
}
|
package/src/index.js
CHANGED
|
@@ -1,11 +1,28 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/********************************************************************************
|
|
2
|
+
* Copyright (C) 2026 CoCreate and Contributors.
|
|
3
|
+
*
|
|
4
|
+
* This program is free software: you can redistribute it and/or modify
|
|
5
|
+
* it under the terms of the GNU Affero General Public License as published
|
|
6
|
+
* by the Free Software Foundation, either version 3 of the License, or
|
|
7
|
+
* (at your option) any later version.
|
|
8
|
+
*
|
|
9
|
+
* This program is distributed in the hope that it will be useful,
|
|
10
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12
|
+
* GNU Affero General Public License for more details.
|
|
13
|
+
*
|
|
14
|
+
* You should have received a copy of the GNU Affero General Public License
|
|
15
|
+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
16
|
+
********************************************************************************/
|
|
17
|
+
|
|
18
|
+
import { Firestore } from "@google-cloud/firestore";
|
|
19
|
+
import {
|
|
3
20
|
dotNotationToObject,
|
|
4
21
|
queryData,
|
|
5
22
|
searchData,
|
|
6
23
|
sortData,
|
|
7
24
|
isValidDate
|
|
8
|
-
}
|
|
25
|
+
} from "@cocreate/utils";
|
|
9
26
|
|
|
10
27
|
const organizations = {};
|
|
11
28
|
|
|
@@ -16,7 +33,6 @@ const organizations = {};
|
|
|
16
33
|
*/
|
|
17
34
|
async function dbClient(data) {
|
|
18
35
|
const storageUrl = data.storageUrl || data.url;
|
|
19
|
-
const storageName = data.storageName || data.provider || "firestore";
|
|
20
36
|
|
|
21
37
|
if (storageUrl) {
|
|
22
38
|
if (!organizations[data.organization_id]) {
|
|
@@ -127,7 +143,7 @@ process.on("orgDeleted", (organization_id) => {
|
|
|
127
143
|
/**
|
|
128
144
|
* Universal router matching the standard CoCreate pipeline signature.
|
|
129
145
|
*/
|
|
130
|
-
function send(data) {
|
|
146
|
+
export function send(data) {
|
|
131
147
|
let [type, method] = data.method.split(".");
|
|
132
148
|
if (type === "database") return database(method, data);
|
|
133
149
|
if (type === "array") return array(method, data);
|
|
@@ -146,7 +162,7 @@ function database(method, data) {
|
|
|
146
162
|
|
|
147
163
|
try {
|
|
148
164
|
const db = await dbClient(data);
|
|
149
|
-
if (!db || db.status === false) return data;
|
|
165
|
+
if (!db || db.status === false) return resolve(data);
|
|
150
166
|
|
|
151
167
|
if (method === "read") {
|
|
152
168
|
// Firestore is serverless and generally operates on a single default schema database per context.
|
|
@@ -213,7 +229,7 @@ function array(method, data) {
|
|
|
213
229
|
|
|
214
230
|
try {
|
|
215
231
|
const db = await dbClient(data);
|
|
216
|
-
if (!db || db.status === false) return data;
|
|
232
|
+
if (!db || db.status === false) return resolve(data);
|
|
217
233
|
|
|
218
234
|
if (data.request) data.array = data.request;
|
|
219
235
|
|
|
@@ -373,7 +389,7 @@ function object(method, data) {
|
|
|
373
389
|
async (resolve, reject) => {
|
|
374
390
|
try {
|
|
375
391
|
const db = await dbClient(data);
|
|
376
|
-
if (!db || db.status === false) return data;
|
|
392
|
+
if (!db || db.status === false) return resolve(data);
|
|
377
393
|
|
|
378
394
|
let type = "object";
|
|
379
395
|
let documents = [];
|
|
@@ -863,4 +879,4 @@ function errorHandler(data, error, database, array) {
|
|
|
863
879
|
}
|
|
864
880
|
}
|
|
865
881
|
|
|
866
|
-
|
|
882
|
+
export default { send };
|