@vectoriox/iox-ui 5.133.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.
Files changed (77) hide show
  1. package/commerce-core/index.d.ts +12 -1
  2. package/composite-core/index.d.ts +27 -22
  3. package/design-core/index.d.ts +436 -35
  4. package/domain-core/index.d.ts +353 -0
  5. package/domain-core/package.json +3 -0
  6. package/fesm2022/vectoriox-iox-ui-actions-core.mjs +2 -0
  7. package/fesm2022/vectoriox-iox-ui-actions-core.mjs.map +1 -1
  8. package/fesm2022/vectoriox-iox-ui-assist-core.mjs +6 -48
  9. package/fesm2022/vectoriox-iox-ui-assist-core.mjs.map +1 -1
  10. package/fesm2022/vectoriox-iox-ui-commerce-core.mjs +21 -0
  11. package/fesm2022/vectoriox-iox-ui-commerce-core.mjs.map +1 -1
  12. package/fesm2022/vectoriox-iox-ui-composite-core.mjs +68 -57
  13. package/fesm2022/vectoriox-iox-ui-composite-core.mjs.map +1 -1
  14. package/fesm2022/vectoriox-iox-ui-design-core.mjs +895 -416
  15. package/fesm2022/vectoriox-iox-ui-design-core.mjs.map +1 -1
  16. package/fesm2022/vectoriox-iox-ui-domain-core.mjs +422 -0
  17. package/fesm2022/vectoriox-iox-ui-domain-core.mjs.map +1 -0
  18. package/fesm2022/vectoriox-iox-ui-generation-core.mjs +13974 -12036
  19. package/fesm2022/vectoriox-iox-ui-generation-core.mjs.map +1 -1
  20. package/fesm2022/vectoriox-iox-ui-harness-core.mjs +9 -3
  21. package/fesm2022/vectoriox-iox-ui-harness-core.mjs.map +1 -1
  22. package/fesm2022/vectoriox-iox-ui-mail-core.mjs +210 -2
  23. package/fesm2022/vectoriox-iox-ui-mail-core.mjs.map +1 -1
  24. package/fesm2022/vectoriox-iox-ui.mjs +290 -16
  25. package/fesm2022/vectoriox-iox-ui.mjs.map +1 -1
  26. package/generation-core/index.d.ts +1419 -379
  27. package/harness-core/index.d.ts +6 -1
  28. package/index.d.ts +139 -10
  29. package/mail-core/index.d.ts +190 -2
  30. package/package.json +5 -1
  31. package/src/actions-core/element-actions.ts +2 -0
  32. package/src/assist-core/page-sections.ts +7 -37
  33. package/src/commerce-core/shop-display.ts +21 -0
  34. package/src/composite-core/shop.ts +71 -57
  35. package/src/design-core/design-settings.ts +16 -0
  36. package/src/design-core/design-token.model.ts +7 -1
  37. package/src/design-core/flavor-spec.generated.ts +374 -35
  38. package/src/design-core/flavor-tokens.ts +12 -1
  39. package/src/design-core/header-behaviour.ts +32 -0
  40. package/src/design-core/motion-language.ts +115 -0
  41. package/src/design-core/public-api.ts +1 -0
  42. package/src/design-core/style-presets.ts +3 -0
  43. package/src/domain-core/domain-vocabulary.ts +125 -0
  44. package/src/domain-core/domain-wire.ts +95 -0
  45. package/src/domain-core/org-path-redirect.ts +105 -0
  46. package/src/domain-core/public-api.ts +12 -0
  47. package/src/domain-core/web-domain.ts +251 -0
  48. package/src/generation-core/carry-fill.ts +36 -0
  49. package/src/generation-core/carry.ts +398 -0
  50. package/src/generation-core/check-carry.ts +216 -0
  51. package/src/generation-core/check-layout.ts +71 -5
  52. package/src/generation-core/compose-layout.ts +187 -28
  53. package/src/generation-core/compose-site.ts +154 -31
  54. package/src/generation-core/entrances.ts +66 -10
  55. package/src/generation-core/header-edit.ts +299 -0
  56. package/src/generation-core/header-mix.ts +64 -5
  57. package/src/generation-core/layout-fingerprint.ts +5 -1
  58. package/src/generation-core/layout-language.ts +20 -1
  59. package/src/generation-core/layout-space.ts +4 -4
  60. package/src/generation-core/layout-wire.ts +36 -1
  61. package/src/generation-core/node-baselines.generated.ts +1 -0
  62. package/src/generation-core/public-api.ts +7 -0
  63. package/src/generation-core/redesign-additions.ts +273 -0
  64. package/src/generation-core/redesign-run.ts +364 -0
  65. package/src/generation-core/refit-page.ts +151 -0
  66. package/src/generation-core/section-stamp.ts +4 -4
  67. package/src/generation-core/shop-plan.ts +15 -0
  68. package/src/generation-core/site-build-run.ts +20 -3
  69. package/src/generation-core/site-spec.generated.ts +194 -94
  70. package/src/generation-core/site-tree.ts +19 -5
  71. package/src/generation-core/validate-site-plan.ts +37 -3
  72. package/src/harness-core/motion.ts +13 -3
  73. package/src/harness-core/starting-design.ts +1 -1
  74. package/src/mail-core/mail-domain.ts +305 -0
  75. package/src/mail-core/mail-wire.ts +8 -0
  76. package/src/mail-core/public-api.ts +3 -1
  77. package/styles/iox-design.css +30 -1
