@picked/client 0.0.1-dev.1785826066660 → 0.0.1-dev.1785908062293

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 (169) hide show
  1. package/dist/.tsbuildinfo +1 -1
  2. package/dist/{api-d0qKmzPH.js → api-03c5jvVk.js} +1 -1
  3. package/dist/{api-Djuh2gfe.cjs → api-CQxCVIrm.cjs} +1 -1
  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/conditions-and-the-logic-engine.md +94 -0
  8. package/dist/docs/explanation/feature-flag-allocation.md +176 -0
  9. package/dist/docs/explanation/how-picked-works.md +124 -0
  10. package/dist/docs/explanation/how-pickedql-works.md +76 -0
  11. package/dist/docs/explanation/pages-and-flows.md +64 -0
  12. package/dist/docs/explanation/the-content-model.md +77 -0
  13. package/dist/docs/explanation/the-two-apis.md +68 -0
  14. package/dist/docs/explanation/why-server-side-rendering.md +76 -0
  15. package/dist/docs/explanation/workspaces-and-versions.md +71 -0
  16. package/dist/docs/how-to/add-a-step-field-or-action.md +43 -0
  17. package/dist/docs/{pickedql/examples.md → how-to/analytics/index.md} +19 -6
  18. package/dist/docs/how-to/archive-or-delete-a-workspace.md +46 -0
  19. package/dist/docs/how-to/authenticate-with-a-magic-link.md +40 -0
  20. package/dist/docs/how-to/authenticate-with-a-password.md +51 -0
  21. package/dist/docs/how-to/authenticate-with-an-api-key.md +51 -0
  22. package/dist/docs/how-to/authenticate-with-oauth.md +40 -0
  23. package/dist/docs/{flow-builder/building-flows.md → how-to/build-a-flow.md} +13 -9
  24. package/dist/docs/how-to/connect-the-mcp-server.md +38 -0
  25. package/dist/docs/how-to/create-a-project.md +29 -0
  26. package/dist/docs/how-to/create-an-experience.md +42 -0
  27. package/dist/docs/how-to/create-and-revoke-an-api-key.md +37 -0
  28. package/dist/docs/how-to/debug-with-the-chrome-extension.md +57 -0
  29. package/dist/docs/how-to/define-a-page-layout.md +39 -0
  30. package/dist/docs/how-to/fill-and-publish-a-page.md +50 -0
  31. package/dist/docs/{gtm-template.md → how-to/install-the-gtm-template.md} +9 -3
  32. package/dist/docs/how-to/install-the-sdk.md +68 -0
  33. package/dist/docs/how-to/install-the-vite-plugin.md +56 -0
  34. package/dist/docs/how-to/invite-and-remove-members.md +34 -0
  35. package/dist/docs/how-to/preview-a-workspace.md +28 -0
  36. package/dist/docs/how-to/publish-a-workspace.md +30 -0
  37. package/dist/docs/how-to/read-a-feature-flag.md +101 -0
  38. package/dist/docs/how-to/register-a-component.md +55 -0
  39. package/dist/docs/how-to/register-an-action-handler.md +67 -0
  40. package/dist/docs/how-to/render-a-step-form.md +132 -0
  41. package/dist/docs/how-to/render-an-unpublished-preview.md +41 -0
  42. package/dist/docs/how-to/reuse-a-section.md +37 -0
  43. package/dist/docs/how-to/reuse-a-step-field-or-action.md +28 -0
  44. package/dist/docs/how-to/roll-back-a-published-version.md +26 -0
  45. package/dist/docs/how-to/run-an-ab-test.md +49 -0
  46. package/dist/docs/how-to/run-code-on-a-form-submission.md +125 -0
  47. package/dist/docs/how-to/server-render-a-page.md +81 -0
  48. package/dist/docs/how-to/set-a-content-security-policy.md +32 -0
  49. package/dist/docs/how-to/set-up-mfa.md +69 -0
  50. package/dist/docs/how-to/upload-and-use-an-asset.mdx +73 -0
  51. package/dist/docs/how-to/validate-a-field.md +52 -0
  52. package/dist/docs/how-to/write-a-condition.md +45 -0
  53. package/dist/docs/how-to/write-a-predicate.md +60 -0
  54. package/dist/docs/index.md +41 -70
  55. package/dist/docs/reference/dashboard/actions.mdx +53 -0
  56. package/dist/docs/{api-keys.mdx → reference/dashboard/api-keys.mdx} +7 -15
  57. package/dist/docs/reference/dashboard/conditions.mdx +42 -0
  58. package/dist/docs/reference/dashboard/content/asset-library.mdx +63 -0
  59. package/dist/docs/{content → reference/dashboard/content}/content-entries.mdx +11 -3
  60. package/dist/docs/{content → reference/dashboard/content}/layouts.mdx +11 -35
  61. package/dist/docs/reference/dashboard/content/pages.mdx +35 -0
  62. package/dist/docs/reference/dashboard/content/sections.mdx +28 -0
  63. package/dist/docs/{experiences.mdx → reference/dashboard/experiences.mdx} +9 -16
  64. package/dist/docs/{features.mdx → reference/dashboard/features.mdx} +26 -41
  65. package/dist/docs/{fields.mdx → reference/dashboard/fields.mdx} +26 -20
  66. package/dist/docs/{flow-builder/overview.mdx → reference/dashboard/flow-builder/canvas.mdx} +8 -13
  67. package/dist/docs/{flow-builder → reference/dashboard/flow-builder}/condition-builder.md +5 -13
  68. package/dist/docs/{flow-builder → reference/dashboard/flow-builder}/keyboard-shortcuts.md +7 -1
  69. package/dist/docs/{flow-builder → reference/dashboard/flow-builder}/nodes.md +10 -3
  70. package/dist/docs/reference/dashboard/projects.mdx +44 -0
  71. package/dist/docs/reference/dashboard/reports.mdx +43 -0
  72. package/dist/docs/reference/dashboard/steps.mdx +37 -0
  73. package/dist/docs/{team-management.md → reference/dashboard/team-management.md} +5 -22
  74. package/dist/docs/{workspace-versioning.mdx → reference/dashboard/workspace-versioning.mdx} +6 -10
  75. package/dist/docs/reference/dashboard/workspaces.mdx +76 -0
  76. package/dist/docs/{delivery-api → reference/delivery-api}/experience-content.md +11 -4
  77. package/dist/docs/reference/delivery-api/index.md +45 -0
  78. package/dist/docs/{delivery-api → reference/delivery-api}/preview-caching-crawling.md +12 -5
  79. package/dist/docs/{delivery-api → reference/delivery-api}/project-config.md +11 -4
  80. package/dist/docs/reference/glossary.md +173 -0
  81. package/dist/docs/reference/management-api/authentication.md +74 -0
  82. package/dist/docs/{api → reference/management-api}/authorization-and-scopes.md +10 -3
  83. package/dist/docs/{api → reference/management-api}/error-handling.md +9 -3
  84. package/dist/docs/{api → reference/management-api}/pagination.md +6 -0
  85. package/dist/docs/{pickedql → reference/pickedql}/data-sources.md +16 -9
  86. package/dist/docs/{pickedql → reference/pickedql}/dimensions.md +7 -0
  87. package/dist/docs/{pickedql → reference/pickedql}/filtering.md +7 -0
  88. package/dist/docs/reference/pickedql/index.md +18 -0
  89. package/dist/docs/{pickedql → reference/pickedql}/schema.md +13 -6
  90. package/dist/docs/{pickedql → reference/pickedql}/virtual-functions.md +7 -0
  91. package/dist/docs/reference/sdk/actions.md +30 -0
  92. package/dist/docs/{sdk → reference/sdk}/conditions.md +8 -1
  93. package/dist/docs/reference/sdk/content-security-policy.md +21 -0
  94. package/dist/docs/reference/sdk/experiences.md +51 -0
  95. package/dist/docs/{sdk → reference/sdk}/features.md +30 -117
  96. package/dist/docs/{sdk → reference/sdk}/fields.md +10 -88
  97. package/dist/docs/reference/sdk/index.md +68 -0
  98. package/dist/docs/{sdk → reference/sdk}/plugins/create-experience.md +10 -22
  99. package/dist/docs/reference/sdk/plugins/dynamic-experiences.md +74 -0
  100. package/dist/docs/reference/sdk/plugins/index.md +29 -0
  101. package/dist/docs/{sdk → reference/sdk}/plugins/window-object.md +6 -0
  102. package/dist/docs/reference/sdk/predicates.md +43 -0
  103. package/dist/docs/reference/sdk/ssr/index.md +33 -0
  104. package/dist/docs/{sdk → reference/sdk}/ssr/rendering-and-hydration.md +4 -63
  105. package/dist/docs/{sdk → reference/sdk}/ssr/serialize.md +6 -33
  106. package/dist/docs/{sdk → reference/sdk}/ssr/slots-and-placements.md +7 -1
  107. package/dist/docs/reference/sdk/steps.md +87 -0
  108. package/dist/docs/reference/tools/chrome-extension.md +16 -0
  109. package/dist/docs/{image-optimisation-service.md → reference/tools/image-optimisation-service.md} +8 -0
  110. package/dist/docs/{mcp.md → reference/tools/mcp.md} +5 -45
  111. package/dist/docs/{vite-plugin.md → reference/tools/vite-plugin.md} +34 -35
  112. package/dist/docs/{api/index.md → tutorials/first-api-call.md} +27 -15
  113. package/dist/docs/tutorials/first-experience-in-the-dashboard.mdx +143 -0
  114. package/dist/docs/tutorials/first-experience.mdx +255 -0
  115. package/dist/docs/tutorials/first-server-rendered-page.mdx +186 -0
  116. package/dist/esm/index.js +290 -319
  117. package/dist/esm/plugins/dynamic-experiences/index.js +3 -3
  118. package/dist/esm/server/index.js +22 -22
  119. package/dist/plugin-CHOVsx7Z.js +287 -0
  120. package/dist/plugin-DsaGXQHx.cjs +1 -0
  121. package/dist/types/data-source/api.d.ts +60 -0
  122. package/dist/types/data-source/api.d.ts.map +1 -0
  123. package/dist/types/data-source/provider.d.ts +97 -0
  124. package/dist/types/data-source/provider.d.ts.map +1 -0
  125. package/dist/types/entities/feature/feature.d.ts +16 -0
  126. package/dist/types/entities/feature/feature.d.ts.map +1 -1
  127. package/dist/types/exports.d.ts +0 -2
  128. package/dist/types/exports.d.ts.map +1 -1
  129. package/dist/types/index.d.ts +0 -1
  130. package/dist/types/index.d.ts.map +1 -1
  131. package/dist/types/picked.d.ts +15 -0
  132. package/dist/types/picked.d.ts.map +1 -1
  133. package/dist/types/plugins/dynamic-experiences/index.d.ts +2 -0
  134. package/dist/types/plugins/dynamic-experiences/index.d.ts.map +1 -1
  135. package/dist/types/plugins/dynamic-experiences/plugin.d.ts +2 -34
  136. package/dist/types/plugins/dynamic-experiences/plugin.d.ts.map +1 -1
  137. package/dist/types/plugins/dynamic-experiences/types.d.ts +34 -16
  138. package/dist/types/plugins/dynamic-experiences/types.d.ts.map +1 -1
  139. package/dist/types/server/serialize.d.ts +7 -6
  140. package/dist/types/server/serialize.d.ts.map +1 -1
  141. package/package.json +1 -1
  142. package/dist/docs/actions.mdx +0 -98
  143. package/dist/docs/api/authentication.md +0 -403
  144. package/dist/docs/chrome-extension.md +0 -68
  145. package/dist/docs/conditions.mdx +0 -72
  146. package/dist/docs/content/asset-library.mdx +0 -124
  147. package/dist/docs/content/pages.mdx +0 -82
  148. package/dist/docs/content/sections.mdx +0 -44
  149. package/dist/docs/delivery-api/index.md +0 -53
  150. package/dist/docs/guides/build-a-personalized-page.mdx +0 -161
  151. package/dist/docs/pickedql/index.md +0 -54
  152. package/dist/docs/projects.mdx +0 -44
  153. package/dist/docs/reports.mdx +0 -20
  154. package/dist/docs/sdk/actions.md +0 -82
  155. package/dist/docs/sdk/content-security-policy.md +0 -33
  156. package/dist/docs/sdk/experiences.md +0 -64
  157. package/dist/docs/sdk/feature-allocation.md +0 -161
  158. package/dist/docs/sdk/index.md +0 -98
  159. package/dist/docs/sdk/plugins/dynamic-experiences.md +0 -84
  160. package/dist/docs/sdk/plugins/index.md +0 -9
  161. package/dist/docs/sdk/predicates.md +0 -128
  162. package/dist/docs/sdk/ssr/index.md +0 -79
  163. package/dist/docs/sdk/steps.md +0 -479
  164. package/dist/docs/steps.mdx +0 -53
  165. package/dist/docs/workspaces.mdx +0 -133
  166. package/dist/plugin-BVAFWjpT.js +0 -252
  167. package/dist/plugin-BcCn2llk.cjs +0 -1
  168. package/dist/types/entities/content/reference.d.ts +0 -101
  169. package/dist/types/entities/content/reference.d.ts.map +0 -1
