@omnibase/cli 0.12.0 → 0.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (199) hide show
  1. package/dist/commands/auth.d.ts +1 -1
  2. package/dist/commands/auth.d.ts.map +1 -1
  3. package/dist/commands/auth.js +4 -4
  4. package/dist/commands/auth.js.map +1 -1
  5. package/dist/commands/cloud.d.ts +21 -2
  6. package/dist/commands/cloud.d.ts.map +1 -1
  7. package/dist/commands/cloud.js +211 -116
  8. package/dist/commands/cloud.js.map +1 -1
  9. package/dist/commands/db/index.d.ts +1 -1
  10. package/dist/commands/db/index.d.ts.map +1 -1
  11. package/dist/commands/db/index.js +5 -5
  12. package/dist/commands/db/index.js.map +1 -1
  13. package/dist/commands/db/migrate.d.ts +1 -1
  14. package/dist/commands/db/migrate.d.ts.map +1 -1
  15. package/dist/commands/db/migrate.js +54 -5
  16. package/dist/commands/db/migrate.js.map +1 -1
  17. package/dist/commands/db/policy.d.ts +1 -1
  18. package/dist/commands/db/policy.d.ts.map +1 -1
  19. package/dist/commands/db/policy.js +21 -19
  20. package/dist/commands/db/policy.js.map +1 -1
  21. package/dist/commands/docs.d.ts +3 -0
  22. package/dist/commands/docs.d.ts.map +1 -0
  23. package/dist/commands/docs.js +105 -0
  24. package/dist/commands/docs.js.map +1 -0
  25. package/dist/commands/email.d.ts +1 -1
  26. package/dist/commands/email.d.ts.map +1 -1
  27. package/dist/commands/email.js +4 -4
  28. package/dist/commands/email.js.map +1 -1
  29. package/dist/commands/environment.d.ts +1 -1
  30. package/dist/commands/environment.d.ts.map +1 -1
  31. package/dist/commands/environment.js +6 -2
  32. package/dist/commands/environment.js.map +1 -1
  33. package/dist/commands/migrate.d.ts +1 -1
  34. package/dist/commands/migrate.d.ts.map +1 -1
  35. package/dist/commands/migrate.js +7 -6
  36. package/dist/commands/migrate.js.map +1 -1
  37. package/dist/commands/permissions.d.ts +2 -2
  38. package/dist/commands/permissions.d.ts.map +1 -1
  39. package/dist/commands/permissions.js +71 -30
  40. package/dist/commands/permissions.js.map +1 -1
  41. package/dist/commands/restart.d.ts +1 -1
  42. package/dist/commands/restart.d.ts.map +1 -1
  43. package/dist/commands/restart.js +24 -8
  44. package/dist/commands/restart.js.map +1 -1
  45. package/dist/commands/stripe.d.ts +1 -1
  46. package/dist/commands/stripe.d.ts.map +1 -1
  47. package/dist/commands/stripe.js +151 -35
  48. package/dist/commands/stripe.js.map +1 -1
  49. package/dist/commands/sync.d.ts +1 -1
  50. package/dist/commands/sync.d.ts.map +1 -1
  51. package/dist/commands/sync.js +11 -7
  52. package/dist/commands/sync.js.map +1 -1
  53. package/dist/config/services.js.map +1 -1
  54. package/dist/index.d.ts.map +1 -1
  55. package/dist/index.js +208 -48
  56. package/dist/index.js.map +1 -1
  57. package/dist/lib/omnibase.d.ts.map +1 -1
  58. package/dist/lib/omnibase.js.map +1 -1
  59. package/dist/schemas/kratos-config.v25.4.0.schema.json +3182 -0
  60. package/dist/schemas/kratos-tracing-config.v25.4.0.schema.json +152 -0
  61. package/dist/services/db/generate/generate.d.ts.map +1 -1
  62. package/dist/services/db/generate/generate.js +5 -5
  63. package/dist/services/db/generate/generate.js.map +1 -1
  64. package/dist/services/db/generate/policies.d.ts.map +1 -1
  65. package/dist/services/db/generate/policies.js.map +1 -1
  66. package/dist/services/db/generate/rls/compile.d.ts.map +1 -1
  67. package/dist/services/db/generate/rls/compile.js +6 -2
  68. package/dist/services/db/generate/rls/compile.js.map +1 -1
  69. package/dist/services/db/generate/rls/diff.d.ts.map +1 -1
  70. package/dist/services/db/generate/rls/diff.js +6 -4
  71. package/dist/services/db/generate/rls/diff.js.map +1 -1
  72. package/dist/services/db/generate/rls/emit.d.ts.map +1 -1
  73. package/dist/services/db/generate/rls/emit.js +1 -1
  74. package/dist/services/db/generate/rls/emit.js.map +1 -1
  75. package/dist/services/db/generate/rls/schema.d.ts.map +1 -1
  76. package/dist/services/db/generate/rls/schema.js +1 -1
  77. package/dist/services/db/generate/rls/schema.js.map +1 -1
  78. package/dist/services/db/generate/rls-policies.d.ts +2 -2
  79. package/dist/services/db/generate/rls-policies.d.ts.map +1 -1
  80. package/dist/services/db/generate/rls-policies.js +5 -5
  81. package/dist/services/db/generate/rls-policies.js.map +1 -1
  82. package/dist/services/db/generate/utils.d.ts.map +1 -1
  83. package/dist/services/db/generate/utils.js.map +1 -1
  84. package/dist/services/db/migrate.d.ts +26 -7
  85. package/dist/services/db/migrate.d.ts.map +1 -1
  86. package/dist/services/db/migrate.js +72 -67
  87. package/dist/services/db/migrate.js.map +1 -1
  88. package/dist/services/db/utils.d.ts.map +1 -1
  89. package/dist/services/db/utils.js +8 -6
  90. package/dist/services/db/utils.js.map +1 -1
  91. package/dist/services/docs/client.d.ts +28 -0
  92. package/dist/services/docs/client.d.ts.map +1 -0
  93. package/dist/services/docs/client.js +139 -0
  94. package/dist/services/docs/client.js.map +1 -0
  95. package/dist/utils/agent-files.d.ts +2 -0
  96. package/dist/utils/agent-files.d.ts.map +1 -0
  97. package/dist/utils/agent-files.js +70 -0
  98. package/dist/utils/agent-files.js.map +1 -0
  99. package/dist/utils/api-client.d.ts +2 -2
  100. package/dist/utils/api-client.d.ts.map +1 -1
  101. package/dist/utils/api-client.js +1 -1
  102. package/dist/utils/api-client.js.map +1 -1
  103. package/dist/utils/auth-env.d.ts +9 -0
  104. package/dist/utils/auth-env.d.ts.map +1 -0
  105. package/dist/utils/auth-env.js +244 -0
  106. package/dist/utils/auth-env.js.map +1 -0
  107. package/dist/utils/config.d.ts +7 -19
  108. package/dist/utils/config.d.ts.map +1 -1
  109. package/dist/utils/config.js +23 -45
  110. package/dist/utils/config.js.map +1 -1
  111. package/dist/utils/context.d.ts +2 -2
  112. package/dist/utils/context.d.ts.map +1 -1
  113. package/dist/utils/context.js.map +1 -1
  114. package/dist/utils/credentials.d.ts.map +1 -1
  115. package/dist/utils/credentials.js +4 -4
  116. package/dist/utils/credentials.js.map +1 -1
  117. package/dist/utils/docker.d.ts +9 -2
  118. package/dist/utils/docker.d.ts.map +1 -1
  119. package/dist/utils/docker.js +101 -42
  120. package/dist/utils/docker.js.map +1 -1
  121. package/dist/utils/environment.d.ts +5 -2
  122. package/dist/utils/environment.d.ts.map +1 -1
  123. package/dist/utils/environment.js +34 -7
  124. package/dist/utils/environment.js.map +1 -1
  125. package/dist/utils/errors.js +1 -1
  126. package/dist/utils/errors.js.map +1 -1
  127. package/dist/utils/logger.d.ts.map +1 -1
  128. package/dist/utils/logger.js +5 -5
  129. package/dist/utils/logger.js.map +1 -1
  130. package/dist/utils/permission-namespaces.d.ts +33 -0
  131. package/dist/utils/permission-namespaces.d.ts.map +1 -0
  132. package/dist/utils/permission-namespaces.js +328 -0
  133. package/dist/utils/permission-namespaces.js.map +1 -0
  134. package/dist/utils/platform-requirements.d.ts +36 -0
  135. package/dist/utils/platform-requirements.d.ts.map +1 -0
  136. package/dist/utils/platform-requirements.js +135 -0
  137. package/dist/utils/platform-requirements.js.map +1 -0
  138. package/dist/utils/start-summary.d.ts +21 -0
  139. package/dist/utils/start-summary.d.ts.map +1 -0
  140. package/dist/utils/start-summary.js +55 -0
  141. package/dist/utils/start-summary.js.map +1 -0
  142. package/dist/utils/user-input.d.ts.map +1 -1
  143. package/dist/utils/user-input.js.map +1 -1
  144. package/dist/utils/versions.d.ts +10 -0
  145. package/dist/utils/versions.d.ts.map +1 -0
  146. package/dist/utils/versions.js +77 -0
  147. package/dist/utils/versions.js.map +1 -0
  148. package/docker/db/000022_drop_stripe_id_mappings.down.sql +18 -0
  149. package/docker/db/000022_drop_stripe_id_mappings.up.sql +1 -0
  150. package/docker/db/000023_email_tenant_templates.down.sql +30 -0
  151. package/docker/db/000023_email_tenant_templates.up.sql +48 -0
  152. package/docker/db/000024_email_history.down.sql +1 -0
  153. package/docker/db/000024_email_history.up.sql +15 -0
  154. package/docker/db/000025_manage_billing.down.sql +4 -0
  155. package/docker/db/000025_manage_billing.up.sql +5 -0
  156. package/docker/db/000026_authenticated_role.down.sql +2 -0
  157. package/docker/db/000026_authenticated_role.up.sql +21 -0
  158. package/docker/db/000027_unique_active_tenant.down.sql +1 -0
  159. package/docker/db/000027_unique_active_tenant.up.sql +13 -0
  160. package/docker/db/000028_drop_enterprise_pricing.down.sql +7 -0
  161. package/docker/db/000028_drop_enterprise_pricing.up.sql +8 -0
  162. package/docker/docker-compose.base.yml +35 -58
  163. package/docker/docker-compose.dev.yml +0 -36
  164. package/docker/docker-compose.perf-test.yml +0 -32
  165. package/docker/docker-compose.test.yml +0 -36
  166. package/docker/keto/permissions.yml +10 -0
  167. package/package.json +63 -62
  168. package/templates/.env.example +36 -0
  169. package/templates/AGENTS.md +41 -0
  170. package/templates/CLAUDE.md +1 -0
  171. package/templates/auth/identity.schema.json +47 -0
  172. package/templates/auth/oidc/apple.jsonnet +17 -0
  173. package/templates/auth/oidc/github.jsonnet +17 -0
  174. package/templates/auth/oidc/google.jsonnet +13 -0
  175. package/templates/auth/oidc/microsoft.jsonnet +22 -0
  176. package/templates/db/README.md +7 -3
  177. package/templates/db/policies/example.ts +11 -11
  178. package/templates/db/policies/index.ts +1 -1
  179. package/templates/email/auth/recovery/invalid/email.body.gotmpl +35 -0
  180. package/templates/email/auth/recovery/invalid/email.body.plaintext.gotmpl +19 -0
  181. package/templates/email/auth/recovery/invalid/email.subject.gotmpl +1 -0
  182. package/templates/email/auth/recovery/valid/email.body.gotmpl +85 -0
  183. package/templates/email/auth/recovery/valid/email.body.plaintext.gotmpl +10 -0
  184. package/templates/email/auth/recovery/valid/email.subject.gotmpl +1 -0
  185. package/templates/email/auth/verification/invalid/email.body.gotmpl +34 -0
  186. package/templates/email/auth/verification/invalid/email.body.plaintext.gotmpl +18 -0
  187. package/templates/email/auth/verification/invalid/email.subject.gotmpl +1 -0
  188. package/templates/email/auth/verification/valid/email.body.gotmpl +85 -0
  189. package/templates/email/auth/verification/valid/email.body.plaintext.gotmpl +10 -0
  190. package/templates/email/auth/verification/valid/email.subject.gotmpl +1 -0
  191. package/templates/omnibase.toml +90 -13
  192. package/templates/stripe/example.config.json +39 -33
  193. package/templates/tsconfig.json +17 -17
  194. package/templates/workers/package.json +21 -21
  195. package/templates/workers/src/index.ts +10 -10
  196. package/templates/workers/tsconfig.json +24 -24
  197. package/templates/permissions/storage.ts +0 -50
  198. package/templates/permissions/tenants.ts +0 -120
  199. package/templates/permissions/types.ts +0 -16
