clefbase 1.3.4 → 1.3.6

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/cli.js CHANGED
@@ -33736,6 +33736,18 @@ async function createSite(cfg, name, description) {
33736
33736
  }
33737
33737
  );
33738
33738
  }
33739
+ async function getDnsStatus(cfg, siteId) {
33740
+ return apiFetch(
33741
+ `${base(cfg)}/api/hosting/databases/${cfg.projectId}/sites/${siteId}/dns`,
33742
+ { headers: adminHeaders(cfg) }
33743
+ );
33744
+ }
33745
+ async function reprovisionDns(cfg, siteId) {
33746
+ return apiFetch(
33747
+ `${base(cfg)}/api/hosting/databases/${cfg.projectId}/sites/${siteId}/dns/provision`,
33748
+ { method: "POST", headers: adminHeaders(cfg), body: JSON.stringify({}) }
33749
+ );
33750
+ }
33739
33751
  async function createDeploy(cfg, siteId, entrypoint = "index.html") {
33740
33752
  return apiFetch(
33741
33753
  `${base(cfg)}/api/hosting/databases/${cfg.projectId}/sites/${siteId}/deploys`,
@@ -34139,6 +34151,9 @@ function fmtBytes(n) {
34139
34151
  if (n < 1024 * 1024) return `${(n / 1024).toFixed(1)} KB`;
34140
34152
  return `${(n / (1024 * 1024)).toFixed(2)} MB`;
34141
34153
  }
34154
+ function siteUrl(site) {
34155
+ return site.customDomain ? `https://${site.customDomain}` : site.previewUrl;
34156
+ }
34142
34157
  async function runDeploy(opts) {
34143
34158
  var _a, _b, _c, _d, _e, _f, _g, _h;
34144
34159
  const cwd = opts.cwd ?? process.cwd();
@@ -34148,17 +34163,22 @@ async function runDeploy(opts) {
34148
34163
  console.log();
34149
34164
  let siteId = opts.site ?? ((_a = cfg.hosting) == null ? void 0 : _a.siteId) ?? "";
34150
34165
  let siteName = ((_b = cfg.hosting) == null ? void 0 : _b.siteName) ?? "";
34166
+ let previewUrl = "";
34151
34167
  if (!siteId) {
34152
- siteId = await pickOrCreateSite(cfg);
34153
- const sites = await listSites(cfg).catch(() => []);
34154
- siteName = ((_c = sites.find((s) => s.id === siteId)) == null ? void 0 : _c.name) ?? siteId;
34168
+ const site = await pickOrCreateSite(cfg);
34169
+ siteId = site.id;
34170
+ siteName = site.name;
34171
+ previewUrl = site.previewUrl;
34155
34172
  cfg.hosting = {
34156
34173
  siteId,
34157
34174
  siteName,
34158
- distDir: ((_d = cfg.hosting) == null ? void 0 : _d.distDir) ?? "dist",
34159
- entrypoint: ((_e = cfg.hosting) == null ? void 0 : _e.entrypoint) ?? "index.html"
34175
+ previewUrl,
34176
+ distDir: ((_c = cfg.hosting) == null ? void 0 : _c.distDir) ?? "dist",
34177
+ entrypoint: ((_d = cfg.hosting) == null ? void 0 : _d.entrypoint) ?? "index.html"
34160
34178
  };
34161
34179
  saveConfig(cfg, cwd);
34180
+ } else {
34181
+ previewUrl = ((_e = cfg.hosting) == null ? void 0 : _e.previewUrl) ?? "";
34162
34182
  }
34163
34183
  const distDir = opts.dir ?? ((_f = cfg.hosting) == null ? void 0 : _f.distDir) ?? await promptDistDir(cwd);
34164
34184
  const absDir = import_path3.default.isAbsolute(distDir) ? distDir : import_path3.default.join(cwd, distDir);
@@ -34185,9 +34205,10 @@ async function runDeploy(opts) {
34185
34205
  console.warn(source_default.yellow(` \u26A0 Entrypoint "${entrypoint}" not found \u2014 is your build output correct?`));
34186
34206
  }
34187
34207
  console.log();
34188
- console.log(` ${source_default.bold("Site:")} ${siteName} ${source_default.dim(siteId)}`);
34189
- console.log(` ${source_default.bold("From:")} ${import_path3.default.relative(cwd, absDir)}`);
34190
- console.log(` ${source_default.bold("Files:")} ${files.length} ${source_default.dim("(" + fmtBytes(totalBytes) + ")")}`);
34208
+ console.log(` ${source_default.bold("Site:")} ${siteName} ${source_default.dim(siteId)}`);
34209
+ console.log(` ${source_default.bold("Preview:")} ${source_default.cyan(previewUrl || "(set after deploy)")}`);
34210
+ console.log(` ${source_default.bold("From:")} ${import_path3.default.relative(cwd, absDir)}`);
34211
+ console.log(` ${source_default.bold("Files:")} ${files.length} ${source_default.dim("(" + fmtBytes(totalBytes) + ")")}`);
34191
34212
  console.log();
34192
34213
  const deploySpinner = ora2("Creating deploy\u2026").start();
34193
34214
  let deploy;
@@ -34231,38 +34252,60 @@ async function runDeploy(opts) {
34231
34252
  finSpinner.fail(`Finalize failed: ${err.message}`);
34232
34253
  process.exit(1);
34233
34254
  }
34234
- const url = `${cfg.serverUrl.replace(/\/+$/, "")}/hosted/${cfg.projectId}/${siteId}`;
34255
+ let canonicalUrl = previewUrl;
34256
+ try {
34257
+ const sites = await listSites(cfg);
34258
+ const liveSite = sites.find((s) => s.id === siteId);
34259
+ if (liveSite) {
34260
+ canonicalUrl = siteUrl(liveSite);
34261
+ if (cfg.hosting && liveSite.previewUrl && cfg.hosting.previewUrl !== liveSite.previewUrl) {
34262
+ cfg.hosting.previewUrl = liveSite.previewUrl;
34263
+ saveConfig(cfg, cwd);
34264
+ }
34265
+ }
34266
+ } catch {
34267
+ }
34235
34268
  console.log();
34236
- console.log(source_default.green.bold(` \u2713 ${url}`));
34269
+ if (canonicalUrl) {
34270
+ console.log(source_default.green.bold(` \u2713 ${canonicalUrl}`));
34271
+ }
34237
34272
  console.log();
34238
34273
  }
34239
34274
  async function runHostingInit(cwd = process.cwd()) {
34240
- var _a, _b, _c;
34275
+ var _a, _b;
34241
34276
  const cfg = requireConfig(cwd);
34242
34277
  console.log();
34243
34278
  console.log(source_default.bold.cyan(" Hosting Setup"));
34244
34279
  console.log();
34245
- const siteId = await pickOrCreateSite(cfg);
34246
- const sites = await listSites(cfg).catch(() => []);
34247
- const siteName = ((_a = sites.find((s) => s.id === siteId)) == null ? void 0 : _a.name) ?? siteId;
34280
+ const site = await pickOrCreateSite(cfg);
34248
34281
  const { distDir } = await lib_default.prompt([{
34249
34282
  type: "input",
34250
34283
  name: "distDir",
34251
34284
  message: "Build output directory",
34252
- default: ((_b = cfg.hosting) == null ? void 0 : _b.distDir) ?? guessDistDir2(cwd),
34285
+ default: ((_a = cfg.hosting) == null ? void 0 : _a.distDir) ?? guessDistDir2(cwd),
34253
34286
  validate: (v) => v.trim().length > 0 || "Required"
34254
34287
  }]);
34255
34288
  const { entrypoint } = await lib_default.prompt([{
34256
34289
  type: "input",
34257
34290
  name: "entrypoint",
34258
34291
  message: "HTML entrypoint",
34259
- default: ((_c = cfg.hosting) == null ? void 0 : _c.entrypoint) ?? "index.html"
34292
+ default: ((_b = cfg.hosting) == null ? void 0 : _b.entrypoint) ?? "index.html"
34260
34293
  }]);
34261
34294
  cfg.services.hosting = true;
34262
- cfg.hosting = { siteId, siteName, distDir: distDir.trim(), entrypoint: entrypoint.trim() };
34295
+ cfg.hosting = {
34296
+ siteId: site.id,
34297
+ siteName: site.name,
34298
+ previewUrl: site.previewUrl,
34299
+ distDir: distDir.trim(),
34300
+ entrypoint: entrypoint.trim()
34301
+ };
34263
34302
  saveConfig(cfg, cwd);
34264
34303
  console.log();
34265
- console.log(source_default.green(` \u2713 Linked to "${siteName}"`));
34304
+ console.log(source_default.green(` \u2713 Linked to "${site.name}"`));
34305
+ console.log(source_default.dim(` Preview URL: ${site.previewUrl}`));
34306
+ if (site.dnsWarning) {
34307
+ console.log(source_default.yellow(` \u26A0 ${site.dnsWarning}`));
34308
+ }
34266
34309
  console.log(source_default.dim(" Run `clefbase deploy` to go live."));
34267
34310
  console.log();
34268
34311
  }
@@ -34284,20 +34327,87 @@ async function runStatus(cwd = process.cwd()) {
34284
34327
  } else {
34285
34328
  sp.succeed("Active deploy");
34286
34329
  const d = active.deploy;
34287
- const url = `${cfg.serverUrl.replace(/\/+$/, "")}/hosted/${cfg.projectId}/${cfg.hosting.siteId}`;
34288
34330
  console.log();
34289
34331
  console.log(` ${source_default.bold("Site:")} ${cfg.hosting.siteName} ${source_default.dim(cfg.hosting.siteId)}`);
34290
34332
  console.log(` ${source_default.bold("Deploy:")} ${source_default.dim(d.id)}`);
34291
34333
  console.log(` ${source_default.bold("Status:")} ${source_default.green(d.status)}`);
34292
34334
  console.log(` ${source_default.bold("Files:")} ${d.fileCount} ${source_default.dim(fmtBytes(d.totalBytes ?? 0))}`);
34293
34335
  console.log(` ${source_default.bold("Deployed:")} ${new Date(d.finishedAt ?? d.createdAt).toLocaleString()}`);
34294
- console.log(` ${source_default.bold("URL:")} ${url}`);
34336
+ if (cfg.hosting.previewUrl) {
34337
+ console.log(` ${source_default.bold("Preview:")} ${source_default.cyan(cfg.hosting.previewUrl)}`);
34338
+ }
34295
34339
  }
34296
34340
  } catch (err) {
34297
34341
  sp.fail(err.message);
34298
34342
  }
34299
34343
  console.log();
34300
34344
  }
34345
+ async function runDnsStatus(cwd = process.cwd()) {
34346
+ var _a;
34347
+ const cfg = requireConfig(cwd);
34348
+ console.log();
34349
+ console.log(source_default.bold(" DNS Status"));
34350
+ console.log();
34351
+ if (!((_a = cfg.hosting) == null ? void 0 : _a.siteId)) {
34352
+ console.log(source_default.yellow(" No site linked. Run `clefbase hosting:init` first.\n"));
34353
+ return;
34354
+ }
34355
+ const sp = ora2("Checking DNS records\u2026").start();
34356
+ try {
34357
+ const dns = await getDnsStatus(cfg, cfg.hosting.siteId);
34358
+ sp.succeed("DNS checked");
34359
+ console.log();
34360
+ console.log(` ${source_default.bold("Preview subdomain:")}`);
34361
+ console.log(` URL: ${source_default.cyan(dns.previewUrl)}`);
34362
+ if (dns.preview.isCorrect) {
34363
+ console.log(` DNS: ${source_default.green("\u2713 Correctly configured")}`);
34364
+ } else if (dns.preview.isConflict) {
34365
+ console.log(` DNS: ${source_default.red("\u2717 Conflict \u2014 " + dns.preview.message)}`);
34366
+ console.log(source_default.dim(" Run `clefbase hosting:dns:reprovision` to fix."));
34367
+ } else {
34368
+ console.log(` DNS: ${source_default.yellow("\u26A0 Not yet provisioned")}`);
34369
+ console.log(source_default.dim(" Run `clefbase hosting:dns:reprovision` to create the record."));
34370
+ }
34371
+ if (dns.customDomain) {
34372
+ console.log();
34373
+ console.log(` ${source_default.bold("Custom domain:")}`);
34374
+ console.log(` Domain: ${dns.customDomain.domain}`);
34375
+ if (dns.customDomain.cnameOk) {
34376
+ console.log(` DNS: ${source_default.green("\u2713 CNAME correctly points to " + dns.customDomain.cnameTarget)}`);
34377
+ } else if (dns.customDomain.conflict) {
34378
+ console.log(` DNS: ${source_default.red("\u2717 Conflict \u2014 existing record points to " + dns.customDomain.cnameTarget)}`);
34379
+ } else {
34380
+ console.log(` DNS: ${source_default.yellow("\u26A0 CNAME not yet set")}`);
34381
+ console.log(` Add: CNAME ${dns.customDomain.instructions.name} \u2192 ${dns.customDomain.instructions.content}`);
34382
+ console.log(source_default.dim(` Note: ${dns.customDomain.instructions.note}`));
34383
+ }
34384
+ }
34385
+ } catch (err) {
34386
+ sp.fail(err.message);
34387
+ }
34388
+ console.log();
34389
+ }
34390
+ async function runDnsReprovision(cwd = process.cwd()) {
34391
+ var _a;
34392
+ const cfg = requireConfig(cwd);
34393
+ if (!((_a = cfg.hosting) == null ? void 0 : _a.siteId)) {
34394
+ console.error(source_default.red("\n No site linked. Run `clefbase hosting:init` first.\n"));
34395
+ process.exit(1);
34396
+ }
34397
+ const sp = ora2(`Provisioning DNS for ${cfg.hosting.siteName}\u2026`).start();
34398
+ try {
34399
+ const result = await reprovisionDns(cfg, cfg.hosting.siteId);
34400
+ if (result.created) {
34401
+ sp.succeed(source_default.green(`DNS record created: ${result.subdomain}`));
34402
+ } else {
34403
+ sp.succeed(source_default.dim(`DNS record already correct: ${result.subdomain}`));
34404
+ }
34405
+ console.log(source_default.cyan(` ${result.url}`));
34406
+ } catch (err) {
34407
+ sp.fail(err.message);
34408
+ }
34409
+ console.log();
34410
+ }
34301
34411
  async function pickOrCreateSite(cfg) {
34302
34412
  const sp = ora2("Fetching sites\u2026").start();
34303
34413
  let sites = [];
@@ -34309,7 +34419,10 @@ async function pickOrCreateSite(cfg) {
34309
34419
  }
34310
34420
  if (sites.length > 0) {
34311
34421
  const choices = [
34312
- ...sites.map((s2) => ({ name: `${s2.name} ${source_default.dim(s2.id)}`, value: s2.id })),
34422
+ ...sites.map((s) => ({
34423
+ name: `${s.name} ${source_default.dim(s.previewUrl || s.id)}`,
34424
+ value: s.id
34425
+ })),
34313
34426
  { name: source_default.cyan("+ Create a new site"), value: "__new__" }
34314
34427
  ];
34315
34428
  const { chosen } = await lib_default.prompt([{
@@ -34318,18 +34431,39 @@ async function pickOrCreateSite(cfg) {
34318
34431
  message: "Which site should receive this deploy?",
34319
34432
  choices
34320
34433
  }]);
34321
- if (chosen !== "__new__") return chosen;
34434
+ if (chosen !== "__new__") {
34435
+ return sites.find((s) => s.id === chosen);
34436
+ }
34437
+ }
34438
+ return createSiteInteractive(cfg);
34439
+ }
34440
+ async function createSiteInteractive(cfg) {
34441
+ while (true) {
34442
+ const { name } = await lib_default.prompt([{
34443
+ type: "input",
34444
+ name: "name",
34445
+ message: "New site name (used as subdomain, e.g. my-app \u2192 my-app.preview.cleforyx.com)",
34446
+ validate: (v) => v.trim().length >= 2 || "Must be at least 2 characters"
34447
+ }]);
34448
+ const s = ora2(`Creating "${name.trim()}"\u2026`).start();
34449
+ try {
34450
+ const site = await createSite(cfg, name.trim());
34451
+ s.succeed(source_default.green(`Created "${site.name}" \u2192 ${source_default.cyan(site.previewUrl)}`));
34452
+ if (site.dnsWarning) {
34453
+ console.log(source_default.yellow(` \u26A0 ${site.dnsWarning}`));
34454
+ }
34455
+ return site;
34456
+ } catch (err) {
34457
+ const message = err.message;
34458
+ if (message.toLowerCase().includes("already exists") || message.includes("409")) {
34459
+ s.fail(source_default.red(message));
34460
+ console.log(source_default.dim(" Please choose a different name.\n"));
34461
+ } else {
34462
+ s.fail(message);
34463
+ throw err;
34464
+ }
34465
+ }
34322
34466
  }
34323
- const { name } = await lib_default.prompt([{
34324
- type: "input",
34325
- name: "name",
34326
- message: "New site name",
34327
- validate: (v) => v.trim().length > 0 || "Required"
34328
- }]);
34329
- const s = ora2(`Creating "${name}"\u2026`).start();
34330
- const site = await createSite(cfg, name.trim());
34331
- s.succeed(source_default.green(`Created "${site.name}" ${source_default.dim(site.id)}`));
34332
- return site.id;
34333
34467
  }
34334
34468
  async function promptDistDir(cwd) {
34335
34469
  const { dir } = await lib_default.prompt([{
@@ -34405,7 +34539,7 @@ async function runSitesList(cwd = process.cwd()) {
34405
34539
  }
34406
34540
 
34407
34541
  // package.json
34408
- var version = "1.3.4";
34542
+ var version = "1.3.6";
34409
34543
 
34410
34544
  // src/cli/index.ts
34411
34545
  var program2 = new Command();
@@ -34445,6 +34579,20 @@ program2.command("hosting:sites").alias("sites").description("List all hosted si
34445
34579
  fatal(err);
34446
34580
  }
34447
34581
  });
34582
+ program2.command("hosting:dns").alias("dns").description("Show DNS status for the linked site's preview and custom domains").action(async () => {
34583
+ try {
34584
+ await runDnsStatus();
34585
+ } catch (err) {
34586
+ fatal(err);
34587
+ }
34588
+ });
34589
+ program2.command("hosting:dns:reprovision").alias("dns:reprovision").description("(Re-)provision the Cloudflare CNAME for the linked site").action(async () => {
34590
+ try {
34591
+ await runDnsReprovision();
34592
+ } catch (err) {
34593
+ fatal(err);
34594
+ }
34595
+ });
34448
34596
  program2.command("info").description("Show project config and server connectivity").action(async () => {
34449
34597
  try {
34450
34598
  await runInfo();
@@ -34454,14 +34602,16 @@ program2.command("info").description("Show project config and server connectivit
34454
34602
  });
34455
34603
  program2.addHelpText("after", `
34456
34604
  ${source_default.bold("Examples:")}
34457
- ${source_default.cyan("clefbase init")} Set up a new project
34458
- ${source_default.cyan("clefbase deploy")} Deploy your built site
34459
- ${source_default.cyan("clefbase deploy -d ./dist")} Deploy from a specific directory
34460
- ${source_default.cyan('clefbase deploy -m "v2 release"')} Deploy with a release note
34461
- ${source_default.cyan("clefbase hosting:init")} Link or create a hosted site
34462
- ${source_default.cyan("clefbase hosting:status")} Show current live deploy
34463
- ${source_default.cyan("clefbase hosting:sites")} List all sites
34464
- ${source_default.cyan("clefbase info")} Show config & connection status
34605
+ ${source_default.cyan("clefbase init")} Set up a new project
34606
+ ${source_default.cyan("clefbase deploy")} Deploy your built site
34607
+ ${source_default.cyan("clefbase deploy -d ./dist")} Deploy from a specific directory
34608
+ ${source_default.cyan('clefbase deploy -m "v2 release"')} Deploy with a release note
34609
+ ${source_default.cyan("clefbase hosting:init")} Link or create a hosted site
34610
+ ${source_default.cyan("clefbase hosting:status")} Show current live deploy
34611
+ ${source_default.cyan("clefbase hosting:sites")} List all sites
34612
+ ${source_default.cyan("clefbase hosting:dns")} Show DNS status
34613
+ ${source_default.cyan("clefbase hosting:dns:reprovision")} Fix / create the preview CNAME
34614
+ ${source_default.cyan("clefbase info")} Show config & connection status
34465
34615
  `);
34466
34616
  program2.parse(process.argv);
34467
34617
  function fatal(err) {
@@ -5,9 +5,18 @@ export interface HostingSite {
5
5
  id: string;
6
6
  dbId: string;
7
7
  name: string;
8
+ /** URL-safe slug — globally unique, used for the preview subdomain */
9
+ slug: string;
8
10
  description?: string;
9
11
  status: HostingStatus;
12
+ /** Auto-provisioned: {slug}.preview.cleforyx.com */
13
+ previewUrl: string;
14
+ /** Optional custom domain the user has configured */
10
15
  customDomain?: string;
16
+ /** Cloudflare DNS record ID for the preview subdomain */
17
+ dnsRecordId?: string;
18
+ /** Non-fatal DNS warning set on creation if Cloudflare provisioning failed */
19
+ dnsWarning?: string;
11
20
  createdAt: string;
12
21
  updatedAt: string;
13
22
  }
@@ -39,7 +48,10 @@ export interface DeployResult {
39
48
  deploy: HostingDeploy;
40
49
  filesUploaded: number;
41
50
  errors: string[];
51
+ /** Canonical URL — custom domain if set, otherwise preview subdomain */
42
52
  url: string;
53
+ /** Always the preview subdomain */
54
+ previewUrl: string;
43
55
  }
44
56
  export interface DeployOptions {
45
57
  entrypoint?: string;
@@ -50,6 +62,32 @@ export interface DeployOptions {
50
62
  /** Called after each batch with progress info. */
51
63
  onProgress?: (uploaded: number, total: number) => void;
52
64
  }
65
+ export interface DnsStatus {
66
+ preview: {
67
+ exists: boolean;
68
+ isCorrect: boolean;
69
+ isConflict: boolean;
70
+ message: string;
71
+ record?: {
72
+ name: string;
73
+ type: string;
74
+ content: string;
75
+ };
76
+ };
77
+ customDomain?: {
78
+ domain: string;
79
+ cnameOk: boolean;
80
+ cnameTarget?: string;
81
+ conflict: boolean;
82
+ instructions: {
83
+ type: string;
84
+ name: string;
85
+ content: string;
86
+ note: string;
87
+ };
88
+ };
89
+ previewUrl: string;
90
+ }
53
91
  /**
54
92
  * A reference to a hosted site.
55
93
  *
@@ -57,6 +95,7 @@ export interface DeployOptions {
57
95
  * const site = hosting.site("my-site-id");
58
96
  * const result = await site.deployFiles({ "index.html": htmlBuffer, "app.js": jsBuffer });
59
97
  * console.log(`Live at ${result.url}`);
98
+ * console.log(`Preview at ${result.previewUrl}`);
60
99
  */
61
100
  export declare class SiteReference {
62
101
  private readonly hosting;
@@ -82,9 +121,23 @@ export declare class SiteReference {
82
121
  * message: "v1.2.0",
83
122
  * onProgress: (done, total) => console.log(`${done}/${total}`),
84
123
  * });
124
+ * console.log(`Live at ${result.url}`);
85
125
  */
86
126
  deployFiles(files: Record<string, Buffer>, opts?: DeployOptions): Promise<DeployResult>;
87
- /** The public URL for this site. */
127
+ /** Check the DNS status of this site's preview + custom domains. */
128
+ getDnsStatus(): Promise<DnsStatus>;
129
+ /** Re-provision the preview DNS record (e.g. if it was accidentally deleted). */
130
+ reprovisionDns(): Promise<{
131
+ subdomain: string;
132
+ url: string;
133
+ created: boolean;
134
+ }>;
135
+ /** The preview URL for this site ({slug}.preview.cleforyx.com). */
136
+ get previewUrl(): string;
137
+ /**
138
+ * The public URL — custom domain if configured, else preview subdomain.
139
+ * Requires the site metadata; use `(await site.get())?.customDomain` to check.
140
+ */
88
141
  get url(): string;
89
142
  }
90
143
  /**
@@ -92,7 +145,12 @@ export declare class SiteReference {
92
145
  *
93
146
  * @example
94
147
  * const hosting = getHosting(app);
148
+ *
149
+ * // Create a site — automatically provisions {name}.preview.cleforyx.com
95
150
  * const site = await hosting.createSite("my-app");
151
+ * console.log(site.previewUrl); // https://my-app.preview.cleforyx.com
152
+ *
153
+ * // Deploy files
96
154
  * const result = await hosting.site(site.id).deployFiles(files);
97
155
  * console.log(result.url);
98
156
  */
@@ -103,18 +161,46 @@ export declare class ClefbaseHosting {
103
161
  constructor(http: HttpClient, dbId: string, serverUrl: string);
104
162
  /** List all sites for this project. */
105
163
  listSites(): Promise<HostingSite[]>;
106
- /** Create a new hosted site. */
164
+ /**
165
+ * Create a new hosted site.
166
+ *
167
+ * Site names must be globally unique across the platform.
168
+ * A CNAME record will be automatically provisioned on Cloudflare:
169
+ * {slug}.preview.cleforyx.com → cleforyx.com
170
+ *
171
+ * Throws a 409 ConflictError if the name is already taken.
172
+ */
107
173
  createSite(name: string, description?: string): Promise<HostingSite>;
108
- /** Update site metadata. */
174
+ /** Update site metadata. Handles DNS rename if name changes. */
109
175
  updateSite(siteId: string, patch: Partial<Pick<HostingSite, "name" | "description" | "status" | "customDomain">>): Promise<HostingSite>;
110
- /** Delete a site and all its deploys permanently. */
111
- deleteSite(siteId: string): Promise<void>;
176
+ /**
177
+ * Begin site deletion flow.
178
+ *
179
+ * Pass `confirm: false` (or omit) to get a confirmation prompt with DNS info.
180
+ * Pass `confirm: true` to actually delete. Include `deleteDns: true` to also
181
+ * remove the Cloudflare DNS record.
182
+ */
183
+ deleteSite(siteId: string, opts?: {
184
+ confirm?: boolean;
185
+ deleteDns?: boolean;
186
+ }): Promise<{
187
+ requiresConfirmation?: boolean;
188
+ dnsRecord?: object;
189
+ message: string;
190
+ deleted?: boolean;
191
+ }>;
112
192
  /** Return a SiteReference for a specific site ID. */
113
193
  site(siteId: string): SiteReference;
114
- _siteUrl(siteId: string): string;
194
+ _previewUrl(siteId: string): string;
115
195
  _getSite(siteId: string): Promise<HostingSite | null>;
116
196
  _getActiveDeploy(siteId: string): Promise<HostingDeploy | null>;
117
197
  _listDeploys(siteId: string): Promise<HostingDeploy[]>;
198
+ _getDnsStatus(siteId: string): Promise<DnsStatus>;
199
+ _reprovisionDns(siteId: string): Promise<{
200
+ subdomain: string;
201
+ url: string;
202
+ created: boolean;
203
+ }>;
118
204
  _deployFiles(siteId: string, files: Record<string, Buffer>, opts?: DeployOptions): Promise<DeployResult>;
119
205
  }
120
206
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hosting/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAIrC,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG,UAAU,CAAC;AACnD,MAAM,MAAM,YAAY,GAAI,SAAS,GAAG,UAAU,GAAG,MAAM,GAAG,QAAQ,CAAC;AAEvE,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,aAAa,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,YAAY,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,SA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