@picked/client 0.0.73 → 0.0.74
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-DGFHHioX.js +22 -0
- package/dist/api-DrR9JbZX.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/how-to/authenticate-the-cli.md +97 -0
- package/dist/docs/how-to/create-and-revoke-an-api-key.md +7 -2
- package/dist/docs/how-to/debug-with-the-chrome-extension.md +1 -1
- package/dist/docs/how-to/install-the-sdk.md +31 -6
- package/dist/docs/how-to/install-the-vite-plugin.md +22 -9
- package/dist/docs/how-to/read-a-feature-flag.md +1 -1
- package/dist/docs/how-to/read-a-referenced-entry.md +4 -6
- package/dist/docs/how-to/register-a-component.md +2 -2
- package/dist/docs/how-to/register-an-action-handler.md +1 -1
- package/dist/docs/how-to/render-a-step-form.md +3 -4
- package/dist/docs/how-to/server-render-a-page.md +1 -1
- package/dist/docs/how-to/switch-workspaces.md +122 -0
- package/dist/docs/how-to/write-a-predicate.md +1 -1
- package/dist/docs/reference/dashboard/api-keys.mdx +5 -4
- package/dist/docs/reference/delivery-api/workspace-schema.md +74 -0
- package/dist/docs/reference/sdk/content.md +7 -10
- package/dist/docs/reference/sdk/features.md +1 -1
- package/dist/docs/reference/sdk/plugins/dynamic-experiences.md +1 -1
- package/dist/docs/reference/sdk/plugins/window-object.md +1 -1
- package/dist/docs/reference/sdk/ssr/serialize.md +1 -1
- package/dist/docs/reference/sdk/steps.md +3 -4
- package/dist/docs/reference/sdk/type-generation.md +169 -0
- package/dist/docs/reference/tools/cli.md +146 -0
- package/dist/docs/reference/tools/vite-plugin.md +28 -6
- package/dist/docs/tutorials/first-experience.mdx +6 -7
- package/dist/docs/tutorials/first-server-rendered-page.mdx +3 -3
- package/dist/esm/index.js +23 -14
- package/dist/esm/plugins/dynamic-experiences/index.js +5 -4
- package/dist/esm/server/index.js +1 -1
- package/dist/{plugin-DviILBha.js → plugin-B-c2VAl2.js} +24 -20
- package/dist/plugin-B8YrVbNq.cjs +1 -0
- package/dist/{provider-fU4mqyvT.js → provider-HpWMlxa0.js} +2 -1
- package/dist/provider-hQPGEy73.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 +1 -1
- package/dist/types/data-source/api.d.ts.map +1 -1
- package/dist/types/data-source/provider.d.ts +11 -1
- package/dist/types/data-source/provider.d.ts.map +1 -1
- package/dist/types/entities/response/response.d.ts +22 -6
- package/dist/types/entities/response/response.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 +2 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/picked.d.ts +5 -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 +1 -1
- package/dist/types/plugins/dynamic-experiences/plugin.d.ts.map +1 -1
- package/dist/types/plugins/dynamic-experiences/types.d.ts +6 -116
- 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 +1 -1
- package/dist/types/server/index.d.ts.map +1 -1
- package/dist/types/server/serialize.d.ts +11 -1
- 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-BJFZwX5G.js +4 -0
- package/dist/version-DzA5_Ptz.cjs +1 -0
- package/package.json +3 -1
- package/dist/api-B6Ma2KAc.cjs +0 -1
- package/dist/api-BlxGTa53.js +0 -38
- package/dist/plugin-DkSWIASL.cjs +0 -1
- package/dist/provider-C8ONTzzL.cjs +0 -1
- package/dist/registry-BvoKbKKv.cjs +0 -1
- package/dist/registry-ZEiRsEkm.js +0 -74
- 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
|
@@ -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
|
+
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GACP,YAAY,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,GAClC,OAAO,CAAA;AAEf,YAAY,EAAE,oBAAoB,EAAE,CAAA"}
|
|
@@ -6,7 +6,7 @@ export { createExperienceInstance } from '../entities/experience-instance/experi
|
|
|
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,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,k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QG;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, 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;
|
|
@@ -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.74`;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.
|
|
3
|
+
"version": "0.0.74",
|
|
4
4
|
"dependencies": {
|
|
5
|
+
"@picked/delivery-api-client": "0.0.74",
|
|
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",
|
package/dist/api-B6Ma2KAc.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
function e(e,t){return{"Picked-Client":e,"Picked-Version":t}}var t=()=>`0.0.73`,n=`v1`;function r(e,t){return new URL(`/api/${n}/${t}`,e).toString()}function i(n){return{...e(`sdk`,t()),...n}}async function a(e,t,n,a){let o=r(e,t);return fetch(o,{headers:i(n),signal:a})}async function o(e,t,n,a){let o=r(e,t);return fetch(o,{method:`POST`,headers:{"Content-Type":`application/json`,...i(a)},body:JSON.stringify(n)})}Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return e}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return o}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return t}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return a}});
|
package/dist/api-BlxGTa53.js
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
function e(e, t) {
|
|
2
|
-
return {
|
|
3
|
-
"Picked-Client": e,
|
|
4
|
-
"Picked-Version": t
|
|
5
|
-
};
|
|
6
|
-
}
|
|
7
|
-
//#endregion
|
|
8
|
-
//#region src/utils/version.ts
|
|
9
|
-
var t = () => "0.0.73", n = "v1";
|
|
10
|
-
function r(e, t) {
|
|
11
|
-
return new URL(`/api/${n}/${t}`, e).toString();
|
|
12
|
-
}
|
|
13
|
-
function i(n) {
|
|
14
|
-
return {
|
|
15
|
-
...e("sdk", t()),
|
|
16
|
-
...n
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
async function a(e, t, n, a) {
|
|
20
|
-
let o = r(e, t);
|
|
21
|
-
return fetch(o, {
|
|
22
|
-
headers: i(n),
|
|
23
|
-
signal: a
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
async function o(e, t, n, a) {
|
|
27
|
-
let o = r(e, t);
|
|
28
|
-
return fetch(o, {
|
|
29
|
-
method: "POST",
|
|
30
|
-
headers: {
|
|
31
|
-
"Content-Type": "application/json",
|
|
32
|
-
...i(a)
|
|
33
|
-
},
|
|
34
|
-
body: JSON.stringify(n)
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
//#endregion
|
|
38
|
-
export { e as i, o as n, t as r, a as t };
|
package/dist/plugin-DkSWIASL.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.references??[],...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}});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
require("./logger-CSTvAyyB.cjs");const e=require("./registry-BvoKbKKv.cjs");var t=`bundle`,n=`api`;async function r(){try{let t=await import(`virtual:picked/data`);return e.r(t)?t:null}catch{return null}}function i(t){if(t===void 0||e.r(t))return t}function a(a){let{apiUrl:o,projectId:s,previewToken:c,signal:l}=a,u=!!c,d=u?n:a.mode,f=i(u?void 0:a.bundle),p=u?void 0:a.projectConfig,m=a.getContent,h={mode:d??n,manifest:null},g,_,v=new Map;function y(){if(d===n)return Promise.resolve(null);if(f)return Promise.resolve(f);let t=e.t();return t?Promise.resolve(t):(g??=r(),g)}function b(e){h.mode=e?t:n,h.manifest=e?e.manifestMetadata:null}async function x(){if(p)return b(await y()),p;let n=await y();return b(n),n?n.projectConfig:d===t?null:e.a(o,s,{...c!==void 0&&{previewToken:c},...l!==void 0&&{signal:l}})}async function S(n,r){let i=c===void 0?void 0:{previewToken:c};if(m)return m(n,i);let a=await y();if(b(a),a)try{return await a.experienceContent(n,i)}catch{return`${n.id}`,null}if(d===t)return null;let u=r??l;return e.i(o,s,n.id,{...c!==void 0&&{previewToken:c},...u!==void 0&&{signal:u}})}return{meta:h,getProjectConfig:()=>(_??=x(),_),getContent:(e,t)=>{let n=v.get(e.id);if(n)return n;let r=S(e,t?.signal).finally(()=>{v.delete(e.id)});return v.set(e.id,r),r}}}exports.createPickedDataProvider=a;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
require("./logger-CSTvAyyB.cjs");const e=require("./api-B6Ma2KAc.cjs");function t(e){return typeof e==`object`&&!!e}function n(e){return t(e)&&`features`in e&&Array.isArray(e.features)}function r(e){return!t(e)||!(`experienceId`in e)||!(`content`in e)?!1:Array.isArray(e.content)}function i(e){try{let t=new URL(e).hostname;return t===`localhost`||t===`127.0.0.1`||t===`::1`}catch{return!1}}function a(e){if(!t(e)||!(`cause`in e))return!1;let{cause:n}=e;return!t(n)||!(`code`in n)?!1:n.code===`ECONNREFUSED`}async function o(t,r,o){let s=o?.previewToken?`projects/${r}?preview_token=${encodeURIComponent(o.previewToken)}`:`projects/${r}`,c;try{c=await e.t(t,s,o?.headers,o?.signal)}catch(e){return i(t)&&a(e),null}if(!c.ok)return`${c.status.toString()}`,null;let l;try{l=await c.json()}catch{return null}return n(l)?l:null}async function s(t,n,o,s){let c=s?.previewToken?`projects/${n}/experiences/${o}/content?preview_token=${encodeURIComponent(s.previewToken)}`:`projects/${n}/experiences/${o}/content`,l;try{l=await e.t(t,c,s?.headers,s?.signal)}catch(e){return i(t)&&a(e)||`${o}`,null}if(!l.ok)return`${o}${l.status.toString()}`,null;let u;try{u=await l.json()}catch{return`${o}`,null}return r(u)?u:(`${o}`,null)}function c(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 l=null;function u(e){c(e)&&(l=e)}function d(){return l}Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return o}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return u}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return c}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return d}});
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import "./logger-DMN6TxJJ.js";
|
|
2
|
-
import { t as e } from "./api-BlxGTa53.js";
|
|
3
|
-
function t(e) {
|
|
4
|
-
return typeof e == "object" && !!e;
|
|
5
|
-
}
|
|
6
|
-
function n(e) {
|
|
7
|
-
return t(e) && "features" in e && Array.isArray(e.features);
|
|
8
|
-
}
|
|
9
|
-
function r(e) {
|
|
10
|
-
return !t(e) || !("experienceId" in e) || !("content" in e) ? !1 : Array.isArray(e.content);
|
|
11
|
-
}
|
|
12
|
-
function i(e) {
|
|
13
|
-
try {
|
|
14
|
-
let t = new URL(e).hostname;
|
|
15
|
-
return t === "localhost" || t === "127.0.0.1" || t === "::1";
|
|
16
|
-
} catch {
|
|
17
|
-
return !1;
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
function a(e) {
|
|
21
|
-
if (!t(e) || !("cause" in e)) return !1;
|
|
22
|
-
let { cause: n } = e;
|
|
23
|
-
return !t(n) || !("code" in n) ? !1 : n.code === "ECONNREFUSED";
|
|
24
|
-
}
|
|
25
|
-
async function o(t, r, o) {
|
|
26
|
-
let s = o?.previewToken ? `projects/${r}?preview_token=${encodeURIComponent(o.previewToken)}` : `projects/${r}`, c;
|
|
27
|
-
try {
|
|
28
|
-
c = await e(t, s, o?.headers, o?.signal);
|
|
29
|
-
} catch (e) {
|
|
30
|
-
return i(t) && a(e), null;
|
|
31
|
-
}
|
|
32
|
-
if (!c.ok) return `${c.status.toString()}`, null;
|
|
33
|
-
let l;
|
|
34
|
-
try {
|
|
35
|
-
l = await c.json();
|
|
36
|
-
} catch {
|
|
37
|
-
return null;
|
|
38
|
-
}
|
|
39
|
-
return n(l) ? l : null;
|
|
40
|
-
}
|
|
41
|
-
async function s(t, n, o, s) {
|
|
42
|
-
let c = s?.previewToken ? `projects/${n}/experiences/${o}/content?preview_token=${encodeURIComponent(s.previewToken)}` : `projects/${n}/experiences/${o}/content`, l;
|
|
43
|
-
try {
|
|
44
|
-
l = await e(t, c, s?.headers, s?.signal);
|
|
45
|
-
} catch (e) {
|
|
46
|
-
return i(t) && a(e) || `${o}`, null;
|
|
47
|
-
}
|
|
48
|
-
if (!l.ok) return `${o}${l.status.toString()}`, null;
|
|
49
|
-
let u;
|
|
50
|
-
try {
|
|
51
|
-
u = await l.json();
|
|
52
|
-
} catch {
|
|
53
|
-
return `${o}`, null;
|
|
54
|
-
}
|
|
55
|
-
return r(u) ? u : (`${o}`, null);
|
|
56
|
-
}
|
|
57
|
-
//#endregion
|
|
58
|
-
//#region src/data-source/virtual-data.ts
|
|
59
|
-
function c(e) {
|
|
60
|
-
if (typeof e != "object" || !e || !("projectConfig" in e) || !("experienceContent" in e) || !("manifestMetadata" in e)) return !1;
|
|
61
|
-
let { experienceContent: t } = e;
|
|
62
|
-
return typeof t == "function";
|
|
63
|
-
}
|
|
64
|
-
//#endregion
|
|
65
|
-
//#region src/data-source/registry.ts
|
|
66
|
-
var l = null;
|
|
67
|
-
function u(e) {
|
|
68
|
-
c(e) && (l = e);
|
|
69
|
-
}
|
|
70
|
-
function d() {
|
|
71
|
-
return l;
|
|
72
|
-
}
|
|
73
|
-
//#endregion
|
|
74
|
-
export { o as a, s as i, u as n, c as r, d as t };
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Performs a GET request against the Picked API.
|
|
3
|
-
*
|
|
4
|
-
* @param {string} baseUrl - The API origin.
|
|
5
|
-
* @param {string} path - The path relative to `/api/v1/`.
|
|
6
|
-
* @param {Record<string, string>} [headers] - Optional header overrides.
|
|
7
|
-
* @param {AbortSignal} [signal] - Optional abort signal, such as a timeout deadline.
|
|
8
|
-
* @returns {Promise<Response>} The fetch response.
|
|
9
|
-
* @example
|
|
10
|
-
* const response = await get('https://api.picked.app', 'projects/p1')
|
|
11
|
-
*/
|
|
12
|
-
export declare function get(baseUrl: string, path: string, headers?: Record<string, string>, signal?: AbortSignal): Promise<Response>;
|
|
13
|
-
/**
|
|
14
|
-
* Performs a JSON POST request against the Picked API.
|
|
15
|
-
*
|
|
16
|
-
* @param {string} baseUrl - The API origin.
|
|
17
|
-
* @param {string} path - The path relative to `/api/v1/`.
|
|
18
|
-
* @param {unknown} data - The request body, serialised as JSON.
|
|
19
|
-
* @param {Record<string, string>} [headers] - Optional header overrides.
|
|
20
|
-
* @returns {Promise<Response>} The fetch response.
|
|
21
|
-
* @example
|
|
22
|
-
* const response = await post('https://api.picked.app', 'events', { type: 'load' })
|
|
23
|
-
*/
|
|
24
|
-
export declare function post(baseUrl: string, path: string, data: unknown, headers?: Record<string, string>): Promise<Response>;
|
|
25
|
-
//# sourceMappingURL=api.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../../src/utils/api.ts"],"names":[],"mappings":"AA+BA;;;;;;;;;;GAUG;AACH,wBAAsB,GAAG,CACvB,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAChC,MAAM,CAAC,EAAE,WAAW,GACnB,OAAO,CAAC,QAAQ,CAAC,CAInB;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,IAAI,CACxB,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,OAAO,EACb,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC/B,OAAO,CAAC,QAAQ,CAAC,CAQnB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"client-headers.d.ts","sourceRoot":"","sources":["../../../src/utils/client-headers.ts"],"names":[],"mappings":"AAGA,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAKzF"}
|