@@ -1,5 +1,7 @@
1
1
  /** @file Public exports for the dynamic-experiences plugin (project config + per-experience content resolution). */
2
2
  export { dynamicExperiencesPlugin, fetchExperienceContent, fetchProject } from './plugin';
3
3
  export { createClientHeaders } from '../../utils/client-headers';
4
+ export { createPickedDataProvider, resolveVirtualDataModule, isVirtualPickedData, } from '../../data-source/provider';
5
+ export type { PickedDataMode, PickedDataProvider, PickedDataProviderMeta, PickedDataProviderOptions, } from '../../data-source/provider';
4
6
  export type * from './types';
5
7
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/plugins/dynamic-experiences/index.ts"],"names":[],"mappings":"AAAA,oHAAoH;AACpH,OAAO,EAAE,wBAAwB,EAAE,sBAAsB,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;AACzF,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAA;AAChE,mBAAmB,SAAS,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/plugins/dynamic-experiences/index.ts"],"names":[],"mappings":"AAAA,oHAAoH;AACpH,OAAO,EAAE,wBAAwB,EAAE,sBAAsB,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;AACzF,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAA;AAChE,OAAO,EACL,wBAAwB,EACxB,wBAAwB,EACxB,mBAAmB,GACpB,MAAM,4BAA4B,CAAA;AACnC,YAAY,EACV,cAAc,EACd,kBAAkB,EAClB,sBAAsB,EACtB,yBAAyB,GAC1B,MAAM,4BAA4B,CAAA;AACnC,mBAAmB,SAAS,CAAA"}
@@ -1,6 +1,7 @@
1
1
  import type { Plugin } from '../../entities/plugin/plugin';
