@cocreate/firestore 1.1.0 → 1.2.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 +7 -0
- package/package.json +13 -10
- package/src/index.js +25 -9
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
# [1.2.0](https://github.com/CoCreate-app/CoCreate-firestore/compare/v1.1.0...v1.2.0) (2026-07-18)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* Update package.json description and keywords; refactor index.js to use ES modules ([1764e13](https://github.com/CoCreate-app/CoCreate-firestore/commit/1764e13f050671a8d2b55609bf118bcf9c510e17))
|
|
7
|
+
|
|
1
8
|
# [1.1.0](https://github.com/CoCreate-app/CoCreate-firestore/compare/v1.0.0...v1.1.0) (2026-07-18)
|
|
2
9
|
|
|
3
10
|
|
package/package.json
CHANGED
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cocreate/firestore",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "1.2.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 };
|