@picked/client 0.0.72-next.1 → 0.0.72-next.3
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/dist/.tsbuildinfo +1 -1
- package/dist/{api-B9DDtylO.cjs → api-B4qxWoQN.cjs} +1 -1
- package/dist/{api-BmzHzzpu.js → api-DNvaLWw_.js} +1 -1
- package/dist/cjs/index.js +2 -2
- package/dist/cjs/plugins/dynamic-experiences/index.js +1 -1
- package/dist/cjs/server/index.js +1 -1
- package/dist/docs/explanation/content-references.md +99 -0
- package/dist/docs/explanation/how-picked-works.md +25 -3
- package/dist/docs/explanation/the-content-model.md +38 -28
- package/dist/docs/how-to/create-a-content-entry.md +48 -0
- package/dist/docs/how-to/define-a-page-layout.md +12 -5
- package/dist/docs/how-to/point-one-entry-at-another.md +61 -0
- package/dist/docs/how-to/read-a-referenced-entry.md +111 -0
- package/dist/docs/how-to/reuse-a-section.md +26 -10
- package/dist/docs/index.md +1 -1
- package/dist/docs/reference/dashboard/content/blocks.mdx +57 -0
- package/dist/docs/reference/dashboard/content/content-entries.mdx +61 -10
- package/dist/docs/reference/dashboard/content/models.mdx +108 -0
- package/dist/docs/reference/dashboard/content/pages.mdx +4 -3
- package/dist/docs/reference/dashboard/fields.mdx +1 -1
- package/dist/docs/reference/dashboard/steps.mdx +2 -2
- package/dist/docs/reference/delivery-api/experience-content.md +68 -13
- package/dist/docs/reference/glossary.md +13 -5
- package/dist/docs/reference/management-api/error-handling.md +2 -2
- package/dist/docs/reference/sdk/content.md +216 -0
- package/dist/docs/reference/sdk/plugins/dynamic-experiences.md +51 -3
- package/dist/docs/reference/sdk/ssr/serialize.md +6 -3
- package/dist/docs/reference/tools/vite-plugin.md +90 -8
- package/dist/docs/tutorials/first-api-call.md +1 -1
- package/dist/docs/tutorials/first-server-rendered-page.mdx +1 -1
- package/dist/esm/index.js +484 -429
- package/dist/esm/plugins/dynamic-experiences/index.js +4 -3
- package/dist/esm/server/index.js +43 -46
- package/dist/plugin-DkSWIASL.cjs +1 -0
- package/dist/plugin-DviILBha.js +153 -0
- package/dist/provider-Bskcgd6U.js +68 -0
- package/dist/provider-Bv5nM3So.cjs +1 -0
- package/dist/registry-BMXsAEbZ.cjs +1 -0
- package/dist/registry-DjBZ8upD.js +74 -0
- package/dist/types/data-source/api.d.ts +60 -0
- package/dist/types/data-source/api.d.ts.map +1 -0
- package/dist/types/data-source/provider.d.ts +90 -0
- package/dist/types/data-source/provider.d.ts.map +1 -0
- package/dist/types/data-source/registry.d.ts +26 -0
- package/dist/types/data-source/registry.d.ts.map +1 -0
- package/dist/types/data-source/virtual-data.d.ts +19 -0
- package/dist/types/data-source/virtual-data.d.ts.map +1 -0
- package/dist/types/entities/content/reference.d.ts +101 -0
- package/dist/types/entities/content/reference.d.ts.map +1 -0
- package/dist/types/exports.d.ts +2 -0
- package/dist/types/exports.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/picked.d.ts +65 -1
- package/dist/types/picked.d.ts.map +1 -1
- package/dist/types/plugins/dynamic-experiences/index.d.ts +1 -0
- package/dist/types/plugins/dynamic-experiences/index.d.ts.map +1 -1
- package/dist/types/plugins/dynamic-experiences/plugin.d.ts +9 -40
- package/dist/types/plugins/dynamic-experiences/plugin.d.ts.map +1 -1
- package/dist/types/plugins/dynamic-experiences/types.d.ts +25 -23
- package/dist/types/plugins/dynamic-experiences/types.d.ts.map +1 -1
- package/dist/types/server/index.d.ts +1 -1
- package/dist/types/server/index.d.ts.map +1 -1
- package/dist/types/server/serialize.d.ts +27 -34
- package/dist/types/server/serialize.d.ts.map +1 -1
- package/package.json +3 -3
- package/dist/docs/reference/dashboard/content/layouts.mdx +0 -62
- package/dist/docs/reference/dashboard/content/sections.mdx +0 -28
- package/dist/plugin-CZN0_kqv.js +0 -252
- package/dist/plugin-SFx511s_.cjs +0 -1
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { VirtualPickedData } from '../plugins/dynamic-experiences/types';
|
|
2
|
+
/**
|
|
3
|
+
* Records the bundle the build generated, for this session's data provider to read.
|
|
4
|
+
*
|
|
5
|
+
* A value that fails the shape guard is refused, so a malformed registration lands on the
|
|
6
|
+
* "no bundle" path. Any usable bundle registered earlier is kept.
|
|
7
|
+
*
|
|
8
|
+
* @param {unknown} bundle - The generated module's exports.
|
|
9
|
+
* @returns {void} Nothing.
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* registerPickedBundle({ projectConfig, experienceContent, manifestMetadata })
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
export declare function registerPickedBundle(bundle: unknown): void;
|
|
16
|
+
/**
|
|
17
|
+
* Reads the registered bundle.
|
|
18
|
+
*
|
|
19
|
+
* @returns {VirtualPickedData | null} The bundle, or `null` when nothing has registered one.
|
|
20
|
+
* @example
|
|
21
|
+
* ```typescript
|
|
22
|
+
* const bundle = readRegisteredBundle()
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export declare function readRegisteredBundle(): VirtualPickedData | null;
|
|
26
|
+
//# sourceMappingURL=registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../../src/data-source/registry.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sCAAsC,CAAA;AAK7E;;;;;;;;;;;;GAYG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,OAAO,GAAG,IAAI,CAQ1D;AAED;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,IAAI,iBAAiB,GAAG,IAAI,CAE/D"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file The shape guard for the generated `virtual:picked/data` module.
|
|
3
|
+
*
|
|
4
|
+
* Lives apart from the provider and the registry because both validate against it, and a guard
|
|
5
|
+
* shared by two modules that also reference each other would otherwise close an import cycle.
|
|
6
|
+
*/
|
|
7
|
+
import type { VirtualPickedData } from '../plugins/dynamic-experiences/types';
|
|
8
|
+
/**
|
|
9
|
+
* Runtime type guard that validates the shape of a `virtual:picked/data` module.
|
|
10
|
+
*
|
|
11
|
+
* @param {unknown} value - Candidate module exports.
|
|
12
|
+
* @returns {boolean} Whether `value` matches the {@link VirtualPickedData} shape.
|
|
13
|
+
* @example
|
|
14
|
+
* ```typescript
|
|
15
|
+
* if (isVirtualPickedData(mod)) { useVirtualModule(mod) }
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export declare function isVirtualPickedData(value: unknown): value is VirtualPickedData;
|
|
19
|
+
//# sourceMappingURL=virtual-data.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"virtual-data.d.ts","sourceRoot":"","sources":["../../../src/data-source/virtual-data.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sCAAsC,CAAA;AAE7E;;;;;;;;;GASG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,iBAAiB,CAU9E"}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Reading `reference` field values out of a delivered content blob.
|
|
3
|
+
*
|
|
4
|
+
* A `reference` field arrives as a pointer at another Content record rather than
|
|
5
|
+
* as the record itself. The referenced record travels separately and is
|
|
6
|
+
* registered into the content index under its own id, so resolving a pointer is
|
|
7
|
+
* a registry lookup — see `useReference` (`@picked/react`) and `getReference`
|
|
8
|
+
* (`@picked/svelte`), which is what most consumers should reach for.
|
|
9
|
+
*
|
|
10
|
+
* This module is the framework-agnostic half: readers that turn a raw field
|
|
11
|
+
* value into the id (or ids) to look up, tolerating both a single value and the
|
|
12
|
+
* array a repeatable field delivers, plus the store derivations the framework
|
|
13
|
+
* bindings wrap.
|
|
14
|
+
*/
|
|
15
|
+
import { type Store } from 'effector';
|
|
16
|
+
import type { Content, ContentsStore } from './content';
|
|
17
|
+
/** A pointer at another Content record, as delivered inside a `reference` field. */
|
|
18
|
+
export interface ContentReference {
|
|
19
|
+
/** Id of the referenced Content record, to look up in the content index. */
|
|
20
|
+
contentEntryId: string;
|
|
21
|
+
/** The `key` of the Content Model the target belongs to, or `null` when unresolved. */
|
|
22
|
+
contentModelKey?: string | null;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Narrows an arbitrary field value to a {@link ContentReference}.
|
|
26
|
+
*
|
|
27
|
+
* A pointer that still carries inline `data` matches: the delivery surface emits
|
|
28
|
+
* inline data alongside the separate record while that format is retired, and
|
|
29
|
+
* both shapes address the same record.
|
|
30
|
+
*
|
|
31
|
+
* @param {unknown} value - The raw value read from a content blob's `data`.
|
|
32
|
+
* @returns {boolean} Whether `value` is a reference pointer.
|
|
33
|
+
* @example
|
|
34
|
+
* ```typescript
|
|
35
|
+
* if (isContentReference(content.author)) { content.author.contentEntryId }
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
export declare function isContentReference(value: unknown): value is ContentReference;
|
|
39
|
+
/**
|
|
40
|
+
* Reads the referenced Content record id from a single `reference` field value.
|
|
41
|
+
*
|
|
42
|
+
* @param {unknown} value - The raw value read from a content blob's `data`.
|
|
43
|
+
* @returns {string | null} The referenced id, or `null` when the field is unset or not a reference.
|
|
44
|
+
* @example
|
|
45
|
+
* ```typescript
|
|
46
|
+
* const authorId = readReferenceId(content.author)
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
export declare function readReferenceId(value: unknown): string | null;
|
|
50
|
+
/**
|
|
51
|
+
* Reads every referenced Content record id from a `reference` field, whether it
|
|
52
|
+
* was authored as repeatable or not. Values that are not references are dropped,
|
|
53
|
+
* so the result is always a list of ids that can be looked up.
|
|
54
|
+
*
|
|
55
|
+
* @param {unknown} value - The raw value read from a content blob's `data`.
|
|
56
|
+
* @returns {string[]} The referenced ids, in field order.
|
|
57
|
+
* @example
|
|
58
|
+
* ```typescript
|
|
59
|
+
* const authorIds = readReferenceIds(content.authors)
|
|
60
|
+
* ```
|
|
61
|
+
*/
|
|
62
|
+
export declare function readReferenceIds(value: unknown): string[];
|
|
63
|
+
/**
|
|
64
|
+
* Derives a store resolving a single `reference` field value against the content
|
|
65
|
+
* registry.
|
|
66
|
+
*
|
|
67
|
+
* Reads the registry index rather than a per-id store so an unset field, an
|
|
68
|
+
* unregistered target, and a target registered after first paint all flow
|
|
69
|
+
* through one reactive path. The framework bindings (`useReference`,
|
|
70
|
+
* `getReference`) wrap this; call it directly only outside React and Svelte.
|
|
71
|
+
*
|
|
72
|
+
* @param {ContentsStore} contents - The client's content registry.
|
|
73
|
+
* @param {unknown} value - The raw `reference` value, or an Effector store carrying one. A
|
|
74
|
+
* store keeps the lookup live when the field arrives after this call.
|
|
75
|
+
* @returns {Store<Content | null>} The referenced record, or `null` when the field is unset or its target is not registered.
|
|
76
|
+
* @example
|
|
77
|
+
* ```typescript
|
|
78
|
+
* const author = deriveReference(client.contents, content.author)
|
|
79
|
+
* ```
|
|
80
|
+
*/
|
|
81
|
+
export declare function deriveReference(contents: ContentsStore, value: unknown): Store<Content | null>;
|
|
82
|
+
/**
|
|
83
|
+
* Derives a store resolving a repeatable `reference` field against the content
|
|
84
|
+
* registry, in field order. A single (non-repeatable) value resolves to a
|
|
85
|
+
* one-element list.
|
|
86
|
+
*
|
|
87
|
+
* The list is dense: a pointer whose target is not registered — deleted, cut off
|
|
88
|
+
* by the reference depth cap, or belonging to another workspace — is skipped
|
|
89
|
+
* rather than held as a hole, so consumers can iterate without a null check.
|
|
90
|
+
*
|
|
91
|
+
* @param {ContentsStore} contents - The client's content registry.
|
|
92
|
+
* @param {unknown} value - The raw `reference` value, or an Effector store carrying one. A
|
|
93
|
+
* store keeps the lookup live when the field arrives after this call.
|
|
94
|
+
* @returns {Store<Content[]>} The referenced records that resolved.
|
|
95
|
+
* @example
|
|
96
|
+
* ```typescript
|
|
97
|
+
* const authors = deriveReferences(client.contents, content.authors)
|
|
98
|
+
* ```
|
|
99
|
+
*/
|
|
100
|
+
export declare function deriveReferences(contents: ContentsStore, value: unknown): Store<Content[]>;
|
|
101
|
+
//# sourceMappingURL=reference.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reference.d.ts","sourceRoot":"","sources":["../../../../src/entities/content/reference.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,EAAe,KAAK,KAAK,EAAE,MAAM,UAAU,CAAA;AAClD,OAAO,KAAK,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAA;AAEvD,oFAAoF;AACpF,MAAM,WAAW,gBAAgB;IAC/B,4EAA4E;IAC5E,cAAc,EAAE,MAAM,CAAA;IACtB,uFAAuF;IACvF,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAChC;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,gBAAgB,CAQ5E;AAED;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAE7D;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,EAAE,CAUzD;AAiCD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,aAAa,EAAE,KAAK,EAAE,OAAO,GAAG,KAAK,CAAC,OAAO,GAAG,IAAI,CAAC,CAS9F;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,aAAa,EAAE,KAAK,EAAE,OAAO,GAAG,KAAK,CAAC,OAAO,EAAE,CAAC,CAS1F"}
|
package/dist/types/exports.d.ts
CHANGED
|
@@ -14,6 +14,8 @@ export { evaluateRuleLogic } from './utils/rules-logic';
|
|
|
14
14
|
export { getPickedConfig } from './utils/picked-config';
|
|
15
15
|
export { lazyComponent, isLazyLoader } from './entities/component/lazyComponent';
|
|
16
16
|
export { createPluginEffect } from './entities/plugin/plugin';
|
|
17
|
+
export { deriveReference, deriveReferences, isContentReference, readReferenceId, readReferenceIds, } from './entities/content/reference';
|
|
18
|
+
export type { ContentReference } from './entities/content/reference';
|
|
17
19
|
/**
|
|
18
20
|
* Creates a new Picked client instance and binds it to the window object.
|
|
19
21
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exports.d.ts","sourceRoot":"","sources":["../../src/exports.ts"],"names":[],"mappings":"AAAA,8IAA8I;AAC9I,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAA;AACnD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AAGjC,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC1C,OAAO,EACL,gBAAgB,EAChB,uBAAuB,EACvB,kBAAkB,EAClB,yBAAyB,EACzB,oBAAoB,GACrB,MAAM,2BAA2B,CAAA;AAClC,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAA;AAC3D,YAAY,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAA;AAC9D,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAA;AAC/E,OAAO,EACL,qBAAqB,EACrB,yBAAyB,EACzB,sBAAsB,GACvB,MAAM,6BAA6B,CAAA;AAEpC,cAAc,kBAAkB,CAAA;AAChC,cAAc,iBAAiB,CAAA;AAC/B,mBAAmB,iBAAiB,CAAA;AACpC,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AACvD,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAA;AAChF,OAAO,EAAE,kB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AM,kCAAkC,CAAA"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export type * from './client';
|
|
|
4
4
|
export type * from './entities/action/action';
|
|
5
5
|
export type * from './entities/condition/condition';
|
|
6
6
|
export type * from './entities/content/content';
|
|
7
|
+
export type * from './entities/content/reference';
|
|
7
8
|
export type * from './entities/component/component';
|
|
8
9
|
export type * from './entities/component/lazyComponent';
|
|
9
10
|
export type * from './entities/experience-instance/experience-instance';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,4GAA4G;AAC5G,cAAc,WAAW,CAAA;AACzB,mBAAmB,UAAU,CAAA;AAC7B,mBAAmB,0BAA0B,CAAA;AAC7C,mBAAmB,gCAAgC,CAAA;AACnD,mBAAmB,4BAA4B,CAAA;AAC/C,mBAAmB,gCAAgC,CAAA;AACnD,mBAAmB,oCAAoC,CAAA;AACvD,mBAAmB,oDAAoD,CAAA;AACvE,mBAAmB,kCAAkC,CAAA;AACrD,mBAAmB,sBAAsB,CAAA;AACzC,mBAAmB,4BAA4B,CAAA;AAC/C,mBAAmB,wBAAwB,CAAA;AAC3C,mBAAmB,gCAAgC,CAAA;AACnD,mBAAmB,4BAA4B,CAAA;AAC/C,mBAAmB,0BAA0B,CAAA;AAC7C,mBAAmB,gCAAgC,CAAA;AACnD,mBAAmB,4BAA4B,CAAA;AAC/C,mBAAmB,gBAAgB,CAAA;AACnC,mBAAmB,uBAAuB,CAAA;AAC1C,mBAAmB,8BAA8B,CAAA;AACjD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,4GAA4G;AAC5G,cAAc,WAAW,CAAA;AACzB,mBAAmB,UAAU,CAAA;AAC7B,mBAAmB,0BAA0B,CAAA;AAC7C,mBAAmB,gCAAgC,CAAA;AACnD,mBAAmB,4BAA4B,CAAA;AAC/C,mBAAmB,8BAA8B,CAAA;AACjD,mBAAmB,gCAAgC,CAAA;AACnD,mBAAmB,oCAAoC,CAAA;AACvD,mBAAmB,oDAAoD,CAAA;AACvE,mBAAmB,kCAAkC,CAAA;AACrD,mBAAmB,sBAAsB,CAAA;AACzC,mBAAmB,4BAA4B,CAAA;AAC/C,mBAAmB,wBAAwB,CAAA;AAC3C,mBAAmB,gCAAgC,CAAA;AACnD,mBAAmB,4BAA4B,CAAA;AAC/C,mBAAmB,0BAA0B,CAAA;AAC7C,mBAAmB,gCAAgC,CAAA;AACnD,mBAAmB,4BAA4B,CAAA;AAC/C,mBAAmB,gBAAgB,CAAA;AACnC,mBAAmB,uBAAuB,CAAA;AAC1C,mBAAmB,8BAA8B,CAAA;AACjD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA"}
|
package/dist/types/picked.d.ts
CHANGED
|
@@ -16,7 +16,7 @@ import { type EventBusPayload, type EventHistoryStore } from './utils/events';
|
|
|
16
16
|
import type { Field } from './entities/field/field';
|
|
17
17
|
import type { ExperienceStep } from './entities/step/step';
|
|
18
18
|
import type { Content, ContentDataPatch } from './entities/content/content';
|
|
19
|
-
import type { ContentLoader } from './plugins/dynamic-experiences/types';
|
|
19
|
+
import type { ContentLoader, ExperienceContentResponse, ProjectConfig } from './plugins/dynamic-experiences/types';
|
|
20
20
|
import type { Action } from './entities/action/action';
|
|
21
21
|
import { type Condition } from './entities/condition/condition';
|
|
22
22
|
import type { SessionEntity } from './entities/session/session';
|
|
@@ -44,6 +44,21 @@ export declare class Picked {
|
|
|
44
44
|
* resolvable; remains `null` when the SDK is using the runtime API path.
|
|
45
45
|
*/
|
|
46
46
|
dataSource: PickedDataSource | null;
|
|
47
|
+
/**
|
|
48
|
+
* `versionId` of the SSR snapshot this client was seeded from, set by the framework
|
|
49
|
+
* providers' `seedFromSnapshot`. `null` when no snapshot was seeded — a browser-only client,
|
|
50
|
+
* or a route that rendered without one.
|
|
51
|
+
*/
|
|
52
|
+
seededVersionId: string | null;
|
|
53
|
+
/**
|
|
54
|
+
* Set when a resolved project config disagrees with the seeded snapshot's `versionId`. The
|
|
55
|
+
* snapshot stays authoritative (it is what the server rendered the markup from) and the
|
|
56
|
+
* resolved config is dropped, so this records the divergence rather than hiding it.
|
|
57
|
+
*/
|
|
58
|
+
versionSkew: {
|
|
59
|
+
seeded: string;
|
|
60
|
+
resolved: string;
|
|
61
|
+
} | null;
|
|
47
62
|
/**
|
|
48
63
|
* Content fetcher selected by `dynamicExperiencesPlugin`'s resolution chain. Called
|
|
49
64
|
* by each experience's `prepareExperienceContentFx` (fired in parallel with
|
|
@@ -59,6 +74,7 @@ export declare class Picked {
|
|
|
59
74
|
*/
|
|
60
75
|
previewEmbedderOrigins: string[] | null;
|
|
61
76
|
private readonly plugins;
|
|
77
|
+
private readonly dataProviders;
|
|
62
78
|
readonly eventBus: EventCallable<EventBusPayload>;
|
|
63
79
|
readonly events: EventHistoryStore;
|
|
64
80
|
readonly projectId: string;
|
|
@@ -262,6 +278,54 @@ export declare class Picked {
|
|
|
262
278
|
context?: Record<string, unknown>;
|
|
263
279
|
}, string, Error>;
|
|
264
280
|
constructor(options: CreateClientOptions);
|
|
281
|
+
/**
|
|
282
|
+
* Resolves the data provider backing a given preview token, building it once per token.
|
|
283
|
+
*
|
|
284
|
+
* @param {string | undefined} previewToken - Preview token for the caller, when there is one.
|
|
285
|
+
* @returns {Promise<PickedDataProvider>} The provider for that token.
|
|
286
|
+
* @example
|
|
287
|
+
* const provider = await client.dataProviderFor(undefined)
|
|
288
|
+
*/
|
|
289
|
+
private dataProviderFor;
|
|
290
|
+
/**
|
|
291
|
+
* Resolves this project's configuration.
|
|
292
|
+
*
|
|
293
|
+
* Reads the build-time bundle when one registered itself, and the Picked API otherwise. A
|
|
294
|
+
* preview token forces the API, because preview renders unpublished data no bundle can hold.
|
|
295
|
+
* Deduplicated per token, so several callers in one request cost one resolution.
|
|
296
|
+
*
|
|
297
|
+
* @param {object} [options] - Per-call resolution inputs.
|
|
298
|
+
* @param {string} [options.previewToken] - Preview token, forcing a live read.
|
|
299
|
+
* @param {AbortSignal} [options.signal] - Signal applied to an API read.
|
|
300
|
+
* @returns {Promise<ProjectConfig>} The project configuration.
|
|
301
|
+
* @throws {Error} When the configuration cannot be resolved from any source.
|
|
302
|
+
* @example
|
|
303
|
+
* const config = await client.getProjectConfig()
|
|
304
|
+
*/
|
|
305
|
+
getProjectConfig(options?: {
|
|
306
|
+
previewToken?: string;
|
|
307
|
+
signal?: AbortSignal;
|
|
308
|
+
}): Promise<ProjectConfig>;
|
|
309
|
+
/**
|
|
310
|
+
* Resolves one experience's CMS content, from the same source as the configuration.
|
|
311
|
+
*
|
|
312
|
+
* @param {{ id: string; key: string }} experience - The experience to resolve content for.
|
|
313
|
+
* @param {string} experience.id - Experience id, which keys bundled content.
|
|
314
|
+
* @param {string} experience.key - Experience key, for a content loader that prefers it.
|
|
315
|
+
* @param {object} [options] - Per-call resolution inputs.
|
|
316
|
+
* @param {string} [options.previewToken] - Preview token, forcing a live read.
|
|
317
|
+
* @param {AbortSignal} [options.signal] - Deadline for this call's API read, if it makes one.
|
|
318
|
+
* @returns {Promise<ExperienceContentResponse | null>} The content, or `null` when it has none.
|
|
319
|
+
* @example
|
|
320
|
+
* const content = await client.getExperienceContent({ id: 'exp_1', key: 'promo' })
|
|
321
|
+
*/
|
|
322
|
+
getExperienceContent(experience: {
|
|
323
|
+
id: string;
|
|
324
|
+
key: string;
|
|
325
|
+
}, options?: {
|
|
326
|
+
previewToken?: string;
|
|
327
|
+
signal?: AbortSignal;
|
|
328
|
+
}): Promise<ExperienceContentResponse | null>;
|
|
265
329
|
/**
|
|
266
330
|
* Lazily starts the preview channel when this frame is a live-preview session: the outbound
|
|
267
331
|
* bridge, which reports the frame's URL to the dashboard, and the inbound receiver, which applies
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"picked.d.ts","sourceRoot":"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E/C;IAED,aAAa,UAAW,KAAK,KAAG,IAAI,CAEnC;IAED,YAAY,SAAU,cAAc,KAAG,IAAI,CAE1C;IAED,eAAe,YAAa,OAAO,KAAG,IAAI,CAEzC;IAED;;;;;;;;;;;;;;;;;;OAkBG;IACH,YAAY,OAAQ,MAAM,SAAS,gBAAgB,KAAG,IAAI,CAEzD;IAED,cAAc,QAAS,MAAM,UAAU,MAAM,KAAG,IAAI,CAEnD;IAED,kBAAkB,eAAgB,UAAU,KAAG,IAAI,CAMlD;IAED;;;;;;;;;OASG;IAEH,oBAAoB,iBACJ,MAAM,YACV,uBAAuB,KAChC,OAAO,CAAC,IAAI,CAAC,CAEf;IACD;;;;;;;;;OASG;IAEH,qBAAqB,kBACJ,MAAM,YACX,uBAAuB,KAChC,OAAO,CAAC,IAAI,CAAC,CAEf;IAED;;;;;;;;OAQG;IAEH,kBAAkB,iBAAwB,MAAM,KAAG,OAAO,CAAC,IAAI,CAAC,CAE/D;IAED;;;;;;;;OAQG;IAEH,mBAAmB,kBAAyB,MAAM,KAAG,OAAO,CAAC,IAAI,CAAC,CAEjE;IAED,OAAO,CAAC,YAAY;IAsBpB,OAAO,CAAC,aAAa;IAsCrB,OAAO,CAAC,eAAe;IAgBvB,OAAO,CAAC,YAAY;IAgBpB,OAAO,CAAC,eAAe;IAWvB,eAAe,eAAgB,MAAM,KAAG,iBAAiB,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAE1F;CACF"}
|
|
@@ -1,5 +1,6 @@
|
|
|
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 { registerPickedBundle } from '../../data-source/registry';
|
|
4
5
|
export type * from './types';
|
|
5
6
|
//# 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;
|
|
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;AAIhE,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAA;AACjE,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 {
|
|
3
|
+
import type { 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.
|
|
@@ -24,46 +25,14 @@ export declare function registerProjectConfig(client: Picked, config: ProjectCon
|
|
|
24
25
|
sessionId: string;
|
|
25
26
|
}): void;
|
|
26
27
|
/**
|
|
27
|
-
*
|
|
28
|
+
* Plugin that resolves project configuration through the client and registers features,
|
|
29
|
+
* steps, fields, and experiences with it.
|
|
28
30
|
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
+
* Resolution runs during the `onStart` hook, before experience initialisation, and reads
|
|
32
|
+
* whichever source the client resolves to — the build-time bundle when one registered itself,
|
|
33
|
+
* the Picked API otherwise. Search param feature overrides take precedence over resolved
|
|
34
|
+
* values.
|
|
31
35
|
*
|
|
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
|
-
/**
|
|
60
|
-
* Plugin that fetches project configuration from the Picked REST API and registers
|
|
61
|
-
* features, steps, fields, and experiences with the client.
|
|
62
|
-
*
|
|
63
|
-
* Features are fetched during the `onStart` hook, before experience initialisation.
|
|
64
|
-
* Search param feature overrides take precedence over API-provided values.
|
|
65
|
-
*
|
|
66
|
-
* @param {DynamicExperiencesPluginOptions} [options] - Optional plugin configuration.
|
|
67
36
|
* @returns {Plugin} A configured Picked plugin.
|
|
68
37
|
* @example
|
|
69
38
|
* ```typescript
|
|
@@ -76,5 +45,5 @@ export declare function fetchExperienceContent(apiUrl: string, projectId: string
|
|
|
76
45
|
* })
|
|
77
46
|
* ```
|
|
78
47
|
*/
|
|
79
|
-
export declare function dynamicExperiencesPlugin(
|
|
48
|
+
export declare function dynamicExperiencesPlugin(): Plugin;
|
|
80
49
|
//# sourceMappingURL=plugin.d.ts.map
|
|
@@ -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,
|
|
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;AAG1C,OAAO,KAAK,EAGV,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;AAwMD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,wBAAwB,IAAI,MAAM,CA4DjD"}
|
|
@@ -78,23 +78,6 @@ export interface ProjectConfig {
|
|
|
78
78
|
*/
|
|
79
79
|
previewEmbedderOrigins?: string[];
|
|
80
80
|
}
|
|
81
|
-
export interface DynamicExperiencesPluginOptions {
|
|
82
|
-
apiUrl?: string;
|
|
83
|
-
projectConfig?: ProjectConfig;
|
|
84
|
-
/**
|
|
85
|
-
* Customer-supplied content fetcher. When provided, supersedes both the virtual
|
|
86
|
-
* data module and the runtime API for per-experience content resolution.
|
|
87
|
-
* Customers using this override are responsible for project ↔ content version
|
|
88
|
-
* consistency. Receives the resolved experience and the current preview token
|
|
89
|
-
* (when present) so the customer can decide preview semantics themselves.
|
|
90
|
-
*/
|
|
91
|
-
getContent?: (experience: {
|
|
92
|
-
id: string;
|
|
93
|
-
key: string;
|
|
94
|
-
}, options?: {
|
|
95
|
-
previewToken?: string;
|
|
96
|
-
}) => Promise<ExperienceContentResponse | null>;
|
|
97
|
-
}
|
|
98
81
|
export interface FetchProjectOptions {
|
|
99
82
|
previewToken?: string;
|
|
100
83
|
headers?: Record<string, string>;
|
|
@@ -122,7 +105,17 @@ export interface ContentBlob {
|
|
|
122
105
|
export interface ExperienceContentResponse {
|
|
123
106
|
experienceId: string;
|
|
124
107
|
versionId: string | null;
|
|
108
|
+
/** The Content records the experience's steps point at, via `Step.layoutContentId`. */
|
|
125
109
|
content: ContentBlob[];
|
|
110
|
+
/**
|
|
111
|
+
* Content records reached from `content` through a `reference` field, deduped
|
|
112
|
+
* and excluding the step blobs. Registered into the content registry the same
|
|
113
|
+
* way, so a `{ contentEntryId }` pointer resolves through `contents.getById`.
|
|
114
|
+
*
|
|
115
|
+
* Optional: a response produced before this field existed — notably a build-time
|
|
116
|
+
* cache written by an older `@picked/vite-plugin-picked` — omits it entirely.
|
|
117
|
+
*/
|
|
118
|
+
references?: ContentBlob[];
|
|
126
119
|
}
|
|
127
120
|
/**
|
|
128
121
|
* Function that resolves an experience's content blobs. Set on the Picked client by
|
|
@@ -136,6 +129,20 @@ export type ContentLoader = (experience: {
|
|
|
136
129
|
}, options?: {
|
|
137
130
|
previewToken?: string;
|
|
138
131
|
}) => Promise<ExperienceContentResponse | null>;
|
|
132
|
+
/**
|
|
133
|
+
* Provenance the virtual data module records about the snapshot it carries: which build
|
|
134
|
+
* flavour produced it, when, and which workspace version it was taken from.
|
|
135
|
+
*/
|
|
136
|
+
export interface PickedManifestMetadata {
|
|
137
|
+
/** `'build'` when build-mode prefetch JSON was used, `'dev'` when the dev-mode fetch was. */
|
|
138
|
+
mode: 'dev' | 'build';
|
|
139
|
+
/** ISO 8601 timestamp from the manifest. `null` in dev mode, where no manifest is written. */
|
|
140
|
+
fetchedAt: string | null;
|
|
141
|
+
/** The `versionId` the snapshot was taken from, when known. */
|
|
142
|
+
projectVersionId: string | null;
|
|
143
|
+
/** The `workspaceId` the snapshot was taken from, when known. */
|
|
144
|
+
workspaceId: string | null;
|
|
145
|
+
}
|
|
139
146
|
/**
|
|
140
147
|
* Optional-fields surface of the virtual data module exposed by `@picked/vite-plugin-picked`.
|
|
141
148
|
* The shape is identical between dev (`vite serve`) and build (`vite build`) modes.
|
|
@@ -143,11 +150,6 @@ export type ContentLoader = (experience: {
|
|
|
143
150
|
export interface VirtualPickedData {
|
|
144
151
|
projectConfig: ProjectConfig;
|
|
145
152
|
experienceContent: ContentLoader;
|
|
146
|
-
manifestMetadata:
|
|
147
|
-
mode: 'dev' | 'build';
|
|
148
|
-
fetchedAt: string | null;
|
|
149
|
-
projectVersionId: string | null;
|
|
150
|
-
workspaceId: string | null;
|
|
151
|
-
};
|
|
153
|
+
manifestMetadata: PickedManifestMetadata;
|
|
152
154
|
}
|
|
153
155
|
//# 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,OA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AAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAA;IACV,0FAA0F;IAC1F,eAAe,EAAE,MAAM,GAAG,IAAI,CAAA;IAC9B,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAC9B;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,yBAAyB;IACxC,YAAY,EAAE,MAAM,CAAA;IACpB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;IACxB,uFAAuF;IACvF,OAAO,EAAE,WAAW,EAAE,CAAA;IACtB;;;;;;;OAOG;IACH,UAAU,CAAC,EAAE,WAAW,EAAE,CAAA;CAC3B;AAED;;;;;GAKG;AACH,MAAM,MAAM,aAAa,GAAG,CAC1B,UAAU,EAAE;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,EACvC,OAAO,CAAC,EAAE;IAAE,YAAY,CAAC,EAAE,MAAM,CAAA;CAAE,KAChC,OAAO,CAAC,yBAAyB,GAAG,IAAI,CAAC,CAAA;AAE9C;;;GAGG;AACH,MAAM,WAAW,sBAAsB;IACrC,6FAA6F;IAC7F,IAAI,EAAE,KAAK,GAAG,OAAO,CAAA;IACrB,8FAA8F;IAC9F,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;IACxB,+DAA+D;IAC/D,gBAAgB,EAAE,MAAM,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,7 +1,7 @@
|
|
|
1
1
|
import type { Picked } from '../picked';
|
|
2
2
|
import type { ExperienceInstance } from '../entities/experience-instance/experience-instance';
|
|
3
3
|
import type { AdaptedComponent } from '../entities/component/component';
|
|
4
|
-
export { serialize, type PickedSnapshot, type SerializeParams, type SerializeAttributes, type SerializeLocation,
|
|
4
|
+
export { serialize, type PickedSnapshot, type SerializeParams, type SerializeAttributes, type SerializeLocation, } from './serialize';
|
|
5
5
|
export { createExperienceInstance } from '../entities/experience-instance/experience-instance';
|
|
6
6
|
export type { ExperienceInstance } from '../entities/experience-instance/experience-instance';
|
|
7
7
|
export { registerProjectConfig } from '../plugins/dynamic-experiences/plugin';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/server/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AACvC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qDAAqD,CAAA;AAE7F,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAA;AAEvE,OAAO,EACL,SAAS,EACT,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,mBAAmB,EACxB,KAAK,iBAAiB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/server/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AACvC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qDAAqD,CAAA;AAE7F,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAA;AAEvE,OAAO,EACL,SAAS,EACT,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,mBAAmB,EACxB,KAAK,iBAAiB,GACvB,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE,wBAAwB,EAAE,MAAM,qDAAqD,CAAA;AAC9F,YAAY,EAAE,kBAAkB,EAAE,MAAM,qDAAqD,CAAA;AAC7F,OAAO,EAAE,qBAAqB,EAAE,MAAM,uCAAuC,CAAA;AAC7E,OAAO,EACL,QAAQ,EACR,qBAAqB,EACrB,kBAAkB,EAClB,oBAAoB,EACpB,wBAAwB,GACzB,MAAM,kCAAkC,CAAA;AACzC,YAAY,EACV,WAAW,EACX,aAAa,EACb,uBAAuB,EACvB,yBAAyB,GAC1B,MAAM,sCAAsC,CAAA;AA0B7C,MAAM,WAAW,QAAQ,CAAC,CAAC,GAAG,gBAAgB,CAAC,MAAM,EAAE,OAAO,CAAC;IAC7D,gBAAgB,EAAE,CAAC,SAAS,EAAE,gBAAgB,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,OAAO,CAAA;IAC3E,MAAM,EAAE,CACN,SAAS,EAAE,CAAC,EACZ,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,kBAAkB,KAC3B,OAAO,CAAC;QACX,IAAI,EAAE,MAAM,CAAA;QACZ,IAAI,EAAE,MAAM,CAAA;KACb,CAAC,CAAA;CACH;AAmBD;;;;;;;;GAQG;AACH,wBAAgB,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAoJ/E"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Picked } from '../picked';
|
|
2
|
-
import type { ContentBlob,
|
|
2
|
+
import type { ContentBlob, ProjectConfig } from '../plugins/dynamic-experiences/types';
|
|
3
3
|
/** Subset of `Location` fields that can be injected into the selection context. */
|
|
4
4
|
export interface SerializeLocation {
|
|
5
5
|
href: string;
|
|
@@ -16,31 +16,19 @@ export interface SerializeLocation {
|
|
|
16
16
|
export interface SerializeAttributes {
|
|
17
17
|
location?: Partial<SerializeLocation>;
|
|
18
18
|
}
|
|
19
|
-
/** Customer-supplied content fetcher used in place of the runtime API during serialization. */
|
|
20
|
-
export type SerializeGetContent = (experience: {
|
|
21
|
-
id: string;
|
|
22
|
-
key: string;
|
|
23
|
-
}, options?: {
|
|
24
|
-
previewToken?: string;
|
|
25
|
-
}) => Promise<ExperienceContentResponse | null>;
|
|
26
19
|
/** Parameters for {@link serialize}. */
|
|
27
20
|
export interface SerializeParams {
|
|
28
|
-
/** The project config to register and select against. */
|
|
29
|
-
projectConfig: ProjectConfig;
|
|
30
21
|
/** URL attributes injected into the selection context. */
|
|
31
22
|
attributes?: SerializeAttributes;
|
|
32
|
-
/** Optional content fetcher; falls back to the runtime API when omitted. */
|
|
33
|
-
getContent?: SerializeGetContent;
|
|
34
23
|
/**
|
|
35
|
-
* Preview token
|
|
36
|
-
* preview
|
|
37
|
-
* so the token cannot be recovered otherwise.
|
|
24
|
+
* Preview token for this request, so preview (unpublished) config and content resolve during
|
|
25
|
+
* preview SSR. The server has no `searchParams`, so the token cannot be recovered otherwise.
|
|
38
26
|
*/
|
|
39
27
|
previewToken?: string;
|
|
40
28
|
/**
|
|
41
|
-
* Per-content-fetch timeout in milliseconds for the
|
|
42
|
-
*
|
|
43
|
-
*
|
|
29
|
+
* Per-content-fetch timeout in milliseconds for the API path, so a slow or hung upstream cannot
|
|
30
|
+
* stall the SSR render indefinitely. On timeout the blob is skipped and the render proceeds.
|
|
31
|
+
* Defaults to {@link DEFAULT_CONTENT_TIMEOUT_MS}.
|
|
44
32
|
*/
|
|
45
33
|
timeoutMs?: number;
|
|
46
34
|
}
|
|
@@ -52,33 +40,38 @@ export interface PickedSnapshot {
|
|
|
52
40
|
versionId: string | null;
|
|
53
41
|
/** The project config the server selected with (travels for preview parity). */
|
|
54
42
|
projectConfig: ProjectConfig;
|
|
55
|
-
/**
|
|
43
|
+
/**
|
|
44
|
+
* Deduped content blobs for the selected experiences — the steps' own layout
|
|
45
|
+
* content and every entry reached from it through a `reference` field. The
|
|
46
|
+
* client provider seeds the whole array into the content registry, so both
|
|
47
|
+
* resolve identically on the server render and the first client paint.
|
|
48
|
+
*/
|
|
56
49
|
content: ContentBlob[];
|
|
57
50
|
/** Memoized condition-evaluation results keyed by rule hash. */
|
|
58
51
|
conditionResults: Record<string, boolean>;
|
|
59
52
|
}
|
|
60
53
|
/**
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
*
|
|
54
|
+
* Selects the experiences whose conditions pass for a URL and returns a plain-JSON snapshot for
|
|
55
|
+
* SSR hydration.
|
|
56
|
+
*
|
|
57
|
+
* Config and content both resolve through the client, which keeps them on one source: a bundled
|
|
58
|
+
* render cannot pair a bundled config with API-fetched content from a newer publish. Content is
|
|
59
|
+
* deduped by blob id, and each API read carries a deadline so a slow upstream cannot stall the
|
|
60
|
+
* render.
|
|
64
61
|
*
|
|
65
|
-
* Registration is synchronous (no `client.start()`), so the client's stores are populated
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
* condition
|
|
70
|
-
* precondition/condition are not evaluated here in v1. Content is fetched via the `getContent`
|
|
71
|
-
* override when provided, otherwise via the runtime API (with `previewToken` forwarded and a
|
|
72
|
-
* per-fetch timeout so a slow upstream cannot stall the render), and deduped by blob id.
|
|
62
|
+
* Registration is synchronous (no `client.start()`), so the client's stores are populated before
|
|
63
|
+
* selection. The condition-results store is reset at entry, and `serialize` expects a per-request
|
|
64
|
+
* client — concurrent calls on one client are not supported. Each experience's own condition is
|
|
65
|
+
* evaluated through the memoized evaluator against the injected URL; client-level
|
|
66
|
+
* precondition/condition are not evaluated here in v1.
|
|
73
67
|
*
|
|
74
|
-
* @param {Picked} client - The Picked client to
|
|
75
|
-
* @param {SerializeParams} params -
|
|
68
|
+
* @param {Picked} client - The Picked client to select with, and to resolve data through.
|
|
69
|
+
* @param {SerializeParams} [params] - URL attributes, preview token, and content timeout.
|
|
76
70
|
* @returns {Promise<PickedSnapshot>} The plain-JSON snapshot of config, content, and condition results.
|
|
77
71
|
* @example
|
|
78
72
|
* const snapshot = await serialize(client, {
|
|
79
|
-
* projectConfig,
|
|
80
73
|
* attributes: { location: { pathname: '/promo' } },
|
|
81
74
|
* })
|
|
82
75
|
*/
|
|
83
|
-
export declare function serialize(client: Picked, params
|
|
76
|
+
export declare function serialize(client: Picked, params?: SerializeParams): Promise<PickedSnapshot>;
|
|
84
77
|
//# sourceMappingURL=serialize.d.ts.map
|
|
@@ -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;
|
|
1
|
+
{"version":3,"file":"serialize.d.ts","sourceRoot":"","sources":["../../../src/server/serialize.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAIvC,OAAO,KAAK,EACV,WAAW,EACX,aAAa,EAEd,MAAM,sCAAsC,CAAA;AAE7C,mFAAmF;AACnF,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,MAAM,CAAA;IAChB,MAAM,EAAE,MAAM,CAAA;IACd,QAAQ,EAAE,MAAM,CAAA;IAChB,MAAM,EAAE,MAAM,CAAA;IACd,QAAQ,EAAE,MAAM,CAAA;IAChB,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;CACb;AAED,mFAAmF;AACnF,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,EAAE,OAAO,CAAC,iBAAiB,CAAC,CAAA;CACtC;AAKD,wCAAwC;AACxC,MAAM,WAAW,eAAe;IAC9B,0DAA0D;IAC1D,UAAU,CAAC,EAAE,mBAAmB,CAAA;IAChC;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,qFAAqF;IACrF,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;IACxB,gFAAgF;IAChF,aAAa,EAAE,aAAa,CAAA;IAC5B;;;;;OAKG;IACH,OAAO,EAAE,WAAW,EAAE,CAAA;IACtB,gEAAgE;IAChE,gBAAgB,E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