@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.
@@ -331,6 +331,7 @@ interface TDataShape {
331
331
  type OmitKeys<T, K> = Pick<T, Exclude<keyof T, K>>;
332
332
  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'>);
333
333
 
334
+ 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';
334
335
  type ChapterStatus$1 = 1 | 2 | 3 | 4;
335
336
  type GalleryMode$1 = 'masonry' | 'carousel';
336
337
  type SlInputEvent = {
@@ -424,6 +425,21 @@ type TopicContentsPage = {
424
425
  offset: number;
425
426
  limit: number;
426
427
  };
428
+ type DocumentIndexEntry = {
429
+ /**
430
+ * The page path, `/map/{language}/{slug}` — what a link to the document points at
431
+ */
432
+ path: string;
433
+ slug: string;
434
+ /**
435
+ * The meta title, or the document name when none is set
436
+ */
437
+ title: string;
438
+ /**
439
+ * The meta description, when set
440
+ */
441
+ description?: string;
442
+ };
427
443
  type RecommendationsResponse = {
428
444
  directRecommendations: Array<ProductMatch>;
429
445
  inverseRecommendations: Array<ProductMatch>;
@@ -460,6 +476,44 @@ type WhisperPayload = {
460
476
  generated_at: number;
461
477
  ttl_ms: number;
462
478
  };
479
+ type SkesisItemPage = {
480
+ /**
481
+ * The canonical page path, `/map/{locale}/{slug}/{id}`, as the sitemap lists it
482
+ */
483
+ path: string;
484
+ /**
485
+ * The catalogue locale the item is read in, as the engine spells it (e.g. `en-IT`)
486
+ */
487
+ locale: string;
488
+ kind: string;
489
+ /**
490
+ * The URL segment the site publishes the item's kind under
491
+ */
492
+ slug: string;
493
+ /**
494
+ * The item's title, or its id when it has none
495
+ */
496
+ title: string;
497
+ /**
498
+ * The item's description, as plain text
499
+ */
500
+ description?: string;
501
+ /**
502
+ * The URL of the item's first image
503
+ */
504
+ image?: string;
505
+ /**
506
+ * The item as stored, for a page that shows more than the crawler is served
507
+ */
508
+ item: {
509
+ id: string;
510
+ kind: string;
511
+ locale: string;
512
+ fields: {
513
+ [key: string]: unknown;
514
+ };
515
+ };
516
+ };
463
517
  type ProductMatch = {
464
518
  match?: {
465
519
  id: string;
@@ -791,6 +845,19 @@ type ChapterOutput = {
791
845
  };
792
846
  references?: Array<string>;
793
847
  blocks?: Array<BlockOutput>;
848
+ /**
849
+ * 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`).
850
+ */
851
+ outline?: Array<{
852
+ /**
853
+ * The block's key, as its block will carry it.
854
+ */
855
+ key: string;
856
+ /**
857
+ * The block's type, as its block will carry it (`custom:<type>`).
858
+ */
859
+ type: string;
860
+ }>;
794
861
  status: ChapterStatus$1;
795
862
  };
796
863
  type CreateRoundContextOutput = {
@@ -823,6 +890,10 @@ type CreateRoundContextOutput = {
823
890
  * The page title, carried in a delivered interaction's envelope.
824
891
  */
825
892
  title?: string;
893
+ /**
894
+ * 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.
895
+ */
896
+ outline?: boolean;
826
897
  [key: string]: unknown;
827
898
  };
828
899
  type CustomBlockOutput = {
@@ -965,7 +1036,7 @@ type LocalizedEpArtworkOutput = {
965
1036
  type: 'ep';
966
1037
  };
967
1038
  type SlDocumentOutput = {
968
- language: string;
1039
+ language: LanguageCode;
969
1040
  type: 'content' | 'image' | 'video';
970
1041
  name: string;
971
1042
  backgroundKnowledge: boolean;
@@ -2676,6 +2747,26 @@ type ContentGetDocumentByPathResponses = {
2676
2747
  */
2677
2748
  200: SlDocumentOutput;
2678
2749
  };
2750
+ type ContentListDocumentsErrors = {
2751
+ /**
2752
+ * Validation error
2753
+ */
2754
+ 400: unknown;
2755
+ /**
2756
+ * Missing or invalid access token
2757
+ */
2758
+ 401: unknown;
2759
+ /**
2760
+ * The caller is not permitted to perform this operation
2761
+ */
2762
+ 403: PinaxForbidden;
2763
+ };
2764
+ type ContentListDocumentsResponses = {
2765
+ /**
2766
+ * Success
2767
+ */
2768
+ 200: Array<DocumentIndexEntry>;
2769
+ };
2679
2770
  type StoriesGetSharedErrors = {
2680
2771
  /**
2681
2772
  * Validation error
@@ -2954,6 +3045,37 @@ type SkesisRelatedResponses = {
2954
3045
  */
2955
3046
  200: SkesisRelatedResponse;
2956
3047
  };
3048
+ type SkesisGetItemByPathErrors = {
3049
+ /**
3050
+ * Validation error
3051
+ */
3052
+ 400: unknown;
3053
+ /**
3054
+ * Missing or invalid access token
3055
+ */
3056
+ 401: unknown;
3057
+ /**
3058
+ * The caller is not permitted to perform this operation
3059
+ */
3060
+ 403: PinaxForbidden;
3061
+ /**
3062
+ * Path did not resolve to a published item
3063
+ */
3064
+ 404: PublicError;
3065
+ /**
3066
+ * Skesis engine unavailable (rate cap, upstream failure, or not configured); retry later
3067
+ */
3068
+ 502: {
3069
+ error: string;
3070
+ errorId: string;
3071
+ };
3072
+ };
3073
+ type SkesisGetItemByPathResponses = {
3074
+ /**
3075
+ * Success
3076
+ */
3077
+ 200: SkesisItemPage;
3078
+ };
2957
3079
 
2958
3080
  type Options<TData extends TDataShape = TDataShape, ThrowOnError extends boolean = boolean, TResponse = unknown> = Options$1<TData, ThrowOnError, TResponse> & {
2959
3081
  /**
@@ -3031,6 +3153,14 @@ declare class Content extends HeyApiClient {
3031
3153
  getDocumentByPath<ThrowOnError extends boolean = false>(parameters: {
3032
3154
  path: string;
3033
3155
  }, options?: Options<never, ThrowOnError>): RequestResult<ContentGetDocumentByPathResponses, ContentGetDocumentByPathErrors, ThrowOnError>;
3156
+ /**
3157
+ * List the published documents in a language
3158
+ *
3159
+ * 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.
3160
+ */
3161
+ listDocuments<ThrowOnError extends boolean = false>(parameters: {
3162
+ language: string;
3163
+ }, options?: Options<never, ThrowOnError>): RequestResult<ContentListDocumentsResponses, ContentListDocumentsErrors, ThrowOnError>;
3034
3164
  }
3035
3165
  declare class Stories extends HeyApiClient {
3036
3166
  /**
@@ -3151,6 +3281,14 @@ declare class Skesis extends HeyApiClient {
3151
3281
  anchorId: string;
3152
3282
  locale?: string;
3153
3283
  }, options?: Options<never, ThrowOnError>): RequestResult<SkesisRelatedResponses, SkesisRelatedErrors, ThrowOnError>;
3284
+ /**
3285
+ * Get a catalogue item page by its path
3286
+ *
3287
+ * 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.
3288
+ */
3289
+ getItemByPath<ThrowOnError extends boolean = false>(parameters: {
3290
+ path: string;
3291
+ }, options?: Options<never, ThrowOnError>): RequestResult<SkesisGetItemByPathResponses, SkesisGetItemByPathErrors, ThrowOnError>;
3154
3292
  }
3155
3293
  declare class CallimacusApi extends HeyApiClient {
3156
3294
  static readonly __registry: HeyApiRegistry<CallimacusApi>;
@@ -3800,6 +3938,90 @@ declare function addToCartResultOf(block: {
3800
3938
  */
3801
3939
  declare function applyBlockPatch(chapter: Chapter, patch: BlockPatch): Chapter;
3802
3940
 
3941
+ type ContractClient = Client;
3942
+ /**
3943
+ What a contract call rejects with under `{throwOnError: true}`.
3944
+
3945
+ - `status` is the HTTP status of the failed response, `undefined` when no response arrived (network or
3946
+ CORS failure). It can be 2xx when the response arrived but its body could not be parsed or validated.
3947
+ - `body` is the parsed error body the server sent — `{error, errorId}` on the public API, a string for
3948
+ non-JSON bodies, `{}` for an empty body — or, when no response arrived, the underlying `TypeError`
3949
+ (also exposed as `cause`).
3950
+
3951
+ Aborting a call through its `signal` is not a failure of the call: the abort reason is rethrown as is. The
3952
+ request signal decides, and it does so whether the abort landed before or after the response headers arrived.
3953
+ */
3954
+ declare class ThamyrHttpError extends Error {
3955
+ readonly status: number | undefined;
3956
+ readonly body: unknown;
3957
+ readonly response: Response | undefined;
3958
+ readonly request: Request | undefined;
3959
+ constructor(body: unknown, response?: Response, request?: Request);
3960
+ }
3961
+ /**
3962
+ Client for the generated {@link CallimacusApi}: the client id doubles as bearer token and x-sl-access-token.
3963
+ Calls made with `{throwOnError: true}` (per call, or through `setConfig`) reject with a
3964
+ {@link ThamyrHttpError}; the envelope's `error` stays the parsed body, as documented.
3965
+ */
3966
+ declare function createContractClient(config: {
3967
+ endpoint: string;
3968
+ accessToken: string;
3969
+ /**
3970
+ Send cookies cross-origin (the old axios `withCredentials`).
3971
+ */
3972
+ withCredentials?: boolean;
3973
+ }): ContractClient;
3974
+
3975
+ /**
3976
+ What a `/map/…` pathname names: the index of a language, or one of its documents.
3977
+ */
3978
+ type MapPath = {
3979
+ language: string;
3980
+ slug?: string;
3981
+ };
3982
+ /**
3983
+ Parses a `/map/{language}` or `/map/{language}/{slug}` pathname the way the
3984
+ server does: the leading slash is optional, the slug may contain slashes, and
3985
+ a trailing slash after the language still means the index. Anything else —
3986
+ another route, a bare `/map` — is `undefined`. Pass `location.pathname`, not
3987
+ the full URL: a query string or a hash would end up in the slug.
3988
+ */
3989
+ declare function parseMapPath(pathname: string): MapPath | undefined;
3990
+ /**
3991
+ What a `/map/…` pathname shows: one document, the per-language index, or one
3992
+ catalogue item (`language` is then the catalogue locale, `slug` the kind's
3993
+ slug and the item id).
3994
+ */
3995
+ type MapPage = {
3996
+ kind: 'document';
3997
+ language: string;
3998
+ slug: string;
3999
+ document: SLDocument;
4000
+ } | {
4001
+ kind: 'index';
4002
+ language: string;
4003
+ entries: DocumentIndexEntry[];
4004
+ } | {
4005
+ kind: 'item';
4006
+ language: string;
4007
+ slug: string;
4008
+ itemPage: SkesisItemPage;
4009
+ };
4010
+ /**
4011
+ Resolves what to show at a `/map/…` pathname: the document at
4012
+ `/map/{language}/{slug}`, the entries of the per-language index at
4013
+ `/map/{language}` — the same list the crawler is served, newest first — or the
4014
+ catalogue item at `/map/{locale}/{kind-slug}/{id}`. A document wins a path both
4015
+ could name, as it does in the server render.
4016
+ @param api - A `Thamyr` instance, or the React package's `thamyrApi`.
4017
+ @param pathname - `location.pathname`.
4018
+ @returns `undefined` when the pathname is not a `/map/` path or names no
4019
+ published document, so the caller renders its own not-found. Any other
4020
+ failure (network, a 5xx, an SDK not initialized) rejects — with a
4021
+ `ThamyrHttpError` when a response arrived.
4022
+ */
4023
+ declare function resolveMapPage(api: Pick<CallimacusApi, 'content' | 'skesis'>, pathname: string): Promise<MapPage | undefined>;
4024
+
3803
4025
  /**
3804
4026
  Structured payload the server attaches to a refused handshake (SOL-1100):
3805
4027
  `code` is an HTTP-style status — 4xx is a deliberate refusal, 5xx means the
@@ -4075,39 +4297,5 @@ declare function ensureIntentSessionId(): void;
4075
4297
  declare function clearIntentSessionId(): void;
4076
4298
  declare function setIntentSessionMaxAge(_seconds: number): void;
4077
4299
 
4078
- type ContractClient = Client;
4079
- /**
4080
- What a contract call rejects with under `{throwOnError: true}`.
4081
-
4082
- - `status` is the HTTP status of the failed response, `undefined` when no response arrived (network or
4083
- CORS failure). It can be 2xx when the response arrived but its body could not be parsed or validated.
4084
- - `body` is the parsed error body the server sent — `{error, errorId}` on the public API, a string for
4085
- non-JSON bodies, `{}` for an empty body — or, when no response arrived, the underlying `TypeError`
4086
- (also exposed as `cause`).
4087
-
4088
- Aborting a call through its `signal` is not a failure of the call: the abort reason is rethrown as is. The
4089
- request signal decides, and it does so whether the abort landed before or after the response headers arrived.
4090
- */
4091
- declare class ThamyrHttpError extends Error {
4092
- readonly status: number | undefined;
4093
- readonly body: unknown;
4094
- readonly response: Response | undefined;
4095
- readonly request: Request | undefined;
4096
- constructor(body: unknown, response?: Response, request?: Request);
4097
- }
4098
- /**
4099
- Client for the generated {@link CallimacusApi}: the client id doubles as bearer token and x-sl-access-token.
4100
- Calls made with `{throwOnError: true}` (per call, or through `setConfig`) reject with a
4101
- {@link ThamyrHttpError}; the envelope's `error` stays the parsed body, as documented.
4102
- */
4103
- declare function createContractClient(config: {
4104
- endpoint: string;
4105
- accessToken: string;
4106
- /**
4107
- Send cookies cross-origin (the old axios `withCredentials`).
4108
- */
4109
- withCredentials?: boolean;
4110
- }): ContractClient;
4111
-
4112
- 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, clearIntentSessionId, createContractClient, deliverResultOf, ensureIntentSessionId, extractTtsAudio, fieldsOf, getIntentSessionId, initIntent, interactionRound, isCustomBlock, isMasterProduct, isSetProduct, landingRound, logger, parseConnectRejection, randomUuid, receptorsOf, setConsent, setDebug, setDebugPanel, setGeo, setIntentSessionMaxAge, shouldRetryHandshake, transformImageUrl };
4113
- 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, InitOptions, 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 };
4300
+ 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, clearIntentSessionId, createContractClient, deliverResultOf, ensureIntentSessionId, extractTtsAudio, fieldsOf, getIntentSessionId, initIntent, interactionRound, isCustomBlock, isMasterProduct, isSetProduct, landingRound, logger, parseConnectRejection, parseMapPath, randomUuid, receptorsOf, resolveMapPage, setConsent, setDebug, setDebugPanel, setGeo, setIntentSessionMaxAge, shouldRetryHandshake, transformImageUrl };
4301
+ 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, InitOptions, 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 };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@callimacus/thamyr-core",
3
- "version": "4.8.3",
3
+ "version": "4.10.0",
4
4
  "private": false,
5
5
  "description": "Core package for Thamyr",
6
6
  "license": "SEE LICENSE IN LICENSE.md",