@picked/client 0.0.1-dev.1786072899095 → 0.0.1-dev.1786601464574

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.
Files changed (96) hide show
  1. package/dist/.tsbuildinfo +1 -1
  2. package/dist/api-C8B96Kwv.js +22 -0
  3. package/dist/api-DS7fA9kj.cjs +1 -0
  4. package/dist/cjs/index.js +2 -2
  5. package/dist/cjs/plugins/dynamic-experiences/index.js +1 -1
  6. package/dist/cjs/server/index.js +1 -1
  7. package/dist/docs/explanation/content-references.md +99 -0
  8. package/dist/docs/explanation/how-picked-works.md +25 -3
  9. package/dist/docs/explanation/the-content-model.md +38 -28
  10. package/dist/docs/how-to/authenticate-the-cli.md +95 -0
  11. package/dist/docs/how-to/create-a-content-entry.md +48 -0
  12. package/dist/docs/how-to/define-a-page-layout.md +12 -5
  13. package/dist/docs/how-to/install-the-sdk.md +7 -0
  14. package/dist/docs/how-to/point-one-entry-at-another.md +61 -0
  15. package/dist/docs/how-to/read-a-referenced-entry.md +111 -0
  16. package/dist/docs/how-to/reuse-a-section.md +26 -10
  17. package/dist/docs/how-to/switch-workspaces.md +123 -0
  18. package/dist/docs/index.md +1 -1
  19. package/dist/docs/reference/dashboard/content/blocks.mdx +57 -0
  20. package/dist/docs/reference/dashboard/content/content-entries.mdx +61 -10
  21. package/dist/docs/reference/dashboard/content/models.mdx +108 -0
  22. package/dist/docs/reference/dashboard/content/pages.mdx +4 -3
  23. package/dist/docs/reference/dashboard/fields.mdx +1 -1
  24. package/dist/docs/reference/dashboard/steps.mdx +2 -2
  25. package/dist/docs/reference/delivery-api/experience-content.md +68 -13
  26. package/dist/docs/reference/delivery-api/workspace-schema.md +74 -0
  27. package/dist/docs/reference/glossary.md +13 -5
  28. package/dist/docs/reference/management-api/error-handling.md +2 -2
  29. package/dist/docs/reference/sdk/content.md +216 -0
  30. package/dist/docs/reference/sdk/plugins/dynamic-experiences.md +51 -3
  31. package/dist/docs/reference/sdk/ssr/serialize.md +6 -3
  32. package/dist/docs/reference/sdk/type-generation.md +130 -0
  33. package/dist/docs/reference/tools/cli.md +141 -0
  34. package/dist/docs/reference/tools/vite-plugin.md +90 -8
  35. package/dist/docs/tutorials/first-api-call.md +1 -1
  36. package/dist/docs/tutorials/first-server-rendered-page.mdx +1 -1
  37. package/dist/esm/index.js +496 -432
  38. package/dist/esm/plugins/dynamic-experiences/index.js +5 -3
  39. package/dist/esm/server/index.js +43 -46
  40. package/dist/plugin-C8hWW3ed.js +157 -0
  41. package/dist/plugin-Dtg2sOad.cjs +1 -0
  42. package/dist/provider-BEpRDCyr.js +69 -0
  43. package/dist/provider-ixdOyYTA.cjs +1 -0
  44. package/dist/registry-C1t8l3t9.cjs +1 -0
  45. package/dist/registry-CXZv0uLg.js +18 -0
  46. package/dist/types/data-source/api.d.ts +60 -0
  47. package/dist/types/data-source/api.d.ts.map +1 -0
  48. package/dist/types/data-source/provider.d.ts +90 -0
  49. package/dist/types/data-source/provider.d.ts.map +1 -0
  50. package/dist/types/data-source/registry.d.ts +26 -0
  51. package/dist/types/data-source/registry.d.ts.map +1 -0
  52. package/dist/types/data-source/virtual-data.d.ts +19 -0
  53. package/dist/types/data-source/virtual-data.d.ts.map +1 -0
  54. package/dist/types/entities/content/reference.d.ts +101 -0
  55. package/dist/types/entities/content/reference.d.ts.map +1 -0
  56. package/dist/types/entities/response/response.d.ts +22 -6
  57. package/dist/types/entities/response/response.d.ts.map +1 -1
  58. package/dist/types/exports.d.ts +2 -0
  59. package/dist/types/exports.d.ts.map +1 -1
  60. package/dist/types/form/create-submit-pipeline.d.ts +32 -3
  61. package/dist/types/form/create-submit-pipeline.d.ts.map +1 -1
  62. package/dist/types/index.d.ts +3 -0
  63. package/dist/types/index.d.ts.map +1 -1
  64. package/dist/types/picked.d.ts +68 -4
  65. package/dist/types/picked.d.ts.map +1 -1
  66. package/dist/types/ping.d.ts +4 -3
  67. package/dist/types/ping.d.ts.map +1 -1
  68. package/dist/types/plugins/dynamic-experiences/index.d.ts +2 -1
  69. package/dist/types/plugins/dynamic-experiences/index.d.ts.map +1 -1
  70. package/dist/types/plugins/dynamic-experiences/plugin.d.ts +9 -40
  71. package/dist/types/plugins/dynamic-experiences/plugin.d.ts.map +1 -1
  72. package/dist/types/plugins/dynamic-experiences/types.d.ts +22 -129
  73. package/dist/types/plugins/dynamic-experiences/types.d.ts.map +1 -1
  74. package/dist/types/schema-registry.d.ts +190 -0
  75. package/dist/types/schema-registry.d.ts.map +1 -0
  76. package/dist/types/server/index.d.ts +2 -2
  77. package/dist/types/server/index.d.ts.map +1 -1
  78. package/dist/types/server/serialize.d.ts +37 -34
  79. package/dist/types/server/serialize.d.ts.map +1 -1
  80. package/dist/types/typed-content.d.ts +17 -0
  81. package/dist/types/typed-content.d.ts.map +1 -0
  82. package/dist/types/utils/picked-config.d.ts +19 -1
  83. package/dist/types/utils/picked-config.d.ts.map +1 -1
  84. package/dist/version-BLzNWQ-j.cjs +1 -0
  85. package/dist/version-IAAIvoH9.js +4 -0
  86. package/package.json +5 -3
  87. package/dist/api-BzK4kXRt.js +0 -38
  88. package/dist/api-CgENjKwJ.cjs +0 -1
  89. package/dist/docs/reference/dashboard/content/layouts.mdx +0 -62
  90. package/dist/docs/reference/dashboard/content/sections.mdx +0 -28
  91. package/dist/plugin-DJjtc5df.js +0 -252
  92. package/dist/plugin-jHxSAqGG.cjs +0 -1
  93. package/dist/types/utils/api.d.ts +0 -25
  94. package/dist/types/utils/api.d.ts.map +0 -1
  95. package/dist/types/utils/client-headers.d.ts +0 -2
  96. package/dist/types/utils/client-headers.d.ts.map +0 -1
