@dyrected/knowledge 0.2.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/LICENSE.md +50 -0
- package/README.md +17 -0
- package/dist/index.d.ts +78 -0
- package/dist/index.js +2776 -0
- package/generated/SKILL.md +276 -0
- package/generated/ai-rules.md +152 -0
- package/generated/endpoints.json +891 -0
- package/generated/examples-inventory.json +3558 -0
- package/generated/intent-index.json +46 -0
- package/generated/llms-index.json +812 -0
- package/generated/openapi.json +1643 -0
- package/generated/recipes.json +224 -0
- package/generated/references.json +1573 -0
- package/package.json +56 -0
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: dyrected
|
|
3
|
+
description: Work correctly with Dyrected in new and existing projects using installation checks, schema safety rules, and compiled implementation recipes.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Dyrected
|
|
7
|
+
|
|
8
|
+
Dyrected is a declarative, schema-driven headless CMS configured primarily through `dyrected.config.ts`.
|
|
9
|
+
|
|
10
|
+
## Step 0 — determine the project state
|
|
11
|
+
|
|
12
|
+
Before changing code, inspect the nearest `package.json` and the workspace root.
|
|
13
|
+
|
|
14
|
+
### Dyrected is not installed
|
|
15
|
+
|
|
16
|
+
Use the CLI:
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
npx @dyrected/cli init
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Detect the framework, package manager, database requirements, storage requirements and deployment target. Let the CLI scaffold configuration, environment variables, Admin integration and AI rules. Verify lint, types and build before modeling content.
|
|
23
|
+
|
|
24
|
+
For an existing website, first inventory editable content and distinguish repeatable entries from singleton settings. Preserve the existing interface, content, URLs and behavior. Do not invent a new content model merely because it is convenient.
|
|
25
|
+
|
|
26
|
+
### Dyrected is installed
|
|
27
|
+
|
|
28
|
+
Read `dyrected.config.ts`, the installed `@dyrected/core` version and its public exports. Inspect the configured database, storage, email, collections, globals, authentication and workflows before proposing changes. Installed types take precedence over remembered APIs or newer documentation.
|
|
29
|
+
|
|
30
|
+
## Operational rules
|
|
31
|
+
|
|
32
|
+
1. Use public package imports such as `@dyrected/core` and `@dyrected/sdk`; do not reach into another workspace package's source directory.
|
|
33
|
+
2. Every named field must define an explicit `label`.
|
|
34
|
+
3. Never invent field types, hook names, configuration keys, adapter methods, SDK methods or REST routes.
|
|
35
|
+
4. Use `client.collection('slug')`, never `client.collections`.
|
|
36
|
+
5. Do not wrap Dyrected Admin routes in custom auth/session middleware.
|
|
37
|
+
6. Do not define `email` or `password` fields on `auth: true` collections; Dyrected injects them.
|
|
38
|
+
7. Do not delete or directly rename persisted fields. Use `renameTo`; add a safe `defaultValue` when introducing fields to existing schemas.
|
|
39
|
+
8. Use server hooks for data correctness. Admin hooks improve live editor feedback but API writes bypass them.
|
|
40
|
+
9. Use serializable Jexl conditions for Cloud-compatible schemas.
|
|
41
|
+
10. Enforce permissions in server access configuration, not only by hiding Admin controls.
|
|
42
|
+
|
|
43
|
+
## Core imports
|
|
44
|
+
|
|
45
|
+
Import public APIs from package entry points:
|
|
46
|
+
|
|
47
|
+
```ts
|
|
48
|
+
import { defineCollection, defineConfig, defineGlobal } from "@dyrected/core";
|
|
49
|
+
import { createClient, type InferSchema } from "@dyrected/sdk";
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Never import from a monorepo source path such as `packages/core/src`. Verify the installed package exports when documentation and local types disagree.
|
|
53
|
+
|
|
54
|
+
## Schema and deployment safety
|
|
55
|
+
|
|
56
|
+
- Read the existing schema before editing it.
|
|
57
|
+
- Make related changes in small batches and verify each batch.
|
|
58
|
+
- Confirm whether the project is Cloud or self-hosted before giving schema synchronization instructions.
|
|
59
|
+
- MongoDB is schema-less; relational adapters may require synchronization for promoted fields.
|
|
60
|
+
- Use `relationship` for the owning stored reference and `join` for a virtual reverse lookup.
|
|
61
|
+
- Use `depth: 0` for lightweight lists and increase depth only when related documents are required.
|
|
62
|
+
- Use hooks for derived values, validation, side effects and revalidation.
|
|
63
|
+
- Use `workflow: publishingWorkflow()` when the requirement is draft, review and publication rather than inventing status logic.
|
|
64
|
+
- Use `defineGlobal` for singleton settings and `defineCollection` for repeatable entries.
|
|
65
|
+
|
|
66
|
+
### Rename a field safely
|
|
67
|
+
|
|
68
|
+
The current `name` is the new key and `renameTo` is the previous stored key:
|
|
69
|
+
|
|
70
|
+
```ts
|
|
71
|
+
{
|
|
72
|
+
name: "fullName",
|
|
73
|
+
type: "text",
|
|
74
|
+
label: "Full name",
|
|
75
|
+
renameTo: "name",
|
|
76
|
+
defaultValue: "",
|
|
77
|
+
}
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Keep the fallback until production documents are migrated and verified. For relational adapters, test promoted or unique changes in staging before synchronization.
|
|
81
|
+
|
|
82
|
+
### Zero-state behavior
|
|
83
|
+
|
|
84
|
+
Use `initialData` only when deliberate seed/fallback behavior is desired:
|
|
85
|
+
|
|
86
|
+
```ts
|
|
87
|
+
const { docs } = await client.collection("posts").find({ initialData: [] });
|
|
88
|
+
const settings = await client
|
|
89
|
+
.global("site-settings")
|
|
90
|
+
.get({ initialData: { siteName: "My site" } });
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
Do not convert authentication, validation, or network failures into empty successful states.
|
|
94
|
+
|
|
95
|
+
## Relationships and depth
|
|
96
|
+
|
|
97
|
+
`relationship` is the stored owning reference. `join` is a virtual reverse lookup.
|
|
98
|
+
|
|
99
|
+
```ts
|
|
100
|
+
{ name: "author", type: "relationship", label: "Author", relationTo: "users" }
|
|
101
|
+
{
|
|
102
|
+
name: "posts",
|
|
103
|
+
type: "join",
|
|
104
|
+
label: "Posts",
|
|
105
|
+
collection: "posts",
|
|
106
|
+
on: "author",
|
|
107
|
+
limit: 20,
|
|
108
|
+
}
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
Use `depth: 0` for lightweight lists and increase depth only when related values are needed. Bound joins and account for their query cost.
|
|
112
|
+
|
|
113
|
+
## Auth and access
|
|
114
|
+
|
|
115
|
+
`auth: true` injects authentication fields and endpoints. Do not redefine `email` or `password`. Treat roles as trusted only when clients cannot assign them to themselves.
|
|
116
|
+
|
|
117
|
+
```ts
|
|
118
|
+
export const Users = defineCollection({
|
|
119
|
+
slug: "users",
|
|
120
|
+
auth: true,
|
|
121
|
+
fields: [
|
|
122
|
+
{ name: "name", type: "text", label: "Name" },
|
|
123
|
+
{
|
|
124
|
+
name: "role",
|
|
125
|
+
type: "select",
|
|
126
|
+
label: "Role",
|
|
127
|
+
options: ["member", "editor", "admin"],
|
|
128
|
+
},
|
|
129
|
+
],
|
|
130
|
+
});
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
Grant read, create, update, delete, and workflow capabilities independently. UI visibility is not authorization.
|
|
134
|
+
|
|
135
|
+
## Uploads
|
|
136
|
+
|
|
137
|
+
```ts
|
|
138
|
+
export const Media = defineCollection({
|
|
139
|
+
slug: "media",
|
|
140
|
+
upload: {
|
|
141
|
+
allowedMimeTypes: ["image/jpeg", "image/png", "image/webp"],
|
|
142
|
+
maxFileSize: 5_000_000,
|
|
143
|
+
},
|
|
144
|
+
fields: [
|
|
145
|
+
{ name: "alt", type: "text", label: "Alternative text", required: true },
|
|
146
|
+
],
|
|
147
|
+
});
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
Consume the returned URL, keep provider credentials server-side, and validate untrusted file contents in addition to MIME metadata.
|
|
151
|
+
|
|
152
|
+
## Dynamic and conditional fields
|
|
153
|
+
|
|
154
|
+
- Static `options`: fixed choices.
|
|
155
|
+
- Server `options` resolver: database access, secrets, user filtering, or caching.
|
|
156
|
+
- `admin.hooks.options`: instant browser-only dependent choices.
|
|
157
|
+
- `admin.condition`: presentation only; use Jexl strings for Cloud synchronization.
|
|
158
|
+
|
|
159
|
+
Server validation is still required when a dependent choice or condition is part of the data contract.
|
|
160
|
+
|
|
161
|
+
## Custom Admin components
|
|
162
|
+
|
|
163
|
+
Reference custom inputs and slots with registered string keys in serializable configuration. Register the actual framework component in the Admin integration. Keep validation and access in the server field definition.
|
|
164
|
+
|
|
165
|
+
## Supported field types
|
|
166
|
+
|
|
167
|
+
<!-- GENERATED:FIELD_TYPES:START -->
|
|
168
|
+
`text`, `textarea`, `richText`, `number`, `boolean`, `date`, `datetime`, `time`, `select`, `multiSelect`, `radio`, `relationship`, `array`, `object`, `json`, `blocks`, `image`, `email`, `url`, `icon`, `join`, `row`
|
|
169
|
+
<!-- GENERATED:FIELD_TYPES:END -->
|
|
170
|
+
|
|
171
|
+
## Compiled recipes
|
|
172
|
+
|
|
173
|
+
These recipes are compiled and behavior-tested. Select them from the user's desired outcome; do not require the user to know Dyrected terminology.
|
|
174
|
+
|
|
175
|
+
<!-- GENERATED:RECIPES:START -->
|
|
176
|
+
- [Generate a slug from a title](https://docs.dyrected.com/docs/recipes/auto-slug) — Generate stable URL slugs on the server while showing editors the value live in the Admin UI.
|
|
177
|
+
- [Show an Admin field only when it is relevant](https://docs.dyrected.com/docs/recipes/conditional-admin-field) — Use a serializable Admin condition to reveal a field from the editor's current form values.
|
|
178
|
+
- [Validate related fields before saving](https://docs.dyrected.com/docs/recipes/cross-field-validation) — Reject invalid combinations of field values before they reach the database.
|
|
179
|
+
- [Update a dropdown from another field](https://docs.dyrected.com/docs/recipes/dependent-dropdown) — Change available Admin UI options immediately when an editor changes a related field.
|
|
180
|
+
- [Add draft, review, and publishing states](https://docs.dyrected.com/docs/recipes/editorial-publishing-workflow) — Attach Dyrected's standard editorial workflow and its capability-aware transitions to a collection.
|
|
181
|
+
- [Limit documents to their owner](https://docs.dyrected.com/docs/recipes/owner-scoped-access) — Return a where constraint from access control so authenticated users only read their own records.
|
|
182
|
+
- [Build flexible pages from reusable blocks](https://docs.dyrected.com/docs/recipes/page-builder-blocks) — Define labeled hero, rich-text, and call-to-action blocks for an editor-controlled page layout.
|
|
183
|
+
- [Model a relationship and its reverse lookup](https://docs.dyrected.com/docs/recipes/relationship-and-reverse-join) — Store an author relationship on posts and expose the author's posts through a virtual join field.
|
|
184
|
+
- [Restrict content operations by user role](https://docs.dyrected.com/docs/recipes/role-based-access) — Allow public reads, editor writes, and administrator deletion with collection access rules.
|
|
185
|
+
- [Rename a field without orphaning existing data](https://docs.dyrected.com/docs/recipes/safe-field-rename) — Use renameTo and a safe default while documents migrate lazily to a new field name.
|
|
186
|
+
- [Create a media upload collection](https://docs.dyrected.com/docs/recipes/upload-collection) — Enable file uploads and capture accessible metadata in a dedicated media collection.
|
|
187
|
+
<!-- GENERATED:RECIPES:END -->
|
|
188
|
+
|
|
189
|
+
## Intent-to-pattern index
|
|
190
|
+
|
|
191
|
+
<!-- GENERATED:INTENTS:START -->
|
|
192
|
+
- “make the URL follow the title” → [Generate a slug from a title](https://docs.dyrected.com/docs/recipes/auto-slug)
|
|
193
|
+
- “automatically generate a slug” → [Generate a slug from a title](https://docs.dyrected.com/docs/recipes/auto-slug)
|
|
194
|
+
- “create friendly URLs from titles” → [Generate a slug from a title](https://docs.dyrected.com/docs/recipes/auto-slug)
|
|
195
|
+
- “keep a slug synchronized with a title” → [Generate a slug from a title](https://docs.dyrected.com/docs/recipes/auto-slug)
|
|
196
|
+
- “show a field conditionally” → [Show an Admin field only when it is relevant](https://docs.dyrected.com/docs/recipes/conditional-admin-field)
|
|
197
|
+
- “hide irrelevant form fields” → [Show an Admin field only when it is relevant](https://docs.dyrected.com/docs/recipes/conditional-admin-field)
|
|
198
|
+
- “show discount only with a coupon” → [Show an Admin field only when it is relevant](https://docs.dyrected.com/docs/recipes/conditional-admin-field)
|
|
199
|
+
- “make the admin form react to another field” → [Show an Admin field only when it is relevant](https://docs.dyrected.com/docs/recipes/conditional-admin-field)
|
|
200
|
+
- “validate fields before saving” → [Validate related fields before saving](https://docs.dyrected.com/docs/recipes/cross-field-validation)
|
|
201
|
+
- “make sure an end date is after the start date” → [Validate related fields before saving](https://docs.dyrected.com/docs/recipes/cross-field-validation)
|
|
202
|
+
- “reject invalid form submissions” → [Validate related fields before saving](https://docs.dyrected.com/docs/recipes/cross-field-validation)
|
|
203
|
+
- “validate multiple fields together” → [Validate related fields before saving](https://docs.dyrected.com/docs/recipes/cross-field-validation)
|
|
204
|
+
- “make one dropdown depend on another” → [Update a dropdown from another field](https://docs.dyrected.com/docs/recipes/dependent-dropdown)
|
|
205
|
+
- “show states based on the selected country” → [Update a dropdown from another field](https://docs.dyrected.com/docs/recipes/dependent-dropdown)
|
|
206
|
+
- “create a cascading dropdown” → [Update a dropdown from another field](https://docs.dyrected.com/docs/recipes/dependent-dropdown)
|
|
207
|
+
- “update select options while editing” → [Update a dropdown from another field](https://docs.dyrected.com/docs/recipes/dependent-dropdown)
|
|
208
|
+
- “add draft and publish states” → [Add draft, review, and publishing states](https://docs.dyrected.com/docs/recipes/editorial-publishing-workflow)
|
|
209
|
+
- “require review before publishing” → [Add draft, review, and publishing states](https://docs.dyrected.com/docs/recipes/editorial-publishing-workflow)
|
|
210
|
+
- “create an editorial workflow” → [Add draft, review, and publishing states](https://docs.dyrected.com/docs/recipes/editorial-publishing-workflow)
|
|
211
|
+
- “let editors submit content for approval” → [Add draft, review, and publishing states](https://docs.dyrected.com/docs/recipes/editorial-publishing-workflow)
|
|
212
|
+
- “users should only see their own records” → [Limit documents to their owner](https://docs.dyrected.com/docs/recipes/owner-scoped-access)
|
|
213
|
+
- “add row level access” → [Limit documents to their owner](https://docs.dyrected.com/docs/recipes/owner-scoped-access)
|
|
214
|
+
- “scope documents by owner” → [Limit documents to their owner](https://docs.dyrected.com/docs/recipes/owner-scoped-access)
|
|
215
|
+
- “prevent users reading another user's data” → [Limit documents to their owner](https://docs.dyrected.com/docs/recipes/owner-scoped-access)
|
|
216
|
+
- “build a page builder” → [Build flexible pages from reusable blocks](https://docs.dyrected.com/docs/recipes/page-builder-blocks)
|
|
217
|
+
- “let editors arrange page sections” → [Build flexible pages from reusable blocks](https://docs.dyrected.com/docs/recipes/page-builder-blocks)
|
|
218
|
+
- “create reusable content blocks” → [Build flexible pages from reusable blocks](https://docs.dyrected.com/docs/recipes/page-builder-blocks)
|
|
219
|
+
- “model flexible landing pages” → [Build flexible pages from reusable blocks](https://docs.dyrected.com/docs/recipes/page-builder-blocks)
|
|
220
|
+
- “connect posts to authors” → [Model a relationship and its reverse lookup](https://docs.dyrected.com/docs/recipes/relationship-and-reverse-join)
|
|
221
|
+
- “show every post written by a user” → [Model a relationship and its reverse lookup](https://docs.dyrected.com/docs/recipes/relationship-and-reverse-join)
|
|
222
|
+
- “create a reverse relationship” → [Model a relationship and its reverse lookup](https://docs.dyrected.com/docs/recipes/relationship-and-reverse-join)
|
|
223
|
+
- “model one-to-many content” → [Model a relationship and its reverse lookup](https://docs.dyrected.com/docs/recipes/relationship-and-reverse-join)
|
|
224
|
+
- “only editors can update content” → [Restrict content operations by user role](https://docs.dyrected.com/docs/recipes/role-based-access)
|
|
225
|
+
- “restrict deletion to admins” → [Restrict content operations by user role](https://docs.dyrected.com/docs/recipes/role-based-access)
|
|
226
|
+
- “make content publicly readable” → [Restrict content operations by user role](https://docs.dyrected.com/docs/recipes/role-based-access)
|
|
227
|
+
- “add role based access” → [Restrict content operations by user role](https://docs.dyrected.com/docs/recipes/role-based-access)
|
|
228
|
+
- “rename a field safely” → [Rename a field without orphaning existing data](https://docs.dyrected.com/docs/recipes/safe-field-rename)
|
|
229
|
+
- “change a field name without losing data” → [Rename a field without orphaning existing data](https://docs.dyrected.com/docs/recipes/safe-field-rename)
|
|
230
|
+
- “migrate an existing schema” → [Rename a field without orphaning existing data](https://docs.dyrected.com/docs/recipes/safe-field-rename)
|
|
231
|
+
- “keep old documents working after a rename” → [Rename a field without orphaning existing data](https://docs.dyrected.com/docs/recipes/safe-field-rename)
|
|
232
|
+
- “let editors upload images” → [Create a media upload collection](https://docs.dyrected.com/docs/recipes/upload-collection)
|
|
233
|
+
- “create a media library” → [Create a media upload collection](https://docs.dyrected.com/docs/recipes/upload-collection)
|
|
234
|
+
- “store uploaded files” → [Create a media upload collection](https://docs.dyrected.com/docs/recipes/upload-collection)
|
|
235
|
+
- “add image uploads to my project” → [Create a media upload collection](https://docs.dyrected.com/docs/recipes/upload-collection)
|
|
236
|
+
<!-- GENERATED:INTENTS:END -->
|
|
237
|
+
|
|
238
|
+
## Generated contract map
|
|
239
|
+
|
|
240
|
+
<!-- GENERATED:REFERENCES:START -->
|
|
241
|
+
- [Configuration](https://docs.dyrected.com/docs/reference/configuration)
|
|
242
|
+
- [Fields and hooks](https://docs.dyrected.com/docs/reference/fields)
|
|
243
|
+
- [Database adapters](https://docs.dyrected.com/docs/adapters/databases)
|
|
244
|
+
- [Storage adapters](https://docs.dyrected.com/docs/adapters/storage)
|
|
245
|
+
- [SDK](https://docs.dyrected.com/docs/reference/sdk)
|
|
246
|
+
- [Workflows](https://docs.dyrected.com/docs/reference/generated-workflows)
|
|
247
|
+
- [REST and OpenAPI](https://docs.dyrected.com/docs/reference/rest-api)
|
|
248
|
+
<!-- GENERATED:REFERENCES:END -->
|
|
249
|
+
|
|
250
|
+
## Work sequence
|
|
251
|
+
|
|
252
|
+
1. Inspect installation, versions, framework and existing configuration.
|
|
253
|
+
2. Translate the plain-language outcome into the matching recipe or documented contract.
|
|
254
|
+
3. Implement no more than three related collections or globals in one batch.
|
|
255
|
+
4. Keep every field labeled and preserve stored data during schema evolution.
|
|
256
|
+
5. Run lint, types, focused tests and build; fix failures before expanding scope.
|
|
257
|
+
6. Explain decisions in the user's language. Do not ask them to choose between technical CMS concepts when the intent determines the correct pattern.
|
|
258
|
+
|
|
259
|
+
## Troubleshooting
|
|
260
|
+
|
|
261
|
+
- Missing export: inspect the installed package version; do not substitute an internal source import.
|
|
262
|
+
- Admin route failure: remove custom auth wrappers and verify the framework integration generated by the CLI.
|
|
263
|
+
- Empty frontend: provide an intentional zero-state or SDK `initialData` fallback.
|
|
264
|
+
- Relationship payload too large: lower query depth.
|
|
265
|
+
- Cloud condition missing: replace callback conditions with Jexl strings.
|
|
266
|
+
- Existing records fail after a schema change: restore the old key through `renameTo` and add a compatible default.
|
|
267
|
+
|
|
268
|
+
## Completion checklist
|
|
269
|
+
|
|
270
|
+
- Installed package APIs were verified.
|
|
271
|
+
- Existing configuration and content were inspected.
|
|
272
|
+
- Named fields have labels.
|
|
273
|
+
- Access and auth are server-enforced.
|
|
274
|
+
- Migrations preserve existing data.
|
|
275
|
+
- Generated knowledge is current.
|
|
276
|
+
- Lint, type checking, tests and build pass.
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
# Dyrected AI Rules
|
|
2
|
+
|
|
3
|
+
This file combines authored operating rules with facts generated by `@dyrected/knowledge`.
|
|
4
|
+
|
|
5
|
+
## Before writing code
|
|
6
|
+
|
|
7
|
+
1. Check `package.json` and the workspace root to confirm `@dyrected/core` is installed.
|
|
8
|
+
2. If it is not installed, use `npx @dyrected/cli init` and verify lint, types, and build before adding collections.
|
|
9
|
+
3. If it is installed, inspect its installed version, public exports, and the existing `dyrected.config.ts`.
|
|
10
|
+
4. When documentation and installed types disagree, follow the installed package.
|
|
11
|
+
5. Detect the project's framework, database adapter, storage adapter, package manager, and deployment target before changing setup.
|
|
12
|
+
|
|
13
|
+
## Hard constraints
|
|
14
|
+
|
|
15
|
+
- Every named field must have an explicit human-readable `label`.
|
|
16
|
+
- Never invent fields, hooks, configuration properties, SDK methods, adapter methods, or routes.
|
|
17
|
+
- Never use `client.collections`; use `client.collection('slug')`.
|
|
18
|
+
- Never define `email` or `password` on an `auth: true` collection.
|
|
19
|
+
- Never add custom authentication middleware around Dyrected Admin routes.
|
|
20
|
+
- Never remove or directly rename a persisted field. Use `renameTo`, and give new fields on existing schemas a safe `defaultValue`.
|
|
21
|
+
- Use server hooks for correctness. Browser Admin hooks are an optional feedback layer, not the only implementation.
|
|
22
|
+
- Use Jexl strings for `admin.condition` when the schema must synchronize with Dyrected Cloud.
|
|
23
|
+
- Prefer the smallest required access permissions and enforce them in server configuration.
|
|
24
|
+
|
|
25
|
+
## Setup and verification
|
|
26
|
+
|
|
27
|
+
- New project: initialize, configure environment variables, database, storage and Admin route, then run lint, type checking and build.
|
|
28
|
+
- Existing project: read the UI and current content model before proposing collections or globals. Preserve existing content and routes.
|
|
29
|
+
- Existing Dyrected project: read the config first and make schema changes in small, verifiable batches.
|
|
30
|
+
- Self-hosted and Cloud projects can have different schema synchronization and serialization constraints. Confirm the target before advising commands.
|
|
31
|
+
|
|
32
|
+
## Modeling and migration guidance
|
|
33
|
+
|
|
34
|
+
- Use `defineGlobal` for one shared settings document and `defineCollection` for repeatable entries.
|
|
35
|
+
- Use `relationship` for the stored owning reference and `join` for a virtual reverse lookup.
|
|
36
|
+
- Use `depth: 0` on lightweight lists; increase depth only when the view needs hydrated relations.
|
|
37
|
+
- Use field hooks for one value and collection hooks for cross-field validation or derived data.
|
|
38
|
+
- Use `workflow: publishingWorkflow()` for capability-controlled draft, review, and publication.
|
|
39
|
+
- Treat collection slugs, field names, block slugs, and public URL patterns as persisted contracts.
|
|
40
|
+
|
|
41
|
+
### Rename a field safely
|
|
42
|
+
|
|
43
|
+
```ts
|
|
44
|
+
{
|
|
45
|
+
name: "fullName",
|
|
46
|
+
type: "text",
|
|
47
|
+
label: "Full name",
|
|
48
|
+
renameTo: "name",
|
|
49
|
+
defaultValue: "",
|
|
50
|
+
}
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Keep `renameTo` until production documents have been migrated and verified.
|
|
54
|
+
|
|
55
|
+
## Security boundaries
|
|
56
|
+
|
|
57
|
+
- Admin visibility and conditions are presentation, not authorization or validation.
|
|
58
|
+
- Set ownership and other trusted fields in server hooks; do not trust client-submitted owner or role values.
|
|
59
|
+
- Keep API keys and storage credentials out of browser bundles.
|
|
60
|
+
- Grant destructive operations and workflow capabilities independently.
|
|
61
|
+
- Use `expectedRevision` when workflow transitions can race with another editor.
|
|
62
|
+
|
|
63
|
+
## Uploads and dynamic options
|
|
64
|
+
|
|
65
|
+
Use `allowedMimeTypes` and `maxFileSize` for upload collections, consume returned URLs, and validate untrusted file contents. Use server option resolvers for database/secret-backed choices and Admin option hooks only for browser-safe dependent choices.
|
|
66
|
+
|
|
67
|
+
## Supported field types
|
|
68
|
+
|
|
69
|
+
<!-- GENERATED:FIELD_TYPES:START -->
|
|
70
|
+
`text`, `textarea`, `richText`, `number`, `boolean`, `date`, `datetime`, `time`, `select`, `multiSelect`, `radio`, `relationship`, `array`, `object`, `json`, `blocks`, `image`, `email`, `url`, `icon`, `join`, `row`
|
|
71
|
+
<!-- GENERATED:FIELD_TYPES:END -->
|
|
72
|
+
|
|
73
|
+
## Compiled recipes
|
|
74
|
+
|
|
75
|
+
<!-- GENERATED:RECIPES:START -->
|
|
76
|
+
- [Generate a slug from a title](https://docs.dyrected.com/docs/recipes/auto-slug) — Generate stable URL slugs on the server while showing editors the value live in the Admin UI.
|
|
77
|
+
- [Show an Admin field only when it is relevant](https://docs.dyrected.com/docs/recipes/conditional-admin-field) — Use a serializable Admin condition to reveal a field from the editor's current form values.
|
|
78
|
+
- [Validate related fields before saving](https://docs.dyrected.com/docs/recipes/cross-field-validation) — Reject invalid combinations of field values before they reach the database.
|
|
79
|
+
- [Update a dropdown from another field](https://docs.dyrected.com/docs/recipes/dependent-dropdown) — Change available Admin UI options immediately when an editor changes a related field.
|
|
80
|
+
- [Add draft, review, and publishing states](https://docs.dyrected.com/docs/recipes/editorial-publishing-workflow) — Attach Dyrected's standard editorial workflow and its capability-aware transitions to a collection.
|
|
81
|
+
- [Limit documents to their owner](https://docs.dyrected.com/docs/recipes/owner-scoped-access) — Return a where constraint from access control so authenticated users only read their own records.
|
|
82
|
+
- [Build flexible pages from reusable blocks](https://docs.dyrected.com/docs/recipes/page-builder-blocks) — Define labeled hero, rich-text, and call-to-action blocks for an editor-controlled page layout.
|
|
83
|
+
- [Model a relationship and its reverse lookup](https://docs.dyrected.com/docs/recipes/relationship-and-reverse-join) — Store an author relationship on posts and expose the author's posts through a virtual join field.
|
|
84
|
+
- [Restrict content operations by user role](https://docs.dyrected.com/docs/recipes/role-based-access) — Allow public reads, editor writes, and administrator deletion with collection access rules.
|
|
85
|
+
- [Rename a field without orphaning existing data](https://docs.dyrected.com/docs/recipes/safe-field-rename) — Use renameTo and a safe default while documents migrate lazily to a new field name.
|
|
86
|
+
- [Create a media upload collection](https://docs.dyrected.com/docs/recipes/upload-collection) — Enable file uploads and capture accessible metadata in a dedicated media collection.
|
|
87
|
+
<!-- GENERATED:RECIPES:END -->
|
|
88
|
+
|
|
89
|
+
## Intent-to-pattern index
|
|
90
|
+
|
|
91
|
+
<!-- GENERATED:INTENTS:START -->
|
|
92
|
+
- “make the URL follow the title” → [Generate a slug from a title](https://docs.dyrected.com/docs/recipes/auto-slug)
|
|
93
|
+
- “automatically generate a slug” → [Generate a slug from a title](https://docs.dyrected.com/docs/recipes/auto-slug)
|
|
94
|
+
- “create friendly URLs from titles” → [Generate a slug from a title](https://docs.dyrected.com/docs/recipes/auto-slug)
|
|
95
|
+
- “keep a slug synchronized with a title” → [Generate a slug from a title](https://docs.dyrected.com/docs/recipes/auto-slug)
|
|
96
|
+
- “show a field conditionally” → [Show an Admin field only when it is relevant](https://docs.dyrected.com/docs/recipes/conditional-admin-field)
|
|
97
|
+
- “hide irrelevant form fields” → [Show an Admin field only when it is relevant](https://docs.dyrected.com/docs/recipes/conditional-admin-field)
|
|
98
|
+
- “show discount only with a coupon” → [Show an Admin field only when it is relevant](https://docs.dyrected.com/docs/recipes/conditional-admin-field)
|
|
99
|
+
- “make the admin form react to another field” → [Show an Admin field only when it is relevant](https://docs.dyrected.com/docs/recipes/conditional-admin-field)
|
|
100
|
+
- “validate fields before saving” → [Validate related fields before saving](https://docs.dyrected.com/docs/recipes/cross-field-validation)
|
|
101
|
+
- “make sure an end date is after the start date” → [Validate related fields before saving](https://docs.dyrected.com/docs/recipes/cross-field-validation)
|
|
102
|
+
- “reject invalid form submissions” → [Validate related fields before saving](https://docs.dyrected.com/docs/recipes/cross-field-validation)
|
|
103
|
+
- “validate multiple fields together” → [Validate related fields before saving](https://docs.dyrected.com/docs/recipes/cross-field-validation)
|
|
104
|
+
- “make one dropdown depend on another” → [Update a dropdown from another field](https://docs.dyrected.com/docs/recipes/dependent-dropdown)
|
|
105
|
+
- “show states based on the selected country” → [Update a dropdown from another field](https://docs.dyrected.com/docs/recipes/dependent-dropdown)
|
|
106
|
+
- “create a cascading dropdown” → [Update a dropdown from another field](https://docs.dyrected.com/docs/recipes/dependent-dropdown)
|
|
107
|
+
- “update select options while editing” → [Update a dropdown from another field](https://docs.dyrected.com/docs/recipes/dependent-dropdown)
|
|
108
|
+
- “add draft and publish states” → [Add draft, review, and publishing states](https://docs.dyrected.com/docs/recipes/editorial-publishing-workflow)
|
|
109
|
+
- “require review before publishing” → [Add draft, review, and publishing states](https://docs.dyrected.com/docs/recipes/editorial-publishing-workflow)
|
|
110
|
+
- “create an editorial workflow” → [Add draft, review, and publishing states](https://docs.dyrected.com/docs/recipes/editorial-publishing-workflow)
|
|
111
|
+
- “let editors submit content for approval” → [Add draft, review, and publishing states](https://docs.dyrected.com/docs/recipes/editorial-publishing-workflow)
|
|
112
|
+
- “users should only see their own records” → [Limit documents to their owner](https://docs.dyrected.com/docs/recipes/owner-scoped-access)
|
|
113
|
+
- “add row level access” → [Limit documents to their owner](https://docs.dyrected.com/docs/recipes/owner-scoped-access)
|
|
114
|
+
- “scope documents by owner” → [Limit documents to their owner](https://docs.dyrected.com/docs/recipes/owner-scoped-access)
|
|
115
|
+
- “prevent users reading another user's data” → [Limit documents to their owner](https://docs.dyrected.com/docs/recipes/owner-scoped-access)
|
|
116
|
+
- “build a page builder” → [Build flexible pages from reusable blocks](https://docs.dyrected.com/docs/recipes/page-builder-blocks)
|
|
117
|
+
- “let editors arrange page sections” → [Build flexible pages from reusable blocks](https://docs.dyrected.com/docs/recipes/page-builder-blocks)
|
|
118
|
+
- “create reusable content blocks” → [Build flexible pages from reusable blocks](https://docs.dyrected.com/docs/recipes/page-builder-blocks)
|
|
119
|
+
- “model flexible landing pages” → [Build flexible pages from reusable blocks](https://docs.dyrected.com/docs/recipes/page-builder-blocks)
|
|
120
|
+
- “connect posts to authors” → [Model a relationship and its reverse lookup](https://docs.dyrected.com/docs/recipes/relationship-and-reverse-join)
|
|
121
|
+
- “show every post written by a user” → [Model a relationship and its reverse lookup](https://docs.dyrected.com/docs/recipes/relationship-and-reverse-join)
|
|
122
|
+
- “create a reverse relationship” → [Model a relationship and its reverse lookup](https://docs.dyrected.com/docs/recipes/relationship-and-reverse-join)
|
|
123
|
+
- “model one-to-many content” → [Model a relationship and its reverse lookup](https://docs.dyrected.com/docs/recipes/relationship-and-reverse-join)
|
|
124
|
+
- “only editors can update content” → [Restrict content operations by user role](https://docs.dyrected.com/docs/recipes/role-based-access)
|
|
125
|
+
- “restrict deletion to admins” → [Restrict content operations by user role](https://docs.dyrected.com/docs/recipes/role-based-access)
|
|
126
|
+
- “make content publicly readable” → [Restrict content operations by user role](https://docs.dyrected.com/docs/recipes/role-based-access)
|
|
127
|
+
- “add role based access” → [Restrict content operations by user role](https://docs.dyrected.com/docs/recipes/role-based-access)
|
|
128
|
+
- “rename a field safely” → [Rename a field without orphaning existing data](https://docs.dyrected.com/docs/recipes/safe-field-rename)
|
|
129
|
+
- “change a field name without losing data” → [Rename a field without orphaning existing data](https://docs.dyrected.com/docs/recipes/safe-field-rename)
|
|
130
|
+
- “migrate an existing schema” → [Rename a field without orphaning existing data](https://docs.dyrected.com/docs/recipes/safe-field-rename)
|
|
131
|
+
- “keep old documents working after a rename” → [Rename a field without orphaning existing data](https://docs.dyrected.com/docs/recipes/safe-field-rename)
|
|
132
|
+
- “let editors upload images” → [Create a media upload collection](https://docs.dyrected.com/docs/recipes/upload-collection)
|
|
133
|
+
- “create a media library” → [Create a media upload collection](https://docs.dyrected.com/docs/recipes/upload-collection)
|
|
134
|
+
- “store uploaded files” → [Create a media upload collection](https://docs.dyrected.com/docs/recipes/upload-collection)
|
|
135
|
+
- “add image uploads to my project” → [Create a media upload collection](https://docs.dyrected.com/docs/recipes/upload-collection)
|
|
136
|
+
<!-- GENERATED:INTENTS:END -->
|
|
137
|
+
|
|
138
|
+
## Canonical references
|
|
139
|
+
|
|
140
|
+
<!-- GENERATED:REFERENCES:START -->
|
|
141
|
+
- [Configuration](https://docs.dyrected.com/docs/reference/configuration)
|
|
142
|
+
- [Fields and hooks](https://docs.dyrected.com/docs/reference/fields)
|
|
143
|
+
- [Database adapters](https://docs.dyrected.com/docs/adapters/databases)
|
|
144
|
+
- [Storage adapters](https://docs.dyrected.com/docs/adapters/storage)
|
|
145
|
+
- [SDK](https://docs.dyrected.com/docs/reference/sdk)
|
|
146
|
+
- [Workflows](https://docs.dyrected.com/docs/reference/generated-workflows)
|
|
147
|
+
- [REST and OpenAPI](https://docs.dyrected.com/docs/reference/rest-api)
|
|
148
|
+
<!-- GENERATED:REFERENCES:END -->
|
|
149
|
+
|
|
150
|
+
## Completion checks
|
|
151
|
+
|
|
152
|
+
Run the repository's lint, type-check, tests and build. Confirm generated files are current, configuration fields remain labeled, schema migrations preserve stored data, and authentication/access behavior is enforced server-side.
|