@vectoriox/iox-ui 5.132.0 → 5.134.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/commerce-core/index.d.ts +12 -1
- package/composite-core/index.d.ts +44 -22
- package/design-core/index.d.ts +436 -35
- package/domain-core/index.d.ts +353 -0
- package/domain-core/package.json +3 -0
- package/fesm2022/vectoriox-iox-ui-actions-core.mjs +2 -0
- package/fesm2022/vectoriox-iox-ui-actions-core.mjs.map +1 -1
- package/fesm2022/vectoriox-iox-ui-assist-core.mjs +6 -48
- package/fesm2022/vectoriox-iox-ui-assist-core.mjs.map +1 -1
- package/fesm2022/vectoriox-iox-ui-commerce-core.mjs +21 -0
- package/fesm2022/vectoriox-iox-ui-commerce-core.mjs.map +1 -1
- package/fesm2022/vectoriox-iox-ui-composite-core.mjs +118 -62
- package/fesm2022/vectoriox-iox-ui-composite-core.mjs.map +1 -1
- package/fesm2022/vectoriox-iox-ui-design-core.mjs +895 -416
- package/fesm2022/vectoriox-iox-ui-design-core.mjs.map +1 -1
- package/fesm2022/vectoriox-iox-ui-domain-core.mjs +422 -0
- package/fesm2022/vectoriox-iox-ui-domain-core.mjs.map +1 -0
- package/fesm2022/vectoriox-iox-ui-generation-core.mjs +13974 -12036
- package/fesm2022/vectoriox-iox-ui-generation-core.mjs.map +1 -1
- package/fesm2022/vectoriox-iox-ui-harness-core.mjs +9 -3
- package/fesm2022/vectoriox-iox-ui-harness-core.mjs.map +1 -1
- package/fesm2022/vectoriox-iox-ui-mail-core.mjs +288 -2
- package/fesm2022/vectoriox-iox-ui-mail-core.mjs.map +1 -1
- package/fesm2022/vectoriox-iox-ui.mjs +290 -16
- package/fesm2022/vectoriox-iox-ui.mjs.map +1 -1
- package/generation-core/index.d.ts +1419 -379
- package/harness-core/index.d.ts +6 -1
- package/index.d.ts +139 -10
- package/mail-core/index.d.ts +315 -39
- package/package.json +5 -1
- package/src/actions-core/element-actions.ts +2 -0
- package/src/assist-core/page-sections.ts +7 -37
- package/src/commerce-core/shop-display.ts +21 -0
- package/src/composite-core/consent.ts +6 -2
- package/src/composite-core/shop-runtime.ts +47 -3
- package/src/composite-core/shop.ts +76 -57
- package/src/design-core/design-settings.ts +16 -0
- package/src/design-core/design-token.model.ts +7 -1
- package/src/design-core/flavor-spec.generated.ts +374 -35
- package/src/design-core/flavor-tokens.ts +12 -1
- package/src/design-core/header-behaviour.ts +32 -0
- package/src/design-core/motion-language.ts +115 -0
- package/src/design-core/public-api.ts +1 -0
- package/src/design-core/style-presets.ts +3 -0
- package/src/domain-core/domain-vocabulary.ts +125 -0
- package/src/domain-core/domain-wire.ts +95 -0
- package/src/domain-core/org-path-redirect.ts +105 -0
- package/src/domain-core/public-api.ts +12 -0
- package/src/domain-core/web-domain.ts +251 -0
- package/src/generation-core/carry-fill.ts +36 -0
- package/src/generation-core/carry.ts +398 -0
- package/src/generation-core/check-carry.ts +216 -0
- package/src/generation-core/check-layout.ts +71 -5
- package/src/generation-core/compose-layout.ts +187 -28
- package/src/generation-core/compose-site.ts +154 -31
- package/src/generation-core/entrances.ts +66 -10
- package/src/generation-core/header-edit.ts +299 -0
- package/src/generation-core/header-mix.ts +64 -5
- package/src/generation-core/layout-fingerprint.ts +5 -1
- package/src/generation-core/layout-language.ts +20 -1
- package/src/generation-core/layout-space.ts +4 -4
- package/src/generation-core/layout-wire.ts +36 -1
- package/src/generation-core/node-baselines.generated.ts +1 -0
- package/src/generation-core/public-api.ts +7 -0
- package/src/generation-core/redesign-additions.ts +273 -0
- package/src/generation-core/redesign-run.ts +364 -0
- package/src/generation-core/refit-page.ts +151 -0
- package/src/generation-core/section-stamp.ts +4 -4
- package/src/generation-core/shop-plan.ts +15 -0
- package/src/generation-core/site-build-run.ts +20 -3
- package/src/generation-core/site-spec.generated.ts +194 -94
- package/src/generation-core/site-tree.ts +19 -5
- package/src/generation-core/validate-site-plan.ts +37 -3
- package/src/harness-core/motion.ts +13 -3
- package/src/harness-core/starting-design.ts +1 -1
- package/src/mail-core/mail-domain.ts +305 -0
- package/src/mail-core/mail-standing.ts +58 -0
- package/src/mail-core/mail-vocabulary.ts +3 -0
- package/src/mail-core/mail-wire.ts +70 -1
- package/src/mail-core/public-api.ts +6 -1
- package/styles/iox-design.css +44 -2
|
@@ -30,6 +30,9 @@ export enum HeaderEdge {
|
|
|
30
30
|
export enum HeaderTrait {
|
|
31
31
|
Behaviour = 'headerBehaviour',
|
|
32
32
|
Edge = 'headerEdge',
|
|
33
|
+
/** HI1b (HS-5): the mix the header was composed as — its `<ingredient>:<word>` words, space-separated (generation-core
|
|
34
|
+
* `stampHeaderMix`). Read by Bindings ▸ Header and the Header studio; no renderer reads it. */
|
|
35
|
+
Mix = 'headerMix',
|
|
33
36
|
}
|
|
34
37
|
|
|
35
38
|
export enum HeaderAttribute {
|
|
@@ -74,3 +77,32 @@ export function headerAttributes(behaviour: unknown, edge: unknown): Record<stri
|
|
|
74
77
|
if (e) out[HeaderAttribute.Edge] = e;
|
|
75
78
|
return out;
|
|
76
79
|
}
|
|
80
|
+
|
|
81
|
+
// ── The header's name on a phone (vectoriox/iox-ui#98) ─────────────────────────────────────────────────────────────
|
|
82
|
+
|
|
83
|
+
/** The brand's role (generation-core `NavRole.Brand`, spelled here: design-core reads no generation-core). */
|
|
84
|
+
export const BRAND_ROLE = 'nav.brand';
|
|
85
|
+
|
|
86
|
+
/** Written on the brand when its name is long: the shared CSS steps its type down the look's scale on a phone. */
|
|
87
|
+
export const BRAND_NAME_ATTRIBUTE = 'data-iox-name';
|
|
88
|
+
|
|
89
|
+
/** How long a header's name is, for a phone bar that must hold it on one or two lines. */
|
|
90
|
+
export enum BrandNameLength {
|
|
91
|
+
/** Wears `size-lead` on a phone. */
|
|
92
|
+
Long = 'long',
|
|
93
|
+
/** Wears `size-body` on a phone. */
|
|
94
|
+
Longer = 'longer',
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/** From this many characters a name is `long`, then `longer`. Below it the name keeps its own size (a phone bar holds a
|
|
98
|
+
* 16-character name in two lines at the largest heading size the looks give a brand). */
|
|
99
|
+
export const BRAND_NAME_LONG_AT = 17;
|
|
100
|
+
export const BRAND_NAME_LONGER_AT = 29;
|
|
101
|
+
|
|
102
|
+
/** The name's attributes: `{}` for a name that keeps its size. Never shortens the words — the type steps down. */
|
|
103
|
+
export function brandNameAttributes(words: string): Record<string, string> {
|
|
104
|
+
const n = [...words.replace(/<[^>]+>/g, '').replace(/\s+/g, ' ').trim()].length;
|
|
105
|
+
if (n >= BRAND_NAME_LONGER_AT) return { [BRAND_NAME_ATTRIBUTE]: BrandNameLength.Longer };
|
|
106
|
+
if (n >= BRAND_NAME_LONG_AT) return { [BRAND_NAME_ATTRIBUTE]: BrandNameLength.Long };
|
|
107
|
+
return {};
|
|
108
|
+
}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { SPEC_MOTION_LANGUAGE, SPEC_STYLE_PRESETS } from './flavor-spec.generated';
|
|
2
|
+
import type { DesignChoices } from './design-token.model';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* THE LOOK'S MOTION LANGUAGE (award-ingredients-plan §5.2, AW3; Motion board MB-D1…MB-D10) — pure, framework-free.
|
|
6
|
+
*
|
|
7
|
+
* Each of the 24 style presets has a language of its own: the curve things ARRIVE on (Design ▸ Motion ▸ Feel), the
|
|
8
|
+
* curve they LEAVE on (it follows Feel — MB-D5), and the move its headings arrive by (Headings arrive). How animated
|
|
9
|
+
* stays the AMOUNT; this is the KIND. Read from the contract (`layout.mjs` MOTION → `SPEC_MOTION_LANGUAGE`) — never
|
|
10
|
+
* retyped. `buildFlavorTokens` writes `ease-enter` / `ease-exit` from it, so a re-theme changes every element's motion
|
|
11
|
+
* at once; generation-core stamps headings by `move`.
|
|
12
|
+
*
|
|
13
|
+
* A stored design from before AW3 holds neither word: it reads the contract's defaults for the curves (today's
|
|
14
|
+
* arrival, the fast ease-out leave of MB-D1) and NO move, so every level keeps its own heading entrance (MB-D8 — a
|
|
15
|
+
* built page keeps what it was stamped with until a look is applied).
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
const L = SPEC_MOTION_LANGUAGE;
|
|
19
|
+
|
|
20
|
+
export type ArriveId = (typeof SPEC_MOTION_LANGUAGE.arrive)[number];
|
|
21
|
+
export type LeaveId = (typeof SPEC_MOTION_LANGUAGE.leave)[number];
|
|
22
|
+
export type MoveId = (typeof SPEC_MOTION_LANGUAGE.move)[number];
|
|
23
|
+
|
|
24
|
+
export const ARRIVE_IDS: ReadonlyArray<ArriveId> = L.arrive;
|
|
25
|
+
export const LEAVE_IDS: ReadonlyArray<LeaveId> = L.leave;
|
|
26
|
+
export const MOVE_IDS: ReadonlyArray<MoveId> = L.move;
|
|
27
|
+
|
|
28
|
+
/** The plan tier a word is offered on (AW-D23): `all` every plan, `pro` Pro and Studio. */
|
|
29
|
+
export enum MotionWordTier {
|
|
30
|
+
All = 'all',
|
|
31
|
+
Pro = 'pro',
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** The arrive curve `spring` names: the look's own `ease-spring` token (a real spring at every speed — MB-D3). */
|
|
35
|
+
export const SPRING_CURVE_TOKEN = 'ease-spring';
|
|
36
|
+
const SPRING_REF = /^\{\{([a-z0-9-]+)\}\}$/;
|
|
37
|
+
|
|
38
|
+
/** A look's motion language, resolved. `move` null = the level's own heading entrance (a design stored before AW3). */
|
|
39
|
+
export interface MotionLanguage {
|
|
40
|
+
readonly arrive: ArriveId;
|
|
41
|
+
readonly leave: LeaveId;
|
|
42
|
+
readonly move: MoveId | null;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export const isArriveId = (v: unknown): v is ArriveId => typeof v === 'string' && (ARRIVE_IDS as ReadonlyArray<string>).includes(v);
|
|
46
|
+
export const isMoveId = (v: unknown): v is MoveId => typeof v === 'string' && (MOVE_IDS as ReadonlyArray<string>).includes(v);
|
|
47
|
+
|
|
48
|
+
const PRESET_LANGUAGE = L.presets as Readonly<Record<string, { arrive: ArriveId; leave: LeaveId; move: MoveId }>>;
|
|
49
|
+
const LEAVE_FOR = L.leaveFor as Readonly<Record<ArriveId, LeaveId>>;
|
|
50
|
+
/** The families a word's tier is asked of: the arrive / leave curves, the heading move, the cover between pages (AW4). */
|
|
51
|
+
export type MotionWordKind = 'arrive' | 'leave' | 'move' | 'cover';
|
|
52
|
+
const TIERS = L.tiers as Readonly<Record<MotionWordKind, Readonly<Record<string, `${MotionWordTier}`>>>>;
|
|
53
|
+
const PLAN_FALLBACK = L.planFallback as Readonly<{ arrive: ArriveId; move: MoveId; cover: string }>;
|
|
54
|
+
|
|
55
|
+
/** A style preset's own language (its Feel and Headings arrive) — undefined for an unknown id. */
|
|
56
|
+
export function presetMotionLanguage(presetId: string | null | undefined): { arrive: ArriveId; leave: LeaveId; move: MoveId } | undefined {
|
|
57
|
+
return presetId ? PRESET_LANGUAGE[presetId] : undefined;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** The tier of a word: `pro` words (expo-out, spring, pop, blur in, the covers…) are offered on Pro and Studio only (MB-D6). */
|
|
61
|
+
export function motionWordTier(kind: MotionWordKind, word: string): MotionWordTier {
|
|
62
|
+
return TIERS[kind]?.[word] === MotionWordTier.Pro ? MotionWordTier.Pro : MotionWordTier.All;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/** `pop` overshoots: only a Lively or Expressive look arrives on it (contract `popLevels`). */
|
|
66
|
+
export function popAllowed(animate: string | null | undefined): boolean {
|
|
67
|
+
return (L.popLevels as ReadonlyArray<string>).includes(String(animate ?? ''));
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* The language a set of choices wears. The leave follows Feel (MB-D5): the preset's own pair when Feel is still its
|
|
72
|
+
* arrival, else the contract's `leaveFor`. A `pop` Feel on a level that may not overshoot settles as expo-out.
|
|
73
|
+
*/
|
|
74
|
+
export function motionLanguageOf(choices: Pick<DesignChoices, 'feel' | 'headings' | 'animate'> & Partial<DesignChoices>, presetId?: string | null): MotionLanguage {
|
|
75
|
+
let arrive: ArriveId = isArriveId(choices.feel) ? choices.feel : (L.defaults.arrive as ArriveId);
|
|
76
|
+
if (arrive === 'pop' && choices.animate !== undefined && !popAllowed(choices.animate)) arrive = 'expo-out' as ArriveId;
|
|
77
|
+
const own = presetMotionLanguage(presetId ?? null);
|
|
78
|
+
const leave = own && own.arrive === arrive ? own.leave : (LEAVE_FOR[arrive] ?? (L.defaults.leave as LeaveId));
|
|
79
|
+
return { arrive, leave, move: isMoveId(choices.headings) ? choices.headings : null };
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/** The CSS timing function of an arrive / leave word; `spring` reads the look's own spring row. */
|
|
83
|
+
export function motionCurve(word: ArriveId | LeaveId, tokenValue: (name: string) => string | undefined = () => undefined): string {
|
|
84
|
+
const curve = (L.curves as Readonly<Record<string, string>>)[word] ?? '';
|
|
85
|
+
const ref = SPRING_REF.exec(curve);
|
|
86
|
+
return ref ? (tokenValue(ref[1]) ?? 'linear') : curve;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* What a lower plan wears of a language (AW-D23, MB-D6): a Pro word is drawn as the plan's own (the contract's
|
|
91
|
+
* `planFallback`) — Feel today's arrival, a Pro move a fade, a Pro cover (AW4) a fade between pages. Applied where a
|
|
92
|
+
* look is CHOSEN (a Look pick, a build); a built site keeps its words.
|
|
93
|
+
*/
|
|
94
|
+
export function motionLanguageForPlan<T extends Pick<DesignChoices, 'feel' | 'headings'> & { between?: DesignChoices['between'] }>(choices: T, pro: boolean): T {
|
|
95
|
+
if (pro) return choices;
|
|
96
|
+
const proWord = (kind: MotionWordKind, word: unknown) => typeof word === 'string' && motionWordTier(kind, word) === MotionWordTier.Pro;
|
|
97
|
+
const feel = isArriveId(choices.feel) && proWord('arrive', choices.feel) ? PLAN_FALLBACK.arrive : choices.feel;
|
|
98
|
+
const headings = isMoveId(choices.headings) && proWord('move', choices.headings) ? PLAN_FALLBACK.move : choices.headings;
|
|
99
|
+
const out = { ...choices, feel, headings };
|
|
100
|
+
if (proWord('cover', choices.between)) out.between = PLAN_FALLBACK.cover as DesignChoices['between'];
|
|
101
|
+
return out;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/** The reduced-motion floor (AW-D6): an entrance is a fade this long at most — gentler, never zero. */
|
|
105
|
+
export const REDUCED_ENTRANCE_MAX_MS: number = L.reduced.enterMaxMs;
|
|
106
|
+
|
|
107
|
+
/** MB-D7: a travelling move plays its quiet form on these levels (rise 8 px, mask lines together, clip from 85 %). */
|
|
108
|
+
export const QUIET_LEVELS: ReadonlyArray<string> = L.quietLevels;
|
|
109
|
+
export const QUIET_MOVE: Readonly<{ riseDistance: number; clipFrom: number; maskBy: string }> = L.quiet;
|
|
110
|
+
|
|
111
|
+
/** An exit takes about this share of its entrance's time (Emil: exits faster than entrances). */
|
|
112
|
+
export const LEAVE_SHARE: number = L.leaveShare;
|
|
113
|
+
|
|
114
|
+
/** Every preset id the contract gives a language to — all 24 (build-spec refuses one without). */
|
|
115
|
+
export const MOTION_LANGUAGE_PRESET_IDS: ReadonlyArray<string> = SPEC_STYLE_PRESETS.map(p => p.id).filter(id => id in PRESET_LANGUAGE);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { SPEC_MOODS, SPEC_STYLE_PRESETS } from './flavor-spec.generated';
|
|
2
2
|
import { resolveDesignChoices } from './design-settings';
|
|
3
|
+
import { presetMotionLanguage } from './motion-language';
|
|
3
4
|
import {
|
|
4
5
|
DensityId, DesignChoices, DesignMode, DesignMotion, MotionId, ShapeId, TintId,
|
|
5
6
|
} from './design-token.model';
|
|
@@ -70,6 +71,8 @@ export function presetChoices(id: string, mode?: DesignMode): DesignChoices | nu
|
|
|
70
71
|
return resolveDesignChoices({
|
|
71
72
|
flavorId: preset.flavorId, seed: preset.seed, pairId: preset.pairId, shape: preset.shape, density: preset.density,
|
|
72
73
|
motion: preset.motion, pillButtons: preset.pillButtons, mode: wear, tint: preset.tint, ...preset.moves,
|
|
74
|
+
// AW3: the look's own motion language — its Feel and how its headings arrive (MB-D5).
|
|
75
|
+
feel: presetMotionLanguage(preset.id)?.arrive, headings: presetMotionLanguage(preset.id)?.move,
|
|
73
76
|
});
|
|
74
77
|
}
|
|
75
78
|
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* domain-core vocabulary — a studio's own web address (custom-domains-plan, CD0). The states, refusals, record roles and
|
|
3
|
+
* the numbers every reader of a domain shares: the control plane writes what it found, iox-cms passes it on, the admin
|
|
4
|
+
* shows it, the engine serves by it. Framework-free; imports nothing.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Where a studio's own address stands — decided by ONE rule, `webDomainState` (R-CD1). "Checking" is not a state: it is
|
|
9
|
+
* the few seconds a Check request is open, said by the screen's busy button, never stored.
|
|
10
|
+
*/
|
|
11
|
+
export enum WebDomainState {
|
|
12
|
+
/** no domain */
|
|
13
|
+
NotSet = 'not-set',
|
|
14
|
+
/** entered; its records were never found (never checked, or the domain is not proven ours yet) */
|
|
15
|
+
Waiting = 'waiting',
|
|
16
|
+
/** DNS is right and proven; cert-manager is getting the certificate (1–10 minutes) */
|
|
17
|
+
Certificate = 'certificate',
|
|
18
|
+
/** the certificate is ready and the address serves the site */
|
|
19
|
+
Live = 'live',
|
|
20
|
+
/** a check found a record missing or wrong, or the certificate could not be issued (CAA, a proxy in front) */
|
|
21
|
+
Failed = 'failed',
|
|
22
|
+
/** was live; a recheck found DNS moved away or the certificate failed — the iox.studio address serves again at once */
|
|
23
|
+
Lost = 'lost',
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/** What cert-manager says about a domain's certificate. `Wildcard` is the default host's (`*.iox.studio`), never a custom one's. */
|
|
27
|
+
export enum WebCertState {
|
|
28
|
+
None = 'none',
|
|
29
|
+
Pending = 'pending',
|
|
30
|
+
Ready = 'ready',
|
|
31
|
+
Failed = 'failed',
|
|
32
|
+
Wildcard = 'wildcard',
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** The three records an owner adds at their DNS host (CD-D3). */
|
|
36
|
+
export enum WebDnsRecordRole {
|
|
37
|
+
/** CNAME `www` → `<studio>.iox.studio` */
|
|
38
|
+
Www = 'www',
|
|
39
|
+
/** A `@` → the ingress load balancer (an ALIAS / ANAME / flattened CNAME resolving there is accepted) */
|
|
40
|
+
Apex = 'apex',
|
|
41
|
+
/** TXT `_iox` = `iox-verify=<token>` — proves this studio owns the domain */
|
|
42
|
+
Ownership = 'ownership',
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** Which of a domain's two names serves the site; the other 301s to it (CD-D2). */
|
|
46
|
+
export enum WebDomainName {
|
|
47
|
+
Www = 'www',
|
|
48
|
+
Apex = 'apex',
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** What a check found wrong beyond a record's own ok/false — said on the card in the owner's words. */
|
|
52
|
+
export enum WebDomainProblem {
|
|
53
|
+
/** the `_iox` TXT is missing or holds another token */
|
|
54
|
+
TokenMissing = 'token-missing',
|
|
55
|
+
/** `www` does not resolve to the studio */
|
|
56
|
+
WwwNotHere = 'www-not-here',
|
|
57
|
+
/** `@` does not resolve to the load balancer */
|
|
58
|
+
ApexNotHere = 'apex-not-here',
|
|
59
|
+
/** `www` or `@` resolves to a proxy (Cloudflare's orange cloud) — HTTP-01 and the recheck cannot reach us (CD-D15) */
|
|
60
|
+
Proxied = 'proxied',
|
|
61
|
+
/** a CAA record does not allow letsencrypt.org — issuance would fail silently (trap 4) */
|
|
62
|
+
CaaRefuses = 'caa-refuses',
|
|
63
|
+
/** cert-manager could not issue or renew the certificate */
|
|
64
|
+
CertificateFailed = 'certificate-failed',
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/** Why a domain cannot be added — the wire's `code` and the screen's message key. */
|
|
68
|
+
export enum WebDomainRefusal {
|
|
69
|
+
/** not a host name at all */
|
|
70
|
+
NotADomain = 'not-a-domain',
|
|
71
|
+
/** an IP address — a site is reached by name */
|
|
72
|
+
IpAddress = 'ip-address',
|
|
73
|
+
/** under iox.studio — the studio already has that address */
|
|
74
|
+
PlatformDomain = 'platform-domain',
|
|
75
|
+
/** only a public suffix (`co.il`, `com`) — nobody owns it */
|
|
76
|
+
PublicSuffix = 'public-suffix',
|
|
77
|
+
/** a name below the domain other than `www` (`shop.mywebsite.co.il`) — the domain itself is entered; both names are connected */
|
|
78
|
+
Subdomain = 'subdomain',
|
|
79
|
+
/** another IOX studio has it VERIFIED (CD-D11) — 409 */
|
|
80
|
+
Taken = 'taken',
|
|
81
|
+
/** the plan's count of own domains is used (CD-D4) — 403 */
|
|
82
|
+
PlanFull = 'plan-full',
|
|
83
|
+
/** the studio's plan has no own domains, or the control plane is not reachable — 403 / 503 */
|
|
84
|
+
NotEnabled = 'not-enabled',
|
|
85
|
+
/** the control plane failed — 502 */
|
|
86
|
+
Upstream = 'upstream',
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/** How iox-cms found the site a request is for. */
|
|
90
|
+
export enum SiteResolvedBy {
|
|
91
|
+
/** the request's Host is one of the organization's own domains — base href `/`, no org segment */
|
|
92
|
+
Host = 'host',
|
|
93
|
+
/** the first path segment is the organization's label — base href `/<label>/` */
|
|
94
|
+
Segment = 'segment',
|
|
95
|
+
/** neither: the default organization serves a path with no org segment (answered only when the engine sent `host`) */
|
|
96
|
+
Default = 'default',
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/** The platform's own zones: a studio already has `<studio>.iox.studio` and can never claim a name under them. */
|
|
100
|
+
export const PLATFORM_WEB_DOMAINS: readonly string[] = ['iox.studio'];
|
|
101
|
+
|
|
102
|
+
/** The ownership record's name and value prefix (CD-D3). */
|
|
103
|
+
export const WEB_DOMAIN_TXT_HOST = '_iox';
|
|
104
|
+
export const WEB_DOMAIN_TOKEN_PREFIX = 'iox-verify=';
|
|
105
|
+
|
|
106
|
+
/** The Check button rests this long after a check (the ML4 rule). */
|
|
107
|
+
export const WEB_DOMAIN_CHECK_MIN_MS = 30_000;
|
|
108
|
+
/** A live (or lost) domain is rechecked once a day (CD-D10). */
|
|
109
|
+
export const WEB_DOMAIN_RECHECK_MS = 24 * 60 * 60 * 1000;
|
|
110
|
+
/** A lost domain stays attached this long, so putting the records back revives it with no new certificate (CD-D10). */
|
|
111
|
+
export const WEB_DOMAIN_LOST_KEEP_MS = 30 * 24 * 60 * 60 * 1000;
|
|
112
|
+
/** An entered-but-unverified claim blocks nobody and expires after this long (CD-D11). */
|
|
113
|
+
export const WEB_DOMAIN_CLAIM_MS = 7 * 24 * 60 * 60 * 1000;
|
|
114
|
+
/** A certificate expiring within this long counts as failing to renew (CD-D10). */
|
|
115
|
+
export const WEB_CERT_RENEW_MARGIN_MS = 14 * 24 * 60 * 60 * 1000;
|
|
116
|
+
/** Domains over a downgraded plan's count stay served this long (CD-D12). */
|
|
117
|
+
export const WEB_DOMAIN_GRACE_MS = 14 * 24 * 60 * 60 * 1000;
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* First path segments that are never redirected from the default host (CD-D6, R-CD5): the admin, the API, sign-in. On a
|
|
121
|
+
* custom host only `webadmin` moves — to the admin origin (CD-D7); the API and sign-in answer on every host the site has.
|
|
122
|
+
*/
|
|
123
|
+
export const NEVER_REDIRECTED_SEGMENTS: readonly string[] = ['webadmin', 'admin', 'api', 'auth'];
|
|
124
|
+
/** The admin SPA's first segment — on a custom host it 301s to the default host (CD-D7). */
|
|
125
|
+
export const ADMIN_SEGMENT = 'webadmin';
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The wire for a studio's own web address: the control plane's `/instances/me/domains` routes (iox-cms calls them with
|
|
3
|
+
* its instance token — R-CD3) and the answer iox-cms passes to the admin.
|
|
4
|
+
*/
|
|
5
|
+
import { SiteResolvedBy, WebCertState, WebDomainName, WebDomainProblem, WebDomainRefusal, WebDomainState } from './domain-vocabulary';
|
|
6
|
+
import { WebDnsRecord } from './web-domain';
|
|
7
|
+
|
|
8
|
+
/** `GET` the studio's domains · `PUT` add one (`WebDomainRequest`) · `DELETE …/:domain` stop using one. */
|
|
9
|
+
export const RELAY_WEB_DOMAINS_PATH = '/instances/me/domains';
|
|
10
|
+
|
|
11
|
+
/** `/instances/me/domains/:domain` */
|
|
12
|
+
export function webDomainPath(domain: string): string {
|
|
13
|
+
return `${RELAY_WEB_DOMAINS_PATH}/${encodeURIComponent(domain.toLowerCase())}`;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/** `POST /instances/me/domains/:domain/check` — resolve its records now on public resolvers. */
|
|
17
|
+
export function webDomainCheckPath(domain: string): string {
|
|
18
|
+
return `${webDomainPath(domain)}/check`;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** `PATCH /instances/me/domains/:domain/primary` — `{ serveAs?, primary? }`. */
|
|
22
|
+
export function webDomainPrimaryPath(domain: string): string {
|
|
23
|
+
return `${webDomainPath(domain)}/primary`;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/** `PUT /instances/me/domains` */
|
|
27
|
+
export interface WebDomainRequest {
|
|
28
|
+
/** what the owner typed — the server normalizes it (`webDomainOf`) and refuses by `webDomainRefusal` */
|
|
29
|
+
domain: string;
|
|
30
|
+
/** the organization it shows; omitted with one organization (CD-D5) */
|
|
31
|
+
orgId?: string | null;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** `PATCH …/primary` */
|
|
35
|
+
export interface WebDomainPrimaryRequest {
|
|
36
|
+
serveAs?: WebDomainName;
|
|
37
|
+
primary?: boolean;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** One domain as the wire carries it — the row plus its decided state, so no reader decides it again. */
|
|
41
|
+
export interface WebDomainEntry {
|
|
42
|
+
domain: string;
|
|
43
|
+
orgId: string | null;
|
|
44
|
+
serveAs: WebDomainName;
|
|
45
|
+
primary: boolean;
|
|
46
|
+
/** `primaryHost(entry)` — the name that serves */
|
|
47
|
+
host: string;
|
|
48
|
+
state: WebDomainState;
|
|
49
|
+
certState: WebCertState;
|
|
50
|
+
records: WebDnsRecord[];
|
|
51
|
+
problems: WebDomainProblem[];
|
|
52
|
+
checkedAt: string | null;
|
|
53
|
+
verifiedAt: string | null;
|
|
54
|
+
liveAt: string | null;
|
|
55
|
+
lostAt: string | null;
|
|
56
|
+
/** the day a domain over a downgraded plan stops (CD-D12), or a lost one detaches (CD-D10); null otherwise */
|
|
57
|
+
stopsAt: string | null;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** `GET /instances/me/domains` (and every write's answer). */
|
|
61
|
+
export interface WebDomainAnswer {
|
|
62
|
+
domains: WebDomainEntry[];
|
|
63
|
+
/** how many own domains the plan includes (CD-D4) */
|
|
64
|
+
limit: number;
|
|
65
|
+
/** the studio's `<studio>.iox.studio` — the CNAME's value and the admin origin */
|
|
66
|
+
studioHost: string;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** iox-cms's answer to the admin: the control plane's, plus whether THIS user may add, remove or pick the primary (CD-D13). */
|
|
70
|
+
export interface WebDomainView extends WebDomainAnswer {
|
|
71
|
+
mayChange: boolean;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/** A refused domain call: `{ code, message }` — 400 (`not-a-domain` · `ip-address` · `platform-domain` · `public-suffix` · `subdomain`), 409 (`taken`), 403 (`plan-full` · `not-enabled`), 503 (`not-enabled`), 502 (`upstream`). */
|
|
75
|
+
export interface WebDomainRefusalBody {
|
|
76
|
+
code: WebDomainRefusal;
|
|
77
|
+
message: string;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/** No domains: what a studio whose control plane is unreachable or whose plan includes none reads. */
|
|
81
|
+
export const NO_WEB_DOMAINS: WebDomainAnswer = Object.freeze({ domains: [], limit: 0, studioHost: '' }) as WebDomainAnswer;
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* `GET api/site/resolve?host=<Host>&org=<first segment>` — what the engine learns about the site a request is for. An
|
|
85
|
+
* engine that sends only `?org=` gets the answer it always got (`null` for an unknown label); `primaryHost` and `by` are
|
|
86
|
+
* additive.
|
|
87
|
+
*/
|
|
88
|
+
export interface SiteResolveAnswer {
|
|
89
|
+
orgId: string;
|
|
90
|
+
label: string | null;
|
|
91
|
+
isDefault: boolean;
|
|
92
|
+
/** the organization's live primary host (canonical); null = the iox.studio address is canonical */
|
|
93
|
+
primaryHost: string | null;
|
|
94
|
+
by: SiteResolvedBy;
|
|
95
|
+
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where a request goes once an organization's own address is live (CD-D6, CD-D7, R-CD5) — the engine applies it as a 301.
|
|
3
|
+
*/
|
|
4
|
+
import { ADMIN_SEGMENT, NEVER_REDIRECTED_SEGMENTS, SiteResolvedBy } from './domain-vocabulary';
|
|
5
|
+
import { normalizeHost } from './web-domain';
|
|
6
|
+
|
|
7
|
+
/** The request as the engine sees it. */
|
|
8
|
+
export interface RedirectRequest {
|
|
9
|
+
/** the `Host` header (a port is ignored) */
|
|
10
|
+
host: string | null | undefined;
|
|
11
|
+
/** the path, starting with `/` — no query */
|
|
12
|
+
path: string;
|
|
13
|
+
/** the query, with or without its `?` */
|
|
14
|
+
search?: string | null;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/** What the engine knows about the site this request is for. */
|
|
18
|
+
export interface RedirectSite {
|
|
19
|
+
/** the studio's `<studio>.iox.studio` — the admin origin (CD-D7) */
|
|
20
|
+
defaultHost: string;
|
|
21
|
+
/** the organization segment the path carries (`kadar` for `/kadar/about`); null when the path carries none (the default organization) */
|
|
22
|
+
orgSegment: string | null;
|
|
23
|
+
/** the organization's LIVE primary host (`orgPrimaryHost`), or null — nothing is redirected while none is live (R-CD6) */
|
|
24
|
+
primary: string | null;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function decodeSegment(raw: string | null): string | null {
|
|
28
|
+
if (!raw) return null;
|
|
29
|
+
try {
|
|
30
|
+
return decodeURIComponent(raw);
|
|
31
|
+
} catch {
|
|
32
|
+
return raw;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function firstSegment(path: string): string {
|
|
37
|
+
return path.replace(/^\/+/, '').split('/')[0] ?? '';
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* The absolute URL a request 301s to, or null to serve it here.
|
|
42
|
+
* - `/webadmin|/admin|/api|/auth` are never moved from the default host; on a custom host only `/webadmin` moves, to the
|
|
43
|
+
* default host (one admin origin, CD-D7) — the API and sign-in answer on every host.
|
|
44
|
+
* - With a live primary: any other host (the default host, the other name, another domain of the organization) goes to the
|
|
45
|
+
* primary with the path kept and the organization segment dropped (`/kadar/about` → `/about`).
|
|
46
|
+
* - On the primary itself only a path still carrying the organization segment moves (an old link) — never a loop.
|
|
47
|
+
*/
|
|
48
|
+
export function orgPathRedirect(req: RedirectRequest, site: RedirectSite): string | null {
|
|
49
|
+
const host = normalizeHost(req.host ?? '');
|
|
50
|
+
const defaultHost = normalizeHost(site.defaultHost);
|
|
51
|
+
if (!host || !defaultHost) return null;
|
|
52
|
+
const path = req.path.startsWith('/') ? req.path : `/${req.path}`;
|
|
53
|
+
const query = req.search ? (req.search.startsWith('?') ? req.search : `?${req.search}`) : '';
|
|
54
|
+
const seg = firstSegment(path);
|
|
55
|
+
const onDefault = host === defaultHost;
|
|
56
|
+
|
|
57
|
+
if (NEVER_REDIRECTED_SEGMENTS.includes(seg)) {
|
|
58
|
+
return !onDefault && seg === ADMIN_SEGMENT ? `https://${defaultHost}${path}${query}` : null;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const primary = site.primary ? normalizeHost(site.primary) : null;
|
|
62
|
+
if (!primary) return null;
|
|
63
|
+
|
|
64
|
+
const org = site.orgSegment?.toLowerCase() ?? null;
|
|
65
|
+
const carriesOrg = !!org && (decodeSegment(seg) ?? '').toLowerCase() === org;
|
|
66
|
+
const rest = carriesOrg ? path.replace(/^\/+[^/]*/, '') || '/' : path;
|
|
67
|
+
|
|
68
|
+
if (host === primary) return carriesOrg ? `https://${primary}${rest}${query}` : null;
|
|
69
|
+
return `https://${primary}${rest}${query}`;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/** What `site/resolve` answered, as far as the request plan reads it (domain-wire's `SiteResolveAnswer`). */
|
|
73
|
+
export interface ResolvedSite {
|
|
74
|
+
label: string | null;
|
|
75
|
+
primaryHost: string | null;
|
|
76
|
+
by: SiteResolvedBy;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/** How the engine handles one request (custom-domains step 21). */
|
|
80
|
+
export interface SiteRequestPlan {
|
|
81
|
+
/** 301 here first; null = render */
|
|
82
|
+
redirect: string | null;
|
|
83
|
+
/** `/<segment>/` when the path carries the organization, else `/` (the organization's own host, or the default organization) */
|
|
84
|
+
baseHref: string;
|
|
85
|
+
/** the site the page renders for; false = the legacy default-organization read (no tenant) */
|
|
86
|
+
tenant: boolean;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* The ONE request decision the engine applies: render for whom, under which base href, or 301 where. A redirect is only
|
|
91
|
+
* ever computed for the studio's own host or a host the studio's table holds — a pod IP, `localhost` or a health probe is
|
|
92
|
+
* served as it is.
|
|
93
|
+
* @param rawSegment the request's first path segment as the browser sent it (possibly URL-encoded)
|
|
94
|
+
* @param studioHost the studio's `<studio>.iox.studio` (null when the engine was not told — nothing is redirected)
|
|
95
|
+
*/
|
|
96
|
+
export function planSiteRequest(req: RedirectRequest, site: ResolvedSite | null, rawSegment: string | null, studioHost: string | null): SiteRequestPlan {
|
|
97
|
+
const by = site?.by ?? null;
|
|
98
|
+
const baseHref = by === SiteResolvedBy.Segment && rawSegment ? `/${rawSegment}/` : '/';
|
|
99
|
+
const tenant = by === SiteResolvedBy.Segment || by === SiteResolvedBy.Host;
|
|
100
|
+
const host = normalizeHost(req.host ?? '');
|
|
101
|
+
const home = studioHost ? normalizeHost(studioHost) : null;
|
|
102
|
+
if (!site || !home || !host || (by !== SiteResolvedBy.Host && host !== home)) return { redirect: null, baseHref, tenant };
|
|
103
|
+
const orgSegment = by === SiteResolvedBy.Segment ? decodeSegment(rawSegment) : by === SiteResolvedBy.Host ? site.label : null;
|
|
104
|
+
return { redirect: orgPathRedirect(req, { defaultHost: home, orgSegment, primary: site.primaryHost }), baseHref, tenant };
|
|
105
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @vectoriox/iox-ui/domain-core — a studio's own web address (custom-domains-plan CD0), FRAMEWORK-FREE: what a domain
|
|
3
|
+
* is (`webDomainRefusal`, `registrableDomain`), the three records to copy, the ONE state rule (`webDomainState`, R-CD1),
|
|
4
|
+
* which host serves an organization (`orgPrimaryHost`, the host table) and where an old address 301s (`orgPathRedirect`).
|
|
5
|
+
* The control plane, iox-cms, the admin and the SSR engine all read it. It imports nothing.
|
|
6
|
+
* ⚠️ Not re-exported from the main entry. Consumers wire the usual trio — ng-package raw-ts assets, jest
|
|
7
|
+
* moduleNameMapper, tsconfig paths — or `nest start` dies with ERR_REQUIRE_ESM.
|
|
8
|
+
*/
|
|
9
|
+
export * from './domain-vocabulary';
|
|
10
|
+
export * from './web-domain';
|
|
11
|
+
export * from './org-path-redirect';
|
|
12
|
+
export * from './domain-wire';
|