2
2
  import type { Picked } from '../../picked';
3
- import type { DynamicExperiencesPluginOptions, ExperienceContentResponse, FetchProjectOptions, ProjectConfig } from './types';
3
+ import type { DynamicExperiencesPluginOptions, ProjectConfig } from './types';
4
+ export { fetchProject, fetchExperienceContent } from '../../data-source/api';
4
5
  /**
5
6
  * Synchronously registers a complete project config with the client: features, conditions,
6
7
  * fields, steps, and experiences, in dependency order.
@@ -23,39 +24,6 @@ export declare function registerProjectConfig(client: Picked, config: ProjectCon
23
24
  isPreview: boolean;
24
25
  sessionId: string;
25
26
  }): void;
26
- /**
27
- * Fetches the project configuration from the Picked REST API.
28
- *
29
- * Returns `null` on network failure, non-OK responses, or invalid JSON shape.
30
- * Connection-refused errors from local URLs are suppressed silently.
31
- *
32
- * @param {string} apiUrl - Base URL for the Picked API.
33
- * @param {string} projectId - Project ID to fetch config for.
34
- * @param {FetchProjectOptions} [options] - Optional headers and preview token.
35
- * @returns {Promise<ProjectConfig | null>} Validated project config, or `null` on any failure.
36
- * @example
37
- * ```typescript
38
- * const config = await fetchProject('https://api.picked.app', 'proj_123')
39
- * ```
40
- */
41
- export declare function fetchProject(apiUrl: string, projectId: string, options?: FetchProjectOptions): Promise<ProjectConfig | null>;
42
- /**
43
- * Fetches per-experience content from the Picked API.
44
- *
45
- * Returns `null` on network failure, non-OK responses, or invalid JSON shape — preserving
46
- * the failure-tolerant policy: experiences still render, layouts handle null defensively.
47
- *
48
- * @param {string} apiUrl - Base URL for the Picked API.
49
- * @param {string} projectId - Project ID to fetch content for.
50
- * @param {string} experienceId - Experience ID whose content to fetch.
51
- * @param {FetchProjectOptions} [options] - Optional headers, preview token, and abort signal.
52
- * @returns {Promise<ExperienceContentResponse | null>} Validated content response, or `null` on any failure.
53
- * @example
54
- * ```typescript
55
- * const content = await fetchExperienceContent('https://api.picked.app', 'proj_1', 'exp_1')
56
- * ```
57
- */
58
- export declare function fetchExperienceContent(apiUrl: string, projectId: string, experienceId: string, options?: FetchProjectOptions): Promise<ExperienceContentResponse | null>;
59
27
  /**
60
28
  * Plugin that fetches project configuration from the Picked REST API and registers
61
29
  * features, steps, fields, and experiences with the client.
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../../src/plugins/dynamic-experiences/plugin.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAA;AAC1D,OAAO,KAAK,EAAE,MAAM,EAAoB,MAAM,cAAc,CAAA;AAI5D,OAAO,KAAK,EAEV,+BAA+B,EAC/B,yBAAyB,EACzB,mBAAmB,EACnB,aAAa,EAId,MAAM,SAAS,CAAA;AA4JhB;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,aAAa,EACrB,OAAO,EAAE;IAAE,SAAS,EAAE,OAAO,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,GACjD,IAAI,CAMN;AAyJD;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,YAAY,CAChC,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,EACjB,OAAO,CAAC,EAAE,mBAAmB,GAC5B,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC,CAmC/B;AAoBD;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,sBAAsB,CAC1C,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,EACjB,YAAY,EAAE,MAAM,EACpB,OAAO,CAAC,EAAE,mBAAmB,GAC5B,OAAO,CAAC,yBAAyB,GAAG,IAAI,CAAC,CAsC3C;AAgRD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,wBAAwB,CAAC,OAAO,CAAC,EAAE,+BAA+B,GAAG,MAAM,CAsC1F"}
1
+ {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../../src/plugins/dynamic-experiences/plugin.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAA;AAC1D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAI1C,OAAO,KAAK,EAEV,+BAA+B,EAE/B,aAAa,EAGd,MAAM,SAAS,CAAA;AAEhB,OAAO,EAAE,YAAY,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAA;AAyI5E;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,aAAa,EACrB,OAAO,EAAE;IAAE,SAAS,EAAE,OAAO,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,GACjD,IAAI,CAMN;AAqOD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,wBAAwB,CAAC,OAAO,CAAC,EAAE,+BAA+B,GAAG,MAAM,CAmD1F"}
@@ -5,6 +5,7 @@ import type { ExperienceStep } from '../../entities/step/step';
5
5
  import type { Field } from '../../entities/field/field';
6
6
  import type { ExperienceEdge, ExperienceNode, ExperienceTarget } from '../../entities/experience/experience';
7
7
  import type { Condition } from '../../entities/condition/condition';
8
+ import type { PickedDataMode, PickedDataProvider } from '../../data-source/provider';
8
9
  import type { LogicRule, LogicValue } from '../../logic-engine';
9
10
  /**
10
11
  * Wire-format step as returned by the Picked API. Matches {@link ExperienceStep}
@@ -80,6 +81,24 @@ export interface ProjectConfig {
80
81
  }
81
82
  export interface DynamicExperiencesPluginOptions {
82
83
  apiUrl?: string;
84
+ /**
85
+ * Which source this session reads project config and CMS content from. Omit to keep the
86
+ * legacy behaviour: the bundle when `virtual:picked/data` resolves, the API otherwise.
87
+ * A preview token forces `'api'` regardless.
88
+ */
89
+ mode?: PickedDataMode;
90
+ /**
91
+ * A pre-built data provider, used verbatim. Supply this to share one provider between the
92
+ * browser plugin and a server-side `serialize()` call, or to inject a stub in tests.
93
+ * Supersedes `mode`, `bundle`, `projectConfig` and `getContent`.
94
+ */
95
+ dataProvider?: PickedDataProvider;
96
+ /**
97
+ * The `virtual:picked/data` module. Supply it to skip the dynamic import — which is also
98
+ * how a consumer places the module in a chosen chunk, since a module that is both
99
+ * statically and dynamically imported is placed in the static chunk.
100
+ */
101
+ bundle?: VirtualPickedData;
83
102
  projectConfig?: ProjectConfig;
