@relyio/sdk 0.11.0 → 0.13.0

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.
Files changed (43) hide show
  1. package/CHANGELOG.md +172 -0
  2. package/dist/chunk-3NPPMGB6.js +1092 -0
  3. package/dist/{chunk-7GLDVHIH.js → chunk-6NGJXLOR.js} +65 -67
  4. package/dist/{chunk-4HTIU5YE.cjs → chunk-DEDIJKHY.cjs} +65 -67
  5. package/dist/{chunk-2TIJLV2X.js → chunk-EW23SZPX.js} +43 -65
  6. package/dist/{chunk-PO7CUR5U.cjs → chunk-FOSM4LMM.cjs} +42 -65
  7. package/dist/chunk-Z6GLWSSD.cjs +1106 -0
  8. package/dist/client/index.cjs +3 -3
  9. package/dist/client/index.d.cts +4 -4
  10. package/dist/client/index.d.ts +4 -4
  11. package/dist/client/index.js +1 -1
  12. package/dist/{define-schema-CVi8nwc7.d.ts → define-schema-UHViXKiv.d.ts} +33 -435
  13. package/dist/{define-schema-DqpipEHv.d.cts → define-schema-sWJ8Zn7C.d.cts} +33 -435
  14. package/dist/{define-content-type-ENAod5Ve.d.cts → include-paths-Bs5FhNw2.d.cts} +3505 -483
  15. package/dist/{define-content-type-ENAod5Ve.d.ts → include-paths-Cb7iPCW2.d.ts} +3505 -483
  16. package/dist/index--_u1nPHv.d.cts +507 -0
  17. package/dist/index-8DozAWsA.d.ts +507 -0
  18. package/dist/{index-MLAFUuco.d.cts → index-BT0L8xJj.d.cts} +139 -90
  19. package/dist/{index-BKEAYvvz.d.ts → index-CPjJ25R4.d.ts} +139 -90
  20. package/dist/index.cjs +134 -110
  21. package/dist/index.d.cts +44 -71
  22. package/dist/index.d.ts +44 -71
  23. package/dist/index.js +5 -28
  24. package/dist/markdown/index.cjs +13750 -0
  25. package/dist/markdown/index.d.cts +111 -0
  26. package/dist/markdown/index.d.ts +111 -0
  27. package/dist/markdown/index.js +13742 -0
  28. package/dist/rich-text/index.cjs +49 -0
  29. package/dist/rich-text/index.d.cts +3 -0
  30. package/dist/rich-text/index.d.ts +3 -0
  31. package/dist/rich-text/index.js +4 -0
  32. package/dist/rich-text.d-BWc-5gX1.d.cts +326 -0
  33. package/dist/rich-text.d-BWc-5gX1.d.ts +326 -0
  34. package/dist/schema/index.cjs +34 -38
  35. package/dist/schema/index.d.cts +15 -137
  36. package/dist/schema/index.d.ts +15 -137
  37. package/dist/schema/index.js +1 -1
  38. package/dist/types/index.d.cts +2 -2
  39. package/dist/types/index.d.ts +2 -2
  40. package/package.json +19 -2
  41. package/dist/.tsbuildinfo +0 -1
  42. package/dist/index-BM42r4yg.d.cts +0 -860
  43. package/dist/index-C73cK2Tt.d.ts +0 -860
package/dist/index.d.cts CHANGED
@@ -1,19 +1,21 @@
1
- import { C as Change, a as ChangesExpiredError, b as ChangesExpiredReason } from './index-MLAFUuco.cjs';
2
- export { A as ActiveSandbox, a6 as AdhocAggregateBlock, a5 as AdhocFetchBlock, a4 as AdhocQueryBuilder, a3 as AdhocQueryClient, ab as AdhocQueryDefinition, ac as AdhocQueryOptions, ae as AdhocQueryResult, a8 as AdhocSearchBlock, a7 as AggregateMetric, af as AssetClient, aq as AssetEntryResponse, am as AssetFileBlock, ag as AssetFileBuilder, an as AssetFileExtracted, ah as AssetUploadBuilder, ap as AssetUrls, aj as AssetVisibility, y as AutocompleteBuilder, K as AutocompleteResponse, J as AutocompleteSuggestion, Y as BatchBuilder, X as BatchClient, Z as BatchMethod, _ as BatchOperation, a0 as BatchOperationResult, $ as BatchOptions, a2 as BatchResponse, a1 as BatchSummary, k as ChangesHeadOptions, l as ChangesOptions, t as ChildrenOptions, e as ClientSchema, i as ConditionalWriteOptions, au as ConfirmInput, av as ConfirmResult, s as ContentByIdBuilder, o as ContentClient, r as ContentQueryBuilder, ay as CreateAssetOptions, E as ExtendedQueryResult, F as FeedChange, al as FileBackend, aI as FileErrorCode, ak as FileStatus, ao as FileStatusResult, aK as FileUploadError, aJ as FileUploadErrorCode, aM as FileValidationConstraints, aL as FileValidationError, a9 as FilterValue, aa as FullTextConfig, H as HttpClient, L as LIVE_KEEPALIVE_INTERVAL_MS, m as LIVE_SOCKET_OPEN_TIMEOUT_MS, n as LiveChangesOptions, aA as MultipartCreateResult, aB as MultipartPart, aC as MultipartTarget, ar as PopulatedAssetReference, as as PresignInput, at as PresignResult, P as Project, ad as QueryMetadata, R as Register, f as RegisteredSchema, aw as ResolveUrlInput, ax as ResolveUrlResult, aF as ResourceConflictError, aG as ResourceExpiredError, aE as ResourceNotFoundError, j as RetryableWriteOptions, S as SandboxState, x as SearchBuilder, w as SearchClient, W as SearchEntry, Q as SearchFields, O as SearchFilter, G as SearchHitMetadata, B as SearchMode, I as SearchResponse, D as SearchResultItem, U as SearchSort, V as SearchTypeName, g as SendOptions, q as SettingsClient, v as SettingsFetchOptions, z as SimilarBuilder, N as SimilarResponse, M as SimilarResult, p as SingletonClient, u as SingletonFetchOptions, d as TypedClientConfig, T as TypedRelyIOClient, aD as UploadProgress, az as WaitUntilReadyOptions, c as createClient, c as default, h as entityTagOf, ai as isAssetEntry, aH as isResourceNotFound, aN as validateFile } from './index-MLAFUuco.cjs';
1
+ import { C as Change, a as ChangesExpiredError, b as ChangesExpiredReason } from './index-BT0L8xJj.cjs';
2
+ export { A as ActiveSandbox, a6 as AdhocAggregateBlock, a5 as AdhocFetchBlock, a4 as AdhocQueryBuilder, a3 as AdhocQueryClient, ab as AdhocQueryDefinition, ac as AdhocQueryOptions, ae as AdhocQueryResult, a8 as AdhocSearchBlock, a7 as AggregateMetric, af as AssetClient, ao as AssetEntryResponse, ag as AssetFileBuilder, am as AssetFileExtracted, ah as AssetUploadBuilder, aj as AssetVisibility, y as AutocompleteBuilder, K as AutocompleteResponse, J as AutocompleteSuggestion, Y as BatchBuilder, X as BatchClient, Z as BatchMethod, _ as BatchOperation, a0 as BatchOperationResult, $ as BatchOptions, a2 as BatchResponse, a1 as BatchSummary, k as ChangesHeadOptions, l as ChangesOptions, t as ChildrenOptions, e as ClientSchema, i as ConditionalWriteOptions, as as ConfirmInput, at as ConfirmResult, s as ContentByIdBuilder, o as ContentClient, r as ContentQueryBuilder, aw as CreateAssetOptions, E as ExtendedQueryResult, F as FeedChange, al as FileBackend, aG as FileErrorCode, ak as FileStatus, an as FileStatusResult, aI as FileUploadError, aH as FileUploadErrorCode, aK as FileValidationConstraints, aJ as FileValidationError, a9 as FilterValue, aa as FullTextConfig, H as HttpClient, L as LIVE_KEEPALIVE_INTERVAL_MS, m as LIVE_SOCKET_OPEN_TIMEOUT_MS, n as LiveChangesOptions, ay as MultipartCreateResult, az as MultipartPart, aA as MultipartTarget, ap as PopulatedAssetReference, aq as PresignInput, ar as PresignResult, P as Project, ad as QueryMetadata, R as Register, f as RegisteredSchema, au as ResolveUrlInput, av as ResolveUrlResult, aD as ResourceConflictError, aE as ResourceExpiredError, aC as ResourceNotFoundError, j as RetryableWriteOptions, S as SandboxState, x as SearchBuilder, w as SearchClient, W as SearchEntry, Q as SearchFields, O as SearchFilter, G as SearchHitMetadata, B as SearchMode, I as SearchResponse, D as SearchResultItem, U as SearchSort, V as SearchTypeName, g as SendOptions, q as SettingsClient, v as SettingsFetchOptions, z as SimilarBuilder, N as SimilarResponse, M as SimilarResult, p as SingletonClient, u as SingletonFetchOptions, d as TypedClientConfig, T as TypedRelyIOClient, aB as UploadProgress, ax as WaitUntilReadyOptions, c as createClient, c as default, h as entityTagOf, ai as isAssetEntry, aF as isResourceNotFound, aL as validateFile } from './index-BT0L8xJj.cjs';
3
3
  export { fields } from './schema/index.cjs';
