@happyvertical/smrt-sites 0.60.18 → 0.61.1

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/AGENTS.md CHANGED
@@ -7,6 +7,8 @@ Multi-tenant site lifecycle management with agent bindings.
7
7
  - **Site**: `domain` (unique per tenant), `tier` (free/standard/premium), `portalConfig` JSON, database connection, `provisioningStatus`/`provisioningTimestamp`. Status: draft/active/suspended/archived.
8
8
  - **SiteAgentBinding**: junction linking sites to agent classes. Per-site `config` overrides and `priority` ordering. `conflictColumns: ['site_id', 'agent_class']`.
9
9
 
10
+ - **DnsZone** (`dns_zones`, apex `name`), **Domain** (`domains`, `zoneId` FK + `hostname`), **ProjectDomain** (`project_domains`, `domainId` FK, `projectId` `@crossPackageRef('@happyvertical/smrt-projects:Project')`, `role`). Named `DnsZone` because smrt-properties already registers `Zone`. `DomainService`: `domainsByZone(tenantId, zoneId)`, `domainsByProject(tenantId, projectId, role?)`, `unassignedDomains(tenantId)`; `ProjectDomainCollection.assign(domain, projectId, role?, tenantId?)` is idempotent, takes the tenant from the domain, and rejects a mismatched `tenantId`. `Site.domain` stays a string.
11
+
10
12
  ## SiteService
11
13
 
12
14
  Stateless lifecycle ops: `activate()`, `suspend()`, `archive()`. `bindAgent()` handles upsert (update config if exists, create if not).
