@rebasepro/common 0.2.3 → 0.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/dist/collections/default-collections.d.ts +12 -0
- package/dist/collections/index.d.ts +1 -0
- package/dist/index.es.js +86 -0
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +86 -0
- package/dist/index.umd.js.map +1 -1
- package/dist/util/permissions.d.ts +1 -0
- package/package.json +3 -3
- package/src/collections/default-collections.ts +79 -0
- package/src/collections/index.ts +1 -0
- package/src/data/buildRebaseData.ts +1 -1
- package/src/util/permissions.ts +1 -1
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { AuthController, Entity, EntityCollection, User } from "@rebasepro/types";
|
|
2
|
+
export declare function checkOperation<M extends Record<string, unknown>, USER extends User>(collection: EntityCollection<M>, authController: AuthController<USER>, entity: Entity<M> | null, targetOperation: "select" | "insert" | "update" | "delete"): boolean;
|
|
2
3
|
export declare function canReadCollection<M extends Record<string, unknown>, USER extends User>(collection: EntityCollection<M>, authController: AuthController<USER>): boolean;
|
|
3
4
|
export declare function canEditEntity<M extends Record<string, unknown>, USER extends User>(collection: EntityCollection<M>, authController: AuthController<USER>, path: string, entity: Entity<M> | null): boolean;
|
|
4
5
|
export declare function canCreateEntity<M extends Record<string, unknown>, USER extends User>(collection: EntityCollection<M>, authController: AuthController<USER>, path: string, entity: Entity<M> | null): boolean;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rebasepro/common",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.3.0",
|
|
5
5
|
"description": "Awesome Firebase/Firestore-based headless open-source CMS",
|
|
6
6
|
"funding": {
|
|
7
7
|
"url": "https://github.com/sponsors/rebaseco"
|
|
@@ -41,8 +41,8 @@
|
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"fast-equals": "6.0.0",
|
|
43
43
|
"json-logic-js": "^2.0.5",
|
|
44
|
-
"@rebasepro/types": "0.
|
|
45
|
-
"@rebasepro/utils": "0.
|
|
44
|
+
"@rebasepro/types": "0.3.0",
|
|
45
|
+
"@rebasepro/utils": "0.3.0"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"@jest/globals": "^29.7.0",
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { PostgresCollection } from "@rebasepro/types";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Default users collection definition.
|
|
5
|
+
*
|
|
6
|
+
* Shared between the admin UI (for navigation/display) and the backend
|
|
7
|
+
* (for schema generation). Both consumers prepend this to the developer's
|
|
8
|
+
* collections array and rely on generic slug-based deduplication
|
|
9
|
+
* (Map keyed by slug, last-write-wins) so that developer-defined
|
|
10
|
+
* collections with the same slug override this default — no hardcoded
|
|
11
|
+
* string checks required.
|
|
12
|
+
*/
|
|
13
|
+
export const defaultUsersCollection: PostgresCollection = {
|
|
14
|
+
name: "Users",
|
|
15
|
+
singularName: "User",
|
|
16
|
+
slug: "users",
|
|
17
|
+
table: "users",
|
|
18
|
+
schema: "rebase",
|
|
19
|
+
icon: "Users",
|
|
20
|
+
group: "Settings",
|
|
21
|
+
properties: {
|
|
22
|
+
id: {
|
|
23
|
+
name: "ID",
|
|
24
|
+
type: "string",
|
|
25
|
+
isId: "uuid"
|
|
26
|
+
},
|
|
27
|
+
email: {
|
|
28
|
+
name: "Email",
|
|
29
|
+
type: "string",
|
|
30
|
+
validation: { required: true, unique: true }
|
|
31
|
+
},
|
|
32
|
+
password_hash: {
|
|
33
|
+
name: "Password Hash",
|
|
34
|
+
type: "string",
|
|
35
|
+
ui: { hideFromCollection: true }
|
|
36
|
+
},
|
|
37
|
+
display_name: {
|
|
38
|
+
name: "Display Name",
|
|
39
|
+
type: "string"
|
|
40
|
+
},
|
|
41
|
+
photo_url: {
|
|
42
|
+
name: "Photo URL",
|
|
43
|
+
type: "string"
|
|
44
|
+
},
|
|
45
|
+
email_verified: {
|
|
46
|
+
name: "Email Verified",
|
|
47
|
+
type: "boolean",
|
|
48
|
+
defaultValue: false
|
|
49
|
+
},
|
|
50
|
+
email_verification_token: {
|
|
51
|
+
name: "Email Verification Token",
|
|
52
|
+
type: "string",
|
|
53
|
+
ui: { hideFromCollection: true }
|
|
54
|
+
},
|
|
55
|
+
email_verification_sent_at: {
|
|
56
|
+
name: "Email Verification Sent At",
|
|
57
|
+
type: "date",
|
|
58
|
+
ui: { hideFromCollection: true }
|
|
59
|
+
},
|
|
60
|
+
metadata: {
|
|
61
|
+
name: "Metadata",
|
|
62
|
+
type: "map",
|
|
63
|
+
defaultValue: {},
|
|
64
|
+
ui: { hideFromCollection: true }
|
|
65
|
+
},
|
|
66
|
+
created_at: {
|
|
67
|
+
name: "Created At",
|
|
68
|
+
type: "date",
|
|
69
|
+
autoValue: "on_create",
|
|
70
|
+
ui: { readOnly: true, hideFromCollection: true }
|
|
71
|
+
},
|
|
72
|
+
updated_at: {
|
|
73
|
+
name: "Updated At",
|
|
74
|
+
type: "date",
|
|
75
|
+
autoValue: "on_update",
|
|
76
|
+
ui: { readOnly: true, hideFromCollection: true }
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
};
|
package/src/collections/index.ts
CHANGED
|
@@ -238,7 +238,7 @@ values: {} as Record<string, unknown> }
|
|
|
238
238
|
} : undefined,
|
|
239
239
|
|
|
240
240
|
// Fluent Query Builder
|
|
241
|
-
where(column: keyof M & string, operator:
|
|
241
|
+
where(column: keyof M & string, operator: WhereFilterOp, value: unknown) {
|
|
242
242
|
return new QueryBuilder<M>(accessor).where(column, operator, value);
|
|
243
243
|
},
|
|
244
244
|
orderBy(column: keyof M & string, ascending?: "asc" | "desc") {
|
package/src/util/permissions.ts
CHANGED
|
@@ -135,7 +135,7 @@ function evaluateRule<USER extends User, M extends Record<string, unknown>>(rule
|
|
|
135
135
|
return true;
|
|
136
136
|
}
|
|
137
137
|
|
|
138
|
-
function checkOperation<M extends Record<string, unknown>, USER extends User>(
|
|
138
|
+
export function checkOperation<M extends Record<string, unknown>, USER extends User>(
|
|
139
139
|
collection: EntityCollection<M>,
|
|
140
140
|
authController: AuthController<USER>,
|
|
141
141
|
entity: Entity<M> | null,
|