4
- import { S as SDKError, B as BaseContent } from './index-BM42r4yg.cjs';
5
- export { c as ApiMethod, A as ApiPath, w as ApiResponse, d as ApiSuccessBody, H as BaseValidationError, t as CacheConfig, y as CacheStrategy, k as ContentQueryResult, o as ContentTypeSchema, C as CreateInput, n as CustomQuery, D as DebugConfig, E as Environment, p as FieldOptions, F as FieldTypeName, J as InvalidPayloadError, L as LiveWebSocket, b as LiveWebSocketConstructor, z as LogLevel, M as MatchRouteOptions, P as PerformanceMetrics, Q as QueryOptions, u as RealtimeConfig, r as RealtimeEvent, q as RealtimeEventType, R as RelyIOConfig, a as RelyIOConfigUpdate, v as RequestConfig, x as RetryConfig, e as RouteMatch, l as SingletonContent, j as SortOptions, s as SubscriptionOptions, U as UpdateInput, I as ValidationError, V as ValidationRule, G as ValidationViolation, h as WhereClause, g as WhereFieldCondition, i as WhereOperator, f as WhereScalar, W as Wire, m as matchRoute } from './index-BM42r4yg.cjs';
4
+ import { bx as SDKError, ap as EntryMetadata } from './include-paths-Bs5FhNw2.cjs';
5
+ export { bD as ApiMethod, bC as ApiPath, ca as ApiResponse, bE as ApiSuccessBody, bJ as AssetFileBlock, a9 as AssetReading, aJ as AssetServedBlocks, aF as AssetTypeConfig, aG as AssetTypeDefinition, bK as AssetUrls, bL as BaseContent, B as BaseFieldConfig, cg as BaseValidationError, a7 as BlockOf, c6 as CacheConfig, cc as CacheStrategy, ab as CheckInclude, aa as CheckedIncludes, bX as ContentQueryResult, ac as ContentReading, an as ContentTypeConfig, ao as ContentTypeDefinition, b_ as ContentTypeSchema, bT as CreateInput, bZ as CustomQuery, bQ as DateOnlyOperator, c8 as DebugConfig, ce as Environment, g as FieldDefinition, am as FieldMember, c1 as FieldOptions, h as FieldRule, a1 as FieldSchemaContext, i as FieldType, b$ as FieldTypeName, j as FieldUIConfig, a2 as FieldValue, a3 as FieldValues, al as Fieldset, aM as FileKindConfig, a_ as FileScanConfig, aZ as FileUploadConfig, aS as ImageExifConfig, aK as ImageKindConfig, aR as ImageSourceConfig, aQ as ImageUploadConfig, ad as IncludablePaths, aI as InferAssetEntry, aH as InferAssetType, aq as InferContentType, bt as InferJsonSchema, ay as InferSingleton, ax as InferSingletonContentType, ci as InvalidPayloadError, bu as JsonFieldValue, bv as JsonSchema, bw as JsonValue, a6 as Keyed, bA as LiveWebSocket, bB as LiveWebSocketConstructor, ar as LocalePublicationFields, k as LocalizationConfig, cd as LogLevel, bI as MatchRouteOptions, c5 as PerformanceMetrics, bS as QueryOptions, af as ReadWith, ae as Reading, c7 as RealtimeConfig, c3 as RealtimeEvent, c2 as RealtimeEventType, by as RelyIOConfig, bz as RelyIOConfigUpdate, c9 as RequestConfig, bV as RestoredContent, cb as RetryConfig, bU as RevisedContent, bH as RouteMatch, aA as SettingsGroupConfig, aB as SettingsGroupDefinition, ag as SettingsReading, a8 as ShapeValue, bY as SingletonContent, av as SingletonContentTypeDefinition, aw as SingletonMetadata, ah as SingletonReading, bR as SortOptions, c4 as SubscriptionOptions, a5 as UnresolvedEntry, ai as UntypedReading, bW as UpdateInput, ch as ValidationError, c0 as ValidationRule, cf as ValidationViolation, aT as VariantDefinition, aW as VideoCaptionsConfig, aX as VideoDownloadConfig, aL as VideoKindConfig, aV as VideoPosterConfig, aU as VideoUploadConfig, aY as VideoWatermarkConfig, bO as WhereClause, bN as WhereFieldCondition, bP as WhereOperator, bM as WhereScalar, bF as Wire, aE as defineAssetType, aj as defineContentType, az as defineSettingsGroup, at as defineSingleton, as as defineSingletonContentType, ak as fieldset, bG as matchRoute } from './include-paths-Bs5FhNw2.cjs';
6
6
  import { VisitorRetry } from './live-visitor.js';
7
7
  export { camelToSnake, createDeferred, debounce, deepClone, generateId, isBrowser, isNode, isPlainObject, isValidEmail, isValidUrl, mergeDeep, omit, pick, retry, sleep, snakeToCamel, throttle, toSafeString } from './utils/index.cjs';
