@rebasepro/common 0.17.3 → 0.18.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/README.md +4 -0
- package/dist/collections/CollectionRegistry.d.ts +1 -1
- package/dist/collections/default-collections.d.ts +15 -84
- package/dist/data/buildRebaseData.d.ts +1 -1
- package/dist/data/filter-dialect.d.ts +11 -0
- package/dist/data/sort-dialect.d.ts +15 -3
- package/dist/index.es.js +375 -63
- package/dist/index.es.js.map +1 -1
- package/dist/util/builders.d.ts +69 -24
- package/dist/util/callback-errors.d.ts +77 -0
- package/dist/util/callback-errors.test.d.ts +1 -0
- package/dist/util/index.d.ts +1 -0
- package/dist/util/policy/evaluatePolicy.d.ts +6 -0
- package/dist/util/relations.d.ts +41 -0
- package/dist/util/table-name.test.d.ts +1 -0
- package/package.json +26 -22
- package/src/collections/CollectionRegistry.ts +0 -485
- package/src/collections/default-collections.ts +0 -109
- package/src/collections/index.ts +0 -2
- package/src/data/buildRebaseData.ts +0 -816
- package/src/data/buildRoutedRebaseData.ts +0 -103
- package/src/data/filter-conditions.ts +0 -46
- package/src/data/filter-dialect.ts +0 -737
- package/src/data/paginate.ts +0 -334
- package/src/data/query_builder.ts +0 -176
- package/src/data/resolveDataSource.ts +0 -135
- package/src/data/sort-dialect.ts +0 -237
- package/src/index.ts +0 -11
- package/src/table-classification.ts +0 -109
- package/src/types/json-logic-js.d.ts +0 -8
- package/src/util/auth-default-policies.ts +0 -215
- package/src/util/builders.ts +0 -82
- package/src/util/callbacks.ts +0 -122
- package/src/util/collections.ts +0 -117
- package/src/util/common.ts +0 -2
- package/src/util/conditions.ts +0 -168
- package/src/util/email.ts +0 -32
- package/src/util/entities.ts +0 -282
- package/src/util/enums.ts +0 -26
- package/src/util/identity.ts +0 -202
- package/src/util/index.ts +0 -21
- package/src/util/internal-tables.test.ts +0 -188
- package/src/util/internal-tables.ts +0 -197
- package/src/util/junction-policies.ts +0 -355
- package/src/util/paths.ts +0 -27
- package/src/util/permissions.test.ts +0 -866
- package/src/util/permissions.ts +0 -206
- package/src/util/pg-column-to-property.ts +0 -377
- package/src/util/policy/evaluatePolicy.ts +0 -194
- package/src/util/policy/index.ts +0 -4
- package/src/util/policy/policyToPostgres.ts +0 -263
- package/src/util/policy/securityRuleToConditions.ts +0 -67
- package/src/util/policy/sqlToPolicy.ts +0 -422
- package/src/util/relations.ts +0 -236
- package/src/util/resolutions.ts +0 -534
- package/src/util/resolve-relation.ts +0 -243
- package/src/util/storage.ts +0 -177
- package/src/util/string-column-length.ts +0 -31
package/README.md
CHANGED
|
@@ -8,6 +8,10 @@ Shared utilities, collection registry, data driver adapter, and fluent query bui
|
|
|
8
8
|
pnpm add @rebasepro/common
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
+
ESM-only: `"type": "module"` with no CommonJS build, so it is loaded with
|
|
12
|
+
`import`. `require()` of it resolves only on Node 22.12+, which supports
|
|
13
|
+
`require(esm)`.
|
|
14
|
+
|
|
11
15
|
## What This Package Does
|
|
12
16
|
|
|
13
17
|
`@rebasepro/common` is the lowest-level shared logic layer in the Rebase frontend stack. It provides:
|
|
@@ -9,7 +9,7 @@ export declare class CollectionRegistry {
|
|
|
9
9
|
private dataSources;
|
|
10
10
|
/**
|
|
11
11
|
* Global lifecycle callbacks applied to every collection.
|
|
12
|
-
* Runs on all data paths (REST, WebSocket, `rebase.
|
|
12
|
+
* Runs on all data paths (REST, WebSocket, `rebase.dataAsAdmin`).
|
|
13
13
|
* Execution order: global → collection → property callbacks.
|
|
14
14
|
*/
|
|
15
15
|
private _globalCallbacks?;
|
|
@@ -11,90 +11,21 @@
|
|
|
11
11
|
* `config/collections/users.ts` carries the presentation for projects that want this
|
|
12
12
|
* collection in their panel, which is also where it is editable.
|
|
13
13
|
*/
|
|
14
|
-
export declare const defaultUsersCollection: import("@rebasepro/types").PostgresCollectionConfig<
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
readonly name: "Name";
|
|
30
|
-
readonly type: "string";
|
|
31
|
-
readonly columnName: "display_name";
|
|
32
|
-
readonly validation: {
|
|
33
|
-
readonly required: true;
|
|
34
|
-
};
|
|
35
|
-
};
|
|
36
|
-
readonly photoURL: {
|
|
37
|
-
readonly name: "Photo URL";
|
|
38
|
-
readonly type: "string";
|
|
39
|
-
readonly columnName: "photo_url";
|
|
40
|
-
};
|
|
41
|
-
readonly roles: {
|
|
42
|
-
readonly name: "Roles";
|
|
43
|
-
readonly type: "array";
|
|
44
|
-
readonly columnType: "text[]";
|
|
45
|
-
readonly of: {
|
|
46
|
-
readonly name: "Role";
|
|
47
|
-
readonly type: "string";
|
|
48
|
-
readonly enum: {
|
|
49
|
-
readonly admin: "Admin";
|
|
50
|
-
readonly editor: "Editor";
|
|
51
|
-
readonly viewer: "Viewer";
|
|
52
|
-
};
|
|
53
|
-
};
|
|
54
|
-
};
|
|
55
|
-
readonly passwordHash: {
|
|
56
|
-
readonly name: "Password Hash";
|
|
57
|
-
readonly type: "string";
|
|
58
|
-
readonly columnName: "password_hash";
|
|
59
|
-
readonly excludeFromApi: true;
|
|
60
|
-
};
|
|
61
|
-
readonly emailVerified: {
|
|
62
|
-
readonly name: "Email Verified";
|
|
63
|
-
readonly type: "boolean";
|
|
64
|
-
readonly columnName: "email_verified";
|
|
65
|
-
readonly defaultValue: false;
|
|
66
|
-
};
|
|
67
|
-
readonly emailVerificationToken: {
|
|
68
|
-
readonly name: "Email Verification Token";
|
|
69
|
-
readonly type: "string";
|
|
70
|
-
readonly columnName: "email_verification_token";
|
|
71
|
-
readonly excludeFromApi: true;
|
|
72
|
-
};
|
|
73
|
-
readonly emailVerificationSentAt: {
|
|
74
|
-
readonly name: "Email Verification Sent At";
|
|
75
|
-
readonly type: "date";
|
|
76
|
-
readonly columnName: "email_verification_sent_at";
|
|
77
|
-
};
|
|
78
|
-
readonly metadata: {
|
|
79
|
-
readonly name: "Metadata";
|
|
80
|
-
readonly type: "map";
|
|
81
|
-
readonly keyValue: true;
|
|
82
|
-
readonly properties: {};
|
|
83
|
-
readonly defaultValue: {};
|
|
84
|
-
};
|
|
85
|
-
readonly createdAt: {
|
|
86
|
-
readonly name: "Created At";
|
|
87
|
-
readonly type: "date";
|
|
88
|
-
readonly columnName: "created_at";
|
|
89
|
-
readonly autoValue: "on_create";
|
|
90
|
-
};
|
|
91
|
-
readonly updatedAt: {
|
|
92
|
-
readonly name: "Updated At";
|
|
93
|
-
readonly type: "date";
|
|
94
|
-
readonly columnName: "updated_at";
|
|
95
|
-
readonly autoValue: "on_update";
|
|
96
|
-
};
|
|
97
|
-
}>, import("@rebasepro/types").User> & {
|
|
14
|
+
export declare const defaultUsersCollection: import("@rebasepro/types").PostgresCollectionConfig<{
|
|
15
|
+
email: string;
|
|
16
|
+
displayName: string;
|
|
17
|
+
} & {
|
|
18
|
+
id?: string | undefined;
|
|
19
|
+
metadata?: import("@rebasepro/types").InferEntityType<{}> | undefined;
|
|
20
|
+
photoURL?: string | undefined;
|
|
21
|
+
roles?: string[] | undefined;
|
|
22
|
+
passwordHash?: string | undefined;
|
|
23
|
+
emailVerified?: boolean | undefined;
|
|
24
|
+
emailVerificationToken?: string | undefined;
|
|
25
|
+
emailVerificationSentAt?: Date | undefined;
|
|
26
|
+
createdAt?: Date | undefined;
|
|
27
|
+
updatedAt?: Date | undefined;
|
|
28
|
+
}, import("@rebasepro/types").User> & {
|
|
98
29
|
properties: {
|
|
99
30
|
readonly id: {
|
|
100
31
|
readonly name: "ID";
|
|
@@ -57,7 +57,7 @@ export declare function wrapAsSdkData(entityData: RebaseData): RebaseSdkData;
|
|
|
57
57
|
* Build a flat {@link RebaseSdkData} from a `DataDriver`.
|
|
58
58
|
*
|
|
59
59
|
* This is the developer-facing SDK data layer used by backend framework
|
|
60
|
-
* callbacks & scripts (`context.data` / `rebase.
|
|
60
|
+
* callbacks & scripts (`context.data` / `rebase.dataAsAdmin`). It returns flat rows —
|
|
61
61
|
* identical in shape to the frontend SDK client, down to how a relation is
|
|
62
62
|
* served: a foreign key stays a foreign key, and a relation named in `include`
|
|
63
63
|
* arrives as the target's own columns. The `{ __type: "relation" }` envelope is
|
|
@@ -105,10 +105,21 @@ export declare function deserializeFilter(query: Record<string, unknown>): Filte
|
|
|
105
105
|
/**
|
|
106
106
|
* Serialize a `LogicalCondition` or `FilterCondition` to its wire-format string.
|
|
107
107
|
*
|
|
108
|
+
* Leaf encoding is {@link serializeOperatorAndValue}, the same function
|
|
109
|
+
* `serializeTuple` uses, so `null`, the empty list and an unknown operator
|
|
110
|
+
* behave identically inside a group and in a query parameter.
|
|
111
|
+
*
|
|
112
|
+
* @throws {TypeError} when a leaf names an operator this dialect does not have.
|
|
113
|
+
* It used to fall back to `eq`, which turned `age >= 18` into `age = 18` with
|
|
114
|
+
* no diagnostic anywhere.
|
|
115
|
+
*
|
|
108
116
|
* @example
|
|
109
117
|
* serializeLogicalCondition({ column: "status", operator: "==", value: "active" })
|
|
110
118
|
* // → "status.eq.active"
|
|
111
119
|
*
|
|
120
|
+
* serializeLogicalCondition({ column: "deleted_at", operator: "==", value: null })
|
|
121
|
+
* // → "deleted_at.isnull.null"
|
|
122
|
+
*
|
|
112
123
|
* serializeLogicalCondition({ type: "or", conditions: [...] })
|
|
113
124
|
* // → "or(status.eq.active,status.eq.pending)"
|
|
114
125
|
*/
|
|
@@ -98,17 +98,29 @@ export declare function serializeOrderBy(orderBy?: OrderBySpec | string): string
|
|
|
98
98
|
/**
|
|
99
99
|
* Deserialize a wire-format `"field:direction"` string into an {@link OrderByTuple}.
|
|
100
100
|
*
|
|
101
|
-
* Lenient parsing
|
|
101
|
+
* Lenient parsing:
|
|
102
102
|
* - Bare field name (no colon): `"name"` → `["name", "asc"]`
|
|
103
103
|
* - Unknown direction: `"name:foo"` → `["name", "asc"]`
|
|
104
|
-
* - Empty / falsy input: → `undefined`
|
|
104
|
+
* - Empty / falsy input, or a blank field name: → `undefined`
|
|
105
|
+
*
|
|
106
|
+
* The leniency is this end's alone; the *server* refuses the same value. This
|
|
107
|
+
* used to say "matches existing server behaviour", and it stopped being true
|
|
108
|
+
* when `parseOrderByParam` grew a strict direction check: `?orderBy=name:foo`
|
|
109
|
+
* now answers `400 INVALID_ORDER_BY` ("entry 0 has direction 'foo'"). The split
|
|
110
|
+
* is deliberate — see {@link parseOrderBySpecStrict} — because a value this
|
|
111
|
+
* function is handed was produced by {@link serializeOrderBy} a moment earlier,
|
|
112
|
+
* and one that reaches the server came from a stranger.
|
|
113
|
+
*
|
|
114
|
+
* A blank field is `undefined` rather than `[" ", "asc"]`: whitespace is not a
|
|
115
|
+
* field name, and the tuple it used to produce could not be re-encoded — the
|
|
116
|
+
* only value in this codec that survived a decode and failed the next encode.
|
|
105
117
|
*
|
|
106
118
|
* Reads the single-key shorthand only. For a value that may carry several keys,
|
|
107
119
|
* use {@link deserializeOrderByList} — handed a JSON array this returns the
|
|
108
120
|
* whole array as one nonsensical field name.
|
|
109
121
|
*
|
|
110
122
|
* @param raw - The wire-format string from an HTTP query parameter.
|
|
111
|
-
* @returns The canonical tuple, or `undefined` if the input
|
|
123
|
+
* @returns The canonical tuple, or `undefined` if the input names no field.
|
|
112
124
|
*/
|
|
113
125
|
export declare function deserializeOrderBy(raw?: string): OrderByTuple | undefined;
|
|
114
126
|
/**
|