@vectoriox/iox-ui 5.119.0 → 5.121.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.
@@ -1,4 +1,4 @@
1
- import { AiStep, JsonSchema, PlanWordContext, AdjustAxis, AdjustKind, SerializedNode } from '@vectoriox/iox-ui/generation-core';
1
+ import { AiStep, JsonSchema, PlanWordContext, AdjustAxis, AdjustKind, SerializedNode, SectionInput } from '@vectoriox/iox-ui/generation-core';
2
2
 
3
3
  /**
4
4
  * The surfaces AI Assist runs on (ai-assist-plan §2, §4): each screen that offers a prompt registers ONE spec — what it
@@ -644,7 +644,8 @@ declare enum PageChangeOp {
644
644
  Words = "words",
645
645
  Style = "style",
646
646
  Scheme = "scheme",
647
- Size = "size"
647
+ Size = "size",
648
+ Section = "section"
648
649
  }
649
650
  interface StyleChange {
650
651
  readonly op: PageChangeOp.Style | PageChangeOp.Scheme | PageChangeOp.Size;
@@ -683,6 +684,113 @@ interface StyleEditsOutcome {
683
684
  */
684
685
  declare function applyStyleEdits(layout: ReadonlyArray<SerializedNode>, edits: ReadonlyArray<LookEdit>, ctx: StyleEditContext): StyleEditsOutcome;
685
686
 
687
+ /**
688
+ * Surface S1 (the builder, this page), family `sections` (ai-assist-plan AI2d; ai-session-panel-plan `addSection` /
689
+ * `removeSection` / `moveSection` / `swapPattern`): a section is added, removed, moved or swapped for another — and every
690
+ * section Ask adds is a library pattern stamped by generation-core's `composeSection`, the SAME recipe the builder palette's
691
+ * ready-made sections and the composer use (R-H9). The model names a pattern from a closed list and a place by handle;
692
+ * it never writes a node. The same pure functions run on the server (the check on a copy) and in the builder (the trial).
693
+ */
694
+ /**
695
+ * The library patterns Ask may add or swap to — those `composeSection` stamps on their own with no Site Plan behind
696
+ * them. Not offered: headers and footers (globals), lists and products (they need a content source — a Pages & data
697
+ * change), Scenes and the owner's film (the look's motion decides them, and a page holds one).
698
+ */
699
+ declare const ASK_SECTION_PATTERNS: ReadonlyArray<string>;
700
+ /** Where an added or moved section goes when it is first on the page. */
701
+ declare const SECTION_START = "start";
702
+ /** The library pattern a section root was stamped from, by its label (the composer names a root by its pattern). */
703
+ declare function sectionPatternOf(root: Pick<SerializedNode, 'label'>): string | undefined;
704
+ /** The patterns Ask offers, as the model and the owner read them: id → its name ("Hero — words centred"). */
705
+ declare function askSectionPatternNames(): Record<string, string>;
706
+ /** A section of the page the family may name: its root, its name, and whether it is in the focus (may be removed, moved, swapped). */
707
+ interface SectionTarget {
708
+ readonly id: string;
709
+ readonly label: string;
710
+ readonly focus: boolean;
711
+ }
712
+ /** Every section of the page by handle (`s0`…) — `after` may name any of them; only focus ones may be changed. */
713
+ type SectionMap = Readonly<Record<string, SectionTarget>>;
714
+ declare enum SectionsAnswerKey {
715
+ Add = "add",
716
+ Remove = "remove",
717
+ Move = "move",
718
+ Swap = "swap",
719
+ Note = "note"
720
+ }
721
+ /**
722
+ * The strict format of family `sections` — ONE request: `add [{pattern, after}]`, `remove [{handle}]`,
723
+ * `move [{handle, after}]`, `swap [{handle, pattern}]`, `note`. Handles are enums of the page's sections (the focus's for
724
+ * what may change), patterns an enum of {@link ASK_SECTION_PATTERNS}. Whether an op makes sense is the check's.
725
+ */
726
+ declare function sectionsJsonSchema(sections: SectionMap): {
727
+ parts: JsonSchema[];
728
+ handles: string[][];
729
+ };
730
+ interface SectionAdd {
731
+ readonly add: string;
732
+ readonly after: string;
733
+ }
734
+ interface SectionRemove {
735
+ readonly remove: string;
736
+ }
737
+ interface SectionMove {
738
+ readonly move: string;
739
+ readonly after: string;
740
+ }
741
+ interface SectionSwap {
742
+ readonly swap: string;
743
+ readonly pattern: string;
744
+ }
745
+ /** Any edit of family `sections`. */
746
+ type SectionEdit = SectionAdd | SectionRemove | SectionMove | SectionSwap;
747
+ declare const isSectionEdit: (e: object) => e is SectionEdit;
748
+ /** The answer → the edits it makes. */
749
+ declare function decodeSectionsAnswers(answers: ReadonlyArray<unknown>): SectionEdit[];
750
+ declare enum SectionChangeKind {
751
+ Add = "add",
752
+ Remove = "remove",
753
+ Move = "move",
754
+ Swap = "swap"
755
+ }
756
+ interface SectionChange {
757
+ readonly op: PageChangeOp.Section;
758
+ readonly kind: SectionChangeKind;
759
+ /** The section's handle (`s2`), or `new` for one added. */
760
+ readonly handle: string;
761
+ /** The node the card outlines — the new root of an added or swapped section, the moved one; a removed one's id (gone). */
762
+ readonly nodeId: string;
763
+ readonly label: string;
764
+ /** The pattern added or swapped to. */
765
+ readonly pattern?: string;
766
+ /** Where it stood / stands, or what it was / is, as the owner reads it. */
767
+ readonly before: string;
768
+ readonly after: string;
769
+ /** A swap: the owner's words and pictures the new section had no place for (still in the old one — Discard keeps it). */
770
+ readonly notPlaced?: number;
771
+ }
772
+ interface SectionEditContext {
773
+ readonly sections: SectionMap;
774
+ /** The studio's name and pages, as the palette composes with (`composeSection`). */
775
+ readonly input?: SectionInput;
776
+ /** A fresh node id (the builder's); default a stable `ask-s<n>` no node of the page holds. */
777
+ readonly newId?: () => string;
778
+ }
779
+ interface SectionEditsOutcome {
780
+ readonly ok: boolean;
781
+ readonly result: SerializedNode[];
782
+ readonly changes: ReadonlyArray<SectionChange>;
783
+ readonly issues: ReadonlyArray<AssistIssue>;
784
+ }
785
+ /**
786
+ * Family `sections`, applied — the SAME check on the server and in the builder. All or none; never mutates its input.
787
+ * Swaps redraw in place, then removals, moves and additions, each placed by the ORIGINAL handles. Refused (re-asked once
788
+ * by the server, never repaired): a handle not on the page or not in the focus, a pattern not offered, a section given two
789
+ * changes, a place that is the section itself or one removed in the same answer, a swap of a section holding a form,
790
+ * content-bound words or a Scene.
791
+ */
792
+ declare function applySectionEdits(layout: ReadonlyArray<SerializedNode>, edits: ReadonlyArray<SectionEdit>, ctx: SectionEditContext): SectionEditsOutcome;
793
+
686
794
  /**
687
795
  * Surface S1 (the builder, this page), family `words` (ai-assist-plan §4, ai-session-panel-plan §3b–§3d): the page as
688
796
  * the model sees it — sections in order, each a handle (`s0`), the parts that carry words as handles (`s0.heading1`,
@@ -738,6 +846,8 @@ interface PageSectionSummary {
738
846
  readonly parts: ReadonlyArray<PagePart>;
739
847
  /** Family `style`: the elements of the section that may take another element style, colour scheme or size step. */