8
- import { Q as EntryMetadata } from './define-content-type-ENAod5Ve.cjs';
9
- export { a5 as AssetTypeConfig, a9 as AssetTypeDefinition, n as BaseFieldConfig, M as ContentTypeConfig, N as ContentTypeConfigWithFields, O as ContentTypeConfigWithFieldsets, P as ContentTypeDefinition, c as FieldDefinition, b as FieldRule, v as FieldSchemaContext, p as FieldType, F as FieldUIConfig, w as FieldValue, x as FieldValues, K as Fieldset, ad as FileKindConfig, ar as FileScanConfig, aq as FileUploadConfig, aj as ImageExifConfig, ab as ImageKindConfig, ai as ImageSourceConfig, ah as ImageUploadConfig, aa as InferAssetType, W as InferContentType, a3 as InferSingleton, a2 as InferSingletonContentType, X as LocalePublicationFields, L as LocalizationConfig, a0 as SingletonContentTypeDefinition, a1 as SingletonMetadata, G as UnresolvedComponent, z as UnresolvedEntry, ak as VariantDefinition, an as VideoCaptionsConfig, ao as VideoDownloadConfig, ac as VideoKindConfig, am as VideoPosterConfig, al as VideoUploadConfig, ap as VideoWatermarkConfig, a4 as defineAssetType, H as defineContentType, Z as defineSingleton, Y as defineSingletonContentType, J as fieldset } from './define-content-type-ENAod5Ve.cjs';
10
- export { a9 as AggregateBlock, C as ComponentConfig, s as ComponentDefinition, t as ComponentMetadata, a8 as FetchBlock, am as FilterDefinition, ai as IncludeDefinition, aw as InferQueryParams, av as InferQueryResponse, a4 as QueryConfig, a5 as QueryDefinition, h as SchemaAssetTypeNames, S as SchemaConfig, b as SchemaContentTypeNames, a as SchemaDefinition, i as SchemaEntry, j as SchemaEntryOf, f as SchemaLocaleCodes, e as SchemaQueryNames, g as SchemaSettingsGroupNames, c as SchemaSingletonNames, aa as SearchBlock, al as SelectMapping, x as SettingsGroupConfig, y as SettingsGroupDefinition, ag as SortCondition, ab as WhereCondition, r as defineComponent, a3 as defineQuery, d as defineSchema, w as defineSettingsGroup } from './define-schema-DqpipEHv.cjs';
8
+ export { n as RICH_TEXT_VOID_TAGS, R as RelyIOFieldAttributes, a as RelyIOFieldName, b as RelyIOFieldPath, c as RelyIOKeyed, q as RichTextAnchorsOption, t as RichTextAttributes, u as RichTextBlocksOf, v as RichTextDeclaredOf, w as RichTextDeclaredWriters, x as RichTextEntryLinkOf, y as RichTextEntryLinkOption, j as RichTextHtmlDeclaredWriters, k as RichTextHtmlFieldOption, l as RichTextHtmlOptions, z as RichTextInlineOf, m as RichTextMarkdownOptions, A as RichTextNodeContext, B as RichTextRenderable, C as RichTextRenderableOf, D as RichTextReplaceableNode, E as RichTextTag, F as RichTextTarget, e as entryHeadingAnchors, g as escapeHtml, o as isDeclaredRichTextNode, r as relyioField, p as renderRichText, d as richTextHeadingAnchors, f as richTextHeadingSlug, h as richTextToHtml, i as richTextToMarkdown, s as safeRichTextHref } from './index--_u1nPHv.cjs';
9
+ export { I as AggregateBlock, H as FetchBlock, Z as FilterDefinition, V as IncludeDefinition, a7 as InferQueryParams, a6 as InferQueryResponse, Q as QueryConfig, D as QueryDefinition, h as SchemaAssetTypeNames, S as SchemaConfig, b as SchemaContentTypeNames, a as SchemaDefinition, i as SchemaEntry, j as SchemaEntryOf, f as SchemaLocaleCodes, e as SchemaQueryNames, g as SchemaSettingsGroupNames, c as SchemaSingletonNames, J as SearchBlock, Y as SelectMapping, P as SortCondition, W as WhereCondition, C as defineQuery, d as defineSchema } from './define-schema-sWJ8Zn7C.cjs';
10
+ export { e as RichTextBlock, f as RichTextCellAlignment, g as RichTextCodeBlock, h as RichTextCodeGroup, i as RichTextCodeLines, j as RichTextDivider, d as RichTextEntryLinkMark, k as RichTextHeading, l as RichTextInline, m as RichTextLineBreak, n as RichTextLinkMark, o as RichTextList, p as RichTextListItem, q as RichTextListStyle, r as RichTextMark, s as RichTextMarkType, t as RichTextNode, u as RichTextParagraph, v as RichTextQuote, w as RichTextSpan, x as RichTextStructure, y as RichTextTable, z as RichTextTableCell, B as RichTextTableRow, b as RichTextValue } from './rich-text.d-BWc-5gX1.cjs';
11
11
  import './dev-handshake/index.cjs';
12
12
 
13
13
  /**
14
- * What a key may do is in its prefix. A RelyIO key is `rly_{scope}_v1_{entropy}_{checksum}`, and a
15
- * publishable key — the one project key that may sit in a browser (`sdk-surfaces-spec.md` decision
16
- * 29) — is scope `pub`. Its scope is in its prefix so that no stored flag can disagree with it.
14
+ * What a key may do is in its prefix. A RelyIO project key is
15
+ * `rly_{scope}_{region}_v2_{entropy}_{checksum}`: the scope first, then the region of its project's
16
+ * data, which RelyIO's edge routes by and this package never reads. A publishable key — the one
17
+ * project key that may sit in a browser (`sdk-surfaces-spec.md` decision 29) — is scope `pub`. Its
18
+ * scope is in its prefix so that no stored flag can disagree with it.
17
19
  *
18
20
  * The truth is the service's: `isPublishableApiKey` in
19
21
  * `packages/data/metadata-db/src/utils/api-key-generator.ts`, which decides whether a presented key is
@@ -812,70 +814,41 @@ declare const localeHelpers: {
812
814
  };
813
815
 
814
816
  /**
815
- * The DOM↔field binding contract, as the one pure helper that emits it.
816
- *
817
- * Spread onto the element that renders a field, it stamps which entry, content type, field and
818
- * locale produced that element, so an editing surface can find the field by scanning the DOM
819
- * rather than by guessing (`INV-TB-BINDING`). The contract is `toolbar-spec.md` §DOM↔field; this
820
- * file is its only implementation.
821
- *
822
- * **Frozen** (`INV-SS-BINDING-FROZEN`). The attribute set is exactly the five below. Adding,
823
- * renaming or dropping one is a new contract, and a new contract is a bump of `data-relyio-v` — a
824
- * page built against version 1 keeps being read as version 1 by any surface that scans it.
825
- *
826
- * **Pure** (`INV-TB-SDK-PURE`). It reads the entry it is handed and returns attributes. It imports
827
- * nothing but the SDK's own types: no realtime, no AI, no first-party code, no framework. That is
828
- * what lets it live in the customer SDK and run on a server render as happily as in a browser.
829
- *
830
- * **Every value comes from the entry.** The id, the content type and the locale are the ones the
831
- * API reported in `_metadata` — the locale is the one the payload's field values were composed
832
- * for. There is deliberately no `locale` argument: a caller-supplied locale could bind a node to a
833
- * locale whose value it is not rendering, which is the silently inferred binding `INV-TB-BINDING`
834
- * forbids.
835
- */
836
-
837
- /** The version of the binding contract this helper emits. */
838
- declare const BINDING_VERSION = "1";
839
- /** The attributes `relyioField` returns — the whole of binding contract version 1. */
840
- interface RelyIOFieldAttributes {
841
- /** The entry's id (`_metadata.id`). */
842
- readonly 'data-relyio-entry': string;
843
- /** The entry's content type (`_metadata.type`); every customer read is keyed by it. */
844
- readonly 'data-relyio-type': string;
845
- /** The field the element renders. */
846
- readonly 'data-relyio-field': string;
847
- /** The locale the entry's field values were composed for (`_metadata.locale`). */
848
- readonly 'data-relyio-locale': string;
849
- /** The binding contract's version. */
850
- readonly 'data-relyio-v': typeof BINDING_VERSION;
851
- }
817
+ * A key path (REL-1814): where a value sits inside an entry, each item on the way named by its
818
+ * `_key` — `sections[_key=="f2k6ub9s"].heading`. A field by its id (`title`), a field of an object's
819
+ * value after the object's (`hero.title`), an item of a list by its key (`faq[_key=="k1"]`) and a
820
+ * field of that item after it (`faq[_key=="k1"].question`), to any depth. Inside a rich-text field a
821
+ * key names a declared Block or Inline element wherever it stands in the tree (`body[_key=="c1"]`):
822
+ * a key is unique within the field, nested trees included, so the path needs no step for the quote
823
+ * or the list item around it, and a field of the node follows it (`body[_key=="c1"].caption`).
824
+ *
825
+ * It is the spelling a validation error's path, a live binding, a comment's anchor and a filled
826
+ * field's path already use, so the address a page stamps is the one the Studio opens a field by,
827
+ * and it stays on its item when the list is reordered — which an index would not. The rule is
828
+ * `@relyio/schema`'s `formatItemPath` and `parseKeyedPath`, restated here because this package takes
829
+ * no runtime from that one (it is build-inlined for types only); `devtools/verification`'s
830
+ * `key-paths-sdk.test.ts` holds the two to one corpus.
831
+ */
832
+ /** One step of a key path: a field by its id, or the item of the list (or rich text) before it. */
833
+ type KeyPathSegment = {
834
+ readonly field: string;
835
+ } | {
836
+ readonly key: string;
837
+ };
852
838
  /**
853
- * The field names `relyioField` accepts for an entry of type `T`.
854
- *
855
- * A schema-typed entry narrows to its declared field names, so they autocomplete and a misspelt
856
- * one does not compile. An entry with no declared fields — `BaseContent`, which is what an
857
- * un-generated client returns — has none to narrow to, and `keyof` of it is `never`; that would
858
- * make the helper uncallable for every untyped customer, so it accepts any field name instead.
839
+ * The key path of an item of the list at `listPath` — `faq[_key=="k1"]` — or of a field inside it
840
+ * when `field` is given: `faq[_key=="k1"].question`. The key is written as a JSON string, so a quote
841
+ * in it stays inside it. `listPath` and `field` are key paths of their own (`sections[_key=="a"].links`,
842
+ * `link.label`).
859
843
  */
