@rebasepro/common 0.23.0 → 0.24.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/CollectionRegistry.d.ts +72 -3
- package/dist/data/buildRebaseData.d.ts +15 -0
- package/dist/data/cursor.d.ts +1 -1
- package/dist/index.es.js +410 -57
- package/dist/index.es.js.map +1 -1
- package/dist/util/copy.d.ts +33 -0
- package/dist/util/entities.d.ts +9 -1
- package/dist/util/index.d.ts +2 -0
- package/dist/util/policy/compileRulePolicies.d.ts +32 -0
- package/dist/util/policy/index.d.ts +1 -0
- package/dist/util/untrusted-envelope.d.ts +25 -0
- package/package.json +3 -3
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { CollectionConfig, ResolvedRelation } from "@rebasepro/types";
|
|
2
|
+
/**
|
|
3
|
+
* Whether a duplicate of a record may carry this relation's value.
|
|
4
|
+
*
|
|
5
|
+
* A duplicate is saved as a create, and a create writes every relation it
|
|
6
|
+
* carries. That is right where the link is the copy's own: a `belongsTo` key on
|
|
7
|
+
* the copy's row, or `manyToMany` links, which are new junction rows beside the
|
|
8
|
+
* original's — the targets are shared by design. It is wrong wherever the key
|
|
9
|
+
* lives on the other row. Writing a `hasMany` or a `hasOne` points the
|
|
10
|
+
* children's foreign key at the copy, which takes them away from the record
|
|
11
|
+
* that was copied: duplicating an author moved every one of their posts to the
|
|
12
|
+
* duplicate and left the original with none. A `via` is declared read-only,
|
|
13
|
+
* and its one-to-one writer re-points the target's key the same way.
|
|
14
|
+
*
|
|
15
|
+
* Exhaustive over the kinds, so a new one is a compile error here rather than
|
|
16
|
+
* a copy that quietly carries it.
|
|
17
|
+
*/
|
|
18
|
+
export declare function copyCarriesRelation(relation: ResolvedRelation): boolean;
|
|
19
|
+
/**
|
|
20
|
+
* The values a duplicate of a record is created with: the original's, less
|
|
21
|
+
* its key and less every relation the copy cannot take without changing
|
|
22
|
+
* another row (see {@link copyCarriesRelation}).
|
|
23
|
+
*
|
|
24
|
+
* The key goes so the database, or the user, gives the copy its own. The
|
|
25
|
+
* relations go because the copy is written as a create, and a create writes
|
|
26
|
+
* them — for a child-held key that is a re-parent of rows the user never
|
|
27
|
+
* touched, with nothing on screen to say so.
|
|
28
|
+
*
|
|
29
|
+
* A relation property that does not resolve is left out as well: what writing
|
|
30
|
+
* it would do cannot be known here, and leaving a value out of a new record
|
|
31
|
+
* changes nothing that exists.
|
|
32
|
+
*/
|
|
33
|
+
export declare function getCopyValues<M extends Record<string, unknown>>(collection: CollectionConfig, values: Partial<M>): Partial<M>;
|
package/dist/util/entities.d.ts
CHANGED
|
@@ -99,7 +99,15 @@ export declare function applyDefaultValuesOnCreate<M extends Record<string, unkn
|
|
|
99
99
|
* @group Driver
|
|
100
100
|
*/
|
|
101
101
|
export declare function sanitizeData<M extends Record<string, unknown>>(values: EntityValues<M>, properties: Properties): Record<string, unknown>;
|
|
102
|
-
|
|
102
|
+
/**
|
|
103
|
+
* A reference to `entity`.
|
|
104
|
+
*
|
|
105
|
+
* @param path where the reference points, when that is not the path the
|
|
106
|
+
* entity is addressed by. A Firestore or MongoDB collection may declare a
|
|
107
|
+
* `path` for its store other than its slug, and a reference has to carry the
|
|
108
|
+
* stored one, where `entity.path` is the path the admin addresses it by.
|
|
109
|
+
*/
|
|
110
|
+
export declare function getReferenceFrom<M extends Record<string, unknown>>(entity: Entity<M>, path?: string): EntityReference;
|
|
103
111
|
export declare function getRelationFrom<M extends Record<string, unknown>>(entity: Entity<M>): EntityRelation;
|
|
104
112
|
/**
|
|
105
113
|
* Normalize a value into a proper EntityRelation instance.
|
package/dist/util/index.d.ts
CHANGED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { CollectionConfig, SecurityOperation, SecurityRule } from "@rebasepro/types";
|
|
2
|
+
import { type PolicyCompileOptions } from "./policyToPostgres.js";
|
|
3
|
+
/**
|
|
4
|
+
* One Postgres policy a security rule compiles to: its name and the clauses
|
|
5
|
+
* `CREATE POLICY` is given for it.
|
|
6
|
+
*/
|
|
7
|
+
export interface CompiledRulePolicy {
|
|
8
|
+
name: string;
|
|
9
|
+
operation: SecurityOperation;
|
|
10
|
+
/** `permissive` | `restrictive`, lower-case as the rule spells it. */
|
|
11
|
+
mode: "permissive" | "restrictive";
|
|
12
|
+
/** The `TO` list. Sorted, `["public"]` when the rule names none. */
|
|
13
|
+
roles: string[];
|
|
14
|
+
/** The `USING` clause, or `null` when the operation takes none. */
|
|
15
|
+
using: string | null;
|
|
16
|
+
/** The `WITH CHECK` clause, or `null` when the operation takes none. */
|
|
17
|
+
withCheck: string | null;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* The policies one security rule compiles to — one per operation.
|
|
21
|
+
*
|
|
22
|
+
* The schema planner writes these into the database, and the Studio's RLS
|
|
23
|
+
* editor compares the database against them; both call this, so "what the code
|
|
24
|
+
* declares" has one meaning.
|
|
25
|
+
*
|
|
26
|
+
* The desugaring (`access` / `ownerField` / `roles` / structured condition /
|
|
27
|
+
* raw SQL → `PolicyExpression`) is {@link securityRuleToConditions}, and the SQL
|
|
28
|
+
* is {@link policyToPostgres}. What lives here is only the shape: which
|
|
29
|
+
* operations a rule expands to, which clauses each operation takes, and the
|
|
30
|
+
* deny-all fallback for a clause that compiled to nothing.
|
|
31
|
+
*/
|
|
32
|
+
export declare function compileRulePolicies(collection: CollectionConfig, rule: SecurityRule, options?: PolicyCompileOptions): CompiledRulePolicy[];
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wrap text that came out of an application's data in an explicit
|
|
3
|
+
* untrusted-data envelope, for a language model to read.
|
|
4
|
+
*
|
|
5
|
+
* A row is text somebody else wrote — a `body` column an anonymous visitor
|
|
6
|
+
* filled in, a support-ticket title — and an MCP tool hands it to the model on
|
|
7
|
+
* the same channel as the tool contract the model is following, in a session
|
|
8
|
+
* that also holds `update_document` and `delete_document`. So an instruction
|
|
9
|
+
* smuggled through a row is an instruction with reach. A fenced envelope does
|
|
10
|
+
* not solve prompt injection; handing the row over with no marking at all is
|
|
11
|
+
* below the floor.
|
|
12
|
+
*
|
|
13
|
+
* The fence has to be one the data cannot close. A fixed end marker is text any
|
|
14
|
+
* row can print, and whatever follows it would sit outside the block — the one
|
|
15
|
+
* place the envelope tells the model to trust. So each envelope's markers carry
|
|
16
|
+
* an id minted for this response, after the data was written, and a
|
|
17
|
+
* marker-like string inside the body is broken with a zero-width space so it
|
|
18
|
+
* does not read as one. The source is JSON-escaped (with `<` and `>` too), so
|
|
19
|
+
* it cannot end the opening marker early either.
|
|
20
|
+
*
|
|
21
|
+
* The remote MCP endpoint (`@rebasepro/server`) wraps with this. The local MCP
|
|
22
|
+
* server (`@rebasepro/mcp`) has its own copy, held to this one's output by a
|
|
23
|
+
* test in that package.
|
|
24
|
+
*/
|
|
25
|
+
export declare function untrustedEnvelope(source: string, body: string): string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rebasepro/common",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.24.0",
|
|
4
4
|
"description": "Rebase shared core — collection registry, data driver adapter and fluent query builder. No React dependency.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"rebase",
|
|
@@ -44,8 +44,8 @@
|
|
|
44
44
|
"dependencies": {
|
|
45
45
|
"fast-equals": "6.0.2",
|
|
46
46
|
"json-logic-js": "^2.0.5",
|
|
47
|
-
"@rebasepro/types": "0.
|
|
48
|
-
"@rebasepro/utils": "0.
|
|
47
|
+
"@rebasepro/types": "0.24.0",
|
|
48
|
+
"@rebasepro/utils": "0.24.0"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"@jest/globals": "^30.4.1",
|