fimo 0.10.1-staging.1 → 0.10.1-staging.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/assets/skills/fimo-cli/references/content.md +25 -6
- package/assets/skills/fimo-code/references/content.md +1 -1
- package/assets/skills/fimo-studio/references/cms.md +8 -8
- package/dist/build/vite/plugins/translations.js +2 -1
- package/dist/cli/bundle.json +1 -1
- package/dist/cli/index.js +48 -57
- package/dist/runtime/content/client/createContentClient.js +1 -1
- package/package.json +2 -1
- package/templates/react-router/package.json +1 -1
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
# Content workflow (schemas + entries)
|
|
1
|
+
# Content workflow (schemas + Singles + entries)
|
|
2
2
|
|
|
3
3
|
> **Run via `npx fimo@latest <command>`** — always the latest CLI, no install needed.
|
|
4
4
|
|
|
5
5
|
> For the JSON shape, field types, Tiptap node spec, slug rules, and generated React Query hooks — these are package surface (version-locked to the project's `fimo`). See **`fimo/references/content.md`**.
|
|
6
6
|
|
|
7
|
-
This file covers the **CLI workflow** for content. Use it when the user wants to add a content type (blog, products, pages) or
|
|
7
|
+
This file covers the **CLI workflow** for content. Use it when the user wants to add a content type (blog, products, pages) or manage Singles and entries.
|
|
8
8
|
|
|
9
9
|
## Flow
|
|
10
10
|
|
|
11
11
|
1. Write `src/schemas/{Uid}.json` — PascalCase filename (e.g. `BlogPost.json`). For the JSON shape and field types, load `fimo/references/content.md`.
|
|
12
12
|
2. Run `fimo schemas push {Uid}`. It generates `src/schemas/{Uid}.types.ts` and `src/schemas/{Uid}.ts`, then registers the schema with Fimo. It does not run whole-project validation.
|
|
13
13
|
3. App code imports the generated client from `@/schemas/{Uid}`, not from `.types.ts` directly. See `fimo/references/content.md` for the hook API.
|
|
14
|
-
4. Seed
|
|
14
|
+
4. Seed collections via `fimo entries create`, or update one-off content via `fimo singles update`. Generate cover images first with `fimo image generate` if needed (see `media.md` / `assets.md`).
|
|
15
15
|
5. Write React pages that import from `@/schemas/{Uid}` and render with `fimo/ui` components.
|
|
16
16
|
|
|
17
17
|
Steps 1, 3, and 5 reference the `fimo-code` skill (`npx fimo@latest skills get fimo-code`) for shape and React API. Steps 2 and 4 are CLI commands documented here.
|
|
@@ -34,7 +34,26 @@ The command is `fimo schemas` (plural). There is no singular `fimo schema` alias
|
|
|
34
34
|
|
|
35
35
|
All commands accept `-C, --cwd <dir>` to point at a different project directory.
|
|
36
36
|
|
|
37
|
-
Schema transitions are automatic. Adding optional fields and changing labels preserve content. A new required field backfills its `default` only where existing values need it; the push fails safely when no default can satisfy existing content. Removing a nested field or block variant removes only those values. `string` and `text` preserve values in both directions. Other primitive changes convert safe values and reject unsafe ones without changing the schema or entries. Lowering block `max` trims from the end; raising `min` fills from the blocks `default` templates. A reference target change clears its connections. Use repeatable `--rename old.path=new.path` arguments when a field moved by name so the one-time migration preserves its values; the operation is not stored in schema JSON. Collection-to-
|
|
37
|
+
Schema transitions are automatic. Adding optional fields and changing labels preserve content. A new required field backfills its `default` only where existing values need it; the push fails safely when no default can satisfy existing content. Removing a nested field or block variant removes only those values. `string` and `text` preserve values in both directions. Other primitive changes convert safe values and reject unsafe ones without changing the schema or entries. Lowering block `max` trims from the end; raising `min` fills from the blocks `default` templates. A reference target change clears its connections. Use repeatable `--rename old.path=new.path` arguments when a field moved by name so the one-time migration preserves its values; the operation is not stored in schema JSON. Collection-to-Single removes that type's entries and cleans inbound references; Single-to-collection preserves its entry. Run `fimo validate` after pushing.
|
|
38
|
+
|
|
39
|
+
## Singles CLI commands
|
|
40
|
+
|
|
41
|
+
Use Singles for one-off content such as a homepage, site settings, or an About story. The type name identifies the content, so these commands do not take an entry ID.
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
fimo singles get <TypeName> [--locale es] [--populate FIELDS]
|
|
45
|
+
fimo singles update <TypeName> [--locale es] (--body '<json>' | --file <path> | --stdin)
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
The update payload uses the regular `{ "data": { ... } }` content body. Pass exactly one input source:
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
fimo singles update Story --body '{"data":{"title":"Our story"}}'
|
|
52
|
+
fimo singles update Story --file story-body.json
|
|
53
|
+
cat story-body.json | fimo singles update Story --stdin
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
The first update creates the Single's content; later updates change it. Use `--locale` for localized variants.
|
|
38
57
|
|
|
39
58
|
## Entries CLI commands
|
|
40
59
|
|
|
@@ -232,7 +251,7 @@ Rules:
|
|
|
232
251
|
|
|
233
252
|
Turning an existing field shared is destructive when the languages currently hold different values. The push collapses each document to its default-locale value and discards the others; there is no prompt and no undo. Most documents already agree, so most collapses change nothing — but tell the user what will happen before adding `"i18n": false` to a field that already holds content, and check whether the languages differ if you are unsure.
|
|
234
253
|
|
|
235
|
-
Use `"isSingleton": true` for a
|
|
254
|
+
Use `"isSingleton": true` for a Single with exactly one set of content. Generated Single clients expose `get`/`update` and their React Query hooks, not collection create/remove APIs.
|
|
236
255
|
|
|
237
256
|
## "Add a blog" recipe
|
|
238
257
|
|
|
@@ -261,4 +280,4 @@ fimo scripts sync-schemas # regenerate src/schemas/*.types.ts and src/schem
|
|
|
261
280
|
|
|
262
281
|
## Non-interactive use
|
|
263
282
|
|
|
264
|
-
All `fimo schemas
|
|
283
|
+
All `fimo schemas *`, `fimo singles *`, and `fimo entries *` commands run non-interactively without extra flags (they don't prompt). Just pass the arguments documented above.
|
|
@@ -226,7 +226,7 @@ After editing schema JSON, run `fimo schemas push {Uid}` and then `fimo validate
|
|
|
226
226
|
- Changing a reference target clears those connections. Renaming a relation field with the same target preserves them.
|
|
227
227
|
- Preserve top-level or nested renames with repeatable one-time operations: `fimo schemas push Page --rename sections.hero.heading=sections.hero.title`. Renames are command intent, not schema JSON.
|
|
228
228
|
- A many-to-one change or scalar/reference change clears only the changed field.
|
|
229
|
-
- Collection-to-
|
|
229
|
+
- Collection-to-Single removes that type's entries and cleans references to them.
|
|
230
230
|
- Singleton-to-collection preserves the existing entry.
|
|
231
231
|
- Blocks migrations are surgical: unaffected nested fields, block keys, and block order survive every supported change.
|
|
232
232
|
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
## How the CMS Works
|
|
2
2
|
|
|
3
|
-
The CMS is where you manage your site's structured content. It separates content by
|
|
3
|
+
The CMS is where you manage your site's structured content. It separates content by whether a schema is repeatable:
|
|
4
4
|
|
|
5
5
|
- **Collections** hold multiple entries of the same kind, such as Blog posts, Team members, or Testimonials.
|
|
6
|
-
- **Singles** hold one
|
|
7
|
-
- **Entries** are the individual
|
|
6
|
+
- **Singles** hold one set of content, such as Site settings, a Homepage, or an About page.
|
|
7
|
+
- **Entries** are the individual records inside a Collection.
|
|
8
8
|
|
|
9
|
-
Both use schemas to define their fields. The difference is whether you edit one
|
|
9
|
+
Both use schemas to define their fields. The difference is whether you edit one set of content or manage a repeatable list.
|
|
10
10
|
|
|
11
11
|
## Browsing Your Content
|
|
12
12
|
|
|
@@ -15,9 +15,9 @@ Both use schemas to define their fields. The difference is whether you edit one
|
|
|
15
15
|
3. Hover over or focus the info icon beside any item for a short explanation.
|
|
16
16
|
4. Each destination shows cards for the schemas in that group.
|
|
17
17
|
5. Click a Collection to see its entries, then click an entry to edit it.
|
|
18
|
-
6. Click a Single to
|
|
18
|
+
6. Click a Single to edit it directly.
|
|
19
19
|
|
|
20
|
-
Collection cards show their entry count. Single cards are labeled **Single** instead because they always represent one
|
|
20
|
+
Collection cards show their entry count. Single cards are labeled **Single** instead because they always represent one set of content.
|
|
21
21
|
|
|
22
22
|
## Editing a Single
|
|
23
23
|
|
|
@@ -25,7 +25,7 @@ Collection cards show their entry count. Single cards are labeled **Single** ins
|
|
|
25
25
|
2. Select the Single you want, such as Site settings.
|
|
26
26
|
3. Update its fields.
|
|
27
27
|
|
|
28
|
-
Changes save automatically. A Single has no entry list, create action, bulk actions, or delete action because it always represents the same
|
|
28
|
+
Changes save automatically. A Single has no entry list, create action, bulk actions, or delete action because it always represents the same set of content.
|
|
29
29
|
|
|
30
30
|
## Navigating the Entry List
|
|
31
31
|
|
|
@@ -96,7 +96,7 @@ The AI chat can help you manage content without navigating through menus:
|
|
|
96
96
|
## Key Concepts
|
|
97
97
|
|
|
98
98
|
- **Collections** are best for repeatable content. Open one to search, sort, create, and manage its entries.
|
|
99
|
-
- **Singles** are best for one-off
|
|
99
|
+
- **Singles** are best for one-off content. Open one and edit it directly.
|
|
100
100
|
- **Content appears automatically** if its schema is connected (wired) to a page on your site. You do not need to manually link each entry.
|
|
101
101
|
- **Forms tab**: View and manage form submissions collected from your site's forms.
|
|
102
102
|
- **Labels & Text tab**: Edit your site's UI labels and static text strings as key-and-value rows. This is for your site's interface copy, not for translated copies of collection entries.
|
|
@@ -9,6 +9,7 @@ const VIRTUAL_ID = 'virtual:translations';
|
|
|
9
9
|
const RESOLVED_ID = '\0' + VIRTUAL_ID;
|
|
10
10
|
const EVENT_RECONNECT_DELAY_MS = 2000;
|
|
11
11
|
const FALLBACK_POLL_INTERVAL_MS = 30_000;
|
|
12
|
+
const LABEL_FETCH_TIMEOUT_MS = 30_000;
|
|
12
13
|
export default function translationsPlugin() {
|
|
13
14
|
let rootDir = process.cwd();
|
|
14
15
|
let bundle = {
|
|
@@ -423,7 +424,7 @@ export async function loadLabelBundle(rootDir) {
|
|
|
423
424
|
async function fetchLabelDictionary(apiUrl, locale) {
|
|
424
425
|
const url = new URL('/labels', apiUrl);
|
|
425
426
|
url.searchParams.set('locale', locale);
|
|
426
|
-
const response = await fetchWithTimeout(url,
|
|
427
|
+
const response = await fetchWithTimeout(url, LABEL_FETCH_TIMEOUT_MS);
|
|
427
428
|
if (!response.ok) {
|
|
428
429
|
return { locale, labels: {}, updatedAt: null };
|
|
429
430
|
}
|