860
- type RelyIOFieldName<T extends BaseContent> = [Exclude<keyof T, '_metadata'>] extends [never] ? string : string & Exclude<keyof T, '_metadata'>;
844
+ declare function formatKeyPath(listPath: string, key: string, field?: string): string;
861
845
  /**
862
- * Binding attributes for one field of one entry.
863
- *
864
- * @example
865
- * ```tsx
866
- * import { relyioField } from '@relyio/sdk'
867
- *
868
- * <h1 {...relyioField(post, 'title')}>{post.title}</h1>
869
- * // → data-relyio-entry="6710f…" data-relyio-type="post" data-relyio-field="title"
870
- * // data-relyio-locale="en-US" data-relyio-v="1"
871
- * ```
872
- *
873
- * @throws {TypeError} when the entry's `_metadata` lacks its id, content type or locale. Every
874
- * entry the API returns carries all three, so this is reached only by a value that was not read
875
- * from RelyIO. It throws rather than emitting a partial binding: a node stamped with no locale, or
876
- * none at all, is a binding a surface would have to guess the rest of.
846
+ * A key path read back into its steps: `sections[_key=="a"].links[_key=="b"].label` → `sections`,
847
+ * `a`, `links`, `b`, `label`. A path with no item in it is its field ids (`hero.title` → `hero`,
848
+ * `title`). `null` for anything else — an index (`faq[0]`), an item of an item, an unterminated or
849
+ * empty key, an empty field id — which names no value by key.
877
850
  */
878
- declare function relyioField<T extends BaseContent>(entry: T, field: RelyIOFieldName<T>): RelyIOFieldAttributes;
851
+ declare function parseKeyPath(path: string): KeyPathSegment[] | null;
879
852
 
