@40rty/ams-sdk 0.5.6 → 0.5.8

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 (26) hide show
  1. package/dist/index.js +1068 -813
  2. package/dist/types/ecommerce/src/code-discounts.d.ts +47 -0
  3. package/dist/types/ecommerce/src/commerce-schemas.d.ts +16 -6
  4. package/dist/types/ecommerce/src/index.d.ts +2 -0
  5. package/dist/types/ecommerce/src/store-theme.d.ts +45 -0
  6. package/dist/types/sdk/src/canvas/hydration-notice.d.ts +23 -0
  7. package/dist/types/sdk/src/canvas/index.d.ts +1 -0
  8. package/dist/types/sdk/src/host/host-modules.d.ts +55 -14
  9. package/dist/types/sdk/src/session/index.d.ts +2 -1
  10. package/dist/types/sdk/src/session/space-locale-context.d.ts +10 -0
  11. package/dist/types/sdk/src/session/visitor-locale.d.ts +15 -0
  12. package/dist/types/sdk/src/shell/composer-attachments/use-composer-attachments.d.ts +4 -3
  13. package/dist/types/sdk/src/verticals/commerce/comparison/comparison-rows.d.ts +11 -2
  14. package/dist/types/sdk/src/verticals/commerce/index.d.ts +1 -1
  15. package/dist/types/sdk/src/verticals/commerce/price/format-price.d.ts +3 -2
  16. package/dist/types/spacestation/src/attachment/attachment-failure.d.ts +32 -0
  17. package/dist/types/spacestation/src/catalog/wire/host-imports.d.ts +15 -0
  18. package/dist/types/spacestation/src/catalog/wire/index.d.ts +2 -1
  19. package/dist/types/spacestation/src/catalog/wire/package-release.d.ts +19 -0
  20. package/dist/types/spacestation/src/contracts/tools/execution-context.d.ts +11 -0
  21. package/dist/types/spacestation/src/index.d.ts +5 -2
  22. package/dist/types/spacestation/src/signal/agent-signals.d.ts +31 -0
  23. package/dist/types/spacestation/src/space/session-queue.d.ts +8 -8
  24. package/dist/types/spacestation/src/space/space-config.d.ts +4 -0
  25. package/dist/types/spacestation/src/space/space-locale.d.ts +46 -0
  26. package/package.json +1 -1
@@ -28,7 +28,7 @@ export { preselectFromFacts } from './variant/preselect-from-facts';
28
28
  export { matchesProductFilter, pruneFilterChips, type ProductFilterChip, type ProductFilterPredicate, } from './product/product-filters';
29
29
  export { normalizeCollectionLegacy, pickCollectionAction } from './product/normalize-collection';
30
30
  export { useCommerceActions, type CommerceActions } from './use-commerce-actions';
31
- export { buildComparisonRows, formatProductPrice, type ComparisonAttributeRow, } from './comparison/comparison-rows';
31
+ export { buildComparisonRows, formatProductPrice, type ComparisonAttributeRow, type ComparisonRowWords, } from './comparison/comparison-rows';
32
32
  export { formatPrice } from './price/format-price';
33
33
  export { isOnSale } from './price/is-on-sale';
34
34
  export { resolveSwatchColor } from './variant/resolve-swatch-color';
@@ -1,7 +1,8 @@
1
1
  /**
2
- * Format a price as a localized currency string. Uses Intl.NumberFormat;
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?: string, locale?: string): string;
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;
@@ -0,0 +1,15 @@
1
+ import { z } from 'zod';
2
+ /** What a bundle reads from each shared module — `default` included when it takes the default export. */
3
+ export declare const HostImportsSchema: z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString, "many">>;
4
+ export type HostImports = z.infer<typeof HostImportsSchema>;
5
+ /** What each shared module exports in one deployment — what `GET /org/host-modules` answers. */
6
+ export declare const HostExportsSchema: z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString, "many">>;
7
+ export type HostExports = z.infer<typeof HostExportsSchema>;
8
+ /**
9
+ * Each import `provided` cannot satisfy, as `module → name` — or `module (not
10
+ * provided)` when the deployment shares no such module at all. Empty when the
11
+ * bundle can run on it.
12
+ */
13
+ export declare function hostImportProblems(imports: HostImports, provided: HostExports): string[];
14
+ /** The refusal's one line: which deployment, and what to do about it. `commit` is `null` where the runtime does not say. */
15
+ export declare function hostImportsRefusal(commit: string | null): string;
@@ -2,7 +2,8 @@ export { WireSchemaSchema, type WireSchema, type WireResolved } from './wire-sch
2
2
  export { schemaToWire, UnsupportedSchemaError } from './schema-to-wire';
