@wopr-network/platform-ui-core 1.13.0 → 1.14.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wopr-network/platform-ui-core",
3
- "version": "1.13.0",
3
+ "version": "1.14.0",
4
4
  "description": "Brand-agnostic AI agent platform UI — deploy as any brand via env vars",
5
5
  "repository": {
6
6
  "type": "git",
@@ -7,6 +7,13 @@
7
7
  * `setBrandConfig()` in their root layout before anything renders.
8
8
  */
9
9
 
10
+ export interface BrandDomain {
11
+ /** The hostname (e.g. "holyship.wtf", "holyship.dev") */
12
+ host: string;
13
+ /** Role: "canonical" is the real site, "redirect" 301s to canonical */
14
+ role: "canonical" | "redirect";
15
+ }
16
+
10
17
  export interface BrandConfig {
11
18
  /** Product name shown to users (e.g. "WOPR Bot", "Paperclip") */
12
19
  productName: string;
@@ -14,9 +21,26 @@ export interface BrandConfig {
14
21
  /** Short brand identifier (e.g. "WOPR", "Paperclip") */
15
22
  brandName: string;
16
23
 
17
- /** Primary domain (e.g. "wopr.bot", "runpaperclip.com") */
24
+ /**
25
+ * Primary domain (e.g. "wopr.bot", "runpaperclip.com").
26
+ * When `domains` is set, this returns the canonical domain's host.
27
+ */
18
28
  domain: string;
19
29
 
30
+ /**
31
+ * All brand domains with roles. Optional — when unset, `domain` is
32
+ * used as the sole canonical domain.
33
+ *
34
+ * Example:
35
+ * ```
36
+ * domains: [
37
+ * { host: "holyship.wtf", role: "canonical" },
38
+ * { host: "holyship.dev", role: "redirect" },
39
+ * ]
40
+ * ```
41
+ */
42
+ domains?: BrandDomain[];
43
+
20
44
  /** App subdomain (e.g. "app.wopr.bot", "app.runpaperclip.com") */
21
45
  appDomain: string;
22
46
 
@@ -169,9 +193,27 @@ export function setBrandConfig(config: Partial<BrandConfig>): void {
169
193
  if (!config.eventPrefix) base.eventPrefix = sp;
170
194
  if (!config.tenantCookieName) base.tenantCookieName = `${sp}_tenant_id`;
171
195
  }
196
+ // When domains[] is provided, derive domain from the canonical entry.
197
+ if (config.domains?.length) {
198
+ const canonical = config.domains.find((d) => d.role === "canonical");
199
+ if (canonical) {
200
+ base.domain = canonical.host;
201
+ }
202
+ }
172
203
  _config = base;
173
204
  }
174
205
 
206
+ /** Get all redirect domains (non-canonical). Empty if domains[] not set. */
207
+ export function getRedirectDomains(): BrandDomain[] {
208
+ return (_config.domains ?? []).filter((d) => d.role === "redirect");
209
+ }
210
+
211
+ /** Get the canonical domain entry, or synthesize one from `domain`. */
212
+ export function getCanonicalDomain(): BrandDomain {
213
+ const canonical = (_config.domains ?? []).find((d) => d.role === "canonical");
214
+ return canonical ?? { host: _config.domain, role: "canonical" };
215
+ }
216
+
175
217
  /** Get the current brand configuration. */
176
218
  export function getBrandConfig(): BrandConfig {
177
219
  return _config;