880
853
  /**
881
854
  * The DOM event a preview surface dispatches when content on the page has changed, and the one
@@ -1006,4 +979,4 @@ declare function snapToLadder(value: number): number;
1006
979
 
1007
980
  declare const VERSION = "__VERSION__";
1008
981
 
1009
- export { AuthorizationError, BaseContent, Change, type ChangeSource, type ChangeSourceOptions, ChangesExpiredError, ChangesExpiredReason, ConnectionError, EntryMetadata, ErrorMapper, FOLLOW_BACK_OFF_MAX_MS, FOLLOW_RETRY_BASE_MS, FOLLOW_RETRY_MAX_MS, type FollowEnd, type FollowOptions, type FollowResync, type FollowState, type FollowVerdict, IMAGE_LADDER, InvalidApiKeyError, type LanguageSwitcherOption, type LanguageSwitcherOptions, type LiveEdgeEnd, LiveEdgeError, type LocaleMetadata, type LocaleStatus, type LocalizedEntry, MethodNotAllowedError, MissingApiKeyError, NetworkError, PUBLISHABLE_KEY_PREFIX, PayloadTooLargeError, PlanFeatureUnavailableError, RELYIO_CHANGE_EVENT, RELYIO_RESYNC_EVENT, RateLimitError, ReadOnlyKeyError, type RelyIOChangeDetail, type RelyIOFieldAttributes, type RelyIOFieldName, type RelyIOResyncDetail, SDKError, ServerError, ServiceIndeterminateError, TimeoutError, TransactionRolledBackError, type TranslationCompleteness, UnknownContractError, UsageQuotaExceededError, VERSION, buildLanguageSwitcher, classifyFollowFailure, estimateTranslationCompleteness, followChanges, getAllLocalizedValues, getAvailableLocaleCodes, getDefaultLocale, getFallbackFields, getFieldFallbackLocale, getLocalizedField, getPublishedLocaleCodes, getRequestedLocale, hasLocale, isFieldFallback, isPublishableKey, isPublishedInLocale, localeHelpers, needsTranslation, relyioField, snapToLadder };
982
+ export { AuthorizationError, Change, type ChangeSource, type ChangeSourceOptions, ChangesExpiredError, ChangesExpiredReason, ConnectionError, EntryMetadata, ErrorMapper, FOLLOW_BACK_OFF_MAX_MS, FOLLOW_RETRY_BASE_MS, FOLLOW_RETRY_MAX_MS, type FollowEnd, type FollowOptions, type FollowResync, type FollowState, type FollowVerdict, IMAGE_LADDER, InvalidApiKeyError, type KeyPathSegment, type LanguageSwitcherOption, type LanguageSwitcherOptions, type LiveEdgeEnd, LiveEdgeError, type LocaleMetadata, type LocaleStatus, type LocalizedEntry, MethodNotAllowedError, MissingApiKeyError, NetworkError, PUBLISHABLE_KEY_PREFIX, PayloadTooLargeError, PlanFeatureUnavailableError, RELYIO_CHANGE_EVENT, RELYIO_RESYNC_EVENT, RateLimitError, ReadOnlyKeyError, type RelyIOChangeDetail, type RelyIOResyncDetail, SDKError, ServerError, ServiceIndeterminateError, TimeoutError, TransactionRolledBackError, type TranslationCompleteness, UnknownContractError, UsageQuotaExceededError, VERSION, buildLanguageSwitcher, classifyFollowFailure, estimateTranslationCompleteness, followChanges, formatKeyPath, getAllLocalizedValues, getAvailableLocaleCodes, getDefaultLocale, getFallbackFields, getFieldFallbackLocale, getLocalizedField, getPublishedLocaleCodes, getRequestedLocale, hasLocale, isFieldFallback, isPublishableKey, isPublishedInLocale, localeHelpers, needsTranslation, parseKeyPath, snapToLadder };
package/dist/index.d.ts CHANGED
@@ -1,19 +1,21 @@
1
- import { C as Change, a as ChangesExpiredError, b as ChangesExpiredReason } from './index-BKEAYvvz.js';
2
- export { A as ActiveSandbox, a6 as AdhocAggregateBlock, a5 as AdhocFetchBlock, a4 as AdhocQueryBuilder, a3 as AdhocQueryClient, ab as AdhocQueryDefinition, ac as AdhocQueryOptions, ae as AdhocQueryResult, a8 as AdhocSearchBlock, a7 as AggregateMetric, af as AssetClient, aq as AssetEntryResponse, am as AssetFileBlock, ag as AssetFileBuilder, an as AssetFileExtracted, ah as AssetUploadBuilder, ap as AssetUrls, aj as AssetVisibility, y as AutocompleteBuilder, K as AutocompleteResponse, J as AutocompleteSuggestion, Y as BatchBuilder, X as BatchClient, Z as BatchMethod, _ as BatchOperation, a0 as BatchOperationResult, $ as BatchOptions, a2 as BatchResponse, a1 as BatchSummary, k as ChangesHeadOptions, l as ChangesOptions, t as ChildrenOptions, e as ClientSchema, i as ConditionalWriteOptions, au as ConfirmInput, av as ConfirmResult, s as ContentByIdBuilder, o as ContentClient, r as ContentQueryBuilder, ay as CreateAssetOptions, E as ExtendedQueryResult, F as FeedChange, al as FileBackend, aI as FileErrorCode, ak as FileStatus, ao as FileStatusResult, aK as FileUploadError, aJ as FileUploadErrorCode, aM as FileValidationConstraints, aL as FileValidationError, a9 as FilterValue, aa as FullTextConfig, H as HttpClient, L as LIVE_KEEPALIVE_INTERVAL_MS, m as LIVE_SOCKET_OPEN_TIMEOUT_MS, n as LiveChangesOptions, aA as MultipartCreateResult, aB as MultipartPart, aC as MultipartTarget, ar as PopulatedAssetReference, as as PresignInput, at as PresignResult, P as Project, ad as QueryMetadata, R as Register, f as RegisteredSchema, aw as ResolveUrlInput, ax as ResolveUrlResult, aF as ResourceConflictError, aG as ResourceExpiredError, aE as ResourceNotFoundError, j as RetryableWriteOptions, S as SandboxState, x as SearchBuilder, w as SearchClient, W as SearchEntry, Q as SearchFields, O as SearchFilter, G as SearchHitMetadata, B as SearchMode, I as SearchResponse, D as SearchResultItem, U as SearchSort, V as SearchTypeName, g as SendOptions, q as SettingsClient, v as SettingsFetchOptions, z as SimilarBuilder, N as SimilarResponse, M as SimilarResult, p as SingletonClient, u as SingletonFetchOptions, d as TypedClientConfig, T as TypedRelyIOClient, aD as UploadProgress, az as WaitUntilReadyOptions, c as createClient, c as default, h as entityTagOf, ai as isAssetEntry, aH as isResourceNotFound, aN as validateFile } from './index-BKEAYvvz.js';
1
+ import { C as Change, a as ChangesExpiredError, b as ChangesExpiredReason } from './index-CPjJ25R4.js';
2
+ export { A as ActiveSandbox, a6 as AdhocAggregateBlock, a5 as AdhocFetchBlock, a4 as AdhocQueryBuilder, a3 as AdhocQueryClient, ab as AdhocQueryDefinition, ac as AdhocQueryOptions, ae as AdhocQueryResult, a8 as AdhocSearchBlock, a7 as AggregateMetric, af as AssetClient, ao as AssetEntryResponse, ag as AssetFileBuilder, am as AssetFileExtracted, ah as AssetUploadBuilder, aj as AssetVisibility, y as AutocompleteBuilder, K as AutocompleteResponse, J as AutocompleteSuggestion, Y as BatchBuilder, X as BatchClient, Z as BatchMethod, _ as BatchOperation, a0 as BatchOperationResult, $ as BatchOptions, a2 as BatchResponse, a1 as BatchSummary, k as ChangesHeadOptions, l as ChangesOptions, t as ChildrenOptions, e as ClientSchema, i as ConditionalWriteOptions, as as ConfirmInput, at as ConfirmResult, s as ContentByIdBuilder, o as ContentClient, r as ContentQueryBuilder, aw as CreateAssetOptions, E as ExtendedQueryResult, F as FeedChange, al as FileBackend, aG as FileErrorCode, ak as FileStatus, an as FileStatusResult, aI as FileUploadError, aH as FileUploadErrorCode, aK as FileValidationConstraints, aJ as FileValidationError, a9 as FilterValue, aa as FullTextConfig, H as HttpClient, L as LIVE_KEEPALIVE_INTERVAL_MS, m as LIVE_SOCKET_OPEN_TIMEOUT_MS, n as LiveChangesOptions, ay as MultipartCreateResult, az as MultipartPart, aA as MultipartTarget, ap as PopulatedAssetReference, aq as PresignInput, ar as PresignResult, P as Project, ad as QueryMetadata, R as Register, f as RegisteredSchema, au as ResolveUrlInput, av as ResolveUrlResult, aD as ResourceConflictError, aE as ResourceExpiredError, aC as ResourceNotFoundError, j as RetryableWriteOptions, S as SandboxState, x as SearchBuilder, w as SearchClient, W as SearchEntry, Q as SearchFields, O as SearchFilter, G as SearchHitMetadata, B as SearchMode, I as SearchResponse, D as SearchResultItem, U as SearchSort, V as SearchTypeName, g as SendOptions, q as SettingsClient, v as SettingsFetchOptions, z as SimilarBuilder, N as SimilarResponse, M as SimilarResult, p as SingletonClient, u as SingletonFetchOptions, d as TypedClientConfig, T as TypedRelyIOClient, aB as UploadProgress, ax as WaitUntilReadyOptions, c as createClient, c as default, h as entityTagOf, ai as isAssetEntry, aF as isResourceNotFound, aL as validateFile } from './index-CPjJ25R4.js';
3
3
  export { fields } from './schema/index.js';
4
- import { S as SDKError, B as BaseContent } from './index-C73cK2Tt.js';
5
- export { c as ApiMethod, A as ApiPath, w as ApiResponse, d as ApiSuccessBody, H as BaseValidationError, t as CacheConfig, y as CacheStrategy, k as ContentQueryResult, o as ContentTypeSchema, C as CreateInput, n as CustomQuery, D as DebugConfig, E as Environment, p as FieldOptions, F as FieldTypeName, J as InvalidPayloadError, L as LiveWebSocket, b as LiveWebSocketConstructor, z as LogLevel, M as MatchRouteOptions, P as PerformanceMetrics, Q as QueryOptions, u as RealtimeConfig, r as RealtimeEvent, q as RealtimeEventType, R as RelyIOConfig, a as RelyIOConfigUpdate, v as RequestConfig, x as RetryConfig, e as RouteMatch, l as SingletonContent, j as SortOptions, s as SubscriptionOptions, U as UpdateInput, I as ValidationError, V as ValidationRule, G as ValidationViolation, h as WhereClause, g as WhereFieldCondition, i as WhereOperator, f as WhereScalar, W as Wire, m as matchRoute } from './index-C73cK2Tt.js';
4
+ import { bx as SDKError, ap as EntryMetadata } from './include-paths-Cb7iPCW2.js';
5
+ export { bD as ApiMethod, bC as ApiPath, ca as ApiResponse, bE as ApiSuccessBody, bJ as AssetFileBlock, a9 as AssetReading, aJ as AssetServedBlocks, aF as AssetTypeConfig, aG as AssetTypeDefinition, bK as AssetUrls, bL as BaseContent, B as BaseFieldConfig, cg as BaseValidationError, a7 as BlockOf, c6 as CacheConfig, cc as CacheStrategy, ab as CheckInclude, aa as CheckedIncludes, bX as ContentQueryResult, ac as ContentReading, an as ContentTypeConfig, ao as ContentTypeDefinition, b_ as ContentTypeSchema, bT as CreateInput, bZ as CustomQuery, bQ as DateOnlyOperator, c8 as DebugConfig, ce as Environment, g as FieldDefinition, am as FieldMember, c1 as FieldOptions, h as FieldRule, a1 as FieldSchemaContext, i as FieldType, b$ as FieldTypeName, j as FieldUIConfig, a2 as FieldValue, a3 as FieldValues, al as Fieldset, aM as FileKindConfig, a_ as FileScanConfig, aZ as FileUploadConfig, aS as ImageExifConfig, aK as ImageKindConfig, aR as ImageSourceConfig, aQ as ImageUploadConfig, ad as IncludablePaths, aI as InferAssetEntry, aH as InferAssetType, aq as InferContentType, bt as InferJsonSchema, ay as InferSingleton, ax as InferSingletonContentType, ci as InvalidPayloadError, bu as JsonFieldValue, bv as JsonSchema, bw as JsonValue, a6 as Keyed, bA as LiveWebSocket, bB as LiveWebSocketConstructor, ar as LocalePublicationFields, k as LocalizationConfig, cd as LogLevel, bI as MatchRouteOptions, c5 as PerformanceMetrics, bS as QueryOptions, af as ReadWith, ae as Reading, c7 as RealtimeConfig, c3 as RealtimeEvent, c2 as RealtimeEventType, by as RelyIOConfig, bz as RelyIOConfigUpdate, c9 as RequestConfig, bV as RestoredContent, cb as RetryConfig, bU as RevisedContent, bH as RouteMatch, aA as SettingsGroupConfig, aB as SettingsGroupDefinition, ag as SettingsReading, a8 as ShapeValue, bY as SingletonContent, av as SingletonContentTypeDefinition, aw as SingletonMetadata, ah as SingletonReading, bR as SortOptions, c4 as SubscriptionOptions, a5 as UnresolvedEntry, ai as UntypedReading, bW as UpdateInput, ch as ValidationError, c0 as ValidationRule, cf as ValidationViolation, aT as VariantDefinition, aW as VideoCaptionsConfig, aX as VideoDownloadConfig, aL as VideoKindConfig, aV as VideoPosterConfig, aU as VideoUploadConfig, aY as VideoWatermarkConfig, bO as WhereClause, bN as WhereFieldCondition, bP as WhereOperator, bM as WhereScalar, bF as Wire, aE as defineAssetType, aj as defineContentType, az as defineSettingsGroup, at as defineSingleton, as as defineSingletonContentType, ak as fieldset, bG as matchRoute } from './include-paths-Cb7iPCW2.js';
6
6
  import { VisitorRetry } from './live-visitor.js';
7
7
  export { camelToSnake, createDeferred, debounce, deepClone, generateId, isBrowser, isNode, isPlainObject, isValidEmail, isValidUrl, mergeDeep, omit, pick, retry, sleep, snakeToCamel, throttle, toSafeString } from './utils/index.js';
8
- import { Q as EntryMetadata } from './define-content-type-ENAod5Ve.js';
9
- export { a5 as AssetTypeConfig, a9 as AssetTypeDefinition, n as BaseFieldConfig, M as ContentTypeConfig, N as ContentTypeConfigWithFields, O as ContentTypeConfigWithFieldsets, P as ContentTypeDefinition, c as FieldDefinition, b as FieldRule, v as FieldSchemaContext, p as FieldType, F as FieldUIConfig, w as FieldValue, x as FieldValues, K as Fieldset, ad as FileKindConfig, ar as FileScanConfig, aq as FileUploadConfig, aj as ImageExifConfig, ab as ImageKindConfig, ai as ImageSourceConfig, ah as ImageUploadConfig, aa as InferAssetType, W as InferContentType, a3 as InferSingleton, a2 as InferSingletonContentType, X as LocalePublicationFields, L as LocalizationConfig, a0 as SingletonContentTypeDefinition, a1 as SingletonMetadata, G as UnresolvedComponent, z as UnresolvedEntry, ak as VariantDefinition, an as VideoCaptionsConfig, ao as VideoDownloadConfig, ac as VideoKindConfig, am as VideoPosterConfig, al as VideoUploadConfig, ap as VideoWatermarkConfig, a4 as defineAssetType, H as defineContentType, Z as defineSingleton, Y as defineSingletonContentType, J as fieldset } from './define-content-type-ENAod5Ve.js';
10
- export { a9 as AggregateBlock, C as ComponentConfig, s as ComponentDefinition, t as ComponentMetadata, a8 as FetchBlock, am as FilterDefinition, ai as IncludeDefinition, aw as InferQueryParams, av as InferQueryResponse, a4 as QueryConfig, a5 as QueryDefinition, h as SchemaAssetTypeNames, S as SchemaConfig, b as SchemaContentTypeNames, a as SchemaDefinition, i as SchemaEntry, j as SchemaEntryOf, f as SchemaLocaleCodes, e as SchemaQueryNames, g as SchemaSettingsGroupNames, c as SchemaSingletonNames, aa as SearchBlock, al as SelectMapping, x as SettingsGroupConfig, y as SettingsGroupDefinition, ag as SortCondition, ab as WhereCondition, r as defineComponent, a3 as defineQuery, d as defineSchema, w as defineSettingsGroup } from './define-schema-CVi8nwc7.js';
8
+ export { n as RICH_TEXT_VOID_TAGS, R as RelyIOFieldAttributes, a as RelyIOFieldName, b as RelyIOFieldPath, c as RelyIOKeyed, q as RichTextAnchorsOption, t as RichTextAttributes, u as RichTextBlocksOf, v as RichTextDeclaredOf, w as RichTextDeclaredWriters, x as RichTextEntryLinkOf, y as RichTextEntryLinkOption, j as RichTextHtmlDeclaredWriters, k as RichTextHtmlFieldOption, l as RichTextHtmlOptions, z as RichTextInlineOf, m as RichTextMarkdownOptions, A as RichTextNodeContext, B as RichTextRenderable, C as RichTextRenderableOf, D as RichTextReplaceableNode, E as RichTextTag, F as RichTextTarget, e as entryHeadingAnchors, g as escapeHtml, o as isDeclaredRichTextNode, r as relyioField, p as renderRichText, d as richTextHeadingAnchors, f as richTextHeadingSlug, h as richTextToHtml, i as richTextToMarkdown, s as safeRichTextHref } from './index-8DozAWsA.js';
9
+ export { I as AggregateBlock, H as FetchBlock, Z as FilterDefinition, V as IncludeDefinition, a7 as InferQueryParams, a6 as InferQueryResponse, Q as QueryConfig, D as QueryDefinition, h as SchemaAssetTypeNames, S as SchemaConfig, b as SchemaContentTypeNames, a as SchemaDefinition, i as SchemaEntry, j as SchemaEntryOf, f as SchemaLocaleCodes, e as SchemaQueryNames, g as SchemaSettingsGroupNames, c as SchemaSingletonNames, J as SearchBlock, Y as SelectMapping, P as SortCondition, W as WhereCondition, C as defineQuery, d as defineSchema } from './define-schema-UHViXKiv.js';
10
+ export { e as RichTextBlock, f as RichTextCellAlignment, g as RichTextCodeBlock, h as RichTextCodeGroup, i as RichTextCodeLines, j as RichTextDivider, d as RichTextEntryLinkMark, k as RichTextHeading, l as RichTextInline, m as RichTextLineBreak, n as RichTextLinkMark, o as RichTextList, p as RichTextListItem, q as RichTextListStyle, r as RichTextMark, s as RichTextMarkType, t as RichTextNode, u as RichTextParagraph, v as RichTextQuote, w as RichTextSpan, x as RichTextStructure, y as RichTextTable, z as RichTextTableCell, B as RichTextTableRow, b as RichTextValue } from './rich-text.d-BWc-5gX1.js';
11
11
  import './dev-handshake/index.js';
12
12
 
13
13
  /**
14
- * What a key may do is in its prefix. A RelyIO key is `rly_{scope}_v1_{entropy}_{checksum}`, and a
15
- * publishable key — the one project key that may sit in a browser (`sdk-surfaces-spec.md` decision
16
- * 29) — is scope `pub`. Its scope is in its prefix so that no stored flag can disagree with it.
14
+ * What a key may do is in its prefix. A RelyIO project key is
15
+ * `rly_{scope}_{region}_v2_{entropy}_{checksum}`: the scope first, then the region of its project's
16
+ * data, which RelyIO's edge routes by and this package never reads. A publishable key — the one
17
+ * project key that may sit in a browser (`sdk-surfaces-spec.md` decision 29) — is scope `pub`. Its
18
+ * scope is in its prefix so that no stored flag can disagree with it.
17
19
  *
18
20
  * The truth is the service's: `isPublishableApiKey` in
19
21
  * `packages/data/metadata-db/src/utils/api-key-generator.ts`, which decides whether a presented key is
@@ -812,70 +814,41 @@ declare const localeHelpers: {
812
814
  };
813
815
 
814
816
  /**
815
- * The DOM↔field binding contract, as the one pure helper that emits it.
816
- *
817
- * Spread onto the element that renders a field, it stamps which entry, content type, field and
818
- * locale produced that element, so an editing surface can find the field by scanning the DOM
819
- * rather than by guessing (`INV-TB-BINDING`). The contract is `toolbar-spec.md` §DOM↔field; this
820
- * file is its only implementation.
821
- *
822
- * **Frozen** (`INV-SS-BINDING-FROZEN`). The attribute set is exactly the five below. Adding,
823
- * renaming or dropping one is a new contract, and a new contract is a bump of `data-relyio-v` — a
824
- * page built against version 1 keeps being read as version 1 by any surface that scans it.
825
- *
826
- * **Pure** (`INV-TB-SDK-PURE`). It reads the entry it is handed and returns attributes. It imports
827
- * nothing but the SDK's own types: no realtime, no AI, no first-party code, no framework. That is
828
- * what lets it live in the customer SDK and run on a server render as happily as in a browser.
829
- *
830
- * **Every value comes from the entry.** The id, the content type and the locale are the ones the
831
- * API reported in `_metadata` — the locale is the one the payload's field values were composed
832
- * for. There is deliberately no `locale` argument: a caller-supplied locale could bind a node to a
833
- * locale whose value it is not rendering, which is the silently inferred binding `INV-TB-BINDING`
834
- * forbids.
835
- */
836
-
837
- /** The version of the binding contract this helper emits. */
838
- declare const BINDING_VERSION = "1";
839
- /** The attributes `relyioField` returns — the whole of binding contract version 1. */
840
- interface RelyIOFieldAttributes {
841
- /** The entry's id (`_metadata.id`). */
842
- readonly 'data-relyio-entry': string;
843
- /** The entry's content type (`_metadata.type`); every customer read is keyed by it. */
844
- readonly 'data-relyio-type': string;
845
- /** The field the element renders. */
846
- readonly 'data-relyio-field': string;
847
- /** The locale the entry's field values were composed for (`_metadata.locale`). */
848
- readonly 'data-relyio-locale': string;
849
- /** The binding contract's version. */
850
- readonly 'data-relyio-v': typeof BINDING_VERSION;
851
- }
817
+ * A key path (REL-1814): where a value sits inside an entry, each item on the way named by its
818
+ * `_key` — `sections[_key=="f2k6ub9s"].heading`. A field by its id (`title`), a field of an object's
819
+ * value after the object's (`hero.title`), an item of a list by its key (`faq[_key=="k1"]`) and a
820
+ * field of that item after it (`faq[_key=="k1"].question`), to any depth. Inside a rich-text field a
821
+ * key names a declared Block or Inline element wherever it stands in the tree (`body[_key=="c1"]`):
822
+ * a key is unique within the field, nested trees included, so the path needs no step for the quote
823
+ * or the list item around it, and a field of the node follows it (`body[_key=="c1"].caption`).
824
+ *
825
+ * It is the spelling a validation error's path, a live binding, a comment's anchor and a filled
826
+ * field's path already use, so the address a page stamps is the one the Studio opens a field by,
827
+ * and it stays on its item when the list is reordered — which an index would not. The rule is
828
+ * `@relyio/schema`'s `formatItemPath` and `parseKeyedPath`, restated here because this package takes
829
+ * no runtime from that one (it is build-inlined for types only); `devtools/verification`'s
830
+ * `key-paths-sdk.test.ts` holds the two to one corpus.
831
+ */
832
+ /** One step of a key path: a field by its id, or the item of the list (or rich text) before it. */
833
+ type KeyPathSegment = {
834
+ readonly field: string;
835
+ } | {
836
+ readonly key: string;
837
+ };
852
838
  /**
853
- * The field names `relyioField` accepts for an entry of type `T`.
854
- *
855
- * A schema-typed entry narrows to its declared field names, so they autocomplete and a misspelt
856
- * one does not compile. An entry with no declared fields — `BaseContent`, which is what an
857
- * un-generated client returns — has none to narrow to, and `keyof` of it is `never`; that would
858
- * make the helper uncallable for every untyped customer, so it accepts any field name instead.
839
+ * The key path of an item of the list at `listPath` — `faq[_key=="k1"]` — or of a field inside it
840
+ * when `field` is given: `faq[_key=="k1"].question`. The key is written as a JSON string, so a quote
841
+ * in it stays inside it. `listPath` and `field` are key paths of their own (`sections[_key=="a"].links`,
842
+ * `link.label`).
859
843
  */