3
3
  export { schemaFromWire } from './schema-from-wire';
4
4
  export { WireCatalogSchema, WireCatalogEntrySchema, catalogToWire, catalogFromWire, type WireCatalog, type WireCatalogEntry, } from './catalog-wire';
5
- export { PackageReleaseSchema, draftSourceId, isDraftSource, releasePreviewSourceId, parseReleasePreview, type PackageRelease } from './package-release';
5
+ export { PackageReleaseSchema, ReleaseMessageSchema, RELEASE_MESSAGE_MAX, draftSourceId, isDraftSource, releasePreviewSourceId, parseReleasePreview, type PackageRelease } from './package-release';
6
6
  export { SDK_VERSION_PATTERN, SdkVersionSchema, OLDEST_SUPPORTED_SDK, SDK_SHIMS, compareSdkVersions, sdkShimsFor, sdkWindowProblem, type SdkShim, } from './sdk-compat';
7
+ export { HostImportsSchema, HostExportsSchema, hostImportProblems, hostImportsRefusal, type HostImports, type HostExports } from './host-imports';
7
8
  export { PackageBundleRefSchema, type PackageBundleRef } from './package-bundle-ref';
8
9
  export { BRAND_MARK_TYPES, BRAND_MARK_SLOTS, BRAND_MARK_MAX_BYTES, BrandMarkSchema, BrandMarkImageSchema, SpaceBrandMarkSchema, type BrandMark, type BrandMarkFile, type BrandMarkUpload, type BrandMarkStored, type BrandMarkSlot, type BrandMarkType, type BrandMarkImage, type SpaceBrandMark, } from './brand-mark';
@@ -1,4 +1,12 @@
1
1
  import { z } from 'zod';
2
+ /**
3
+ * What a release changed, in one line a person reads in a version list — what
4
+ * `forty publish --message` and the console's Publish both take. Every release
5
+ * appended carries one; the release schema keeps it optional only because
6
+ * drafts and releases stored before it was required have none.
7
+ */
8
+ export declare const RELEASE_MESSAGE_MAX = 140;
9
+ export declare const ReleaseMessageSchema: z.ZodString;
2
10
  /**
3
11
  * A brand's component source, published as DATA from the brand's own
4
12
  * repository: its catalog (props schemas in wire form) and the markdown
@@ -25,6 +33,15 @@ export declare const PackageReleaseSchema: z.ZodObject<{
25
33
  * published before the stamp existed — those are legacy.
26
34
  */
27
35
  builtWithSdk: z.ZodOptional<z.ZodString>;