package/README.md CHANGED
@@ -57,6 +57,20 @@ Sites progress through four statuses: `draft` -> `active` -> `suspended` -> `arc
57
57
 
58
58
  `SiteAgentBinding` is a junction table linking sites to agent classes. Each binding has a `priority` (higher values execute first), an `enabled` flag, and optional per-site `config` overrides stored as JSON. The `bindAgent()` method upserts -- updating config if a binding already exists, creating one if not. `findEnabled()` returns bindings sorted by priority descending.
59
59
 
60
+ ### Zones, domains, and project links
61
+
62
+ `DnsZone` is an apex (`example.com`); `Domain` is one hostname under a zone (`work.example.com`, FK `zoneId`); `ProjectDomain` links a domain to a project with a `role` (`production`, `staging`, `preview`, `mail`, `redirect`, `other`). One zone hosts many projects. `projectId` is a `@crossPackageRef` to `@happyvertical/smrt-projects:Project` (no package dependency). The zone model is `DnsZone`, not `Zone`, because `@happyvertical/smrt-properties` already registers a `Zone`.
63
+
64
+ ```typescript
65
+ const service = new DomainService({ domains, links });
66
+ await links.assign(domain, projectId, 'production'); // idempotent; tenant from the domain
67
+ await service.domainsByZone(tenantId, zone.id);
68
+ await service.domainsByProject(tenantId, projectId, 'staging'); // role optional
69
+ await service.unassignedDomains(tenantId); // domains with no project link
70
+ ```
71
+
72
+ `Site.domain` remains a plain string; it is not yet linked to `Domain`.
73
+
60
74
  ### Portal configuration
61
75
 
62
76
  Sites store theme, branding, and navigation settings in `portalConfig` as JSON. Use `getPortalConfig()`/`setPortalConfig()` for type-safe access. Both models require tenant context (`@TenantScoped({ mode: 'required' })`).
@@ -0,0 +1,11 @@
1
+ /**
2
+ * DnsZoneCollection - Collection manager for DnsZone objects
3
+ */
4
+ import { SmrtCollection } from '@happyvertical/smrt-core';
5
+ import { DnsZone } from "../models/DnsZone.js";
6
+ export declare class DnsZoneCollection extends SmrtCollection<DnsZone> {
7
+ static readonly _itemClass: typeof DnsZone;
8
+ /** Find a zone by apex name */
9
+ findByName(name: string): Promise<DnsZone | null>;
10
+ }
11
+ //# sourceMappingURL=DnsZoneCollection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DnsZoneCollection.d.ts","sourceRoot":"","sources":["../../src/collections/DnsZoneCollection.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAmB,CAAC;AAE5C,qBAAa,iBAAkB,SAAQ,cAAc,CAAC,OAAO,CAAC;IAC5D,MAAM,CAAC,QAAQ,CAAC,UAAU,iBAAW;IAErC,+BAA+B;IACzB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC;CAIxD"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * DomainCollection - Collection manager for Domain objects
3
+ */
4
+ import { SmrtCollection } from '@happyvertical/smrt-core';
5
+ import { Domain } from "../models/Domain.js";
6
+ export declare class DomainCollection extends SmrtCollection<Domain> {
7
+ static readonly _itemClass: typeof Domain;
8
+ /** Find a domain by hostname */
9
+ findByHostname(hostname: string): Promise<Domain | null>;
10
+ /** All domains under a zone */
11
+ findByZone(zoneId: string): Promise<Domain[]>;
12
+ }
13
+ //# sourceMappingURL=DomainCollection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DomainCollection.d.ts","sourceRoot":"","sources":["../../src/collections/DomainCollection.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAkB,CAAC;AAE1C,qBAAa,gBAAiB,SAAQ,cAAc,CAAC,MAAM,CAAC;IAC1D,MAAM,CAAC,QAAQ,CAAC,UAAU,gBAAU;IAEpC,gCAAgC;IAC1B,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAK9D,+BAA+B;IACzB,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;CAGpD"}
@@ -0,0 +1,26 @@
1
+ /**
2
+ * ProjectDomainCollection - Collection manager for ProjectDomain links
3
+ */
4
+ import { SmrtJunction } from '@happyvertical/smrt-core';
5
+ import type { Domain } from "../models/Domain.js";
6
+ import { ProjectDomain } from "../models/ProjectDomain.js";
7
+ import type { DomainRole } from "../types.js";
8
+ export declare class ProjectDomainCollection extends SmrtJunction<ProjectDomain> {
9
+ static readonly _itemClass: typeof ProjectDomain;
10
+ protected leftField: string;
11
+ protected rightField: string;
12
+ protected sortField: string | null;
13
+ protected positionField: string | null;
14
+ /** Links for a domain (alias of `byLeft`) */
15
+ findByDomain(domainId: string): Promise<ProjectDomain[]>;
16
+ /** Links for a project (alias of `byRight`) */
17
+ findByProject(projectId: string): Promise<ProjectDomain[]>;
18
+ findByRole(role: DomainRole): Promise<ProjectDomain[]>;
19
+ /**
20
+ * Link a domain to a project with a role; idempotent per
21
+ * (domain, project, role). The link's tenant is taken from the domain;
22
+ * an explicit `tenantId` that differs from it is rejected.
23
+ */
24
+ assign(domain: Domain, projectId: string, role?: DomainRole, tenantId?: string): Promise<ProjectDomain>;
25
+ }
26
+ //# sourceMappingURL=ProjectDomainCollection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ProjectDomainCollection.d.ts","sourceRoot":"","sources":["../../src/collections/ProjectDomainCollection.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,YAAY,EAAQ,MAAM,0BAA0B,CAAC;AAC9D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAkB,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,4BAAyB,CAAC;AACxD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAU,CAAC;AAI3C,qBACa,uBAAwB,SAAQ,YAAY,CAAC,aAAa,CAAC;IACtE,MAAM,CAAC,QAAQ,CAAC,UAAU,uBAAiB;IAC3C,SAAS,CAAC,SAAS,SAAc;IACjC,SAAS,CAAC,UAAU,SAAe;IAEnC,SAAS,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAQ;IAC1C,SAAS,CAAC,aAAa,EAAE,MAAM,GAAG,IAAI,CAAQ;IAE9C,6CAA6C;IACvC,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;IAI9D,+CAA+C;IACzC,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;IAI1D,UAAU,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;IAI5D;;;;OAIG;IACG,MAAM,CACV,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,EACjB,IAAI,GAAE,UAAyB,EAC/B,QAAQ,CAAC,EAAE,MAAM,GAChB,OAAO,CAAC,aAAa,CAAC;CAsB1B"}
package/dist/index.d.ts CHANGED
@@ -5,16 +5,25 @@
5
5
  *
6
6
  * Provides models, collections, and services for managing deployable
7
7
  * websites within a tenant hierarchy, including agent binding and
8
- * infrastructure provisioning tracking.
8
+ * infrastructure provisioning tracking, plus DNS zone / domain /
9
+ * project-domain records.
9
10
  *
10
11
  * @packageDocumentation
11
12
  */
12
13
  import './__smrt-register__.js';
14
+ export { DnsZoneCollection } from "./collections/DnsZoneCollection.js";
15
+ export { DomainCollection } from "./collections/DomainCollection.js";
16
+ export { ProjectDomainCollection } from "./collections/ProjectDomainCollection.js";
13
17
  export { SiteAgentBindingCollection } from "./collections/SiteAgentBindingCollection.js";
14
18
  export { SiteCollection } from "./collections/SiteCollection.js";
19
+ export { DnsZone } from "./models/DnsZone.js";
20
+ export { Domain } from "./models/Domain.js";
21
+ export { ProjectDomain } from "./models/ProjectDomain.js";
15
22
  export { Site } from "./models/Site.js";
16
23
  export { SiteAgentBinding } from "./models/SiteAgentBinding.js";
24
+ export type { DomainServiceOptions } from "./services/DomainService.js";
25
+ export { DomainService } from "./services/DomainService.js";
17
26
  export type { SiteServiceOptions } from "./services/SiteService.js";
18
27
  export { SiteService } from "./services/SiteService.js";
19
- export type { CreateSiteData, ProvisioningStatus, SiteAgentBindingOptions, SiteOptions, SitePortalConfig, SiteStatus, SiteTier, } from "./types.js";
28
+ export type { CreateSiteData, DnsZoneOptions, DomainOptions, DomainRole, ProjectDomainOptions, ProvisioningStatus, SiteAgentBindingOptions, SiteOptions, SitePortalConfig, SiteStatus, SiteTier, } from "./types.js";
20
29
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAKH,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