@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
@@ -6,8 +6,8 @@ layout: docs
6
6
  # Vite Plugin
7
7
 
8
8
  `@picked/vite-plugin-picked` adds Picked to your Vite project. It reads the options
9
- of your project at build time. It then injects them through the Vite `define`
10
- option, so the SDK makes no API request at runtime. In development it also serves a
9
+ of your project at build time. It then puts them in a module that gives them to the
10
+ SDK, so the SDK makes no API request at runtime. In development it also serves a
11
11
  launcher page. On that page you can see a preview of an experience with your own
12
12
  feature flag values.
13
13
 
@@ -19,11 +19,75 @@ When Vite starts, in both `dev` and `build`, the plugin does this:
19
19
 
20
20
  1. It reads the configuration of your project from the Picked API.
21
21
  2. It embeds those options in your bundle.
22
- 3. The SDK reads the embedded configuration at runtime and makes no network request.
22
+ 3. The module gives the options to the SDK as the browser loads it.
23
+ 4. The SDK reads the embedded configuration at runtime and makes no network request.
24
+
25
+ Step 3 is a function call. The module gives the options to the SDK as it loads, and does
26
+ not wait for the SDK to ask.
23
27
 
24
28
  When a preview token is there at runtime, the SDK ignores the embedded configuration and
25
29
  reads fresh data from the API.
26
30
 
31
+ ### Preload of the data file
32
+
33
+ Vite puts the options of your project in their own JavaScript file. For each HTML page
34
+ in your build, the plugin adds a `<link rel="modulepreload">` for that file. The
35
+ browser then gets it while it reads the page, and not later when the SDK starts.
36
+
37
+ The CMS content of an experience stays in its own file and gets no preload. The
38
+ browser gets it only when an experience needs it.
39
+
40
+ Some applications make their HTML from the code, and not from an HTML file in your
41
+ project. React Router in server mode is one of these. Such a build has no page for the
42
+ plugin to add the link to. Add this line to the code that runs in the browser instead:
43
+
44
+ :::code-group
45
+
46
+ ```ts [entry.client.ts]
47
+ import 'virtual:picked/data'
48
+ ```
49
+
50
+ :::
51
+
52
+ Your framework then sees the file in its own list and adds the preload for you.
53
+
54
+ The line reads no value from the module. It is there for the work the module does as it
55
+ loads. A bundler removes a module that only declares values, and removes the line with
56
+ it. This module gives your project options to the SDK, which is work, so the bundler
57
+ keeps both.
58
+
59
+ Your application is correct without this line. The SDK gets the same data later, as it
60
+ starts. The line moves that work earlier.
61
+
62
+ ### Types for the data file
63
+
64
+ The plugin makes `virtual:picked/data` at build time. Because the module is not a file in
65
+ your project, TypeScript cannot find its types. The plugin gives you a type file for the
66
+ module. Point your project at that type file to import from the module:
67
+
68
+ :::code-group
69
+
70
+ ```json [tsconfig.json]
71
+ {
72
+ "compilerOptions": {
73
+ "types": ["@picked/vite-plugin-picked/client"]
74
+ }
75
+ }
76
+ ```
77
+
78
+ ```ts [picked-data.ts]
79
+ /// <reference types="@picked/vite-plugin-picked/client" />
80
+ ```
81
+
82
+ :::
83
+
84
+ Use one of the two. The `types` option applies to all files in your project. The
85
+ `reference` comment applies to one file.
86
+
87
+ The module gives three values: `projectConfig`, `experienceContent` and
88
+ `manifestMetadata`. You do not give these values to the SDK. The module gives them to
89
+ the SDK itself as the browser loads it.
90
+
27
91
  ### Dev launcher
28
92
 
29
93
  In development, the plugin serves an HTML page at `/`. On that page you can:
@@ -42,11 +106,23 @@ After the dev server starts, the launcher URL appears next to the Vite output:
42
106
 
43
107
  ## Options
44
108
 
45
- | Option | Type | Default | Description |
46
- | ---------------- | --------- | ---------------------------- | -------------------------------------------------------- |
47
- | `projectId` | `string` | — | **Required.** The ID of your Picked project. |
48
- | `apiUrl` | `string` | `https://api.picked.app` | Your own API URL, for a self-hosted or local API. |
49
- | `disableLauncher`| `boolean` | `false` | Turns the launcher page off in both dev and build output.|
109
+ | Option | Type | Default | Description |
110
+ | ---------------- | --------------------- | ------------------------ | --------------------------------------------------------- |
111
+ | `projectId` | `string` | — | **Required.** The ID of your Picked project. |
112
+ | `apiUrl` | `string` | `https://api.picked.app` | Your own API URL, for a self-hosted or local API. |
113
+ | `disableLauncher`| `boolean` | `false` | Turns the launcher page off in both dev and build output. |
114
+ | `mode` | `'bundle' \| 'api'` | `'bundle'` | Whether the build carries your project data. |
115
+
116
+ ### mode
117
+
118
+ `'bundle'` reads your project options at build time and puts them in your bundle.
119
+
120
+ `'api'` does not read them. Your build then makes no request to the Picked API, and
121
+ writes no `.picked` directory. The SDK reads your project options from the API at
122
+ runtime instead. Use this when your build must not depend on the Picked API.
123
+
124
+ The SDK has no equivalent option. It uses the data your build gives it, and the API when
125
+ your build gives none.
50
126
 
51
127
  ## Build output
52
128
 
@@ -54,6 +130,12 @@ For a production build, `vite build`, the plugin writes an `index.html` file tha
54
130
  holds the launcher page. Set `disableLauncher` to stop this. The file lets you deploy
55
131
  the launcher next to your application, so that a stakeholder can see a preview.
56
132
 
133
+ The plugin writes that file only when your build made no `index.html` of its own. An
134
+ application that has an HTML entry keeps its own page at the root of the output.
135
+
136
+ The plugin also writes a `.picked` directory next to your Vite `root`. It holds the
137
+ options of your project and the CMS content of each experience.
138
+
57
139
  ## Related
58
140
 
59
141
  - [How to install the Vite plugin](/how-to/install-the-vite-plugin)
@@ -118,7 +118,7 @@ When `requiresMfa` is `true`, you must complete the MFA challenge before you rec
118
118
  a session. See the [Authentication](/reference/management-api/authentication) guide.
119
119
 
120
120
  For a server-to-server integration, use
121
- [API key authentication](/reference/management-api/authentication#api-key-authentication) and not a
121
+ [API key authentication](/how-to/authenticate-with-an-api-key) and not a
122
122
  session token.
123
123
 
124
124
  ## Make an authenticated query
@@ -181,6 +181,6 @@ new content on the next request, and you deploy nothing.
181
181
  - [About server-side rendering](/explanation/why-server-side-rendering) — why the
182
182
  snapshot exists, and what it carries.
183
183
  - [Server snapshot](/reference/sdk/ssr/serialize) — every `serialize()` parameter.
184
- - [Page and step layouts](/reference/dashboard/content/layouts) — every field type.
184
+ - [Models](/reference/dashboard/content/models) — every field type.
185
185
  - [Preview, cache, and crawlers](/reference/delivery-api/preview-caching-crawling) — how
186
186
  a draft stays out of the search index.