36
+ /**
37
+ * Every name the bundle reads from each module it takes from the page
38
+ * (`host-imports.ts`) — what lets the platform refuse a bundle it cannot
39
+ * run. Sent by `forty publish` / `forty dev` with every bundle; absent on
40
+ * releases built before it existed, which are admitted (and logged). Kept
41
+ * beside the release, not in the bundle, so a rollback can check it without
42
+ * fetching the components.
43
+ */
44
+ hostImports: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString, "many">>>;
28
45
  catalog: z.ZodRecord<z.ZodString, z.ZodObject<{
29
46
  type: z.ZodString;
30
47
  propsSchema: z.ZodOptional<z.ZodType<import("./wire-schema").WireSchema, z.ZodTypeDef, import("./wire-schema").WireSchema>>;
@@ -383,6 +400,7 @@ export declare const PackageReleaseSchema: z.ZodObject<{
383
400
  config?: Record<string, unknown> | undefined;
384
401
  description?: string | undefined;
385
402
  builtWithSdk?: string | undefined;
403
+ hostImports?: Record<string, string[]> | undefined;
386
404
  bundle?: {
387
405
  js: string;
388
406
  css: string;
@@ -465,6 +483,7 @@ export declare const PackageReleaseSchema: z.ZodObject<{
465
483
  config?: Record<string, unknown> | undefined;
466
484
  description?: string | undefined;
467
485
  builtWithSdk?: string | undefined;
486
+ hostImports?: Record<string, string[]> | undefined;
468
487
  bundle?: {
469
488
  js: string;
470
489
  css: string;
@@ -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';
@@ -31,7 +31,7 @@ export { isElementUnfilled, rendersNothing } from './catalog/element-filled';
31
31
  export { carriesShapeToken } from './catalog/shape-tokens';
32
32
  export { applySinglePatch } from './layout/apply-patch';
33
33
  export { derivePropsDoc } from './catalog/derive-props-doc';
34
- export { WireSchemaSchema, WireCatalogSchema, WireCatalogEntrySchema, schemaToWire, schemaFromWire, catalogToWire, catalogFromWire, UnsupportedSchemaError, PackageReleaseSchema, draftSourceId, isDraftSource, releasePreviewSourceId, parseReleasePreview, SDK_VERSION_PATTERN, SdkVersionSchema, OLDEST_SUPPORTED_SDK, SDK_SHIMS, compareSdkVersions, sdkShimsFor, sdkWindowProblem, type SdkShim, PackageBundleRefSchema, type PackageBundleRef, BRAND_MARK_TYPES, BRAND_MARK_SLOTS, BRAND_MARK_MAX_BYTES, BrandMarkSchema, BrandMarkImageSchema, SpaceBrandMarkSchema, type BrandMark, type BrandMarkFile, type BrandMarkUpload, type BrandMarkStored, type BrandMarkSlot, type BrandMarkType, type BrandMarkImage, type SpaceBrandMark, type PackageRelease, type WireSchema, type WireCatalog, type WireCatalogEntry, } from './catalog/wire';
34
+ export { WireSchemaSchema, WireCatalogSchema, WireCatalogEntrySchema, schemaToWire, schemaFromWire, catalogToWire, catalogFromWire, UnsupportedSchemaError, PackageReleaseSchema, ReleaseMessageSchema, RELEASE_MESSAGE_MAX, draftSourceId, isDraftSource, releasePreviewSourceId, parseReleasePreview, SDK_VERSION_PATTERN, SdkVersionSchema, OLDEST_SUPPORTED_SDK, SDK_SHIMS, compareSdkVersions, sdkShimsFor, sdkWindowProblem, type SdkShim, HostImportsSchema, HostExportsSchema, hostImportProblems, hostImportsRefusal, type HostImports, type HostExports, PackageBundleRefSchema, type PackageBundleRef, BRAND_MARK_TYPES, BRAND_MARK_SLOTS, BRAND_MARK_MAX_BYTES, BrandMarkSchema, BrandMarkImageSchema, SpaceBrandMarkSchema, type BrandMark, type BrandMarkFile, type BrandMarkUpload, type BrandMarkStored, type BrandMarkSlot, type BrandMarkType, type BrandMarkImage, type SpaceBrandMark, type PackageRelease, type WireSchema, type WireCatalog, type WireCatalogEntry, } from './catalog/wire';
35
35
  export { LateBoundValueSchema, DirectiveValueSchema, ProjectionDirectiveSchema, ProjectionPreferencesSchema, ProjectionSetPayloadSchema, PROJECTION_SET_SIGNAL, isLateBound, isActiveDirective, projectCollection, type LateBoundValue, type DirectiveValue, type ProjectionDirective, type ProjectionPreferences, type ProjectionSetPayload, type ProjectionAccessors, } from './projection/projection';
36
36
  export { VIEW_HOST_SIGNAL, HostPayloadSchema, type HostPayload, hostPlace, pagePlace, hostFillsPage, HostClearedSchema, HOST_CLEARED, type HostCleared, PAGELESS_HOST_PLACE, } from './host/host-page';
37
37
  export { VIEW_FOCUS_ELEMENT_SIGNAL, FocusElementPayloadSchema, type FocusElementPayload, } from './focus/focus';
@@ -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';
@@ -279,7 +279,38 @@ export interface ActionDefinition {
279
279
  * twice, in one run. A rule the model can decline to follow is not a rule.
280
280
  */
281
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[]>;
282
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
+ };
283
314
  /**
284
315
  * The ENTITY facts a precondition may consult, beside the client's live state.
285
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;
package/package.json CHANGED
@@ -26,7 +26,7 @@
26
26
  "react": "^18.3.0 || ^19.0.0",
27
27
  "react-dom": "^18.3.0 || ^19.0.0"
28
28
  },
29
- "version": "0.5.6",
29
+ "version": "0.5.8",
30
30
  "homepage": "https://docs.40rty.ai",
31
31
  "license": "UNLICENSED",
32
32
  "engines": {