@picked/client 0.0.1-dev.1786065500148 → 0.0.1-dev.1786072899095
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-BzK4kXRt.js +38 -0
- package/dist/api-CgENjKwJ.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/how-picked-works.md +3 -25
- package/dist/docs/reference/sdk/plugins/dynamic-experiences.md +2 -50
- package/dist/docs/reference/tools/vite-plugin.md +8 -90
- package/dist/esm/index.js +452 -499
- package/dist/esm/plugins/dynamic-experiences/index.js +3 -3
- package/dist/esm/server/index.js +46 -43
- package/dist/plugin-DJjtc5df.js +252 -0
- package/dist/plugin-jHxSAqGG.cjs +1 -0
- package/dist/types/entities/feature/feature.d.ts +9 -2
- package/dist/types/entities/feature/feature.d.ts.map +1 -1
- package/dist/types/picked.d.ts +3 -66
- package/dist/types/picked.d.ts.map +1 -1
- package/dist/types/plugins/dynamic-experiences/index.d.ts +0 -1
- package/dist/types/plugins/dynamic-experiences/index.d.ts.map +1 -1
- package/dist/types/plugins/dynamic-experiences/plugin.d.ts +40 -9
- package/dist/types/plugins/dynamic-experiences/plugin.d.ts.map +1 -1
- package/dist/types/plugins/dynamic-experiences/types.d.ts +23 -15
- 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 +19 -7
- package/dist/types/server/serialize.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/plugin-EFn9ALEF.cjs +0 -1
- package/dist/plugin-YytfMG0n.js +0 -153
- package/dist/registry-BYtEBdL1.js +0 -111
- package/dist/registry-DtmKJre-.cjs +0 -1
- package/dist/types/data-source/api.d.ts +0 -60
- package/dist/types/data-source/api.d.ts.map +0 -1
- package/dist/types/data-source/provider.d.ts +0 -91
- package/dist/types/data-source/provider.d.ts.map +0 -1
- package/dist/types/data-source/registry.d.ts +0 -27
- package/dist/types/data-source/registry.d.ts.map +0 -1
- package/dist/types/data-source/virtual-data.d.ts +0 -19
- package/dist/types/data-source/virtual-data.d.ts.map +0 -1
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { Plugin } from '../../entities/plugin/plugin';
|
|
2
2
|
import type { Picked } from '../../picked';
|
|
3
|
-
import type { ProjectConfig } from './types';
|
|
4
|
-
export { fetchProject, fetchExperienceContent } from '../../data-source/api';
|
|
3
|
+
import type { DynamicExperiencesPluginOptions, ExperienceContentResponse, FetchProjectOptions, ProjectConfig } from './types';
|
|
5
4
|
/**
|
|
6
5
|
* Synchronously registers a complete project config with the client: features, conditions,
|
|
7
6
|
* fields, steps, and experiences, in dependency order.
|
|
@@ -25,14 +24,46 @@ export declare function registerProjectConfig(client: Picked, config: ProjectCon
|
|
|
25
24
|
sessionId: string;
|
|
26
25
|
}): void;
|
|
27
26
|
/**
|
|
28
|
-
*
|
|
29
|
-
* steps, fields, and experiences with it.
|
|
27
|
+
* Fetches the project configuration from the Picked REST API.
|
|
30
28
|
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
* the Picked API otherwise. Search param feature overrides take precedence over resolved
|
|
34
|
-
* values.
|
|
29
|
+
* Returns `null` on network failure, non-OK responses, or invalid JSON shape.
|
|
30
|
+
* Connection-refused errors from local URLs are suppressed silently.
|
|
35
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
|
+
/**
|
|
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.
|
|
36
67
|
* @returns {Plugin} A configured Picked plugin.
|
|
37
68
|
* @example
|
|
38
69
|
* ```typescript
|
|
@@ -45,5 +76,5 @@ export declare function registerProjectConfig(client: Picked, config: ProjectCon
|
|
|
45
76
|
* })
|
|
46
77
|
* ```
|
|
47
78
|
*/
|
|
48
|
-
export declare function dynamicExperiencesPlugin(): Plugin;
|
|
79
|
+
export declare function dynamicExperiencesPlugin(options?: DynamicExperiencesPluginOptions): Plugin;
|
|
49
80
|
//# 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,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;AA4QD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,wBAAwB,CAAC,OAAO,CAAC,EAAE,+BAA+B,GAAG,MAAM,CAsC1F"}
|
|
@@ -78,6 +78,23 @@ 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
|
+
}
|
|
81
98
|
export interface FetchProjectOptions {
|
|
82
99
|
previewToken?: string;
|
|
83
100
|
headers?: Record<string, string>;
|
|
@@ -119,20 +136,6 @@ export type ContentLoader = (experience: {
|
|
|
119
136
|
}, options?: {
|
|
120
137
|
previewToken?: string;
|
|
121
138
|
}) => Promise<ExperienceContentResponse | null>;
|
|
122
|
-
/**
|
|
123
|
-
* Provenance the virtual data module records about the snapshot it carries: which build
|
|
124
|
-
* flavour produced it, when, and which workspace version it was taken from.
|
|
125
|
-
*/
|
|
126
|
-
export interface PickedManifestMetadata {
|
|
127
|
-
/** `'build'` when build-mode prefetch JSON was used, `'dev'` when the dev-mode fetch was. */
|
|
128
|
-
mode: 'dev' | 'build';
|
|
129
|
-
/** ISO 8601 timestamp from the manifest. `null` in dev mode, where no manifest is written. */
|
|
130
|
-
fetchedAt: string | null;
|
|
131
|
-
/** The `versionId` the snapshot was taken from, when known. */
|
|
132
|
-
projectVersionId: string | null;
|
|
133
|
-
/** The `workspaceId` the snapshot was taken from, when known. */
|
|
134
|
-
workspaceId: string | null;
|
|
135
|
-
}
|
|
136
139
|
/**
|
|
137
140
|
* Optional-fields surface of the virtual data module exposed by `@picked/vite-plugin-picked`.
|
|
138
141
|
* The shape is identical between dev (`vite serve`) and build (`vite build`) modes.
|
|
@@ -140,6 +143,11 @@ export interface PickedManifestMetadata {
|
|
|
140
143
|
export interface VirtualPickedData {
|
|
141
144
|
projectConfig: ProjectConfig;
|
|
142
145
|
experienceContent: ContentLoader;
|
|
143
|
-
manifestMetadata:
|
|
146
|
+
manifestMetadata: {
|
|
147
|
+
mode: 'dev' | 'build';
|
|
148
|
+
fetchedAt: string | null;
|
|
149
|
+
projectVersionId: string | null;
|
|
150
|
+
workspaceId: string | null;
|
|
151
|
+
};
|
|
144
152
|
}
|
|
145
153
|
//# 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,oBAAoB;IACnC,EAAE,EAAE,MAAM,CAAA;IACV,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,CAAA;CAAE,KAChC,OAAO,CAAC,yBAAyB,GAAG,IAAI,CAAC,CAAA;AAE9C;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IAChC,aAAa,EAAE,aAAa,CAAA;IAC5B,iBAAiB,EAAE,aAAa,CAAA;IAChC,gBAAgB,EAAE;QAChB,IAAI,EAAE,KAAK,GAAG,OAAO,CAAA;QACrB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;QACxB,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAA;QAC/B,WAAW,EAAE,MAAM,GAAG,IAAI,CAAA;KAC3B,CAAA;CACF"}
|
|
@@ -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, } from './serialize';
|
|
4
|
+
export { serialize, type PickedSnapshot, type SerializeParams, type SerializeAttributes, type SerializeLocation, type SerializeGetContent, } 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.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AoJ/E"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Picked } from '../picked';
|
|
2
|
-
import type { ContentBlob, ProjectConfig } from '../plugins/dynamic-experiences/types';
|
|
2
|
+
import type { ContentBlob, ExperienceContentResponse, 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,19 +16,31 @@ 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>;
|
|
19
26
|
/** Parameters for {@link serialize}. */
|
|
20
27
|
export interface SerializeParams {
|
|
28
|
+
/** The project config to register and select against. */
|
|
29
|
+
projectConfig: ProjectConfig;
|
|
21
30
|
/** URL attributes injected into the selection context. */
|
|
22
31
|
attributes?: SerializeAttributes;
|
|
32
|
+
/** Optional content fetcher; falls back to the runtime API when omitted. */
|
|
33
|
+
getContent?: SerializeGetContent;
|
|
23
34
|
/**
|
|
24
|
-
* Preview token
|
|
25
|
-
* preview SSR. The server has no `searchParams`,
|
|
35
|
+
* Preview token forwarded to the default API content fetch (and to a custom `getContent`), so
|
|
36
|
+
* preview (unpublished) content resolves during preview SSR. The server has no `searchParams`,
|
|
37
|
+
* so the token cannot be recovered otherwise.
|
|
26
38
|
*/
|
|
27
39
|
previewToken?: string;
|
|
28
40
|
/**
|
|
29
|
-
* Per-content-fetch timeout in milliseconds for the API path, so a slow or hung upstream
|
|
30
|
-
* stall the SSR render indefinitely. On timeout the blob is skipped and the render
|
|
31
|
-
* Defaults to {@link DEFAULT_CONTENT_TIMEOUT_MS}.
|
|
41
|
+
* Per-content-fetch timeout in milliseconds for the default API path, so a slow or hung upstream
|
|
42
|
+
* cannot stall the SSR render indefinitely. On timeout the blob is skipped and the render
|
|
43
|
+
* proceeds (matching the existing null-tolerant path). Defaults to {@link DEFAULT_CONTENT_TIMEOUT_MS}.
|
|
32
44
|
*/
|
|
33
45
|
timeoutMs?: number;
|
|
34
46
|
}
|
|
@@ -68,5 +80,5 @@ export interface PickedSnapshot {
|
|
|
68
80
|
* attributes: { location: { pathname: '/promo' } },
|
|
69
81
|
* })
|
|
70
82
|
*/
|
|
71
|
-
export declare function serialize(client: Picked, params
|
|
83
|
+
export declare function serialize(client: Picked, params: SerializeParams): Promise<PickedSnapshot>;
|
|
72
84
|
//# 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;AAOvC,OAAO,KAAK,EACV,WAAW,EACX,yBAAyB,EACzB,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;AAED,+FAA+F;AAC/F,MAAM,MAAM,mBAAmB,GAAG,CAChC,UAAU,EAAE;IACV,EAAE,EAAE,MAAM,CAAA;IACV,GAAG,EAAE,MAAM,CAAA;CACZ,EACD,OAAO,CAAC,EAAE;IAAE,YAAY,CAAC,EAAE,MAAM,CAAA;CAAE,KAChC,OAAO,CAAC,yBAAyB,GAAG,IAAI,CAAC,CAAA;AAK9C,wCAAwC;AACxC,MAAM,WAAW,eAAe;IAC9B,yDAAyD;IACzD,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;CACnB;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,CAgEhG"}
|
package/package.json
CHANGED
package/dist/plugin-EFn9ALEF.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
require("./logger-CSTvAyyB.cjs");let e=require("effector");function t(e){let t=2166136261;for(let n of e)t^=n.codePointAt(0)??0,t=Math.imul(t,16777619);return t>>>0}function n(e){let t=e;return t^=t>>>16,t=Math.imul(t,2246822507),t^=t>>>13,t=Math.imul(t,3266489909),t^=t>>>16,t>>>0}function r(e,r){return n(t(`${e}:${r}`))%100}function i(e,t){return t<=0?!1:t>=100||e<t}function a(e,t){if(Array.isArray(t.conditions))for(let n of t.conditions)e.registerCondition(n)}function o(e,t){e.registerExperience({id:t.id,key:t.key,name:t.name,targets:t.targets,nodes:t.nodes,edges:t.edges,condition:t.condition,initializeOpen:t.initializeOpen,componentName:t.componentName})}function s(e,t){if(Array.isArray(t.fields))for(let n of t.fields)e.registerField(n)}function c(e,t){if(!Array.isArray(t.steps))return;let n=new Map(t.fields.map(e=>[e.id,e.key]));for(let r of t.steps){let t=[];for(let e of r.fieldIds??[]){let i=n.get(e);if(i===void 0){`${r.key}${e}`;continue}t.push(i)}let i=r.layoutContentId?e.contents.getById(r.layoutContentId):null;e.registerStep({id:r.id,key:r.key,name:r.name,fieldKeys:t,layoutName:r.layoutName,...r.layoutContentId!==void 0&&{layoutContentId:r.layoutContentId,layoutContentStore:i}})}}function l(e,t){if(Array.isArray(t.experiences))for(let n of t.experiences)o(e,n)}function u(e,t,n){p(e,t,n.isPreview,n.sessionId),a(e,t),s(e,t),c(e,t),l(e,t)}function d(e){let t=e.searchParams[`preview-token`];if(t&&t.length>0)return t[0]}function f(e){let t=new Set,n=e.searchParams.feature;if(!n)return t;for(let e of n){let n=e.indexOf(`:`);n>0&&t.add(e.substring(0,n))}return t}function p(e,t,n,r){let i=f(e);for(let a of t.features)i.has(a.id)||m(e,a,n,r)}function m(e,t,n,a){let o=r(a,t.id);e.registerFeature(t.id,{key:`v${t.version}`,name:t.name,enabled:t.enabled,weight:t.weight,storage:n?`session`:`local`,decide:()=>i(o,t.weight)})}function h(e,t){for(let n of t.content)e.registerContent({id:n.id,contentModelKey:n.contentModelKey,data:n.data})}function g(e,t){let n=new Map;return(r,i)=>{let a=n.get(r.id);if(a)return a;let o=(async()=>{try{let n=await t(r,i);return n&&h(e,n),n}finally{n.delete(r.id)}})();return n.set(r.id,o),o}}function _(e,t){let n=new Set(t&&Array.isArray(t.experiences)?t.experiences.map(e=>e.id):[]);return(t,r)=>n.has(t.id)?e(t,r):Promise.resolve(null)}function v(){return{name:`dynamic-experiences`,setup:t=>({onStart:(0,e.attach)({source:t.session.store.map(e=>e.id),effect:async e=>{let n=d(t),r=n!==void 0,i=n===void 0?void 0:{previewToken:n},a=await t.getProjectConfig(n===void 0?void 0:{previewToken:n}).catch(e=>null);if(t.contentLoader=g(t,_(e=>t.getExperienceContent(e,i),a)),!a)return;let o=t.seededVersionId;if(o!==null&&o!==a.versionId){t.versionSkew={seeded:o,resolved:a.versionId},`${a.versionId}${o}`;return}t.previewEmbedderOrigins=a.previewEmbedderOrigins??null,u(t,a,{isPreview:r,sessionId:e})}})})}}Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return u}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return v}});
|
package/dist/plugin-YytfMG0n.js
DELETED
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
import "./logger-DMN6TxJJ.js";
|
|
2
|
-
import { attach as e } from "effector";
|
|
3
|
-
//#region src/plugins/dynamic-experiences/hash.ts
|
|
4
|
-
function t(e) {
|
|
5
|
-
let t = 2166136261;
|
|
6
|
-
for (let n of e) t ^= n.codePointAt(0) ?? 0, t = Math.imul(t, 16777619);
|
|
7
|
-
return t >>> 0;
|
|
8
|
-
}
|
|
9
|
-
function n(e) {
|
|
10
|
-
let t = e;
|
|
11
|
-
return t ^= t >>> 16, t = Math.imul(t, 2246822507), t ^= t >>> 13, t = Math.imul(t, 3266489909), t ^= t >>> 16, t >>> 0;
|
|
12
|
-
}
|
|
13
|
-
function r(e, r) {
|
|
14
|
-
return n(t(`${e}:${r}`)) % 100;
|
|
15
|
-
}
|
|
16
|
-
function i(e, t) {
|
|
17
|
-
return t <= 0 ? !1 : t >= 100 || e < t;
|
|
18
|
-
}
|
|
19
|
-
//#endregion
|
|
20
|
-
//#region src/plugins/dynamic-experiences/plugin.ts
|
|
21
|
-
function a(e, t) {
|
|
22
|
-
if (Array.isArray(t.conditions)) for (let n of t.conditions) e.registerCondition(n);
|
|
23
|
-
}
|
|
24
|
-
function o(e, t) {
|
|
25
|
-
e.registerExperience({
|
|
26
|
-
id: t.id,
|
|
27
|
-
key: t.key,
|
|
28
|
-
name: t.name,
|
|
29
|
-
targets: t.targets,
|
|
30
|
-
nodes: t.nodes,
|
|
31
|
-
edges: t.edges,
|
|
32
|
-
condition: t.condition,
|
|
33
|
-
initializeOpen: t.initializeOpen,
|
|
34
|
-
componentName: t.componentName
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
function s(e, t) {
|
|
38
|
-
if (Array.isArray(t.fields)) for (let n of t.fields) e.registerField(n);
|
|
39
|
-
}
|
|
40
|
-
function c(e, t) {
|
|
41
|
-
if (!Array.isArray(t.steps)) return;
|
|
42
|
-
let n = new Map(t.fields.map((e) => [e.id, e.key]));
|
|
43
|
-
for (let r of t.steps) {
|
|
44
|
-
let t = [];
|
|
45
|
-
for (let e of r.fieldIds ?? []) {
|
|
46
|
-
let i = n.get(e);
|
|
47
|
-
if (i === void 0) {
|
|
48
|
-
`${r.key}${e}`;
|
|
49
|
-
continue;
|
|
50
|
-
}
|
|
51
|
-
t.push(i);
|
|
52
|
-
}
|
|
53
|
-
let i = r.layoutContentId ? e.contents.getById(r.layoutContentId) : null;
|
|
54
|
-
e.registerStep({
|
|
55
|
-
id: r.id,
|
|
56
|
-
key: r.key,
|
|
57
|
-
name: r.name,
|
|
58
|
-
fieldKeys: t,
|
|
59
|
-
layoutName: r.layoutName,
|
|
60
|
-
...r.layoutContentId !== void 0 && {
|
|
61
|
-
layoutContentId: r.layoutContentId,
|
|
62
|
-
layoutContentStore: i
|
|
63
|
-
}
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
function l(e, t) {
|
|
68
|
-
if (Array.isArray(t.experiences)) for (let n of t.experiences) o(e, n);
|
|
69
|
-
}
|
|
70
|
-
function u(e, t, n) {
|
|
71
|
-
p(e, t, n.isPreview, n.sessionId), a(e, t), s(e, t), c(e, t), l(e, t);
|
|
72
|
-
}
|
|
73
|
-
function d(e) {
|
|
74
|
-
let t = e.searchParams["preview-token"];
|
|
75
|
-
if (t && t.length > 0) return t[0];
|
|
76
|
-
}
|
|
77
|
-
function f(e) {
|
|
78
|
-
let t = /* @__PURE__ */ new Set(), n = e.searchParams.feature;
|
|
79
|
-
if (!n) return t;
|
|
80
|
-
for (let e of n) {
|
|
81
|
-
let n = e.indexOf(":");
|
|
82
|
-
n > 0 && t.add(e.substring(0, n));
|
|
83
|
-
}
|
|
84
|
-
return t;
|
|
85
|
-
}
|
|
86
|
-
function p(e, t, n, r) {
|
|
87
|
-
let i = f(e);
|
|
88
|
-
for (let a of t.features) i.has(a.id) || m(e, a, n, r);
|
|
89
|
-
}
|
|
90
|
-
function m(e, t, n, a) {
|
|
91
|
-
let o = r(a, t.id);
|
|
92
|
-
e.registerFeature(t.id, {
|
|
93
|
-
key: `v${t.version}`,
|
|
94
|
-
name: t.name,
|
|
95
|
-
enabled: t.enabled,
|
|
96
|
-
weight: t.weight,
|
|
97
|
-
storage: n ? "session" : "local",
|
|
98
|
-
decide: () => i(o, t.weight)
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
function h(e, t) {
|
|
102
|
-
for (let n of t.content) e.registerContent({
|
|
103
|
-
id: n.id,
|
|
104
|
-
contentModelKey: n.contentModelKey,
|
|
105
|
-
data: n.data
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
function g(e, t) {
|
|
109
|
-
let n = /* @__PURE__ */ new Map();
|
|
110
|
-
return (r, i) => {
|
|
111
|
-
let a = n.get(r.id);
|
|
112
|
-
if (a) return a;
|
|
113
|
-
let o = (async () => {
|
|
114
|
-
try {
|
|
115
|
-
let n = await t(r, i);
|
|
116
|
-
return n && h(e, n), n;
|
|
117
|
-
} finally {
|
|
118
|
-
n.delete(r.id);
|
|
119
|
-
}
|
|
120
|
-
})();
|
|
121
|
-
return n.set(r.id, o), o;
|
|
122
|
-
};
|
|
123
|
-
}
|
|
124
|
-
function _(e, t) {
|
|
125
|
-
let n = new Set(t && Array.isArray(t.experiences) ? t.experiences.map((e) => e.id) : []);
|
|
126
|
-
return (t, r) => n.has(t.id) ? e(t, r) : Promise.resolve(null);
|
|
127
|
-
}
|
|
128
|
-
function v() {
|
|
129
|
-
return {
|
|
130
|
-
name: "dynamic-experiences",
|
|
131
|
-
setup: (t) => ({ onStart: e({
|
|
132
|
-
source: t.session.store.map((e) => e.id),
|
|
133
|
-
effect: async (e) => {
|
|
134
|
-
let n = d(t), r = n !== void 0, i = n === void 0 ? void 0 : { previewToken: n }, a = await t.getProjectConfig(n === void 0 ? void 0 : { previewToken: n }).catch((e) => null);
|
|
135
|
-
if (t.contentLoader = g(t, _((e) => t.getExperienceContent(e, i), a)), !a) return;
|
|
136
|
-
let o = t.seededVersionId;
|
|
137
|
-
if (o !== null && o !== a.versionId) {
|
|
138
|
-
t.versionSkew = {
|
|
139
|
-
seeded: o,
|
|
140
|
-
resolved: a.versionId
|
|
141
|
-
}, `${a.versionId}${o}`;
|
|
142
|
-
return;
|
|
143
|
-
}
|
|
144
|
-
t.previewEmbedderOrigins = a.previewEmbedderOrigins ?? null, u(t, a, {
|
|
145
|
-
isPreview: r,
|
|
146
|
-
sessionId: e
|
|
147
|
-
});
|
|
148
|
-
}
|
|
149
|
-
}) })
|
|
150
|
-
};
|
|
151
|
-
}
|
|
152
|
-
//#endregion
|
|
153
|
-
export { u as n, v as t };
|
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
import "./logger-DMN6TxJJ.js";
|
|
2
|
-
//#region src/utils/client-headers.ts
|
|
3
|
-
var e = "Picked-Client", t = "Picked-Version";
|
|
4
|
-
function n(n, r) {
|
|
5
|
-
return {
|
|
6
|
-
[e]: n,
|
|
7
|
-
[t]: r
|
|
8
|
-
};
|
|
9
|
-
}
|
|
10
|
-
//#endregion
|
|
11
|
-
//#region src/utils/version.ts
|
|
12
|
-
var r = () => "0.0.1-dev.1786065500148", i = "v1";
|
|
13
|
-
function a(e, t) {
|
|
14
|
-
return new URL(`/api/${i}/${t}`, e).toString();
|
|
15
|
-
}
|
|
16
|
-
function o(e) {
|
|
17
|
-
return {
|
|
18
|
-
...n("sdk", r()),
|
|
19
|
-
...e
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
async function s(e, t, n, r) {
|
|
23
|
-
let i = a(e, t);
|
|
24
|
-
return fetch(i, {
|
|
25
|
-
headers: o(n),
|
|
26
|
-
signal: r
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
async function c(e, t, n, r) {
|
|
30
|
-
let i = a(e, t);
|
|
31
|
-
return fetch(i, {
|
|
32
|
-
method: "POST",
|
|
33
|
-
headers: {
|
|
34
|
-
"Content-Type": "application/json",
|
|
35
|
-
...o(r)
|
|
36
|
-
},
|
|
37
|
-
body: JSON.stringify(n)
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
function l(e) {
|
|
41
|
-
return typeof e == "object" && !!e;
|
|
42
|
-
}
|
|
43
|
-
function u(e) {
|
|
44
|
-
return l(e) && "features" in e && Array.isArray(e.features);
|
|
45
|
-
}
|
|
46
|
-
function d(e) {
|
|
47
|
-
return !l(e) || !("experienceId" in e) || !("content" in e) ? !1 : Array.isArray(e.content);
|
|
48
|
-
}
|
|
49
|
-
function f(e) {
|
|
50
|
-
try {
|
|
51
|
-
let t = new URL(e).hostname;
|
|
52
|
-
return t === "localhost" || t === "127.0.0.1" || t === "::1";
|
|
53
|
-
} catch {
|
|
54
|
-
return !1;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
function p(e) {
|
|
58
|
-
if (!l(e) || !("cause" in e)) return !1;
|
|
59
|
-
let { cause: t } = e;
|
|
60
|
-
return !l(t) || !("code" in t) ? !1 : t.code === "ECONNREFUSED";
|
|
61
|
-
}
|
|
62
|
-
async function m(e, t, n) {
|
|
63
|
-
let r = n?.previewToken ? `projects/${t}?preview_token=${encodeURIComponent(n.previewToken)}` : `projects/${t}`, i;
|
|
64
|
-
try {
|
|
65
|
-
i = await s(e, r, n?.headers, n?.signal);
|
|
66
|
-
} catch (t) {
|
|
67
|
-
return f(e) && p(t), null;
|
|
68
|
-
}
|
|
69
|
-
if (!i.ok) return `${i.status.toString()}`, null;
|
|
70
|
-
let a;
|
|
71
|
-
try {
|
|
72
|
-
a = await i.json();
|
|
73
|
-
} catch {
|
|
74
|
-
return null;
|
|
75
|
-
}
|
|
76
|
-
return u(a) ? a : null;
|
|
77
|
-
}
|
|
78
|
-
async function h(e, t, n, r) {
|
|
79
|
-
let i = r?.previewToken ? `projects/${t}/experiences/${n}/content?preview_token=${encodeURIComponent(r.previewToken)}` : `projects/${t}/experiences/${n}/content`, a;
|
|
80
|
-
try {
|
|
81
|
-
a = await s(e, i, r?.headers, r?.signal);
|
|
82
|
-
} catch (t) {
|
|
83
|
-
return f(e) && p(t) || `${n}`, null;
|
|
84
|
-
}
|
|
85
|
-
if (!a.ok) return `${n}${a.status.toString()}`, null;
|
|
86
|
-
let o;
|
|
87
|
-
try {
|
|
88
|
-
o = await a.json();
|
|
89
|
-
} catch {
|
|
90
|
-
return `${n}`, null;
|
|
91
|
-
}
|
|
92
|
-
return d(o) ? o : (`${n}`, null);
|
|
93
|
-
}
|
|
94
|
-
//#endregion
|
|
95
|
-
//#region src/data-source/virtual-data.ts
|
|
96
|
-
function g(e) {
|
|
97
|
-
if (typeof e != "object" || !e || !("projectConfig" in e) || !("experienceContent" in e) || !("manifestMetadata" in e)) return !1;
|
|
98
|
-
let { experienceContent: t } = e;
|
|
99
|
-
return typeof t == "function";
|
|
100
|
-
}
|
|
101
|
-
//#endregion
|
|
102
|
-
//#region src/data-source/registry.ts
|
|
103
|
-
var _ = null;
|
|
104
|
-
function v(e) {
|
|
105
|
-
g(e) && (_ = e);
|
|
106
|
-
}
|
|
107
|
-
function y() {
|
|
108
|
-
return _;
|
|
109
|
-
}
|
|
110
|
-
//#endregion
|
|
111
|
-
export { m as a, n as c, h as i, v as n, c as o, g as r, r as s, y as t };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
require("./logger-CSTvAyyB.cjs");var e=`Picked-Client`,t=`Picked-Version`;function n(n,r){return{[e]:n,[t]:r}}var r=()=>`0.0.1-dev.1786065500148`,i=`v1`;function a(e,t){return new URL(`/api/${i}/${t}`,e).toString()}function o(e){return{...n(`sdk`,r()),...e}}async function s(e,t,n,r){let i=a(e,t);return fetch(i,{headers:o(n),signal:r})}async function c(e,t,n,r){let i=a(e,t);return fetch(i,{method:`POST`,headers:{"Content-Type":`application/json`,...o(r)},body:JSON.stringify(n)})}function l(e){return typeof e==`object`&&!!e}function u(e){return l(e)&&`features`in e&&Array.isArray(e.features)}function d(e){return!l(e)||!(`experienceId`in e)||!(`content`in e)?!1:Array.isArray(e.content)}function f(e){try{let t=new URL(e).hostname;return t===`localhost`||t===`127.0.0.1`||t===`::1`}catch{return!1}}function p(e){if(!l(e)||!(`cause`in e))return!1;let{cause:t}=e;return!l(t)||!(`code`in t)?!1:t.code===`ECONNREFUSED`}async function m(e,t,n){let r=n?.previewToken?`projects/${t}?preview_token=${encodeURIComponent(n.previewToken)}`:`projects/${t}`,i;try{i=await s(e,r,n?.headers,n?.signal)}catch(t){return f(e)&&p(t),null}if(!i.ok)return`${i.status.toString()}`,null;let a;try{a=await i.json()}catch{return null}return u(a)?a:null}async function h(e,t,n,r){let i=r?.previewToken?`projects/${t}/experiences/${n}/content?preview_token=${encodeURIComponent(r.previewToken)}`:`projects/${t}/experiences/${n}/content`,a;try{a=await s(e,i,r?.headers,r?.signal)}catch(t){return f(e)&&p(t)||`${n}`,null}if(!a.ok)return`${n}${a.status.toString()}`,null;let o;try{o=await a.json()}catch{return`${n}`,null}return d(o)?o:(`${n}`,null)}function g(e){if(typeof e!=`object`||!e||!(`projectConfig`in e)||!(`experienceContent`in e)||!(`manifestMetadata`in e))return!1;let{experienceContent:t}=e;return typeof t==`function`}var _=null;function v(e){g(e)&&(_=e)}function y(){return _}Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return m}}),Object.defineProperty(exports,"c",{enumerable:!0,get:function(){return n}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return h}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return v}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return c}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return g}}),Object.defineProperty(exports,"s",{enumerable:!0,get:function(){return r}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return y}});
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import type { ExperienceContentResponse, FetchProjectOptions, ProjectConfig } from '../plugins/dynamic-experiences/types';
|
|
2
|
-
/**
|
|
3
|
-
* Minimal shape check: verifies that `data` is an object with a `features` array.
|
|
4
|
-
*
|
|
5
|
-
* This is the minimum invariant required to prevent runtime crashes when iterating
|
|
6
|
-
* `config.features`. Individual feature and experience shapes are trusted from the API.
|
|
7
|
-
*
|
|
8
|
-
* @param {unknown} data - Unknown API response to validate.
|
|
9
|
-
* @returns {boolean} Whether `data` has the minimum required shape.
|
|
10
|
-
* @example
|
|
11
|
-
* ```typescript
|
|
12
|
-
* if (isProjectConfig(json)) { json.features }
|
|
13
|
-
* ```
|
|
14
|
-
*/
|
|
15
|
-
export declare function isProjectConfig(data: unknown): data is ProjectConfig;
|
|
16
|
-
/**
|
|
17
|
-
* Minimal shape check for a successful experience-content response.
|
|
18
|
-
*
|
|
19
|
-
* @param {unknown} data - Unknown API response to validate.
|
|
20
|
-
* @returns {boolean} Whether `data` has the minimum required shape.
|
|
21
|
-
* @example
|
|
22
|
-
* ```typescript
|
|
23
|
-
* if (isExperienceContentResponse(json)) { useResponse(json) }
|
|
24
|
-
* ```
|
|
25
|
-
*/
|
|
26
|
-
export declare function isExperienceContentResponse(data: unknown): data is ExperienceContentResponse;
|
|
27
|
-
/**
|
|
28
|
-
* Fetches the project configuration from the Picked REST API.
|
|
29
|
-
*
|
|
30
|
-
* Returns `null` on network failure, non-OK responses, or invalid JSON shape.
|
|
31
|
-
* Connection-refused errors from local URLs are suppressed silently.
|
|
32
|
-
*
|
|
33
|
-
* @param {string} apiUrl - Base URL for the Picked API.
|
|
34
|
-
* @param {string} projectId - Project ID to fetch config for.
|
|
35
|
-
* @param {FetchProjectOptions} [options] - Optional headers, preview token, and abort signal.
|
|
36
|
-
* @returns {Promise<ProjectConfig | null>} Validated project config, or `null` on any failure.
|
|
37
|
-
* @example
|
|
38
|
-
* ```typescript
|
|
39
|
-
* const config = await fetchProject('https://api.picked.app', 'proj_123')
|
|
40
|
-
* ```
|
|
41
|
-
*/
|
|
42
|
-
export declare function fetchProject(apiUrl: string, projectId: string, options?: FetchProjectOptions): Promise<ProjectConfig | null>;
|
|
43
|
-
/**
|
|
44
|
-
* Fetches per-experience content from the Picked API.
|
|
45
|
-
*
|
|
46
|
-
* Returns `null` on network failure, non-OK responses, or invalid JSON shape — preserving
|
|
47
|
-
* the failure-tolerant policy: experiences still render, layouts handle null defensively.
|
|
48
|
-
*
|
|
49
|
-
* @param {string} apiUrl - Base URL for the Picked API.
|
|
50
|
-
* @param {string} projectId - Project ID to fetch content for.
|
|
51
|
-
* @param {string} experienceId - Experience ID whose content to fetch.
|
|
52
|
-
* @param {FetchProjectOptions} [options] - Optional headers, preview token, and abort signal.
|
|
53
|
-
* @returns {Promise<ExperienceContentResponse | null>} Validated content response, or `null` on any failure.
|
|
54
|
-
* @example
|
|
55
|
-
* ```typescript
|
|
56
|
-
* const content = await fetchExperienceContent('https://api.picked.app', 'proj_1', 'exp_1')
|
|
57
|
-
* ```
|
|
58
|
-
*/
|
|
59
|
-
export declare function fetchExperienceContent(apiUrl: string, projectId: string, experienceId: string, options?: FetchProjectOptions): Promise<ExperienceContentResponse | null>;
|
|
60
|
-
//# sourceMappingURL=api.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../../src/data-source/api.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EACV,yBAAyB,EACzB,mBAAmB,EACnB,aAAa,EACd,MAAM,sCAAsC,CAAA;AAiC7C;;;;;;;;;;;;GAYG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,IAAI,aAAa,CAEpE;AAED;;;;;;;;;GASG;AACH,wBAAgB,2BAA2B,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,IAAI,yBAAyB,CAM5F;AA8CD;;;;;;;;;;;;;;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;AAED;;;;;;;;;;;;;;;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,CAqC3C"}
|