@vectoriox/iox-ui 5.118.0 → 5.120.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.
- package/assist-core/index.d.ts +41 -13
- package/commerce-core/index.d.ts +169 -5
- package/fesm2022/vectoriox-iox-ui-assist-core.mjs +91 -12
- package/fesm2022/vectoriox-iox-ui-assist-core.mjs.map +1 -1
- package/fesm2022/vectoriox-iox-ui-commerce-core.mjs +214 -5
- package/fesm2022/vectoriox-iox-ui-commerce-core.mjs.map +1 -1
- package/fesm2022/vectoriox-iox-ui-generation-core.mjs +178 -1
- package/fesm2022/vectoriox-iox-ui-generation-core.mjs.map +1 -1
- package/generation-core/index.d.ts +56 -2
- package/package.json +1 -1
- package/src/assist-core/assist-turn.ts +3 -3
- package/src/assist-core/page-edits.ts +6 -5
- package/src/assist-core/page-style.ts +115 -13
- package/src/assist-core/page-words.ts +2 -1
- package/src/commerce-core/payment-sessions.ts +213 -0
- package/src/commerce-core/payments.ts +21 -4
- package/src/commerce-core/public-api.ts +1 -0
- package/src/commerce-core/site-checkout.ts +61 -1
- package/src/generation-core/adjustments.ts +182 -0
- package/src/generation-core/public-api.ts +1 -0
package/assist-core/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AiStep, JsonSchema, PlanWordContext, SerializedNode } from '@vectoriox/iox-ui/generation-core';
|
|
1
|
+
import { AiStep, JsonSchema, PlanWordContext, AdjustAxis, AdjustKind, SerializedNode } 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
|
|
@@ -535,6 +535,9 @@ declare function applyFieldEdits(values: ContentRecord, edits: ReadonlyArray<Fie
|
|
|
535
535
|
* copy) and in the builder (the trial): `pageLooks` (the targets and their handles), `styleJsonSchema`,
|
|
536
536
|
* `decodeStyleAnswers`, `applyStyleEdits` — design-core's `switchElementStyle` (the author's own changes are kept) and
|
|
537
537
|
* `setColorScheme` (the ONE scheme writer), all or none.
|
|
538
|
+
*
|
|
539
|
+
* AI2c adds SIZE STEPS to the same family: a section's height and spacing, a card's or panel's padding, where words sit
|
|
540
|
+
* — each a row of generation-core `ADJUSTMENTS` (the only place their values come from), never a number the model wrote.
|
|
538
541
|
*/
|
|
539
542
|
/**
|
|
540
543
|
* The styles an owner may swap between by asking — each set is ONE kind of thing (a button, a heading, words, a box, a
|
|
@@ -543,6 +546,11 @@ declare function applyFieldEdits(values: ContentRecord, edits: ReadonlyArray<Fie
|
|
|
543
546
|
* to the styles its type may wear (design-core `elementStylesFor`).
|
|
544
547
|
*/
|
|
545
548
|
declare const ASK_STYLE_SETS: ReadonlyArray<ReadonlyArray<string>>;
|
|
549
|
+
/**
|
|
550
|
+
* The size axes a node may be stepped on, and which kind each acts as (AI2c): a section root its height and rhythm, a
|
|
551
|
+
* card or panel its padding, a heading or text its alignment. A node that is none of these takes no step.
|
|
552
|
+
*/
|
|
553
|
+
declare function adjustAxesOf(node: SerializedNode, isRoot: boolean, carriesWords: boolean): Partial<Record<AdjustAxis, AdjustKind>>;
|
|
546
554
|
/** The styles a node may take by asking — its own among them — or [] when it is not a target. */
|
|
547
555
|
declare function askableStyles(node: Pick<SerializedNode, 'type' | 'elementStyle'>): string[];
|
|
548
556
|
/** A target of family `style` — what the brief says, and what the check needs (the node id is never sent). */
|
|
@@ -555,9 +563,13 @@ interface PageLook {
|
|
|
555
563
|
readonly styles?: ReadonlyArray<string>;
|
|
556
564
|
/** Its colour scheme, when it takes one. */
|
|
557
565
|
readonly scheme?: string;
|
|
566
|
+
/** The size axes it may be stepped on, each with the step it holds now (`own` = a value of its own). */
|
|
567
|
+
readonly sizes?: Readonly<Partial<Record<AdjustAxis, string>>>;
|
|
558
568
|
}
|
|
559
569
|
interface WalkedLook {
|
|
560
570
|
readonly look: PageLook;
|
|
571
|
+
/** Which kind each of its size axes acts as — what the check writes with (never sent). */
|
|
572
|
+
readonly axes: Readonly<Partial<Record<AdjustAxis, AdjustKind>>>;
|
|
561
573
|
readonly section: number;
|
|
562
574
|
readonly nodeId: string;
|
|
563
575
|
readonly type: string;
|
|
@@ -583,11 +595,14 @@ interface LookTarget {
|
|
|
583
595
|
readonly label: string;
|
|
584
596
|
readonly styles: ReadonlyArray<string>;
|
|
585
597
|
readonly scheme: boolean;
|
|
598
|
+
/** The size axes it may be stepped on, and the kind each acts as. */
|
|
599
|
+
readonly sizes?: Readonly<Partial<Record<AdjustAxis, AdjustKind>>>;
|
|
586
600
|
}
|
|
587
601
|
type LookMap = Readonly<Record<string, LookTarget>>;
|
|
588
602
|
declare enum StyleAnswerKey {
|
|
589
603
|
Styles = "styles",
|
|
590
604
|
Schemes = "schemes",
|
|
605
|
+
Sizes = "sizes",
|
|
591
606
|
Note = "note"
|
|
592
607
|
}
|
|
593
608
|
interface StyleSchemas {
|
|
@@ -611,22 +626,34 @@ interface SchemeEdit {
|
|
|
611
626
|
readonly handle: string;
|
|
612
627
|
readonly scheme: string;
|
|
613
628
|
}
|
|
629
|
+
/** An element stepped on a size axis — a row of generation-core `ADJUSTMENTS`. */
|
|
630
|
+
interface SizeEdit {
|
|
631
|
+
readonly handle: string;
|
|
632
|
+
readonly axis: string;
|
|
633
|
+
readonly step: string;
|
|
634
|
+
}
|
|
635
|
+
/** Any edit of family `style`. */
|
|
636
|
+
type LookEdit = StyleEdit | SchemeEdit | SizeEdit;
|
|
614
637
|
/** The answer → the edits it makes. */
|
|
615
|
-
declare function decodeStyleAnswers(answers: ReadonlyArray<unknown>):
|
|
638
|
+
declare function decodeStyleAnswers(answers: ReadonlyArray<unknown>): LookEdit[];
|
|
616
639
|
declare const isStyleEdit: (e: object) => e is StyleEdit;
|
|
617
640
|
declare const isSchemeEdit: (e: object) => e is SchemeEdit;
|
|
641
|
+
declare const isSizeEdit: (e: object) => e is SizeEdit;
|
|
618
642
|
/** Which kind of change a change card shows. */
|
|
619
643
|
declare enum PageChangeOp {
|
|
620
644
|
Words = "words",
|
|
621
645
|
Style = "style",
|
|
622
|
-
Scheme = "scheme"
|
|
646
|
+
Scheme = "scheme",
|
|
647
|
+
Size = "size"
|
|
623
648
|
}
|
|
624
649
|
interface StyleChange {
|
|
625
|
-
readonly op: PageChangeOp.Style | PageChangeOp.Scheme;
|
|
650
|
+
readonly op: PageChangeOp.Style | PageChangeOp.Scheme | PageChangeOp.Size;
|
|
651
|
+
/** A size step's axis. */
|
|
652
|
+
readonly axis?: AdjustAxis;
|
|
626
653
|
readonly handle: string;
|
|
627
654
|
readonly nodeId: string;
|
|
628
655
|
readonly label: string;
|
|
629
|
-
/** The style / scheme ids, and how the owner reads them. */
|
|
656
|
+
/** The style / scheme / step ids, and how the owner reads them. */
|
|
630
657
|
readonly from: string;
|
|
631
658
|
readonly to: string;
|
|
632
659
|
readonly before: string;
|
|
@@ -654,7 +681,7 @@ interface StyleEditsOutcome {
|
|
|
654
681
|
* handle not in the focus, a style the target may not take, a scheme on a target that takes none are refused (re-asked
|
|
655
682
|
* once by the server, never repaired here); an edit that changes nothing is dropped.
|
|
656
683
|
*/
|
|
657
|
-
declare function applyStyleEdits(layout: ReadonlyArray<SerializedNode>, edits: ReadonlyArray<
|
|
684
|
+
declare function applyStyleEdits(layout: ReadonlyArray<SerializedNode>, edits: ReadonlyArray<LookEdit>, ctx: StyleEditContext): StyleEditsOutcome;
|
|
658
685
|
|
|
659
686
|
/**
|
|
660
687
|
* Surface S1 (the builder, this page), family `words` (ai-assist-plan §4, ai-session-panel-plan §3b–§3d): the page as
|
|
@@ -709,7 +736,7 @@ interface PageSectionSummary {
|
|
|
709
736
|
/** The section's own name ("Hero", "Our work") or "Section 3". */
|
|
710
737
|
readonly label: string;
|
|
711
738
|
readonly parts: ReadonlyArray<PagePart>;
|
|
712
|
-
/** Family `style`: the elements of the section that may take another element style or
|
|
739
|
+
/** Family `style`: the elements of the section that may take another element style, colour scheme or size step. */
|
|
713
740
|
readonly looks?: ReadonlyArray<PageLook>;
|
|
714
741
|
}
|
|
715
742
|
interface PageFocus {
|
|
@@ -850,11 +877,12 @@ declare function pageWriteLocale(layout: ReadonlyArray<SerializedNode>, ctx: {
|
|
|
850
877
|
}): string;
|
|
851
878
|
|
|
852
879
|
/**
|
|
853
|
-
* Surface S1's answer as ONE thing (AI2b): the edits of every family a page turn routed to — words (`{ handle, value }`),
|
|
854
|
-
* styles (`{ handle, style }`), schemes (`{ handle, scheme }`)
|
|
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
|
|
855
883
|
* checks each family as it is asked; the builder's trial applies the turn's edits through this, so both read one rule.
|
|
856
884
|
*/
|
|
857
|
-
type PageEdit = WordEdit | StyleEdit | SchemeEdit;
|
|
885
|
+
type PageEdit = WordEdit | StyleEdit | SchemeEdit | SizeEdit;
|
|
858
886
|
type PageChange = WordChange | StyleChange;
|
|
859
887
|
interface PageEditContext extends Omit<WordEditContext, 'handles' | 'never'> {
|
|
860
888
|
readonly summary: Pick<SummarizedPage, 'handles' | 'looks'> & {
|
|
@@ -924,7 +952,7 @@ interface AssistTurnRequest {
|
|
|
924
952
|
};
|
|
925
953
|
}
|
|
926
954
|
/** 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`). */
|
|
927
|
-
type AssistEdit = FieldEdit | WordEdit | StyleEdit | SchemeEdit;
|
|
955
|
+
type AssistEdit = FieldEdit | WordEdit | StyleEdit | SchemeEdit | SizeEdit;
|
|
928
956
|
/** What a turn changed, as the card says it. */
|
|
929
957
|
type AssistChange = FieldChange | WordChange | StyleChange;
|
|
930
958
|
/** POST's 202 answer. */
|
|
@@ -1037,5 +1065,5 @@ declare function turnLocale(sentence: string, fields: ReadonlyArray<AssistField>
|
|
|
1037
1065
|
/** The language's own name in the admin's language (`en` → "English" / "אנגלית"). */
|
|
1038
1066
|
declare const languageName: (locale: string, uiLang: string) => string;
|
|
1039
1067
|
|
|
1040
|
-
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, 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, 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 };
|
|
1041
|
-
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, LookMap, LookTarget, NeverWrite, PageAround, PageBrief, PageBriefContext, PageChange, PageEdit, PageEditContext, PageEditsOutcome, PageFocus, PageLook, PagePart, PageSectionSummary, PageSuggestion, SchemeEdit, StyleChange, StyleEdit, StyleEditContext, StyleEditsOutcome, StyleSchemas, SummarizedItem, SummarizedPage, SurfaceSpec, WalkedLook, WordChange, WordEdit, WordEditContext, WordEditsOutcome, WordsSchemas, WrittenWords };
|
|
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 };
|
package/commerce-core/index.d.ts
CHANGED
|
@@ -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)
|
|
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
|
-
/**
|
|
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 };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AiStep, STRICT_SCHEMA_BUDGET, strictSchemaComplexity, jsonText, jsonListOf, jsonOneOf, jsonClosedObject, jsonAnyOf, PlanWordIssueCode, factIssues, NODE_BASELINES,
|
|
1
|
+
import { AiStep, STRICT_SCHEMA_BUDGET, strictSchemaComplexity, jsonText, jsonListOf, jsonOneOf, jsonClosedObject, jsonAnyOf, PlanWordIssueCode, factIssues, walkSerialized, AdjustKind, AdjustAxis, adjustStepOf, ADJUST_STEPS, NODE_BASELINES, adjustStyleProps, ADJUST_AXIS_LABELS, adjustStepLabel } from '@vectoriox/iox-ui/generation-core';
|
|
2
2
|
import { elementStylesFor, colorSchemeOf, ColorScheme, COLOR_SCHEME_TYPES, elementStyleById, COLOR_SCHEMES, NEW_NODE_STYLE_DEFAULTS, setColorScheme, switchElementStyle } from '@vectoriox/iox-ui/design-core';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -1021,6 +1021,9 @@ const languageName = (locale, uiLang) => displayName(locale, uiLang) ?? locale;
|
|
|
1021
1021
|
* copy) and in the builder (the trial): `pageLooks` (the targets and their handles), `styleJsonSchema`,
|
|
1022
1022
|
* `decodeStyleAnswers`, `applyStyleEdits` — design-core's `switchElementStyle` (the author's own changes are kept) and
|
|
1023
1023
|
* `setColorScheme` (the ONE scheme writer), all or none.
|
|
1024
|
+
*
|
|
1025
|
+
* AI2c adds SIZE STEPS to the same family: a section's height and spacing, a card's or panel's padding, where words sit
|
|
1026
|
+
* — each a row of generation-core `ADJUSTMENTS` (the only place their values come from), never a number the model wrote.
|
|
1024
1027
|
*/
|
|
1025
1028
|
/**
|
|
1026
1029
|
* The styles an owner may swap between by asking — each set is ONE kind of thing (a button, a heading, words, a box, a
|
|
@@ -1042,6 +1045,35 @@ const SURFACE_STYLES = new Set(['section', 'card', 'panel']);
|
|
|
1042
1045
|
const paintsGround = (style) => SURFACE_STYLES.has(style ?? '');
|
|
1043
1046
|
/** A Text wearing this is a ButtonBlock's words: the button is the style target. */
|
|
1044
1047
|
const BUTTON_LABEL_STYLE$1 = 'button-label';
|
|
1048
|
+
/** The words types whose line alignment may be asked for (a button's or a link's words sit as their button does). */
|
|
1049
|
+
const ALIGNABLE_TYPES = new Set(['Heading', 'Text']);
|
|
1050
|
+
/** Boxes whose padding is a framed box's (`--iox-space-pad`). */
|
|
1051
|
+
const PADDED_STYLES = new Set(['card', 'panel']);
|
|
1052
|
+
/** A Scene, or a section holding a pinned (sticky) part, owns its height — it plays over the scroll it is given. */
|
|
1053
|
+
function ownsItsHeight(root) {
|
|
1054
|
+
let owns = false;
|
|
1055
|
+
walkSerialized([root], n => { if (n.role === 'scene' || n.styleProps?.['position'] === 'sticky')
|
|
1056
|
+
owns = true; });
|
|
1057
|
+
return owns;
|
|
1058
|
+
}
|
|
1059
|
+
/**
|
|
1060
|
+
* The size axes a node may be stepped on, and which kind each acts as (AI2c): a section root its height and rhythm, a
|
|
1061
|
+
* card or panel its padding, a heading or text its alignment. A node that is none of these takes no step.
|
|
1062
|
+
*/
|
|
1063
|
+
function adjustAxesOf(node, isRoot, carriesWords) {
|
|
1064
|
+
const axes = {};
|
|
1065
|
+
if (isRoot) {
|
|
1066
|
+
if (!ownsItsHeight(node))
|
|
1067
|
+
axes[AdjustAxis.Height] = AdjustKind.Section;
|
|
1068
|
+
axes[AdjustAxis.Spacing] = AdjustKind.Section;
|
|
1069
|
+
}
|
|
1070
|
+
else if (PADDED_STYLES.has(node.elementStyle ?? '')) {
|
|
1071
|
+
axes[AdjustAxis.Spacing] = AdjustKind.Box;
|
|
1072
|
+
}
|
|
1073
|
+
if (carriesWords && ALIGNABLE_TYPES.has(node.type) && node.elementStyle !== BUTTON_LABEL_STYLE$1)
|
|
1074
|
+
axes[AdjustAxis.Align] = AdjustKind.Words;
|
|
1075
|
+
return axes;
|
|
1076
|
+
}
|
|
1045
1077
|
/** The styles a node may take by asking — its own among them — or [] when it is not a target. */
|
|
1046
1078
|
function askableStyles(node) {
|
|
1047
1079
|
const current = node.elementStyle;
|
|
@@ -1073,7 +1105,9 @@ function pageLooks(layout, wordHandles, selectedId) {
|
|
|
1073
1105
|
// TAKE such a style is offered one too; the check refuses the scheme unless the turn gives it that style.
|
|
1074
1106
|
const takesScheme = COLOR_SCHEME_TYPES.includes(node.type) && !isRecipePart(node)
|
|
1075
1107
|
&& (paintsGround(node.elementStyle) || scheme !== ColorScheme.Default || (takesStyle && styles.some(paintsGround)));
|
|
1076
|
-
|
|
1108
|
+
const axes = adjustAxesOf(node, isRoot, wordHandles.has(node.id));
|
|
1109
|
+
const sized = Object.entries(axes);
|
|
1110
|
+
if (takesStyle || takesScheme || sized.length) {
|
|
1077
1111
|
const handle = lookHandle(node, index, isRoot, wordHandles, () => ++boxes);
|
|
1078
1112
|
if (handle) {
|
|
1079
1113
|
out.push({
|
|
@@ -1082,8 +1116,9 @@ function pageLooks(layout, wordHandles, selectedId) {
|
|
|
1082
1116
|
label: lookLabel(handle, root, index),
|
|
1083
1117
|
...(takesStyle ? { style: node.elementStyle, styles } : {}),
|
|
1084
1118
|
...(takesScheme ? { scheme } : {}),
|
|
1119
|
+
...(sized.length ? { sizes: Object.fromEntries(sized.map(([axis, kind]) => [axis, adjustStepOf(axis, kind, node.styleProps)])) } : {}),
|
|
1085
1120
|
},
|
|
1086
|
-
section: index, nodeId: node.id, type: node.type, lineage: here,
|
|
1121
|
+
axes, section: index, nodeId: node.id, type: node.type, lineage: here,
|
|
1087
1122
|
});
|
|
1088
1123
|
}
|
|
1089
1124
|
}
|
|
@@ -1132,6 +1167,7 @@ var StyleAnswerKey;
|
|
|
1132
1167
|
(function (StyleAnswerKey) {
|
|
1133
1168
|
StyleAnswerKey["Styles"] = "styles";
|
|
1134
1169
|
StyleAnswerKey["Schemes"] = "schemes";
|
|
1170
|
+
StyleAnswerKey["Sizes"] = "sizes";
|
|
1135
1171
|
StyleAnswerKey["Note"] = "note";
|
|
1136
1172
|
})(StyleAnswerKey || (StyleAnswerKey = {}));
|
|
1137
1173
|
/**
|
|
@@ -1143,7 +1179,8 @@ var StyleAnswerKey;
|
|
|
1143
1179
|
function styleJsonSchema(looks) {
|
|
1144
1180
|
const styled = Object.entries(looks).filter(([, t]) => t.styles.length);
|
|
1145
1181
|
const schemed = Object.entries(looks).filter(([, t]) => t.scheme);
|
|
1146
|
-
|
|
1182
|
+
const sized = Object.entries(looks).filter(([, t]) => Object.keys(t.sizes ?? {}).length);
|
|
1183
|
+
if (!styled.length && !schemed.length && !sized.length)
|
|
1147
1184
|
return { parts: [], handles: [] };
|
|
1148
1185
|
const properties = {};
|
|
1149
1186
|
if (styled.length) {
|
|
@@ -1165,10 +1202,21 @@ function styleJsonSchema(looks) {
|
|
|
1165
1202
|
description: 'A section or box taking another colour scheme; [] changes no colours.',
|
|
1166
1203
|
};
|
|
1167
1204
|
}
|
|
1205
|
+
if (sized.length) {
|
|
1206
|
+
const axes = [...new Set(sized.flatMap(([, t]) => Object.keys(t.sizes ?? {})))];
|
|
1207
|
+
properties[StyleAnswerKey.Sizes] = {
|
|
1208
|
+
...jsonListOf(jsonClosedObject({
|
|
1209
|
+
handle: jsonOneOf(sized.map(([h]) => h)),
|
|
1210
|
+
axis: jsonOneOf(axes),
|
|
1211
|
+
step: jsonOneOf([...new Set(axes.flatMap(a => ADJUST_STEPS[a].map(s => s.id)))]),
|
|
1212
|
+
}, ['handle', 'axis', 'step'])),
|
|
1213
|
+
description: 'An element stepped on one of the size axes the focus lists for it; [] changes no size.',
|
|
1214
|
+
};
|
|
1215
|
+
}
|
|
1168
1216
|
properties[StyleAnswerKey.Note] = { ...jsonText(), description: 'One short line for the owner on what changed, or what needs them.' };
|
|
1169
1217
|
const part = jsonClosedObject(properties, Object.keys(properties));
|
|
1170
1218
|
assertAssistBudget('style', [part]);
|
|
1171
|
-
return { parts: [part], handles: [[...new Set([...styled, ...schemed].map(([h]) => h))]] };
|
|
1219
|
+
return { parts: [part], handles: [[...new Set([...styled, ...schemed, ...sized].map(([h]) => h))]] };
|
|
1172
1220
|
}
|
|
1173
1221
|
const listOf = (answer, key) => {
|
|
1174
1222
|
const list = answer && typeof answer === 'object' ? answer[key] : undefined;
|
|
@@ -1179,16 +1227,19 @@ function decodeStyleAnswers(answers) {
|
|
|
1179
1227
|
return answers.flatMap(answer => [
|
|
1180
1228
|
...listOf(answer, StyleAnswerKey.Styles).map(x => ({ handle: String(x['handle'] ?? ''), style: String(x['style'] ?? '') })),
|
|
1181
1229
|
...listOf(answer, StyleAnswerKey.Schemes).map(x => ({ handle: String(x['handle'] ?? ''), scheme: String(x['scheme'] ?? '') })),
|
|
1230
|
+
...listOf(answer, StyleAnswerKey.Sizes).map(x => ({ handle: String(x['handle'] ?? ''), axis: String(x['axis'] ?? ''), step: String(x['step'] ?? '') })),
|
|
1182
1231
|
]);
|
|
1183
1232
|
}
|
|
1184
1233
|
const isStyleEdit = (e) => typeof e.style === 'string';
|
|
1185
1234
|
const isSchemeEdit = (e) => typeof e.scheme === 'string';
|
|
1235
|
+
const isSizeEdit = (e) => typeof e.axis === 'string' && typeof e.step === 'string';
|
|
1186
1236
|
/** Which kind of change a change card shows. */
|
|
1187
1237
|
var PageChangeOp;
|
|
1188
1238
|
(function (PageChangeOp) {
|
|
1189
1239
|
PageChangeOp["Words"] = "words";
|
|
1190
1240
|
PageChangeOp["Style"] = "style";
|
|
1191
1241
|
PageChangeOp["Scheme"] = "scheme";
|
|
1242
|
+
PageChangeOp["Size"] = "size";
|
|
1192
1243
|
})(PageChangeOp || (PageChangeOp = {}));
|
|
1193
1244
|
/** The serialized baseline: the type's constructor values, its text colour released as a new node's is (generation-core `createSerializedNode`). */
|
|
1194
1245
|
const serializedBaselineStyles = type => {
|
|
@@ -1213,14 +1264,18 @@ function applyStyleEdits(layout, edits, ctx) {
|
|
|
1213
1264
|
const issues = [];
|
|
1214
1265
|
const changes = [];
|
|
1215
1266
|
const seen = new Set();
|
|
1216
|
-
// Styles first: a scheme may need the style the same turn gives its node (a plain box made a panel, then darkened)
|
|
1217
|
-
|
|
1267
|
+
// Styles first: a scheme may need the style the same turn gives its node (a plain box made a panel, then darkened);
|
|
1268
|
+
// size steps last, over what the style switch released.
|
|
1269
|
+
const ordered = [
|
|
1270
|
+
...edits.filter(e => !isSchemeEdit(e) && !isSizeEdit(e)), ...edits.filter(isSchemeEdit), ...edits.filter(isSizeEdit),
|
|
1271
|
+
];
|
|
1218
1272
|
for (const edit of ordered) {
|
|
1219
1273
|
const scheme = isSchemeEdit(edit);
|
|
1220
|
-
const
|
|
1274
|
+
const size = isSizeEdit(edit);
|
|
1275
|
+
const key = size ? `size:${edit.handle}:${edit.axis}` : `${scheme ? 'scheme' : 'style'}:${edit.handle}`;
|
|
1221
1276
|
const refuse = (code, message) => issues.push({ code, handle: edit.handle, message });
|
|
1222
1277
|
if (seen.has(key)) {
|
|
1223
|
-
refuse(AssistIssueCode.Duplicate, `"${edit.handle}" is given two ${scheme ? 'schemes' : 'styles'}`);
|
|
1278
|
+
refuse(AssistIssueCode.Duplicate, `"${edit.handle}" is given two ${size ? `${edit.axis} steps` : scheme ? 'schemes' : 'styles'}`);
|
|
1224
1279
|
continue;
|
|
1225
1280
|
}
|
|
1226
1281
|
seen.add(key);
|
|
@@ -1230,6 +1285,29 @@ function applyStyleEdits(layout, edits, ctx) {
|
|
|
1230
1285
|
refuse(AssistIssueCode.UnknownHandle, `"${edit.handle}" is not an element of the focus`);
|
|
1231
1286
|
continue;
|
|
1232
1287
|
}
|
|
1288
|
+
if (size) {
|
|
1289
|
+
const axis = edit.axis;
|
|
1290
|
+
const kind = Object.prototype.hasOwnProperty.call(target.sizes ?? {}, axis) ? target.sizes[axis] : undefined;
|
|
1291
|
+
if (!kind) {
|
|
1292
|
+
const takes = Object.keys(target.sizes ?? {});
|
|
1293
|
+
refuse(AssistIssueCode.NotAnOption, `${target.label} takes no ${edit.axis} step${takes.length ? ` — only ${takes.join(', ')}` : ''}`);
|
|
1294
|
+
continue;
|
|
1295
|
+
}
|
|
1296
|
+
const props = adjustStyleProps(axis, kind, edit.step, node.styleProps);
|
|
1297
|
+
if (!props) {
|
|
1298
|
+
refuse(AssistIssueCode.NotAnOption, `${ADJUST_AXIS_LABELS[axis].toLowerCase()} takes ${ADJUST_STEPS[axis].map(s => `"${s.id}"`).join(', ')} — not "${edit.step}"`);
|
|
1299
|
+
continue;
|
|
1300
|
+
}
|
|
1301
|
+
const from = adjustStepOf(axis, kind, node.styleProps);
|
|
1302
|
+
if (from === edit.step)
|
|
1303
|
+
continue;
|
|
1304
|
+
node.styleProps = { ...(node.styleProps ?? {}), ...props };
|
|
1305
|
+
changes.push({
|
|
1306
|
+
op: PageChangeOp.Size, axis, handle: edit.handle, nodeId: node.id, label: `${target.label} · ${ADJUST_AXIS_LABELS[axis].toLowerCase()}`,
|
|
1307
|
+
from, to: edit.step, before: adjustStepLabel(axis, from), after: adjustStepLabel(axis, edit.step),
|
|
1308
|
+
});
|
|
1309
|
+
continue;
|
|
1310
|
+
}
|
|
1233
1311
|
if (scheme) {
|
|
1234
1312
|
const to = edit.scheme;
|
|
1235
1313
|
if (!target.scheme) {
|
|
@@ -1424,6 +1502,7 @@ function summarizePage(layout, ctx) {
|
|
|
1424
1502
|
const focusLooks = walkedLooks.filter(lookInFocus);
|
|
1425
1503
|
const looks = Object.fromEntries(focusLooks.map(l => [l.look.handle, {
|
|
1426
1504
|
id: l.nodeId, type: l.type, label: l.look.label, styles: [...(l.look.styles ?? [])], scheme: l.look.scheme !== undefined,
|
|
1505
|
+
...(Object.keys(l.axes).length ? { sizes: { ...l.axes } } : {}),
|
|
1427
1506
|
}]));
|
|
1428
1507
|
for (const l of walkedLooks)
|
|
1429
1508
|
nodes[l.look.handle] ??= l.nodeId;
|
|
@@ -1664,7 +1743,7 @@ function applyPageEdits(layout, edits, ctx) {
|
|
|
1664
1743
|
const words = applyWordEdits(layout, edits.filter(isWordEdit), {
|
|
1665
1744
|
handles: ctx.summary.handles, never: ctx.summary.brief.rules.never, sentence: ctx.sentence, words: ctx.words,
|
|
1666
1745
|
});
|
|
1667
|
-
const looks = edits.filter((e) => !isWordEdit(e) && (isStyleEdit(e) || isSchemeEdit(e)));
|
|
1746
|
+
const looks = edits.filter((e) => !isWordEdit(e) && (isStyleEdit(e) || isSchemeEdit(e) || isSizeEdit(e)));
|
|
1668
1747
|
const style = applyStyleEdits(words.result, looks, { looks: ctx.summary.looks, baseline: ctx.baseline });
|
|
1669
1748
|
const issues = [...words.issues, ...style.issues];
|
|
1670
1749
|
if (issues.length)
|
|
@@ -1692,7 +1771,7 @@ const isTerminalTurn = (status) => TERMINAL.has(status);
|
|
|
1692
1771
|
const ASSIST_MODEL_AUTO = 'auto';
|
|
1693
1772
|
const ASSIST_POLL_MS = 750;
|
|
1694
1773
|
const MAX_SENTENCE_CHARS = 2000;
|
|
1695
|
-
const isLookChange = (c) => 'op' in c && (c.op === PageChangeOp.Style || c.op === PageChangeOp.Scheme);
|
|
1774
|
+
const isLookChange = (c) => 'op' in c && (c.op === PageChangeOp.Style || c.op === PageChangeOp.Scheme || c.op === PageChangeOp.Size);
|
|
1696
1775
|
/** A turn's own refusals and failures, beside generation-core's `AiRefusalCode`s (credits, plan, key), which a turn returns as they are. */
|
|
1697
1776
|
var AssistRefusalCode;
|
|
1698
1777
|
(function (AssistRefusalCode) {
|
|
@@ -1840,5 +1919,5 @@ function validateTurnRequest(req) {
|
|
|
1840
1919
|
* Generated bundle index. Do not edit.
|
|
1841
1920
|
*/
|
|
1842
1921
|
|
|
1843
|
-
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, 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, 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 };
|
|
1922
|
+
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 };
|
|
1844
1923
|
//# sourceMappingURL=vectoriox-iox-ui-assist-core.mjs.map
|