@@ -45,24 +45,28 @@ exports.pickLiveBranch = pickLiveBranch;
45
45
  exports.buildBranchEnv = buildBranchEnv;
46
46
  exports.stripUnresolvedOidcProviders = stripUnresolvedOidcProviders;
47
47
  exports.pushEnvConfig = pushEnvConfig;
48
+ exports.findPlanById = findPlanById;
49
+ exports.findPostgresById = findPostgresById;
48
50
  exports.addCloudCommands = addCloudCommands;
49
- const child_process_1 = require("child_process");
50
- const promises_1 = require("fs/promises");
51
- const fs = __importStar(require("fs"));
51
+ const node_child_process_1 = require("node:child_process");
52
+ const fs = __importStar(require("node:fs"));
53
+ const promises_1 = require("node:fs/promises");
54
+ const path = __importStar(require("node:path"));
55
+ const prompts_1 = require("@inquirer/prompts");
56
+ const axios_1 = __importDefault(require("axios"));
52
57
  const form_data_1 = __importDefault(require("form-data"));
53
58
  const jszip_1 = __importDefault(require("jszip"));
54
59
  const TOML = __importStar(require("smol-toml"));
55
- const axios_1 = __importDefault(require("axios"));
56
- const prompts_1 = require("@inquirer/prompts");
57
- const path = __importStar(require("path"));
58
- const environment_1 = require("../utils/environment");
59
- const credentials_1 = require("../utils/credentials");
60
- const logger_1 = require("../utils/logger");
61
- const errors_1 = require("../utils/errors");
62
60
  const api_client_1 = require("../utils/api-client");