860
- type RelyIOFieldName<T extends BaseContent> = [Exclude<keyof T, '_metadata'>] extends [never] ? string : string & Exclude<keyof T, '_metadata'>;
844
+ declare function formatKeyPath(listPath: string, key: string, field?: string): string;
861
845
  /**
862
- * Binding attributes for one field of one entry.
863
- *
864
- * @example
865
- * ```tsx
866
- * import { relyioField } from '@relyio/sdk'
867
- *
868
- * <h1 {...relyioField(post, 'title')}>{post.title}</h1>
869
- * // → data-relyio-entry="6710f…" data-relyio-type="post" data-relyio-field="title"
870
- * // data-relyio-locale="en-US" data-relyio-v="1"
871
- * ```
872
- *
873
- * @throws {TypeError} when the entry's `_metadata` lacks its id, content type or locale. Every
874
- * entry the API returns carries all three, so this is reached only by a value that was not read
875
- * from RelyIO. It throws rather than emitting a partial binding: a node stamped with no locale, or
876
- * none at all, is a binding a surface would have to guess the rest of.
846
+ * A key path read back into its steps: `sections[_key=="a"].links[_key=="b"].label` → `sections`,
847
+ * `a`, `links`, `b`, `label`. A path with no item in it is its field ids (`hero.title` → `hero`,
848
+ * `title`). `null` for anything else — an index (`faq[0]`), an item of an item, an unterminated or
849
+ * empty key, an empty field id — which names no value by key.
877
850
  */