84
103
  /**
85
104
  * Customer-supplied content fetcher. When provided, supersedes both the virtual
@@ -122,17 +141,7 @@ export interface ContentBlob {
122
141
  export interface ExperienceContentResponse {
123
142
  experienceId: string;
124
143
  versionId: string | null;
125
- /** The Content records the experience's steps point at, via `Step.layoutContentId`. */
126
144
  content: ContentBlob[];
127
- /**
128
- * Content records reached from `content` through a `reference` field, deduped
129
- * and excluding the step blobs. Registered into the content registry the same
130
- * way, so a `{ contentEntryId }` pointer resolves through `contents.getById`.
131
- *
132
- * Optional: a response produced before this field existed — notably a build-time
133
- * cache written by an older `@picked/vite-plugin-picked` — omits it entirely.
134
- */
135
- references?: ContentBlob[];
136
145
  }
137
146
  /**
138
147
  * Function that resolves an experience's content blobs. Set on the Picked client by
@@ -146,6 +155,20 @@ export type ContentLoader = (experience: {
146
155
  }, options?: {
147
156
  previewToken?: string;
148
157
  }) => Promise<ExperienceContentResponse | null>;
158
+ /**
159
+ * Provenance the virtual data module records about the snapshot it carries: which build
160
+ * flavour produced it, when, and which workspace version it was taken from.
161
+ */
162
+ export interface PickedManifestMetadata {
163
+ /** `'build'` when build-mode prefetch JSON was used, `'dev'` when the dev-mode fetch was. */
164
+ mode: 'dev' | 'build';
165
+ /** ISO 8601 timestamp from the manifest. `null` in dev mode, where no manifest is written. */
166
+ fetchedAt: string | null;
167
+ /** The `versionId` the snapshot was taken from, when known. */
168
+ projectVersionId: string | null;
169
+ /** The `workspaceId` the snapshot was taken from, when known. */
170
+ workspaceId: string | null;
171
+ }
149
172
  /**
150
173
  * Optional-fields surface of the virtual data module exposed by `@picked/vite-plugin-picked`.
151
174
  * The shape is identical between dev (`vite serve`) and build (`vite build`) modes.
@@ -153,11 +176,6 @@ export type ContentLoader = (experience: {
153
176
  export interface VirtualPickedData {
154
177
  projectConfig: ProjectConfig;
155
178
  experienceContent: ContentLoader;
156
- manifestMetadata: {
157
- mode: 'dev' | 'build';
158
- fetchedAt: string | null;
159
- projectVersionId: string | null;
160
- workspaceId: string | null;
161
- };
179
+ manifestMetadata: PickedManifestMetadata;
162
180
  }
163
181
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/plugins/dynamic-experiences/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAA;AAC9D,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAA;AACvD,OAAO,KAAK,EACV,cAAc,EACd,cAAc,EACd,gBAAgB,EACjB,MAAM,sCAAsC,CAAA;AAC7C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oCAAoC,CAAA;AACnE,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AAE/D;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,iBAAiB,GAAG,IAAI,CAAC,cAAc,EAAE,WAAW,GAAG,oBAAoB,CAAC,GAAG;IACzF,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAA;CACpB,CAAA;AAED,MAAM,WAAW,o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GAAG,IAAI,CAAA;IAC/B,iEAAiE;IACjE,WAAW,EAAE,MAAM,GAAG,IAAI,CAAA;CAC3B;AAED;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IAChC,aAAa,EAAE,aAAa,CAAA;IAC5B,iBAAiB,EAAE,aAAa,CAAA;IAChC,gBAAgB,EAAE,sBAAsB,CAAA;CACzC"}
@@ -1,4 +1,5 @@
1
1
  import type { Picked } from '../picked';
2
+ import type { PickedDataProvider } from '../data-source/provider';
2
3
  import type { ContentBlob, ExperienceContentResponse, ProjectConfig } from '../plugins/dynamic-experiences/types';
3
4
  /** Subset of `Location` fields that can be injected into the selection context. */
