@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
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Reading `reference` field values out of a delivered content blob.
|
|
3
|
+
*
|
|
4
|
+
* A `reference` field arrives as a pointer at another Content record rather than
|
|
5
|
+
* as the record itself. The referenced record travels separately and is
|
|
6
|
+
* registered into the content index under its own id, so resolving a pointer is
|
|
7
|
+
* a registry lookup — see `useReference` (`@picked/react`) and `getReference`
|
|
8
|
+
* (`@picked/svelte`), which is what most consumers should reach for.
|
|
9
|
+
*
|
|
10
|
+
* This module is the framework-agnostic half: readers that turn a raw field
|
|
11
|
+
* value into the id (or ids) to look up, tolerating both a single value and the
|
|
12
|
+
* array a repeatable field delivers, plus the store derivations the framework
|
|
13
|
+
* bindings wrap.
|
|
14
|
+
*/
|
|
15
|
+
import { type Store } from 'effector';
|
|
16
|
+
import type { Content, ContentsStore } from './content';
|
|
17
|
+
/** A pointer at another Content record, as delivered inside a `reference` field. */
|
|
18
|
+
export interface ContentReference {
|
|
19
|
+
/** Id of the referenced Content record, to look up in the content index. */
|
|
20
|
+
contentEntryId: string;
|
|
21
|
+
/** The `key` of the Content Model the target belongs to, or `null` when unresolved. */
|
|
22
|
+
contentModelKey?: string | null;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Narrows an arbitrary field value to a {@link ContentReference}.
|
|
26
|
+
*
|
|
27
|
+
* A pointer that still carries inline `data` matches: the delivery surface emits
|
|
28
|
+
* inline data alongside the separate record while that format is retired, and
|
|
29
|
+
* both shapes address the same record.
|
|
30
|
+
*
|
|
31
|
+
* @param {unknown} value - The raw value read from a content blob's `data`.
|
|
32
|
+
* @returns {boolean} Whether `value` is a reference pointer.
|
|
33
|
+
* @example
|
|
34
|
+
* ```typescript
|
|
35
|
+
* if (isContentReference(content.author)) { content.author.contentEntryId }
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
export declare function isContentReference(value: unknown): value is ContentReference;
|
|
39
|
+
/**
|
|
40
|
+
* Reads the referenced Content record id from a single `reference` field value.
|
|
41
|
+
*
|
|
42
|
+
* @param {unknown} value - The raw value read from a content blob's `data`.
|
|
43
|
+
* @returns {string | null} The referenced id, or `null` when the field is unset or not a reference.
|
|
44
|
+
* @example
|
|
45
|
+
* ```typescript
|
|
46
|
+
* const authorId = readReferenceId(content.author)
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
export declare function readReferenceId(value: unknown): string | null;
|
|
50
|
+
/**
|
|
51
|
+
* Reads every referenced Content record id from a `reference` field, whether it
|
|
52
|
+
* was authored as repeatable or not. Values that are not references are dropped,
|
|
53
|
+
* so the result is always a list of ids that can be looked up.
|
|
54
|
+
*
|
|
55
|
+
* @param {unknown} value - The raw value read from a content blob's `data`.
|
|
56
|
+
* @returns {string[]} The referenced ids, in field order.
|
|
57
|
+
* @example
|
|
58
|
+
* ```typescript
|
|
59
|
+
* const authorIds = readReferenceIds(content.authors)
|
|
60
|
+
* ```
|
|
61
|
+
*/
|
|
62
|
+
export declare function readReferenceIds(value: unknown): string[];
|
|
63
|
+
/**
|
|
64
|
+
* Derives a store resolving a single `reference` field value against the content
|
|
65
|
+
* registry.
|
|
66
|
+
*
|
|
67
|
+
* Reads the registry index rather than a per-id store so an unset field, an
|
|
68
|
+
* unregistered target, and a target registered after first paint all flow
|
|
69
|
+
* through one reactive path. The framework bindings (`useReference`,
|
|
70
|
+
* `getReference`) wrap this; call it directly only outside React and Svelte.
|
|
71
|
+
*
|
|
72
|
+
* @param {ContentsStore} contents - The client's content registry.
|
|
73
|
+
* @param {unknown} value - The raw `reference` value, or an Effector store carrying one. A
|
|
74
|
+
* store keeps the lookup live when the field arrives after this call.
|
|
75
|
+
* @returns {Store<Content | null>} The referenced record, or `null` when the field is unset or its target is not registered.
|
|
76
|
+
* @example
|
|
77
|
+
* ```typescript
|
|
78
|
+
* const author = deriveReference(client.contents, content.author)
|
|
79
|
+
* ```
|
|
80
|
+
*/
|
|
81
|
+
export declare function deriveReference(contents: ContentsStore, value: unknown): Store<Content | null>;
|
|
82
|
+
/**
|
|
83
|
+
* Derives a store resolving a repeatable `reference` field against the content
|
|
84
|
+
* registry, in field order. A single (non-repeatable) value resolves to a
|
|
85
|
+
* one-element list.
|
|
86
|
+
*
|
|
87
|
+
* The list is dense: a pointer whose target is not registered — deleted, cut off
|
|
88
|
+
* by the reference depth cap, or belonging to another workspace — is skipped
|
|
89
|
+
* rather than held as a hole, so consumers can iterate without a null check.
|
|
90
|
+
*
|
|
91
|
+
* @param {ContentsStore} contents - The client's content registry.
|
|
92
|
+
* @param {unknown} value - The raw `reference` value, or an Effector store carrying one. A
|
|
93
|
+
* store keeps the lookup live when the field arrives after this call.
|
|
94
|
+
* @returns {Store<Content[]>} The referenced records that resolved.
|
|
95
|
+
* @example
|
|
96
|
+
* ```typescript
|
|
97
|
+
* const authors = deriveReferences(client.contents, content.authors)
|
|
98
|
+
* ```
|
|
99
|
+
*/
|
|
100
|
+
export declare function deriveReferences(contents: ContentsStore, value: unknown): Store<Content[]>;
|
|
101
|
+
//# sourceMappingURL=reference.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reference.d.ts","sourceRoot":"","sources":["../../../../src/entities/content/reference.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,EAAe,KAAK,KAAK,EAAE,MAAM,UAAU,CAAA;AAClD,OAAO,KAAK,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAA;AAEvD,oFAAoF;AACpF,MAAM,WAAW,gBAAgB;IAC/B,4EAA4E;IAC5E,cAAc,EAAE,MAAM,CAAA;IACtB,uFAAuF;IACvF,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAChC;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,gBAAgB,CAQ5E;AAED;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAE7D;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,EAAE,CAUzD;AAiCD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,aAAa,EAAE,KAAK,EAAE,OAAO,GAAG,KAAK,CAAC,OAAO,GAAG,IAAI,CAAC,CAS9F;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,aAAa,EAAE,KAAK,EAAE,OAAO,GAAG,KAAK,CAAC,OAAO,EAAE,CAAC,CAS1F"}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { type Store } from 'effector';
|
|
3
3
|
import type { Picked } from '../../picked';
|
|
4
4
|
import type { Field, FieldValue } from '../field/field';
|
|
5
|
+
import type { FieldKeys, FieldValueFor } from '../../schema-registry';
|
|
5
6
|
import { type ValidationError } from './response-validation';
|
|
6
7
|
export type { ValidationError } from './response-validation';
|
|
7
8
|
export type ResponsesStore = ReturnType<typeof createResponseIndex>;
|
|
@@ -19,10 +20,10 @@ declare const createResponseIndexFactory: ({ client }: {
|
|
|
19
20
|
};
|
|
20
21
|
clearAll: import("effector").EventCallable<void>;
|
|
21
22
|
clear: import("effector").EventCallable<string>;
|
|
22
|
-
commit: (responsesToCommit:
|
|
23
|
+
commit: <T extends CommitResponses>(responsesToCommit: T & ValidateResponses<T>) => Promise<{
|
|
23
24
|
errors: ValidationError[];
|
|
24
25
|
}>;
|
|
25
|
-
getResponsesToCommit: (responsesToCommit:
|
|
26
|
+
getResponsesToCommit: <T extends CommitResponses>(responsesToCommit: T & ValidateResponses<T>) => Promise<{
|
|
26
27
|
responsesToCommit: CommitResponses;
|
|
27
28
|
validationErrors: ValidationError[];
|
|
28
29
|
}>;
|
|
@@ -34,20 +35,35 @@ declare const createResponseIndexFactory: ({ client }: {
|
|
|
34
35
|
[fieldKey: string]: FieldValue;
|
|
35
36
|
}>;
|
|
36
37
|
getByFieldId: (id: Field['id']) => Store<FieldValue>;
|
|
37
|
-
getByFieldKey: (key:
|
|
38
|
+
getByFieldKey: <K extends string>(key: K) => Store<FieldValueFor<K>>;
|
|
38
39
|
getByFieldName: (fieldName: Field['name']) => Store<FieldValue>;
|
|
39
40
|
};
|
|
40
41
|
/**
|
|
41
42
|
* Creates a response index instance bound to the given client.
|
|
42
43
|
*
|
|
43
|
-
* @
|
|
44
|
-
* @
|
|
44
|
+
* @template T
|
|
45
|
+
* @param {T} params - Configuration including the Picked client instance.
|
|
46
|
+
* @returns {ReturnType<typeof createResponseIndexFactory>} The response index with register, commit, and lookup methods.
|
|
45
47
|
* @example
|
|
46
48
|
* ```typescript
|
|
47
49
|
* const responses = createResponseIndex({ client })
|
|
48
50
|
* ```
|
|
49
51
|
*/
|
|
50
52
|
export declare function createResponseIndex<T extends Parameters<typeof createResponseIndexFactory>[0]>(params: T): ReturnType<typeof createResponseIndexFactory>;
|
|
51
|
-
/**
|
|
53
|
+
/** Loose transport shape: a record keyed by field `key`. Used internally and by the form bridge. */
|
|
52
54
|
export type CommitResponses = Record<string, FieldValue>;
|
|
55
|
+
/**
|
|
56
|
+
* Validates a response payload against the generated schema. For each key the caller actually
|
|
57
|
+
* provides, a workspace-known field key is narrowed to its schema value type while any other key
|
|
58
|
+
* stays a permissive `FieldValue`. Mapping over the caller's own keys (rather than requiring the
|
|
59
|
+
* full field set) is what lets typed literals be checked without breaking dynamic, out-of-schema
|
|
60
|
+
* payloads built by the form bridge.
|
|
61
|
+
*
|
|
62
|
+
* @template T - The inferred payload type.
|
|
63
|
+
* @example
|
|
64
|
+
* type Checked = ValidateResponses<{ 'email-address': string }>
|
|
65
|
+
*/
|
|
66
|
+
export type ValidateResponses<T> = {
|
|
67
|
+
[K in keyof T]: K extends FieldKeys ? FieldValueFor<K> : FieldValue;
|
|
68
|
+
};
|
|
53
69
|
//# sourceMappingURL=response.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"response.d.ts","sourceRoot":"","sources":["../../../../src/entities/response/response.ts"],"names":[],"mappings":"AAAA,mGAAmG;AACnG,OAAO,EAAiE,KAAK,KAAK,EAAE,MAAM,UAAU,CAAA;AAEpG,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAC1C,OAAO,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;
|
|
1
|
+
{"version":3,"file":"response.d.ts","sourceRoot":"","sources":["../../../../src/entities/response/response.ts"],"names":[],"mappings":"AAAA,mGAAmG;AACnG,OAAO,EAAiE,KAAK,KAAK,EAAE,MAAM,UAAU,CAAA;AAEpG,OAAO,KAAK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CAAC,UAAU,CAAC;CA2BpE,CAAA;AAEF;;;;;;;;;;GAUG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,SAAS,UAAU,CAAC,OAAO,0BAA0B,CAAC,CAAC,CAAC,CAAC,EAC5F,MAAM,EAAE,CAAC,GACR,UAAU,CAAC,OAAO,0BAA0B,CAAC,CAE/C;AAED,oGAAoG;AACpG,MAAM,MAAM,eAAe,GAAG,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAA;AAExD;;;;;;;;;;GAUG;AACH,MAAM,MAAM,iBAAiB,CAAC,CAAC,IAAI;KAChC,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,SAAS,SAAS,GAAG,aAAa,CAAC,CAAC,CAAC,GAAG,UAAU;CACpE,CAAA"}
|
package/dist/types/exports.d.ts
CHANGED
|
@@ -14,6 +14,8 @@ export { evaluateRuleLogic } from './utils/rules-logic';
|
|
|
14
14
|
export { getPickedConfig } from './utils/picked-config';
|
|
15
15
|
export { lazyComponent, isLazyLoader } from './entities/component/lazyComponent';
|
|
16
16
|
export { createPluginEffect } from './entities/plugin/plugin';
|
|
17
|
+
export { deriveReference, deriveReferences, isContentReference, readReferenceId, readReferenceIds, } from './entities/content/reference';
|
|
18
|
+
export type { ContentReference } from './entities/content/reference';
|
|
17
19
|
/**
|
|
18
20
|
* Creates a new Picked client instance and binds it to the window object.
|
|
19
21
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exports.d.ts","sourceRoot":"","sources":["../../src/exports.ts"],"names":[],"mappings":"AAAA,8IAA8I;AAC9I,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAA;AACnD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AAGjC,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC1C,OAAO,EACL,gBAAgB,EAChB,uBAAuB,EACvB,kBAAkB,EAClB,yBAAyB,EACzB,oBAAoB,GACrB,MAAM,2BAA2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;AAC/B,mBAAmB,iBAAiB,CAAA;AACpC,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AACvD,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAA;AAChF,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAA;AAC7D,OAAO,EACL,eAAe,EACf,gBAAgB,EAChB,kBAAkB,EAClB,eAAe,EACf,gBAAgB,GACjB,MAAM,8BAA8B,CAAA;AACrC,YAAY,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAA;AAEpE;;;;;;;;;;GAUG;AACH,eAAO,MAAM,YAAY,YAAa,mBAAmB,KAAG,MAI3D,CAAA;AAED,YAAY,EACV,uBAAuB,EACvB,qBAAqB,GACtB,MAAM,kCAAkC,CAAA"}
|
|
@@ -2,18 +2,47 @@
|
|
|
2
2
|
import { type Event, type EventCallable, type Store } from 'effector';
|
|
3
3
|
import type { ExperienceInstance } from '../entities/experience-instance/experience-instance';
|
|
4
4
|
import type { ExperienceStep } from '../entities/step/step';
|
|
5
|
-
import type { Field
|
|
5
|
+
import type { Field } from '../entities/field/field';
|
|
6
6
|
import type { ValidationError } from '../entities/response/response';
|
|
7
7
|
import type { Picked } from '../picked';
|
|
8
|
+
import type { FieldValueFor } from '../schema-registry';
|
|
8
9
|
export type SubmitEventWithCurrentTarget = SubmitEvent & {
|
|
9
10
|
currentTarget: EventTarget & HTMLFormElement;
|
|
10
11
|
};
|
|
12
|
+
/**
|
|
13
|
+
* Callback fired after a successful commit, receiving the committed `data` keyed by
|
|
14
|
+
* the step's field ids.
|
|
15
|
+
*
|
|
16
|
+
* The `data` value type is a schema-typed *view* over runtime-`FieldValue` data — the
|
|
17
|
+
* same soundness posture as `getField`/`getByFieldKey`. The registry narrows each field
|
|
18
|
+
* id to its declared value type, but the values are not runtime-validated against it. The
|
|
19
|
+
* default `TFieldIds = string` resolves to `Record<string, FieldValue>`, so untyped
|
|
20
|
+
* consumers keep the broad value type.
|
|
21
|
+
*/
|
|
11
22
|
export type SuccessCallback<TFieldIds extends string = string> = (options: {
|
|
12
|
-
data:
|
|
23
|
+
data: {
|
|
24
|
+
[P in TFieldIds]: FieldValueFor<P>;
|
|
25
|
+
};
|
|
13
26
|
stopNavigation: EventCallable<void>;
|
|
14
27
|
}) => void | Promise<void>;
|
|
15
28
|
export type ErrorCallback = (errors: ValidationError[]) => void | Promise<void>;
|
|
16
|
-
|
|
29
|
+
/**
|
|
30
|
+
* Callback fired before commit, receiving the parsed `data` keyed by the step's field
|
|
31
|
+
* ids and optionally returning a transformed copy.
|
|
32
|
+
*
|
|
33
|
+
* The `data` value type is a schema-typed *view* over runtime-`FieldValue` data — the
|
|
34
|
+
* same soundness posture as `getField`/`getByFieldKey`. The registry narrows each field
|
|
35
|
+
* id to its declared value type, but the values are not runtime-validated against it. The
|
|
36
|
+
* default `TFieldIds = string` resolves to `Record<string, FieldValue>`, so untyped
|
|
37
|
+
* consumers keep the broad value type.
|
|
38
|
+
*/
|
|
39
|
+
export type SubmitCallback<TFieldIds extends string = string> = (data: {
|
|
40
|
+
[P in TFieldIds]: FieldValueFor<P>;
|
|
41
|
+
}) => {
|
|
42
|
+
[P in TFieldIds]: FieldValueFor<P>;
|
|
43
|
+
} | void | Promise<{
|
|
44
|
+
[P in TFieldIds]: FieldValueFor<P>;
|
|
45
|
+
} | void>;
|
|
17
46
|
/**
|
|
18
47
|
* Latest-wins submit callback slots accepted by the framework adapters.
|
|
19
48
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-submit-pipeline.d.ts","sourceRoot":"","sources":["../../../src/form/create-submit-pipeline.ts"],"names":[],"mappings":"AAAA,gGAAgG;AAChG,OAAO,EAOL,KAAK,KAAK,EACV,KAAK,aAAa,EAClB,KAAK,KAAK,EACX,MAAM,UAAU,CAAA;AACjB,OAAO,KAAK,EAAE,kBAAkB,EAA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IAC1B;;;OAGG;IACH,wBAAwB,EAAE,KAAK,CAAC,eAAe,EAAE,CAAC,CAAA;CACnD;AAyED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,oBAAoB,CAAC,EACnC,MAAM,EACN,kBAAkB,EAClB,MAAM,EACN,KAAK,EACL,SAAS,EACT,WAAW,EACX,YAAY,GACb,EAAE,oBAAoB,GAAG,cAAc,CAoRvC"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export type * from './client';
|
|
|
4
4
|
export type * from './entities/action/action';
|
|
5
5
|
export type * from './entities/condition/condition';
|
|
6
6
|
export type * from './entities/content/content';
|
|
7
|
+
export type * from './entities/content/reference';
|
|
7
8
|
export type * from './entities/component/component';
|
|
8
9
|
export type * from './entities/component/lazyComponent';
|
|
9
10
|
export type * from './entities/experience-instance/experience-instance';
|
|
@@ -20,4 +21,6 @@ export type * from './utils/events';
|
|
|
20
21
|
export type * from './utils/search-params';
|
|
21
22
|
export type * from './entities/response/response';
|
|
22
23
|
export { Picked } from './picked';
|
|
24
|
+
export type { ActionKeys, ContentForStep, ExperienceKeys, FeatureKeys, FieldKeys, FieldKeysForStep, FieldValueFor, KnownActionKeys, KnownExperienceKeys, KnownFeatureKeys, KnownFieldKeys, KnownStepKeys, PickedSchemaRegistry, ReferencedContent, StepContentModelsMap, StepKeys, StepLayoutContent, TypedContent, } from './schema-registry';
|
|
25
|
+
export { toTypedContentStore } from './typed-content';
|
|
23
26
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,4GAA4G;AAC5G,cAAc,WAAW,CAAA;AACzB,mBAAmB,UAAU,CAAA;AAC7B,mBAAmB,0BAA0B,CAAA;AAC7C,mBAAmB,gCAAgC,CAAA;AACnD,mBAAmB,4BAA4B,CAAA;AAC/C,mBAAmB,gCAAgC,CAAA;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EACV,cAAc,EACd,cAAc,EACd,WAAW,EACX,SAAS,EACT,gBAAgB,EAChB,aAAa,EACb,eAAe,EACf,mBAAmB,EACnB,gBAAgB,EAChB,cAAc,EACd,aAAa,EACb,oBAAoB,EACpB,iBAAiB,EACjB,oBAAoB,EACpB,QAAQ,EACR,iBAAiB,EACjB,YAAY,GACb,MAAM,mBAAmB,CAAA;AAC1B,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAA"}
|
package/dist/types/picked.d.ts
CHANGED
|
@@ -16,7 +16,7 @@ import { type EventBusPayload, type EventHistoryStore } from './utils/events';
|
|
|
16
16
|
import type { Field } from './entities/field/field';
|
|
17
17
|
import type { ExperienceStep } from './entities/step/step';
|
|
18
18
|
import type { Content, ContentDataPatch } from './entities/content/content';
|
|
19
|
-
import type { ContentLoader } from './plugins/dynamic-experiences/types';
|
|
19
|
+
import type { ContentLoader, ExperienceContentResponse, ProjectConfig } from './plugins/dynamic-experiences/types';
|
|
20
20
|
import type { Action } from './entities/action/action';
|
|
21
21
|
import { type Condition } from './entities/condition/condition';
|
|
22
22
|
import type { SessionEntity } from './entities/session/session';
|
|
@@ -44,6 +44,21 @@ export declare class Picked {
|
|
|
44
44
|
* resolvable; remains `null` when the SDK is using the runtime API path.
|
|
45
45
|
*/
|
|
46
46
|
dataSource: PickedDataSource | null;
|
|
47
|
+
/**
|
|
48
|
+
* `versionId` of the SSR snapshot this client was seeded from, set by the framework
|
|
49
|
+
* providers' `seedFromSnapshot`. `null` when no snapshot was seeded — a browser-only client,
|
|
50
|
+
* or a route that rendered without one.
|
|
51
|
+
*/
|
|
52
|
+
seededVersionId: string | null;
|
|
53
|
+
/**
|
|
54
|
+
* Set when a resolved project config disagrees with the seeded snapshot's `versionId`. The
|
|
55
|
+
* snapshot stays authoritative (it is what the server rendered the markup from) and the
|
|
56
|
+
* resolved config is dropped, so this records the divergence rather than hiding it.
|
|
57
|
+
*/
|
|
58
|
+
versionSkew: {
|
|
59
|
+
seeded: string;
|
|
60
|
+
resolved: string;
|
|
61
|
+
} | null;
|
|
47
62
|
/**
|
|
48
63
|
* Content fetcher selected by `dynamicExperiencesPlugin`'s resolution chain. Called
|
|
49
64
|
* by each experience's `prepareExperienceContentFx` (fired in parallel with
|
|
@@ -59,6 +74,7 @@ export declare class Picked {
|
|
|
59
74
|
*/
|
|
60
75
|
previewEmbedderOrigins: string[] | null;
|
|
61
76
|
private readonly plugins;
|
|
77
|
+
private readonly dataProviders;
|
|
62
78
|
readonly eventBus: EventCallable<EventBusPayload>;
|
|
63
79
|
readonly events: EventHistoryStore;
|
|
64
80
|
readonly projectId: string;
|
|
@@ -182,10 +198,10 @@ export declare class Picked {
|
|
|
182
198
|
};
|
|
183
199
|
clearAll: EventCallable<void>;
|
|
184
200
|
clear: EventCallable<string>;
|
|
185
|
-
commit: (responsesToCommit: import(".").
|
|
201
|
+
commit: <T extends import(".").CommitResponses>(responsesToCommit: T & import(".").ValidateResponses<T>) => Promise<{
|
|
186
202
|
errors: import(".").ValidationError[];
|
|
187
203
|
}>;
|
|
188
|
-
getResponsesToCommit: (responsesToCommit: import(".").
|
|
204
|
+
getResponsesToCommit: <T extends import(".").CommitResponses>(responsesToCommit: T & import(".").ValidateResponses<T>) => Promise<{
|
|
189
205
|
responsesToCommit: import(".").CommitResponses;
|
|
190
206
|
validationErrors: import(".").ValidationError[];
|
|
191
207
|
}>;
|
|
@@ -197,7 +213,7 @@ export declare class Picked {
|
|
|
197
213
|
[fieldKey: string]: import(".").FieldValue;
|
|
198
214
|
}>;
|
|
199
215
|
getByFieldId: (id: Field['id']) => Store<import(".").FieldValue>;
|
|
200
|
-
getByFieldKey: (key:
|
|
216
|
+
getByFieldKey: <K extends string>(key: K) => Store<import("./schema-registry").FieldValueFor<K>>;
|
|
201
217
|
getByFieldName: (fieldName: Field['name']) => Store<import(".").FieldValue>;
|
|
202
218
|
};
|
|
203
219
|
readonly steps: {
|
|
@@ -262,6 +278,54 @@ export declare class Picked {
|
|
|
262
278
|
context?: Record<string, unknown>;
|
|
263
279
|
}, string, Error>;
|
|
264
280
|
constructor(options: CreateClientOptions);
|
|
281
|
+
/**
|
|
282
|
+
* Resolves the data provider backing a given preview token, building it once per token.
|
|
283
|
+
*
|
|
284
|
+
* @param {string | undefined} previewToken - Preview token for the caller, when there is one.
|
|
285
|
+
* @returns {Promise<PickedDataProvider>} The provider for that token.
|
|
286
|
+
* @example
|
|
287
|
+
* const provider = await client.dataProviderFor(undefined)
|
|
288
|
+
*/
|
|
289
|
+
private dataProviderFor;
|
|
290
|
+
/**
|
|
291
|
+
* Resolves this project's configuration.
|
|
292
|
+
*
|
|
293
|
+
* Reads the build-time bundle when one registered itself, and the Picked API otherwise. A
|
|
294
|
+
* preview token forces the API, because preview renders unpublished data no bundle can hold.
|
|
295
|
+
* Deduplicated per token, so several callers in one request cost one resolution.
|
|
296
|
+
*
|
|
297
|
+
* @param {object} [options] - Per-call resolution inputs.
|
|
298
|
+
* @param {string} [options.previewToken] - Preview token, forcing a live read.
|
|
299
|
+
* @param {AbortSignal} [options.signal] - Signal applied to an API read.
|
|
300
|
+
* @returns {Promise<ProjectConfig>} The project configuration.
|
|
301
|
+
* @throws {Error} When the configuration cannot be resolved from any source.
|
|
302
|
+
* @example
|
|
303
|
+
* const config = await client.getProjectConfig()
|
|
304
|
+
*/
|
|
305
|
+
getProjectConfig(options?: {
|
|
306
|
+
previewToken?: string;
|
|
307
|
+
signal?: AbortSignal;
|
|
308
|
+
}): Promise<ProjectConfig>;
|
|
309
|
+
/**
|
|
310
|
+
* Resolves one experience's CMS content, from the same source as the configuration.
|
|
311
|
+
*
|
|
312
|
+
* @param {{ id: string; key: string }} experience - The experience to resolve content for.
|
|
313
|
+
* @param {string} experience.id - Experience id, which keys bundled content.
|
|
314
|
+
* @param {string} experience.key - Experience key, for a content loader that prefers it.
|
|
315
|
+
* @param {object} [options] - Per-call resolution inputs.
|
|
316
|
+
* @param {string} [options.previewToken] - Preview token, forcing a live read.
|
|
317
|
+
* @param {AbortSignal} [options.signal] - Deadline for this call's API read, if it makes one.
|
|
318
|
+
* @returns {Promise<ExperienceContentResponse | null>} The content, or `null` when it has none.
|
|
319
|
+
* @example
|
|
320
|
+
* const content = await client.getExperienceContent({ id: 'exp_1', key: 'promo' })
|
|
321
|
+
*/
|
|
322
|
+
getExperienceContent(experience: {
|
|
323
|
+
id: string;
|
|
324
|
+
key: string;
|
|
325
|
+
}, options?: {
|
|
326
|
+
previewToken?: string;
|
|
327
|
+
signal?: AbortSignal;
|
|
328
|
+
}): Promise<ExperienceContentResponse | null>;
|
|
265
329
|
/**
|
|
266
330
|
* Lazily starts the preview channel when this frame is a live-preview session: the outbound
|
|
267
331
|
* bridge, which reports the frame's URL to the dashboard, and the inbound receiver, which applies
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"picked.d.ts","sourceRoot":"","sources":["../../src/picked.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,OAAO,EAGL,KAAK,MAAM,EACX,KAAK,aAAa,EAClB,KAAK,KAAK,EACV,KAAK,aAAa,EACnB,MAAM,UAAU,CAAA;AACjB,OAAO,EAEL,KAAK,UAAU,EACf,KAAK,uBAAuB,EAC7B,MAAM,kCAAkC,CAAA;AACzC,OAAO,EAAE,KAAK,MAAM,EAAE,KAAK,iBAAiB,EAAe,MAAM,0BAA0B,CAAA;AAC3F,OAAO,EAAE,KAAK,mBAAmB,EAAE,MAAM,UAAU,CAAA;AACnD,OAAO,EACL,KAAK,gBAAgB,EAGtB,MAAM,gCAAgC,CAAA;AACvC,OAAO,EAEL,KAAK,SAAS,EAEf,MAAM,gCAAgC,CAAA;AACvC,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AACvC,OAAO,EAA4B,KAAK,aAAa,EAAE,MAAM,4BAA4B,CAAA;AACzF,OAAO,EAA6B,KAAK,uBAAuB,EAAE,MAAM,yBAAyB,CAAA;AACjG,OAAO,EAAE,KAAK,gBAAgB,EAA0B,MAAM,iC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AAC,YAAY;IAsBpB,OAAO,CAAC,aAAa;IAsCrB,OAAO,CAAC,eAAe;IAgBvB,OAAO,CAAC,YAAY;IAgBpB,OAAO,CAAC,eAAe;IAWvB,eAAe,eAAgB,MAAM,KAAG,iBAAiB,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAE1F;CACF"}
|
package/dist/types/ping.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import type { Picked } from './picked';
|
|
2
2
|
/**
|
|
3
3
|
* Pings the server to track the last time the library was loaded.
|
|
4
|
-
* Implements rate limiting and supports Vercel branch deployments.
|
|
5
4
|
*
|
|
6
|
-
* @param
|
|
7
|
-
* @returns
|
|
5
|
+
* @param {Picked} client - The active Picked client instance.
|
|
6
|
+
* @returns {Promise<boolean>} Whether the ping succeeded.
|
|
7
|
+
* @example
|
|
8
|
+
* await ping(client)
|
|
8
9
|
*/
|
|
9
10
|
export declare const ping: (client: Picked) => Promise<boolean>;
|
|
10
11
|
//# sourceMappingURL=ping.d.ts.map
|
package/dist/types/ping.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ping.d.ts","sourceRoot":"","sources":["../../src/ping.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ping.d.ts","sourceRoot":"","sources":["../../src/ping.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AAKtC;;;;;;;GAOG;AACH,eAAO,MAAM,IAAI,WAAkB,MAAM,KAAG,OAAO,CAAC,OAAO,CAoC1D,CAAA"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/** @file Public exports for the dynamic-experiences plugin (project config + per-experience content resolution). */
|
|
2
2
|
export { dynamicExperiencesPlugin, fetchExperienceContent, fetchProject } from './plugin';
|
|
3
|
-
export { createClientHeaders } from '
|
|
3
|
+
export { createClientHeaders, fetchSchema } from '@picked/delivery-api-client';
|
|
4
|
+
export { registerPickedBundle } from '../../data-source/registry';
|
|
4
5
|
export type * from './types';
|
|
5
6
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/plugins/dynamic-experiences/index.ts"],"names":[],"mappings":"AAAA,oHAAoH;AACpH,OAAO,EAAE,wBAAwB,EAAE,sBAAsB,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/plugins/dynamic-experiences/index.ts"],"names":[],"mappings":"AAAA,oHAAoH;AACpH,OAAO,EAAE,wBAAwB,EAAE,sBAAsB,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;AAGzF,OAAO,EAAE,mBAAmB,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAA;AAI9E,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAA;AACjE,mBAAmB,SAAS,CAAA"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Plugin } from '../../entities/plugin/plugin';
|
|
2
2
|
import type { Picked } from '../../picked';
|
|
3
|
-
import type {
|
|
3
|
+
import type { ProjectConfig } from './types';
|
|
4
|
+
export { fetchProject, fetchExperienceContent } from '../../data-source/api';
|
|
4
5
|
/**
|
|
5
6
|
* Synchronously registers a complete project config with the client: features, conditions,
|
|
6
7
|
* fields, steps, and experiences, in dependency order.
|
|
@@ -24,46 +25,14 @@ export declare function registerProjectConfig(client: Picked, config: ProjectCon
|
|
|
24
25
|
sessionId: string;
|
|
25
26
|
}): void;
|
|
26
27
|
/**
|
|
27
|
-
*
|
|
28
|
+
* Plugin that resolves project configuration through the client and registers features,
|
|
29
|
+
* steps, fields, and experiences with it.
|
|
28
30
|
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
+
* Resolution runs during the `onStart` hook, before experience initialisation, and reads
|
|
32
|
+
* whichever source the client resolves to — the build-time bundle when one registered itself,
|
|
33
|
+
* the Picked API otherwise. Search param feature overrides take precedence over resolved
|
|
34
|
+
* values.
|
|
31
35
|
*
|
|
32
|
-
* @param {string} apiUrl - Base URL for the Picked API.
|
|
33
|
-
* @param {string} projectId - Project ID to fetch config for.
|
|
34
|
-
* @param {FetchProjectOptions} [options] - Optional headers and preview token.
|
|
35
|
-
* @returns {Promise<ProjectConfig | null>} Validated project config, or `null` on any failure.
|
|
36
|
-
* @example
|
|
37
|
-
* ```typescript
|
|
38
|
-
* const config = await fetchProject('https://api.picked.app', 'proj_123')
|
|
39
|
-
* ```
|
|
40
|
-
*/
|
|
41
|
-
export declare function fetchProject(apiUrl: string, projectId: string, options?: FetchProjectOptions): Promise<ProjectConfig | null>;
|
|
42
|
-
/**
|
|
43
|
-
* Fetches per-experience content from the Picked API.
|
|
44
|
-
*
|
|
45
|
-
* Returns `null` on network failure, non-OK responses, or invalid JSON shape — preserving
|
|
46
|
-
* the failure-tolerant policy: experiences still render, layouts handle null defensively.
|
|
47
|
-
*
|
|
48
|
-
* @param {string} apiUrl - Base URL for the Picked API.
|
|
49
|
-
* @param {string} projectId - Project ID to fetch content for.
|
|
50
|
-
* @param {string} experienceId - Experience ID whose content to fetch.
|
|
51
|
-
* @param {FetchProjectOptions} [options] - Optional headers, preview token, and abort signal.
|
|
52
|
-
* @returns {Promise<ExperienceContentResponse | null>} Validated content response, or `null` on any failure.
|
|
53
|
-
* @example
|
|
54
|
-
* ```typescript
|
|
55
|
-
* const content = await fetchExperienceContent('https://api.picked.app', 'proj_1', 'exp_1')
|
|
56
|
-
* ```
|
|
57
|
-
*/
|
|
58
|
-
export declare function fetchExperienceContent(apiUrl: string, projectId: string, experienceId: string, options?: FetchProjectOptions): Promise<ExperienceContentResponse | null>;
|
|
59
|
-
/**
|
|
60
|
-
* Plugin that fetches project configuration from the Picked REST API and registers
|
|
61
|
-
* features, steps, fields, and experiences with the client.
|
|
62
|
-
*
|
|
63
|
-
* Features are fetched during the `onStart` hook, before experience initialisation.
|
|
64
|
-
* Search param feature overrides take precedence over API-provided values.
|
|
65
|
-
*
|
|
66
|
-
* @param {DynamicExperiencesPluginOptions} [options] - Optional plugin configuration.
|
|
67
36
|
* @returns {Plugin} A configured Picked plugin.
|
|
68
37
|
* @example
|
|
69
38
|
* ```typescript
|
|
@@ -76,5 +45,5 @@ export declare function fetchExperienceContent(apiUrl: string, projectId: string
|
|
|
76
45
|
* })
|
|
77
46
|
* ```
|
|
78
47
|
*/
|
|
79
|
-
export declare function dynamicExperiencesPlugin(
|
|
48
|
+
export declare function dynamicExperiencesPlugin(): Plugin;
|
|
80
49
|
//# sourceMappingURL=plugin.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../../src/plugins/dynamic-experiences/plugin.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAA;
|
|
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;AAE1D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAG1C,OAAO,KAAK,EAGV,aAAa,EAGd,MAAM,SAAS,CAAA;AAEhB,OAAO,EAAE,YAAY,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAA;AA+J5E;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,aAAa,EACrB,OAAO,EAAE;IAAE,SAAS,EAAE,OAAO,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,GACjD,IAAI,CAMN;AAwMD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,wBAAwB,IAAI,MAAM,CA4DjD"}
|