@gettersethya/mira-collection 0.1.0-alpha.34 → 0.1.0-alpha.36
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 +25 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -6,6 +6,8 @@
|
|
|
6
6
|
|
|
7
7
|
Collection definitions, filter DSL, and access rule builder for [Mira](https://github.com/gettersethya/mira). Shared between server and client — isomorphic, no runtime dependencies beyond `effect`.
|
|
8
8
|
|
|
9
|
+
**Documentation:** https://gettersethya.github.io/mira/docs/collections/
|
|
10
|
+
|
|
9
11
|
## Installation
|
|
10
12
|
|
|
11
13
|
```bash
|
|
@@ -111,6 +113,25 @@ Bytes.fromGB(n)
|
|
|
111
113
|
Bytes.fromTB(n)
|
|
112
114
|
```
|
|
113
115
|
|
|
116
|
+
Every field also accepts `name` (override the column name), `required`, `default`,
|
|
117
|
+
`hidden` (strip from non-admin responses and reject in `select`), `unique`, `indexed`,
|
|
118
|
+
and `error` (a callback that maps a constraint kind to a custom validation message).
|
|
119
|
+
A field is required unless `required: false` or a `default` is set. `Field.date` stores
|
|
120
|
+
the provided string as-is; it does not parse or validate ISO 8601. `Field.file({ protected: true })`
|
|
121
|
+
requires a short-lived file token to download.
|
|
122
|
+
|
|
123
|
+
## Relations
|
|
124
|
+
|
|
125
|
+
`Field.relation(Target, { field })` stores another collection's field value, defaulting to
|
|
126
|
+
the target's `id`. Only the target collection name and target field are serialized. `expand`
|
|
127
|
+
joins the target's `id`; a relation declared with a different target field stores and
|
|
128
|
+
validates that value, but is not expanded by the current join.
|
|
129
|
+
|
|
130
|
+
```typescript
|
|
131
|
+
author: Field.relation(Users) // stores users.id
|
|
132
|
+
ownerEmail: Field.relation(Users, { field: "email" })
|
|
133
|
+
```
|
|
134
|
+
|
|
114
135
|
## Indexes
|
|
115
136
|
|
|
116
137
|
```typescript
|
|
@@ -131,6 +152,10 @@ Field.text({ indexed: true }) // non-unique index
|
|
|
131
152
|
|
|
132
153
|
Rules are evaluated server-side on every request. A missing key means **deny all** for that action.
|
|
133
154
|
|
|
155
|
+
`manage` is available on auth collections only and is additive: it never bypasses the
|
|
156
|
+
base create/update rule, but a matching manager may set `email`/`emailVerified` and
|
|
157
|
+
change a password without `oldPassword`. It has no effect on `list`, `view`, or `delete`.
|
|
158
|
+
|
|
134
159
|
```typescript
|
|
135
160
|
Rule.public() // allow all
|
|
136
161
|
R.authId(Users).neq(R.literal("")) // logged-in users only
|