4
5
  export interface SerializeLocation {
@@ -43,6 +44,11 @@ export interface SerializeParams {
43
44
  * proceeds (matching the existing null-tolerant path). Defaults to {@link DEFAULT_CONTENT_TIMEOUT_MS}.
44
45
  */
45
46
  timeoutMs?: number;
47
+ /**
48
+ * Data provider used to resolve content, so the server honours the same `mode` contract as the
49
+ * browser. Omit to fetch from the Picked API with the per-fetch timeout above.
50
+ */
51
+ dataProvider?: PickedDataProvider;
46
52
  }
47
53
  /**
48
54
  * Plain-JSON SSR snapshot produced by {@link serialize} and consumed by the client provider.
@@ -52,12 +58,7 @@ export interface PickedSnapshot {
52
58
  versionId: string | null;
53
59
  /** The project config the server selected with (travels for preview parity). */
54
60
  projectConfig: ProjectConfig;
55
- /**
56
- * Deduped content blobs for the selected experiences — the steps' own layout
57
- * content and every entry reached from it through a `reference` field. The
58
- * client provider seeds the whole array into the content registry, so both
59
- * resolve identically on the server render and the first client paint.
60
- */
61
+ /** Deduped content blobs for the selected experiences. */
61
62
  content: ContentBlob[];
62
63
  /** Memoized condition-evaluation results keyed by rule hash. */
63
64
  conditionResults: Record<string, boolean>;
@@ -1 +1 @@
1
- {"version":3,"file":"serialize.d.ts","sourceRoot":"","sources":["../../../src/server/serialize.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAO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zD,aAAa,EAAE,aAAa,CAAA;IAC5B,0DAA0D;IAC1D,UAAU,CAAC,EAAE,mBAAmB,CAAA;IAChC,4EAA4E;IAC5E,UAAU,CAAC,EAAE,mBAAmB,CAAA;IAChC;;;;OAIG;IACH,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB;;;OAGG;IACH,YAAY,CAAC,EAAE,kBAAkB,CAAA;CAClC;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,qFAAqF;IACrF,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;IACxB,gFAAgF;IAChF,aAAa,EAAE,aAAa,CAAA;IAC5B,0DAA0D;IAC1D,OAAO,EAAE,WAAW,EAAE,CAAA;IACtB,gEAAgE;IAChE,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAC1C;AAoCD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAsB,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,cAAc,CAAC,CAgFhG"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@picked/client",
3
- "version": "0.0.1-dev.1785826066660",
3
+ "version": "0.0.1-dev.1785908062293",
4
4
  "dependencies": {
5
5
  "@withease/factories": "^1.0.5"
6
6
  },
@@ -1,98 +0,0 @@
1
- ---
2
- layout: docs
3
- ---
4
-
5
- import { Screenshot } from '../../components/Screenshot'
6
-
7
- # Actions
8
-
9
- An action is a side effect that starts when the flow reaches it. Use an action to
10
- track an event, to send data to an external service, or to call a webhook.
11
-
12
- <Screenshot
13
- route="/{orgSlug}/{projectId}/workspaces/{workspaceId}/actions"
14
- alt="The actions list for a workspace on the Picked dashboard"
15
- />
16
-
17
- ## Create an action
18
-
19
- 1. Open your project.
20
- 2. Click **Actions** in the sidebar.
21
- 3. Click **New Action**.
22
- 4. Enter a name and a key.
23
- 5. Click **Create**.
24
-
25
- The key is a unique identifier for your application. You set it once, and you cannot
26
- change it later.
27
-
28
- ## Set up an action
29
-
30
- **Name**: The name that the dashboard shows. Your visitors do not see it.
31
-
32
- **Key**: The identifier that your application uses for this action. Your visitors do
33
- not see it.
34
-
35
- ## Register in your application
36
-
37
- Register your actions when you create the Picked client. Pass an `actions` object.
38
- Each key in it must match an action key from the dashboard:
39
-
40
- ```typescript
41
- import { createClient } from '@picked/client'
42
-
43
- const picked = createClient({
44
- projectId: 'your-project-id',
45
- actions: {
46
- 'track-signup': () => {
47
- analytics.track('signup_completed')
48
- },
49
- 'notify': (params) => {
50
- sendNotification(params)
51
- },
52
- 'check-eligibility': async () => {
53
- const response = await fetch('/api/eligibility')
54
- // Throw only when the request itself fails. That takes the failure branch.
55
- if (!response.ok) throw new Error('Eligibility request failed')
56
- },
57
- },
58
- })
59
- ```
60
-
61
- Each action is a function. It takes optional parameters and it usually runs a side
62
- effect. When the flow reaches an action node, the SDK calls the function that
63
- matches. The SDK then takes a branch, which depends on whether the function succeeds
64
- or throws. See [Success and failure branches](#success-and-failure-branches).
65
-
66
- See [SDK Actions](/sdk/actions) for more detail.
67
-
68
- ## Use actions in flows
69
-
70
- In the flow builder, drag an action from the entity browser onto the canvas. Connect
71
- it to the point in the flow where you want it to start.
72
-
73
- An action runs when the flow reaches its node. It does not interrupt your visitor. By
74
- default the flow continues to the next connected node.
75
-
76
- ### Success and failure branches
77
-
78
- An action node can have two outgoing branches: **success** and **failure**. The SDK
79
- chooses the branch from the outcome of the action:
80
-
81
- - **Failure** — the action throws, or its promise rejects. The flow takes the failure
82
- branch.
83
- - **Success** — the action resolves to any value: nothing, `true`, `false`, or a
84
- string. A returned `false` is a valid response and not a failure. The flow takes
85
- the success branch.
86
-
87
- Keep the failure branch for a true error. Throw on the failure case, for example
88
- `if (!response.ok) throw new Error(...)`. A valid negative result is _not_ a failure.
89
- An API that returns `200` with `{ serviced: false }` must record that value as a
90
- response. Branch on it with a condition instead of a throw.
91
-
92
- An action node can also have one plain connection, with no success or failure branch.
93
- The flow then continues through it on either outcome.
94
-
95
- ## Reuse actions
96
-
97
- An action is a project-level entity. Use the same action in more than one experience
98
- flow. A change to the options of an action applies at every place that uses it.