878
- declare function relyioField<T extends BaseContent>(entry: T, field: RelyIOFieldName<T>): RelyIOFieldAttributes;
851
+ declare function parseKeyPath(path: string): KeyPathSegment[] | null;
879
852
 
880
853
  /**
881
854
  * The DOM event a preview surface dispatches when content on the page has changed, and the one
@@ -1006,4 +979,4 @@ declare function snapToLadder(value: number): number;
1006
979
 
1007
980
  declare const VERSION = "__VERSION__";
1008
981
 
1009
- export { AuthorizationError, BaseContent, Change, type ChangeSource, type ChangeSourceOptions, ChangesExpiredError, ChangesExpiredReason, ConnectionError, EntryMetadata, ErrorMapper, FOLLOW_BACK_OFF_MAX_MS, FOLLOW_RETRY_BASE_MS, FOLLOW_RETRY_MAX_MS, type FollowEnd, type FollowOptions, type FollowResync, type FollowState, type FollowVerdict, IMAGE_LADDER, InvalidApiKeyError, type LanguageSwitcherOption, type LanguageSwitcherOptions, type LiveEdgeEnd, LiveEdgeError, type LocaleMetadata, type LocaleStatus, type LocalizedEntry, MethodNotAllowedError, MissingApiKeyError, NetworkError, PUBLISHABLE_KEY_PREFIX, PayloadTooLargeError, PlanFeatureUnavailableError, RELYIO_CHANGE_EVENT, RELYIO_RESYNC_EVENT, RateLimitError, ReadOnlyKeyError, type RelyIOChangeDetail, type RelyIOFieldAttributes, type RelyIOFieldName, type RelyIOResyncDetail, SDKError, ServerError, ServiceIndeterminateError, TimeoutError, TransactionRolledBackError, type TranslationCompleteness, UnknownContractError, UsageQuotaExceededError, VERSION, buildLanguageSwitcher, classifyFollowFailure, estimateTranslationCompleteness, followChanges, getAllLocalizedValues, getAvailableLocaleCodes, getDefaultLocale, getFallbackFields, getFieldFallbackLocale, getLocalizedField, getPublishedLocaleCodes, getRequestedLocale, hasLocale, isFieldFallback, isPublishableKey, isPublishedInLocale, localeHelpers, needsTranslation, relyioField, snapToLadder };
982
+ export { AuthorizationError, Change, type ChangeSource, type ChangeSourceOptions, ChangesExpiredError, ChangesExpiredReason, ConnectionError, EntryMetadata, ErrorMapper, FOLLOW_BACK_OFF_MAX_MS, FOLLOW_RETRY_BASE_MS, FOLLOW_RETRY_MAX_MS, type FollowEnd, type FollowOptions, type FollowResync, type FollowState, type FollowVerdict, IMAGE_LADDER, InvalidApiKeyError, type KeyPathSegment, type LanguageSwitcherOption, type LanguageSwitcherOptions, type LiveEdgeEnd, LiveEdgeError, type LocaleMetadata, type LocaleStatus, type LocalizedEntry, MethodNotAllowedError, MissingApiKeyError, NetworkError, PUBLISHABLE_KEY_PREFIX, PayloadTooLargeError, PlanFeatureUnavailableError, RELYIO_CHANGE_EVENT, RELYIO_RESYNC_EVENT, RateLimitError, ReadOnlyKeyError, type RelyIOChangeDetail, type RelyIOResyncDetail, SDKError, ServerError, ServiceIndeterminateError, TimeoutError, TransactionRolledBackError, type TranslationCompleteness, UnknownContractError, UsageQuotaExceededError, VERSION, buildLanguageSwitcher, classifyFollowFailure, estimateTranslationCompleteness, followChanges, formatKeyPath, getAllLocalizedValues, getAvailableLocaleCodes, getDefaultLocale, getFallbackFields, getFieldFallbackLocale, getLocalizedField, getPublishedLocaleCodes, getRequestedLocale, hasLocale, isFieldFallback, isPublishableKey, isPublishedInLocale, localeHelpers, needsTranslation, parseKeyPath, snapToLadder };
package/dist/index.js CHANGED
@@ -1,9 +1,10 @@
1
- export { defineAssetType, defineComponent, defineContentType, defineQuery, defineSchema, defineSettingsGroup, defineSingleton, defineSingletonContentType, fields, fieldset } from './chunk-2TIJLV2X.js';
2
- import { LiveEdgeError, SDKError, serviceInstructedDelayMs, VISITOR_ADMISSION_RETRY_AFTER_SECONDS, isAborted, sleep } from './chunk-7GLDVHIH.js';
3
- export { AdhocQueryBuilder, AdhocQueryClient, AssetClient, AssetFileBuilder, AssetUploadBuilder, AuthorizationError, AutocompleteBuilder, BaseValidationError, BatchBuilder, BatchClient, ChangesExpiredError, ConnectionError, ContentByIdBuilder, ContentClient, ContentQueryBuilder, ErrorMapper, FileUploadError, FileValidationError, HttpClient, InvalidApiKeyError, InvalidPayloadError, LIVE_KEEPALIVE_INTERVAL_MS, LIVE_SOCKET_OPEN_TIMEOUT_MS, LiveEdgeError, MethodNotAllowedError, MissingApiKeyError, NetworkError, PUBLISHABLE_KEY_PREFIX, PayloadTooLargeError, PlanFeatureUnavailableError, RateLimitError, ReadOnlyKeyError, ResourceConflictError, ResourceExpiredError, ResourceNotFoundError, SDKError, SearchBuilder, SearchClient, ServerError, ServiceIndeterminateError, SettingsClient, SimilarBuilder, SingletonClient, TimeoutError, TransactionRolledBackError, TypedRelyIOClient, UnknownContractError, UsageQuotaExceededError, ValidationError, createClient, createClient as default, entityTagOf, isAssetEntry, isPublishableKey, isResourceNotFound, matchRoute, validateFile } from './chunk-7GLDVHIH.js';
1
+ export { defineAssetType, defineContentType, defineQuery, defineSchema, defineSettingsGroup, defineSingleton, defineSingletonContentType, fields, fieldset } from './chunk-EW23SZPX.js';
2
+ import { LiveEdgeError, SDKError, serviceInstructedDelayMs, VISITOR_ADMISSION_RETRY_AFTER_SECONDS, isAborted, sleep } from './chunk-6NGJXLOR.js';
3
+ export { AdhocQueryBuilder, AdhocQueryClient, AssetClient, AssetFileBuilder, AssetUploadBuilder, AuthorizationError, AutocompleteBuilder, BaseValidationError, BatchBuilder, BatchClient, ChangesExpiredError, ConnectionError, ContentByIdBuilder, ContentClient, ContentQueryBuilder, ErrorMapper, FileUploadError, FileValidationError, HttpClient, InvalidApiKeyError, InvalidPayloadError, LIVE_KEEPALIVE_INTERVAL_MS, LIVE_SOCKET_OPEN_TIMEOUT_MS, LiveEdgeError, MethodNotAllowedError, MissingApiKeyError, NetworkError, PUBLISHABLE_KEY_PREFIX, PayloadTooLargeError, PlanFeatureUnavailableError, RateLimitError, ReadOnlyKeyError, ResourceConflictError, ResourceExpiredError, ResourceNotFoundError, SDKError, SearchBuilder, SearchClient, ServerError, ServiceIndeterminateError, SettingsClient, SimilarBuilder, SingletonClient, TimeoutError, TransactionRolledBackError, TypedRelyIOClient, UnknownContractError, UsageQuotaExceededError, ValidationError, createClient, createClient as default, entityTagOf, isAssetEntry, isPublishableKey, isResourceNotFound, matchRoute, validateFile } from './chunk-6NGJXLOR.js';
4
4
  import './chunk-BBUB7C2Z.js';
5
5
  import './chunk-IY5LSKXU.js';
6
6
  export { camelToSnake, createDeferred, debounce, deepClone, generateId, isBrowser, isNode, isPlainObject, isValidEmail, isValidUrl, mergeDeep, omit, pick, retry, sleep, snakeToCamel, throttle, toSafeString } from './chunk-H6IBQSMM.js';
7
+ export { RICH_TEXT_VOID_TAGS, entryHeadingAnchors, escapeHtml, formatKeyPath, isDeclaredRichTextNode, parseKeyPath, relyioField, renderRichText, richTextHeadingAnchors, richTextHeadingSlug, richTextToHtml, richTextToMarkdown, safeRichTextHref } from './chunk-3NPPMGB6.js';
7
8
  import { __name } from './chunk-XQ4QHWZE.js';
8
9
 
9
10
  /* RelyIO SDK - Built with ❤️ by the RelyIO Team */