@@ -0,0 +1,57 @@
1
+ ---
2
+ type: reference
3
+ layout: docs
4
+ ---
5
+
6
+ import { Screenshot } from '../../../../../components/Screenshot'
7
+
8
+ # Blocks
9
+
10
+ A Block is a reusable schema fragment that you embed inside a Model, so that a common structure is defined one time.
11
+
12
+ <Screenshot
13
+ route="/{orgSlug}/{projectId}/workspaces/{workspaceId}/blocks"
14
+ alt="The blocks list in the schema builder on the Picked dashboard"
15
+ />
16
+
17
+ ## What a Block is
18
+
19
+ A Block is a schema fragment with its own **Key**. A
20
+ [Model](/reference/dashboard/content/models) gives its shape to a whole Page or Step. A
21
+ Block is a part that you put into one or more Models. Define the shape one time, then
22
+ reuse it everywhere.
23
+
24
+ A Block holds no data of its own. The content that fills a Block sits inside the entry
25
+ of the Model that embeds it.
26
+
27
+ ## Where a Block appears
28
+
29
+ **CMS** in the sidebar holds **Blocks**, and that list shows every Block in the
30
+ workspace. **Pages** holds **Page Sections**, which is the same list limited to the
31
+ Section category.
32
+
33
+ ## Category
34
+
35
+ | Category | What it does |
36
+ | --- | --- |
37
+ | **Section** | Marks the Block as a page section. A **Page Sections** field accepts it. |
38
+ | **None (general content)** | Gives the Block no layout role. |
39
+
40
+ The category is fixed when you create the Block. You cannot change it later.
41
+
42
+ A **Content block** field holds the category of the Blocks that it accepts. Give that
43
+ field the **Section** category to build a page section list.
44
+
45
+ A field set to **Any category** accepts every Block in the workspace. This is the only
46
+ kind of field that can hold a Block with no category.
47
+
48
+ ## Field types
49
+
50
+ A Block holds the same field types as a Model. See
51
+ [Field types](/reference/dashboard/content/models#field-types).
52
+
53
+ ## Related
54
+
55
+ - [About the content model](/explanation/the-content-model) — why Blocks exist.
56
+ - [How to reuse a section](/how-to/reuse-a-section)
57
+ - [Models](/reference/dashboard/content/models)
@@ -7,7 +7,7 @@ import { Screenshot } from '../../../../../components/Screenshot'
7
7
 
8
8
  # Content Entries
9
9
 
10
- A Content Entry is an instance of a layout filled with real data. A Page renders one entry; a Flow Step can render one too.
10
+ A content entry is one instance of a Model, filled with real data. A Page renders one entry, and a Flow Step can render one too.
11
11
 
12
12
  <Screenshot
13
13
  route="/{orgSlug}/{projectId}/workspaces/{workspaceId}/content"
@@ -16,29 +16,80 @@ A Content Entry is an instance of a layout filled with real data. A Page renders
16
16
 
17
17
  ## What a content entry is
18
18
 
19
- A Content Entry is an instance of a layout's schema. The [layout](/reference/dashboard/content/layouts) defines the fields; the entry holds the actual values. One layout can back many entries, each with its own data.
19
+ A content entry is an instance of the schema of a
20
+ [Model](/reference/dashboard/content/models). The Model sets the fields, and the entry
21
+ holds the values. One Model backs many entries, and each entry holds its own data.
22
+
23
+ The Model of an entry is fixed when you create the entry.
24
+
25
+ ## The entries list
26
+
27
+ **CMS** in the sidebar holds **Content entries**, with a count of every entry in the
28
+ workspace.
29
+
30
+ | Column | What it shows |
31
+ | --- | --- |
32
+ | Title | The value of the first single-line text field of the entry. It falls back to the entry id when no such field holds a value. |
33
+ | Model | The Model that the entry belongs to. |
34
+ | Entry ID | The stable id of the entry. |
35
+ | Last updated | When somebody last saved the entry. |
36
+
37
+ The **Model** filter narrows the list to one Model. The list has no search, because the
38
+ title is derived at read time and is not a column that Picked can search.
20
39
 
21
40
  ## How entries bind to pages and steps
22
41
 
23
- A [Page](/reference/dashboard/content/pages) has a single Step, and that Step links to its entry through the layout content link. A Flow [Step](/reference/dashboard/steps) backed by a Step Layout binds an entry the same way. When the SDK renders the Page or Step, it resolves the linked entry and hands its data to your component.
42
+ A [Page](/reference/dashboard/content/pages) has a single Step, and that Step links to
43
+ its entry through the layout content link. A Flow [Step](/reference/dashboard/steps)
44
+ with a Step Layout binds an entry the same way. When the SDK renders the Page or the
45
+ Step, it resolves the linked entry and gives the data to your component.
24
46
 
25
47
  ## Edit entry data
26
48
 
27
- The entry editor renders a form from the layout schema. There is one input for each
28
- field, in the order that the schema sets. A repeatable field appears as a sortable
49
+ The entry editor renders a form from the schema of the Model. There is one input for
50
+ each field, in the order that the schema sets. A repeatable field shows as a sortable
29
51
  list. You can add to that list and put it into a new order. A group field holds its
30
52
  inputs under one heading.
31
53
 
54
+ ## Reference fields
55
+
56
+ A [Reference field](/reference/dashboard/content/models#reference-fields) holds a pointer
57
+ at another entry, and not a copy of it.
58
+
59
+ | Control | What it does |
60
+ | --- | --- |
61
+ | **Choose entry** | Opens the entry picker. |
62
+ | **Change entry** | Opens the entry picker on a field that holds a target already. |
63
+ | **Clear** | Removes the pointer. It does not delete the entry. |
64
+
65
+ The entry picker lists the entries that the **Target Model** of the field allows, and it
66
+ has a search box. **Open model** opens the Model of an entry in a new tab.
67
+
32
68
  ## Validation
33
69
 
34
- Invalid data appears as an error on each field. The error carries a path in the JSON
35
- style, and it points at the exact place in the entry, for example
36
- `sections[0].data.title`. Fix every error before you publish, because Picked serves
70
+ Invalid data shows as an error on each field. The error carries a path in the JSON style,
71
+ and it points at the exact place in the entry, for example `sections[0].data.title`.
72
+
73
+ A reference field reports an error when its target does not exist, or when the target
74
+ belongs to the wrong Model. Fix every error before you publish, because Picked serves
37
75
  valid content only.
38
76
 
77
+ ## Delete rules
78
+
79
+ Picked does not delete an entry while something still points at it.
80
+
81
+ | Condition | Result |
82
+ | --- | --- |
83
+ | A Step uses the entry as its layout | The delete stops. |
84
+ | Another entry points at it through a Reference field | The delete stops. |
85
+
86
+ Clear the reference on the other entry first, then delete the target.
87
+
39
88
  ## Related
40
89
 
41
90
  - [About the content model](/explanation/the-content-model) — why the schema and the data
42
91
  are separate.
43
- - [How to fill and publish a page](/how-to/fill-and-publish-a-page)
44
- - [Page and step layouts](/reference/dashboard/content/layouts)
92
+ - [About content references](/explanation/content-references) — why a delete stops.
93
+ - [How to create a content entry](/how-to/create-a-content-entry)
94
+ - [How to point one entry at another](/how-to/point-one-entry-at-another)
95
+ - [Models](/reference/dashboard/content/models)
@@ -0,0 +1,108 @@
1
+ ---
2
+ type: reference
3
+ layout: docs
4
+ ---
5
+
6
+ import { Screenshot } from '../../../../../components/Screenshot'
7
+
8
+ # Models
9
+
10
+ A Model is a reusable schema. It sets which fields a piece of content can hold, and it holds no data itself.
11
+
12
+ <Screenshot
13
+ route="/{orgSlug}/{projectId}/workspaces/{workspaceId}/models"
14
+ alt="The models list in the schema builder on the Picked dashboard"
15
+ />
16
+
17
+ ## Where a Model appears
18
+
19
+ **CMS** in the sidebar holds **Models**, and that list shows every Model in the
20
+ workspace. The list shows the **Key** below the name, because the key is the value that
21
+ a schema holds.
22
+
23
+ Two shortcuts open a filtered subset of the same list. **Flows** holds **Step Layouts**,
24
+ and **Pages** holds **Page Layouts**.
25
+
26
+ ## Category
27
+
28
+ A category gives a Model a role. It decides where the Model appears, and what renders an
29
+ entry that comes from it.
30
+
31
+ | Category | It gives its shape to | What renders it |
32
+ | --- | --- | --- |
33
+ | **Page layout** | A standalone [Page](/reference/dashboard/content/pages). | The SDK renders the entry on your server. |
34
+ | **Step layout** | One [Step](/reference/dashboard/steps) inside a Flow. | The Step renders the entry in the browser. |
35
+ | **None (general content)** | Content with no layout role. | Nothing renders it directly. A [reference field](#reference-fields) reaches it. |
36
+
37
+ A Model with no category holds content that other content points at, such as a product
38
+ or a category. It appears under **CMS** only.
39
+
40
+ :::warning
41
+ The category is fixed when you create the Model. You cannot change it later.
42
+ :::
43
+
44
+ ## Field types
45
+
46
+ A Model is built from fields. Each field has a type. The type decides the editor for the
47
+ field, and the shape of the value that the field holds.
48
+
49
+ | Type | Holds | Use it for |
50
+ | --- | --- | --- |
51
+ | **Single line text** | A short string. | A title, a label, or a short headline. |
52
+ | **Multi-line text** | A longer plain string. | A description, or a paragraph with no format marks. |
53
+ | **Markdown** | A Markdown string. | Body copy with format marks. |
54
+ | **Slug** | A URL-safe string. | A part of a path, or an identifier. |
55
+ | **Number** | A numeric value. | A price, a count, or a rating. |
56
+ | **Boolean** | A true or false value. | A toggle or a flag. |
57
+ | **Date** | A date value. | A publish date or a deadline. |
58
+ | **Color** | A color value. | A theme accent or a swatch. |
59
+ | **JSON** | Any JSON value. | Structured data with no editor of its own. |
60
+ | **Group** | An object of fields inside the Model. | A set of related fields, held together. |
61
+ | **Content block** | A [Block](/reference/dashboard/content/blocks) schema inside the Model. | A shared schema fragment that you reuse. |
62
+ | **Page Sections** | A repeatable Content block field, limited to the Section category. | The section list of a page. |
63
+ | **Reference** | A pointer at another [content entry](/reference/dashboard/content/content-entries). | A product that points at its category. |
64
+ | **Asset** | A link to an [Asset Library](/reference/dashboard/content/asset-library) item. | An image, a video, or a document. |
65
+ | **HTML** | A link to a `.html` file in your library. | HTML that you wrote before, held inside the content. |
66
+
67
+ ## Reference fields
68
+
69
+ A **Reference** field points at another content entry. The entry that you point at keeps
70
+ its own data, and many fields can point at the same entry.
71
+
72
+ | Option | Values | What it does |
73
+ | --- | --- | --- |
74
+ | **Target Model** | A Model, or **Any Model** | Limits which entries an editor can choose. |
75
+ | **Repeatable** | On or off | On gives an ordered list of entries. Off gives one entry. |
76
+
77
+ **Target Model** holds the `key` of the Model, and not its id. A duplicate of the
78
+ workspace therefore keeps the constraint.
79
+
80
+ A reference stays inside one workspace. A field cannot point at an entry in another
81
+ workspace, and Picked reports such a target as unknown.
82
+
83
+ ## Repeatable and grouped fields
84
+
85
+ You can make any field **repeatable**. It then shows as a sortable list of values, and
86
+ not as one value. Use it for a gallery, for a list of features, or for any collection.
87
+
88
+ A **Group** field holds a set of fields under one key, and it gives a structured object.
89
+ Make a group repeatable to describe a list of objects, such as a list of feature cards.
90
+
91
+ ## Delete rules
92
+
93
+ Picked does not delete a Model while something still needs it.
94
+
95
+ | Condition | Result |
96
+ | --- | --- |
97
+ | Content entries still belong to the Model | The delete stops. |
98
+ | A Reference field still holds the Model as its **Target Model** | The delete stops. |
99
+
100
+ ## Related
101
+
102
+ - [About the content model](/explanation/the-content-model) — why a schema change does not
103
+ migrate your data.
104
+ - [About content references](/explanation/content-references) — why a reference is a pointer.
105
+ - [How to define a page layout](/how-to/define-a-page-layout)
106
+ - [How to create a content entry](/how-to/create-a-content-entry)
107
+ - [How to point one entry at another](/how-to/point-one-entry-at-another)
108
+ - [Blocks](/reference/dashboard/content/blocks)
@@ -24,12 +24,13 @@ choose, and the preview panel shows the page while it fills in.
24
24
  ## Change or remove the layout
25
25
 
26
26
  Use the change-layout control on the **Settings** tab to move the page to another
27
- Page Layout. When you unlink a layout, Picked separates the Content Entry from the
28
- page. It deletes no entry, but the page then has no content to render until you
29
- attach a layout again.
27
+ [Page Layout](/reference/dashboard/content/models#category). When you unlink a layout,
28
+ Picked separates the content entry from the page. It deletes no entry, but the page then
29
+ has no content to render until you attach a layout again.
30
30
 
31
31
  ## Related
32
32
 
33
33
  - [About pages and flows](/explanation/pages-and-flows) — when to choose a Page.
34
34
  - [How to fill and publish a page](/how-to/fill-and-publish-a-page)
35
35
  - [How to server-render a page](/how-to/server-render-a-page)
36
+ - [Models](/reference/dashboard/content/models) — the schema behind a Page.
@@ -12,7 +12,7 @@ information such as a name, an email address, a preference, or a choice.
12
12
 
13
13
  This page covers the experience field, which collects visitor input. An experience
14
14
  field is not the same as a content field. A content field is part of the schema of a
15
- CMS layout. See [Page and Step Layouts](/reference/dashboard/content/layouts) for those.
15
+ CMS layout. See [Models](/reference/dashboard/content/models) for those.
16
16
 
17
17
  <Screenshot
18
18
  route="/{orgSlug}/{projectId}/workspaces/{workspaceId}/fields"
@@ -26,7 +26,7 @@ visitors do not see it.
26
26
  are `card`, `modal`, and `fullscreen`.
27
27
 
28
28
  A step can also carry a **Step Layout**. A step layout is a reusable CMS schema, and
29
- it gives the step a Content Entry. See [Page and Step Layouts](/reference/dashboard/content/layouts).
29
+ it gives the step a Content Entry. See [Models](/reference/dashboard/content/models).
30
30
 
31
31
  ## Related
32
32
 
@@ -34,4 +34,4 @@ it gives the step a Content Entry. See [Page and Step Layouts](/reference/dashbo
34
34
 
35
35
  - [How to build a flow](/how-to/build-a-flow) — add a step and assign fields to it.
36
36
  - [How to reuse a step, a field, or an action](/how-to/reuse-a-step-field-or-action)
37
- - [Page and step layouts](/reference/dashboard/content/layouts) — the step layout schema.
37
+ - [Models](/reference/dashboard/content/models) — the step layout schema.
@@ -5,7 +5,7 @@ layout: docs
5
5
 
6
6
  # Experience Content Endpoint
7
7
 
8
- Fetch the Content Entries that back a single experience's steps.
8
+ Fetch the content entries that back the steps of a single experience.
9
9
 
10
10
  ## Request
11
11
 
@@ -29,7 +29,17 @@ GET /api/v1/projects/:projectId/experiences/:id/content
29
29
  {
30
30
  "id": "entry_789",
31
31
  "contentModelKey": "page-hero",
32
- "data": { "title": "Spring sale", "body": "..." }
32
+ "data": {
33
+ "title": "Spring sale",
34
+ "category": { "contentEntryId": "entry_42", "contentModelKey": "category" }
35
+ }
36
+ }
37
+ ],
38
+ "references": [
39
+ {
40
+ "id": "entry_42",
41
+ "contentModelKey": "category",
42
+ "data": { "name": "Outerwear" }
33
43
  }
34
44
  ]
35
45
  }
@@ -39,14 +49,59 @@ GET /api/v1/projects/:projectId/experiences/:id/content
39
49
  | --- | --- | --- |
40
50
  | `experienceId` | `string` | The experience the content belongs to. |
41
51
  | `versionId` | `string \| null` | The published version id, or `null` on preview. |
42
- | `content[].id` | `string` | The Content Entry id. |
43
- | `content[].contentModelKey` | `string \| null` | The layout's Key, or `null` when it cannot be resolved. |
44
- | `content[].data` | `object` | The entry data. It matches the layout schema. |
52
+ | `content[]` | `array` | The entries that the steps of the experience point at. |
53
+ | `content[].id` | `string` | The content entry id. |
54
+ | `content[].contentModelKey` | `string \| null` | The Key of the Model, or `null` when it cannot be resolved. |
55
+ | `content[].data` | `object` | The entry data. It matches the schema of the Model. |
56
+ | `references[]` | `array` | Every entry that a `reference` field reaches, in the same blob shape as `content[]`. |
57
+
58
+ The published response and the preview response hold the same fields, and the same
59
+ values, for the same content.
60
+
61
+ ## A reference field points at a separate blob
62
+
63
+ A [Reference field](/reference/dashboard/content/models#reference-fields) arrives as a
64
+ pointer, and not as the entry:
65
+
66
+ ```json
67
+ { "contentEntryId": "entry_42", "contentModelKey": "category" }
68
+ ```
69
+
70
+ A repeatable Reference field arrives as an array of such pointers.
71
+
72
+ The entry itself arrives in `references[]` under its own `id`. Look the pointer up
73
+ there. The SDK does this for you, through
74
+ [`useReference` and `getReference`](/reference/sdk/content).
75
+
76
+ `references[]` holds each entry one time, for any number of fields that point at it. It
77
+ omits the entries that are in `content[]` already.
78
+
79
+ ### What `references[]` omits
80
+
81
+ Picked resolves a chain of references to a maximum depth of 5. It counts the depth from
82
+ the entries in `content[]`. An entry is absent from `references[]` when Picked cannot
83
+ resolve it:
84
+
85
+ | Cause | Result |
86
+ | --- | --- |
87
+ | The target was deleted | The pointer stays. The entry is absent. |
88
+ | The target is in another workspace | The pointer stays. The entry is absent. |
89
+ | The chain makes a cycle | The pointer stays. The entry is absent. |
90
+ | The chain is deeper than 5 | The pointer stays, with its `contentModelKey`. The entry is absent. |
91
+
92
+ A pointer with no entry in `references[]` means that there is no such entry. Picked sends
93
+ no empty blob for it.
94
+
95
+ :::warning
96
+ A reference pointer also carries a `data` field with the content of the target inlined.
97
+ This is for the SDK versions that came before `references[]`. Read `references[]`
98
+ instead. A later release removes the inline copy.
99
+ :::
45
100
 
46
101
  ## An HTML asset comes back in the response
47
102
 
48
- A layout can have an [HTML asset](/reference/dashboard/content/asset-library) field. The value of that
49
- field arrives inside the response. The endpoint changes the reference to
103
+ A Model can have an [HTML asset](/reference/dashboard/content/asset-library) field. The
104
+ value of that field arrives inside the response. The endpoint changes the reference to
50
105
  `{ id, content }`. There, `content` holds the HTML that you uploaded, as a string. It
51
106
  is `null` when the endpoint cannot resolve it:
52
107
 
@@ -82,16 +137,16 @@ curl https://api.picked.app/api/v1/projects/proj_123/experiences/exp_123/content
82
137
  "versionId": "ver_456",
83
138
  "content": [
84
139
  { "id": "entry_789", "contentModelKey": "page-hero", "data": { "title": "Spring sale" } }
85
- ]
140
+ ],
141
+ "references": []
86
142
  }
87
143
  ```
88
144
 
89
- See [Project Config](/reference/delivery-api/project-config) for the endpoint that links a step
90
- to an entry. See [Asset Library](/reference/dashboard/content/asset-library) for an HTML asset. See
91
- [Server Snapshot](/reference/sdk/ssr/serialize) for how the SDK reads this content.
92
-
93
145
  ## Related
94
146
 
95
147
  - [About the two APIs](/explanation/the-two-apis)
96
- - [Project config](/reference/delivery-api/project-config)
148
+ - [About content references](/explanation/content-references) — why a reference is a pointer.
149
+ - [Content](/reference/sdk/content) — how the SDK resolves a pointer.
150
+ - [Project config](/reference/delivery-api/project-config) — the endpoint that links a step to an entry.
151
+ - [Server Snapshot](/reference/sdk/ssr/serialize) — how the SDK reads this content.
97
152
  - [Preview, cache, and crawlers](/reference/delivery-api/preview-caching-crawling)
@@ -0,0 +1,74 @@
1
+ ---
2
+ type: reference
3
+ layout: docs
4
+ ---
5
+
6
+ # Workspace Schema Endpoint
7
+
8
+ A JSON Schema document for the structure of your project: content models, fields, feature keys, experience keys, and step keys. Tooling reads this endpoint to generate TypeScript types for your application.
9
+
10
+ ## Request
11
+
12
+ ```
13
+ GET /api/v1/projects/:projectId/schema
14
+ ```
15
+
16
+ | Parameter | In | Description |
17
+ | --- | --- | --- |
18
+ | `projectId` | path | The project whose schema to fetch. |
19
+ | `preview_token` | query | Optional. Returns the preview (unpublished) schema when you send it. |
20
+
21
+ ## Response
22
+
23
+ The response is a [JSON Schema draft 2020-12](https://json-schema.org/draft/2020-12/schema) document with Picked-specific extension fields:
24
+
25
+ | Field | Description |
26
+ | --- | --- |
27
+ | `x-picked-schema-version` | Schema document version (currently `1`). |
28
+ | `x-picked-source` | `"published"` or `"preview"` — mirrors the surface you requested. |
29
+ | `x-picked-version-id` | Published workspace version id, or `null` on preview. |
30
+ | `x-picked-step-content-models` | Map of step key → content model key, which gives each layout its type. |
31
+ | `$defs.contentModels` | JSON Schema definitions for each content model. |
32
+ | `$defs.contentBlocks` | JSON Schema definitions for reusable content blocks. |
33
+ | `$defs.fields` | Object schema for project field values. |
34
+ | `$defs.featureKeys` | String enum of feature keys. |
35
+ | `$defs.experienceKeys` | String enum of experience keys. |
36
+ | `$defs.stepKeys` | String enum of step keys. |
37
+
38
+ ## Published and preview
39
+
40
+ On the published surface, the schema reflects your last published workspace. On the preview surface (`?preview_token=...`), the schema reflects the current draft workspace. See [Preview, cache, and crawlers](/reference/delivery-api/preview-caching-crawling).
41
+
42
+ When no published schema exists, the published endpoint returns `404` and tells you to publish the workspace.
43
+
44
+ ## Example
45
+
46
+ ```bash
47
+ curl https://api.picked.app/api/v1/projects/proj_123/schema
48
+ ```
49
+
50
+ ```json
51
+ {
52
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
53
+ "$id": "picked:project/proj_123/schema",
54
+ "x-picked-schema-version": 1,
55
+ "x-picked-source": "published",
56
+ "x-picked-version-id": "ver_456",
57
+ "x-picked-step-content-models": {
58
+ "intro": "welcome-page"
59
+ },
60
+ "$defs": {
61
+ "contentModels": {},
62
+ "contentBlocks": {},
63
+ "fields": { "type": "object", "additionalProperties": false, "properties": {} },
64
+ "featureKeys": { "type": "string", "enum": ["default"] },
65
+ "experienceKeys": { "type": "string", "enum": ["welcome-survey"] },
66
+ "stepKeys": { "type": "string", "enum": ["intro"] }
67
+ }
68
+ }
69
+ ```
70
+
71
+ ## Related
72
+
73
+ - [Type generation](/reference/sdk/type-generation) — Generate TypeScript types from this schema in your app.
74
+ - [Project Config](/reference/delivery-api/project-config) — Runtime project configuration for the SDK.
@@ -74,14 +74,21 @@ documentation uses, and it names the others.
74
74
 
75
75
  | Term | What it is |
76
76
  | --- | --- |
77
- | **Page layout** | A reusable schema that sets which fields a Page can hold. The API type is `ContentModel`, and the dashboard list page is titled **Models**. |
78
- | **Step layout** | The same, for one Step inside a Flow. |
79
- | **Section** | A reusable schema fragment that you put inside one or more layouts. The API type is `ContentBlock`, and the dashboard list page is titled **Blocks**. |
80
- | **Content entry** | One instance of a layout, filled with real values. The dashboard list page is titled **Content**. |
77
+ | **Model** | A reusable schema that sets which fields a piece of content can hold. The API type is `ContentModel`. The dashboard lists them under **CMS**, at **Models**. |
78
+ | **Block** | A reusable schema fragment that you put inside one or more Models. The API type is `ContentBlock`. The dashboard lists them under **CMS**, at **Blocks**. |
79
+ | **Content entry** | One instance of a Model, filled with real values. The dashboard lists them under **CMS**, at **Content entries**. |
80
+ | **Category** | The role of a Model or a Block. It is fixed when you create the record. |
81
+ | **Page layout** | A Model with the Page layout category. It sets which fields a Page can hold. |
82
+ | **Step layout** | A Model with the Step layout category. It sets which fields one Step inside a Flow can hold. |
83
+ | **Section** | A Block with the Section category. A **Page Sections** field accepts it. |
84
+ | **General content** | A Model or a Block with no category. It has no layout role, and nothing renders its entries directly. |
85
+ | **Reference** | A field that points one content entry at another. The pointer holds the id of the target, and not a copy of it. |
86
+ | **Target Model** | The Model whose entries a Reference field accepts. It holds a Key. **Any Model** sets no limit. |
87
+ | **Entry title** | The name that the entries list shows. It is the first single-line text field of the entry, and it falls back to the entry id. |
81
88
  | **Asset** | A file that your content points at: an image, a video, a document, or HTML. |
82
89
  | **Asset library** | The project-level store that holds your assets. |
83
90
  | **Design system** | A set of shared design decisions for a project. |
84
- | **Content schema** | The set of fields that a layout or a section defines. |
91
+ | **Content schema** | The set of fields that a Model or a Block defines. |
85
92
  | **Asset version** | One file that somebody uploaded for an asset. The library keeps the earlier versions. |
86
93
  | **Validation error** | A report that one field in a content entry does not match its schema. It carries the path to the exact field. |
87
94
 
@@ -96,6 +103,7 @@ documentation uses, and it names the others.
96
103
  | **Slot** | A named mount point, rendered by `<ExperienceSlot name="…" />`. It maps to the `.picked-slot-<name>` selector. |
97
104
  | **Placement** | Where an experience renders against its target: `replace`, `before`, `prepend`, `append`, or `after`. |
98
105
  | **Target selector** | The selector that an experience renders into. |
106
+ | **Content index** | The store of every content record that the client holds, keyed by id. `useContent(id)` and `useReference()` read it. |
99
107
  | **Snapshot** | The plain JSON that `serialize()` returns on your server, and that seeds the client in the browser. |
100
108
  | **Precondition** | A gate that decides whether Picked starts at all. |
101
109
  | **Visitor** | The person on your site. Picked gives each one a stable ID. A visitor is not a user. |
@@ -46,7 +46,7 @@ operation, or MFA. They match the `AuthErrorCode` enum in the schema.
46
46
  | Code | Description |
47
47
  |------|-------------|
48
48
  | `INVALID_CREDENTIALS` | The email address and the password do not match. |
49
- | `EMAIL_NOT_CONFIRMED` | The account is there, but nobody verified the email address. See [Authentication](/reference/management-api/authentication#verify-an-email-address). |
49
+ | `EMAIL_NOT_CONFIRMED` | The account is there, but nobody verified the email address. See [Authentication](/reference/management-api/authentication#the-mutations). |
50
50
  | `USER_NOT_FOUND` | There is no account with that email address. |
51
51
  | `USER_ALREADY_EXISTS` | An account with that email address is there already. The API returns this when you create an account. |
52
52
  | `WEAK_PASSWORD` | The password is not strong enough. |
@@ -199,7 +199,7 @@ if (result.errors) {
199
199
  ### Refresh a token that expired
200
200
 
201
201
  A request can return `UNAUTHORIZED` while the caller holds a refresh token. Try a
202
- [session refresh](/reference/management-api/authentication#refresh-a-session) first. Do not treat it as a
202
+ [session refresh](/reference/management-api/authentication#the-mutations) first. Do not treat it as a
203
203
  failure to sign in:
204
204
 
205
205
  ```javascript