@geekmidas/constructs 10.0.0-alpha.186 → 10.0.0-alpha.188

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/dist/site.cjs CHANGED
@@ -32,15 +32,6 @@ let _geekmidas_manifest = require("@geekmidas/manifest");
32
32
  * is not a site — it is reached by a scheme, not a URL — and is its own
33
33
  * construct: see `MobileApp`.
34
34
  */
35
- /** `subdomain: '*'` without `hosts`: nothing would say which hosts are tenants. */
36
- var WildcardSiteNeedsHosts = class extends Error {
37
- id;
38
- constructor(id) {
39
- super(`'${id}' answers on every subdomain, so it has to say which of them are tenants: pass \`hosts\`, a GET endpoint answering 200 for a host it serves and 404 otherwise.`);
40
- this.id = id;
41
- this.name = "WildcardSiteNeedsHosts";
42
- }
43
- };
44
35
  /** `hosts` on a site with one host, where there is nothing to check. */
45
36
  var SiteHostsNeedsWildcard = class extends Error {
46
37
  id;
@@ -108,7 +99,6 @@ var StaticSite = class StaticSite {
108
99
  register: (options) => require_construct_interface.publicUrl(options, this.keys.url)
109
100
  };
110
101
  const wildcard = config.subdomain === _geekmidas_manifest.WILDCARD_SUBDOMAIN;
111
- if (wildcard && !config.hosts) throw new WildcardSiteNeedsHosts(this.id);
112
102
  if (!wildcard && config.hosts) throw new SiteHostsNeedsWildcard(this.id);
113
103
  if (wildcard && config.root) throw new WildcardSiteCannotBeRoot(this.id);
114
104
  (0, _geekmidas_manifest.assertHostLabels)({
@@ -119,7 +109,7 @@ var StaticSite = class StaticSite {
119
109
  });
120
110
  const variant = config.variant ?? "static";
121
111
  if (config.prerender && variant !== "static") throw new PrerenderNeedsStaticSite(this.id, variant);
122
- if (config.hosts && config.hosts.method.toUpperCase() !== "GET") throw new SiteHostsNotGet(this.id, config.hosts.method, config.hosts.route);
112
+ if (config.hosts && "method" in config.hosts && config.hosts.method.toUpperCase() !== "GET") throw new SiteHostsNotGet(this.id, config.hosts.method, config.hosts.route);
123
113
  }
124
114
  /**
125
115
  * What this site calls.
@@ -145,6 +135,7 @@ var StaticSite = class StaticSite {
145
135
  }
146
136
  declare() {
147
137
  const { hosts } = this.config;
138
+ const wildcard = this.config.subdomain === _geekmidas_manifest.WILDCARD_SUBDOMAIN;
148
139
  return [{
149
140
  kind: "site",
150
141
  id: this.id,
@@ -154,7 +145,7 @@ var StaticSite = class StaticSite {
154
145
  ...this.config.redirects?.length ? { redirects: [...this.config.redirects] } : {},
155
146
  ...hosts ? { hosts: {
156
147
  surface: (0, _geekmidas_manifest.canonicalId)(hosts.surface.id),
157
- path: hosts.route
148
+ path: "route" in hosts ? hosts.route : hosts.path
158
149
  } } : {},
159
150
  app: {
160
151
  path: this.config.path,
@@ -169,7 +160,7 @@ var StaticSite = class StaticSite {
169
160
  stages: [...this.config.password.stages]
170
161
  } } : {},
171
162
  ...this.config.prerender ? { prerender: this.config.prerender } : {},
172
- provides: [this.keys.url, ...hosts ? [(0, _geekmidas_manifest.providedKeyFor)(this.id, "site", "domain"), (0, _geekmidas_manifest.providedKeyFor)(this.id, "site", "protectedSubdomains")] : []]
163
+ provides: [this.keys.url, ...wildcard ? [(0, _geekmidas_manifest.providedKeyFor)(this.id, "site", "domain"), (0, _geekmidas_manifest.providedKeyFor)(this.id, "site", "protectedSubdomains")] : []]
173
164
  }];
174
165
  }
175
166
  };
@@ -197,6 +188,5 @@ Object.defineProperty(exports, "WildcardSiteCannotHaveAliases", {
197
188
  return _geekmidas_manifest.WildcardSiteCannotHaveAliases;
198
189
  }
199
190
  });
200
- exports.WildcardSiteNeedsHosts = WildcardSiteNeedsHosts;
201
191
 
202
192
  //# sourceMappingURL=site.cjs.map
package/dist/site.cjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"site.cjs","names":["canonicalId","providedKeyFor","serviceKey","publicUrl","WILDCARD_SUBDOMAIN","frontendEdgeTo"],"sources":["../src/site.ts"],"sourcesContent":["/**\n * `StaticSite` — a frontend, declared like anything else.\n *\n * The point is not that a site needs provisioning; it is that a site is the\n * *consumer* whose edges make four hand-maintained lists derivable. Declaring it\n * is what turns \"which origins does the API allow\" from something a person keeps\n * in step into something the graph already knows.\n *\n * ```ts\n * export const console = new StaticSite('Console', { path: 'apps/console' })\n * .dependsOn([api, auth]);\n * ```\n *\n * A site consumes addresses, not connections: it is built, and the values it\n * needs are inlined or fetched by its own framework, so its own edges take any\n * {@link Declarable}. Its `.service` is its public address — what a worker's\n * cron or an endpoint that builds links to it reads:\n *\n * ```ts\n * export const digest = worker\n * .cron('rate(1 day)')\n * .dependsOn([web])\n * .handle(async ({ services }) => link(services.web, '/inbox'));\n * ```\n *\n * Only the static variant ships. SSR deploy shapes are unstable and each one is\n * its own maintenance, so they follow rather than arrive together. A mobile app\n * is not a site — it is reached by a scheme, not a URL — and is its own\n * construct: see `MobileApp`.\n */\n\nimport {\n\tassertHostLabels,\n\ttype ConstructName,\n\tcanonicalId,\n\ttype Declaration,\n\ttype Dependency,\n\tprovidedKeyFor,\n\ttype SiteDeclaration,\n\tserviceKey,\n\tWILDCARD_SUBDOMAIN,\n} from '@geekmidas/manifest';\n\n/** Thrown at construction for an alias or redirect that cannot be a host label. */\nexport {\n\tHostLabelBothAliasAndRedirect,\n\tInvalidHostLabel,\n\tWildcardSiteCannotHaveAliases,\n} from '@geekmidas/manifest';\n\nimport type { Service } from '@geekmidas/services';\nimport {\n\ttype Construct,\n\ttype Declarable,\n\tfrontendEdgeTo,\n\tpublicUrl,\n} from './construct-interface';\nimport type { RandomPassword } from './random-password';\nimport type { DeployedStage } from './stages';\nimport type { Telemetry } from './telemetry';\n\n/**\n * Where a site's source lives, and the little else a layout can differ by.\n *\n * Only `path` is required: `new StaticSite('Web', { path: 'apps/web' })` is a\n * complete site.\n */\nexport interface StaticSiteConfig {\n\t/**\n\t * Where its source lives, relative to the workspace root — `'apps/web'`.\n\t *\n\t * Required, the same field `RestApi` and `BetterAuth` take. It was\n\t * inferred from the id, which made a site's home whatever was on disk.\n\t */\n\tpath: string;\n\t/**\n\t * The label it answers on under a stage's domain — `api` for\n\t * `api.myapp.com`, from `domains` — and under the project locally,\n\t * `api.myapp.localhost`. Absent, its id kebab-cased.\n\t *\n\t * `'*'` answers on every subdomain nothing else does — one host per\n\t * tenant, `acme.myapp.com` — and then `hosts` names which of them are\n\t * real. Every other app keeps its own host, and a project has at most one\n\t * such site.\n\t */\n\tsubdomain?: string;\n\t/**\n\t * More labels it answers on under the stage's domain, exactly as on its\n\t * own: each a host the site really serves, and an origin every surface it\n\t * depends on trusts. Its own host stays canonical (`<ID>_URL`).\n\t */\n\taliases?: readonly string[];\n\t/**\n\t * Labels that answer with a permanent (301) redirect to its own host,\n\t * path and query kept — `['www']` sends `www.myapp.com` to `myapp.com`.\n\t * Nothing answers on a host unless a construct names it, so there is no\n\t * automatic `www`. Sites only: an API client does not reliably follow a\n\t * redirect on a `POST`.\n\t */\n\tredirects?: readonly string[];\n\t/**\n\t * With `subdomain: '*'`, the route that says which hosts are tenants: an\n\t * exported `GET` endpoint the edge asks before it serves a host,\n\t * `?domain=<host>`, answering `200` for a tenant and `404` otherwise.\n\t *\n\t * It runs without a session and belongs to no public API.\n\t */\n\thosts?: SiteHostsEndpoint;\n\t/**\n\t * The port it answers on locally.\n\t *\n\t * Normally omitted: ports are assigned in a stable order, so adding a site\n\t * does not renumber the ones already running.\n\t */\n\tport?: number;\n\t/**\n\t * Modules to import when sniffing which env vars this site reads.\n\t *\n\t * A frontend's values are inlined at build time, so the build has to know\n\t * which ones it reads before it reads them.\n\t */\n\tconfig?: { client?: string; server?: string };\n\t/**\n\t * Whether the base domain points at this site.\n\t *\n\t * A project with one site needs this no more than a project with one\n\t * database needs to say which database. It matters when there are several\n\t * and none is called `web`: the base domain then belongs to whichever site\n\t * says so, rather than to whichever file the glob happened to reach first.\n\t */\n\troot?: boolean;\n\t/**\n\t * Which framework builds it.\n\t *\n\t * It selects how values are delivered — `VITE_`, `NEXT_PUBLIC_`, a fetched\n\t * `config.json` — and never which values there are. One neutral name from the\n\t * construct, one serialisation per framework, the same rule as everywhere\n\t * else.\n\t */\n\tvariant?: SiteDeclaration['variant'];\n\t/**\n\t * What the site emits — the `Telemetry` construct. An edge to the node and\n\t * nothing more for now: a site is handed none of its server keys, and the\n\t * browser half (propagation from the generated client, then a browser SDK\n\t * exporting through the API) builds on this edge.\n\t */\n\ttelemetry?: Telemetry;\n\t/**\n\t * A login the site is served behind on the stages named, so a staging\n\t * build is not public while it is tried.\n\t *\n\t * ```ts\n\t * export const sitePassword = new RandomPassword('SitePassword');\n\t *\n\t * export const web = new StaticSite('Web', {\n\t * path: 'apps/web',\n\t * password: { secret: sitePassword, stages: ['staging'] },\n\t * });\n\t * ```\n\t *\n\t * The edge asks for it with HTTP basic auth before a request reaches the\n\t * site: the user is the stage's name, the password the `RandomPassword`'s\n\t * value on that stage. Like any `RandomPassword` it is generated on the\n\t * first deploy and kept, and one set by hand wins. It is not an edge — the\n\t * site is handed none of it — so export it from a constructs file of its\n\t * own, as any construct is.\n\t *\n\t * The compose target alone serves it so far; another refuses the stage\n\t * rather than serving it publicly.\n\t */\n\tpassword?: {\n\t\tsecret: RandomPassword;\n\t\tstages: readonly [DeployedStage, ...DeployedStage[]];\n\t};\n\t/**\n\t * `'stage'` for a `static` site that pre-renders data at build time\n\t * (vite-ssg and similar): its build fetches from the APIs it\n\t * `.dependsOn()`, and bakes their answers into its files.\n\t *\n\t * ```ts\n\t * new StaticSite('Web', {\n\t * path: 'apps/web',\n\t * variant: 'static',\n\t * prerender: 'stage',\n\t * }).dependsOn([api]);\n\t * ```\n\t *\n\t * The deploy then builds the site only once those APIs are up and\n\t * healthy on the stage, and the build reaches them at their public\n\t * addresses, as a browser would. Without it, a site is built offline,\n\t * before its stage runs (`GKM_BUILD_OFFLINE=1`), and nothing at runtime\n\t * can fill a page built without its data.\n\t *\n\t * Opt-in, because the image then holds that stage's data: the same commit\n\t * builds a different image per stage, and `gkm compose --build --push`\n\t * needs the stage it builds for already running.\n\t */\n\tprerender?: 'stage';\n}\n\n/**\n * The shape of the endpoint `hosts` names — read structurally, so a site\n * module never loads the endpoint machinery to say which route it means.\n */\nexport interface SiteHostsEndpoint {\n\troute: string;\n\tmethod: string;\n\tsurface: { id: string };\n}\n\n/** `subdomain: '*'` without `hosts`: nothing would say which hosts are tenants. */\nexport class WildcardSiteNeedsHosts extends Error {\n\tconstructor(readonly id: string) {\n\t\tsuper(\n\t\t\t`'${id}' answers on every subdomain, so it has to say which of them ` +\n\t\t\t\t`are tenants: pass \\`hosts\\`, a GET endpoint answering 200 for a ` +\n\t\t\t\t`host it serves and 404 otherwise.`,\n\t\t);\n\t\tthis.name = 'WildcardSiteNeedsHosts';\n\t}\n}\n\n/** `hosts` on a site with one host, where there is nothing to check. */\nexport class SiteHostsNeedsWildcard extends Error {\n\tconstructor(readonly id: string) {\n\t\tsuper(\n\t\t\t`'${id}' names a \\`hosts\\` check but answers on one host. ` +\n\t\t\t\t`Declare \\`subdomain: '*'\\` to serve every subdomain, or drop \\`hosts\\`.`,\n\t\t);\n\t\tthis.name = 'SiteHostsNeedsWildcard';\n\t}\n}\n\n/** A `hosts` endpoint that is not a `GET`: the edge only ever asks with one. */\nexport class SiteHostsNotGet extends Error {\n\tconstructor(\n\t\treadonly id: string,\n\t\treadonly method: string,\n\t\treadonly route: string,\n\t) {\n\t\tsuper(\n\t\t\t`'${id}' checks its hosts with ${method} ${route}, but the edge asks ` +\n\t\t\t\t`with GET ${route}?domain=<host>. Make it a GET endpoint.`,\n\t\t);\n\t\tthis.name = 'SiteHostsNotGet';\n\t}\n}\n\n/**\n * `prerender: 'stage'` on a site that renders its pages on a server, where a\n * page renders on its first request — which the deploy's warm-up makes — and\n * needs no data at build.\n */\nexport class PrerenderNeedsStaticSite extends Error {\n\tconstructor(\n\t\treadonly id: string,\n\t\treadonly variant: SiteDeclaration['variant'],\n\t) {\n\t\tsuper(\n\t\t\t`'${id}' is a '${variant}' site, which renders its pages on its own ` +\n\t\t\t\t`server, so it never needs its APIs at build: drop \\`prerender\\`, ` +\n\t\t\t\t`and render data-backed pages on request (the deploy warms them). ` +\n\t\t\t\t`\\`prerender: 'stage'\\` is for a 'static' site that bakes data into ` +\n\t\t\t\t`its files.`,\n\t\t);\n\t\tthis.name = 'PrerenderNeedsStaticSite';\n\t}\n}\n\n/** A wildcard site that says it holds the base domain. */\nexport class WildcardSiteCannotBeRoot extends Error {\n\tconstructor(readonly id: string) {\n\t\tsuper(\n\t\t\t`'${id}' answers on every subdomain, so it cannot also hold the base ` +\n\t\t\t\t`domain. Drop \\`root: true\\`, and declare the site the base domain ` +\n\t\t\t\t`points at separately.`,\n\t\t);\n\t\tthis.name = 'WildcardSiteCannotBeRoot';\n\t}\n}\n\nexport class StaticSite<TName extends string = string>\n\timplements Declarable<TName>, Construct<TName, string>\n{\n\treadonly id: TName;\n\treadonly keys: { url: string };\n\n\t/**\n\t * Its public address, `https://web.example.com` — a string, no await. The\n\t * same `<ID>_URL` on every command and stage, so a link built from it opens\n\t * in a browser.\n\t */\n\treadonly service: Service<Uncapitalize<TName>, string>;\n\n\tconstructor(\n\t\tid: ConstructName<TName>,\n\t\tprivate readonly config: StaticSiteConfig,\n\t\t/**\n\t\t * Internal: how `.dependsOn()` carries edges into the copy it returns.\n\t\t * Written as a parameter rather than a mutable field so the builder can\n\t\t * stay immutable without a clone method, the same shape\n\t\t * `KyselyDatabase` uses for its derived forms.\n\t\t */\n\t\tprivate readonly dependencies: readonly Dependency[] = [],\n\t) {\n\t\tthis.id = canonicalId(id as string) as TName;\n\t\tthis.keys = { url: providedKeyFor(this.id, 'site', 'url') };\n\t\t// A field, not a getter: consumers cache services by object identity.\n\t\tthis.service = {\n\t\t\tserviceName: serviceKey(this.id) as Uncapitalize<TName>,\n\t\t\tregister: (options) => publicUrl(options, this.keys.url),\n\t\t};\n\n\t\tconst wildcard = config.subdomain === WILDCARD_SUBDOMAIN;\n\t\tif (wildcard && !config.hosts) throw new WildcardSiteNeedsHosts(this.id);\n\t\tif (!wildcard && config.hosts) throw new SiteHostsNeedsWildcard(this.id);\n\t\tif (wildcard && config.root) throw new WildcardSiteCannotBeRoot(this.id);\n\t\tassertHostLabels({\n\t\t\tid: this.id,\n\t\t\t...(config.subdomain ? { subdomain: config.subdomain } : {}),\n\t\t\t...(config.aliases ? { aliases: config.aliases } : {}),\n\t\t\t...(config.redirects ? { redirects: config.redirects } : {}),\n\t\t});\n\t\tconst variant = config.variant ?? 'static';\n\t\tif (config.prerender && variant !== 'static') {\n\t\t\tthrow new PrerenderNeedsStaticSite(this.id, variant);\n\t\t}\n\t\tif (config.hosts && config.hosts.method.toUpperCase() !== 'GET') {\n\t\t\tthrow new SiteHostsNotGet(\n\t\t\t\tthis.id,\n\t\t\t\tconfig.hosts.method,\n\t\t\t\tconfig.hosts.route,\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * What this site calls.\n\t *\n\t * Immutable, like every other builder here: it returns a new site rather than\n\t * mutating this one, so a module that exports both a base and a variant of it\n\t * cannot have the second silently change the first.\n\t *\n\t * Takes {@link Declarable} rather than {@link Consumable} because a site's\n\t * edge is a build-time link and not a service injection — requiring a client\n\t * would exclude exactly the surfaces a frontend actually depends on.\n\t *\n\t * A plain edge to a `FileServer` is to its public face: the site is built\n\t * with the address its objects are served on, and handed nothing that\n\t * writes to the bucket. A plain edge to an `ObjectStorage` is to where its\n\t * links are signed (`<PREFIX><T>_SIGNED_ORIGIN`), and to nothing else of\n\t * it. `.dependsOn([assets.server])` or `.dependsOn([documents.server])`\n\t * asks for the bucket and its credentials too, for a server half that\n\t * uploads or presigns.\n\t */\n\tdependsOn(constructs: readonly Declarable[]): StaticSite<TName> {\n\t\treturn new StaticSite<TName>(this.id as ConstructName<TName>, this.config, [\n\t\t\t...this.dependencies,\n\t\t\t...constructs.map(frontendEdgeTo),\n\t\t]);\n\t}\n\n\tdeclare(): Declaration[] {\n\t\tconst { hosts } = this.config;\n\t\treturn [\n\t\t\t{\n\t\t\t\tkind: 'site',\n\t\t\t\tid: this.id,\n\t\t\t\tvariant: this.config.variant ?? 'static',\n\t\t\t\t...(this.config.subdomain ? { subdomain: this.config.subdomain } : {}),\n\t\t\t\t...(this.config.aliases?.length\n\t\t\t\t\t? { aliases: [...this.config.aliases] }\n\t\t\t\t\t: {}),\n\t\t\t\t...(this.config.redirects?.length\n\t\t\t\t\t? { redirects: [...this.config.redirects] }\n\t\t\t\t\t: {}),\n\t\t\t\t...(hosts\n\t\t\t\t\t? {\n\t\t\t\t\t\t\thosts: {\n\t\t\t\t\t\t\t\tsurface: canonicalId(hosts.surface.id),\n\t\t\t\t\t\t\t\tpath: hosts.route,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t}\n\t\t\t\t\t: {}),\n\t\t\t\tapp: {\n\t\t\t\t\tpath: this.config.path,\n\t\t\t\t\t...(this.config.port ? { port: this.config.port } : {}),\n\t\t\t\t\t...(this.config.config ? { config: this.config.config } : {}),\n\t\t\t\t},\n\t\t\t\t...(this.config.root ? { root: true } : {}),\n\t\t\t\tdependencies: this.dependencies,\n\t\t\t\t...(this.config.telemetry\n\t\t\t\t\t? { telemetry: this.config.telemetry.id }\n\t\t\t\t\t: {}),\n\t\t\t\t...(this.config.password\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tpassword: {\n\t\t\t\t\t\t\t\tsecret: this.config.password.secret.id,\n\t\t\t\t\t\t\t\tstages: [...this.config.password.stages],\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t}\n\t\t\t\t\t: {}),\n\t\t\t\t...(this.config.prerender ? { prerender: this.config.prerender } : {}),\n\t\t\t\tprovides: [\n\t\t\t\t\tthis.keys.url,\n\t\t\t\t\t...(hosts\n\t\t\t\t\t\t? [\n\t\t\t\t\t\t\t\tprovidedKeyFor(this.id, 'site', 'domain'),\n\t\t\t\t\t\t\t\tprovidedKeyFor(this.id, 'site', 'protectedSubdomains'),\n\t\t\t\t\t\t\t]\n\t\t\t\t\t\t: []),\n\t\t\t\t],\n\t\t\t},\n\t\t];\n\t}\n}\n"],"mappings":";;;;;;;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AK,OAAO,WAAW,SACxB,EAAE,WAAW,CAAC,GAAG,KAAK,OAAO,SAAS,EAAE,IACxC,CAAC;GACJ,GAAI,QACD,EACA,OAAO;IACN,UAAA,GAASL,oBAAAA,YAAAA,CAAY,MAAM,QAAQ,EAAE;IACrC,MAAM,MAAM;GACb,EACD,IACC,CAAC;GACJ,KAAK;IACJ,MAAM,KAAK,OAAO;IAClB,GAAI,KAAK,OAAO,OAAO,EAAE,MAAM,KAAK,OAAO,KAAK,IAAI,CAAC;IACrD,GAAI,KAAK,OAAO,SAAS,EAAE,QAAQ,KAAK,OAAO,OAAO,IAAI,CAAC;GAC5D;GACA,GAAI,KAAK,OAAO,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;GACzC,cAAc,KAAK;GACnB,GAAI,KAAK,OAAO,YACb,EAAE,WAAW,KAAK,OAAO,UAAU,GAAG,IACtC,CAAC;GACJ,GAAI,KAAK,OAAO,WACb,EACA,UAAU;IACT,QAAQ,KAAK,OAAO,SAAS,OAAO;IACpC,QAAQ,CAAC,GAAG,KAAK,OAAO,SAAS,MAAM;GACxC,EACD,IACC,CAAC;GACJ,GAAI,KAAK,OAAO,YAAY,EAAE,WAAW,KAAK,OAAO,UAAU,IAAI,CAAC;GACpE,UAAU,CACT,KAAK,KAAK,KACV,GAAI,QACD,EAAA,GACAC,oBAAAA,eAAAA,CAAe,KAAK,IAAI,QAAQ,QAAQ,IAAA,GACxCA,oBAAAA,eAAAA,CAAe,KAAK,IAAI,QAAQ,qBAAqB,CACtD,IACC,CAAC,CACL;EACD,CACD;CACD;AACD"}
1
+ {"version":3,"file":"site.cjs","names":["canonicalId","providedKeyFor","serviceKey","publicUrl","WILDCARD_SUBDOMAIN","frontendEdgeTo"],"sources":["../src/site.ts"],"sourcesContent":["/**\n * `StaticSite` — a frontend, declared like anything else.\n *\n * The point is not that a site needs provisioning; it is that a site is the\n * *consumer* whose edges make four hand-maintained lists derivable. Declaring it\n * is what turns \"which origins does the API allow\" from something a person keeps\n * in step into something the graph already knows.\n *\n * ```ts\n * export const console = new StaticSite('Console', { path: 'apps/console' })\n * .dependsOn([api, auth]);\n * ```\n *\n * A site consumes addresses, not connections: it is built, and the values it\n * needs are inlined or fetched by its own framework, so its own edges take any\n * {@link Declarable}. Its `.service` is its public address — what a worker's\n * cron or an endpoint that builds links to it reads:\n *\n * ```ts\n * export const digest = worker\n * .cron('rate(1 day)')\n * .dependsOn([web])\n * .handle(async ({ services }) => link(services.web, '/inbox'));\n * ```\n *\n * Only the static variant ships. SSR deploy shapes are unstable and each one is\n * its own maintenance, so they follow rather than arrive together. A mobile app\n * is not a site — it is reached by a scheme, not a URL — and is its own\n * construct: see `MobileApp`.\n */\n\nimport {\n\tassertHostLabels,\n\ttype ConstructName,\n\tcanonicalId,\n\ttype Declaration,\n\ttype Dependency,\n\tprovidedKeyFor,\n\ttype SiteDeclaration,\n\tserviceKey,\n\tWILDCARD_SUBDOMAIN,\n} from '@geekmidas/manifest';\n\n/** Thrown at construction for an alias or redirect that cannot be a host label. */\nexport {\n\tHostLabelBothAliasAndRedirect,\n\tInvalidHostLabel,\n\tWildcardSiteCannotHaveAliases,\n} from '@geekmidas/manifest';\n\nimport type { Service } from '@geekmidas/services';\nimport {\n\ttype Construct,\n\ttype Declarable,\n\tfrontendEdgeTo,\n\tpublicUrl,\n} from './construct-interface';\nimport type { RandomPassword } from './random-password';\nimport type { DeployedStage } from './stages';\nimport type { Telemetry } from './telemetry';\n\n/**\n * Where a site's source lives, and the little else a layout can differ by.\n *\n * Only `path` is required: `new StaticSite('Web', { path: 'apps/web' })` is a\n * complete site.\n */\nexport interface StaticSiteConfig {\n\t/**\n\t * Where its source lives, relative to the workspace root — `'apps/web'`.\n\t *\n\t * Required, the same field `RestApi` and `BetterAuth` take. It was\n\t * inferred from the id, which made a site's home whatever was on disk.\n\t */\n\tpath: string;\n\t/**\n\t * The label it answers on under a stage's domain — `api` for\n\t * `api.myapp.com`, from `domains` — and under the project locally,\n\t * `api.myapp.localhost`. Absent, its id kebab-cased.\n\t *\n\t * `'*'` answers on every subdomain nothing else does — one host per\n\t * tenant, `acme.myapp.com` — and `hosts` may name the route that says\n\t * which of them are real. Every other app keeps its own host, and a project has at most one\n\t * such site.\n\t */\n\tsubdomain?: string;\n\t/**\n\t * More labels it answers on under the stage's domain, exactly as on its\n\t * own: each a host the site really serves, and an origin every surface it\n\t * depends on trusts. Its own host stays canonical (`<ID>_URL`).\n\t */\n\taliases?: readonly string[];\n\t/**\n\t * Labels that answer with a permanent (301) redirect to its own host,\n\t * path and query kept — `['www']` sends `www.myapp.com` to `myapp.com`.\n\t * Nothing answers on a host unless a construct names it, so there is no\n\t * automatic `www`. Sites only: an API client does not reliably follow a\n\t * redirect on a `POST`.\n\t */\n\tredirects?: readonly string[];\n\t/**\n\t * With `subdomain: '*'`, the route that says which hosts are tenants: a\n\t * `GET` route on a surface, asked `?domain=<host>`, answering `200` for a\n\t * tenant and `404` otherwise. Named by its surface and path, so the\n\t * construct imports no app code:\n\t *\n\t * ```ts\n\t * hosts: { surface: api, path: '/tenants/hosts' },\n\t * ```\n\t *\n\t * Optional. A deploy needs it only where the edge gets a certificate per\n\t * tenant on demand (the stack's own Caddy without `deploy.compose.tls`):\n\t * the edge asks it before issuing one, so nobody can make it request\n\t * certificates for hosts that are no tenant. Behind a wildcard\n\t * certificate — the DNS challenge, the stage's own, CloudFront's — every\n\t * label but the protected ones reaches the site, and the app answers an\n\t * unknown tenant itself. Given, `gkm dev` also asks it before serving a\n\t * host.\n\t *\n\t * `gkm` checks, where it reads the whole project, that the surface serves\n\t * `GET <path>` (`SiteHostsEndpointMissing`). The endpoint itself is still\n\t * accepted, for projects that already pass it.\n\t *\n\t * It runs without a session and belongs to no public API.\n\t */\n\thosts?: SiteHostsRoute | SiteHostsEndpoint;\n\t/**\n\t * The port it answers on locally.\n\t *\n\t * Normally omitted: ports are assigned in a stable order, so adding a site\n\t * does not renumber the ones already running.\n\t */\n\tport?: number;\n\t/**\n\t * Modules to import when sniffing which env vars this site reads.\n\t *\n\t * A frontend's values are inlined at build time, so the build has to know\n\t * which ones it reads before it reads them.\n\t */\n\tconfig?: { client?: string; server?: string };\n\t/**\n\t * Whether the base domain points at this site.\n\t *\n\t * A project with one site needs this no more than a project with one\n\t * database needs to say which database. It matters when there are several\n\t * and none is called `web`: the base domain then belongs to whichever site\n\t * says so, rather than to whichever file the glob happened to reach first.\n\t */\n\troot?: boolean;\n\t/**\n\t * Which framework builds it.\n\t *\n\t * It selects how values are delivered — `VITE_`, `NEXT_PUBLIC_`, a fetched\n\t * `config.json` — and never which values there are. One neutral name from the\n\t * construct, one serialisation per framework, the same rule as everywhere\n\t * else.\n\t */\n\tvariant?: SiteDeclaration['variant'];\n\t/**\n\t * What the site emits — the `Telemetry` construct. An edge to the node and\n\t * nothing more for now: a site is handed none of its server keys, and the\n\t * browser half (propagation from the generated client, then a browser SDK\n\t * exporting through the API) builds on this edge.\n\t */\n\ttelemetry?: Telemetry;\n\t/**\n\t * A login the site is served behind on the stages named, so a staging\n\t * build is not public while it is tried.\n\t *\n\t * ```ts\n\t * export const sitePassword = new RandomPassword('SitePassword');\n\t *\n\t * export const web = new StaticSite('Web', {\n\t * path: 'apps/web',\n\t * password: { secret: sitePassword, stages: ['staging'] },\n\t * });\n\t * ```\n\t *\n\t * The edge asks for it with HTTP basic auth before a request reaches the\n\t * site: the user is the stage's name, the password the `RandomPassword`'s\n\t * value on that stage. Like any `RandomPassword` it is generated on the\n\t * first deploy and kept, and one set by hand wins. It is not an edge — the\n\t * site is handed none of it — so export it from a constructs file of its\n\t * own, as any construct is.\n\t *\n\t * The compose target alone serves it so far; another refuses the stage\n\t * rather than serving it publicly.\n\t */\n\tpassword?: {\n\t\tsecret: RandomPassword;\n\t\tstages: readonly [DeployedStage, ...DeployedStage[]];\n\t};\n\t/**\n\t * `'stage'` for a `static` site that pre-renders data at build time\n\t * (vite-ssg and similar): its build fetches from the APIs it\n\t * `.dependsOn()`, and bakes their answers into its files.\n\t *\n\t * ```ts\n\t * new StaticSite('Web', {\n\t * path: 'apps/web',\n\t * variant: 'static',\n\t * prerender: 'stage',\n\t * }).dependsOn([api]);\n\t * ```\n\t *\n\t * The deploy then builds the site only once those APIs are up and\n\t * healthy on the stage, and the build reaches them at their public\n\t * addresses, as a browser would. Without it, a site is built offline,\n\t * before its stage runs (`GKM_BUILD_OFFLINE=1`), and nothing at runtime\n\t * can fill a page built without its data.\n\t *\n\t * Opt-in, because the image then holds that stage's data: the same commit\n\t * builds a different image per stage, and `gkm compose --build --push`\n\t * needs the stage it builds for already running.\n\t */\n\tprerender?: 'stage';\n}\n\n/**\n * The route `hosts` names, by its surface and its path — what a constructs\n * file can say without importing the endpoint from an app. The surface is\n * read structurally (its `id`), so a site module never loads the endpoint\n * machinery, and the method is always `GET`.\n */\nexport interface SiteHostsRoute {\n\tsurface: { id: string };\n\tpath: string;\n}\n\n/**\n * The endpoint itself, as `hosts` was first given — read structurally, for\n * the same reason. Prefer {@link SiteHostsRoute}: an endpoint lives in an\n * app, and a construct that imports it cannot load where that app is not.\n */\nexport interface SiteHostsEndpoint {\n\troute: string;\n\tmethod: string;\n\tsurface: { id: string };\n}\n\n/** `hosts` on a site with one host, where there is nothing to check. */\nexport class SiteHostsNeedsWildcard extends Error {\n\tconstructor(readonly id: string) {\n\t\tsuper(\n\t\t\t`'${id}' names a \\`hosts\\` check but answers on one host. ` +\n\t\t\t\t`Declare \\`subdomain: '*'\\` to serve every subdomain, or drop \\`hosts\\`.`,\n\t\t);\n\t\tthis.name = 'SiteHostsNeedsWildcard';\n\t}\n}\n\n/** A `hosts` endpoint that is not a `GET`: the edge only ever asks with one. */\nexport class SiteHostsNotGet extends Error {\n\tconstructor(\n\t\treadonly id: string,\n\t\treadonly method: string,\n\t\treadonly route: string,\n\t) {\n\t\tsuper(\n\t\t\t`'${id}' checks its hosts with ${method} ${route}, but the edge asks ` +\n\t\t\t\t`with GET ${route}?domain=<host>. Make it a GET endpoint.`,\n\t\t);\n\t\tthis.name = 'SiteHostsNotGet';\n\t}\n}\n\n/**\n * `prerender: 'stage'` on a site that renders its pages on a server, where a\n * page renders on its first request — which the deploy's warm-up makes — and\n * needs no data at build.\n */\nexport class PrerenderNeedsStaticSite extends Error {\n\tconstructor(\n\t\treadonly id: string,\n\t\treadonly variant: SiteDeclaration['variant'],\n\t) {\n\t\tsuper(\n\t\t\t`'${id}' is a '${variant}' site, which renders its pages on its own ` +\n\t\t\t\t`server, so it never needs its APIs at build: drop \\`prerender\\`, ` +\n\t\t\t\t`and render data-backed pages on request (the deploy warms them). ` +\n\t\t\t\t`\\`prerender: 'stage'\\` is for a 'static' site that bakes data into ` +\n\t\t\t\t`its files.`,\n\t\t);\n\t\tthis.name = 'PrerenderNeedsStaticSite';\n\t}\n}\n\n/** A wildcard site that says it holds the base domain. */\nexport class WildcardSiteCannotBeRoot extends Error {\n\tconstructor(readonly id: string) {\n\t\tsuper(\n\t\t\t`'${id}' answers on every subdomain, so it cannot also hold the base ` +\n\t\t\t\t`domain. Drop \\`root: true\\`, and declare the site the base domain ` +\n\t\t\t\t`points at separately.`,\n\t\t);\n\t\tthis.name = 'WildcardSiteCannotBeRoot';\n\t}\n}\n\nexport class StaticSite<TName extends string = string>\n\timplements Declarable<TName>, Construct<TName, string>\n{\n\treadonly id: TName;\n\treadonly keys: { url: string };\n\n\t/**\n\t * Its public address, `https://web.example.com` — a string, no await. The\n\t * same `<ID>_URL` on every command and stage, so a link built from it opens\n\t * in a browser.\n\t */\n\treadonly service: Service<Uncapitalize<TName>, string>;\n\n\tconstructor(\n\t\tid: ConstructName<TName>,\n\t\tprivate readonly config: StaticSiteConfig,\n\t\t/**\n\t\t * Internal: how `.dependsOn()` carries edges into the copy it returns.\n\t\t * Written as a parameter rather than a mutable field so the builder can\n\t\t * stay immutable without a clone method, the same shape\n\t\t * `KyselyDatabase` uses for its derived forms.\n\t\t */\n\t\tprivate readonly dependencies: readonly Dependency[] = [],\n\t) {\n\t\tthis.id = canonicalId(id as string) as TName;\n\t\tthis.keys = { url: providedKeyFor(this.id, 'site', 'url') };\n\t\t// A field, not a getter: consumers cache services by object identity.\n\t\tthis.service = {\n\t\t\tserviceName: serviceKey(this.id) as Uncapitalize<TName>,\n\t\t\tregister: (options) => publicUrl(options, this.keys.url),\n\t\t};\n\n\t\tconst wildcard = config.subdomain === WILDCARD_SUBDOMAIN;\n\t\tif (!wildcard && config.hosts) throw new SiteHostsNeedsWildcard(this.id);\n\t\tif (wildcard && config.root) throw new WildcardSiteCannotBeRoot(this.id);\n\t\tassertHostLabels({\n\t\t\tid: this.id,\n\t\t\t...(config.subdomain ? { subdomain: config.subdomain } : {}),\n\t\t\t...(config.aliases ? { aliases: config.aliases } : {}),\n\t\t\t...(config.redirects ? { redirects: config.redirects } : {}),\n\t\t});\n\t\tconst variant = config.variant ?? 'static';\n\t\tif (config.prerender && variant !== 'static') {\n\t\t\tthrow new PrerenderNeedsStaticSite(this.id, variant);\n\t\t}\n\t\tif (\n\t\t\tconfig.hosts &&\n\t\t\t'method' in config.hosts &&\n\t\t\tconfig.hosts.method.toUpperCase() !== 'GET'\n\t\t) {\n\t\t\tthrow new SiteHostsNotGet(\n\t\t\t\tthis.id,\n\t\t\t\tconfig.hosts.method,\n\t\t\t\tconfig.hosts.route,\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * What this site calls.\n\t *\n\t * Immutable, like every other builder here: it returns a new site rather than\n\t * mutating this one, so a module that exports both a base and a variant of it\n\t * cannot have the second silently change the first.\n\t *\n\t * Takes {@link Declarable} rather than {@link Consumable} because a site's\n\t * edge is a build-time link and not a service injection — requiring a client\n\t * would exclude exactly the surfaces a frontend actually depends on.\n\t *\n\t * A plain edge to a `FileServer` is to its public face: the site is built\n\t * with the address its objects are served on, and handed nothing that\n\t * writes to the bucket. A plain edge to an `ObjectStorage` is to where its\n\t * links are signed (`<PREFIX><T>_SIGNED_ORIGIN`), and to nothing else of\n\t * it. `.dependsOn([assets.server])` or `.dependsOn([documents.server])`\n\t * asks for the bucket and its credentials too, for a server half that\n\t * uploads or presigns.\n\t */\n\tdependsOn(constructs: readonly Declarable[]): StaticSite<TName> {\n\t\treturn new StaticSite<TName>(this.id as ConstructName<TName>, this.config, [\n\t\t\t...this.dependencies,\n\t\t\t...constructs.map(frontendEdgeTo),\n\t\t]);\n\t}\n\n\tdeclare(): Declaration[] {\n\t\tconst { hosts } = this.config;\n\t\tconst wildcard = this.config.subdomain === WILDCARD_SUBDOMAIN;\n\t\treturn [\n\t\t\t{\n\t\t\t\tkind: 'site',\n\t\t\t\tid: this.id,\n\t\t\t\tvariant: this.config.variant ?? 'static',\n\t\t\t\t...(this.config.subdomain ? { subdomain: this.config.subdomain } : {}),\n\t\t\t\t...(this.config.aliases?.length\n\t\t\t\t\t? { aliases: [...this.config.aliases] }\n\t\t\t\t\t: {}),\n\t\t\t\t...(this.config.redirects?.length\n\t\t\t\t\t? { redirects: [...this.config.redirects] }\n\t\t\t\t\t: {}),\n\t\t\t\t...(hosts\n\t\t\t\t\t? {\n\t\t\t\t\t\t\thosts: {\n\t\t\t\t\t\t\t\tsurface: canonicalId(hosts.surface.id),\n\t\t\t\t\t\t\t\tpath: 'route' in hosts ? hosts.route : hosts.path,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t}\n\t\t\t\t\t: {}),\n\t\t\t\tapp: {\n\t\t\t\t\tpath: this.config.path,\n\t\t\t\t\t...(this.config.port ? { port: this.config.port } : {}),\n\t\t\t\t\t...(this.config.config ? { config: this.config.config } : {}),\n\t\t\t\t},\n\t\t\t\t...(this.config.root ? { root: true } : {}),\n\t\t\t\tdependencies: this.dependencies,\n\t\t\t\t...(this.config.telemetry\n\t\t\t\t\t? { telemetry: this.config.telemetry.id }\n\t\t\t\t\t: {}),\n\t\t\t\t...(this.config.password\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tpassword: {\n\t\t\t\t\t\t\t\tsecret: this.config.password.secret.id,\n\t\t\t\t\t\t\t\tstages: [...this.config.password.stages],\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t}\n\t\t\t\t\t: {}),\n\t\t\t\t...(this.config.prerender ? { prerender: this.config.prerender } : {}),\n\t\t\t\tprovides: [\n\t\t\t\t\tthis.keys.url,\n\t\t\t\t\t// The tenant comes off the host it was reached on, whether or\n\t\t\t\t\t// not an edge asks the app about it first.\n\t\t\t\t\t...(wildcard\n\t\t\t\t\t\t? [\n\t\t\t\t\t\t\t\tprovidedKeyFor(this.id, 'site', 'domain'),\n\t\t\t\t\t\t\t\tprovidedKeyFor(this.id, 'site', 'protectedSubdomains'),\n\t\t\t\t\t\t\t]\n\t\t\t\t\t\t: []),\n\t\t\t\t],\n\t\t\t},\n\t\t];\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiPA,IAAa,yBAAb,cAA4C,MAAM;CAC5B;CAArB,YAAY,IAAqB;EAChC,MACC,IAAI,GAAG,2HAER;EAJoB,KAAA,KAAA;EAKpB,KAAK,OAAO;CACb;AACD;;AAGA,IAAa,kBAAb,cAAqC,MAAM;CAEhC;CACA;CACA;CAHV,YACC,IACA,QACA,OACC;EACD,MACC,IAAI,GAAG,0BAA0B,OAAO,GAAG,MAAM,+BACpC,MAAM,wCACpB;EAPS,KAAA,KAAA;EACA,KAAA,SAAA;EACA,KAAA,QAAA;EAMT,KAAK,OAAO;CACb;AACD;;;;;;AAOA,IAAa,2BAAb,cAA8C,MAAM;CAEzC;CACA;CAFV,YACC,IACA,SACC;EACD,MACC,IAAI,GAAG,UAAU,QAAQ,2PAK1B;EATS,KAAA,KAAA;EACA,KAAA,UAAA;EAST,KAAK,OAAO;CACb;AACD;;AAGA,IAAa,2BAAb,cAA8C,MAAM;CAC9B;CAArB,YAAY,IAAqB;EAChC,MACC,IAAI,GAAG,sJAGR;EALoB,KAAA,KAAA;EAMpB,KAAK,OAAO;CACb;AACD;AAEA,IAAa,aAAb,MAAa,WAEb;CAamB;CAOA;CAnBlB;CACA;;;;;;CAOA;CAEA,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AA,eAAAA,CAAe,KAAK,IAAI,QAAQ,qBAAqB,CACtD,IACC,CAAC,CACL;EACD,CACD;CACD;AACD"}
package/dist/site.d.cts CHANGED
@@ -25,8 +25,8 @@ export interface StaticSiteConfig {
25
25
  * `api.myapp.localhost`. Absent, its id kebab-cased.
26
26
  *
27
27
  * `'*'` answers on every subdomain nothing else does — one host per
28
- * tenant, `acme.myapp.com` — and then `hosts` names which of them are
29
- * real. Every other app keeps its own host, and a project has at most one
28
+ * tenant, `acme.myapp.com` — and `hosts` may name the route that says
29
+ * which of them are real. Every other app keeps its own host, and a project has at most one
30
30
  * such site.
31
31
  */
32
32
  subdomain?: string;
@@ -45,13 +45,31 @@ export interface StaticSiteConfig {
45
45
  */
46
46
  redirects?: readonly string[];
47
47
  /**
48
- * With `subdomain: '*'`, the route that says which hosts are tenants: an
49
- * exported `GET` endpoint the edge asks before it serves a host,
50
- * `?domain=<host>`, answering `200` for a tenant and `404` otherwise.
48
+ * With `subdomain: '*'`, the route that says which hosts are tenants: a
49
+ * `GET` route on a surface, asked `?domain=<host>`, answering `200` for a
50
+ * tenant and `404` otherwise. Named by its surface and path, so the
51
+ * construct imports no app code:
52
+ *
53
+ * ```ts
54
+ * hosts: { surface: api, path: '/tenants/hosts' },
55
+ * ```
56
+ *
57
+ * Optional. A deploy needs it only where the edge gets a certificate per
58
+ * tenant on demand (the stack's own Caddy without `deploy.compose.tls`):
59
+ * the edge asks it before issuing one, so nobody can make it request
60
+ * certificates for hosts that are no tenant. Behind a wildcard
61
+ * certificate — the DNS challenge, the stage's own, CloudFront's — every
62
+ * label but the protected ones reaches the site, and the app answers an
63
+ * unknown tenant itself. Given, `gkm dev` also asks it before serving a
64
+ * host.
65
+ *
66
+ * `gkm` checks, where it reads the whole project, that the surface serves
67
+ * `GET <path>` (`SiteHostsEndpointMissing`). The endpoint itself is still
68
+ * accepted, for projects that already pass it.
51
69
  *
52
70
  * It runs without a session and belongs to no public API.
53
71
  */
54
- hosts?: SiteHostsEndpoint;
72
+ hosts?: SiteHostsRoute | SiteHostsEndpoint;
55
73
  /**
56
74
  * The port it answers on locally.
57
75
  *
@@ -147,8 +165,21 @@ export interface StaticSiteConfig {
147
165
  prerender?: 'stage';
148
166
  }
149
167
  /**
150
- * The shape of the endpoint `hosts` names — read structurally, so a site
151
- * module never loads the endpoint machinery to say which route it means.
168
+ * The route `hosts` names, by its surface and its path — what a constructs
169
+ * file can say without importing the endpoint from an app. The surface is
170
+ * read structurally (its `id`), so a site module never loads the endpoint
171
+ * machinery, and the method is always `GET`.
172
+ */
173
+ export interface SiteHostsRoute {
174
+ surface: {
175
+ id: string;
176
+ };
177
+ path: string;
178
+ }
179
+ /**
180
+ * The endpoint itself, as `hosts` was first given — read structurally, for
181
+ * the same reason. Prefer {@link SiteHostsRoute}: an endpoint lives in an
182
+ * app, and a construct that imports it cannot load where that app is not.
152
183
  */
153
184
  export interface SiteHostsEndpoint {
154
185
  route: string;
@@ -157,11 +188,6 @@ export interface SiteHostsEndpoint {
157
188
  id: string;
158
189
  };
159
190
  }
160
- /** `subdomain: '*'` without `hosts`: nothing would say which hosts are tenants. */
161
- export declare class WildcardSiteNeedsHosts extends Error {
162
- readonly id: string;
163
- constructor(id: string);
164
- }
165
191
  /** `hosts` on a site with one host, where there is nothing to check. */
166
192
  export declare class SiteHostsNeedsWildcard extends Error {
167
193
  readonly id: string;
@@ -1 +1 @@
1
- {"version":3,"file":"site.d.cts","names":[],"sources":["../src/site.ts"],"mappings":";;;;;;;;;;;;;iBAmEiB;;;;;;;EAOhB;;;;;;;;;;;EAWA;;;;;;EAMA;;;;;;;;EAQA;;;;;;;;EAQA,QAAQ;;;;;;;EAOR;;;;;;;EAOA;IAAW;IAAiB;;;;;;;;;;EAS5B;;;;;;;;;EASA,UAAU;;;;;;;EAOV,YAAY;;;;;;;;;;;;;;;;;;;;;;;;EAwBZ;IACC,QAAQ;IACR,kBAAkB,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;EAyBrC;;;;;;i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;;;;;mBAOA;WAnBT,IAAI;WACJ;IAAQ;;;;;;;WAOR,SAAS,QAAQ,aAAa;EAEvC,YACC,IAAI,cAAc,QACD,QAAQ,kBAOR;;;;;;;EAAA,wBAAuB;;;;;;;;;;;;;;;;;;;;EAuDzC,UAAU,qBAAqB,eAAe,WAAW;EAOzD,WAAW"}
package/dist/site.d.mts CHANGED
@@ -25,8 +25,8 @@ export interface StaticSiteConfig {
25
25
  * `api.myapp.localhost`. Absent, its id kebab-cased.
26
26
  *
27
27
  * `'*'` answers on every subdomain nothing else does — one host per
28
- * tenant, `acme.myapp.com` — and then `hosts` names which of them are
29
- * real. Every other app keeps its own host, and a project has at most one
28
+ * tenant, `acme.myapp.com` — and `hosts` may name the route that says
29
+ * which of them are real. Every other app keeps its own host, and a project has at most one
30
30
  * such site.
31
31
  */
32
32
  subdomain?: string;
@@ -45,13 +45,31 @@ export interface StaticSiteConfig {
45
45
  */
46
46
  redirects?: readonly string[];
47
47
  /**
48
- * With `subdomain: '*'`, the route that says which hosts are tenants: an
49
- * exported `GET` endpoint the edge asks before it serves a host,
50
- * `?domain=<host>`, answering `200` for a tenant and `404` otherwise.
48
+ * With `subdomain: '*'`, the route that says which hosts are tenants: a
49
+ * `GET` route on a surface, asked `?domain=<host>`, answering `200` for a
50
+ * tenant and `404` otherwise. Named by its surface and path, so the
51
+ * construct imports no app code:
52
+ *
53
+ * ```ts
54
+ * hosts: { surface: api, path: '/tenants/hosts' },
55
+ * ```
56
+ *
57
+ * Optional. A deploy needs it only where the edge gets a certificate per
58
+ * tenant on demand (the stack's own Caddy without `deploy.compose.tls`):
59
+ * the edge asks it before issuing one, so nobody can make it request
60
+ * certificates for hosts that are no tenant. Behind a wildcard
61
+ * certificate — the DNS challenge, the stage's own, CloudFront's — every
62
+ * label but the protected ones reaches the site, and the app answers an
63
+ * unknown tenant itself. Given, `gkm dev` also asks it before serving a
64
+ * host.
65
+ *
66
+ * `gkm` checks, where it reads the whole project, that the surface serves
67
+ * `GET <path>` (`SiteHostsEndpointMissing`). The endpoint itself is still
68
+ * accepted, for projects that already pass it.
51
69
  *
52
70
  * It runs without a session and belongs to no public API.
53
71
  */
54
- hosts?: SiteHostsEndpoint;
72
+ hosts?: SiteHostsRoute | SiteHostsEndpoint;
55
73
  /**
56
74
  * The port it answers on locally.
57
75
  *
@@ -147,8 +165,21 @@ export interface StaticSiteConfig {
147
165
  prerender?: 'stage';
148
166
  }
149
167
  /**
150
- * The shape of the endpoint `hosts` names — read structurally, so a site
151
- * module never loads the endpoint machinery to say which route it means.
168
+ * The route `hosts` names, by its surface and its path — what a constructs
169
+ * file can say without importing the endpoint from an app. The surface is
170
+ * read structurally (its `id`), so a site module never loads the endpoint
171
+ * machinery, and the method is always `GET`.
172
+ */
173
+ export interface SiteHostsRoute {
174
+ surface: {
175
+ id: string;
176
+ };
177
+ path: string;
178
+ }
179
+ /**
180
+ * The endpoint itself, as `hosts` was first given — read structurally, for
181
+ * the same reason. Prefer {@link SiteHostsRoute}: an endpoint lives in an
182
+ * app, and a construct that imports it cannot load where that app is not.
152
183
  */
153
184
  export interface SiteHostsEndpoint {
154
185
  route: string;
@@ -157,11 +188,6 @@ export interface SiteHostsEndpoint {
157
188
  id: string;
158
189
  };
159
190
  }
160
- /** `subdomain: '*'` without `hosts`: nothing would say which hosts are tenants. */
161
- export declare class WildcardSiteNeedsHosts extends Error {
162
- readonly id: string;
163
- constructor(id: string);
164
- }
165
191
  /** `hosts` on a site with one host, where there is nothing to check. */
166
192
  export declare class SiteHostsNeedsWildcard extends Error {
167
193
  readonly id: string;
@@ -1 +1 @@
1
- {"version":3,"file":"site.d.mts","names":[],"sources":["../src/site.ts"],"mappings":";;;;;;;;;;;;;iBAmEiB;;;;;;;EAOhB;;;;;;;;;;;EAWA;;;;;;EAMA;;;;;;;;EAQA;;;;;;;;EAQA,QAAQ;;;;;;;EAOR;;;;;;;EAOA;IAAW;IAAiB;;;;;;;;;;EAS5B;;;;;;;;;EASA,UAAU;;;;;;;EAO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nC;WACA,SAAS;EAFnB,YACU,YACA,SAAS;;;qBAcP,iCAAiC;WACxB;EAArB,YAAqB;;qBAUT,WAAW,0CACZ,WAAW,QAAQ,UAAU;mBActB;;;;;;;mBAOA;WAnBT,IAAI;WACJ;IAAQ;;;;;;;WAOR,SAAS,QAAQ,aAAa;EAEvC,YACC,IAAI,cAAc,QACD,QAAQ,kBAOR;;;;;;;EAAA,wBAAuB;;;;;;;;;;;;;;;;;;;;EAuDzC,UAAU,qBAAqB,eAAe,WAAW;EAOzD,WAAW"}
package/dist/site.mjs CHANGED
@@ -31,15 +31,6 @@ import { HostLabelBothAliasAndRedirect, InvalidHostLabel, WILDCARD_SUBDOMAIN, Wi
31
31
  * is not a site — it is reached by a scheme, not a URL — and is its own
32
32
  * construct: see `MobileApp`.
33
33
  */
34
- /** `subdomain: '*'` without `hosts`: nothing would say which hosts are tenants. */
35
- var WildcardSiteNeedsHosts = class extends Error {
36
- id;
37
- constructor(id) {
38
- super(`'${id}' answers on every subdomain, so it has to say which of them are tenants: pass \`hosts\`, a GET endpoint answering 200 for a host it serves and 404 otherwise.`);
39
- this.id = id;
40
- this.name = "WildcardSiteNeedsHosts";
41
- }
42
- };
43
34
  /** `hosts` on a site with one host, where there is nothing to check. */
44
35
  var SiteHostsNeedsWildcard = class extends Error {
45
36
  id;
@@ -107,7 +98,6 @@ var StaticSite = class StaticSite {
107
98
  register: (options) => publicUrl(options, this.keys.url)
108
99
  };
109
100
  const wildcard = config.subdomain === WILDCARD_SUBDOMAIN;
110
- if (wildcard && !config.hosts) throw new WildcardSiteNeedsHosts(this.id);
111
101
  if (!wildcard && config.hosts) throw new SiteHostsNeedsWildcard(this.id);
112
102
  if (wildcard && config.root) throw new WildcardSiteCannotBeRoot(this.id);
113
103
  assertHostLabels({
@@ -118,7 +108,7 @@ var StaticSite = class StaticSite {
118
108
  });
119
109
  const variant = config.variant ?? "static";
120
110
  if (config.prerender && variant !== "static") throw new PrerenderNeedsStaticSite(this.id, variant);
121
- if (config.hosts && config.hosts.method.toUpperCase() !== "GET") throw new SiteHostsNotGet(this.id, config.hosts.method, config.hosts.route);
111
+ if (config.hosts && "method" in config.hosts && config.hosts.method.toUpperCase() !== "GET") throw new SiteHostsNotGet(this.id, config.hosts.method, config.hosts.route);
122
112
  }
123
113
  /**
124
114
  * What this site calls.
@@ -144,6 +134,7 @@ var StaticSite = class StaticSite {
144
134
  }
145
135
  declare() {
146
136
  const { hosts } = this.config;
137
+ const wildcard = this.config.subdomain === WILDCARD_SUBDOMAIN;
147
138
  return [{
148
139
  kind: "site",
149
140
  id: this.id,
@@ -153,7 +144,7 @@ var StaticSite = class StaticSite {
153
144
  ...this.config.redirects?.length ? { redirects: [...this.config.redirects] } : {},
154
145
  ...hosts ? { hosts: {
155
146
  surface: canonicalId(hosts.surface.id),
156
- path: hosts.route
147
+ path: "route" in hosts ? hosts.route : hosts.path
157
148
  } } : {},
158
149
  app: {
159
150
  path: this.config.path,
@@ -168,11 +159,11 @@ var StaticSite = class StaticSite {
168
159
  stages: [...this.config.password.stages]
169
160
  } } : {},
170
161
  ...this.config.prerender ? { prerender: this.config.prerender } : {},
171
- provides: [this.keys.url, ...hosts ? [providedKeyFor(this.id, "site", "domain"), providedKeyFor(this.id, "site", "protectedSubdomains")] : []]
162
+ provides: [this.keys.url, ...wildcard ? [providedKeyFor(this.id, "site", "domain"), providedKeyFor(this.id, "site", "protectedSubdomains")] : []]
172
163
  }];
173
164
  }
174
165
  };
175
166
  //#endregion
176
- export { HostLabelBothAliasAndRedirect, InvalidHostLabel, PrerenderNeedsStaticSite, SiteHostsNeedsWildcard, SiteHostsNotGet, StaticSite, WildcardSiteCannotBeRoot, WildcardSiteCannotHaveAliases, WildcardSiteNeedsHosts };
167
+ export { HostLabelBothAliasAndRedirect, InvalidHostLabel, PrerenderNeedsStaticSite, SiteHostsNeedsWildcard, SiteHostsNotGet, StaticSite, WildcardSiteCannotBeRoot, WildcardSiteCannotHaveAliases };
177
168
 
178
169
  //# sourceMappingURL=site.mjs.map
package/dist/site.mjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"site.mjs","names":[],"sources":["../src/site.ts"],"sourcesContent":["/**\n * `StaticSite` — a frontend, declared like anything else.\n *\n * The point is not that a site needs provisioning; it is that a site is the\n * *consumer* whose edges make four hand-maintained lists derivable. Declaring it\n * is what turns \"which origins does the API allow\" from something a person keeps\n * in step into something the graph already knows.\n *\n * ```ts\n * export const console = new StaticSite('Console', { path: 'apps/console' })\n * .dependsOn([api, auth]);\n * ```\n *\n * A site consumes addresses, not connections: it is built, and the values it\n * needs are inlined or fetched by its own framework, so its own edges take any\n * {@link Declarable}. Its `.service` is its public address — what a worker's\n * cron or an endpoint that builds links to it reads:\n *\n * ```ts\n * export const digest = worker\n * .cron('rate(1 day)')\n * .dependsOn([web])\n * .handle(async ({ services }) => link(services.web, '/inbox'));\n * ```\n *\n * Only the static variant ships. SSR deploy shapes are unstable and each one is\n * its own maintenance, so they follow rather than arrive together. A mobile app\n * is not a site — it is reached by a scheme, not a URL — and is its own\n * construct: see `MobileApp`.\n */\n\nimport {\n\tassertHostLabels,\n\ttype ConstructName,\n\tcanonicalId,\n\ttype Declaration,\n\ttype Dependency,\n\tprovidedKeyFor,\n\ttype SiteDeclaration,\n\tserviceKey,\n\tWILDCARD_SUBDOMAIN,\n} from '@geekmidas/manifest';\n\n/** Thrown at construction for an alias or redirect that cannot be a host label. */\nexport {\n\tHostLabelBothAliasAndRedirect,\n\tInvalidHostLabel,\n\tWildcardSiteCannotHaveAliases,\n} from '@geekmidas/manifest';\n\nimport type { Service } from '@geekmidas/services';\nimport {\n\ttype Construct,\n\ttype Declarable,\n\tfrontendEdgeTo,\n\tpublicUrl,\n} from './construct-interface';\nimport type { RandomPassword } from './random-password';\nimport type { DeployedStage } from './stages';\nimport type { Telemetry } from './telemetry';\n\n/**\n * Where a site's source lives, and the little else a layout can differ by.\n *\n * Only `path` is required: `new StaticSite('Web', { path: 'apps/web' })` is a\n * complete site.\n */\nexport interface StaticSiteConfig {\n\t/**\n\t * Where its source lives, relative to the workspace root — `'apps/web'`.\n\t *\n\t * Required, the same field `RestApi` and `BetterAuth` take. It was\n\t * inferred from the id, which made a site's home whatever was on disk.\n\t */\n\tpath: string;\n\t/**\n\t * The label it answers on under a stage's domain — `api` for\n\t * `api.myapp.com`, from `domains` — and under the project locally,\n\t * `api.myapp.localhost`. Absent, its id kebab-cased.\n\t *\n\t * `'*'` answers on every subdomain nothing else does — one host per\n\t * tenant, `acme.myapp.com` — and then `hosts` names which of them are\n\t * real. Every other app keeps its own host, and a project has at most one\n\t * such site.\n\t */\n\tsubdomain?: string;\n\t/**\n\t * More labels it answers on under the stage's domain, exactly as on its\n\t * own: each a host the site really serves, and an origin every surface it\n\t * depends on trusts. Its own host stays canonical (`<ID>_URL`).\n\t */\n\taliases?: readonly string[];\n\t/**\n\t * Labels that answer with a permanent (301) redirect to its own host,\n\t * path and query kept — `['www']` sends `www.myapp.com` to `myapp.com`.\n\t * Nothing answers on a host unless a construct names it, so there is no\n\t * automatic `www`. Sites only: an API client does not reliably follow a\n\t * redirect on a `POST`.\n\t */\n\tredirects?: readonly string[];\n\t/**\n\t * With `subdomain: '*'`, the route that says which hosts are tenants: an\n\t * exported `GET` endpoint the edge asks before it serves a host,\n\t * `?domain=<host>`, answering `200` for a tenant and `404` otherwise.\n\t *\n\t * It runs without a session and belongs to no public API.\n\t */\n\thosts?: SiteHostsEndpoint;\n\t/**\n\t * The port it answers on locally.\n\t *\n\t * Normally omitted: ports are assigned in a stable order, so adding a site\n\t * does not renumber the ones already running.\n\t */\n\tport?: number;\n\t/**\n\t * Modules to import when sniffing which env vars this site reads.\n\t *\n\t * A frontend's values are inlined at build time, so the build has to know\n\t * which ones it reads before it reads them.\n\t */\n\tconfig?: { client?: string; server?: string };\n\t/**\n\t * Whether the base domain points at this site.\n\t *\n\t * A project with one site needs this no more than a project with one\n\t * database needs to say which database. It matters when there are several\n\t * and none is called `web`: the base domain then belongs to whichever site\n\t * says so, rather than to whichever file the glob happened to reach first.\n\t */\n\troot?: boolean;\n\t/**\n\t * Which framework builds it.\n\t *\n\t * It selects how values are delivered — `VITE_`, `NEXT_PUBLIC_`, a fetched\n\t * `config.json` — and never which values there are. One neutral name from the\n\t * construct, one serialisation per framework, the same rule as everywhere\n\t * else.\n\t */\n\tvariant?: SiteDeclaration['variant'];\n\t/**\n\t * What the site emits — the `Telemetry` construct. An edge to the node and\n\t * nothing more for now: a site is handed none of its server keys, and the\n\t * browser half (propagation from the generated client, then a browser SDK\n\t * exporting through the API) builds on this edge.\n\t */\n\ttelemetry?: Telemetry;\n\t/**\n\t * A login the site is served behind on the stages named, so a staging\n\t * build is not public while it is tried.\n\t *\n\t * ```ts\n\t * export const sitePassword = new RandomPassword('SitePassword');\n\t *\n\t * export const web = new StaticSite('Web', {\n\t * path: 'apps/web',\n\t * password: { secret: sitePassword, stages: ['staging'] },\n\t * });\n\t * ```\n\t *\n\t * The edge asks for it with HTTP basic auth before a request reaches the\n\t * site: the user is the stage's name, the password the `RandomPassword`'s\n\t * value on that stage. Like any `RandomPassword` it is generated on the\n\t * first deploy and kept, and one set by hand wins. It is not an edge — the\n\t * site is handed none of it — so export it from a constructs file of its\n\t * own, as any construct is.\n\t *\n\t * The compose target alone serves it so far; another refuses the stage\n\t * rather than serving it publicly.\n\t */\n\tpassword?: {\n\t\tsecret: RandomPassword;\n\t\tstages: readonly [DeployedStage, ...DeployedStage[]];\n\t};\n\t/**\n\t * `'stage'` for a `static` site that pre-renders data at build time\n\t * (vite-ssg and similar): its build fetches from the APIs it\n\t * `.dependsOn()`, and bakes their answers into its files.\n\t *\n\t * ```ts\n\t * new StaticSite('Web', {\n\t * path: 'apps/web',\n\t * variant: 'static',\n\t * prerender: 'stage',\n\t * }).dependsOn([api]);\n\t * ```\n\t *\n\t * The deploy then builds the site only once those APIs are up and\n\t * healthy on the stage, and the build reaches them at their public\n\t * addresses, as a browser would. Without it, a site is built offline,\n\t * before its stage runs (`GKM_BUILD_OFFLINE=1`), and nothing at runtime\n\t * can fill a page built without its data.\n\t *\n\t * Opt-in, because the image then holds that stage's data: the same commit\n\t * builds a different image per stage, and `gkm compose --build --push`\n\t * needs the stage it builds for already running.\n\t */\n\tprerender?: 'stage';\n}\n\n/**\n * The shape of the endpoint `hosts` names — read structurally, so a site\n * module never loads the endpoint machinery to say which route it means.\n */\nexport interface SiteHostsEndpoint {\n\troute: string;\n\tmethod: string;\n\tsurface: { id: string };\n}\n\n/** `subdomain: '*'` without `hosts`: nothing would say which hosts are tenants. */\nexport class WildcardSiteNeedsHosts extends Error {\n\tconstructor(readonly id: string) {\n\t\tsuper(\n\t\t\t`'${id}' answers on every subdomain, so it has to say which of them ` +\n\t\t\t\t`are tenants: pass \\`hosts\\`, a GET endpoint answering 200 for a ` +\n\t\t\t\t`host it serves and 404 otherwise.`,\n\t\t);\n\t\tthis.name = 'WildcardSiteNeedsHosts';\n\t}\n}\n\n/** `hosts` on a site with one host, where there is nothing to check. */\nexport class SiteHostsNeedsWildcard extends Error {\n\tconstructor(readonly id: string) {\n\t\tsuper(\n\t\t\t`'${id}' names a \\`hosts\\` check but answers on one host. ` +\n\t\t\t\t`Declare \\`subdomain: '*'\\` to serve every subdomain, or drop \\`hosts\\`.`,\n\t\t);\n\t\tthis.name = 'SiteHostsNeedsWildcard';\n\t}\n}\n\n/** A `hosts` endpoint that is not a `GET`: the edge only ever asks with one. */\nexport class SiteHostsNotGet extends Error {\n\tconstructor(\n\t\treadonly id: string,\n\t\treadonly method: string,\n\t\treadonly route: string,\n\t) {\n\t\tsuper(\n\t\t\t`'${id}' checks its hosts with ${method} ${route}, but the edge asks ` +\n\t\t\t\t`with GET ${route}?domain=<host>. Make it a GET endpoint.`,\n\t\t);\n\t\tthis.name = 'SiteHostsNotGet';\n\t}\n}\n\n/**\n * `prerender: 'stage'` on a site that renders its pages on a server, where a\n * page renders on its first request — which the deploy's warm-up makes — and\n * needs no data at build.\n */\nexport class PrerenderNeedsStaticSite extends Error {\n\tconstructor(\n\t\treadonly id: string,\n\t\treadonly variant: SiteDeclaration['variant'],\n\t) {\n\t\tsuper(\n\t\t\t`'${id}' is a '${variant}' site, which renders its pages on its own ` +\n\t\t\t\t`server, so it never needs its APIs at build: drop \\`prerender\\`, ` +\n\t\t\t\t`and render data-backed pages on request (the deploy warms them). ` +\n\t\t\t\t`\\`prerender: 'stage'\\` is for a 'static' site that bakes data into ` +\n\t\t\t\t`its files.`,\n\t\t);\n\t\tthis.name = 'PrerenderNeedsStaticSite';\n\t}\n}\n\n/** A wildcard site that says it holds the base domain. */\nexport class WildcardSiteCannotBeRoot extends Error {\n\tconstructor(readonly id: string) {\n\t\tsuper(\n\t\t\t`'${id}' answers on every subdomain, so it cannot also hold the base ` +\n\t\t\t\t`domain. Drop \\`root: true\\`, and declare the site the base domain ` +\n\t\t\t\t`points at separately.`,\n\t\t);\n\t\tthis.name = 'WildcardSiteCannotBeRoot';\n\t}\n}\n\nexport class StaticSite<TName extends string = string>\n\timplements Declarable<TName>, Construct<TName, string>\n{\n\treadonly id: TName;\n\treadonly keys: { url: string };\n\n\t/**\n\t * Its public address, `https://web.example.com` — a string, no await. The\n\t * same `<ID>_URL` on every command and stage, so a link built from it opens\n\t * in a browser.\n\t */\n\treadonly service: Service<Uncapitalize<TName>, string>;\n\n\tconstructor(\n\t\tid: ConstructName<TName>,\n\t\tprivate readonly config: StaticSiteConfig,\n\t\t/**\n\t\t * Internal: how `.dependsOn()` carries edges into the copy it returns.\n\t\t * Written as a parameter rather than a mutable field so the builder can\n\t\t * stay immutable without a clone method, the same shape\n\t\t * `KyselyDatabase` uses for its derived forms.\n\t\t */\n\t\tprivate readonly dependencies: readonly Dependency[] = [],\n\t) {\n\t\tthis.id = canonicalId(id as string) as TName;\n\t\tthis.keys = { url: providedKeyFor(this.id, 'site', 'url') };\n\t\t// A field, not a getter: consumers cache services by object identity.\n\t\tthis.service = {\n\t\t\tserviceName: serviceKey(this.id) as Uncapitalize<TName>,\n\t\t\tregister: (options) => publicUrl(options, this.keys.url),\n\t\t};\n\n\t\tconst wildcard = config.subdomain === WILDCARD_SUBDOMAIN;\n\t\tif (wildcard && !config.hosts) throw new WildcardSiteNeedsHosts(this.id);\n\t\tif (!wildcard && config.hosts) throw new SiteHostsNeedsWildcard(this.id);\n\t\tif (wildcard && config.root) throw new WildcardSiteCannotBeRoot(this.id);\n\t\tassertHostLabels({\n\t\t\tid: this.id,\n\t\t\t...(config.subdomain ? { subdomain: config.subdomain } : {}),\n\t\t\t...(config.aliases ? { aliases: config.aliases } : {}),\n\t\t\t...(config.redirects ? { redirects: config.redirects } : {}),\n\t\t});\n\t\tconst variant = config.variant ?? 'static';\n\t\tif (config.prerender && variant !== 'static') {\n\t\t\tthrow new PrerenderNeedsStaticSite(this.id, variant);\n\t\t}\n\t\tif (config.hosts && config.hosts.method.toUpperCase() !== 'GET') {\n\t\t\tthrow new SiteHostsNotGet(\n\t\t\t\tthis.id,\n\t\t\t\tconfig.hosts.method,\n\t\t\t\tconfig.hosts.route,\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * What this site calls.\n\t *\n\t * Immutable, like every other builder here: it returns a new site rather than\n\t * mutating this one, so a module that exports both a base and a variant of it\n\t * cannot have the second silently change the first.\n\t *\n\t * Takes {@link Declarable} rather than {@link Consumable} because a site's\n\t * edge is a build-time link and not a service injection — requiring a client\n\t * would exclude exactly the surfaces a frontend actually depends on.\n\t *\n\t * A plain edge to a `FileServer` is to its public face: the site is built\n\t * with the address its objects are served on, and handed nothing that\n\t * writes to the bucket. A plain edge to an `ObjectStorage` is to where its\n\t * links are signed (`<PREFIX><T>_SIGNED_ORIGIN`), and to nothing else of\n\t * it. `.dependsOn([assets.server])` or `.dependsOn([documents.server])`\n\t * asks for the bucket and its credentials too, for a server half that\n\t * uploads or presigns.\n\t */\n\tdependsOn(constructs: readonly Declarable[]): StaticSite<TName> {\n\t\treturn new StaticSite<TName>(this.id as ConstructName<TName>, this.config, [\n\t\t\t...this.dependencies,\n\t\t\t...constructs.map(frontendEdgeTo),\n\t\t]);\n\t}\n\n\tdeclare(): Declaration[] {\n\t\tconst { hosts } = this.config;\n\t\treturn [\n\t\t\t{\n\t\t\t\tkind: 'site',\n\t\t\t\tid: this.id,\n\t\t\t\tvariant: this.config.variant ?? 'static',\n\t\t\t\t...(this.config.subdomain ? { subdomain: this.config.subdomain } : {}),\n\t\t\t\t...(this.config.aliases?.length\n\t\t\t\t\t? { aliases: [...this.config.aliases] }\n\t\t\t\t\t: {}),\n\t\t\t\t...(this.config.redirects?.length\n\t\t\t\t\t? { redirects: [...this.config.redirects] }\n\t\t\t\t\t: {}),\n\t\t\t\t...(hosts\n\t\t\t\t\t? {\n\t\t\t\t\t\t\thosts: {\n\t\t\t\t\t\t\t\tsurface: canonicalId(hosts.surface.id),\n\t\t\t\t\t\t\t\tpath: hosts.route,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t}\n\t\t\t\t\t: {}),\n\t\t\t\tapp: {\n\t\t\t\t\tpath: this.config.path,\n\t\t\t\t\t...(this.config.port ? { port: this.config.port } : {}),\n\t\t\t\t\t...(this.config.config ? { config: this.config.config } : {}),\n\t\t\t\t},\n\t\t\t\t...(this.config.root ? { root: true } : {}),\n\t\t\t\tdependencies: this.dependencies,\n\t\t\t\t...(this.config.telemetry\n\t\t\t\t\t? { telemetry: this.config.telemetry.id }\n\t\t\t\t\t: {}),\n\t\t\t\t...(this.config.password\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tpassword: {\n\t\t\t\t\t\t\t\tsecret: this.config.password.secret.id,\n\t\t\t\t\t\t\t\tstages: [...this.config.password.stages],\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t}\n\t\t\t\t\t: {}),\n\t\t\t\t...(this.config.prerender ? { prerender: this.config.prerender } : {}),\n\t\t\t\tprovides: [\n\t\t\t\t\tthis.keys.url,\n\t\t\t\t\t...(hosts\n\t\t\t\t\t\t? [\n\t\t\t\t\t\t\t\tprovidedKeyFor(this.id, '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,OAAO,OAAO,EAAE,IACpC,CAAC;GACJ,GAAI,KAAK,OAAO,WAAW,SACxB,EAAE,WAAW,CAAC,GAAG,KAAK,OAAO,SAAS,EAAE,IACxC,CAAC;GACJ,GAAI,QACD,EACA,OAAO;IACN,SAAS,YAAY,MAAM,QAAQ,EAAE;IACrC,MAAM,MAAM;GACb,EACD,IACC,CAAC;GACJ,KAAK;IACJ,MAAM,KAAK,OAAO;IAClB,GAAI,KAAK,OAAO,OAAO,EAAE,MAAM,KAAK,OAAO,KAAK,IAAI,CAAC;IACrD,GAAI,KAAK,OAAO,SAAS,EAAE,QAAQ,KAAK,OAAO,OAAO,IAAI,CAAC;GAC5D;GACA,GAAI,KAAK,OAAO,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;GACzC,cAAc,KAAK;GACnB,GAAI,KAAK,OAAO,YACb,EAAE,WAAW,KAAK,OAAO,UAAU,GAAG,IACtC,CAAC;GACJ,GAAI,KAAK,OAAO,WACb,EACA,UAAU;IACT,QAAQ,KAAK,OAAO,SAAS,OAAO;IACpC,QAAQ,CAAC,GAAG,KAAK,OAAO,SAAS,MAAM;GACxC,EACD,IACC,CAAC;GACJ,GAAI,KAAK,OAAO,YAAY,EAAE,WAAW,KAAK,OAAO,UAAU,IAAI,CAAC;GACpE,UAAU,CACT,KAAK,KAAK,KACV,GAAI,QACD,CACA,eAAe,KAAK,IAAI,QAAQ,QAAQ,GACxC,eAAe,KAAK,IAAI,QAAQ,qBAAqB,CACtD,IACC,CAAC,CACL;EACD,CACD;CACD;AACD"}
1
+ {"version":3,"file":"site.mjs","names":[],"sources":["../src/site.ts"],"sourcesContent":["/**\n * `StaticSite` — a frontend, declared like anything else.\n *\n * The point is not that a site needs provisioning; it is that a site is the\n * *consumer* whose edges make four hand-maintained lists derivable. Declaring it\n * is what turns \"which origins does the API allow\" from something a person keeps\n * in step into something the graph already knows.\n *\n * ```ts\n * export const console = new StaticSite('Console', { path: 'apps/console' })\n * .dependsOn([api, auth]);\n * ```\n *\n * A site consumes addresses, not connections: it is built, and the values it\n * needs are inlined or fetched by its own framework, so its own edges take any\n * {@link Declarable}. Its `.service` is its public address — what a worker's\n * cron or an endpoint that builds links to it reads:\n *\n * ```ts\n * export const digest = worker\n * .cron('rate(1 day)')\n * .dependsOn([web])\n * .handle(async ({ services }) => link(services.web, '/inbox'));\n * ```\n *\n * Only the static variant ships. SSR deploy shapes are unstable and each one is\n * its own maintenance, so they follow rather than arrive together. A mobile app\n * is not a site — it is reached by a scheme, not a URL — and is its own\n * construct: see `MobileApp`.\n */\n\nimport {\n\tassertHostLabels,\n\ttype ConstructName,\n\tcanonicalId,\n\ttype Declaration,\n\ttype Dependency,\n\tprovidedKeyFor,\n\ttype SiteDeclaration,\n\tserviceKey,\n\tWILDCARD_SUBDOMAIN,\n} from '@geekmidas/manifest';\n\n/** Thrown at construction for an alias or redirect that cannot be a host label. */\nexport {\n\tHostLabelBothAliasAndRedirect,\n\tInvalidHostLabel,\n\tWildcardSiteCannotHaveAliases,\n} from '@geekmidas/manifest';\n\nimport type { Service } from '@geekmidas/services';\nimport {\n\ttype Construct,\n\ttype Declarable,\n\tfrontendEdgeTo,\n\tpublicUrl,\n} from './construct-interface';\nimport type { RandomPassword } from './random-password';\nimport type { DeployedStage } from './stages';\nimport type { Telemetry } from './telemetry';\n\n/**\n * Where a site's source lives, and the little else a layout can differ by.\n *\n * Only `path` is required: `new StaticSite('Web', { path: 'apps/web' })` is a\n * complete site.\n */\nexport interface StaticSiteConfig {\n\t/**\n\t * Where its source lives, relative to the workspace root — `'apps/web'`.\n\t *\n\t * Required, the same field `RestApi` and `BetterAuth` take. It was\n\t * inferred from the id, which made a site's home whatever was on disk.\n\t */\n\tpath: string;\n\t/**\n\t * The label it answers on under a stage's domain — `api` for\n\t * `api.myapp.com`, from `domains` — and under the project locally,\n\t * `api.myapp.localhost`. Absent, its id kebab-cased.\n\t *\n\t * `'*'` answers on every subdomain nothing else does — one host per\n\t * tenant, `acme.myapp.com` — and `hosts` may name the route that says\n\t * which of them are real. Every other app keeps its own host, and a project has at most one\n\t * such site.\n\t */\n\tsubdomain?: string;\n\t/**\n\t * More labels it answers on under the stage's domain, exactly as on its\n\t * own: each a host the site really serves, and an origin every surface it\n\t * depends on trusts. Its own host stays canonical (`<ID>_URL`).\n\t */\n\taliases?: readonly string[];\n\t/**\n\t * Labels that answer with a permanent (301) redirect to its own host,\n\t * path and query kept — `['www']` sends `www.myapp.com` to `myapp.com`.\n\t * Nothing answers on a host unless a construct names it, so there is no\n\t * automatic `www`. Sites only: an API client does not reliably follow a\n\t * redirect on a `POST`.\n\t */\n\tredirects?: readonly string[];\n\t/**\n\t * With `subdomain: '*'`, the route that says which hosts are tenants: a\n\t * `GET` route on a surface, asked `?domain=<host>`, answering `200` for a\n\t * tenant and `404` otherwise. Named by its surface and path, so the\n\t * construct imports no app code:\n\t *\n\t * ```ts\n\t * hosts: { surface: api, path: '/tenants/hosts' },\n\t * ```\n\t *\n\t * Optional. A deploy needs it only where the edge gets a certificate per\n\t * tenant on demand (the stack's own Caddy without `deploy.compose.tls`):\n\t * the edge asks it before issuing one, so nobody can make it request\n\t * certificates for hosts that are no tenant. Behind a wildcard\n\t * certificate — the DNS challenge, the stage's own, CloudFront's — every\n\t * label but the protected ones reaches the site, and the app answers an\n\t * unknown tenant itself. Given, `gkm dev` also asks it before serving a\n\t * host.\n\t *\n\t * `gkm` checks, where it reads the whole project, that the surface serves\n\t * `GET <path>` (`SiteHostsEndpointMissing`). The endpoint itself is still\n\t * accepted, for projects that already pass it.\n\t *\n\t * It runs without a session and belongs to no public API.\n\t */\n\thosts?: SiteHostsRoute | SiteHostsEndpoint;\n\t/**\n\t * The port it answers on locally.\n\t *\n\t * Normally omitted: ports are assigned in a stable order, so adding a site\n\t * does not renumber the ones already running.\n\t */\n\tport?: number;\n\t/**\n\t * Modules to import when sniffing which env vars this site reads.\n\t *\n\t * A frontend's values are inlined at build time, so the build has to know\n\t * which ones it reads before it reads them.\n\t */\n\tconfig?: { client?: string; server?: string };\n\t/**\n\t * Whether the base domain points at this site.\n\t *\n\t * A project with one site needs this no more than a project with one\n\t * database needs to say which database. It matters when there are several\n\t * and none is called `web`: the base domain then belongs to whichever site\n\t * says so, rather than to whichever file the glob happened to reach first.\n\t */\n\troot?: boolean;\n\t/**\n\t * Which framework builds it.\n\t *\n\t * It selects how values are delivered — `VITE_`, `NEXT_PUBLIC_`, a fetched\n\t * `config.json` — and never which values there are. One neutral name from the\n\t * construct, one serialisation per framework, the same rule as everywhere\n\t * else.\n\t */\n\tvariant?: SiteDeclaration['variant'];\n\t/**\n\t * What the site emits — the `Telemetry` construct. An edge to the node and\n\t * nothing more for now: a site is handed none of its server keys, and the\n\t * browser half (propagation from the generated client, then a browser SDK\n\t * exporting through the API) builds on this edge.\n\t */\n\ttelemetry?: Telemetry;\n\t/**\n\t * A login the site is served behind on the stages named, so a staging\n\t * build is not public while it is tried.\n\t *\n\t * ```ts\n\t * export const sitePassword = new RandomPassword('SitePassword');\n\t *\n\t * export const web = new StaticSite('Web', {\n\t * path: 'apps/web',\n\t * password: { secret: sitePassword, stages: ['staging'] },\n\t * });\n\t * ```\n\t *\n\t * The edge asks for it with HTTP basic auth before a request reaches the\n\t * site: the user is the stage's name, the password the `RandomPassword`'s\n\t * value on that stage. Like any `RandomPassword` it is generated on the\n\t * first deploy and kept, and one set by hand wins. It is not an edge — the\n\t * site is handed none of it — so export it from a constructs file of its\n\t * own, as any construct is.\n\t *\n\t * The compose target alone serves it so far; another refuses the stage\n\t * rather than serving it publicly.\n\t */\n\tpassword?: {\n\t\tsecret: RandomPassword;\n\t\tstages: readonly [DeployedStage, ...DeployedStage[]];\n\t};\n\t/**\n\t * `'stage'` for a `static` site that pre-renders data at build time\n\t * (vite-ssg and similar): its build fetches from the APIs it\n\t * `.dependsOn()`, and bakes their answers into its files.\n\t *\n\t * ```ts\n\t * new StaticSite('Web', {\n\t * path: 'apps/web',\n\t * variant: 'static',\n\t * prerender: 'stage',\n\t * }).dependsOn([api]);\n\t * ```\n\t *\n\t * The deploy then builds the site only once those APIs are up and\n\t * healthy on the stage, and the build reaches them at their public\n\t * addresses, as a browser would. Without it, a site is built offline,\n\t * before its stage runs (`GKM_BUILD_OFFLINE=1`), and nothing at runtime\n\t * can fill a page built without its data.\n\t *\n\t * Opt-in, because the image then holds that stage's data: the same commit\n\t * builds a different image per stage, and `gkm compose --build --push`\n\t * needs the stage it builds for already running.\n\t */\n\tprerender?: 'stage';\n}\n\n/**\n * The route `hosts` names, by its surface and its path — what a constructs\n * file can say without importing the endpoint from an app. The surface is\n * read structurally (its `id`), so a site module never loads the endpoint\n * machinery, and the method is always `GET`.\n */\nexport interface SiteHostsRoute {\n\tsurface: { id: string };\n\tpath: string;\n}\n\n/**\n * The endpoint itself, as `hosts` was first given — read structurally, for\n * the same reason. Prefer {@link SiteHostsRoute}: an endpoint lives in an\n * app, and a construct that imports it cannot load where that app is not.\n */\nexport interface SiteHostsEndpoint {\n\troute: string;\n\tmethod: string;\n\tsurface: { id: string };\n}\n\n/** `hosts` on a site with one host, where there is nothing to check. */\nexport class SiteHostsNeedsWildcard extends Error {\n\tconstructor(readonly id: string) {\n\t\tsuper(\n\t\t\t`'${id}' names a \\`hosts\\` check but answers on one host. ` +\n\t\t\t\t`Declare \\`subdomain: '*'\\` to serve every subdomain, or drop \\`hosts\\`.`,\n\t\t);\n\t\tthis.name = 'SiteHostsNeedsWildcard';\n\t}\n}\n\n/** A `hosts` endpoint that is not a `GET`: the edge only ever asks with one. */\nexport class SiteHostsNotGet extends Error {\n\tconstructor(\n\t\treadonly id: string,\n\t\treadonly method: string,\n\t\treadonly route: string,\n\t) {\n\t\tsuper(\n\t\t\t`'${id}' checks its hosts with ${method} ${route}, but the edge asks ` +\n\t\t\t\t`with GET ${route}?domain=<host>. Make it a GET endpoint.`,\n\t\t);\n\t\tthis.name = 'SiteHostsNotGet';\n\t}\n}\n\n/**\n * `prerender: 'stage'` on a site that renders its pages on a server, where a\n * page renders on its first request — which the deploy's warm-up makes — and\n * needs no data at build.\n */\nexport class PrerenderNeedsStaticSite extends Error {\n\tconstructor(\n\t\treadonly id: string,\n\t\treadonly variant: SiteDeclaration['variant'],\n\t) {\n\t\tsuper(\n\t\t\t`'${id}' is a '${variant}' site, which renders its pages on its own ` +\n\t\t\t\t`server, so it never needs its APIs at build: drop \\`prerender\\`, ` +\n\t\t\t\t`and render data-backed pages on request (the deploy warms them). ` +\n\t\t\t\t`\\`prerender: 'stage'\\` is for a 'static' site that bakes data into ` +\n\t\t\t\t`its files.`,\n\t\t);\n\t\tthis.name = 'PrerenderNeedsStaticSite';\n\t}\n}\n\n/** A wildcard site that says it holds the base domain. */\nexport class WildcardSiteCannotBeRoot extends Error {\n\tconstructor(readonly id: string) {\n\t\tsuper(\n\t\t\t`'${id}' answers on every subdomain, so it cannot also hold the base ` +\n\t\t\t\t`domain. Drop \\`root: true\\`, and declare the site the base domain ` +\n\t\t\t\t`points at separately.`,\n\t\t);\n\t\tthis.name = 'WildcardSiteCannotBeRoot';\n\t}\n}\n\nexport class StaticSite<TName extends string = string>\n\timplements Declarable<TName>, Construct<TName, string>\n{\n\treadonly id: TName;\n\treadonly keys: { url: string };\n\n\t/**\n\t * Its public address, `https://web.example.com` — a string, no await. The\n\t * same `<ID>_URL` on every command and stage, so a link built from it opens\n\t * in a browser.\n\t */\n\treadonly service: Service<Uncapitalize<TName>, string>;\n\n\tconstructor(\n\t\tid: ConstructName<TName>,\n\t\tprivate readonly config: StaticSiteConfig,\n\t\t/**\n\t\t * Internal: how `.dependsOn()` carries edges into the copy it returns.\n\t\t * Written as a parameter rather than a mutable field so the builder can\n\t\t * stay immutable without a clone method, the same shape\n\t\t * `KyselyDatabase` uses for its derived forms.\n\t\t */\n\t\tprivate readonly dependencies: readonly Dependency[] = [],\n\t) {\n\t\tthis.id = canonicalId(id as string) as TName;\n\t\tthis.keys = { url: providedKeyFor(this.id, 'site', 'url') };\n\t\t// A field, not a getter: consumers cache services by object identity.\n\t\tthis.service = {\n\t\t\tserviceName: serviceKey(this.id) as Uncapitalize<TName>,\n\t\t\tregister: (options) => publicUrl(options, this.keys.url),\n\t\t};\n\n\t\tconst wildcard = config.subdomain === WILDCARD_SUBDOMAIN;\n\t\tif (!wildcard && config.hosts) throw new SiteHostsNeedsWildcard(this.id);\n\t\tif (wildcard && config.root) throw new WildcardSiteCannotBeRoot(this.id);\n\t\tassertHostLabels({\n\t\t\tid: this.id,\n\t\t\t...(config.subdomain ? { subdomain: config.subdomain } : {}),\n\t\t\t...(config.aliases ? { aliases: config.aliases } : {}),\n\t\t\t...(config.redirects ? { redirects: config.redirects } : {}),\n\t\t});\n\t\tconst variant = config.variant ?? 'static';\n\t\tif (config.prerender && variant !== 'static') {\n\t\t\tthrow new PrerenderNeedsStaticSite(this.id, variant);\n\t\t}\n\t\tif (\n\t\t\tconfig.hosts &&\n\t\t\t'method' in config.hosts &&\n\t\t\tconfig.hosts.method.toUpperCase() !== 'GET'\n\t\t) {\n\t\t\tthrow new SiteHostsNotGet(\n\t\t\t\tthis.id,\n\t\t\t\tconfig.hosts.method,\n\t\t\t\tconfig.hosts.route,\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * What this site calls.\n\t *\n\t * Immutable, like every other builder here: it returns a new site rather than\n\t * mutating this one, so a module that exports both a base and a variant of it\n\t * cannot have the second silently change the first.\n\t *\n\t * Takes {@link Declarable} rather than {@link Consumable} because a site's\n\t * edge is a build-time link and not a service injection — requiring a client\n\t * would exclude exactly the surfaces a frontend actually depends on.\n\t *\n\t * A plain edge to a `FileServer` is to its public face: the site is built\n\t * with the address its objects are served on, and handed nothing that\n\t * writes to the bucket. A plain edge to an `ObjectStorage` is to where its\n\t * links are signed (`<PREFIX><T>_SIGNED_ORIGIN`), and to nothing else of\n\t * it. `.dependsOn([assets.server])` or `.dependsOn([documents.server])`\n\t * asks for the bucket and its credentials too, for a server half that\n\t * uploads or presigns.\n\t */\n\tdependsOn(constructs: readonly Declarable[]): StaticSite<TName> {\n\t\treturn new StaticSite<TName>(this.id as ConstructName<TName>, this.config, [\n\t\t\t...this.dependencies,\n\t\t\t...constructs.map(frontendEdgeTo),\n\t\t]);\n\t}\n\n\tdeclare(): Declaration[] {\n\t\tconst { hosts } = this.config;\n\t\tconst wildcard = this.config.subdomain === WILDCARD_SUBDOMAIN;\n\t\treturn [\n\t\t\t{\n\t\t\t\tkind: 'site',\n\t\t\t\tid: this.id,\n\t\t\t\tvariant: this.config.variant ?? 'static',\n\t\t\t\t...(this.config.subdomain ? { subdomain: this.config.subdomain } : {}),\n\t\t\t\t...(this.config.aliases?.length\n\t\t\t\t\t? { aliases: [...this.config.aliases] }\n\t\t\t\t\t: {}),\n\t\t\t\t...(this.config.redirects?.length\n\t\t\t\t\t? { redirects: [...this.config.redirects] }\n\t\t\t\t\t: {}),\n\t\t\t\t...(hosts\n\t\t\t\t\t? {\n\t\t\t\t\t\t\thosts: {\n\t\t\t\t\t\t\t\tsurface: canonicalId(hosts.surface.id),\n\t\t\t\t\t\t\t\tpath: 'route' in hosts ? hosts.route : hosts.path,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t}\n\t\t\t\t\t: {}),\n\t\t\t\tapp: {\n\t\t\t\t\tpath: this.config.path,\n\t\t\t\t\t...(this.config.port ? { port: this.config.port } : {}),\n\t\t\t\t\t...(this.config.config ? { config: this.config.config } : {}),\n\t\t\t\t},\n\t\t\t\t...(this.config.root ? { root: true } : {}),\n\t\t\t\tdependencies: this.dependencies,\n\t\t\t\t...(this.config.telemetry\n\t\t\t\t\t? { telemetry: this.config.telemetry.id }\n\t\t\t\t\t: {}),\n\t\t\t\t...(this.config.password\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tpassword: {\n\t\t\t\t\t\t\t\tsecret: this.config.password.secret.id,\n\t\t\t\t\t\t\t\tstages: [...this.config.password.stages],\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t}\n\t\t\t\t\t: {}),\n\t\t\t\t...(this.config.prerender ? { prerender: this.config.prerender } : {}),\n\t\t\t\tprovides: [\n\t\t\t\t\tthis.keys.url,\n\t\t\t\t\t// The tenant comes off the host it was reached on, whether or\n\t\t\t\t\t// not an edge asks the app about it first.\n\t\t\t\t\t...(wildcard\n\t\t\t\t\t\t? [\n\t\t\t\t\t\t\t\tprovidedKeyFor(this.id, 'site', 'domain'),\n\t\t\t\t\t\t\t\tprovidedKeyFor(this.id, 'site', 'protectedSubdomains'),\n\t\t\t\t\t\t\t]\n\t\t\t\t\t\t: []),\n\t\t\t\t],\n\t\t\t},\n\t\t];\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiPA,IAAa,yBAAb,cAA4C,MAAM;CAC5B;CAArB,YAAY,IAAqB;EAChC,MACC,IAAI,GAAG,2HAER;EAJoB,KAAA,KAAA;EAKpB,KAAK,OAAO;CACb;AACD;;AAGA,IAAa,kBAAb,cAAqC,MAAM;CAEhC;CACA;CACA;CAHV,YACC,IACA,QACA,OACC;EACD,MACC,IAAI,GAAG,0BAA0B,OAAO,GAAG,MAAM,+BACpC,MAAM,wCACpB;EAPS,KAAA,KAAA;EACA,KAAA,SAAA;EACA,KAAA,QAAA;EAMT,KAAK,OAAO;CACb;AACD;;;;;;AAOA,IAAa,2BAAb,cAA8C,MAAM;CAEzC;CACA;CAFV,YACC,IACA,SACC;EACD,MACC,IAAI,GAAG,UAAU,QAAQ,2PAK1B;EATS,KAAA,KAAA;EACA,KAAA,UAAA;EAST,KAAK,OAAO;CACb;AACD;;AAGA,IAAa,2BAAb,cAA8C,MAAM;CAC9B;CAArB,YAAY,IAAqB;EAChC,MACC,IAAI,GAAG,sJAGR;EALoB,KAAA,KAAA;EAMpB,KAAK,OAAO;CACb;AACD;AAEA,IAAa,aAAb,MAAa,WAEb;CAamB;CAOA;CAnBlB;CACA;;;;;;CAOA;CAEA,YACC,IACA,QAOA,eAAuD,CAAC,GACvD;EARgB,KAAA,SAAA;EAOA,KAAA,eAAA;EAEjB,KAAK,KA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AAO,SAAS,SACtB,EAAE,SAAS,CAAC,GAAG,KAAK,OAAO,OAAO,EAAE,IACpC,CAAC;GACJ,GAAI,KAAK,OAAO,WAAW,SACxB,EAAE,WAAW,CAAC,GAAG,KAAK,OAAO,SAAS,EAAE,IACxC,CAAC;GACJ,GAAI,QACD,EACA,OAAO;IACN,SAAS,YAAY,MAAM,QAAQ,EAAE;IACrC,MAAM,WAAW,QAAQ,MAAM,QAAQ,MAAM;GAC9C,EACD,IACC,CAAC;GACJ,KAAK;IACJ,MAAM,KAAK,OAAO;IAClB,GAAI,KAAK,OAAO,OAAO,EAAE,MAAM,KAAK,OAAO,KAAK,IAAI,CAAC;IACrD,GAAI,KAAK,OAAO,SAAS,EAAE,QAAQ,KAAK,OAAO,OAAO,IAAI,CAAC;GAC5D;GACA,GAAI,KAAK,OAAO,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;GACzC,cAAc,KAAK;GACnB,GAAI,KAAK,OAAO,YACb,EAAE,WAAW,KAAK,OAAO,UAAU,GAAG,IACtC,CAAC;GACJ,GAAI,KAAK,OAAO,WACb,EACA,UAAU;IACT,QAAQ,KAAK,OAAO,SAAS,OAAO;IACpC,QAAQ,CAAC,GAAG,KAAK,OAAO,SAAS,MAAM;GACxC,EACD,IACC,CAAC;GACJ,GAAI,KAAK,OAAO,YAAY,EAAE,WAAW,KAAK,OAAO,UAAU,IAAI,CAAC;GACpE,UAAU,CACT,KAAK,KAAK,KAGV,GAAI,WACD,CACA,eAAe,KAAK,IAAI,QAAQ,QAAQ,GACxC,eAAe,KAAK,IAAI,QAAQ,qBAAqB,CACtD,IACC,CAAC,CACL;EACD,CACD;CACD;AACD"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@geekmidas/constructs",
3
- "version": "10.0.0-alpha.186",
3
+ "version": "10.0.0-alpha.188",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "exports": {
@@ -345,13 +345,13 @@
345
345
  "lodash.uniqby": "~4.7.0",
346
346
  "openapi-types": "~12.1.3",
347
347
  "qs": "~6.16.0",
348
- "@geekmidas/envkit": ">=10.0.0-alpha.186 <10.0.0",
349
- "@geekmidas/errors": ">=10.0.0-alpha.186 <10.0.0",
350
- "@geekmidas/events": ">=10.0.0-alpha.186 <10.0.0",
351
- "@geekmidas/logger": ">=10.0.0-alpha.186 <10.0.0",
352
- "@geekmidas/manifest": ">=10.0.0-alpha.186 <10.0.0",
353
- "@geekmidas/schema": ">=10.0.0-alpha.186 <10.0.0",
354
- "@geekmidas/services": ">=10.0.0-alpha.186 <10.0.0"
348
+ "@geekmidas/envkit": ">=10.0.0-alpha.188 <10.0.0",
349
+ "@geekmidas/errors": ">=10.0.0-alpha.188 <10.0.0",
350
+ "@geekmidas/events": ">=10.0.0-alpha.188 <10.0.0",
351
+ "@geekmidas/logger": ">=10.0.0-alpha.188 <10.0.0",
352
+ "@geekmidas/manifest": ">=10.0.0-alpha.188 <10.0.0",
353
+ "@geekmidas/schema": ">=10.0.0-alpha.188 <10.0.0",
354
+ "@geekmidas/services": ">=10.0.0-alpha.188 <10.0.0"
355
355
  },
356
356
  "devDependencies": {
357
357
  "@aws-sdk/client-apigatewaymanagementapi": "~3.1136.0",
@@ -374,20 +374,20 @@
374
374
  "pg": "~8.23.0",
375
375
  "ws": "~8.22.0",
376
376
  "zod": "~4.6.5",
377
- "@geekmidas/audit": ">=10.0.0-alpha.186 <10.0.0",
378
- "@geekmidas/auth": "10.0.0-alpha.186",
379
- "@geekmidas/cache": ">=10.0.0-alpha.186 <10.0.0",
380
- "@geekmidas/db": ">=10.0.0-alpha.186 <10.0.0",
381
- "@geekmidas/emailkit": ">=10.0.0-alpha.186 <10.0.0",
382
- "@geekmidas/envkit": ">=10.0.0-alpha.186 <10.0.0",
383
- "@geekmidas/errors": ">=10.0.0-alpha.186 <10.0.0",
384
- "@geekmidas/events": ">=10.0.0-alpha.186 <10.0.0",
385
- "@geekmidas/logger": ">=10.0.0-alpha.186 <10.0.0",
386
- "@geekmidas/rate-limit": ">=10.0.0-alpha.186 <10.0.0",
387
- "@geekmidas/schema": ">=10.0.0-alpha.186 <10.0.0",
388
- "@geekmidas/services": ">=10.0.0-alpha.186 <10.0.0",
389
- "@geekmidas/telescope": "10.0.0-alpha.186",
390
- "@geekmidas/testkit": ">=10.0.0-alpha.186 <10.0.0"
377
+ "@geekmidas/audit": ">=10.0.0-alpha.188 <10.0.0",
378
+ "@geekmidas/auth": "10.0.0-alpha.188",
379
+ "@geekmidas/cache": ">=10.0.0-alpha.188 <10.0.0",
380
+ "@geekmidas/db": ">=10.0.0-alpha.188 <10.0.0",
381
+ "@geekmidas/emailkit": ">=10.0.0-alpha.188 <10.0.0",
382
+ "@geekmidas/envkit": ">=10.0.0-alpha.188 <10.0.0",
383
+ "@geekmidas/errors": ">=10.0.0-alpha.188 <10.0.0",
384
+ "@geekmidas/events": ">=10.0.0-alpha.188 <10.0.0",
385
+ "@geekmidas/logger": ">=10.0.0-alpha.188 <10.0.0",
386
+ "@geekmidas/rate-limit": ">=10.0.0-alpha.188 <10.0.0",
387
+ "@geekmidas/schema": ">=10.0.0-alpha.188 <10.0.0",
388
+ "@geekmidas/services": ">=10.0.0-alpha.188 <10.0.0",
389
+ "@geekmidas/telescope": "10.0.0-alpha.188",
390
+ "@geekmidas/testkit": ">=10.0.0-alpha.188 <10.0.0"
391
391
  },
392
392
  "peerDependencies": {
393
393
  "@aws-sdk/client-apigatewaymanagementapi": ">=3.1136.0",
@@ -403,15 +403,15 @@
403
403
  "msw": ">=2.15.0",
404
404
  "pg": ">=8.23.0",
405
405
  "ws": ">=8.22.0",
406
- "@geekmidas/audit": ">=10.0.0-alpha.186 <10.0.0",
407
- "@geekmidas/auth": "10.0.0-alpha.186",
408
- "@geekmidas/cache": ">=10.0.0-alpha.186 <10.0.0",
409
- "@geekmidas/db": ">=10.0.0-alpha.186 <10.0.0",
410
- "@geekmidas/emailkit": ">=10.0.0-alpha.186 <10.0.0",
411
- "@geekmidas/rate-limit": ">=10.0.0-alpha.186 <10.0.0",
412
- "@geekmidas/storage": ">=10.0.0-alpha.186 <10.0.0",
413
- "@geekmidas/telescope": "10.0.0-alpha.186",
414
- "@geekmidas/testkit": ">=10.0.0-alpha.186 <10.0.0"
406
+ "@geekmidas/audit": ">=10.0.0-alpha.188 <10.0.0",
407
+ "@geekmidas/auth": "10.0.0-alpha.188",
408
+ "@geekmidas/cache": ">=10.0.0-alpha.188 <10.0.0",
409
+ "@geekmidas/db": ">=10.0.0-alpha.188 <10.0.0",
410
+ "@geekmidas/emailkit": ">=10.0.0-alpha.188 <10.0.0",
411
+ "@geekmidas/rate-limit": ">=10.0.0-alpha.188 <10.0.0",
412
+ "@geekmidas/storage": ">=10.0.0-alpha.188 <10.0.0",
413
+ "@geekmidas/telescope": "10.0.0-alpha.188",
414
+ "@geekmidas/testkit": ">=10.0.0-alpha.188 <10.0.0"
415
415
  },
416
416
  "peerDependenciesMeta": {
417
417
  "@aws-sdk/client-apigatewaymanagementapi": {