@@ -252,30 +253,6 @@ var localeHelpers = {
252
253
  getAllLocalizedValues
253
254
  };
254
255
 
255
- // src/binding/relyio-field.ts
256
- var BINDING_VERSION = "1";
257
- function relyioField(entry, field) {
258
- const metadata = entry._metadata;
259
- return {
260
- "data-relyio-entry": requireMetadata(metadata, "id", field),
261
- "data-relyio-type": requireMetadata(metadata, "type", field),
262
- "data-relyio-field": field,
263
- "data-relyio-locale": requireMetadata(metadata, "locale", field),
264
- "data-relyio-v": BINDING_VERSION
265
- };
266
- }
267
- __name(relyioField, "relyioField");
268
- function requireMetadata(metadata, key, field) {
269
- const value = metadata?.[key];
270
- if (typeof value !== "string" || value.length === 0) {
271
- throw new TypeError(
272
- `relyioField(entry, '${field}'): the entry has no _metadata.${key}, so the field cannot be bound. Pass an entry as the RelyIO API returned it.`
273
- );
274
- }
275
- return value;
276
- }
277
- __name(requireMetadata, "requireMetadata");
278
-
279
256
  // src/binding/change-event.ts
280
257
  var RELYIO_CHANGE_EVENT = "relyio:change";
281
258
  var RELYIO_RESYNC_EVENT = "relyio:resync";
@@ -297,6 +274,6 @@ __name(snapToLadder, "snapToLadder");
297
274
  // src/index.ts
298
275
  var VERSION = "__VERSION__";
299
276
 
300
- export { FOLLOW_BACK_OFF_MAX_MS, FOLLOW_RETRY_BASE_MS, FOLLOW_RETRY_MAX_MS, IMAGE_LADDER, RELYIO_CHANGE_EVENT, RELYIO_RESYNC_EVENT, VERSION, buildLanguageSwitcher, classifyFollowFailure, estimateTranslationCompleteness, followChanges, getAllLocalizedValues, getAvailableLocaleCodes, getDefaultLocale, getFallbackFields, getFieldFallbackLocale, getLocalizedField, getPublishedLocaleCodes, getRequestedLocale, hasLocale, isFieldFallback, isPublishedInLocale, localeHelpers, needsTranslation, relyioField, snapToLadder };
277
+ export { FOLLOW_BACK_OFF_MAX_MS, FOLLOW_RETRY_BASE_MS, FOLLOW_RETRY_MAX_MS, IMAGE_LADDER, RELYIO_CHANGE_EVENT, RELYIO_RESYNC_EVENT, VERSION, buildLanguageSwitcher, classifyFollowFailure, estimateTranslationCompleteness, followChanges, getAllLocalizedValues, getAvailableLocaleCodes, getDefaultLocale, getFallbackFields, getFieldFallbackLocale, getLocalizedField, getPublishedLocaleCodes, getRequestedLocale, hasLocale, isFieldFallback, isPublishedInLocale, localeHelpers, needsTranslation, snapToLadder };
301
278
  //# sourceMappingURL=index.js.map
302
279
  //# sourceMappingURL=index.js.map