@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.
- package/dist/.tsbuildinfo +1 -1
- package/dist/api-C8B96Kwv.js +22 -0
- package/dist/api-DS7fA9kj.cjs +1 -0
- 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/authenticate-the-cli.md +95 -0
- 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/install-the-sdk.md +7 -0
- 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/how-to/switch-workspaces.md +123 -0
- 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/delivery-api/workspace-schema.md +74 -0
- 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/sdk/type-generation.md +130 -0
- package/dist/docs/reference/tools/cli.md +141 -0
- 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 +496 -432
- package/dist/esm/plugins/dynamic-experiences/index.js +5 -3
- package/dist/esm/server/index.js +43 -46
- package/dist/plugin-C8hWW3ed.js +157 -0
- package/dist/plugin-Dtg2sOad.cjs +1 -0
- package/dist/provider-BEpRDCyr.js +69 -0
- package/dist/provider-ixdOyYTA.cjs +1 -0
- package/dist/registry-C1t8l3t9.cjs +1 -0
- package/dist/registry-CXZv0uLg.js +18 -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/entities/response/response.d.ts +22 -6
- package/dist/types/entities/response/response.d.ts.map +1 -1
- package/dist/types/exports.d.ts +2 -0
- package/dist/types/exports.d.ts.map +1 -1
- package/dist/types/form/create-submit-pipeline.d.ts +32 -3
- package/dist/types/form/create-submit-pipeline.d.ts.map +1 -1
- package/dist/types/index.d.ts +3 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/picked.d.ts +68 -4
- package/dist/types/picked.d.ts.map +1 -1
- package/dist/types/ping.d.ts +4 -3
- package/dist/types/ping.d.ts.map +1 -1
- package/dist/types/plugins/dynamic-experiences/index.d.ts +2 -1
- 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 +22 -129
- package/dist/types/plugins/dynamic-experiences/types.d.ts.map +1 -1
- package/dist/types/schema-registry.d.ts +190 -0
- package/dist/types/schema-registry.d.ts.map +1 -0
- package/dist/types/server/index.d.ts +2 -2
- package/dist/types/server/index.d.ts.map +1 -1
- package/dist/types/server/serialize.d.ts +37 -34
- package/dist/types/server/serialize.d.ts.map +1 -1
- package/dist/types/typed-content.d.ts +17 -0
- package/dist/types/typed-content.d.ts.map +1 -0
- package/dist/types/utils/picked-config.d.ts +19 -1
- package/dist/types/utils/picked-config.d.ts.map +1 -1
- package/dist/version-BLzNWQ-j.cjs +1 -0
- package/dist/version-IAAIvoH9.js +4 -0
- package/package.json +5 -3
- package/dist/api-BzK4kXRt.js +0 -38
- package/dist/api-CgENjKwJ.cjs +0 -1
- package/dist/docs/reference/dashboard/content/layouts.mdx +0 -62
- package/dist/docs/reference/dashboard/content/sections.mdx +0 -28
- package/dist/plugin-DJjtc5df.js +0 -252
- package/dist/plugin-jHxSAqGG.cjs +0 -1
- package/dist/types/utils/api.d.ts +0 -25
- package/dist/types/utils/api.d.ts.map +0 -1
- package/dist/types/utils/client-headers.d.ts +0 -2
- package/dist/types/utils/client-headers.d.ts.map +0 -1
|
@@ -1,129 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @file
|
|
3
|
-
*/
|
|
4
|
-
import type { ExperienceStep } from '../../entities/step/step';
|
|
5
|
-
import type { Field } from '../../entities/field/field';
|
|
6
|
-
import type { ExperienceEdge, ExperienceNode, ExperienceTarget } from '../../entities/experience/experience';
|
|
7
|
-
import type { Condition } from '../../entities/condition/condition';
|
|
8
|
-
import type { LogicRule, LogicValue } from '../../logic-engine';
|
|
9
|
-
/**
|
|
10
|
-
* Wire-format step as returned by the Picked API. Matches {@link ExperienceStep}
|
|
11
|
-
* except that fields are still referenced by ID — the plugin resolves them to
|
|
12
|
-
* keys against `ProjectConfig.fields` at registration time.
|
|
13
|
-
*
|
|
14
|
-
* `fieldIds` is optional: layout-only steps (driven purely by `layoutName`) omit it.
|
|
15
|
-
*
|
|
16
|
-
* `layoutContentId` is the wire-format reference to a CMS Content record. The actual
|
|
17
|
-
* content blob is delivered by `dynamicExperiencesPlugin`'s content resolution chain
|
|
18
|
-
* (virtual data module, preview-token API fetch, or direct API fetch) and registered
|
|
19
|
-
* via `client.registerContent`. Steps' derived `layoutContentStore` resolves reactively
|
|
20
|
-
* against the registry at render time.
|
|
21
|
-
*/
|
|
22
|
-
export type ApiExperienceStep = Omit<ExperienceStep, 'fieldKeys' | 'layoutContentStore'> & {
|
|
23
|
-
fieldIds?: string[];
|
|
24
|
-
};
|
|
25
|
-
export interface ProjectConfigFeature {
|
|
26
|
-
id: string;
|
|
27
|
-
name: string;
|
|
28
|
-
enabled: boolean;
|
|
29
|
-
weight: number;
|
|
30
|
-
version: number;
|
|
31
|
-
}
|
|
32
|
-
export type ProjectConfigNode = ExperienceNode;
|
|
33
|
-
/**
|
|
34
|
-
* An experience payload as returned by the API.
|
|
35
|
-
* Steps are referenced by ID only; the full step definitions live in the
|
|
36
|
-
* top-level `steps` array of ProjectConfig.
|
|
37
|
-
* Conditions are referenced by nodes via `conditionId`; the full condition
|
|
38
|
-
* definitions live in the top-level `conditions` array of ProjectConfig.
|
|
39
|
-
*/
|
|
40
|
-
export interface ProjectConfigExperience {
|
|
41
|
-
id: string;
|
|
42
|
-
key: string;
|
|
43
|
-
name: string;
|
|
44
|
-
componentName: string;
|
|
45
|
-
nodes: ProjectConfigNode[];
|
|
46
|
-
edges: ExperienceEdge[];
|
|
47
|
-
/** Decision logic that controls whether this experience is initialised. */
|
|
48
|
-
condition: LogicRule | LogicValue;
|
|
49
|
-
/** Logic that controls the initial open state of the experience. */
|
|
50
|
-
initializeOpen: LogicRule | LogicValue;
|
|
51
|
-
/** DOM targets this experience mounts into. */
|
|
52
|
-
targets: ExperienceTarget[];
|
|
53
|
-
}
|
|
54
|
-
export interface ProjectConfig {
|
|
55
|
-
id: string;
|
|
56
|
-
name: string;
|
|
57
|
-
status: string;
|
|
58
|
-
versionId: string;
|
|
59
|
-
workspaceId: string;
|
|
60
|
-
features: ProjectConfigFeature[];
|
|
61
|
-
/** Experience definitions with steps and conditions referenced by ID. */
|
|
62
|
-
experiences: ProjectConfigExperience[];
|
|
63
|
-
/** Global step definitions shared across experiences. */
|
|
64
|
-
steps: ApiExperienceStep[];
|
|
65
|
-
/** Global field definitions shared across steps. */
|
|
66
|
-
fields: Field[];
|
|
67
|
-
/** Global condition definitions referenced by experience flow nodes. */
|
|
68
|
-
conditions: Condition[];
|
|
69
|
-
actions: Array<{
|
|
70
|
-
id: string;
|
|
71
|
-
name: string;
|
|
72
|
-
key: string;
|
|
73
|
-
}>;
|
|
74
|
-
/**
|
|
75
|
-
* Origins permitted to push live-preview content patches into this page, issued by the API on the
|
|
76
|
-
* preview surface only. The preview receiver validates every inbound message against this list;
|
|
77
|
-
* absent or empty means no embedder is trusted and the channel stays closed.
|
|
78
|
-
*/
|
|
79
|
-
previewEmbedderOrigins?: string[];
|
|
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
|
-
export interface FetchProjectOptions {
|
|
99
|
-
previewToken?: string;
|
|
100
|
-
headers?: Record<string, string>;
|
|
101
|
-
/** Abort signal applied to the underlying `fetch` (for example an `AbortSignal.timeout` deadline). */
|
|
102
|
-
signal?: AbortSignal;
|
|
103
|
-
}
|
|
104
|
-
/**
|
|
105
|
-
* Wire-format content blob as returned by the Picked API content endpoint.
|
|
106
|
-
*/
|
|
107
|
-
export interface ContentBlob {
|
|
108
|
-
id: string;
|
|
109
|
-
/** The `key` of the Content Model that produced this entry, or `null` when unresolved. */
|
|
110
|
-
contentModelKey: string | null;
|
|
111
|
-
data: Record<string, unknown>;
|
|
112
|
-
}
|
|
113
|
-
/**
|
|
114
|
-
* Wire-format response shape for `GET /api/v1/projects/:projectId/experiences/:experienceId/content`.
|
|
115
|
-
* The response is agnostic of step structure — step ↔ content mapping is encoded in the
|
|
116
|
-
* project blob via `Step.layoutContentId`.
|
|
2
|
+
* @file Plugin-specific types for the dynamic-experiences plugin.
|
|
117
3
|
*
|
|
118
|
-
*
|
|
119
|
-
*
|
|
120
|
-
*
|
|
4
|
+
* The wire-format shapes the Delivery API returns live in `@picked/delivery-api-client`,
|
|
5
|
+
* which stays runtime-agnostic. This file re-exports them under the names the SDK uses and
|
|
6
|
+
* adds the types that only mean something inside the client: the content loader and the
|
|
7
|
+
* virtual data module `@picked/vite-plugin-picked` generates.
|
|
121
8
|
*/
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
versionId: string | null;
|
|
125
|
-
content: ContentBlob[];
|
|
126
|
-
}
|
|
9
|
+
import type { ExperienceContentResponse, ProjectConfig } from '@picked/delivery-api-client';
|
|
10
|
+
export type { ApiExperienceStep, ContentBlob, ExperienceContentResponse, FetchProjectOptions, ProjectConfig, ProjectConfigExperience, ProjectConfigFeature, ProjectConfigNode, } from '@picked/delivery-api-client';
|
|
127
11
|
/**
|
|
128
12
|
* Function that resolves an experience's content blobs. Set on the Picked client by
|
|
129
13
|
* `dynamicExperiencesPlugin` (selecting from virtual module, getContent override, or API)
|
|
@@ -136,6 +20,20 @@ export type ContentLoader = (experience: {
|
|
|
136
20
|
}, options?: {
|
|
137
21
|
previewToken?: string;
|
|
138
22
|
}) => Promise<ExperienceContentResponse | null>;
|
|
23
|
+
/**
|
|
24
|
+
* Provenance the virtual data module records about the snapshot it carries: which build
|
|
25
|
+
* flavour produced it, when, and which workspace version it was taken from.
|
|
26
|
+
*/
|
|
27
|
+
export interface PickedManifestMetadata {
|
|
28
|
+
/** `'build'` when build-mode prefetch JSON was used, `'dev'` when the dev-mode fetch was. */
|
|
29
|
+
mode: 'dev' | 'build';
|
|
30
|
+
/** ISO 8601 timestamp from the manifest. `null` in dev mode, where no manifest is written. */
|
|
31
|
+
fetchedAt: string | null;
|
|
32
|
+
/** The `versionId` the snapshot was taken from, when known. */
|
|
33
|
+
projectVersionId: string | null;
|
|
34
|
+
/** The `workspaceId` the snapshot was taken from, when known. */
|
|
35
|
+
workspaceId: string | null;
|
|
36
|
+
}
|
|
139
37
|
/**
|
|
140
38
|
* Optional-fields surface of the virtual data module exposed by `@picked/vite-plugin-picked`.
|
|
141
39
|
* The shape is identical between dev (`vite serve`) and build (`vite build`) modes.
|
|
@@ -143,11 +41,6 @@ export type ContentLoader = (experience: {
|
|
|
143
41
|
export interface VirtualPickedData {
|
|
144
42
|
projectConfig: ProjectConfig;
|
|
145
43
|
experienceContent: ContentLoader;
|
|
146
|
-
manifestMetadata:
|
|
147
|
-
mode: 'dev' | 'build';
|
|
148
|
-
fetchedAt: string | null;
|
|
149
|
-
projectVersionId: string | null;
|
|
150
|
-
workspaceId: string | null;
|
|
151
|
-
};
|
|
44
|
+
manifestMetadata: PickedManifestMetadata;
|
|
152
45
|
}
|
|
153
46
|
//# 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
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/plugins/dynamic-experiences/types.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,KAAK,EAAE,yBAAyB,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAA;AAE3F,YAAY,EACV,iBAAiB,EACjB,WAAW,EACX,yBAAyB,EACzB,mBAAmB,EACnB,aAAa,EACb,uBAAuB,EACvB,oBAAoB,EACpB,iBAAiB,GAClB,MAAM,6BAA6B,CAAA;AAEpC;;;;;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"}
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
/** @file Schema registry types augmented by generated `picked-env.d.ts`. */
|
|
2
|
+
import type { Content } from './entities/content/content';
|
|
3
|
+
import type { FieldValue as ResponseFieldValue } from './entities/field/field';
|
|
4
|
+
/**
|
|
5
|
+
* Augmented by generated `picked-env.d.ts`. Empty by default.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* // After codegen:
|
|
9
|
+
* // interface PickedSchemaRegistry {
|
|
10
|
+
* // contentModels: { 'welcome-page': WelcomePageContent }
|
|
11
|
+
* // }
|
|
12
|
+
*/
|
|
13
|
+
export interface PickedSchemaRegistry {
|
|
14
|
+
}
|
|
15
|
+
type ContentModelsMap = PickedSchemaRegistry extends {
|
|
16
|
+
contentModels: infer M extends Record<string, unknown>;
|
|
17
|
+
} ? M : Record<string, Record<string, unknown>>;
|
|
18
|
+
type StepContentModelsMap = PickedSchemaRegistry extends {
|
|
19
|
+
stepContentModels: infer S extends Record<string, string>;
|
|
20
|
+
} ? S : Record<string, string>;
|
|
21
|
+
type StepFieldKeysMap = PickedSchemaRegistry extends {
|
|
22
|
+
stepFieldKeys: infer S extends Record<string, string>;
|
|
23
|
+
} ? S : Record<string, string>;
|
|
24
|
+
type FieldValuesMap = PickedSchemaRegistry extends {
|
|
25
|
+
fieldValues: infer F extends Record<string, unknown>;
|
|
26
|
+
} ? F : never;
|
|
27
|
+
/**
|
|
28
|
+
* Widens a key union so it still accepts a key the workspace does not declare.
|
|
29
|
+
*
|
|
30
|
+
* Features, actions, fields, steps and experiences can all be defined in the application
|
|
31
|
+
* rather than the workspace — `createClient({ features })` and `client.registerField()`
|
|
32
|
+
* among them — and those keys are absent from the generated schema. Intersecting with an
|
|
33
|
+
* object type keeps TypeScript from collapsing `K | string` down to `string`, so an editor
|
|
34
|
+
* still suggests the workspace's keys while any other string is accepted.
|
|
35
|
+
*
|
|
36
|
+
* The `Known*` union beside each key type stays closed, for a caller that wants only what
|
|
37
|
+
* the workspace declares.
|
|
38
|
+
*/
|
|
39
|
+
type AnyString = string & Record<never, never>;
|
|
40
|
+
/**
|
|
41
|
+
* Feature keys the workspace declares. Closed: a locally-defined feature is not in it.
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* type Keys = KnownFeatureKeys
|
|
45
|
+
*/
|
|
46
|
+
export type KnownFeatureKeys = PickedSchemaRegistry extends {
|
|
47
|
+
featureKeys: infer K extends string;
|
|
48
|
+
} ? K : string;
|
|
49
|
+
/**
|
|
50
|
+
* Feature keys — the workspace union when augmented, plus any locally-defined key.
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* type Keys = FeatureKeys
|
|
54
|
+
*/
|
|
55
|
+
export type FeatureKeys = PickedSchemaRegistry extends {
|
|
56
|
+
featureKeys: infer K extends string;
|
|
57
|
+
} ? K | AnyString : string;
|
|
58
|
+
/**
|
|
59
|
+
* Step keys the workspace declares. Closed: a locally-registered step is not in it.
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* type Keys = KnownStepKeys
|
|
63
|
+
*/
|
|
64
|
+
export type KnownStepKeys = PickedSchemaRegistry extends {
|
|
65
|
+
stepKeys: infer K extends string;
|
|
66
|
+
} ? K : string;
|
|
67
|
+
/**
|
|
68
|
+
* Step keys — the workspace union when augmented, plus any locally-registered key.
|
|
69
|
+
*
|
|
70
|
+
* @example
|
|
71
|
+
* type Keys = StepKeys
|
|
72
|
+
*/
|
|
73
|
+
export type StepKeys = PickedSchemaRegistry extends {
|
|
74
|
+
stepKeys: infer K extends string;
|
|
75
|
+
} ? K | AnyString : string;
|
|
76
|
+
/**
|
|
77
|
+
* Action keys the workspace declares. Closed: an action the app registers on its own is
|
|
78
|
+
* not in it.
|
|
79
|
+
*
|
|
80
|
+
* @example
|
|
81
|
+
* type Keys = KnownActionKeys
|
|
82
|
+
*/
|
|
83
|
+
export type KnownActionKeys = PickedSchemaRegistry extends {
|
|
84
|
+
actionKeys: infer K extends string;
|
|
85
|
+
} ? K : string;
|
|
86
|
+
/**
|
|
87
|
+
* Action keys — the workspace union when augmented, plus any key the app registers.
|
|
88
|
+
*
|
|
89
|
+
* @example
|
|
90
|
+
* type Keys = ActionKeys
|
|
91
|
+
*/
|
|
92
|
+
export type ActionKeys = PickedSchemaRegistry extends {
|
|
93
|
+
actionKeys: infer K extends string;
|
|
94
|
+
} ? K | AnyString : string;
|
|
95
|
+
/**
|
|
96
|
+
* Experience keys the workspace declares. Closed: a locally-registered experience is not
|
|
97
|
+
* in it.
|
|
98
|
+
*
|
|
99
|
+
* @example
|
|
100
|
+
* type Keys = KnownExperienceKeys
|
|
101
|
+
*/
|
|
102
|
+
export type KnownExperienceKeys = PickedSchemaRegistry extends {
|
|
103
|
+
experienceKeys: infer K extends string;
|
|
104
|
+
} ? K : string;
|
|
105
|
+
/**
|
|
106
|
+
* Experience keys — the workspace union when augmented, plus any locally-registered key.
|
|
107
|
+
*
|
|
108
|
+
* @example
|
|
109
|
+
* type Keys = ExperienceKeys
|
|
110
|
+
*/
|
|
111
|
+
export type ExperienceKeys = PickedSchemaRegistry extends {
|
|
112
|
+
experienceKeys: infer K extends string;
|
|
113
|
+
} ? K | AnyString : string;
|
|
114
|
+
/**
|
|
115
|
+
* Field keys the workspace declares. Closed: a locally-registered field is not in it.
|
|
116
|
+
*
|
|
117
|
+
* @example
|
|
118
|
+
* type Keys = KnownFieldKeys
|
|
119
|
+
*/
|
|
120
|
+
export type KnownFieldKeys = FieldValuesMap extends never ? string : keyof FieldValuesMap & string;
|
|
121
|
+
/**
|
|
122
|
+
* Field keys — the workspace union when augmented, plus any locally-registered key.
|
|
123
|
+
*
|
|
124
|
+
* A key outside the workspace reads as the general {@link FieldValueFor} value type, which
|
|
125
|
+
* is how every value resolver here already treats one.
|
|
126
|
+
*
|
|
127
|
+
* @example
|
|
128
|
+
* type Keys = FieldKeys
|
|
129
|
+
*/
|
|
130
|
+
export type FieldKeys = FieldValuesMap extends never ? string : KnownFieldKeys | AnyString;
|
|
131
|
+
/**
|
|
132
|
+
* Union of every content model bound to a step layout.
|
|
133
|
+
*
|
|
134
|
+
* @example
|
|
135
|
+
* type Union = StepLayoutContent
|
|
136
|
+
*/
|
|
137
|
+
export type StepLayoutContent = ContentModelsMap[StepContentModelsMap[keyof StepContentModelsMap] & keyof ContentModelsMap];
|
|
138
|
+
/**
|
|
139
|
+
* Content type for a specific step key, via the step -> model map.
|
|
140
|
+
*
|
|
141
|
+
* @param {PropertyKey} K - Step key from the workspace schema.
|
|
142
|
+
* @example
|
|
143
|
+
* type Main = ContentForStep<'main'>
|
|
144
|
+
*/
|
|
145
|
+
export type ContentForStep<K extends PropertyKey> = K extends keyof StepContentModelsMap ? ContentModelsMap[StepContentModelsMap[K] & keyof ContentModelsMap] : StepLayoutContent;
|
|
146
|
+
/**
|
|
147
|
+
* Field keys bound to a specific step key, via the step → field-keys map.
|
|
148
|
+
* Falls back to all workspace {@link FieldKeys} when the registry has no
|
|
149
|
+
* `stepFieldKeys` entry for `K` (old snapshots / unaugmented clients).
|
|
150
|
+
*
|
|
151
|
+
* @param {PropertyKey} K - Step key from the workspace schema.
|
|
152
|
+
* @example
|
|
153
|
+
* type MainFields = FieldKeysForStep<'main'>
|
|
154
|
+
*/
|
|
155
|
+
export type FieldKeysForStep<K extends PropertyKey> = K extends keyof StepFieldKeysMap ? StepFieldKeysMap[K] & KnownFieldKeys : FieldKeys;
|
|
156
|
+
/**
|
|
157
|
+
* Value type for a field key (always optional at read time).
|
|
158
|
+
*
|
|
159
|
+
* @param {PropertyKey} K - Field key from the workspace schema.
|
|
160
|
+
* @example
|
|
161
|
+
* type Email = FieldValueFor<'email'>
|
|
162
|
+
*/
|
|
163
|
+
export type FieldValueFor<K extends PropertyKey> = FieldValuesMap extends never ? ResponseFieldValue : K extends keyof FieldValuesMap ? FieldValuesMap[K] | null : ResponseFieldValue;
|
|
164
|
+
/**
|
|
165
|
+
* A `Content` record whose `data` is narrowed to `TData`.
|
|
166
|
+
*
|
|
167
|
+
* @param {unknown} TData - Explicit content model shape.
|
|
168
|
+
* @example
|
|
169
|
+
* type Typed = TypedContent<WelcomePageContent>
|
|
170
|
+
*/
|
|
171
|
+
export type TypedContent<TData> = Omit<Content, 'data'> & {
|
|
172
|
+
data: TData;
|
|
173
|
+
};
|
|
174
|
+
/**
|
|
175
|
+
* The Content record a `reference` field value points at.
|
|
176
|
+
*
|
|
177
|
+
* A generated pointer carries the target's shape on its optional `data` member, so the
|
|
178
|
+
* referenced record narrows to that shape. A value the generator knows nothing about —
|
|
179
|
+
* an unaugmented client, or a field that accepts any Content Model — falls back to the
|
|
180
|
+
* untyped {@link Content}. A repeatable field resolves through its element type.
|
|
181
|
+
*
|
|
182
|
+
* @param {unknown} TValue - The raw `reference` field value read from a content blob.
|
|
183
|
+
* @example
|
|
184
|
+
* type Author = ReferencedContent<WelcomePageContent['author']>
|
|
185
|
+
*/
|
|
186
|
+
export type ReferencedContent<TValue> = NonNullable<TValue> extends readonly (infer TElement)[] ? ReferencedContent<TElement> : NonNullable<TValue> extends {
|
|
187
|
+
data?: infer TData;
|
|
188
|
+
} ? [NonNullable<TData>] extends [never] ? Content : TypedContent<NonNullable<TData>> : Content;
|
|
189
|
+
export type { StepContentModelsMap };
|
|
190
|
+
//# sourceMappingURL=schema-registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema-registry.d.ts","sourceRoot":"","sources":["../../src/schema-registry.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAA;AACzD,OAAO,KAAK,EAAE,UAAU,IAAI,kBAAkB,EAAE,MAAM,wBAAwB,CAAA;AAE9E;;;;;;;;GAQG;AAEH,MAAM,WAAW,oBAAoB;CAAG;AAGxC,KAAK,gBAAgB,GAAG,oBAAoB,SAAS;IACnD,aAAa,EAAE,MAAM,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CACvD,GACG,CAAC,GACD,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAA;AAE3C,KAAK,oBAAoB,GAAG,oBAAoB,SAAS;IACvD,iBAAiB,EAAE,MAAM,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAC1D,GACG,CAAC,GACD,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;AAE1B,KAAK,gBAAgB,GAAG,oBAAoB,SAAS;IACnD,aAAa,EAAE,MAAM,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CACtD,GACG,CAAC,GACD,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;AAE1B,KAAK,cAAc,GAAG,oBAAoB,SAAS;IACjD,WAAW,EAAE,MAAM,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CACrD,GACG,CAAC,GACD,KAAK,CAAA;AAET;;;;;;;;;;;GAWG;AACH,KAAK,SAAS,GAAG,MAAM,GAAG,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,CAAA;AAE9C;;;;;GAKG;AACH,MAAM,MAAM,gBAAgB,GAAG,oBAAoB,SAAS;IAC1D,WAAW,EAAE,MAAM,CAAC,SAAS,MAAM,CAAA;CACpC,GACG,CAAC,GACD,MAAM,CAAA;AAEV;;;;;GAKG;AACH,MAAM,MAAM,WAAW,GAAG,oBAAoB,SAAS;IAAE,WAAW,EAAE,MAAM,CAAC,SAAS,MAAM,CAAA;CAAE,GAC1F,CAAC,GAAG,SAAS,GACb,MAAM,CAAA;AAEV;;;;;GAKG;AACH,MAAM,MAAM,aAAa,GAAG,oBAAoB,SAAS;IAAE,QAAQ,EAAE,MAAM,CAAC,SAAS,MAAM,CAAA;CAAE,GACzF,CAAC,GACD,MAAM,CAAA;AAEV;;;;;GAKG;AACH,MAAM,MAAM,QAAQ,GAAG,oBAAoB,SAAS;IAAE,QAAQ,EAAE,MAAM,CAAC,SAAS,MAAM,CAAA;CAAE,GACpF,CAAC,GAAG,SAAS,GACb,MAAM,CAAA;AAEV;;;;;;GAMG;AACH,MAAM,MAAM,eAAe,GAAG,oBAAoB,SAAS;IACzD,UAAU,EAAE,MAAM,CAAC,SAAS,MAAM,CAAA;CACnC,GACG,CAAC,GACD,MAAM,CAAA;AAEV;;;;;GAKG;AACH,MAAM,MAAM,UAAU,GAAG,oBAAoB,SAAS;IAAE,UAAU,EAAE,MAAM,CAAC,SAAS,MAAM,CAAA;CAAE,GACxF,CAAC,GAAG,SAAS,GACb,MAAM,CAAA;AAEV;;;;;;GAMG;AACH,MAAM,MAAM,mBAAmB,GAAG,oBAAoB,SAAS;IAC7D,cAAc,EAAE,MAAM,CAAC,SAAS,MAAM,CAAA;CACvC,GACG,CAAC,GACD,MAAM,CAAA;AAEV;;;;;GAKG;AACH,MAAM,MAAM,cAAc,GAAG,oBAAoB,SAAS;IACxD,cAAc,EAAE,MAAM,CAAC,SAAS,MAAM,CAAA;CACvC,GACG,CAAC,GAAG,SAAS,GACb,MAAM,CAAA;AAEV;;;;;GAKG;AACH,MAAM,MAAM,cAAc,GAAG,cAAc,SAAS,KAAK,GAAG,MAAM,GAAG,MAAM,cAAc,GAAG,MAAM,CAAA;AAElG;;;;;;;;GAQG;AACH,MAAM,MAAM,SAAS,GAAG,cAAc,SAAS,KAAK,GAAG,MAAM,GAAG,cAAc,GAAG,SAAS,CAAA;AAE1F;;;;;GAKG;AACH,MAAM,MAAM,iBAAiB,GAAG,gBAAgB,CAAC,oBAAoB,CAAC,MAAM,oBAAoB,CAAC,GAC/F,MAAM,gBAAgB,CAAC,CAAA;AAEzB;;;;;;GAMG;AACH,MAAM,MAAM,cAAc,CAAC,CAAC,SAAS,WAAW,IAAI,CAAC,SAAS,MAAM,oBAAoB,GACpF,gBAAgB,CAAC,oBAAoB,CAAC,CAAC,CAAC,GAAG,MAAM,gBAAgB,CAAC,GAClE,iBAAiB,CAAA;AAErB;;;;;;;;GAQG;AACH,MAAM,MAAM,gBAAgB,CAAC,CAAC,SAAS,WAAW,IAAI,CAAC,SAAS,MAAM,gBAAgB,GAClF,gBAAgB,CAAC,CAAC,CAAC,GAAG,cAAc,GACpC,SAAS,CAAA;AAEb;;;;;;GAMG;AACH,MAAM,MAAM,aAAa,CAAC,CAAC,SAAS,WAAW,IAAI,cAAc,SAAS,KAAK,GAC3E,kBAAkB,GAClB,CAAC,SAAS,MAAM,cAAc,GAC5B,cAAc,CAAC,CAAC,CAAC,GAAG,IAAI,GACxB,kBAAkB,CAAA;AAExB;;;;;;GAMG;AACH,MAAM,MAAM,YAAY,CAAC,KAAK,IAAI,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,GAAG;IAAE,IAAI,EAAE,KAAK,CAAA;CAAE,CAAA;AAEzE;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,iBAAiB,CAAC,MAAM,IAClC,WAAW,CAAC,MAAM,CAAC,SAAS,SAAS,CAAC,MAAM,QAAQ,CAAC,EAAE,GACnD,iBAAiB,CAAC,QAAQ,CAAC,GAC3B,WAAW,CAAC,MAAM,CAAC,SAAS;IAAE,IAAI,CAAC,EAAE,MAAM,KAAK,CAAA;CAAE,GAChD,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,GAClC,OAAO,GACP,YAAY,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,GAClC,OAAO,CAAA;AAEf,YAAY,EAAE,oBAAoB,EAAE,CAAA"}
|
|
@@ -1,12 +1,12 @@
|
|
|
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';
|
|
8
8
|
export { hashRule, evaluateConditionMemo, isExperienceActive, ruleReferencesAction, ruleReferencesActionDeep, } from '../lifecycle/condition-selection';
|
|
9
|
-
export type { ContentBlob, ProjectConfig, ProjectConfigExperience,
|
|
9
|
+
export type { ContentBlob, ExperienceContentResponse, ProjectConfig, ProjectConfigExperience, } from '@picked/delivery-api-client';
|
|
10
10
|
export interface Renderer<T = AdaptedComponent<string, unknown>> {
|
|
11
11
|
isValidComponent: (component: AdaptedComponent<string, unknown>) => boolean;
|
|
12
12
|
render: (component: T, client: Picked, experience: ExperienceInstance) => Promise<{
|
|
@@ -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,yBAAyB,EACzB,aAAa,EACb,uBAAuB,GACxB,MAAM,6BAA6B,CAAA;AA0BpC,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,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Server-side `serialize` helper: synchronously registers a project config, selects the
|
|
3
|
+
* experiences whose conditions pass for a given URL, fetches content for the selected
|
|
4
|
+
* experiences that reference CMS layout content, and returns a plain-JSON snapshot for SSR
|
|
5
|
+
* hydration.
|
|
6
|
+
*
|
|
7
|
+
* The snapshot is plain JSON: `projectConfig` travels so the client renders against the exact
|
|
8
|
+
* config the server selected with (critical for preview), and `conditionResults` carries the
|
|
9
|
+
* memoized selection so the client's first paint reuses the server's results without re-evaluating.
|
|
10
|
+
*/
|
|
11
|
+
import type { ContentBlob, ProjectConfig } from '@picked/delivery-api-client';
|
|
1
12
|
import type { Picked } from '../picked';
|
|
2
|
-
import type { ContentBlob, ExperienceContentResponse, ProjectConfig } from '../plugins/dynamic-experiences/types';
|
|
3
13
|
/** Subset of `Location` fields that can be injected into the selection context. */
|
|
4
14
|
export interface SerializeLocation {
|
|
5
15
|
href: string;
|
|
@@ -16,31 +26,19 @@ export interface SerializeLocation {
|
|
|
16
26
|
export interface SerializeAttributes {
|
|
17
27
|
location?: Partial<SerializeLocation>;
|
|
18
28
|
}
|
|
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
29
|
/** Parameters for {@link serialize}. */
|
|
27
30
|
export interface SerializeParams {
|
|
28
|
-
/** The project config to register and select against. */
|
|
29
|
-
projectConfig: ProjectConfig;
|
|
30
31
|
/** URL attributes injected into the selection context. */
|
|
31
32
|
attributes?: SerializeAttributes;
|
|
32
|
-
/** Optional content fetcher; falls back to the runtime API when omitted. */
|
|
33
|
-
getContent?: SerializeGetContent;
|
|
34
33
|
/**
|
|
35
|
-
* Preview token
|
|
36
|
-
* preview
|
|
37
|
-
* so the token cannot be recovered otherwise.
|
|
34
|
+
* Preview token for this request, so preview (unpublished) config and content resolve during
|
|
35
|
+
* preview SSR. The server has no `searchParams`, so the token cannot be recovered otherwise.
|
|
38
36
|
*/
|
|
39
37
|
previewToken?: string;
|
|
40
38
|
/**
|
|
41
|
-
* Per-content-fetch timeout in milliseconds for the
|
|
42
|
-
*
|
|
43
|
-
*
|
|
39
|
+
* Per-content-fetch timeout in milliseconds for the API path, so a slow or hung upstream cannot
|
|
40
|
+
* stall the SSR render indefinitely. On timeout the blob is skipped and the render proceeds.
|
|
41
|
+
* Defaults to {@link DEFAULT_CONTENT_TIMEOUT_MS}.
|
|
44
42
|
*/
|
|
45
43
|
timeoutMs?: number;
|
|
46
44
|
}
|
|
@@ -52,33 +50,38 @@ export interface PickedSnapshot {
|
|
|
52
50
|
versionId: string | null;
|
|
53
51
|
/** The project config the server selected with (travels for preview parity). */
|
|
54
52
|
projectConfig: ProjectConfig;
|
|
55
|
-
/**
|
|
53
|
+
/**
|
|
54
|
+
* Deduped content blobs for the selected experiences — the steps' own layout
|
|
55
|
+
* content and every entry reached from it through a `reference` field. The
|
|
56
|
+
* client provider seeds the whole array into the content registry, so both
|
|
57
|
+
* resolve identically on the server render and the first client paint.
|
|
58
|
+
*/
|
|
56
59
|
content: ContentBlob[];
|
|
57
60
|
/** Memoized condition-evaluation results keyed by rule hash. */
|
|
58
61
|
conditionResults: Record<string, boolean>;
|
|
59
62
|
}
|
|
60
63
|
/**
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
+
* Selects the experiences whose conditions pass for a URL and returns a plain-JSON snapshot for
|
|
65
|
+
* SSR hydration.
|
|
66
|
+
*
|
|
67
|
+
* Config and content both resolve through the client, which keeps them on one source: a bundled
|
|
68
|
+
* render cannot pair a bundled config with API-fetched content from a newer publish. Content is
|
|
69
|
+
* deduped by blob id, and each API read carries a deadline so a slow upstream cannot stall the
|
|
70
|
+
* render.
|
|
64
71
|
*
|
|
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.
|
|
72
|
+
* Registration is synchronous (no `client.start()`), so the client's stores are populated before
|
|
73
|
+
* selection. The condition-results store is reset at entry, and `serialize` expects a per-request
|
|
74
|
+
* client — concurrent calls on one client are not supported. Each experience's own condition is
|
|
75
|
+
* evaluated through the memoized evaluator against the injected URL; client-level
|
|
76
|
+
* precondition/condition are not evaluated here in v1.
|
|
73
77
|
*
|
|
74
|
-
* @param {Picked} client - The Picked client to
|
|
75
|
-
* @param {SerializeParams} params -
|
|
78
|
+
* @param {Picked} client - The Picked client to select with, and to resolve data through.
|
|
79
|
+
* @param {SerializeParams} [params] - URL attributes, preview token, and content timeout.
|
|
76
80
|
* @returns {Promise<PickedSnapshot>} The plain-JSON snapshot of config, content, and condition results.
|
|
77
81
|
* @example
|
|
78
82
|
* const snapshot = await serialize(client, {
|
|
79
|
-
* projectConfig,
|
|
80
83
|
* attributes: { location: { pathname: '/promo' } },
|
|
81
84
|
* })
|
|
82
85
|
*/
|
|
83
|
-
export declare function serialize(client: Picked, params
|
|
86
|
+
export declare function serialize(client: Picked, params?: SerializeParams): Promise<PickedSnapshot>;
|
|
84
87
|
//# sourceMappingURL=serialize.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serialize.d.ts","sourceRoot":"","sources":["../../../src/server/serialize.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"serialize.d.ts","sourceRoot":"","sources":["../../../src/server/serialize.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,KAAK,EACV,WAAW,EACX,aAAa,EAEd,MAAM,6BAA6B,CAAA;AAEpC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAKvC,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,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAC1C;AAoCD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAsB,SAAS,CAC7B,MAAM,EAAE,MAAM,EACd,MAAM,GAAE,eAAoB,GAC3B,OAAO,CAAC,cAAc,CAAC,CA6EzB"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/** @file Bridges untyped content registry stores to codegen-narrowed consumer types. */
|
|
2
|
+
import type { Store } from 'effector';
|
|
3
|
+
import type { Content } from './entities/content/content';
|
|
4
|
+
import type { TypedContent } from './schema-registry';
|
|
5
|
+
/**
|
|
6
|
+
* Maps an untyped content store to a codegen-narrowed `TypedContent` store. The
|
|
7
|
+
* `TData` narrowing is compile-time only (no runtime shape check); records whose
|
|
8
|
+
* `data` is not an object map to `null`.
|
|
9
|
+
*
|
|
10
|
+
* @template {Record<string, unknown>} TData
|
|
11
|
+
* @param {Store<Content | null>} store - Registry store from `client.contents.getById`.
|
|
12
|
+
* @returns {Store<TypedContent<TData> | null>} Store whose `data` is narrowed to `TData`.
|
|
13
|
+
* @example
|
|
14
|
+
* const banner = toTypedContentStore<WelcomePage>(client.contents.getById('lc_banner'))
|
|
15
|
+
*/
|
|
16
|
+
export declare function toTypedContentStore<TData extends Record<string, unknown>>(store: Store<Content | null>): Store<TypedContent<TData> | null>;
|
|
17
|
+
//# sourceMappingURL=typed-content.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typed-content.d.ts","sourceRoot":"","sources":["../../src/typed-content.ts"],"names":[],"mappings":"AAAA,wFAAwF;AACxF,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,UAAU,CAAA;AACrC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAA;AACzD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAoBrD;;;;;;;;;;GAUG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACvE,KAAK,EAAE,KAAK,CAAC,OAAO,GAAG,IAAI,CAAC,GAC3B,KAAK,CAAC,YAAY,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,CAWnC"}
|
|
@@ -1,10 +1,27 @@
|
|
|
1
1
|
/** @file Resolves the project id for a Picked client from options, window config, or script tag attributes. */
|
|
2
2
|
import type { CreateClientOptions } from '../client';
|
|
3
|
+
/** Subset of {@link CreateClientOptions} exposed on `window.pickedConfig`. */
|
|
4
|
+
interface WindowPickedConfig {
|
|
5
|
+
organizationId?: string;
|
|
6
|
+
projectId?: string;
|
|
7
|
+
previewToken?: string;
|
|
8
|
+
apiUrl?: string;
|
|
9
|
+
dashboardUrl?: string;
|
|
10
|
+
documentationSiteUrl?: string;
|
|
11
|
+
}
|
|
3
12
|
declare global {
|
|
4
13
|
interface Window {
|
|
5
|
-
pickedConfig?:
|
|
14
|
+
pickedConfig?: WindowPickedConfig;
|
|
6
15
|
}
|
|
7
16
|
}
|
|
17
|
+
/**
|
|
18
|
+
* Reads `window.pickedConfig` when running in a browser.
|
|
19
|
+
*
|
|
20
|
+
* @template ExtendedPickedConfig - Additional keys consumers attach to the window config.
|
|
21
|
+
* @returns {Readonly<Partial<CreateClientOptions> & ExtendedPickedConfig> | undefined} The window config, if set.
|
|
22
|
+
* @example
|
|
23
|
+
* getPickedConfig<{ theme: string }>()?.theme
|
|
24
|
+
*/
|
|
8
25
|
export declare function getPickedConfig<ExtendedPickedConfig extends Record<string, unknown> | undefined>(): Readonly<Partial<CreateClientOptions> & ExtendedPickedConfig> | undefined;
|
|
9
26
|
/**
|
|
10
27
|
* Resolves the Picked project id from the supplied options, falling back to
|
|
@@ -18,4 +35,5 @@ export declare function getPickedConfig<ExtendedPickedConfig extends Record<stri
|
|
|
18
35
|
* getCreateClientProjectId({ projectId: 'proj-abc' })
|
|
19
36
|
*/
|
|
20
37
|
export declare function getCreateClientProjectId(options: CreateClientOptions): string;
|
|
38
|
+
export {};
|
|
21
39
|
//# sourceMappingURL=picked-config.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"picked-config.d.ts","sourceRoot":"","sources":["../../../src/utils/picked-config.ts"],"names":[],"mappings":"AAAA,+GAA+G;AAC/G,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAA;AAGpD,
|
|
1
|
+
{"version":3,"file":"picked-config.d.ts","sourceRoot":"","sources":["../../../src/utils/picked-config.ts"],"names":[],"mappings":"AAAA,+GAA+G;AAC/G,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAA;AAGpD,8EAA8E;AAC9E,UAAU,kBAAkB;IAC1B,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,oBAAoB,CAAC,EAAE,MAAM,CAAA;CAC9B;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd,YAAY,CAAC,EAAE,kBAAkB,CAAA;KAClC;CACF;AAED;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAC7B,oBAAoB,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,+EAUjE;AAyCD;;;;;;;;;;GAUG;AACH,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,mBAAmB,GAAG,MAAM,CAqB7E"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=()=>`0.0.1-dev.1786601464574`;Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return e}});
|
package/package.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@picked/client",
|
|
3
|
-
"version": "0.0.1-dev.
|
|
3
|
+
"version": "0.0.1-dev.1786601464574",
|
|
4
4
|
"dependencies": {
|
|
5
|
+
"@picked/delivery-api-client": "0.0.1-dev.1786601464574",
|
|
5
6
|
"@withease/factories": "^1.0.5"
|
|
6
7
|
},
|
|
7
8
|
"devDependencies": {
|
|
@@ -126,6 +127,7 @@
|
|
|
126
127
|
"duplicates"
|
|
127
128
|
],
|
|
128
129
|
"ignoreDependencies": [
|
|
130
|
+
"@picked/delivery-api-client",
|
|
129
131
|
"@repo/eslint-config",
|
|
130
132
|
"@repo/typescript-config",
|
|
131
133
|
"@testing-library/dom",
|
|
@@ -171,8 +173,8 @@
|
|
|
171
173
|
"size-limit": [
|
|
172
174
|
{
|
|
173
175
|
"path": "dist/esm/index.js",
|
|
174
|
-
"limit": "
|
|
175
|
-
"name": "index (incl. lazily-loaded preview channel; see AGENTS.md)"
|
|
176
|
+
"limit": "18 kB",
|
|
177
|
+
"name": "index (incl. lazily-loaded preview channel and data provider; see AGENTS.md)"
|
|
176
178
|
},
|
|
177
179
|
{
|
|
178
180
|
"path": "dist/esm/server/index.js",
|