61
+ const auth_env_1 = require("../utils/auth-env");
63
62
  const config_1 = require("../utils/config");
63
+ const credentials_1 = require("../utils/credentials");
64
+ const environment_1 = require("../utils/environment");
65
+ const errors_1 = require("../utils/errors");
66
+ const logger_1 = require("../utils/logger");
64
67
  function unwrapManagedHostingData(body) {
65
- return (body?.data ?? body);
68
+ const record = body;
69
+ return (record?.data ?? body);
66
70
  }
67
71
  /**
68
72
  * Login to OmniBase Cloud
@@ -178,7 +182,9 @@ async function switchProfile(profileName) {
178
182
  if (!credentials.profiles[profileName]) {
179
183
  logger_1.logger.fail(`Profile '${profileName}' not found.`);
180
184
  logger_1.logger.log("Available profiles:");
181
- profiles.forEach((p) => { logger_1.logger.log(` - ${p}`); });
185
+ profiles.forEach((p) => {
186
+ logger_1.logger.log(` - ${p}`);
187
+ });
182
188
  return;
183
189
  }
184
190
  credentials.active_profile = profileName;
@@ -223,25 +229,20 @@ async function listProfiles() {
223
229
  });
224
230
  }
225
231
  /**
226
- * Get deployments from config or fall back to legacy single-worker dir
232
+ * Get deployments from config
227
233
  */
228
234
  function getDeployments(root) {
229
235
  const config = (0, config_1.loadConfig)(root);
230
236
  if (config.deployments.length > 0)
231
237
  return config.deployments;
232
- const legacyWorkersDir = path.join(root, "omnibase", "workers");
233
- if (fs.existsSync(legacyWorkersDir)) {
234
- return [{ name: "default", path: "workers" }];
235
- }
236
- throw new Error("No deployments found. Add [[deployments]] to omnibase/omnibase.toml\n" +
237
- " or create omnibase/workers/ for the default deployment.");
238
+ throw new Error("No deployments found. Add [[deployments]] to omnibase/omnibase.toml.");
238
239
  }
239
240
  /**
240
241
  * Deploy workers to Cloudflare via managed hosting
241
242
  */