@@ -0,0 +1,422 @@
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
+ * Where a studio's own address stands — decided by ONE rule, `webDomainState` (R-CD1). "Checking" is not a state: it is
8
+ * the few seconds a Check request is open, said by the screen's busy button, never stored.
9
+ */
10
+ var WebDomainState;
11
+ (function (WebDomainState) {
12
+ /** no domain */
13
+ WebDomainState["NotSet"] = "not-set";
14
+ /** entered; its records were never found (never checked, or the domain is not proven ours yet) */
15
+ WebDomainState["Waiting"] = "waiting";
16
+ /** DNS is right and proven; cert-manager is getting the certificate (1–10 minutes) */
17
+ WebDomainState["Certificate"] = "certificate";
18
+ /** the certificate is ready and the address serves the site */
19
+ WebDomainState["Live"] = "live";
20
+ /** a check found a record missing or wrong, or the certificate could not be issued (CAA, a proxy in front) */
21
+ WebDomainState["Failed"] = "failed";
22
+ /** was live; a recheck found DNS moved away or the certificate failed — the iox.studio address serves again at once */
23
+ WebDomainState["Lost"] = "lost";
24
+ })(WebDomainState || (WebDomainState = {}));
25
+ /** What cert-manager says about a domain's certificate. `Wildcard` is the default host's (`*.iox.studio`), never a custom one's. */
26
+ var WebCertState;
27
+ (function (WebCertState) {
28
+ WebCertState["None"] = "none";
29
+ WebCertState["Pending"] = "pending";
30
+ WebCertState["Ready"] = "ready";
31
+ WebCertState["Failed"] = "failed";
32
+ WebCertState["Wildcard"] = "wildcard";
33
+ })(WebCertState || (WebCertState = {}));
34
+ /** The three records an owner adds at their DNS host (CD-D3). */
35
+ var WebDnsRecordRole;
36
+ (function (WebDnsRecordRole) {
37
+ /** CNAME `www` → `<studio>.iox.studio` */
38
+ WebDnsRecordRole["Www"] = "www";
39
+ /** A `@` → the ingress load balancer (an ALIAS / ANAME / flattened CNAME resolving there is accepted) */
40
+ WebDnsRecordRole["Apex"] = "apex";
41
+ /** TXT `_iox` = `iox-verify=<token>` — proves this studio owns the domain */
42
+ WebDnsRecordRole["Ownership"] = "ownership";
43
+ })(WebDnsRecordRole || (WebDnsRecordRole = {}));
44
+ /** Which of a domain's two names serves the site; the other 301s to it (CD-D2). */
45
+ var WebDomainName;
46
+ (function (WebDomainName) {
47
+ WebDomainName["Www"] = "www";
48
+ WebDomainName["Apex"] = "apex";
49
+ })(WebDomainName || (WebDomainName = {}));
50
+ /** What a check found wrong beyond a record's own ok/false — said on the card in the owner's words. */
51
+ var WebDomainProblem;
52
+ (function (WebDomainProblem) {
53
+ /** the `_iox` TXT is missing or holds another token */
54
+ WebDomainProblem["TokenMissing"] = "token-missing";
55
+ /** `www` does not resolve to the studio */
56
+ WebDomainProblem["WwwNotHere"] = "www-not-here";
57
+ /** `@` does not resolve to the load balancer */
58
+ WebDomainProblem["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
+ WebDomainProblem["Proxied"] = "proxied";
61
+ /** a CAA record does not allow letsencrypt.org — issuance would fail silently (trap 4) */
62
+ WebDomainProblem["CaaRefuses"] = "caa-refuses";
63
+ /** cert-manager could not issue or renew the certificate */
64
+ WebDomainProblem["CertificateFailed"] = "certificate-failed";
65
+ })(WebDomainProblem || (WebDomainProblem = {}));
66
+ /** Why a domain cannot be added — the wire's `code` and the screen's message key. */
67
+ var WebDomainRefusal;
68
+ (function (WebDomainRefusal) {
69
+ /** not a host name at all */
70
+ WebDomainRefusal["NotADomain"] = "not-a-domain";
71
+ /** an IP address — a site is reached by name */
72
+ WebDomainRefusal["IpAddress"] = "ip-address";
73
+ /** under iox.studio — the studio already has that address */
74
+ WebDomainRefusal["PlatformDomain"] = "platform-domain";
75
+ /** only a public suffix (`co.il`, `com`) — nobody owns it */
76
+ WebDomainRefusal["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
+ WebDomainRefusal["Subdomain"] = "subdomain";
79
+ /** another IOX studio has it VERIFIED (CD-D11) — 409 */
80
+ WebDomainRefusal["Taken"] = "taken";
81
+ /** the plan's count of own domains is used (CD-D4) — 403 */
82
+ WebDomainRefusal["PlanFull"] = "plan-full";
83
+ /** the studio's plan has no own domains, or the control plane is not reachable — 403 / 503 */
84
+ WebDomainRefusal["NotEnabled"] = "not-enabled";
85
+ /** the control plane failed — 502 */
86
+ WebDomainRefusal["Upstream"] = "upstream";
87
+ })(WebDomainRefusal || (WebDomainRefusal = {}));
88
+ /** How iox-cms found the site a request is for. */
89
+ var SiteResolvedBy;
90
+ (function (SiteResolvedBy) {
91
+ /** the request's Host is one of the organization's own domains — base href `/`, no org segment */
92
+ SiteResolvedBy["Host"] = "host";
93
+ /** the first path segment is the organization's label — base href `/<label>/` */
94
+ SiteResolvedBy["Segment"] = "segment";
95
+ /** neither: the default organization serves a path with no org segment (answered only when the engine sent `host`) */
96
+ SiteResolvedBy["Default"] = "default";
97
+ })(SiteResolvedBy || (SiteResolvedBy = {}));
98
+ /** The platform's own zones: a studio already has `<studio>.iox.studio` and can never claim a name under them. */
99
+ const PLATFORM_WEB_DOMAINS = ['iox.studio'];
100
+ /** The ownership record's name and value prefix (CD-D3). */
101
+ const WEB_DOMAIN_TXT_HOST = '_iox';
102
+ const WEB_DOMAIN_TOKEN_PREFIX = 'iox-verify=';
103
+ /** The Check button rests this long after a check (the ML4 rule). */
104
+ const WEB_DOMAIN_CHECK_MIN_MS = 30_000;
105
+ /** A live (or lost) domain is rechecked once a day (CD-D10). */
106
+ const WEB_DOMAIN_RECHECK_MS = 24 * 60 * 60 * 1000;
107
+ /** A lost domain stays attached this long, so putting the records back revives it with no new certificate (CD-D10). */
108
+ const WEB_DOMAIN_LOST_KEEP_MS = 30 * 24 * 60 * 60 * 1000;
109
+ /** An entered-but-unverified claim blocks nobody and expires after this long (CD-D11). */
110
+ const WEB_DOMAIN_CLAIM_MS = 7 * 24 * 60 * 60 * 1000;
111
+ /** A certificate expiring within this long counts as failing to renew (CD-D10). */
112
+ const WEB_CERT_RENEW_MARGIN_MS = 14 * 24 * 60 * 60 * 1000;
113
+ /** Domains over a downgraded plan's count stay served this long (CD-D12). */
114
+ const WEB_DOMAIN_GRACE_MS = 14 * 24 * 60 * 60 * 1000;
115
+ /**
116
+ * First path segments that are never redirected from the default host (CD-D6, R-CD5): the admin, the API, sign-in. On a
117
+ * custom host only `webadmin` moves — to the admin origin (CD-D7); the API and sign-in answer on every host the site has.
118
+ */
119
+ const NEVER_REDIRECTED_SEGMENTS = ['webadmin', 'admin', 'api', 'auth'];
120
+ /** The admin SPA's first segment — on a custom host it 301s to the default host (CD-D7). */
121
+ const ADMIN_SEGMENT = 'webadmin';
122
+
123
+ /**
124
+ * A studio's own web address — what a domain is, the three records, the ONE state rule, which host serves (CD0).
125
+ */
126
+ /**
127
+ * Public suffixes of more than one label, curated (not the whole Public Suffix List — a framework-free entry carries no
128
+ * 250 KB table). Israel's first, then the ones an Israeli studio's customers most often hold. A suffix missing here makes
129
+ * `registrableDomain('shop.example.com.xx')` one label short, which the screen shows before anything is asked of DNS.
130
+ */
131
+ const MULTI_PART_SUFFIXES = [
132
+ 'co.il', 'org.il', 'net.il', 'ac.il', 'gov.il', 'muni.il', 'k12.il', 'idf.il',
133
+ 'co.uk', 'org.uk', 'me.uk', 'ltd.uk', 'plc.uk', 'net.uk', 'ac.uk', 'gov.uk',
134
+ 'com.au', 'net.au', 'org.au', 'co.nz', 'org.nz', 'co.za', 'co.jp', 'or.jp', 'ne.jp',
135
+ 'com.br', 'com.mx', 'com.ar', 'com.tr', 'com.cy', 'com.gr', 'co.in', 'co.kr', 'com.cn', 'com.hk', 'com.sg',
136
+ ];
137
+ const LABEL = /^(?!-)[a-z0-9-]{1,63}(?<!-)$/;
138
+ const IPV4 = /^\d{1,3}(\.\d{1,3}){3}$/;
139
+ /**
140
+ * The host a person typed, as a lower-case ASCII host name — a scheme, a path, a port, a trailing dot and spaces are
141
+ * forgiven; a Hebrew name becomes its punycode (the WHATWG URL parser does it, in Node and every browser). Null when it
142
+ * is not a host name.
143
+ */
144
+ function normalizeHost(input) {
145
+ if (typeof input !== 'string')
146
+ return null;
147
+ let raw = input.trim();
148
+ if (!raw || /\s/.test(raw))
149
+ return null;
150
+ if (!/^[a-z][a-z0-9+.-]*:\/\//i.test(raw))
151
+ raw = `http://${raw}`;
152
+ let host;
153
+ try {
154
+ host = new URL(raw).hostname;
155
+ }
156
+ catch {
157
+ return null;
158
+ }
159
+ host = host.replace(/\.$/, '').toLowerCase();
160
+ if (host.startsWith('['))
161
+ return host; // an IPv6 literal — refused by the caller as an IP
162
+ return host || null;
163
+ }
164
+ function isIp(host) {
165
+ return host.startsWith('[') || host.includes(':') || IPV4.test(host);
166
+ }
167
+ /** `a.b` is `b` or below it. */
168
+ function under(host, zone) {
169
+ return host === zone || host.endsWith(`.${zone}`);
170
+ }
171
+ /** The public suffix of a host: a known multi-part one, else its last label. */
172
+ function publicSuffix(host) {
173
+ return MULTI_PART_SUFFIXES.find((s) => under(host, s)) ?? host.slice(host.lastIndexOf('.') + 1);
174
+ }
175
+ /**
176
+ * The registrable domain of a host — `www.shop.mywebsite.co.il` → `mywebsite.co.il`. Null for an IP, a single label or
177
+ * a bare public suffix.
178
+ */
179
+ function registrableDomain(input) {
180
+ const host = normalizeHost(input);
181
+ if (!host || isIp(host) || !host.includes('.'))
182
+ return null;
183
+ if (!host.split('.').every((l) => LABEL.test(l)))
184
+ return null;
185
+ const suffix = publicSuffix(host);
186
+ if (host === suffix)
187
+ return null;
188
+ const rest = host.slice(0, host.length - suffix.length - 1);
189
+ return `${rest.slice(rest.lastIndexOf('.') + 1)}.${suffix}`;
190
+ }
191
+ /** Why `input` cannot become a studio's own domain, or null when it can (the domain is then `webDomainOf(input)`). */
192
+ function webDomainRefusal(input, platformDomains = PLATFORM_WEB_DOMAINS) {
193
+ const host = normalizeHost(input);
194
+ if (!host)
195
+ return WebDomainRefusal.NotADomain;
196
+ if (isIp(host))
197
+ return WebDomainRefusal.IpAddress;
198
+ if (!host.includes('.') || !host.split('.').every((l) => LABEL.test(l)) || /^\d+$/.test(host.slice(host.lastIndexOf('.') + 1))) {
199
+ return WebDomainRefusal.NotADomain;
200
+ }
201
+ if (platformDomains.some((p) => under(host, p.toLowerCase())))
202
+ return WebDomainRefusal.PlatformDomain;
203
+ const domain = registrableDomain(host);
204
+ if (!domain)
205
+ return WebDomainRefusal.PublicSuffix;
206
+ if (host !== domain && host !== `www.${domain}`)
207
+ return WebDomainRefusal.Subdomain;
208
+ return null;
209
+ }
210
+ /** The registrable domain an accepted input names (`https://www.MyWebsite.co.il/` → `mywebsite.co.il`), else null. */
211
+ function webDomainOf(input, platformDomains = PLATFORM_WEB_DOMAINS) {
212
+ return webDomainRefusal(input, platformDomains) ? null : registrableDomain(input);
213
+ }
214
+ /** The ownership record's value for a studio's token. */
215
+ function webDomainTokenValue(token) {
216
+ return `${WEB_DOMAIN_TOKEN_PREFIX}${token}`;
217
+ }
218
+ /**
219
+ * The three records to copy (CD-D3), in the order the card lists them, not checked yet. `studioHost` is the studio's
220
+ * `<studio>.iox.studio`; `loadBalancerIp` the ingress's public address.
221
+ */
222
+ function webDomainRecords(domain, studioHost, loadBalancerIp, token) {
223
+ const d = domain.toLowerCase();
224
+ return [
225
+ { role: WebDnsRecordRole.Www, type: 'CNAME', name: `www.${d}`, host: 'www', value: studioHost.toLowerCase(), ok: null },
226
+ { role: WebDnsRecordRole.Apex, type: 'A', name: d, host: '@', value: loadBalancerIp, ok: null },
227
+ { role: WebDnsRecordRole.Ownership, type: 'TXT', name: `${WEB_DOMAIN_TXT_HOST}.${d}`, host: WEB_DOMAIN_TXT_HOST, value: webDomainTokenValue(token), ok: null },
228
+ ];
229
+ }
230
+ function recordsRight(row) {
231
+ const records = row.records ?? [];
232
+ return records.length > 0 && records.every((r) => r.ok === true) && !(row.problems ?? []).length;
233
+ }
234
+ function recordWrong(row) {
235
+ return (row.records ?? []).some((r) => r.ok === false) || (row.problems ?? []).length > 0;
236
+ }
237
+ /**
238
+ * THE state of a domain (R-CD1) — every screen, the bell, the engine's host table and the control plane read it.
239
+ * Live only when proven, pointing here, and cert-manager says Ready (R-CD2); once live, anything less is Lost.
240
+ */
241
+ function webDomainState(row) {
242
+ if (!row?.domain)
243
+ return WebDomainState.NotSet;
244
+ const right = !!row.verifiedAt && recordsRight(row);
245
+ if (right && row.certState === WebCertState.Ready)
246
+ return WebDomainState.Live;
247
+ if (row.liveAt)
248
+ return WebDomainState.Lost;
249
+ if (row.certState === WebCertState.Failed)
250
+ return WebDomainState.Failed;
251
+ if (right)
252
+ return WebDomainState.Certificate;
253
+ if (row.checkedAt && recordWrong(row))
254
+ return WebDomainState.Failed;
255
+ return WebDomainState.Waiting;
256
+ }
257
+ /** States whose names are on the studio's custom Ingress (the chart's `customHosts`): DNS was right once, so a certificate is (being) held. */
258
+ const ATTACHED = new Set([WebDomainState.Certificate, WebDomainState.Live, WebDomainState.Lost]);
259
+ /** Is the domain on the studio's custom Ingress — the control plane renders its names into `customHosts`, the engine serves them. */
260
+ function webDomainAttached(row) {
261
+ return ATTACHED.has(webDomainState(row));
262
+ }
263
+ /** The host that serves a domain: `www.<domain>` unless the owner picked the bare domain (CD-D2). */
264
+ function primaryHost(row) {
265
+ const d = row.domain.toLowerCase();
266
+ return row.serveAs === WebDomainName.Apex ? d : `www.${d}`;
267
+ }
268
+ /** Both names a domain connects — the served one first. */
269
+ function webDomainHosts(row) {
270
+ const d = row.domain.toLowerCase();
271
+ return row.serveAs === WebDomainName.Apex ? [d, `www.${d}`] : [`www.${d}`, d];
272
+ }
273
+ /**
274
+ * The live address an organization's site answers on, or null (no live domain → the iox.studio address is canonical).
275
+ * The row marked `primary` wins; with none marked, the first live one (one domain needs no choice, CD-D5).
276
+ */
277
+ function orgPrimaryHost(rows, orgId) {
278
+ const live = (rows ?? []).filter((r) => (r.orgId ?? null) === orgId && webDomainState(r) === WebDomainState.Live);
279
+ const chosen = live.find((r) => r.primary) ?? live[0];
280
+ return chosen ? primaryHost(chosen) : null;
281
+ }
282
+ /**
283
+ * The host table: every name of every ATTACHED domain → its organization, with that organization's live primary. A Lost
284
+ * domain still serves its organization (so a returning record revives it) but is nobody's primary (R-CD6).
285
+ */
286
+ function webHostTable(rows) {
287
+ const out = [];
288
+ for (const row of rows ?? []) {
289
+ if (!webDomainAttached(row))
290
+ continue;
291
+ const orgId = row.orgId ?? null;
292
+ const primary = orgPrimaryHost(rows, orgId);
293
+ for (const host of webDomainHosts(row))
294
+ out.push({ host, orgId, primaryHost: primary });
295
+ }
296
+ return out;
297
+ }
298
+ /** The route for a request's Host, or null (the default host, or a name no domain holds). */
299
+ function webHostRoute(table, host) {
300
+ const h = normalizeHost(host ?? '');
301
+ return h ? (table ?? []).find((r) => r.host === h) ?? null : null;
302
+ }
303
+ /** Is a live or lost domain due its daily recheck (CD-D10)? */
304
+ function webDomainRecheckDue(row, now) {
305
+ const state = webDomainState(row);
306
+ if (state !== WebDomainState.Live && state !== WebDomainState.Lost)
307
+ return false;
308
+ const at = row?.checkedAt ? Date.parse(row.checkedAt) : NaN;
309
+ return !Number.isFinite(at) || now - at >= WEB_DOMAIN_RECHECK_MS;
310
+ }
311
+ /** Has a lost domain been gone 30 days — detach it (CD-D10)? */
312
+ function webDomainDetachDue(row, now) {
313
+ if (webDomainState(row) !== WebDomainState.Lost || !row?.lostAt)
314
+ return false;
315
+ const at = Date.parse(row.lostAt);
316
+ return Number.isFinite(at) && now - at >= WEB_DOMAIN_LOST_KEEP_MS;
317
+ }
318
+ /** Has an entered-but-unproven claim expired, so it blocks nobody (CD-D11)? */
319
+ function webDomainClaimExpired(row, now) {
320
+ if (!row?.domain || row.verifiedAt)
321
+ return false;
322
+ const at = row.createdAt ? Date.parse(row.createdAt) : NaN;
323
+ return Number.isFinite(at) && now - at >= WEB_DOMAIN_CLAIM_MS;
324
+ }
325
+
326
+ /**
327
+ * 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.
328
+ */
329
+ function decodeSegment(raw) {
330
+ if (!raw)
331
+ return null;
332
+ try {
333
+ return decodeURIComponent(raw);
334
+ }
335
+ catch {
336
+ return raw;
337
+ }
338
+ }
339
+ function firstSegment(path) {
340
+ return path.replace(/^\/+/, '').split('/')[0] ?? '';
341
+ }
342
+ /**
343
+ * The absolute URL a request 301s to, or null to serve it here.
344
+ * - `/webadmin|/admin|/api|/auth` are never moved from the default host; on a custom host only `/webadmin` moves, to the
345
+ * default host (one admin origin, CD-D7) — the API and sign-in answer on every host.
346
+ * - With a live primary: any other host (the default host, the other name, another domain of the organization) goes to the
347
+ * primary with the path kept and the organization segment dropped (`/kadar/about` → `/about`).
348
+ * - On the primary itself only a path still carrying the organization segment moves (an old link) — never a loop.
349
+ */
350
+ function orgPathRedirect(req, site) {
351
+ const host = normalizeHost(req.host ?? '');
352
+ const defaultHost = normalizeHost(site.defaultHost);
353
+ if (!host || !defaultHost)
354
+ return null;
355
+ const path = req.path.startsWith('/') ? req.path : `/${req.path}`;
356
+ const query = req.search ? (req.search.startsWith('?') ? req.search : `?${req.search}`) : '';
357
+ const seg = firstSegment(path);
358
+ const onDefault = host === defaultHost;
359
+ if (NEVER_REDIRECTED_SEGMENTS.includes(seg)) {
360
+ return !onDefault && seg === ADMIN_SEGMENT ? `https://${defaultHost}${path}${query}` : null;
361
+ }
362
+ const primary = site.primary ? normalizeHost(site.primary) : null;
363
+ if (!primary)
364
+ return null;
365
+ const org = site.orgSegment?.toLowerCase() ?? null;
366
+ const carriesOrg = !!org && (decodeSegment(seg) ?? '').toLowerCase() === org;
367
+ const rest = carriesOrg ? path.replace(/^\/+[^/]*/, '') || '/' : path;
368
+ if (host === primary)
369
+ return carriesOrg ? `https://${primary}${rest}${query}` : null;
370
+ return `https://${primary}${rest}${query}`;
371
+ }
372
+ /**
373
+ * The ONE request decision the engine applies: render for whom, under which base href, or 301 where. A redirect is only
374
+ * 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
375
+ * served as it is.
376
+ * @param rawSegment the request's first path segment as the browser sent it (possibly URL-encoded)
377
+ * @param studioHost the studio's `<studio>.iox.studio` (null when the engine was not told — nothing is redirected)
378
+ */
379
+ function planSiteRequest(req, site, rawSegment, studioHost) {
380
+ const by = site?.by ?? null;
381
+ const baseHref = by === SiteResolvedBy.Segment && rawSegment ? `/${rawSegment}/` : '/';
382
+ const tenant = by === SiteResolvedBy.Segment || by === SiteResolvedBy.Host;
383
+ const host = normalizeHost(req.host ?? '');
384
+ const home = studioHost ? normalizeHost(studioHost) : null;
385
+ if (!site || !home || !host || (by !== SiteResolvedBy.Host && host !== home))
386
+ return { redirect: null, baseHref, tenant };
387
+ const orgSegment = by === SiteResolvedBy.Segment ? decodeSegment(rawSegment) : by === SiteResolvedBy.Host ? site.label : null;
388
+ return { redirect: orgPathRedirect(req, { defaultHost: home, orgSegment, primary: site.primaryHost }), baseHref, tenant };
389
+ }
390
+
391
+ /** `GET` the studio's domains · `PUT` add one (`WebDomainRequest`) · `DELETE …/:domain` stop using one. */
392
+ const RELAY_WEB_DOMAINS_PATH = '/instances/me/domains';
393
+ /** `/instances/me/domains/:domain` */
394
+ function webDomainPath(domain) {
395
+ return `${RELAY_WEB_DOMAINS_PATH}/${encodeURIComponent(domain.toLowerCase())}`;
396
+ }
397
+ /** `POST /instances/me/domains/:domain/check` — resolve its records now on public resolvers. */
398
+ function webDomainCheckPath(domain) {
399
+ return `${webDomainPath(domain)}/check`;
400
+ }
401
+ /** `PATCH /instances/me/domains/:domain/primary` — `{ serveAs?, primary? }`. */
402
+ function webDomainPrimaryPath(domain) {
403
+ return `${webDomainPath(domain)}/primary`;
404
+ }
405
+ /** No domains: what a studio whose control plane is unreachable or whose plan includes none reads. */
406
+ const NO_WEB_DOMAINS = Object.freeze({ domains: [], limit: 0, studioHost: '' });
407
+
408
+ /**
409
+ * @vectoriox/iox-ui/domain-core — a studio's own web address (custom-domains-plan CD0), FRAMEWORK-FREE: what a domain
410
+ * is (`webDomainRefusal`, `registrableDomain`), the three records to copy, the ONE state rule (`webDomainState`, R-CD1),
411
+ * which host serves an organization (`orgPrimaryHost`, the host table) and where an old address 301s (`orgPathRedirect`).
412
+ * The control plane, iox-cms, the admin and the SSR engine all read it. It imports nothing.
413
+ * ⚠️ Not re-exported from the main entry. Consumers wire the usual trio — ng-package raw-ts assets, jest
414
+ * moduleNameMapper, tsconfig paths — or `nest start` dies with ERR_REQUIRE_ESM.
415
+ */
416
+
417
+ /**
418
+ * Generated bundle index. Do not edit.
419
+ */
420
+
421
+ export { ADMIN_SEGMENT, MULTI_PART_SUFFIXES, NEVER_REDIRECTED_SEGMENTS, NO_WEB_DOMAINS, PLATFORM_WEB_DOMAINS, RELAY_WEB_DOMAINS_PATH, SiteResolvedBy, WEB_CERT_RENEW_MARGIN_MS, WEB_DOMAIN_CHECK_MIN_MS, WEB_DOMAIN_CLAIM_MS, WEB_DOMAIN_GRACE_MS, WEB_DOMAIN_LOST_KEEP_MS, WEB_DOMAIN_RECHECK_MS, WEB_DOMAIN_TOKEN_PREFIX, WEB_DOMAIN_TXT_HOST, WebCertState, WebDnsRecordRole, WebDomainName, WebDomainProblem, WebDomainRefusal, WebDomainState, normalizeHost, orgPathRedirect, orgPrimaryHost, planSiteRequest, primaryHost, registrableDomain, webDomainAttached, webDomainCheckPath, webDomainClaimExpired, webDomainDetachDue, webDomainHosts, webDomainOf, webDomainPath, webDomainPrimaryPath, webDomainRecheckDue, webDomainRecords, webDomainRefusal, webDomainState, webDomainTokenValue, webHostRoute, webHostTable };
422
+ //# sourceMappingURL=vectoriox-iox-ui-domain-core.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vectoriox-iox-ui-domain-core.mjs","sources":["../../../projects/iox-ui/src/domain-core/domain-vocabulary.ts","../../../projects/iox-ui/src/domain-core/web-domain.ts","../../../projects/iox-ui/src/domain-core/org-path-redirect.ts","../../../projects/iox-ui/src/domain-core/domain-wire.ts","../../../projects/iox-ui/src/domain-core/public-api.ts","../../../projects/iox-ui/src/domain-core/vectoriox-iox-ui-domain-core.ts"],"sourcesContent":["/**\n * domain-core vocabulary — a studio's own web address (custom-domains-plan, CD0). The states, refusals, record roles and\n * the numbers every reader of a domain shares: the control plane writes what it found, iox-cms passes it on, the admin\n * shows it, the engine serves by it. Framework-free; imports nothing.\n */\n\n/**\n * Where a studio's own address stands — decided by ONE rule, `webDomainState` (R-CD1). \"Checking\" is not a state: it is\n * the few seconds a Check request is open, said by the screen's busy button, never stored.\n */\nexport enum WebDomainState {\n /** no domain */\n NotSet = 'not-set',\n /** entered; its records were never found (never checked, or the domain is not proven ours yet) */\n Waiting = 'waiting',\n /** DNS is right and proven; cert-manager is getting the certificate (1–10 minutes) */\n Certificate = 'certificate',\n /** the certificate is ready and the address serves the site */\n Live = 'live',\n /** a check found a record missing or wrong, or the certificate could not be issued (CAA, a proxy in front) */\n Failed = 'failed',\n /** was live; a recheck found DNS moved away or the certificate failed — the iox.studio address serves again at once */\n Lost = 'lost',\n}\n\n/** What cert-manager says about a domain's certificate. `Wildcard` is the default host's (`*.iox.studio`), never a custom one's. */\nexport enum WebCertState {\n None = 'none',\n Pending = 'pending',\n Ready = 'ready',\n Failed = 'failed',\n Wildcard = 'wildcard',\n}\n\n/** The three records an owner adds at their DNS host (CD-D3). */\nexport enum WebDnsRecordRole {\n /** CNAME `www` → `<studio>.iox.studio` */\n Www = 'www',\n /** A `@` → the ingress load balancer (an ALIAS / ANAME / flattened CNAME resolving there is accepted) */\n Apex = 'apex',\n /** TXT `_iox` = `iox-verify=<token>` — proves this studio owns the domain */\n Ownership = 'ownership',\n}\n\n/** Which of a domain's two names serves the site; the other 301s to it (CD-D2). */\nexport enum WebDomainName {\n Www = 'www',\n Apex = 'apex',\n}\n\n/** What a check found wrong beyond a record's own ok/false — said on the card in the owner's words. */\nexport enum WebDomainProblem {\n /** the `_iox` TXT is missing or holds another token */\n TokenMissing = 'token-missing',\n /** `www` does not resolve to the studio */\n WwwNotHere = 'www-not-here',\n /** `@` does not resolve to the load balancer */\n ApexNotHere = 'apex-not-here',\n /** `www` or `@` resolves to a proxy (Cloudflare's orange cloud) — HTTP-01 and the recheck cannot reach us (CD-D15) */\n Proxied = 'proxied',\n /** a CAA record does not allow letsencrypt.org — issuance would fail silently (trap 4) */\n CaaRefuses = 'caa-refuses',\n /** cert-manager could not issue or renew the certificate */\n CertificateFailed = 'certificate-failed',\n}\n\n/** Why a domain cannot be added — the wire's `code` and the screen's message key. */\nexport enum WebDomainRefusal {\n /** not a host name at all */\n NotADomain = 'not-a-domain',\n /** an IP address — a site is reached by name */\n IpAddress = 'ip-address',\n /** under iox.studio — the studio already has that address */\n PlatformDomain = 'platform-domain',\n /** only a public suffix (`co.il`, `com`) — nobody owns it */\n PublicSuffix = 'public-suffix',\n /** a name below the domain other than `www` (`shop.mywebsite.co.il`) — the domain itself is entered; both names are connected */\n Subdomain = 'subdomain',\n /** another IOX studio has it VERIFIED (CD-D11) — 409 */\n Taken = 'taken',\n /** the plan's count of own domains is used (CD-D4) — 403 */\n PlanFull = 'plan-full',\n /** the studio's plan has no own domains, or the control plane is not reachable — 403 / 503 */\n NotEnabled = 'not-enabled',\n /** the control plane failed — 502 */\n Upstream = 'upstream',\n}\n\n/** How iox-cms found the site a request is for. */\nexport enum SiteResolvedBy {\n /** the request's Host is one of the organization's own domains — base href `/`, no org segment */\n Host = 'host',\n /** the first path segment is the organization's label — base href `/<label>/` */\n Segment = 'segment',\n /** neither: the default organization serves a path with no org segment (answered only when the engine sent `host`) */\n Default = 'default',\n}\n\n/** The platform's own zones: a studio already has `<studio>.iox.studio` and can never claim a name under them. */\nexport const PLATFORM_WEB_DOMAINS: readonly string[] = ['iox.studio'];\n\n/** The ownership record's name and value prefix (CD-D3). */\nexport const WEB_DOMAIN_TXT_HOST = '_iox';\nexport const WEB_DOMAIN_TOKEN_PREFIX = 'iox-verify=';\n\n/** The Check button rests this long after a check (the ML4 rule). */\nexport const WEB_DOMAIN_CHECK_MIN_MS = 30_000;\n/** A live (or lost) domain is rechecked once a day (CD-D10). */\nexport const WEB_DOMAIN_RECHECK_MS = 24 * 60 * 60 * 1000;\n/** A lost domain stays attached this long, so putting the records back revives it with no new certificate (CD-D10). */\nexport const WEB_DOMAIN_LOST_KEEP_MS = 30 * 24 * 60 * 60 * 1000;\n/** An entered-but-unverified claim blocks nobody and expires after this long (CD-D11). */\nexport const WEB_DOMAIN_CLAIM_MS = 7 * 24 * 60 * 60 * 1000;\n/** A certificate expiring within this long counts as failing to renew (CD-D10). */\nexport const WEB_CERT_RENEW_MARGIN_MS = 14 * 24 * 60 * 60 * 1000;\n/** Domains over a downgraded plan's count stay served this long (CD-D12). */\nexport const WEB_DOMAIN_GRACE_MS = 14 * 24 * 60 * 60 * 1000;\n\n/**\n * First path segments that are never redirected from the default host (CD-D6, R-CD5): the admin, the API, sign-in. On a\n * custom host only `webadmin` moves — to the admin origin (CD-D7); the API and sign-in answer on every host the site has.\n */\nexport const NEVER_REDIRECTED_SEGMENTS: readonly string[] = ['webadmin', 'admin', 'api', 'auth'];\n/** The admin SPA's first segment — on a custom host it 301s to the default host (CD-D7). */\nexport const ADMIN_SEGMENT = 'webadmin';\n","/**\n * A studio's own web address — what a domain is, the three records, the ONE state rule, which host serves (CD0).\n */\nimport {\n PLATFORM_WEB_DOMAINS, WEB_DOMAIN_CLAIM_MS, WEB_DOMAIN_LOST_KEEP_MS, WEB_DOMAIN_RECHECK_MS, WEB_DOMAIN_TOKEN_PREFIX, WEB_DOMAIN_TXT_HOST,\n WebCertState, WebDnsRecordRole, WebDomainName, WebDomainProblem, WebDomainRefusal, WebDomainState,\n} from './domain-vocabulary';\n\n/**\n * Public suffixes of more than one label, curated (not the whole Public Suffix List — a framework-free entry carries no\n * 250 KB table). Israel's first, then the ones an Israeli studio's customers most often hold. A suffix missing here makes\n * `registrableDomain('shop.example.com.xx')` one label short, which the screen shows before anything is asked of DNS.\n */\nexport const MULTI_PART_SUFFIXES: readonly string[] = [\n 'co.il', 'org.il', 'net.il', 'ac.il', 'gov.il', 'muni.il', 'k12.il', 'idf.il',\n 'co.uk', 'org.uk', 'me.uk', 'ltd.uk', 'plc.uk', 'net.uk', 'ac.uk', 'gov.uk',\n 'com.au', 'net.au', 'org.au', 'co.nz', 'org.nz', 'co.za', 'co.jp', 'or.jp', 'ne.jp',\n 'com.br', 'com.mx', 'com.ar', 'com.tr', 'com.cy', 'com.gr', 'co.in', 'co.kr', 'com.cn', 'com.hk', 'com.sg',\n];\n\n/** A record the owner adds, with the check's last word on it. */\nexport interface WebDnsRecord {\n role: WebDnsRecordRole;\n type: 'CNAME' | 'A' | 'TXT';\n /** the full name — `www.mywebsite.co.il` */\n name: string;\n /** the name as most DNS screens want it, relative to the domain (`www`, `@`, `_iox`) */\n host: string;\n value: string;\n /** the last check: true ok · false wrong or missing · null not checked yet */\n ok: boolean | null;\n}\n\n/** What the control plane keeps per domain (one row = one registrable domain with its `www`, CD-D4). */\nexport interface WebDomainRow {\n /** the registrable domain, lower-case ASCII (punycode for a Hebrew name) — `mywebsite.co.il` */\n domain: string;\n /** the organization the domain shows (CD-D5); null = the studio's default organization */\n orgId?: string | null;\n /** which name serves; the other 301s to it (CD-D2) — `www` unless the owner picked the bare domain */\n serveAs?: WebDomainName | null;\n /** the organization's primary domain — its other domains 301 here (CD-D5) */\n primary?: boolean;\n records?: readonly WebDnsRecord[];\n problems?: readonly WebDomainProblem[];\n certState?: WebCertState | null;\n /** ISO times */\n checkedAt?: string | null;\n /** the TXT token was found — the domain is proven ours (R-CD2) */\n verifiedAt?: string | null;\n /** the first time the domain went live — a domain that once was and no longer is, is Lost */\n liveAt?: string | null;\n /** when a recheck found it gone (starts the 30 days, CD-D10) */\n lostAt?: string | null;\n createdAt?: string | null;\n}\n\nconst LABEL = /^(?!-)[a-z0-9-]{1,63}(?<!-)$/;\nconst IPV4 = /^\\d{1,3}(\\.\\d{1,3}){3}$/;\n\n/**\n * The host a person typed, as a lower-case ASCII host name — a scheme, a path, a port, a trailing dot and spaces are\n * forgiven; a Hebrew name becomes its punycode (the WHATWG URL parser does it, in Node and every browser). Null when it\n * is not a host name.\n */\nexport function normalizeHost(input: unknown): string | null {\n if (typeof input !== 'string') return null;\n let raw = input.trim();\n if (!raw || /\\s/.test(raw)) return null;\n if (!/^[a-z][a-z0-9+.-]*:\\/\\//i.test(raw)) raw = `http://${raw}`;\n let host: string;\n try {\n host = new URL(raw).hostname;\n } catch {\n return null;\n }\n host = host.replace(/\\.$/, '').toLowerCase();\n if (host.startsWith('[')) return host; // an IPv6 literal — refused by the caller as an IP\n return host || null;\n}\n\nfunction isIp(host: string): boolean {\n return host.startsWith('[') || host.includes(':') || IPV4.test(host);\n}\n\n/** `a.b` is `b` or below it. */\nfunction under(host: string, zone: string): boolean {\n return host === zone || host.endsWith(`.${zone}`);\n}\n\n/** The public suffix of a host: a known multi-part one, else its last label. */\nfunction publicSuffix(host: string): string {\n return MULTI_PART_SUFFIXES.find((s) => under(host, s)) ?? host.slice(host.lastIndexOf('.') + 1);\n}\n\n/**\n * The registrable domain of a host — `www.shop.mywebsite.co.il` → `mywebsite.co.il`. Null for an IP, a single label or\n * a bare public suffix.\n */\nexport function registrableDomain(input: unknown): string | null {\n const host = normalizeHost(input);\n if (!host || isIp(host) || !host.includes('.')) return null;\n if (!host.split('.').every((l) => LABEL.test(l))) return null;\n const suffix = publicSuffix(host);\n if (host === suffix) return null;\n const rest = host.slice(0, host.length - suffix.length - 1);\n return `${rest.slice(rest.lastIndexOf('.') + 1)}.${suffix}`;\n}\n\n/** Why `input` cannot become a studio's own domain, or null when it can (the domain is then `webDomainOf(input)`). */\nexport function webDomainRefusal(input: unknown, platformDomains: readonly string[] = PLATFORM_WEB_DOMAINS): WebDomainRefusal | null {\n const host = normalizeHost(input);\n if (!host) return WebDomainRefusal.NotADomain;\n if (isIp(host)) return WebDomainRefusal.IpAddress;\n if (!host.includes('.') || !host.split('.').every((l) => LABEL.test(l)) || /^\\d+$/.test(host.slice(host.lastIndexOf('.') + 1))) {\n return WebDomainRefusal.NotADomain;\n }\n if (platformDomains.some((p) => under(host, p.toLowerCase()))) return WebDomainRefusal.PlatformDomain;\n const domain = registrableDomain(host);\n if (!domain) return WebDomainRefusal.PublicSuffix;\n if (host !== domain && host !== `www.${domain}`) return WebDomainRefusal.Subdomain;\n return null;\n}\n\n/** The registrable domain an accepted input names (`https://www.MyWebsite.co.il/` → `mywebsite.co.il`), else null. */\nexport function webDomainOf(input: unknown, platformDomains: readonly string[] = PLATFORM_WEB_DOMAINS): string | null {\n return webDomainRefusal(input, platformDomains) ? null : registrableDomain(input);\n}\n\n/** The ownership record's value for a studio's token. */\nexport function webDomainTokenValue(token: string): string {\n return `${WEB_DOMAIN_TOKEN_PREFIX}${token}`;\n}\n\n/**\n * The three records to copy (CD-D3), in the order the card lists them, not checked yet. `studioHost` is the studio's\n * `<studio>.iox.studio`; `loadBalancerIp` the ingress's public address.\n */\nexport function webDomainRecords(domain: string, studioHost: string, loadBalancerIp: string, token: string): WebDnsRecord[] {\n const d = domain.toLowerCase();\n return [\n { role: WebDnsRecordRole.Www, type: 'CNAME', name: `www.${d}`, host: 'www', value: studioHost.toLowerCase(), ok: null },\n { role: WebDnsRecordRole.Apex, type: 'A', name: d, host: '@', value: loadBalancerIp, ok: null },\n { role: WebDnsRecordRole.Ownership, type: 'TXT', name: `${WEB_DOMAIN_TXT_HOST}.${d}`, host: WEB_DOMAIN_TXT_HOST, value: webDomainTokenValue(token), ok: null },\n ];\n}\n\nfunction recordsRight(row: WebDomainRow): boolean {\n const records = row.records ?? [];\n return records.length > 0 && records.every((r) => r.ok === true) && !(row.problems ?? []).length;\n}\n\nfunction recordWrong(row: WebDomainRow): boolean {\n return (row.records ?? []).some((r) => r.ok === false) || (row.problems ?? []).length > 0;\n}\n\n/**\n * THE state of a domain (R-CD1) — every screen, the bell, the engine's host table and the control plane read it.\n * Live only when proven, pointing here, and cert-manager says Ready (R-CD2); once live, anything less is Lost.\n */\nexport function webDomainState(row: WebDomainRow | null | undefined): WebDomainState {\n if (!row?.domain) return WebDomainState.NotSet;\n const right = !!row.verifiedAt && recordsRight(row);\n if (right && row.certState === WebCertState.Ready) return WebDomainState.Live;\n if (row.liveAt) return WebDomainState.Lost;\n if (row.certState === WebCertState.Failed) return WebDomainState.Failed;\n if (right) return WebDomainState.Certificate;\n if (row.checkedAt && recordWrong(row)) return WebDomainState.Failed;\n return WebDomainState.Waiting;\n}\n\n/** States whose names are on the studio's custom Ingress (the chart's `customHosts`): DNS was right once, so a certificate is (being) held. */\nconst ATTACHED: ReadonlySet<WebDomainState> = new Set([WebDomainState.Certificate, WebDomainState.Live, WebDomainState.Lost]);\n\n/** Is the domain on the studio's custom Ingress — the control plane renders its names into `customHosts`, the engine serves them. */\nexport function webDomainAttached(row: WebDomainRow | null | undefined): boolean {\n return ATTACHED.has(webDomainState(row));\n}\n\n/** The host that serves a domain: `www.<domain>` unless the owner picked the bare domain (CD-D2). */\nexport function primaryHost(row: Pick<WebDomainRow, 'domain' | 'serveAs'>): string {\n const d = row.domain.toLowerCase();\n return row.serveAs === WebDomainName.Apex ? d : `www.${d}`;\n}\n\n/** Both names a domain connects — the served one first. */\nexport function webDomainHosts(row: Pick<WebDomainRow, 'domain' | 'serveAs'>): [string, string] {\n const d = row.domain.toLowerCase();\n return row.serveAs === WebDomainName.Apex ? [d, `www.${d}`] : [`www.${d}`, d];\n}\n\n/**\n * The live address an organization's site answers on, or null (no live domain → the iox.studio address is canonical).\n * The row marked `primary` wins; with none marked, the first live one (one domain needs no choice, CD-D5).\n */\nexport function orgPrimaryHost(rows: readonly WebDomainRow[] | null | undefined, orgId: string | null): string | null {\n const live = (rows ?? []).filter((r) => (r.orgId ?? null) === orgId && webDomainState(r) === WebDomainState.Live);\n const chosen = live.find((r) => r.primary) ?? live[0];\n return chosen ? primaryHost(chosen) : null;\n}\n\n/** One entry of the host table iox-cms answers the engine's `resolve?host=` from. */\nexport interface WebHostRoute {\n host: string;\n orgId: string | null;\n /** the organization's live primary host — the canonical address; null while none is live (no redirect anywhere) */\n primaryHost: string | null;\n}\n\n/**\n * The host table: every name of every ATTACHED domain → its organization, with that organization's live primary. A Lost\n * domain still serves its organization (so a returning record revives it) but is nobody's primary (R-CD6).\n */\nexport function webHostTable(rows: readonly WebDomainRow[] | null | undefined): WebHostRoute[] {\n const out: WebHostRoute[] = [];\n for (const row of rows ?? []) {\n if (!webDomainAttached(row)) continue;\n const orgId = row.orgId ?? null;\n const primary = orgPrimaryHost(rows, orgId);\n for (const host of webDomainHosts(row)) out.push({ host, orgId, primaryHost: primary });\n }\n return out;\n}\n\n/** The route for a request's Host, or null (the default host, or a name no domain holds). */\nexport function webHostRoute(table: readonly WebHostRoute[] | null | undefined, host: string | null | undefined): WebHostRoute | null {\n const h = normalizeHost(host ?? '');\n return h ? (table ?? []).find((r) => r.host === h) ?? null : null;\n}\n\n/** Is a live or lost domain due its daily recheck (CD-D10)? */\nexport function webDomainRecheckDue(row: WebDomainRow | null | undefined, now: number): boolean {\n const state = webDomainState(row);\n if (state !== WebDomainState.Live && state !== WebDomainState.Lost) return false;\n const at = row?.checkedAt ? Date.parse(row.checkedAt) : NaN;\n return !Number.isFinite(at) || now - at >= WEB_DOMAIN_RECHECK_MS;\n}\n\n/** Has a lost domain been gone 30 days — detach it (CD-D10)? */\nexport function webDomainDetachDue(row: WebDomainRow | null | undefined, now: number): boolean {\n if (webDomainState(row) !== WebDomainState.Lost || !row?.lostAt) return false;\n const at = Date.parse(row.lostAt);\n return Number.isFinite(at) && now - at >= WEB_DOMAIN_LOST_KEEP_MS;\n}\n\n/** Has an entered-but-unproven claim expired, so it blocks nobody (CD-D11)? */\nexport function webDomainClaimExpired(row: WebDomainRow | null | undefined, now: number): boolean {\n if (!row?.domain || row.verifiedAt) return false;\n const at = row.createdAt ? Date.parse(row.createdAt) : NaN;\n return Number.isFinite(at) && now - at >= WEB_DOMAIN_CLAIM_MS;\n}\n","/**\n * 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.\n */\nimport { ADMIN_SEGMENT, NEVER_REDIRECTED_SEGMENTS, SiteResolvedBy } from './domain-vocabulary';\nimport { normalizeHost } from './web-domain';\n\n/** The request as the engine sees it. */\nexport interface RedirectRequest {\n /** the `Host` header (a port is ignored) */\n host: string | null | undefined;\n /** the path, starting with `/` — no query */\n path: string;\n /** the query, with or without its `?` */\n search?: string | null;\n}\n\n/** What the engine knows about the site this request is for. */\nexport interface RedirectSite {\n /** the studio's `<studio>.iox.studio` — the admin origin (CD-D7) */\n defaultHost: string;\n /** the organization segment the path carries (`kadar` for `/kadar/about`); null when the path carries none (the default organization) */\n orgSegment: string | null;\n /** the organization's LIVE primary host (`orgPrimaryHost`), or null — nothing is redirected while none is live (R-CD6) */\n primary: string | null;\n}\n\nfunction decodeSegment(raw: string | null): string | null {\n if (!raw) return null;\n try {\n return decodeURIComponent(raw);\n } catch {\n return raw;\n }\n}\n\nfunction firstSegment(path: string): string {\n return path.replace(/^\\/+/, '').split('/')[0] ?? '';\n}\n\n/**\n * The absolute URL a request 301s to, or null to serve it here.\n * - `/webadmin|/admin|/api|/auth` are never moved from the default host; on a custom host only `/webadmin` moves, to the\n * default host (one admin origin, CD-D7) — the API and sign-in answer on every host.\n * - With a live primary: any other host (the default host, the other name, another domain of the organization) goes to the\n * primary with the path kept and the organization segment dropped (`/kadar/about` → `/about`).\n * - On the primary itself only a path still carrying the organization segment moves (an old link) — never a loop.\n */\nexport function orgPathRedirect(req: RedirectRequest, site: RedirectSite): string | null {\n const host = normalizeHost(req.host ?? '');\n const defaultHost = normalizeHost(site.defaultHost);\n if (!host || !defaultHost) return null;\n const path = req.path.startsWith('/') ? req.path : `/${req.path}`;\n const query = req.search ? (req.search.startsWith('?') ? req.search : `?${req.search}`) : '';\n const seg = firstSegment(path);\n const onDefault = host === defaultHost;\n\n if (NEVER_REDIRECTED_SEGMENTS.includes(seg)) {\n return !onDefault && seg === ADMIN_SEGMENT ? `https://${defaultHost}${path}${query}` : null;\n }\n\n const primary = site.primary ? normalizeHost(site.primary) : null;\n if (!primary) return null;\n\n const org = site.orgSegment?.toLowerCase() ?? null;\n const carriesOrg = !!org && (decodeSegment(seg) ?? '').toLowerCase() === org;\n const rest = carriesOrg ? path.replace(/^\\/+[^/]*/, '') || '/' : path;\n\n if (host === primary) return carriesOrg ? `https://${primary}${rest}${query}` : null;\n return `https://${primary}${rest}${query}`;\n}\n\n/** What `site/resolve` answered, as far as the request plan reads it (domain-wire's `SiteResolveAnswer`). */\nexport interface ResolvedSite {\n label: string | null;\n primaryHost: string | null;\n by: SiteResolvedBy;\n}\n\n/** How the engine handles one request (custom-domains step 21). */\nexport interface SiteRequestPlan {\n /** 301 here first; null = render */\n redirect: string | null;\n /** `/<segment>/` when the path carries the organization, else `/` (the organization's own host, or the default organization) */\n baseHref: string;\n /** the site the page renders for; false = the legacy default-organization read (no tenant) */\n tenant: boolean;\n}\n\n/**\n * The ONE request decision the engine applies: render for whom, under which base href, or 301 where. A redirect is only\n * 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\n * served as it is.\n * @param rawSegment the request's first path segment as the browser sent it (possibly URL-encoded)\n * @param studioHost the studio's `<studio>.iox.studio` (null when the engine was not told — nothing is redirected)\n */\nexport function planSiteRequest(req: RedirectRequest, site: ResolvedSite | null, rawSegment: string | null, studioHost: string | null): SiteRequestPlan {\n const by = site?.by ?? null;\n const baseHref = by === SiteResolvedBy.Segment && rawSegment ? `/${rawSegment}/` : '/';\n const tenant = by === SiteResolvedBy.Segment || by === SiteResolvedBy.Host;\n const host = normalizeHost(req.host ?? '');\n const home = studioHost ? normalizeHost(studioHost) : null;\n if (!site || !home || !host || (by !== SiteResolvedBy.Host && host !== home)) return { redirect: null, baseHref, tenant };\n const orgSegment = by === SiteResolvedBy.Segment ? decodeSegment(rawSegment) : by === SiteResolvedBy.Host ? site.label : null;\n return { redirect: orgPathRedirect(req, { defaultHost: home, orgSegment, primary: site.primaryHost }), baseHref, tenant };\n}\n","/**\n * The wire for a studio's own web address: the control plane's `/instances/me/domains` routes (iox-cms calls them with\n * its instance token — R-CD3) and the answer iox-cms passes to the admin.\n */\nimport { SiteResolvedBy, WebCertState, WebDomainName, WebDomainProblem, WebDomainRefusal, WebDomainState } from './domain-vocabulary';\nimport { WebDnsRecord } from './web-domain';\n\n/** `GET` the studio's domains · `PUT` add one (`WebDomainRequest`) · `DELETE …/:domain` stop using one. */\nexport const RELAY_WEB_DOMAINS_PATH = '/instances/me/domains';\n\n/** `/instances/me/domains/:domain` */\nexport function webDomainPath(domain: string): string {\n return `${RELAY_WEB_DOMAINS_PATH}/${encodeURIComponent(domain.toLowerCase())}`;\n}\n\n/** `POST /instances/me/domains/:domain/check` — resolve its records now on public resolvers. */\nexport function webDomainCheckPath(domain: string): string {\n return `${webDomainPath(domain)}/check`;\n}\n\n/** `PATCH /instances/me/domains/:domain/primary` — `{ serveAs?, primary? }`. */\nexport function webDomainPrimaryPath(domain: string): string {\n return `${webDomainPath(domain)}/primary`;\n}\n\n/** `PUT /instances/me/domains` */\nexport interface WebDomainRequest {\n /** what the owner typed — the server normalizes it (`webDomainOf`) and refuses by `webDomainRefusal` */\n domain: string;\n /** the organization it shows; omitted with one organization (CD-D5) */\n orgId?: string | null;\n}\n\n/** `PATCH …/primary` */\nexport interface WebDomainPrimaryRequest {\n serveAs?: WebDomainName;\n primary?: boolean;\n}\n\n/** One domain as the wire carries it — the row plus its decided state, so no reader decides it again. */\nexport interface WebDomainEntry {\n domain: string;\n orgId: string | null;\n serveAs: WebDomainName;\n primary: boolean;\n /** `primaryHost(entry)` — the name that serves */\n host: string;\n state: WebDomainState;\n certState: WebCertState;\n records: WebDnsRecord[];\n problems: WebDomainProblem[];\n checkedAt: string | null;\n verifiedAt: string | null;\n liveAt: string | null;\n lostAt: string | null;\n /** the day a domain over a downgraded plan stops (CD-D12), or a lost one detaches (CD-D10); null otherwise */\n stopsAt: string | null;\n}\n\n/** `GET /instances/me/domains` (and every write's answer). */\nexport interface WebDomainAnswer {\n domains: WebDomainEntry[];\n /** how many own domains the plan includes (CD-D4) */\n limit: number;\n /** the studio's `<studio>.iox.studio` — the CNAME's value and the admin origin */\n studioHost: string;\n}\n\n/** iox-cms's answer to the admin: the control plane's, plus whether THIS user may add, remove or pick the primary (CD-D13). */\nexport interface WebDomainView extends WebDomainAnswer {\n mayChange: boolean;\n}\n\n/** 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`). */\nexport interface WebDomainRefusalBody {\n code: WebDomainRefusal;\n message: string;\n}\n\n/** No domains: what a studio whose control plane is unreachable or whose plan includes none reads. */\nexport const NO_WEB_DOMAINS: WebDomainAnswer = Object.freeze({ domains: [], limit: 0, studioHost: '' }) as WebDomainAnswer;\n\n/**\n * `GET api/site/resolve?host=<Host>&org=<first segment>` — what the engine learns about the site a request is for. An\n * engine that sends only `?org=` gets the answer it always got (`null` for an unknown label); `primaryHost` and `by` are\n * additive.\n */\nexport interface SiteResolveAnswer {\n orgId: string;\n label: string | null;\n isDefault: boolean;\n /** the organization's live primary host (canonical); null = the iox.studio address is canonical */\n primaryHost: string | null;\n by: SiteResolvedBy;\n}\n","/**\n * @vectoriox/iox-ui/domain-core — a studio's own web address (custom-domains-plan CD0), FRAMEWORK-FREE: what a domain\n * is (`webDomainRefusal`, `registrableDomain`), the three records to copy, the ONE state rule (`webDomainState`, R-CD1),\n * which host serves an organization (`orgPrimaryHost`, the host table) and where an old address 301s (`orgPathRedirect`).\n * The control plane, iox-cms, the admin and the SSR engine all read it. It imports nothing.\n * ⚠️ Not re-exported from the main entry. Consumers wire the usual trio — ng-package raw-ts assets, jest\n * moduleNameMapper, tsconfig paths — or `nest start` dies with ERR_REQUIRE_ESM.\n */\nexport * from './domain-vocabulary';\nexport * from './web-domain';\nexport * from './org-path-redirect';\nexport * from './domain-wire';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":"AAAA;;;;AAIG;AAEH;;;AAGG;IACS;AAAZ,CAAA,UAAY,cAAc,EAAA;;AAEtB,IAAA,cAAA,CAAA,QAAA,CAAA,GAAA,SAAkB;;AAElB,IAAA,cAAA,CAAA,SAAA,CAAA,GAAA,SAAmB;;AAEnB,IAAA,cAAA,CAAA,aAAA,CAAA,GAAA,aAA2B;;AAE3B,IAAA,cAAA,CAAA,MAAA,CAAA,GAAA,MAAa;;AAEb,IAAA,cAAA,CAAA,QAAA,CAAA,GAAA,QAAiB;;AAEjB,IAAA,cAAA,CAAA,MAAA,CAAA,GAAA,MAAa;AACjB,CAAC,EAbW,cAAc,KAAd,cAAc,GAAA,EAAA,CAAA,CAAA;AAe1B;IACY;AAAZ,CAAA,UAAY,YAAY,EAAA;AACpB,IAAA,YAAA,CAAA,MAAA,CAAA,GAAA,MAAa;AACb,IAAA,YAAA,CAAA,SAAA,CAAA,GAAA,SAAmB;AACnB,IAAA,YAAA,CAAA,OAAA,CAAA,GAAA,OAAe;AACf,IAAA,YAAA,CAAA,QAAA,CAAA,GAAA,QAAiB;AACjB,IAAA,YAAA,CAAA,UAAA,CAAA,GAAA,UAAqB;AACzB,CAAC,EANW,YAAY,KAAZ,YAAY,GAAA,EAAA,CAAA,CAAA;AAQxB;IACY;AAAZ,CAAA,UAAY,gBAAgB,EAAA;;AAExB,IAAA,gBAAA,CAAA,KAAA,CAAA,GAAA,KAAW;;AAEX,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