@callimacus/thamyr-core 4.8.3 → 4.10.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.
@@ -333,6 +333,7 @@ interface TDataShape {
333
333
  type OmitKeys<T, K> = Pick<T, Exclude<keyof T, K>>;
334
334
  type Options$1<TData extends TDataShape = TDataShape, ThrowOnError extends boolean = boolean, TResponse = unknown, TResponseStyle extends ResponseStyle = 'fields'> = OmitKeys<RequestOptions<TResponse, TResponseStyle, ThrowOnError>, 'body' | 'path' | 'query' | 'url'> & ([TData] extends [never] ? unknown : Omit<TData, 'url'>);
335
335
 
336
+ type LanguageCode = 'aa' | 'ab' | 'ae' | 'af' | 'ak' | 'am' | 'an' | 'ar' | 'as' | 'av' | 'ay' | 'az' | 'ba' | 'be' | 'bg' | 'bi' | 'bm' | 'bn' | 'bo' | 'br' | 'bs' | 'ca' | 'ce' | 'ch' | 'co' | 'cr' | 'cs' | 'cu' | 'cv' | 'cy' | 'da' | 'de' | 'dv' | 'dz' | 'ee' | 'el' | 'en' | 'eo' | 'es' | 'et' | 'eu' | 'fa' | 'ff' | 'fi' | 'fj' | 'fo' | 'fr' | 'fy' | 'ga' | 'gd' | 'gl' | 'gn' | 'gu' | 'gv' | 'ha' | 'he' | 'hi' | 'ho' | 'hr' | 'ht' | 'hu' | 'hy' | 'hz' | 'ia' | 'id' | 'ie' | 'ig' | 'ii' | 'ik' | 'io' | 'is' | 'it' | 'iu' | 'ja' | 'jv' | 'ka' | 'kg' | 'ki' | 'kj' | 'kk' | 'kl' | 'km' | 'kn' | 'ko' | 'kr' | 'ks' | 'ku' | 'kv' | 'kw' | 'ky' | 'la' | 'lb' | 'lg' | 'li' | 'ln' | 'lo' | 'lt' | 'lu' | 'lv' | 'mg' | 'mh' | 'mi' | 'mk' | 'ml' | 'mn' | 'mr' | 'ms' | 'mt' | 'my' | 'na' | 'nb' | 'nd' | 'ne' | 'ng' | 'nl' | 'nn' | 'no' | 'nr' | 'nv' | 'ny' | 'oc' | 'oj' | 'om' | 'or' | 'os' | 'pa' | 'pi' | 'pl' | 'ps' | 'pt' | 'qu' | 'rm' | 'rn' | 'ro' | 'ru' | 'rw' | 'sa' | 'sc' | 'sd' | 'se' | 'sg' | 'si' | 'sk' | 'sl' | 'sm' | 'sn' | 'so' | 'sq' | 'sr' | 'ss' | 'st' | 'su' | 'sv' | 'sw' | 'ta' | 'te' | 'tg' | 'th' | 'ti' | 'tk' | 'tl' | 'tn' | 'to' | 'tr' | 'ts' | 'tt' | 'tw' | 'ty' | 'ug' | 'uk' | 'ur' | 'uz' | 've' | 'vi' | 'vo' | 'wa' | 'wo' | 'xh' | 'yi' | 'yo' | 'za' | 'zh' | 'zu';
336
337
  type ChapterStatus$1 = 1 | 2 | 3 | 4;
337
338
  type GalleryMode$1 = 'masonry' | 'carousel';
338
339
  type SlInputEvent = {
@@ -426,6 +427,21 @@ type TopicContentsPage = {
426
427
  offset: number;
427
428
  limit: number;
428
429
  };
430
+ type DocumentIndexEntry = {
431
+ /**
432
+ * The page path, `/map/{language}/{slug}` — what a link to the document points at
433
+ */
434
+ path: string;
435
+ slug: string;
436
+ /**
437
+ * The meta title, or the document name when none is set
438
+ */
439
+ title: string;
440
+ /**
441
+ * The meta description, when set
442
+ */
443
+ description?: string;
444
+ };
429
445
  type RecommendationsResponse = {
430
446
  directRecommendations: Array<ProductMatch>;
431
447
  inverseRecommendations: Array<ProductMatch>;
@@ -462,6 +478,44 @@ type WhisperPayload = {
462
478
  generated_at: number;
463
479
  ttl_ms: number;
464
480
  };
481
+ type SkesisItemPage = {
482
+ /**
483
+ * The canonical page path, `/map/{locale}/{slug}/{id}`, as the sitemap lists it
484
+ */
485
+ path: string;
486
+ /**
487
+ * The catalogue locale the item is read in, as the engine spells it (e.g. `en-IT`)
488
+ */
489
+ locale: string;
490
+ kind: string;
491
+ /**
492
+ * The URL segment the site publishes the item's kind under
493
+ */
494
+ slug: string;
495
+ /**
496
+ * The item's title, or its id when it has none
497
+ */
498
+ title: string;
499
+ /**
500
+ * The item's description, as plain text
501
+ */
502
+ description?: string;
503
+ /**
504
+ * The URL of the item's first image
505
+ */
506
+ image?: string;
507
+ /**
508
+ * The item as stored, for a page that shows more than the crawler is served
509
+ */
510
+ item: {
511
+ id: string;
512
+ kind: string;
513
+ locale: string;
514
+ fields: {
515
+ [key: string]: unknown;
516
+ };
517
+ };
518
+ };
465
519
  type ProductMatch = {
466
520
  match?: {
467
521
  id: string;
@@ -793,6 +847,19 @@ type ChapterOutput = {
793
847
  };
794
848
  references?: Array<string>;
795
849
  blocks?: Array<BlockOutput>;
850
+ /**
851
+ * The blocks this round will show, in page order, sent as soon as the page is decided and before their contents are ready, so a storefront can hold their places. A block whose contents find nothing is still dropped: `blocks` is the page; the outline is the shape it is expected to take. Sent only when the round asked for it (`context.outline`).
852
+ */
853
+ outline?: Array<{
854
+ /**
855
+ * The block's key, as its block will carry it.
856
+ */
857
+ key: string;
858
+ /**
859
+ * The block's type, as its block will carry it (`custom:<type>`).
860
+ */
861
+ type: string;
862
+ }>;
796
863
  status: ChapterStatus$1;
797
864
  };
798
865
  type CreateRoundContextOutput = {
@@ -825,6 +892,10 @@ type CreateRoundContextOutput = {
825
892
  * The page title, carried in a delivered interaction's envelope.
826
893
  */
827
894
  title?: string;
895
+ /**
896
+ * Ask for the round's `outline`: the blocks it will show, in page order, sent before their contents are ready. Without it, no outline is sent.
897
+ */
898
+ outline?: boolean;
828
899
  [key: string]: unknown;
829
900
  };
830
901
  type CustomBlockOutput = {
@@ -967,7 +1038,7 @@ type LocalizedEpArtworkOutput = {
967
1038
  type: 'ep';
968
1039
  };
969
1040
  type SlDocumentOutput = {
970
- language: string;
1041
+ language: LanguageCode;
971
1042
  type: 'content' | 'image' | 'video';
972
1043
  name: string;
973
1044
  backgroundKnowledge: boolean;
@@ -2678,6 +2749,26 @@ type ContentGetDocumentByPathResponses = {
2678
2749
  */
2679
2750
  200: SlDocumentOutput;
2680
2751
  };
2752
+ type ContentListDocumentsErrors = {
2753
+ /**
2754
+ * Validation error
2755
+ */
2756
+ 400: unknown;
2757
+ /**
2758
+ * Missing or invalid access token
2759
+ */
2760
+ 401: unknown;
2761
+ /**
2762
+ * The caller is not permitted to perform this operation
2763
+ */
2764
+ 403: PinaxForbidden;
2765
+ };
2766
+ type ContentListDocumentsResponses = {
2767
+ /**
2768
+ * Success
2769
+ */
2770
+ 200: Array<DocumentIndexEntry>;
2771
+ };
2681
2772
  type StoriesGetSharedErrors = {
2682
2773
  /**
2683
2774
  * Validation error
@@ -2956,6 +3047,37 @@ type SkesisRelatedResponses = {
2956
3047
  */
2957
3048
  200: SkesisRelatedResponse;
2958
3049
  };
3050
+ type SkesisGetItemByPathErrors = {
3051
+ /**
3052
+ * Validation error
3053
+ */
3054
+ 400: unknown;
3055
+ /**
3056
+ * Missing or invalid access token
3057
+ */
3058
+ 401: unknown;
3059
+ /**
3060
+ * The caller is not permitted to perform this operation
3061
+ */
3062
+ 403: PinaxForbidden;
3063
+ /**
3064
+ * Path did not resolve to a published item
3065
+ */
3066
+ 404: PublicError;
3067
+ /**
3068
+ * Skesis engine unavailable (rate cap, upstream failure, or not configured); retry later
3069
+ */
3070
+ 502: {
3071
+ error: string;
3072
+ errorId: string;
3073
+ };
3074
+ };
3075
+ type SkesisGetItemByPathResponses = {
3076
+ /**
3077
+ * Success
3078
+ */
3079
+ 200: SkesisItemPage;
3080
+ };
2959
3081
 
2960
3082
  type Options<TData extends TDataShape = TDataShape, ThrowOnError extends boolean = boolean, TResponse = unknown> = Options$1<TData, ThrowOnError, TResponse> & {
2961
3083
  /**
@@ -3033,6 +3155,14 @@ declare class Content extends HeyApiClient {
3033
3155
  getDocumentByPath<ThrowOnError extends boolean = false>(parameters: {
3034
3156
  path: string;
3035
3157
  }, options?: Options<never, ThrowOnError>): RequestResult<ContentGetDocumentByPathResponses, ContentGetDocumentByPathErrors, ThrowOnError>;
3158
+ /**
3159
+ * List the published documents in a language
3160
+ *
3161
+ * The entries of the per-language index at `/map/{language}`: every approved, published document with a slug, newest first, each with the path of its page and the title a link to it should carry. A language with no published document lists nothing, it is not a 404.
3162
+ */
3163
+ listDocuments<ThrowOnError extends boolean = false>(parameters: {
3164
+ language: string;
3165
+ }, options?: Options<never, ThrowOnError>): RequestResult<ContentListDocumentsResponses, ContentListDocumentsErrors, ThrowOnError>;
3036
3166
  }
3037
3167
  declare class Stories extends HeyApiClient {
3038
3168
  /**
@@ -3153,6 +3283,14 @@ declare class Skesis extends HeyApiClient {
3153
3283
  anchorId: string;
3154
3284
  locale?: string;
3155
3285
  }, options?: Options<never, ThrowOnError>): RequestResult<SkesisRelatedResponses, SkesisRelatedErrors, ThrowOnError>;
3286
+ /**
3287
+ * Get a catalogue item page by its path
3288
+ *
3289
+ * Resolves a `/map/{locale}/{slug}/{id}` path from the sitemap to what the crawler is served there: a visible item of a kind the site publishes as pages, in that locale. Pass the path as the browser shows it (`location.pathname`). A document wins a path both could name, so resolve a `/map/` path with `content.getDocumentByPath` first and with this read on its 404. A path that names no such item is a 404, not a 400.
3290
+ */
3291
+ getItemByPath<ThrowOnError extends boolean = false>(parameters: {
3292
+ path: string;
3293
+ }, options?: Options<never, ThrowOnError>): RequestResult<SkesisGetItemByPathResponses, SkesisGetItemByPathErrors, ThrowOnError>;
3156
3294
  }
3157
3295
  declare class CallimacusApi extends HeyApiClient {
3158
3296
  static readonly __registry: HeyApiRegistry<CallimacusApi>;
@@ -3802,6 +3940,90 @@ declare function addToCartResultOf(block: {
3802
3940
  */
3803
3941
  declare function applyBlockPatch(chapter: Chapter, patch: BlockPatch): Chapter;
3804
3942
 
3943
+ type ContractClient = Client;
3944
+ /**
3945
+ What a contract call rejects with under `{throwOnError: true}`.
3946
+
3947
+ - `status` is the HTTP status of the failed response, `undefined` when no response arrived (network or
3948
+ CORS failure). It can be 2xx when the response arrived but its body could not be parsed or validated.
3949
+ - `body` is the parsed error body the server sent — `{error, errorId}` on the public API, a string for
3950
+ non-JSON bodies, `{}` for an empty body — or, when no response arrived, the underlying `TypeError`
3951
+ (also exposed as `cause`).
3952
+
3953
+ Aborting a call through its `signal` is not a failure of the call: the abort reason is rethrown as is. The
3954
+ request signal decides, and it does so whether the abort landed before or after the response headers arrived.
3955
+ */
3956
+ declare class ThamyrHttpError extends Error {
3957
+ readonly status: number | undefined;
3958
+ readonly body: unknown;
3959
+ readonly response: Response | undefined;
3960
+ readonly request: Request | undefined;
3961
+ constructor(body: unknown, response?: Response, request?: Request);
3962
+ }
3963
+ /**
3964
+ Client for the generated {@link CallimacusApi}: the client id doubles as bearer token and x-sl-access-token.
3965
+ Calls made with `{throwOnError: true}` (per call, or through `setConfig`) reject with a
3966
+ {@link ThamyrHttpError}; the envelope's `error` stays the parsed body, as documented.
3967
+ */
3968
+ declare function createContractClient(config: {
3969
+ endpoint: string;
3970
+ accessToken: string;
3971
+ /**
3972
+ Send cookies cross-origin (the old axios `withCredentials`).
3973
+ */
3974
+ withCredentials?: boolean;
3975
+ }): ContractClient;
3976
+
3977
+ /**
3978
+ What a `/map/…` pathname names: the index of a language, or one of its documents.
3979
+ */
3980
+ type MapPath = {
3981
+ language: string;
3982
+ slug?: string;
3983
+ };
3984
+ /**
3985
+ Parses a `/map/{language}` or `/map/{language}/{slug}` pathname the way the
3986
+ server does: the leading slash is optional, the slug may contain slashes, and
3987
+ a trailing slash after the language still means the index. Anything else —
3988
+ another route, a bare `/map` — is `undefined`. Pass `location.pathname`, not
3989
+ the full URL: a query string or a hash would end up in the slug.
3990
+ */
3991
+ declare function parseMapPath(pathname: string): MapPath | undefined;
3992
+ /**
3993
+ What a `/map/…` pathname shows: one document, the per-language index, or one
3994
+ catalogue item (`language` is then the catalogue locale, `slug` the kind's
3995
+ slug and the item id).
3996
+ */
3997
+ type MapPage = {
3998
+ kind: 'document';
3999
+ language: string;
4000
+ slug: string;
4001
+ document: SLDocument;
4002
+ } | {
4003
+ kind: 'index';
4004
+ language: string;
4005
+ entries: DocumentIndexEntry[];
4006
+ } | {
4007
+ kind: 'item';
4008
+ language: string;
4009
+ slug: string;
4010
+ itemPage: SkesisItemPage;
4011
+ };
4012
+ /**
4013
+ Resolves what to show at a `/map/…` pathname: the document at
4014
+ `/map/{language}/{slug}`, the entries of the per-language index at
4015
+ `/map/{language}` — the same list the crawler is served, newest first — or the
4016
+ catalogue item at `/map/{locale}/{kind-slug}/{id}`. A document wins a path both
4017
+ could name, as it does in the server render.
4018
+ @param api - A `Thamyr` instance, or the React package's `thamyrApi`.
4019
+ @param pathname - `location.pathname`.
4020
+ @returns `undefined` when the pathname is not a `/map/` path or names no
4021
+ published document, so the caller renders its own not-found. Any other
4022
+ failure (network, a 5xx, an SDK not initialized) rejects — with a
4023
+ `ThamyrHttpError` when a response arrived.
4024
+ */
4025
+ declare function resolveMapPage(api: Pick<CallimacusApi, 'content' | 'skesis'>, pathname: string): Promise<MapPage | undefined>;
4026
+
3805
4027
  /**
3806
4028
  Structured payload the server attaches to a refused handshake (SOL-1100):
3807
4029
  `code` is an HTTP-style status — 4xx is a deliberate refusal, 5xx means the
@@ -4016,39 +4238,5 @@ declare function transformImageUrl(cdnUrl: string, edits: ImageEdits): string;
4016
4238
  */
4017
4239
  declare function randomUuid(): string;
4018
4240
 
4019
- type ContractClient = Client;
4020
- /**
4021
- What a contract call rejects with under `{throwOnError: true}`.
4022
-
4023
- - `status` is the HTTP status of the failed response, `undefined` when no response arrived (network or
4024
- CORS failure). It can be 2xx when the response arrived but its body could not be parsed or validated.
4025
- - `body` is the parsed error body the server sent — `{error, errorId}` on the public API, a string for
4026
- non-JSON bodies, `{}` for an empty body — or, when no response arrived, the underlying `TypeError`
4027
- (also exposed as `cause`).
4028
-
4029
- Aborting a call through its `signal` is not a failure of the call: the abort reason is rethrown as is. The
4030
- request signal decides, and it does so whether the abort landed before or after the response headers arrived.
4031
- */
4032
- declare class ThamyrHttpError extends Error {
4033
- readonly status: number | undefined;
4034
- readonly body: unknown;
4035
- readonly response: Response | undefined;
4036
- readonly request: Request | undefined;
4037
- constructor(body: unknown, response?: Response, request?: Request);
4038
- }
4039
- /**
4040
- Client for the generated {@link CallimacusApi}: the client id doubles as bearer token and x-sl-access-token.
4041
- Calls made with `{throwOnError: true}` (per call, or through `setConfig`) reject with a
4042
- {@link ThamyrHttpError}; the envelope's `error` stays the parsed body, as documented.
4043
- */
4044
- declare function createContractClient(config: {
4045
- endpoint: string;
4046
- accessToken: string;
4047
- /**
4048
- Send cookies cross-origin (the old axios `withCredentials`).
4049
- */
4050
- withCredentials?: boolean;
4051
- }): ContractClient;
4052
-
4053
- export { ACTION_TYPES, ADD_TO_CART_RESULT_BLOCK, CallimacusApi, CallimacusEvent, CallimacusService, ChapterStatus, ClientEvents, DELIVER_RESULT_BLOCK, GalleryMode, LANDING_VALUE_MAX_LENGTH, MAX_HANDSHAKE_RETRIES, SLInputEventType, ServerEvents, ThamyrHttpError, ThamyrResponseType, UserInteractionType, actionOf, addToCartResultOf, applyBlockPatch, blockKeyOf, callimacusService, classifyConnectError, createContractClient, deliverResultOf, extractTtsAudio, fieldsOf, interactionRound, isCustomBlock, isMasterProduct, isSetProduct, landingRound, logger, parseConnectRejection, randomUuid, receptorsOf, shouldRetryHandshake, transformImageUrl };
4054
- export type { Action, ActionType, AddToCartResult, BCProduct, Basket, Block, BlockPatch, BoundingBox, CallimacusErrorMessage, Chapter, ClientInfo, ConnectRejection, ConnectionStatusCallback, ContractClient, CustomBlock, DeliverResult, ErrorCallback, ErrorMessage, Gallery, GenericProduct, HomePage, Image, ImageEdits, ImageFormatEdit, ImageResizeEdit, InteractionContext, InteractionId, InteractionOptions, InteractionPayload, InteractionPayloadMap, LegacyBlock, LocalizedEPArtwork, LocalizedEPChapter, LogLevel, LoggerConfig, MasterProduct, MasterProductWithVariationGroup, OptionItem, ProductItem, ProductMatch, RecommendationsResponse, RiveManifest, RoundOptions, SLDocument, SLDocumentSection, SLInputEvent, ServerResponseCallback, SetProduct, SkesisItem, SkesisRelatedResponse, SkesisSimilarResponse, Story, SuggestPayload, Suggestions, ThamyrInteractionMap, ThamyrResponse, Topic, TopicContentsPage, TopicSummary, TtsAudio, UiElement, UiObserverConfig, UiSnapshot, UserInteraction, Variant, VariationAttribute, VariationGroup, Video, WhisperPayload };
4241
+ export { ACTION_TYPES, ADD_TO_CART_RESULT_BLOCK, CallimacusApi, CallimacusEvent, CallimacusService, ChapterStatus, ClientEvents, DELIVER_RESULT_BLOCK, GalleryMode, LANDING_VALUE_MAX_LENGTH, MAX_HANDSHAKE_RETRIES, SLInputEventType, ServerEvents, ThamyrHttpError, ThamyrResponseType, UserInteractionType, actionOf, addToCartResultOf, applyBlockPatch, blockKeyOf, callimacusService, classifyConnectError, createContractClient, deliverResultOf, extractTtsAudio, fieldsOf, interactionRound, isCustomBlock, isMasterProduct, isSetProduct, landingRound, logger, parseConnectRejection, parseMapPath, randomUuid, receptorsOf, resolveMapPage, shouldRetryHandshake, transformImageUrl };
4242
+ export type { Action, ActionType, AddToCartResult, BCProduct, Basket, Block, BlockPatch, BoundingBox, CallimacusErrorMessage, Chapter, ClientInfo, ConnectRejection, ConnectionStatusCallback, ContractClient, CustomBlock, DeliverResult, DocumentIndexEntry, ErrorCallback, ErrorMessage, Gallery, GenericProduct, HomePage, Image, ImageEdits, ImageFormatEdit, ImageResizeEdit, InteractionContext, InteractionId, InteractionOptions, InteractionPayload, InteractionPayloadMap, LegacyBlock, LocalizedEPArtwork, LocalizedEPChapter, LogLevel, LoggerConfig, MapPage, MapPath, MasterProduct, MasterProductWithVariationGroup, OptionItem, ProductItem, ProductMatch, RecommendationsResponse, RiveManifest, RoundOptions, SLDocument, SLDocumentSection, SLInputEvent, ServerResponseCallback, SetProduct, SkesisItem, SkesisItemPage, SkesisRelatedResponse, SkesisSimilarResponse, Story, SuggestPayload, Suggestions, ThamyrInteractionMap, ThamyrResponse, Topic, TopicContentsPage, TopicSummary, TtsAudio, UiElement, UiObserverConfig, UiSnapshot, UserInteraction, Variant, VariationAttribute, VariationGroup, Video, WhisperPayload };