740
848
  readonly looks?: ReadonlyArray<PageLook>;
849
+ /** Family `sections`: the library pattern the section was stamped from, when it is one Ask offers. */
850
+ readonly pattern?: string;
741
851
  }
742
852
  interface PageFocus {
743
853
  readonly scope: AssistScope;
@@ -753,6 +863,8 @@ interface PageFocus {
753
863
  /** How the owner reads the style and scheme ids the looks name. */
754
864
  readonly styleNames?: Readonly<Record<string, string>>;
755
865
  readonly schemeNames?: Readonly<Record<string, string>>;
866
+ /** Family `sections`: the library sections Ask may add or swap to, by id → name. */
867
+ readonly sectionPatterns?: Readonly<Record<string, string>>;
756
868
  }
757
869
  interface PageAround {
758
870
  /** The other sections, one line each. */
@@ -789,6 +901,8 @@ interface SummarizedPage {
789
901
  readonly nodes: Readonly<Record<string, string>>;
790
902
  /** Family `style`: the focus's targets — what a style request carries and the check may write. */
791
903
  readonly looks: LookMap;
904
+ /** Family `sections`: every section of the page by handle; the focus's may be removed, moved or swapped. */
905
+ readonly sections: SectionMap;
792
906
  }
793
907
  /**
794
908
  * The page as the model sees it. The selection decides the focus: a node → its section in full, its own parts as
@@ -877,15 +991,16 @@ declare function pageWriteLocale(layout: ReadonlyArray<SerializedNode>, ctx: {
877
991
  }): string;
878
992
 
879
993
  /**
880
- * Surface S1's answer as ONE thing (AI2b, AI2c): the edits of every family a page turn routed to — words (`{ handle, value }`),
881
- * styles (`{ handle, style }`), schemes (`{ handle, scheme }`), size steps (`{ handle, axis, step }`) — applied in that
882
- * order on a copy, all or none. The server
883
- * checks each family as it is asked; the builder's trial applies the turn's edits through this, so both read one rule.
994
+ * Surface S1's answer as ONE thing (AI2b–AI2d): the edits of every family a page turn routed to — words (`{ handle, value }`),
995
+ * styles (`{ handle, style }`), schemes (`{ handle, scheme }`), size steps (`{ handle, axis, step }`), sections
996
+ * (`{ add | remove | move | swap }`) — applied in that order on a copy, all or none. Sections go last: every handle the
997
+ * other families name is read on the page as it stood. The server checks each family as it is asked; the builder's trial
998
+ * applies the turn's edits through this, so both read one rule.
884
999
  */
885
- type PageEdit = WordEdit | StyleEdit | SchemeEdit | SizeEdit;
886
- type PageChange = WordChange | StyleChange;
1000
+ type PageEdit = WordEdit | StyleEdit | SchemeEdit | SizeEdit | SectionEdit;
1001
+ type PageChange = WordChange | StyleChange | SectionChange;
887
1002
  interface PageEditContext extends Omit<WordEditContext, 'handles' | 'never'> {
888
- readonly summary: Pick<SummarizedPage, 'handles' | 'looks'> & {
1003
+ readonly summary: Pick<SummarizedPage, 'handles' | 'looks'> & Partial<Pick<SummarizedPage, 'sections'>> & {
889
1004
  readonly brief: {
890
1005
  readonly rules: {
891
1006
  readonly never: WordEditContext['never'];
@@ -894,6 +1009,9 @@ interface PageEditContext extends Omit<WordEditContext, 'handles' | 'never'> {
894
1009
  };
895
1010
  /** The builder's registry baseline; default the saved shape's (`serializedBaselineStyles`). */
896
1011
  readonly baseline?: BaselineStyles;
1012
+ /** Family `sections`: the studio's name and pages (what the palette composes with) and the builder's fresh ids. */
1013
+ readonly sectionInput?: SectionEditContext['input'];
1014
+ readonly newId?: SectionEditContext['newId'];
897
1015
  }
898
1016
  interface PageEditsOutcome {
899
1017
  readonly ok: boolean;
@@ -952,9 +1070,9 @@ interface AssistTurnRequest {
952
1070
  };
953
1071
  }
954
1072
  /** What a turn proposes, per family: a field's value (`fields`), a part's words (`words`), an element's style or a section's scheme (`style`). */
955
- type AssistEdit = FieldEdit | WordEdit | StyleEdit | SchemeEdit | SizeEdit;
1073
+ type AssistEdit = FieldEdit | WordEdit | StyleEdit | SchemeEdit | SizeEdit | SectionEdit;
956
1074
  /** What a turn changed, as the card says it. */
957
- type AssistChange = FieldChange | WordChange | StyleChange;
1075
+ type AssistChange = FieldChange | WordChange | StyleChange | SectionChange;
958
1076
  /** POST's 202 answer. */
959
1077
  interface AssistTurnAccepted {
960
1078
  readonly turnId: string;
@@ -1065,5 +1183,5 @@ declare function turnLocale(sentence: string, fields: ReadonlyArray<AssistField>
1065
1183
  /** The language's own name in the admin's language (`en` → "English" / "אנגלית"). */
1066
1184
  declare const languageName: (locale: string, uiLang: string) => string;
1067
1185
 
1068
- export { AROUND_ITEMS_MAX, AROUND_TEXT_CHARS, ASK_STYLE_SETS, ASSIST_MODEL_AUTO, ASSIST_POLL_MS, ASSIST_ROUTES, AssistBriefError, AssistBudgetError, AssistFieldKind, AssistIssueCode, AssistPathError, AssistPermission, AssistRefusalCode, AssistRouteKey, AssistScope, AssistStep, AssistSurface, AssistTurnStatus, BOOLEAN_FALSE, BOOLEAN_TRUE, CommitKind, EditFamily, FIELDS_PER_PART, FIELD_HANDLE_PREFIX, FOCUS_TEXT_CHARS, FieldsAnswerKey, ItemSuggestionKind, LOCALE_NAME_LANGUAGES, MAX_ASSIST_PROPERTIES, MAX_ROUTE_PROPERTIES, MAX_SENTENCE_CHARS, MEMORY_TURNS, NEW_TARGET, NONE_TEXT, NeverWriteReason, PAGE_WORD_SLOTS, PageChangeOp, PagePartKind, PageSuggestionKind, RouteAnswerKey, SHORTEN_FROM_CHARS, SHORTEN_HEADING_FROM_CHARS, SHORTEN_TEXT_FROM_CHARS, SIBLING_HANDLE_PREFIX, SURFACES, StyleAnswerKey, SurfaceStatus, WORDS_PER_PART, WordsAnswerKey, adjustAxesOf, applyFieldEdits, applyPageEdits, applyStyleEdits, applyWordEdits, askableStyles, assertAssistBudget, assistBudgetIssues, assistFactIssues, assistFields, assistPath, assistSession, assistSessionKey, builtSurfaces, clipText, commitOf, containsHtml, decodeFieldsAnswers, decodeStyleAnswers, decodeWordsAnswers, escapeText, fieldHandle, fieldsJsonSchema, fieldsNamedIn, isEmptyFieldValue, isPlainRecord, isSchemeEdit, isSessionOf, isSizeEdit, isStyleEdit, isTerminalTurn, isWritable, itemLocales, itemSuggestions, languageName, lookNames, memoryLine, namedLocale, pageLooks, pageSuggestions, pageWriteLocale, paragraphsToRichText, primaryLocale, readFieldValue, readLocaleValues, readRoute, readableWords, resolveHandle, richTextParagraphs, routeJsonSchema, sectionLabel, serializedBaselineStyles, sessionMemory, styleJsonSchema, summarizeItem, summarizePage, surfacePermissions, surfaceSpec, titleField, turnLocale, unknownHandles, validateTurnRequest, wordsJsonSchema };
1069
- export type { AssistChange, AssistEdit, AssistField, AssistIssue, AssistMemoryLine, AssistModelChoice, AssistRoute, AssistSession, AssistTarget, AssistTurn, AssistTurnAccepted, AssistTurnRefusal, AssistTurnRequest, AssistWordContext, BaselineStyles, Brief, BriefRules, BriefValue, ContentControllerDef, ContentPropertyDef, ContentRecord, ContentTypeSchema, FieldChange, FieldEdit, FieldEditContext, FieldEditsOutcome, FieldsSchemaOptions, FieldsSchemas, HandleMap, HandleResolution, HandleTarget, ItemAround, ItemBrief, ItemBriefContext, ItemBriefField, ItemFocus, ItemSuggestion, ItemSummary, LookEdit, LookMap, LookTarget, NeverWrite, PageAround, PageBrief, PageBriefContext, PageChange, PageEdit, PageEditContext, PageEditsOutcome, PageFocus, PageLook, PagePart, PageSectionSummary, PageSuggestion, SchemeEdit, SizeEdit, StyleChange, StyleEdit, StyleEditContext, StyleEditsOutcome, StyleSchemas, SummarizedItem, SummarizedPage, SurfaceSpec, WalkedLook, WordChange, WordEdit, WordEditContext, WordEditsOutcome, WordsSchemas, WrittenWords };
1186
+ export { AROUND_ITEMS_MAX, AROUND_TEXT_CHARS, ASK_SECTION_PATTERNS, ASK_STYLE_SETS, ASSIST_MODEL_AUTO, ASSIST_POLL_MS, ASSIST_ROUTES, AssistBriefError, AssistBudgetError, AssistFieldKind, AssistIssueCode, AssistPathError, AssistPermission, AssistRefusalCode, AssistRouteKey, AssistScope, AssistStep, AssistSurface, AssistTurnStatus, BOOLEAN_FALSE, BOOLEAN_TRUE, CommitKind, EditFamily, FIELDS_PER_PART, FIELD_HANDLE_PREFIX, FOCUS_TEXT_CHARS, FieldsAnswerKey, ItemSuggestionKind, LOCALE_NAME_LANGUAGES, MAX_ASSIST_PROPERTIES, MAX_ROUTE_PROPERTIES, MAX_SENTENCE_CHARS, MEMORY_TURNS, NEW_TARGET, NONE_TEXT, NeverWriteReason, PAGE_WORD_SLOTS, PageChangeOp, PagePartKind, PageSuggestionKind, RouteAnswerKey, SECTION_START, SHORTEN_FROM_CHARS, SHORTEN_HEADING_FROM_CHARS, SHORTEN_TEXT_FROM_CHARS, SIBLING_HANDLE_PREFIX, SURFACES, SectionChangeKind, SectionsAnswerKey, StyleAnswerKey, SurfaceStatus, WORDS_PER_PART, WordsAnswerKey, adjustAxesOf, applyFieldEdits, applyPageEdits, applySectionEdits, applyStyleEdits, applyWordEdits, askSectionPatternNames, askableStyles, assertAssistBudget, assistBudgetIssues, assistFactIssues, assistFields, assistPath, assistSession, assistSessionKey, builtSurfaces, clipText, commitOf, containsHtml, decodeFieldsAnswers, decodeSectionsAnswers, decodeStyleAnswers, decodeWordsAnswers, escapeText, fieldHandle, fieldsJsonSchema, fieldsNamedIn, isEmptyFieldValue, isPlainRecord, isSchemeEdit, isSectionEdit, isSessionOf, isSizeEdit, isStyleEdit, isTerminalTurn, isWritable, itemLocales, itemSuggestions, languageName, lookNames, memoryLine, namedLocale, pageLooks, pageSuggestions, pageWriteLocale, paragraphsToRichText, primaryLocale, readFieldValue, readLocaleValues, readRoute, readableWords, resolveHandle, richTextParagraphs, routeJsonSchema, sectionLabel, sectionPatternOf, sectionsJsonSchema, serializedBaselineStyles, sessionMemory, styleJsonSchema, summarizeItem, summarizePage, surfacePermissions, surfaceSpec, titleField, turnLocale, unknownHandles, validateTurnRequest, wordsJsonSchema };
1187
+ export type { AssistChange, AssistEdit, AssistField, AssistIssue, AssistMemoryLine, AssistModelChoice, AssistRoute, AssistSession, AssistTarget, AssistTurn, AssistTurnAccepted, AssistTurnRefusal, AssistTurnRequest, AssistWordContext, BaselineStyles, Brief, BriefRules, BriefValue, ContentControllerDef, ContentPropertyDef, ContentRecord, ContentTypeSchema, FieldChange, FieldEdit, FieldEditContext, FieldEditsOutcome, FieldsSchemaOptions, FieldsSchemas, HandleMap, HandleResolution, HandleTarget, ItemAround, ItemBrief, ItemBriefContext, ItemBriefField, ItemFocus, ItemSuggestion, ItemSummary, LookEdit, LookMap, LookTarget, NeverWrite, PageAround, PageBrief, PageBriefContext, PageChange, PageEdit, PageEditContext, PageEditsOutcome, PageFocus, PageLook, PagePart, PageSectionSummary, PageSuggestion, SchemeEdit, SectionAdd, SectionChange, SectionEdit, SectionEditContext, SectionEditsOutcome, SectionMap, SectionMove, SectionRemove, SectionSwap, SectionTarget, SizeEdit, StyleChange, StyleEdit, StyleEditContext, StyleEditsOutcome, StyleSchemas, SummarizedItem, SummarizedPage, SurfaceSpec, WalkedLook, WordChange, WordEdit, WordEditContext, WordEditsOutcome, WordsSchemas, WrittenWords };
@@ -467,7 +467,7 @@ declare enum PaymentMethodKind {
467
467
  PayOnPickup = "payOnPickup",
468
468
  CashOnDelivery = "cashOnDelivery",
469
469
  Bit = "bit",
470
- /** A PSP's hosted page (E2, Cardcom first) — typed now, not offered yet. */
470
+ /** A PSP's hosted page (E2, Cardcom first): the buyer pays there, never on a card field of ours. */
471
471
  Online = "online"
472
472
  }
473
473
  declare enum PaymentProvider {
@@ -494,6 +494,8 @@ interface PaymentMethodRule {
494
494
  readonly channel: PaymentChannel;
495
495
  /** false = typed for a later phase, never shown to a buyer. */
496
496
  readonly offered: boolean;
497
+ /** Ready only while the studio's payment connector answers (E2): the server says so in `connected`. */
498
+ readonly needsConnection: boolean;
497
499
  readonly fields: readonly PaymentField[];
498
500
  readonly fit: DeliveryFit;
499
501
  readonly label: CommerceLabel;
@@ -508,12 +510,19 @@ interface PaymentMethodConfig {
508
510
  details?: Partial<Record<PaymentField, string>> | null;
509
511
  /** The owner's own words, shown after the instructions. */
510
512
  note?: string | null;
513
+ /**
514
+ * A FACT the server adds, never stored: the studio's payment connector answered its last check (E2). Only a method
515
+ * that `needsConnection` reads it — a card method whose terminal does not answer is not a way to get paid.
516
+ */
517
+ connected?: boolean | null;
511
518
  }
512
519
  declare const isPaymentMethodKind: (value: unknown) => value is PaymentMethodKind;
513
520
  declare function paymentChannelOf(kind: PaymentMethodKind): PaymentChannel;
514
521
  /** The fields a method lacks or holds in a form it cannot be paid with. */
515
522
  declare function paymentMethodProblems(config: PaymentMethodConfig): PaymentField[];
516
- /** Enabled, offered in this phase, complete: the ONE rule the checkout and its gate read. */
523
+ /** A method that needs no connection, or whose connection answered (E2). */
524
+ declare function paymentMethodConnected(config: PaymentMethodConfig): boolean;
525
+ /** Enabled, offered in this phase, complete and — for a card method — connected: the ONE rule the checkout and its gate read. */
517
526
  declare function paymentMethodReady(config: PaymentMethodConfig): boolean;
518
527
  /** The methods a buyer may pick with this delivery (null = nothing ships). */
519
528
  declare function usablePaymentMethods(configs: readonly PaymentMethodConfig[], shippingKind?: ShippingMethodKind | null): PaymentMethodConfig[];
@@ -618,6 +627,122 @@ declare function openingOrderState(kind: PaymentMethodKind): {
618
627
  declare function reservationExpiresAt(now: Date): Date;
619
628
  declare const ORDER_STATE_LABELS: Readonly<Record<OrderState, CommerceLabel>>;
620
629
 
630
+ /**
631
+ * Card payments (commerce E2, C-D2, trap T2): what a payment provider's answer MEANS for an order. The provider's
632
+ * adapter (iox-cms) asks the provider itself — never the buyer's browser, never a webhook's body — and normalises its
633
+ * answer to a `PaymentResult`; `paymentVerdict` decides. Pure: no clock (the caller passes `now`), no provider names.
634
+ */
635
+ declare enum PaymentResultStatus {
636
+ /** The provider took the money: a transaction exists. */
637
+ Paid = "paid",
638
+ /** The page is open (the buyer has not paid yet, or a card was declined and the page still waits). */
639
+ Pending = "pending",
640
+ /** The provider closed the session without a payment. */
641
+ Failed = "failed",
642
+ /** The provider does not know the session (or did not answer): nothing is decided. */
643
+ Unknown = "unknown"
644
+ }
645
+ /** One provider answer about one session, as its adapter read it. */
646
+ interface PaymentResult {
647
+ status: PaymentResultStatus;
648
+ /** The provider's session id, as the provider said it. */
649
+ sessionId: string | null;
650
+ /** Our reference, echoed back by the provider (what we sent when the session was made). */
651
+ reference: string | null;
652
+ /** The provider's transaction id — what a refund names. */
653
+ transactionId: string | null;
654
+ /** What was charged, in minor units of the charged currency. */
655
+ amount: Money | null;
656
+ /** The provider's words for the last declined try while the page still waits — shown to the buyer. */
657
+ declined?: string | null;
658
+ /** What the owner may read of the card that paid (never more than a brand and the last four digits). */
659
+ card?: PaidCard | null;
660
+ }
661
+ interface PaidCard {
662
+ brand: string | null;
663
+ last4: string | null;
664
+ }
665
+ /** One time the buyer was sent to the provider's page for an order. */
666
+ declare enum PaymentAttemptStatus {
667
+ Open = "open",
668
+ Paid = "paid",
669
+ Failed = "failed",
670
+ /** The order expired or was cancelled while this page was open. */
671
+ Closed = "closed"
672
+ }
673
+ interface PaymentAttempt {
674
+ /** Our reference: the provider echoes it, so a result for another order is refused. */
675
+ reference: string;
676
+ provider: string;
677
+ sessionId: string;
678
+ /** Where the buyer pays (the provider's hosted page). */
679
+ url: string;
680
+ status: PaymentAttemptStatus;
681
+ createdAt: Date | string;
682
+ }
683
+ declare enum PaymentVerdictKind {
684
+ /** Paid and every fact matches: the order moves to paid (the machine's `confirmPayment`). */
685
+ Confirm = "confirm",
686
+ /** The provider closed the session unpaid: `failPayment`, the reservation released. */
687
+ Fail = "fail",
688
+ /** Still open: show "Confirming…" and ask again. */
689
+ Wait = "wait",
690
+ /** Nothing to do (an unknown session, a pending page of an order that moved on). */
691
+ Ignore = "ignore",
692
+ /** The answer does not belong to this order or does not match it: nothing changes, the owner is told. */
693
+ Refuse = "refuse",
694
+ /** The same transaction was already recorded: a replayed answer, a second webhook, the return racing the webhook. */
695
+ AlreadyPaid = "alreadyPaid",
696
+ /** A SECOND transaction paid an order already paid (two tabs): kept for the owner to refund. */
697
+ PaidTwice = "paidTwice",
698
+ /** Paid after the order was cancelled (the reservation ran out): kept for the owner to refund. */
699
+ PaidAfterClose = "paidAfterClose"
700
+ }
701
+ declare enum PaymentMismatch {
702
+ Session = "session-mismatch",
703
+ Reference = "reference-mismatch",
704
+ Currency = "currency-mismatch",
705
+ Amount = "amount-mismatch",
706
+ NoTransaction = "no-transaction"
707
+ }
708
+ interface PaymentVerdict {
709
+ kind: PaymentVerdictKind;
710
+ mismatches: PaymentMismatch[];
711
+ }
712
+ interface PaymentVerdictInput {
713
+ state: OrderState;
714
+ /** The order's total — what must have been charged. */
715
+ total: Money;
716
+ /** The attempt this answer is about (found by OUR records, never by the answer). */
717
+ attempt: Pick<PaymentAttempt, 'reference' | 'sessionId'>;
718
+ /** The transaction already recorded as paying this order, if any. */
719
+ paidTransactionId: string | null;
720
+ result: PaymentResult;
721
+ }
722
+ /** THE decision on a provider's answer (T2): only a paid answer for THIS attempt, of exactly this total, pays — once. */
723
+ declare function paymentVerdict(input: PaymentVerdictInput): PaymentVerdict;
724
+ /** A page made this recently is sent again instead of a new one (a double click, a second tab) — while the stock is held. */
725
+ declare function reusableAttempt(attempts: readonly PaymentAttempt[] | null | undefined, now: number): PaymentAttempt | null;
726
+ /** The reservation ran out: the payment sweep asks the provider one last time, then expires the order (C-D10). */
727
+ declare function reservationDue(reservedUntil: Date | string | null | undefined, now: number): boolean;
728
+ /** What the buyer's order page shows about paying (the engine's "Confirming your payment…"). */
729
+ declare enum BuyerPaymentStage {
730
+ /** A manual method: how to pay. */
731
+ Instructions = "instructions",
732
+ /** A card payment is open: confirming with the provider. */
733
+ Confirming = "confirming",
734
+ Paid = "paid",
735
+ /** The card payment did not go through: the buyer may try again. */
736
+ Failed = "failed",
737
+ /** Cancelled (by the owner, or not paid in time). */
738
+ Closed = "closed"
739
+ }
740
+ declare function buyerPaymentStage(state: OrderState, channel: PaymentChannel): BuyerPaymentStage;
741
+ /** The buyer may (re)open the payment page: still within the open states of a card order. */
742
+ declare function buyerMayPay(state: OrderState, channel: PaymentChannel): boolean;
743
+ /** What happened to a card payment, as the order's history and the admin say it. */
744
+ declare const PAYMENT_VERDICT_LABELS: Readonly<Record<PaymentVerdictKind, CommerceLabel>>;
745
+
621
746
  /** The fixed checkout's steps, in order (C-D3); a checkout keeps the FURTHEST it reached (the journey, §3g). */
622
747
  declare enum CheckoutStep {
623
748
  Contact = "contact",
@@ -1115,6 +1240,12 @@ declare enum SiteCommerceRoute {
1115
1240
  Unsubscribe = "marketing/unsubscribe",
1116
1241
  Order = "order"
1117
1242
  }
1243
+ /** What the buyer does to a card order through its link (E2): `pay` opens (or re-opens) the provider's page. */
1244
+ declare enum SiteOrderAction {
1245
+ Pay = "pay"
1246
+ }
1247
+ /** `POST /api/site/<org>/order/<token>/pay` — root-relative, like every site route. */
1248
+ declare function siteOrderActionPath(orgId: string, token: string, action: SiteOrderAction): string;
1118
1249
  /** A public commerce route of one org, ROOT-relative (the same rule as `cartEndpointPath`). */
1119
1250
  declare function siteCommercePath(orgId: string, route: SiteCommerceRoute, id?: string | null): string;
1120
1251
  /** The cart cookie iox-cms sets for one org (httpOnly — a site script never reads it; SSR forwards it). */
@@ -1220,11 +1351,29 @@ interface SiteBuyerOrder {
1220
1351
  snapshot: OrderSnapshot;
1221
1352
  paymentLabel: string;
1222
1353
  instructions: string | null;
1354
+ /** How paying stands (E2): the stage the page shows, whether the buyer may open the payment page, a declined card's words. */
1355
+ payment: SiteOrderPayment;
1356
+ }
1357
+ interface SiteOrderPayment {
1358
+ channel: PaymentChannel;
1359
+ stage: BuyerPaymentStage;
1360
+ canPay: boolean;
1361
+ declined: string | null;
1362
+ }
1363
+ /** Where to send the buyer to pay — a card order only (E2); `null` when the page could not be made (they try again from the order page). */
1364
+ interface SitePaymentRedirect {
1365
+ redirectUrl: string;
1223
1366
  }
1224
1367
  /** `POST checkout/place` — 201. */
1225
1368
  interface SitePlacedOrder {
1226
1369
  order: SiteBuyerOrder;
1227
1370
  viewToken: string;
1371
+ payment?: SitePaymentRedirect | null;
1372
+ }
1373
+ /** `POST order/:token/pay` — the order as it stands and where to pay. */
1374
+ interface SitePayAnswer {
1375
+ order: SiteBuyerOrder;
1376
+ payment: SitePaymentRedirect | null;
1228
1377
  }
1229
1378
  /**
1230
1379
  * The step to SHOW: no checkout yet is Contact; then the first step still missing what it needs — a delivery chosen
@@ -1282,7 +1431,18 @@ declare enum CheckoutWord {
1282
1431
  Coupon = "coupon",
1283
1432
  ApplyCoupon = "applyCoupon",
1284
1433
  RemoveCoupon = "removeCoupon",
1285
- Discount = "discount"
1434
+ Discount = "discount",
1435
+ PayOrder = "payOrder",
1436
+ PayNote = "payNote",
1437
+ ToPaymentPage = "toPaymentPage",
1438
+ ConfirmingPayment = "confirmingPayment",
1439
+ ConfirmingSlow = "confirmingSlow",
1440
+ PaymentConfirmed = "paymentConfirmed",
1441
+ PaymentFailed = "paymentFailed",
1442
+ PaymentDeclined = "paymentDeclined",
1443
+ TryAgain = "tryAgain",
1444
+ PayNow = "payNow",
1445
+ OrderClosed = "orderClosed"
1286
1446
  }
1287
1447
  /** `{name}`, `{n}`, `{of}`, `{amount}`, `{percent}`, `{number}`, `{email}`, `{total}`, `{place}` are filled by `checkoutWord`. */
1288
1448
  declare const CHECKOUT_WORDS: Readonly<Record<CheckoutWord, CommerceLabel>>;
@@ -1350,6 +1510,10 @@ declare enum SiteRefusalCode {
1350
1510
  RecoveryDone = "recovery-done",
1351
1511
  /** A reminder's link whose bag is gone, or a link that is not one. */
1352
1512
  RecoveryExpired = "recovery-expired",
1513
+ /** The payment page could not be made right now (the provider did not answer) — the order stands; try again (E2). */
1514
+ PaymentUnavailable = "payment-unavailable",
1515
+ /** This order cannot be paid any more (paid, or cancelled). */
1516
+ PaymentClosed = "payment-closed",
1353
1517
  Network = "network"
1354
1518
  }
1355
1519
  interface RefusalRule {
@@ -1575,5 +1739,5 @@ declare const looksLikeEmail: (value: unknown) => boolean;
1575
1739
  /** A phone a person can be called on: 7–15 digits once spaces, dashes, brackets and a leading + are dropped. */
1576
1740
  declare const looksLikePhone: (value: unknown) => boolean;
1577
1741
 
1578
- export { ABANDONED_AFTER_MS, Availability, CART_COOKIE_PREFIX, CART_ISSUE_LABELS, CART_TRANSPORT_ERROR_LABELS, CHECKOUT_FORM_STEPS, CHECKOUT_GATE_RULES, CHECKOUT_PATH, CHECKOUT_STEPS, CHECKOUT_STEP_LABELS, CHECKOUT_WORDS, COUPON_CODE_MAX, COUPON_CODE_MIN, COUPON_REFUSAL_LABELS, CURRENCY_CODES, CURRENCY_EXPONENTS, CartIssueCode, CartTransportError, CartTransportErrorCode, CheckoutAskedField, CheckoutFieldMode, CheckoutGateArea, CheckoutGateCode, CheckoutSlot, CheckoutStep, CheckoutWord, CommerceLanguage, CouponKind, CouponProblem, CouponRefusal, CurrencyCode, DEFAULT_JOURNEY_DAYS, DEFAULT_MONEY_LOCALE, DEFAULT_REMINDER_SETTINGS, DEFAULT_VARIANT_NAME, DeliveryFit, FINAL_ORDER_STATES, FUNNEL_STAGES, FunnelStage, JOURNEY_PERIODS_DAYS, JourneyEventKind, LegalPage, MAX_CART_AMOUNT, MAX_CART_LINES, MAX_LINE_QUANTITY, MAX_VAT_PERCENT, MIN_LINE_QUANTITY, MoneyError, MoneyErrorCode, NO_CART_TRANSPORT, ORDER_PATH, ORDER_STATE_LABELS, ORDER_STOCK_HOLD, ORDER_TRANSITIONS, OrderActor, OrderEvent, OrderRefusal, OrderSnapshotRefusal, OrderState, PAYMENT_FIELD_LABELS, PAYMENT_METHODS, PaymentChannel, PaymentField, PaymentMethodKind, PaymentProvider, QuantityStep, RECOVERY_PATH, RECOVERY_WORDS, REMINDER_LATE_MS, REMINDER_SEQUENCE, REMINDER_STEPS, REMINDER_SUBJECT_WORDS, REMINDER_WORDS_MAX, RecoveryWord, ReminderOutcome, ReminderSkip, ReminderStep, ReminderStop, SAMPLE_CART_LINE, SAMPLE_PRODUCT, SAMPLE_STUDIO, SAMPLE_SWATCHES, SHIPPING_KINDS, SHOP_SLOTS, SHOP_WORDS, SITE_REFUSALS, STOCK_EFFECTS, STOCK_RESERVATION_MINUTES, STOREFRONT_COMPUTED_FIELDS, STOREFRONT_FIELDS, ShippingField, ShippingMethodKind, ShopSlot, ShopWord, SiteCommerceRoute, SiteRefusalCode, StockEffect, StockHold, StorefrontCollection, UNSUBSCRIBE_PATH, VARIANT_NAME_SEPARATOR, VAT_PERCENT_MAX_DECIMALS, addMoney, addressLine, availableShippingMethods, biggestDrop, canBuy, canStep, cartCookieName, cartEndpointPath, cartIssueWords, cartLineId, cartOf, cartTransportErrorFor, cartViewOf, catalogKey, checkoutGate, checkoutHref, checkoutWord, chooseValue, clampQuantity, commerceLanguage, couponDiscount, couponOfferWords, couponProblems, couponRefusalWords, currencyExponent, currentCheckoutStep, defaultChoice, emptyCartView, fieldAsked, fieldRequired, findVariant, formatMoney, formatMoneyValue, freeShippingRemaining, funnelOf, furthestStep, includedVat, isAbandoned, isCouponCode, isCurrencyCode, isMoney, isPaymentMethodKind, isShippingMethodKind, isStorefrontField, isStorefrontProduct, isVatPercent, labelIn, looksLikeEmail, looksLikePhone, majorToMinor, marketingAllowed, maskEmail, mergeCarts, migrateMajorPrice, minorToMajor, money, nextOrderState, nextReminder, normalizeCouponCode, openingOrderState, optionValueStates, orderHref, orderSnapshot, paymentChannelOf, paymentInstructions, paymentMethodProblems, paymentMethodReady, percentOf, priceCart, productCurrency, productInScope, productOptions, productVariants, quantityBounds, quoteShipping, recoveryHref, recoveryWord, reminderNumber, reminderSettingsOf, reservationExpiresAt, sellableQuantity, shippingMethodProblems, shippingMethodReady, shippingNeedsAddress, shopWord, simulatedCartTransport, siteCartView, siteCommercePath, siteRefusalsOf, stepQuantity, stockEffect, stoppedAt, storefrontBindPaths, storefrontCatalog, storefrontMoney, subtractMoney, timesMoney, unsubscribeHref, usablePaymentMethods, variantChoiceOf, variantSlotOf, variantWords };
1579
- export type { AddToCartRequest, AppliedCoupon, BusinessIdentity, Cart, CartIssue, CartLine, CartTransport, CartView, CartViewLine, CatalogEntry, CheckoutFieldModes, CheckoutGateFacts, CheckoutGateRefusal, CheckoutGateResult, CommerceLabel, ConsentDecision, Coupon, CouponCheck, FunnelRow, Money, OptionState, OptionValueState, OrderBuyer, OrderMove, OrderSnapshot, OrderSnapshotLine, OrderSnapshotResult, OrderTransition, PaymentMethodConfig, PostalAddress, PricedCart, PricedLine, PricingChoice, ProductOption, ProductVariantView, QuantityBounds, ReminderFacts, ReminderPlan, ReminderSettings, ReminderTiming, ReminderWords, ShippingCart, ShippingGoods, ShippingMethod, ShippingQuote, SimulatedCartTransport, SiteBuyerOrder, SiteCartView, SiteCheckoutContact, SiteCheckoutOptions, SiteCheckoutView, SiteLegalLink, SitePaymentOption, SitePlacedOrder, SiteRefusal, SiteShippingMethod, SiteShippingOption, SiteUnsubscribeState, StorefrontFieldSpec, StorefrontProduct, StorefrontVariant, StudioCommerce, VariantChoice, VariantSlot };
1742
+ export { ABANDONED_AFTER_MS, Availability, BuyerPaymentStage, CART_COOKIE_PREFIX, CART_ISSUE_LABELS, CART_TRANSPORT_ERROR_LABELS, CHECKOUT_FORM_STEPS, CHECKOUT_GATE_RULES, CHECKOUT_PATH, CHECKOUT_STEPS, CHECKOUT_STEP_LABELS, CHECKOUT_WORDS, COUPON_CODE_MAX, COUPON_CODE_MIN, COUPON_REFUSAL_LABELS, CURRENCY_CODES, CURRENCY_EXPONENTS, CartIssueCode, CartTransportError, CartTransportErrorCode, CheckoutAskedField, CheckoutFieldMode, CheckoutGateArea, CheckoutGateCode, CheckoutSlot, CheckoutStep, CheckoutWord, CommerceLanguage, CouponKind, CouponProblem, CouponRefusal, CurrencyCode, DEFAULT_JOURNEY_DAYS, DEFAULT_MONEY_LOCALE, DEFAULT_REMINDER_SETTINGS, DEFAULT_VARIANT_NAME, DeliveryFit, FINAL_ORDER_STATES, FUNNEL_STAGES, FunnelStage, JOURNEY_PERIODS_DAYS, JourneyEventKind, LegalPage, MAX_CART_AMOUNT, MAX_CART_LINES, MAX_LINE_QUANTITY, MAX_VAT_PERCENT, MIN_LINE_QUANTITY, MoneyError, MoneyErrorCode, NO_CART_TRANSPORT, ORDER_PATH, ORDER_STATE_LABELS, ORDER_STOCK_HOLD, ORDER_TRANSITIONS, OrderActor, OrderEvent, OrderRefusal, OrderSnapshotRefusal, OrderState, PAYMENT_FIELD_LABELS, PAYMENT_METHODS, PAYMENT_VERDICT_LABELS, PaymentAttemptStatus, PaymentChannel, PaymentField, PaymentMethodKind, PaymentMismatch, PaymentProvider, PaymentResultStatus, PaymentVerdictKind, QuantityStep, RECOVERY_PATH, RECOVERY_WORDS, REMINDER_LATE_MS, REMINDER_SEQUENCE, REMINDER_STEPS, REMINDER_SUBJECT_WORDS, REMINDER_WORDS_MAX, RecoveryWord, ReminderOutcome, ReminderSkip, ReminderStep, ReminderStop, SAMPLE_CART_LINE, SAMPLE_PRODUCT, SAMPLE_STUDIO, SAMPLE_SWATCHES, SHIPPING_KINDS, SHOP_SLOTS, SHOP_WORDS, SITE_REFUSALS, STOCK_EFFECTS, STOCK_RESERVATION_MINUTES, STOREFRONT_COMPUTED_FIELDS, STOREFRONT_FIELDS, ShippingField, ShippingMethodKind, ShopSlot, ShopWord, SiteCommerceRoute, SiteOrderAction, SiteRefusalCode, StockEffect, StockHold, StorefrontCollection, UNSUBSCRIBE_PATH, VARIANT_NAME_SEPARATOR, VAT_PERCENT_MAX_DECIMALS, addMoney, addressLine, availableShippingMethods, biggestDrop, buyerMayPay, buyerPaymentStage, canBuy, canStep, cartCookieName, cartEndpointPath, cartIssueWords, cartLineId, cartOf, cartTransportErrorFor, cartViewOf, catalogKey, checkoutGate, checkoutHref, checkoutWord, chooseValue, clampQuantity, commerceLanguage, couponDiscount, couponOfferWords, couponProblems, couponRefusalWords, currencyExponent, currentCheckoutStep, defaultChoice, emptyCartView, fieldAsked, fieldRequired, findVariant, formatMoney, formatMoneyValue, freeShippingRemaining, funnelOf, furthestStep, includedVat, isAbandoned, isCouponCode, isCurrencyCode, isMoney, isPaymentMethodKind, isShippingMethodKind, isStorefrontField, isStorefrontProduct, isVatPercent, labelIn, looksLikeEmail, looksLikePhone, majorToMinor, marketingAllowed, maskEmail, mergeCarts, migrateMajorPrice, minorToMajor, money, nextOrderState, nextReminder, normalizeCouponCode, openingOrderState, optionValueStates, orderHref, orderSnapshot, paymentChannelOf, paymentInstructions, paymentMethodConnected, paymentMethodProblems, paymentMethodReady, paymentVerdict, percentOf, priceCart, productCurrency, productInScope, productOptions, productVariants, quantityBounds, quoteShipping, recoveryHref, recoveryWord, reminderNumber, reminderSettingsOf, reservationDue, reservationExpiresAt, reusableAttempt, sellableQuantity, shippingMethodProblems, shippingMethodReady, shippingNeedsAddress, shopWord, simulatedCartTransport, siteCartView, siteCommercePath, siteOrderActionPath, siteRefusalsOf, stepQuantity, stockEffect, stoppedAt, storefrontBindPaths, storefrontCatalog, storefrontMoney, subtractMoney, timesMoney, unsubscribeHref, usablePaymentMethods, variantChoiceOf, variantSlotOf, variantWords };
1743
+ export type { AddToCartRequest, AppliedCoupon, BusinessIdentity, Cart, CartIssue, CartLine, CartTransport, CartView, CartViewLine, CatalogEntry, CheckoutFieldModes, CheckoutGateFacts, CheckoutGateRefusal, CheckoutGateResult, CommerceLabel, ConsentDecision, Coupon, CouponCheck, FunnelRow, Money, OptionState, OptionValueState, OrderBuyer, OrderMove, OrderSnapshot, OrderSnapshotLine, OrderSnapshotResult, OrderTransition, PaidCard, PaymentAttempt, PaymentMethodConfig, PaymentResult, PaymentVerdict, PaymentVerdictInput, PostalAddress, PricedCart, PricedLine, PricingChoice, ProductOption, ProductVariantView, QuantityBounds, ReminderFacts, ReminderPlan, ReminderSettings, ReminderTiming, ReminderWords, ShippingCart, ShippingGoods, ShippingMethod, ShippingQuote, SimulatedCartTransport, SiteBuyerOrder, SiteCartView, SiteCheckoutContact, SiteCheckoutOptions, SiteCheckoutView, SiteLegalLink, SiteOrderPayment, SitePayAnswer, SitePaymentOption, SitePaymentRedirect, SitePlacedOrder, SiteRefusal, SiteShippingMethod, SiteShippingOption, SiteUnsubscribeState, StorefrontFieldSpec, StorefrontProduct, StorefrontVariant, StudioCommerce, VariantChoice, VariantSlot };