@40rty/ams-sdk 0.5.5 → 0.5.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +872 -694
- package/dist/types/ecommerce/src/code-discounts.d.ts +47 -0
- package/dist/types/ecommerce/src/commerce-schemas.d.ts +16 -6
- package/dist/types/ecommerce/src/index.d.ts +1 -0
- package/dist/types/sdk/src/canvas/hydration-notice.d.ts +23 -0
- package/dist/types/sdk/src/canvas/index.d.ts +1 -0
- package/dist/types/sdk/src/catalog/registration/types.d.ts +4 -3
- package/dist/types/sdk/src/host/host-modules.d.ts +43 -14
- package/dist/types/sdk/src/session/index.d.ts +2 -1
- package/dist/types/sdk/src/session/space-locale-context.d.ts +10 -0
- package/dist/types/sdk/src/session/visitor-locale.d.ts +15 -0
- package/dist/types/sdk/src/shell/composer-attachments/use-composer-attachments.d.ts +4 -3
- package/dist/types/sdk/src/verticals/commerce/commerce-context.d.ts +6 -2
- package/dist/types/sdk/src/verticals/commerce/commerce-shapes.d.ts +16 -0
- package/dist/types/sdk/src/verticals/commerce/comparison/comparison-rows.d.ts +11 -2
- package/dist/types/sdk/src/verticals/commerce/index.d.ts +3 -3
- package/dist/types/sdk/src/verticals/commerce/price/format-price.d.ts +3 -2
- package/dist/types/spacestation/src/attachment/attachment-failure.d.ts +32 -0
- package/dist/types/spacestation/src/contracts/tools/definitions.d.ts +9 -0
- package/dist/types/spacestation/src/contracts/tools/execution-context.d.ts +11 -0
- package/dist/types/spacestation/src/index.d.ts +4 -1
- package/dist/types/spacestation/src/signal/agent-signals.d.ts +36 -0
- package/dist/types/spacestation/src/space/session-queue.d.ts +8 -8
- package/dist/types/spacestation/src/space/space-config.d.ts +4 -0
- package/dist/types/spacestation/src/space/space-locale.d.ts +46 -0
- package/package.json +1 -1
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Format a price as a localized currency string
|
|
2
|
+
* Format a price as a localized currency string, in the SPACE's locale
|
|
3
|
+
* (`useSpaceLocale()`) — never a hardcoded or browser default. Uses Intl.NumberFormat;
|
|
3
4
|
* brand components don't need to hand-roll currency symbols, decimals, or
|
|
4
5
|
* thousand separators. Drops the decimal part when the price is a whole
|
|
5
6
|
* dollar amount ($49, not $49.00) — cents only render when they're non-zero.
|
|
6
7
|
*/
|
|
7
|
-
export declare function formatPrice(amount: number, currencyCode
|
|
8
|
+
export declare function formatPrice(amount: number, currencyCode: string, locale: string): string;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WHY an attachment did not make it — a reason, never a sentence. The engine
|
|
3
|
+
* and the sdk report this; the UI words it in the space's language
|
|
4
|
+
* (`composer.attachmentFailure` in `@fourty/ui`'s labels). A server message is
|
|
5
|
+
* English diagnostics: it goes to the console, never to the visitor.
|
|
6
|
+
*/
|
|
7
|
+
export type AttachmentFailure = {
|
|
8
|
+
kind: 'empty';
|
|
9
|
+
}
|
|
10
|
+
/** `mimeType` is what the browser reported — empty when it reported none. */
|
|
11
|
+
| {
|
|
12
|
+
kind: 'unsupported_type';
|
|
13
|
+
mimeType: string;
|
|
14
|
+
} | {
|
|
15
|
+
kind: 'too_large';
|
|
16
|
+
maxMb: number;
|
|
17
|
+
}
|
|
18
|
+
/** Picked before the session existed to upload into. */
|
|
19
|
+
| {
|
|
20
|
+
kind: 'not_ready';
|
|
21
|
+
} | {
|
|
22
|
+
kind: 'upload_failed';
|
|
23
|
+
};
|
|
24
|
+
/** The per-file ceiling in whole MB, as the visitor is told it. */
|
|
25
|
+
export declare const MAX_ATTACHMENT_MB: number;
|
|
26
|
+
/** Thrown by the upload; `message` is diagnostics, `failure` is what the visitor sees. */
|
|
27
|
+
export declare class AttachmentUploadError extends Error {
|
|
28
|
+
readonly failure: AttachmentFailure;
|
|
29
|
+
constructor(failure: AttachmentFailure, detail: string);
|
|
30
|
+
}
|
|
31
|
+
/** The upload endpoint's refusal status → its reason (`POST /sessions/:id/attachments`). */
|
|
32
|
+
export declare function attachmentFailureOfStatus(status: number, mimeType: string): AttachmentFailure;
|
|
@@ -71,6 +71,15 @@ export interface FourtyToolDefDescriptor {
|
|
|
71
71
|
* on) takes precedence.
|
|
72
72
|
*/
|
|
73
73
|
defaultEnabled?: boolean;
|
|
74
|
+
/**
|
|
75
|
+
* Whether a session may replay this tool's result for an identical call.
|
|
76
|
+
* Absent = `true`: the registry's per-session cache answers a repeat
|
|
77
|
+
* `(name, args)` without running the tool. Set `false` for a tool whose
|
|
78
|
+
* answer follows visitor state that changes mid-session with the same args
|
|
79
|
+
* — a signed-in shopper's account reads "not signed in" until they sign in,
|
|
80
|
+
* and a replay would keep saying so after they have.
|
|
81
|
+
*/
|
|
82
|
+
cacheResults?: boolean;
|
|
74
83
|
/**
|
|
75
84
|
* Declarative absorb shape — when present, the agent's per-session
|
|
76
85
|
* entity registry harvests entries from this tool's result without
|
|
@@ -66,6 +66,17 @@ export interface ToolExecutionContext {
|
|
|
66
66
|
* allowing the action, never to blocking it.
|
|
67
67
|
*/
|
|
68
68
|
readStateSnapshot?: (namespace: string) => Record<string, unknown> | undefined;
|
|
69
|
+
/**
|
|
70
|
+
* Entities of `kind` that answer to a name, best first — the space's own
|
|
71
|
+
* lookup for that kind (e.g. product search), registered by the platform.
|
|
72
|
+
* Lets an action resolve a NAME to an id in the same batch it acts in (see
|
|
73
|
+
* `ActionDefinition.prepare`). Absent when nothing is registered for the
|
|
74
|
+
* space; a caller then has nothing to resolve with.
|
|
75
|
+
*/
|
|
76
|
+
findEntitiesByName?: (kind: string, name: string, limit: number) => Promise<ReadonlyArray<{
|
|
77
|
+
id: string;
|
|
78
|
+
title: string;
|
|
79
|
+
}>>;
|
|
69
80
|
/**
|
|
70
81
|
* Hand the client entities this call just resolved, as `ref → entity`, under
|
|
71
82
|
* the `resolverKey` a catalog declares via `resolved()`. The client's
|
|
@@ -12,7 +12,7 @@ export { CART_REMOVE_SIGNAL, CART_SET_QUANTITY_SIGNAL, CHECKOUT_BEGIN_SIGNAL, CA
|
|
|
12
12
|
export { type ChatMessage, type ConversationSummary, type StreamRecord, type ReasoningBeat, type Message, type PendingMessage, } from './layout/conversation';
|
|
13
13
|
export { type StepName, type TraceEvent, type EmitFn, type TraceStartInfo, type StepConfig, type SystemPromptSnapshot, type VisitorIdentity, type PhaseProgress, type PhaseProgressPreview, } from './trace/trace-events';
|
|
14
14
|
export { type TraceDiagnostic, type DiagnosticKind, type TraceStage, } from './trace/trace-diagnostics';
|
|
15
|
-
export { type SuggestionAction, type SuggestionActions, type SuggestionRendererProps, SuggestionActionSchema, SuggestionActionsSchema, SIGNAL_PATCH_PREFIX, type SuggestionActionInput, type AgentSignal, type AgentSignalInput, AgentSignalSchema, InteractionSignalSchema, MAX_VISITOR_PROMPT_CHARS, type ToolCallHint, ToolCallHintSchema, type ActionDefinition, type ActionConfirmation, type ActionGuardEntities, type ActionManifest, type AskDefinition, type AskManifest, NAVIGATE_SIGNAL, FLOW_OUTPUT_SIGNAL, PRESENCE_FLOW, PRESENCE_OPTIMISTIC_FACTS_FLOW, EXTEND_FLOW, DIRECTION_FLOW, EPHEMERAL_FACT_FLOWS, type FlowSpec, type FacultyFlowSpec, } from './signal/agent-signals';
|
|
15
|
+
export { type SuggestionAction, type SuggestionActions, type SuggestionRendererProps, SuggestionActionSchema, SuggestionActionsSchema, SIGNAL_PATCH_PREFIX, type SuggestionActionInput, type AgentSignal, type AgentSignalInput, AgentSignalSchema, InteractionSignalSchema, MAX_VISITOR_PROMPT_CHARS, type ToolCallHint, ToolCallHintSchema, type ActionDefinition, type ActionConfirmation, type ActionGuardEntities, type ActionPrepareContext, type ActionNamedEntity, type ActionPrepared, type ActionManifest, type AskDefinition, type AskManifest, NAVIGATE_SIGNAL, FLOW_OUTPUT_SIGNAL, PRESENCE_FLOW, PRESENCE_OPTIMISTIC_FACTS_FLOW, EXTEND_FLOW, DIRECTION_FLOW, EPHEMERAL_FACT_FLOWS, type FlowSpec, type FacultyFlowSpec, } from './signal/agent-signals';
|
|
16
16
|
export { TURN_ASK_SIGNAL, TurnAskSchema, turnAskFromSignal, turnAskSegments, turnAskAnswers, turnAskPlainText, type TurnAsk, type TurnAskSegment } from './signal/turn-ask';
|
|
17
17
|
export { type TraceSpanData, type TraceData, type Trace, type TraceLatency, type TraceEventLogEntry, type LayoutChangeEntry, } from './trace/trace-data';
|
|
18
18
|
export { type TraceSnapshotEnvelope, type SystemPromptSnapshotEnvelope, type LayoutSnapshotEnvelope, type SuggestionsSnapshotEnvelope, type TurnSnapshotEnvelope, type AssemblyInputsEnvelope, type AssemblyInputComponent, type AssemblyInputTool, type AssemblyInputPrompt, } from './trace/trace-envelopes';
|
|
@@ -39,6 +39,7 @@ export { VIEW_EXTEND_SIGNAL, VIEW_EXHAUSTED_SIGNAL, ViewExtendPayloadSchema, CON
|
|
|
39
39
|
export type { Hydrator, HydratorMap, HydrationContext } from './hydration/hydration';
|
|
40
40
|
export { ShellConfigSchema, type ShellConfig, ShellMenuItemSchema, type ShellMenuItem, EMPTY_SHELL, } from './shell/shell';
|
|
41
41
|
export { ALLOWED_ATTACHMENT_TYPES, MAX_ATTACHMENT_BYTES, isAllowedAttachmentType, isImageAttachment, AttachmentRefSchema, AttachmentRefsSchema, type AllowedAttachmentType, type AttachmentRef, } from './attachment/attachment';
|
|
42
|
+
export { MAX_ATTACHMENT_MB, AttachmentUploadError, attachmentFailureOfStatus, type AttachmentFailure, } from './attachment/attachment-failure';
|
|
42
43
|
export { ENTRY_CONTEXT_MAX_VALUE_CHARS, ENTRY_CONTEXT_MAX_KEYS, ENTRY_CONTEXT_MAX_NAMESPACES, ENTRY_CONTEXT_MAX_NAME_CHARS, EntryContextValueSchema, EntryContextNamespaceSchema, EntryContextSchema, type EntryContext, } from './contracts/entry-context';
|
|
43
44
|
export { ARRIVAL_MAX_VALUE_CHARS, SURFACES, SurfaceSchema, type Surface, CLICK_ID_KINDS, ClickIdKindSchema, type ClickIdKind, VISITOR_ID_DURABILITIES, VisitorIdDurabilitySchema, type VisitorIdDurability, TRAFFIC_BUCKETS, TrafficBucketSchema, type TrafficBucket, SessionArrivalSchema, type SessionArrival, type RecordedSessionArrival, } from './contracts/session-arrival';
|
|
44
45
|
export { ARRIVAL_PARAMS, REFERRER_HOST_PARAM, arrivalFromParams, arrivalToParams, type ArrivalEvidence, } from './contracts/session-arrival-params';
|
|
@@ -51,6 +52,8 @@ export type { HostedApp, SpaceConfig, SpaceWithConfig, VisitorAccess } from './s
|
|
|
51
52
|
export type { ConnectorDescriptor, ConnectorFieldDescriptor } from './space/connector';
|
|
52
53
|
export { AgentDirectiveSchema, SpaceAgentDirectiveSchema, SpaceAgentDirectiveListItemSchema, UpdateAgentDirectiveInputSchema, ReorderAgentDirectivesInputSchema, AGENT_DIRECTIVE_KINDS, AGENT_DIRECTIVE_SEVERITIES, AGENT_DIRECTIVE_SOURCES, AGENT_DIRECTIVE_STATUSES, MAX_ACTIVE_AGENT_DIRECTIVES, } from './space/agent-directive';
|
|
53
54
|
export type { AgentDirective, SpaceAgentDirective, SpaceAgentDirectiveListItem, UpdateAgentDirectiveInput, } from './space/agent-directive';
|
|
55
|
+
export { DEFAULT_SPACE_LOCALE, SpaceLocaleSchema, textDirectionOf, languageOf, languageNameOf, spaceLocaleOf, declaredSpaceLocaleOf, SUPPORTED_SPACE_LOCALES, } from './space/space-locale';
|
|
56
|
+
export type { TextDirection } from './space/space-locale';
|
|
54
57
|
export { DEFAULT_SPACE_CONFIG, DEFAULT_VISITOR_ACCESS, VISITOR_ACCESS, visitorAccessOf, } from './space/space-config';
|
|
55
58
|
export type { ThemePackageOption, BrandDefinition, BrandPromptSection } from './space/workspace-catalog';
|
|
56
59
|
export { COMPONENT_SOURCE, THEME_PACKAGE, THEME_CLASS, COMPONENT_SOURCE_DEFAULT_THEME, WORKSPACE_THEME_PACKAGES, } from './space/workspace-catalog';
|
|
@@ -247,6 +247,11 @@ export interface ActionDefinition {
|
|
|
247
247
|
* e.g. `text.delta`). Tells the SDK to debounce/batch and tells the LLM
|
|
248
248
|
* the cadence is allowed. */
|
|
249
249
|
streaming?: boolean;
|
|
250
|
+
/** The tool this action belongs beside. When set, the action is offered
|
|
251
|
+
* only while that tool is enabled for the space — one switch turns on a
|
|
252
|
+
* capability and the verb that acts on it (`customer.signin` follows
|
|
253
|
+
* `get_customer_account`). Absent → offered to every space. */
|
|
254
|
+
requiresTool?: string;
|
|
250
255
|
/**
|
|
251
256
|
* How this action's real-world effect is CONFIRMED. An action tool only
|
|
252
257
|
* dispatches a client signal — the effect (a cart write, a wishlist
|
|
@@ -274,7 +279,38 @@ export interface ActionDefinition {
|
|
|
274
279
|
* twice, in one run. A rule the model can decline to follow is not a rule.
|
|
275
280
|
*/
|
|
276
281
|
guard?: (payload: Record<string, unknown>, snapshot: Record<string, unknown>, entities: ActionGuardEntities) => string | undefined;
|
|
282
|
+
/**
|
|
283
|
+
* Server-side preparation before anything else judges the payload — today,
|
|
284
|
+
* turning a NAME the agent was given into the entity id the verb acts on.
|
|
285
|
+
*
|
|
286
|
+
* Why it exists: on a one-round space the agent cannot search and then act
|
|
287
|
+
* on what it found in the same turn (there is no second round), so "add the
|
|
288
|
+
* Volcom jacket in M" for a product not on screen was structurally
|
|
289
|
+
* unreachable — and the reply then narrated an add that never happened.
|
|
290
|
+
* Resolving the name here makes the verb reachable in the FIRST batch.
|
|
291
|
+
*
|
|
292
|
+
* Returns the payload to continue with, or a refusal the agent narrates
|
|
293
|
+
* (e.g. the name fits several products — ask which). Runs before the
|
|
294
|
+
* ref-kind gate and the guard, so they judge the prepared payload.
|
|
295
|
+
*/
|
|
296
|
+
prepare?: (payload: Record<string, unknown>, context: ActionPrepareContext) => Promise<ActionPrepared>;
|
|
297
|
+
}
|
|
298
|
+
/** What `ActionDefinition.prepare` may use. Vertical-neutral: entities are
|
|
299
|
+
* addressed by the `resolverKey` kind a catalog declares (`product`, …). */
|
|
300
|
+
export interface ActionPrepareContext {
|
|
301
|
+
/** Entities of `kind` that answer to `name`, best first; empty when none do
|
|
302
|
+
* or when this space has no lookup for that kind. */
|
|
303
|
+
findByName: (kind: string, name: string, limit: number) => Promise<readonly ActionNamedEntity[]>;
|
|
277
304
|
}
|
|
305
|
+
export interface ActionNamedEntity {
|
|
306
|
+
id: string;
|
|
307
|
+
title: string;
|
|
308
|
+
}
|
|
309
|
+
export type ActionPrepared = {
|
|
310
|
+
payload: Record<string, unknown>;
|
|
311
|
+
} | {
|
|
312
|
+
refusal: string;
|
|
313
|
+
};
|
|
278
314
|
/**
|
|
279
315
|
* The ENTITY facts a precondition may consult, beside the client's live state.
|
|
280
316
|
*
|
|
@@ -1272,16 +1272,16 @@ export declare const SessionCaptureSchema: z.ZodObject<{
|
|
|
1272
1272
|
/** Referrer at session create — separates agentic traffic from organic. */
|
|
1273
1273
|
referrer: z.ZodNullable<z.ZodString>;
|
|
1274
1274
|
}, "strip", z.ZodTypeAny, {
|
|
1275
|
+
locale: string | null;
|
|
1275
1276
|
viewportWidth: number | null;
|
|
1276
1277
|
viewportHeight: number | null;
|
|
1277
1278
|
userAgent: string | null;
|
|
1278
|
-
locale: string | null;
|
|
1279
1279
|
referrer: string | null;
|
|
1280
1280
|
}, {
|
|
1281
|
+
locale: string | null;
|
|
1281
1282
|
viewportWidth: number | null;
|
|
1282
1283
|
viewportHeight: number | null;
|
|
1283
1284
|
userAgent: string | null;
|
|
1284
|
-
locale: string | null;
|
|
1285
1285
|
referrer: string | null;
|
|
1286
1286
|
}>;
|
|
1287
1287
|
export type SessionCapture = z.infer<typeof SessionCaptureSchema>;
|
|
@@ -1311,21 +1311,21 @@ export declare const SessionCaptureInputSchema: z.ZodObject<{
|
|
|
1311
1311
|
clientVersion: z.ZodOptional<z.ZodString>;
|
|
1312
1312
|
isInternal: z.ZodOptional<z.ZodBoolean>;
|
|
1313
1313
|
}, "strip", z.ZodTypeAny, {
|
|
1314
|
+
locale?: string | undefined;
|
|
1314
1315
|
isInternal?: boolean | undefined;
|
|
1315
1316
|
clientVersion?: string | undefined;
|
|
1316
1317
|
viewportWidth?: number | undefined;
|
|
1317
1318
|
viewportHeight?: number | undefined;
|
|
1318
1319
|
userAgent?: string | undefined;
|
|
1319
|
-
locale?: string | undefined;
|
|
1320
1320
|
referrer?: string | undefined;
|
|
1321
1321
|
timeZone?: string | undefined;
|
|
1322
1322
|
}, {
|
|
1323
|
+
locale?: string | undefined;
|
|
1323
1324
|
isInternal?: boolean | undefined;
|
|
1324
1325
|
clientVersion?: string | undefined;
|
|
1325
1326
|
viewportWidth?: number | undefined;
|
|
1326
1327
|
viewportHeight?: number | undefined;
|
|
1327
1328
|
userAgent?: string | undefined;
|
|
1328
|
-
locale?: string | undefined;
|
|
1329
1329
|
referrer?: string | undefined;
|
|
1330
1330
|
timeZone?: string | undefined;
|
|
1331
1331
|
}>;
|
|
@@ -1547,16 +1547,16 @@ export declare const SessionDetailSchema: z.ZodObject<{
|
|
|
1547
1547
|
/** Referrer at session create — separates agentic traffic from organic. */
|
|
1548
1548
|
referrer: z.ZodNullable<z.ZodString>;
|
|
1549
1549
|
}, "strip", z.ZodTypeAny, {
|
|
1550
|
+
locale: string | null;
|
|
1550
1551
|
viewportWidth: number | null;
|
|
1551
1552
|
viewportHeight: number | null;
|
|
1552
1553
|
userAgent: string | null;
|
|
1553
|
-
locale: string | null;
|
|
1554
1554
|
referrer: string | null;
|
|
1555
1555
|
}, {
|
|
1556
|
+
locale: string | null;
|
|
1556
1557
|
viewportWidth: number | null;
|
|
1557
1558
|
viewportHeight: number | null;
|
|
1558
1559
|
userAgent: string | null;
|
|
1559
|
-
locale: string | null;
|
|
1560
1560
|
referrer: string | null;
|
|
1561
1561
|
}>;
|
|
1562
1562
|
/** Full verdict history, newest first. Verdicts are revisable, and a session
|
|
@@ -1876,10 +1876,10 @@ export declare const SessionDetailSchema: z.ZodObject<{
|
|
|
1876
1876
|
bugIssueState: string | null;
|
|
1877
1877
|
};
|
|
1878
1878
|
capture: {
|
|
1879
|
+
locale: string | null;
|
|
1879
1880
|
viewportWidth: number | null;
|
|
1880
1881
|
viewportHeight: number | null;
|
|
1881
1882
|
userAgent: string | null;
|
|
1882
|
-
locale: string | null;
|
|
1883
1883
|
referrer: string | null;
|
|
1884
1884
|
};
|
|
1885
1885
|
reviews: {
|
|
@@ -1974,10 +1974,10 @@ export declare const SessionDetailSchema: z.ZodObject<{
|
|
|
1974
1974
|
bugIssueState: string | null;
|
|
1975
1975
|
};
|
|
1976
1976
|
capture: {
|
|
1977
|
+
locale: string | null;
|
|
1977
1978
|
viewportWidth: number | null;
|
|
1978
1979
|
viewportHeight: number | null;
|
|
1979
1980
|
userAgent: string | null;
|
|
1980
|
-
locale: string | null;
|
|
1981
1981
|
referrer: string | null;
|
|
1982
1982
|
};
|
|
1983
1983
|
reviews: {
|
|
@@ -57,6 +57,10 @@ export interface SpaceConfig {
|
|
|
57
57
|
* every page it measures, so it is the other config key besides
|
|
58
58
|
* `componentSources` the public projection may carry. */
|
|
59
59
|
facebookPixelId?: string;
|
|
60
|
+
/** The language this space speaks (BCP 47, e.g. `he-IL`) — agent output, UI
|
|
61
|
+
* chrome, direction and formatting all follow it. Absent ⇒ `en-US`. Public
|
|
62
|
+
* by design: the page renders in it. See `space-locale.ts`. */
|
|
63
|
+
locale?: string;
|
|
60
64
|
/** IANA zone the space's reporting DAY is measured on (e.g.
|
|
61
65
|
* `America/Los_Angeles`), seeded from the connected store at install. Absent ⇒
|
|
62
66
|
* the platform reports in UTC and labels it as such. A REPORTING concern only:
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* THE LANGUAGE A SPACE SPEAKS — one BCP 47 tag on `spaces.config.locale`
|
|
4
|
+
* (`he-IL`, `en-US`). Every visitor-facing surface reads it from here:
|
|
5
|
+
*
|
|
6
|
+
* - the agent writes prose, layout copy, chips and presence in its language;
|
|
7
|
+
* - the spacefront sets `<html lang dir>` and mounts the matching UI labels;
|
|
8
|
+
* - commerce formats money/dates and asks the store for its translation.
|
|
9
|
+
*
|
|
10
|
+
* Direction is DERIVED, never stored: a second field would be a second source
|
|
11
|
+
* of truth that could disagree with the language (an `he` space marked `ltr`).
|
|
12
|
+
*
|
|
13
|
+
* Absent ⇒ `DEFAULT_SPACE_LOCALE`. The visitor's browser language does not
|
|
14
|
+
* override it: a space is a brand surface in one language, and a half-English
|
|
15
|
+
* Hebrew storefront is the failure this field exists to prevent.
|
|
16
|
+
*/
|
|
17
|
+
export declare const DEFAULT_SPACE_LOCALE = "en-US";
|
|
18
|
+
/** Strict at the write boundary: a typo'd tag would silently serve English. */
|
|
19
|
+
export declare const SpaceLocaleSchema: z.ZodEffects<z.ZodString, string, string>;
|
|
20
|
+
export type TextDirection = 'ltr' | 'rtl';
|
|
21
|
+
export declare function textDirectionOf(locale: string): TextDirection;
|
|
22
|
+
/** The bare language subtag (`he` for `he-IL`) — what `<html lang>` and the
|
|
23
|
+
* Storefront `@inContext(language:)` take. */
|
|
24
|
+
export declare function languageOf(locale: string): string;
|
|
25
|
+
/** The language's English name ("Hebrew") — what the agent's prompt names. */
|
|
26
|
+
export declare function languageNameOf(locale: string): string;
|
|
27
|
+
/** The locales a space can be set to from the console — the ones the UI
|
|
28
|
+
* labels ship for. Any BCP 47 tag is VALID (`SpaceLocaleSchema`); these are
|
|
29
|
+
* the ones offered. */
|
|
30
|
+
export declare const SUPPORTED_SPACE_LOCALES: readonly string[];
|
|
31
|
+
/** The locale the space DECLARED, or `undefined` when it declared none.
|
|
32
|
+
* Malformed throws: the write boundary refuses it, so a bad value here is
|
|
33
|
+
* data written around that boundary and must surface, not serve English.
|
|
34
|
+
*
|
|
35
|
+
* Commerce reads THIS, not `spaceLocaleOf`: a store read in the space's
|
|
36
|
+
* language only when the space asked for one. An undeclared space keeps the
|
|
37
|
+
* store's own language and the visitor's market — defaulting it to `en-US`
|
|
38
|
+
* would translate a Portuguese store's catalog into English. */
|
|
39
|
+
export declare function declaredSpaceLocaleOf(config: {
|
|
40
|
+
locale?: unknown;
|
|
41
|
+
} | null | undefined): string | undefined;
|
|
42
|
+
/** Resolve a stored (possibly absent / legacy-malformed) value to a usable
|
|
43
|
+
* locale — what the page and the agent speak. */
|
|
44
|
+
export declare function spaceLocaleOf(config: {
|
|
45
|
+
locale?: unknown;
|
|
46
|
+
} | null | undefined): string;
|