@rebasepro/common 0.1.0 → 0.1.2
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/README.md +178 -110
- package/dist/index.es.js +5 -6
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +6 -6
- package/dist/index.umd.js.map +1 -1
- package/package.json +3 -4
- package/src/collections/CollectionRegistry.ts +5 -6
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rebasepro/common",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.2",
|
|
5
5
|
"description": "Awesome Firebase/Firestore-based headless open-source CMS",
|
|
6
6
|
"funding": {
|
|
7
7
|
"url": "https://github.com/sponsors/rebaseco"
|
|
@@ -41,15 +41,14 @@
|
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"fast-equals": "6.0.0",
|
|
43
43
|
"json-logic-js": "^2.0.5",
|
|
44
|
-
"@rebasepro/types": "0.1.
|
|
45
|
-
"@rebasepro/utils": "0.1.
|
|
44
|
+
"@rebasepro/types": "0.1.2",
|
|
45
|
+
"@rebasepro/utils": "0.1.2"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"@jest/globals": "^29.7.0",
|
|
49
49
|
"@testing-library/react": "^16.3.0",
|
|
50
50
|
"@testing-library/user-event": "^14.6.1",
|
|
51
51
|
"@types/jest": "^29.5.14",
|
|
52
|
-
"@types/lodash": "4.17.24",
|
|
53
52
|
"@types/node": "^20.17.14",
|
|
54
53
|
"@types/object-hash": "^3.0.6",
|
|
55
54
|
"@types/react": "^19.0.8",
|
|
@@ -16,8 +16,7 @@ import {
|
|
|
16
16
|
import { deepEqual } from "fast-equals";
|
|
17
17
|
|
|
18
18
|
import { enumToObjectEntries, getSubcollections, getTableName, resolveCollectionRelations, findRelation, sanitizeRelation } from "../util";
|
|
19
|
-
import
|
|
20
|
-
import { removeFunctions, mergeDeep } from "@rebasepro/utils";
|
|
19
|
+
import { removeFunctions, mergeDeep, deepClone } from "@rebasepro/utils";
|
|
21
20
|
|
|
22
21
|
export class CollectionRegistry {
|
|
23
22
|
|
|
@@ -83,7 +82,7 @@ export class CollectionRegistry {
|
|
|
83
82
|
// (e.g. Tags from Posts.relations) using the raw module object (without injected views)
|
|
84
83
|
// before the top-level Tags collection (with injected views) gets its turn.
|
|
85
84
|
normalizedCollections.forEach((c, index) => {
|
|
86
|
-
const raw =
|
|
85
|
+
const raw = deepClone(collections[index]);
|
|
87
86
|
this.rootCollections.push(c);
|
|
88
87
|
this.rawRootCollections.push(raw);
|
|
89
88
|
|
|
@@ -105,7 +104,7 @@ export class CollectionRegistry {
|
|
|
105
104
|
subcollections.forEach((subCollection) => {
|
|
106
105
|
if (!subCollection) return;
|
|
107
106
|
// Spread to avoid mutating the original target() return value
|
|
108
|
-
this._registerRecursively(this.normalizeCollection({ ...subCollection }),
|
|
107
|
+
this._registerRecursively(this.normalizeCollection({ ...subCollection }), deepClone(subCollection));
|
|
109
108
|
});
|
|
110
109
|
}
|
|
111
110
|
});
|
|
@@ -117,7 +116,7 @@ export class CollectionRegistry {
|
|
|
117
116
|
}
|
|
118
117
|
|
|
119
118
|
register(collection: EntityCollection, rawCollection?: EntityCollection) {
|
|
120
|
-
const raw = rawCollection ?
|
|
119
|
+
const raw = rawCollection ? deepClone(rawCollection) : deepClone(collection);
|
|
121
120
|
|
|
122
121
|
this.rootCollections.push(collection);
|
|
123
122
|
this.rawRootCollections.push(raw);
|
|
@@ -149,7 +148,7 @@ export class CollectionRegistry {
|
|
|
149
148
|
subcollections.forEach((subCollection) => {
|
|
150
149
|
if (!subCollection) return;
|
|
151
150
|
// Spread to avoid mutating the original target() return value
|
|
152
|
-
this._registerRecursively(this.normalizeCollection({ ...subCollection }),
|
|
151
|
+
this._registerRecursively(this.normalizeCollection({ ...subCollection }), deepClone(subCollection));
|
|
153
152
|
});
|
|
154
153
|
}
|
|
155
154
|
}
|