@venizia/ignis-docs 0.0.8-1 → 0.0.8-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/package.json +13 -13
- package/wiki/extensions/components/authorization/api.md +239 -376
- package/wiki/extensions/components/authorization/errors.md +52 -43
- package/wiki/extensions/components/authorization/index.md +127 -65
- package/wiki/extensions/components/authorization/usage.md +198 -98
- package/wiki/guides/migrations/scoped-rbac-migration.md +300 -0
- package/wiki/references/base/filter-system/default-filter.md +6 -3
- package/wiki/references/base/filter-system/fields-order-pagination.md +26 -0
- package/wiki/references/base/models.md +6 -3
|
@@ -132,6 +132,32 @@ await repo.find({
|
|
|
132
132
|
> [!TIP]
|
|
133
133
|
> Always use `limit` for public-facing endpoints to prevent memory exhaustion. The default limit is 10 if not specified.
|
|
134
134
|
|
|
135
|
+
### Default Limit
|
|
136
|
+
|
|
137
|
+
When a query omits `limit`, the repository resolves one with this precedence:
|
|
138
|
+
|
|
139
|
+
```
|
|
140
|
+
query.limit ?? model settings.defaultLimit ?? DEFAULT_LIMIT (10)
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
- **`query.limit`** — an explicit `limit` in the filter always wins.
|
|
144
|
+
- **`settings.defaultLimit`** — a per-model default set on the `@model` decorator. Must be a positive integer (validated at decoration time). Applies to top-level `find()` and to every to-many relation (using the related model's own `defaultLimit`).
|
|
145
|
+
- **`DEFAULT_LIMIT`** — the global fallback, `10`.
|
|
146
|
+
|
|
147
|
+
```typescript
|
|
148
|
+
@model({
|
|
149
|
+
type: 'entity',
|
|
150
|
+
settings: { defaultLimit: 200 }, // Small lookup table — default to 200 rows
|
|
151
|
+
})
|
|
152
|
+
export class Country extends BaseEntity<typeof Country.schema> {}
|
|
153
|
+
|
|
154
|
+
await countryRepo.find({ filter: {} }); // LIMIT 200
|
|
155
|
+
await countryRepo.find({ filter: { limit: 10 } }); // LIMIT 10 (explicit wins)
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
> [!NOTE]
|
|
159
|
+
> `defaultLimit` is independent of `defaultFilter`: passing `shouldSkipDefaultFilter` to bypass the default `where` clause does **not** drop the default limit. There is no "unbounded" sentinel — to fetch more rows, pass an explicit `limit`.
|
|
160
|
+
|
|
135
161
|
### Pagination Helper
|
|
136
162
|
|
|
137
163
|
```typescript
|
|
@@ -51,6 +51,7 @@ The `@model` decorator marks a class as a database entity and configures its beh
|
|
|
51
51
|
settings?: {
|
|
52
52
|
hiddenProperties?: string[], // Properties to exclude from query results
|
|
53
53
|
defaultFilter?: TFilter, // Filter applied to all repository queries
|
|
54
|
+
defaultLimit?: number, // Default row limit when a query omits `limit`
|
|
54
55
|
authorize?: { // Authorization settings
|
|
55
56
|
principal: string, // Authorization subject name
|
|
56
57
|
[extra: string | symbol]: any, // Extensible metadata
|
|
@@ -66,15 +67,17 @@ The `@model` decorator marks a class as a database entity and configures its beh
|
|
|
66
67
|
| `skipMigrate` | `boolean` | Skip this model during schema migrations |
|
|
67
68
|
| `settings.hiddenProperties` | `string[]` | Array of property names to exclude from all repository query results |
|
|
68
69
|
| `settings.defaultFilter` | `TFilter` | Filter automatically applied to all repository queries (see [Default Filter](/references/base/filter-system/default-filter)) |
|
|
70
|
+
| `settings.defaultLimit` | `number` | Default row limit applied when a query omits `limit`. Must be a positive integer (validated at decoration time). Falls back to the global `DEFAULT_LIMIT` (10). See [Pagination](/references/base/filter-system/fields-order-pagination#default-limit) |
|
|
69
71
|
| `settings.authorize` | `IModelAuthorizeSettings` | Authorization settings — declares the model's authorization principal (see [Authorization](/extensions/components/authorization/usage#model-based-resource-references)) |
|
|
70
72
|
| `settings.authorize.principal` | `string` | The authorization subject name for this model. Auto-populates `AUTHORIZATION_SUBJECT` static property |
|
|
71
73
|
|
|
72
74
|
#### `@model` Behavior
|
|
73
75
|
|
|
74
76
|
When the `@model` decorator is applied:
|
|
75
|
-
1. If `settings.
|
|
76
|
-
2.
|
|
77
|
-
3. The
|
|
77
|
+
1. If `settings.defaultLimit` is provided, it is validated to be a positive integer — otherwise the decorator throws at decoration (boot) time
|
|
78
|
+
2. If `settings.authorize.principal` is provided and `AUTHORIZATION_SUBJECT` is not already defined on the class, it auto-populates `AUTHORIZATION_SUBJECT` with the principal value
|
|
79
|
+
3. The model is registered in the `MetadataRegistry` model registry, keyed by table name (resolved as: `metadata.tableName` > `static TABLE_NAME` > class name)
|
|
80
|
+
4. The static `relations` property is stored as a resolver (not immediately resolved) to avoid circular dependency issues between models
|
|
78
81
|
|
|
79
82
|
### Hidden Properties
|
|
80
83
|
|