242
243
  async function deployWorkers(envFlag, nameFlag, allFlag) {
243
244
  const root = (0, environment_1.findOmnibaseRoot)();
244
- const env = await (0, environment_1.selectEnvironment)(envFlag);
245
+ const env = await (0, environment_1.resolveEnvironment)(envFlag);
245
246
  if (env.name === "local") {
246
247
  logger_1.logger.warn("Workers deployment is not available for local environment.");
247
248
  logger_1.logger.log("Use --env flag to specify a cloud environment:");
@@ -259,7 +260,7 @@ async function deployWorkers(envFlag, nameFlag, allFlag) {
259
260
  `Ensure your profile is configured: 'omnibase cloud login'`);
260
261
  }
261
262
  const deployments = getDeployments(root);
262
- const config = (0, config_1.loadConfig)(root);
263
+ const _config = (0, config_1.loadConfig)(root);
263
264
  const secrets = (0, config_1.loadSecretsMap)(root, env.name);
264
265
  let targets;
265
266
  if (nameFlag) {
@@ -293,13 +294,13 @@ async function deployWorkers(envFlag, nameFlag, allFlag) {
293
294
  }
294
295
  logger_1.logger.start(`Building '${dep.name}' for ${env.name}...`);
295
296
  try {
296
- (0, child_process_1.execSync)("bunx wrangler deploy --dry-run --outdir .bundle", {
297
+ (0, node_child_process_1.execSync)("bunx wrangler deploy --dry-run --outdir .bundle", {
297
298
  cwd: workersDir,
298
299
  stdio: "inherit",
299
300
  env: { ...process.env, ...secrets },
300
301
  });
301
302
  }
302
- catch (error) {
303
+ catch (_error) {
303
304
  logger_1.logger.fail(`Build failed for '${dep.name}'. Check the output above.`);
304
305
  failures.push(dep.name);
305
306
  continue;
@@ -338,7 +339,10 @@ async function packageWorkerBundle(workersDir, secrets = {}) {
338
339
  const assetsDir = config.assets?.directory;
339
340
  if (assetsDir) {
340
341
  config.assets = { ...config.assets, directory: "assets" };
341
- await addDirToZip(zip.folder("assets"), path.join(workersDir, assetsDir));
342
+ const assetsZip = zip.folder("assets");
343
+ if (!assetsZip)
344
+ throw new Error("Failed to create assets folder in worker zip");
345
+ await addDirToZip(assetsZip, path.join(workersDir, assetsDir));
342
346
  }
343
347
  zip.file("wrangler.json", JSON.stringify(config, null, 2));
344
348
  return zip.generateAsync({
@@ -362,6 +366,12 @@ async function resolveBundleEntry(bundleDir, configuredMain) {
362
366
  return candidates[0];
363
367
  throw new Error("Could not determine the worker entry module. Check the .bundle output.");
364
368
  }
369
+ function isEnoent(error) {
370
+ return (typeof error === "object" &&
371
+ error !== null &&
372
+ "code" in error &&
373
+ error.code === "ENOENT");
374
+ }
365
375
  async function loadWranglerConfig(workersDir) {
366
376
  const parsers = {
367
377
  "wrangler.jsonc": stripJsonc,
@@ -374,7 +384,7 @@ async function loadWranglerConfig(workersDir) {
374
384
  return parse(await (0, promises_1.readFile)(p, "utf-8"));
375
385
  }
376
386
  catch (error) {
377
- if (error?.code !== "ENOENT")
387
+ if (!isEnoent(error))
378
388
  throw error;
379
389
  }
380
390
  }
@@ -385,7 +395,7 @@ function parseToml(text) {
385
395
  }
386
396
  function stripJsonc(text) {
387
397
  const noComments = text
388
- .replace(/\\"|"(?:\\"|[^"])*"|(\/\/[^\n\r]*|\/\*[\s\S]*?\*\/)/g, (m, comment) => comment ? "" : m)
398
+ .replace(/\\"|"(?:\\"|[^"])*"|(\/\/[^\n\r]*|\/\*[\s\S]*?\*\/)/g, (m, comment) => (comment ? "" : m))
389
399
  .replace(/,(\s*[}\]])/g, "$1");
390
400
  return JSON.parse(noComments);
391
401
  }
@@ -394,7 +404,11 @@ async function addDirToZip(folder, dir, skip) {
394
404
  for (const entry of entries) {
395
405
  const full = path.join(dir, entry.name);
396
406
  if (entry.isDirectory()) {
397
- await addDirToZip(folder.folder(entry.name), full, skip);
407
+ const child = folder.folder(entry.name);
408
+ if (!child) {
409
+ throw new Error(`Failed to create zip folder ${entry.name}`);
410
+ }
411
+ await addDirToZip(child, full, skip);
398
412
  }
399
413
  else if (entry.isFile()) {
400
414
  if (skip?.(entry.name))
@@ -403,7 +417,7 @@ async function addDirToZip(folder, dir, skip) {
403
417
  }
404
418
  }
405
419
  }
406
- async function uploadToManagedHosting(env, bundle, deploymentName = "default") {
420
+ async function uploadToManagedHosting(env, bundle, deploymentName) {
407
421
  const api = (0, api_client_1.createManagedHostingClient)(env);
408
422
  const form = new form_data_1.default();
409
423
  form.append("bundle", bundle, {
@@ -546,10 +560,10 @@ function buildBranchEnv(input) {
546
560
  if (!composedSlug) {
547
561
  throw new Error(`Could not derive a branch slug from ${input.apiUrl}`);
548
562
  }
549
- const workerDomain = (input.workerDomain ?? "workers.omnibase.tech").replace(/^\.+/, "");
563
+ const workerDomain = (input.workerDomain ?? "omnibase-workers.app").replace(/^\.+/, "");
550
564
  const cookieDomain = input.cookieDomain ?? `.${workerDomain}`;
551
565
  const dashboardUrl = (input.dashboardUrl ?? `https://${composedSlug}-dashboard.${workerDomain}`).replace(/\/+$/, "");
552
- const postgrestUrl = (input.postgrestUrl ?? `${apiUrl}/rest/v1`).replace(/\/+$/, "");
566
+ const postgrestUrl = (input.postgrestUrl ?? `${apiUrl}/api/v1/rest`).replace(/\/+$/, "");
553
567
  return {
554
568
  NEXT_PUBLIC_WEBSITE_URL: dashboardUrl,
555
569
  WEBSITE_URL: dashboardUrl,
@@ -569,7 +583,7 @@ function buildBranchEnv(input) {
569
583
  * matches by name, slug, or id; otherwise a single branch is auto-selected or
570
584
  * the user is prompted.
571
585
  */
572
- async function resolveBranch(managedHostingUrl, projectId, branchFlag) {
586
+ async function _resolveBranch(managedHostingUrl, projectId, branchFlag) {
573
587
  const api = (0, api_client_1.createManagedHostingClient)({
574
588
  name: branchFlag || "cloud",
575
589
  managedHostingApiUrl: managedHostingUrl,
@@ -597,7 +611,10 @@ async function resolveBranch(managedHostingUrl, projectId, branchFlag) {
597
611
  value: b.id,
598
612
  })),
599
613
  });
600
- return branches.find((b) => b.id === id);
614
+ const branch = branches.find((b) => b.id === id);
615
+ if (!branch)
616
+ throw new Error("Selected branch was not found");
617
+ return branch;
601
618
  }
602
619
  /**
603
620
  * Push config from omnibase.toml to managed hosting.
@@ -611,29 +628,36 @@ async function resolveBranch(managedHostingUrl, projectId, branchFlag) {
611
628
  */
612
629
  function stripUnresolvedOidcProviders(payload) {
613
630
  const auth = payload.auth;
614
- const providers = auth?.oidc;
615
- if (!Array.isArray(providers))
631
+ const selfservice = auth?.selfservice;
632
+ const methods = selfservice?.methods;
633
+ const oidc = methods?.oidc;
634
+ const config = oidc?.config;
635
+ const providers = config?.providers;
636
+ if (!config || !Array.isArray(providers))
616
637
  return [];
617
638
  const dropped = [];
618
- auth.oidc = providers.filter((provider) => {
639
+ const remaining = providers.filter((provider) => {
619
640
  const unresolved = ["client_id", "client_secret"].some((key) => {
620
641
  const value = provider[key];
621
- return typeof value === "string" && /\{[A-Za-z_][A-Za-z0-9_]*\}/.test(value);
642
+ return (typeof value === "string" && /\{[A-Za-z_][A-Za-z0-9_]*\}/.test(value));
622
643
  });
623
644
  if (unresolved) {
624
- dropped.push(String(provider.provider ?? "unknown"));
645
+ dropped.push(String(provider.provider ?? provider.id ?? "unknown"));
625
646
  return false;
626
647
  }
627
648
  return true;
628
649
  });
629
- if (auth.oidc.length === 0) {
630
- delete auth.oidc;
650
+ if (remaining.length === 0) {
651
+ delete config.providers;
652
+ }
653
+ else {
654
+ config.providers = remaining;
631
655
  }
632
656
  return dropped;
633
657
  }
634
658
  async function pushEnvConfig(envFlag) {
635
659
  const root = (0, environment_1.findOmnibaseRoot)();
636
- const env = await (0, environment_1.selectEnvironment)(envFlag);
660
+ const env = await (0, environment_1.resolveEnvironment)(envFlag);
637
661
  if (env.name === "local") {
638
662
  logger_1.logger.warn("Environment push is not available for the local environment.");
639
663
  logger_1.logger.log(" omnibase cloud env push --env <branch>");
@@ -661,6 +685,14 @@ async function pushEnvConfig(envFlag) {
661
685
  if (droppedOidc.length > 0) {
662
686
  logger_1.logger.warn(`Skipping OIDC provider(s) with unresolved credentials: ${droppedOidc.join(", ")}`);
663
687
  }
688
+ const auth = payload.auth;
689
+ delete payload.auth;
690
+ if (auth) {
691
+ payload.auth_env = (0, auth_env_1.authEnvFromConfig)(auth, {
692
+ projectRoot: root,
693
+ warn: (message) => logger_1.logger.warn(message),
694
+ });
695
+ }
664
696
  const sections = Object.keys(payload);
665
697
  if (sections.length === 0) {
666
698
  logger_1.logger.info("Nothing to push: omnibase.toml has no cloud config sections.");
@@ -692,50 +724,115 @@ async function pushEnvConfig(envFlag) {
692
724
  throw new Error((0, errors_1.formatHttpError)(error));
693
725
  }
694
726
  }
695
- /**
696
- * Create a new branch
697
- */
698
- async function branchNew(options) {
699
- const root = (0, environment_1.findOmnibaseRoot)();
700
- const config = (0, config_1.loadConfig)(root);
701
- const api = (0, api_client_1.createProfileClient)();
702
- const projectId = options.projectId ?? config.project_id ?? (await (0, prompts_1.input)({ message: "Project ID:" }));
703
- const branchName = options.name ?? (await (0, prompts_1.input)({ message: "Branch name:", default: "dev" }));
704
- const email = options.email ?? (await (0, prompts_1.input)({ message: "Billing email:" }));
705
- let region = options.region;
706
- let tier = options.tier;
707
- if (!region || !tier) {
727
+ function findPlanById(plans, planId) {
728
+ return plans.find((plan) => plan.id === planId);
729
+ }
730
+ function findPostgresById(plan, postgresId) {
731
+ return (plan.postgres ?? []).find((postgres) => postgres.id === postgresId);
732
+ }
733
+ async function fetchManagedPlans(api) {
734
+ const response = await api.get("/api/v1/projects/plans");
735
+ return response.data?.tiers ?? [];
736
+ }
737
+ async function resolveBranchTarget(api, options) {
738
+ const needsPlans = !options.plan || !options.postgres || !options.region;
739
+ let plans = [];
740
+ if (needsPlans) {
708
741
  try {
709
- const optsRes = await api.get("/api/v1/options");
710
- const opts = optsRes.data;
711
- if (!region && opts.regions?.length) {
712
- region = await (0, prompts_1.select)({
713
- message: "Region:",
714
- choices: opts.regions.map((r) => ({ name: `${r.name} (${r.id})`, value: r.id })),
715
- });
716
- }
717
- if (!tier && opts.tiers?.length) {
718
- tier = await (0, prompts_1.select)({
719
- message: "Deployment tier:",
720
- choices: opts.tiers.map((t) => ({ name: `${t.name}`, value: t.id })),
721
- });
722
- }
742
+ plans = await fetchManagedPlans(api);
723
743
  }
724
744
  catch {
725
- if (!region)
726
- region = await (0, prompts_1.input)({ message: "Region:", default: "syd" });
727
- if (!tier)
728
- tier = await (0, prompts_1.input)({ message: "Deployment tier:", default: "shared" });
745
+ plans = [];
729
746
  }
730
747
  }
748
+ let plan;
749
+ if (options.plan && plans.length > 0) {
750
+ plan = findPlanById(plans, options.plan);
751
+ if (!plan) {
752
+ throw new Error(`Unknown plan '${options.plan}'. Available plans: ${plans.map((p) => p.id).join(", ")}`);
753
+ }
754
+ }
755
+ else if (options.plan) {
756
+ plan = { id: options.plan };
757
+ }
758
+ else if (plans.length > 0) {
759
+ plan = await (0, prompts_1.select)({
760
+ message: "Plan:",
761
+ choices: plans.map((p) => ({
762
+ name: `${p.display_name ?? p.name ?? p.id} (${p.id})`,
763
+ value: p,
764
+ })),
765
+ });
766
+ }
767
+ else {
768
+ return {
769
+ planId: await (0, prompts_1.input)({ message: "Plan ID:", default: "shared_tier" }),
770
+ postgresId: options.postgres ??
771
+ (await (0, prompts_1.input)({ message: "Postgres ID:", default: "postgres_shared" })),
772
+ region: options.region ?? (await (0, prompts_1.input)({ message: "Region:", default: "eu" })),
773
+ };
774
+ }
775
+ let postgresId = options.postgres;
776
+ if (postgresId) {
777
+ if ((plan.postgres ?? []).length > 0 &&
778
+ !findPostgresById(plan, postgresId)) {
779
+ throw new Error(`Postgres '${postgresId}' is not available for plan '${plan.id}'. Available: ${(plan.postgres ?? []).map((p) => p.id).join(", ")}`);
780
+ }
781
+ }
782
+ else if ((plan.postgres ?? []).length > 0) {
783
+ const postgres = await (0, prompts_1.select)({
784
+ message: "Postgres:",
785
+ choices: (plan.postgres ?? []).map((p) => ({
786
+ name: `${p.name} (${p.id})`,
787
+ value: p.id,
788
+ })),
789
+ });
790
+ postgresId = postgres;
791
+ }
792
+ else {
793
+ postgresId = await (0, prompts_1.input)({
794
+ message: "Postgres ID:",
795
+ default: "postgres_shared",
796
+ });
797
+ }
798
+ let region = options.region;
799
+ if (region) {
800
+ if ((plan.regions ?? []).length > 0 &&
801
+ !plan.regions?.some((r) => r.id === region)) {
802
+ throw new Error(`Region '${region}' is not available for plan '${plan.id}'. Available: ${plan.regions?.map((r) => r.id).join(", ")}`);
803
+ }
804
+ }
805
+ else if ((plan.regions ?? []).length > 0) {
806
+ region = await (0, prompts_1.select)({
807
+ message: "Region:",
808
+ choices: (plan.regions ?? []).map((r) => ({
809
+ name: `${r.name} (${r.id})`,
810
+ value: r.id,
811
+ })),
812
+ });
813
+ }
814
+ else {
815
+ region = await (0, prompts_1.input)({ message: "Region:", default: "eu" });
816
+ }
817
+ return { planId: plan.id, postgresId, region };
818
+ }
819
+ async function branchNew(options) {
820
+ const root = (0, environment_1.findOmnibaseRoot)();
821
+ const config = (0, config_1.loadConfig)(root);
822
+ const api = (0, api_client_1.createProfileClient)();
823
+ const projectId = options.projectId ??
824
+ config.project_id ??
825
+ (await (0, prompts_1.input)({ message: "Project ID:" }));
826
+ const branchName = options.name ?? (await (0, prompts_1.input)({ message: "Branch name:", default: "dev" }));
827
+ const target = await resolveBranchTarget(api, options);
731
828
  logger_1.logger.start(`Creating branch '${branchName}'...`);
732
829
  try {
733
830
  const response = await api.post("/api/v1/project_branches", {
734
831
  project_id: projectId,
735
832
  branch_name: branchName,
736
- region,
737
- deployment_tier: tier,
738
- billing_email: email,
833
+ region: target.region,
834
+ plan_id: target.planId,
835
+ postgres_id: target.postgresId,
739
836
  });
740
837
  const data = response.data;
741
838
  logger_1.logger.succeed(`Branch '${branchName}' provisioning started`);
@@ -794,8 +891,8 @@ async function branchEnsure(branchName, options) {
794
891
  logger_1.logger.succeed(`Reusing branch '${branch.name}' (${branch.id})`);
795
892
  }
796
893
  else {
797
- if (!options.region || !options.tier || !options.email) {
798
- throw new Error("--region, --tier, and --email are required when creating a branch");
894
+ if (!options.region || !options.plan || !options.postgres) {
895
+ throw new Error("--region, --plan, and --postgres are required when creating a branch");
799
896
  }
800
897
  if (!quiet)
801
898
  logger_1.logger.start(`Creating branch '${branchName}'...`);
@@ -803,8 +900,8 @@ async function branchEnsure(branchName, options) {
803
900
  project_id: projectId,
804
901
  branch_name: branchName,
805
902
  region: options.region,
806
- deployment_tier: options.tier,
807
- billing_email: options.email,
903
+ plan_id: options.plan,
904
+ postgres_id: options.postgres,
808
905
  });
809
906
  branch = {
810
907
  id: response.data.branch_id,
@@ -879,9 +976,9 @@ async function branchEnv(branchRef, options) {
879
976
  cookieDomain: options.cookieDomain ?? process.env.OMNIBASE_COOKIE_DOMAIN,
880
977
  dashboardUrl: options.dashboardUrl,
881
978
  });
882
- const content = Object.entries(env)
979
+ const content = `${Object.entries(env)
883
980
  .map(([key, value]) => `${key}=${value}`)
884
- .join("\n") + "\n";
981
+ .join("\n")}\n`;
885
982
  if (options.output) {
886
983
  const target = path.resolve(options.output);
887
984
  fs.mkdirSync(path.dirname(target), { recursive: true });
@@ -932,7 +1029,7 @@ async function branchDelete(branchRef, projectIdFlag, options = {}) {
932
1029
  * List workers for a branch
933
1030
  */
934
1031
  async function listWorkers(envFlag) {
935
- const env = await (0, environment_1.selectEnvironment)(envFlag);
1032
+ const env = await (0, environment_1.resolveEnvironment)(envFlag);
936
1033
  const api = (0, api_client_1.createManagedHostingClient)(env);
937
1034
  const branchId = env.branchId;
938
1035
  if (!branchId) {
@@ -958,7 +1055,7 @@ async function listWorkers(envFlag) {
958
1055
  * Add an account-level custom domain (e.g. example.com or *.example.com)
959
1056
  */
960
1057
  async function domainAdd(envFlag, domain) {
961
- const env = await (0, environment_1.selectEnvironment)(envFlag);
1058
+ const env = await (0, environment_1.resolveEnvironment)(envFlag);
962
1059
  const api = (0, api_client_1.createManagedHostingClient)(env);
963
1060
  logger_1.logger.start(`Adding domain ${domain}...`);
964
1061
  try {
@@ -984,7 +1081,7 @@ async function domainAdd(envFlag, domain) {
984
1081
  * List account-level domains
985
1082
  */
986
1083
  async function domainList(envFlag) {
987
- const env = await (0, environment_1.selectEnvironment)(envFlag);
1084
+ const env = await (0, environment_1.resolveEnvironment)(envFlag);
988
1085
  const api = (0, api_client_1.createManagedHostingClient)(env);
989
1086
  logger_1.logger.start("Fetching domains...");
990
1087
  try {
@@ -1006,7 +1103,7 @@ async function domainList(envFlag) {
1006
1103
  * Remove an account-level domain
1007
1104
  */
1008
1105
  async function domainRemove(envFlag, domainId) {
1009
- const env = await (0, environment_1.selectEnvironment)(envFlag);
1106
+ const env = await (0, environment_1.resolveEnvironment)(envFlag);
1010
1107
  const api = (0, api_client_1.createManagedHostingClient)(env);
1011
1108
  logger_1.logger.start("Removing domain...");
1012
1109
  try {
@@ -1022,7 +1119,7 @@ async function domainRemove(envFlag, domainId) {
1022
1119
  * Poll the status of an account-level domain until it activates or times out
1023
1120
  */
1024
1121
  async function domainStatus(envFlag, domainId, pollSeconds) {
1025
- const env = await (0, environment_1.selectEnvironment)(envFlag);
1122
+ const env = await (0, environment_1.resolveEnvironment)(envFlag);
1026
1123
  const api = (0, api_client_1.createManagedHostingClient)(env);
1027
1124
  const deadline = Date.now() + pollSeconds * 1000;
1028
1125
  try {
@@ -1053,7 +1150,7 @@ async function domainStatus(envFlag, domainId, pollSeconds) {
1053
1150
  * Attach a validated account domain to a worker
1054
1151
  */
1055
1152
  async function domainAttach(envFlag, domainId, workerName, hostname) {
1056
- const env = await (0, environment_1.selectEnvironment)(envFlag);
1153
+ const env = await (0, environment_1.resolveEnvironment)(envFlag);
1057
1154
  const api = (0, api_client_1.createManagedHostingClient)(env);
1058
1155
  const branchId = env.branchId;
1059
1156
  if (!branchId) {
@@ -1077,7 +1174,7 @@ async function domainAttach(envFlag, domainId, workerName, hostname) {
1077
1174
  * Detach a domain from a worker
1078
1175
  */
1079
1176
  async function domainDetach(envFlag, domainId) {
1080
- const env = await (0, environment_1.selectEnvironment)(envFlag);
1177
+ const env = await (0, environment_1.resolveEnvironment)(envFlag);
1081
1178
  const api = (0, api_client_1.createManagedHostingClient)(env);
1082
1179
  const branchId = env.branchId;
1083
1180
  if (!branchId) {
@@ -1196,10 +1293,9 @@ function addCloudCommands(program) {
1196
1293
  const workers = cloud
1197
1294
  .command("workers")
1198
1295
  .summary("Manage Cloudflare Workers deployments")
1199
- .description("Deploy and inspect the Workers deployments defined in omnibase.toml " +
1200
- "or `omnibase/workers/`.\n\n" +
1201
- "Each deployment maps to a directory (default `omnibase/workers/`) " +
1202
- "containing a `wrangler.toml`, `wrangler.jsonc`, or `wrangler.json`. " +
1296
+ .description("Deploy and inspect the Workers deployments defined in omnibase.toml.\n\n" +
1297
+ "Each deployment maps to a directory containing a `wrangler.toml`, " +
1298
+ "`wrangler.jsonc`, or `wrangler.json`. " +
1203
1299
  "`deploy` ships a deployment to the managed hosting cloud; `list` shows " +
1204
1300
  "what is currently deployed for a branch.");
1205
1301
  workers
@@ -1219,16 +1315,16 @@ function addCloudCommands(program) {
1219
1315
  " package time.\n" +
1220
1316
  "5. Upload the bundle to managed hosting, which runs " +
1221
1317
  " `wrangler deploy --dispatch-namespace` and returns the live URL.\n\n" +
1222
- "By default a single-deployment project deploys it directly; with " +
1318
+ "When a project has a single deployment it deploys directly; with " +
1223
1319
  "multiple deployments you are prompted to select one. `--name` picks a " +
1224
1320
  "specific deployment by name and `--all` deploys every deployment.\n\n" +
1225
1321
  "Before: the branch must be provisioned (has a branch ID) and a profile " +
1226
1322
  "must be configured (`omnibase cloud login`). Deployments must exist in " +
1227
- "omnibase.toml or `omnibase/workers/`. Cloud environments are required — " +
1323
+ "omnibase.toml. Cloud environments are required — " +
1228
1324
  "deploying to `local` is not supported.\n\n" +
1229
1325
  "Environment variables: `{VAR}` references in the wrangler `[vars]` " +
1230
1326
  "resolve from the branch env file. See the env resolution model on the " +
1231
- "[`cloud env`](/reference/cli/cloud/env) page.\n\n" +
1327
+ "[`cloud env`](/cli/cloud/env) page.\n\n" +
1232
1328
  "Caveats: values in `[vars]` are visible in the deployed worker — put " +
1233
1329
  "secrets in `wrangler secret` or the managed-hosting secrets API, not in " +
1234
1330
  "`[vars]`. Unresolved `{VAR}` values are left literal and the CLI warns.\n\n" +
@@ -1287,7 +1383,7 @@ function addCloudCommands(program) {
1287
1383
  "omnibase cloud domains add example.com --env dev\n" +
1288
1384
  "omnibase cloud domains add '*.example.com' --env dev\n" +
1289
1385
  "```")
1290
- .action(async (domain, cmdOptions) => {
1386
+ .action(async (domain, _cmdOptions) => {
1291
1387
  try {
1292
1388
  const globalOptions = program.opts();
1293
1389
  await domainAdd(globalOptions.env, domain);
@@ -1321,7 +1417,7 @@ function addCloudCommands(program) {
1321
1417
  "omnibase cloud domains list --env dev\n" +
1322
1418
  "omnibase cloud domains rm dom_123 --env dev\n" +
1323
1419
  "```")
1324
- .action(async (domainId, cmdOptions) => {
1420
+ .action(async (domainId, _cmdOptions) => {
1325
1421
  try {
1326
1422
  const globalOptions = program.opts();
1327
1423
  await domainRemove(globalOptions.env, domainId);
@@ -1384,7 +1480,7 @@ function addCloudCommands(program) {
1384
1480
  "```bash\n" +
1385
1481
  "omnibase cloud domains detach dom_123 --env dev\n" +
1386
1482
  "```")
1387
- .action(async (domainId, cmdOptions) => {
1483
+ .action(async (domainId, _cmdOptions) => {
1388
1484
  try {
1389
1485
  const globalOptions = program.opts();
1390
1486
  await domainDetach(globalOptions.env, domainId);
@@ -1406,21 +1502,20 @@ function addCloudCommands(program) {
1406
1502
  .summary("Create a new project branch")
1407
1503
  .description("Provision a new branch (environment) for the project.\n\n" +
1408
1504
  "The project ID comes from `--project-id` or the `project_id` in " +
1409
- "omnibase.toml, and is prompted for if neither is set. Region and tier " +
1410
- "default to a picker fed by the managed hosting options endpoint " +
1411
- "(falling back to `syd` / `shared` prompts). A billing email is " +
1412
- "required.\n\n" +
1505
+ "omnibase.toml, and is prompted for if neither is set. Plan, Postgres, " +
1506
+ "and region default to pickers fed by the managed hosting plans " +
1507
+ "endpoint.\n\n" +
1413
1508
  "After: provisioning starts asynchronously. Once complete, use the " +
1414
1509
  "branch with `--env <branch>` on other commands.\n\n" +
1415
1510
  "```bash\n" +
1416
1511
  "omnibase cloud branch new --name staging\n" +
1417
- "omnibase cloud branch new --project-id proj_123 --name dev --region syd --tier shared\n" +
1512
+ "omnibase cloud branch new --project-id proj_123 --name dev --region eu --plan shared_tier --postgres postgres_shared\n" +
1418
1513
  "```")
1419
1514
  .option("--project-id <id>", "Project ID")
1420
1515
  .option("--name <name>", "Branch name")
1421
- .option("--region <region>", "Region (e.g. syd)")
1422
- .option("--tier <tier>", "Deployment tier (e.g. shared)")
1423
- .option("--email <email>", "Billing email")
1516
+ .option("--region <region>", "Region ID (e.g. eu, syd)")
1517
+ .option("--plan <id>", "Plan ID (e.g. shared_tier)")
1518
+ .option("--postgres <id>", "Postgres ID (e.g. postgres_shared)")
1424
1519
  .action(async (cmdOptions) => {
1425
1520
  try {
1426
1521
  await branchNew(cmdOptions);
@@ -1435,18 +1530,18 @@ function addCloudCommands(program) {
1435
1530
  .description("Idempotently provision a branch and wait until it is active and its " +
1436
1531
  "API reports ready.\n\n" +
1437
1532
  "An existing live branch with the same name is reused, so this is safe " +
1438
- "to run on every CI job. When no branch exists, `--region`, `--tier`, " +
1439
- "and `--email` are required.\n\n" +
1533
+ "to run on every CI job. When no branch exists, `--region`, `--plan`, " +
1534
+ "and `--postgres` are required.\n\n" +
1440
1535
  "With `--json`, prints a single JSON object instead of log output. Use " +
1441
1536
  "`--no-wait` to return as soon as provisioning starts.\n\n" +
1442
1537
  "```bash\n" +
1443
- "omnibase cloud branch ensure pr-123 --region syd --tier shared_starter --email ci@example.com\n" +
1444
- "omnibase cloud branch ensure pr-123 --region syd --tier shared_starter --email ci@example.com --json\n" +
1538
+ "omnibase cloud branch ensure pr-123 --region eu --plan shared_tier --postgres postgres_shared\n" +
1539
+ "omnibase cloud branch ensure pr-123 --region eu --plan shared_tier --postgres postgres_shared --json\n" +
1445
1540
  "```")
1446
1541
  .option("--project-id <id>", "Project ID")
1447
- .option("--region <region>", "Region (e.g. syd)")
1448
- .option("--tier <tier>", "Deployment tier (e.g. shared_starter)")
1449
- .option("--email <email>", "Billing email")
1542
+ .option("--region <region>", "Region ID (e.g. eu, syd)")
1543
+ .option("--plan <id>", "Plan ID (e.g. shared_tier)")
1544
+ .option("--postgres <id>", "Postgres ID (e.g. postgres_shared)")
1450
1545
  .option("--no-wait", "Return immediately after provisioning starts")
1451
1546
  .option("--timeout <seconds>", "Provisioning timeout in seconds", "1800")
1452
1547
  .option("--health-timeout <seconds>", "Health check timeout in seconds", "600")
@@ -1471,7 +1566,7 @@ function addCloudCommands(program) {
1471
1566
  "omnibase cloud branch env pr-123\n" +
1472
1567
  "```")
1473
1568
  .option("--project-id <id>", "Project ID")
1474
- .option("--worker-domain <domain>", "Workers domain", "workers.omnibase.tech")
1569
+ .option("--worker-domain <domain>", "Workers domain", "omnibase-workers.app")
1475
1570
  .option("--cookie-domain <domain>", "Cookie domain")
1476
1571
  .option("--dashboard-url <url>", "Override the dashboard URL")
1477
1572
  .option("--output <path>", "Write dotenv output to a file")
@@ -1535,7 +1630,7 @@ function addCloudCommands(program) {
1535
1630
  "variables.\n\n" +
1536
1631
  "**Environment variable injection**\n\n" +
1537
1632
  "Several commands resolve `{VAR}` references in your configuration " +
1538
- "(e.g. `website_url = \"{PUBLIC_WEBSITE_URL}\"`) from a two-layer " +
1633
+ '(e.g. `selfservice.default_browser_return_url = "{PUBLIC_WEBSITE_URL}"`) from a two-layer ' +
1539
1634
  "model:\n\n" +
1540
1635
  "- **omnibase/omnibase.toml** (committed) — the structure, with `{VAR}` " +
1541
1636
  "references for per-environment values.\n" +
@@ -1565,12 +1660,12 @@ function addCloudCommands(program) {
1565
1660
  "not supported.\n\n" +
1566
1661
  "After: the branch reports which sections were applied and which were " +
1567
1662
  "ignored. Unresolved `{VAR}` values are warned about and left literal.\n\n" +
1568
- "See the env resolution model on the [`cloud env`](/reference/cli/cloud/env) page.\n\n" +
1663
+ "See the env resolution model on the [`cloud env`](/cli/cloud/env) page.\n\n" +
1569
1664
  "```bash\n" +
1570
1665
  "omnibase cloud env push --env dev\n" +
1571
1666
  "omnibase cloud env push --env staging\n" +
1572
1667
  "```")
1573
- .action(async (cmdOptions) => {
1668
+ .action(async (_cmdOptions) => {
1574
1669
  try {
1575
1670
  const globalOptions = program.opts();
1576
1671
  await pushEnvConfig(globalOptions.env);