@odla-ai/cli 0.10.2 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/bin.cjs CHANGED
@@ -1084,6 +1084,28 @@ function unique(values) {
1084
1084
  return [...new Set(values.filter(Boolean))];
1085
1085
  }
1086
1086
 
1087
+ // src/calendar-errors.ts
1088
+ var PLATFORM_NOT_READY_CODES = /* @__PURE__ */ new Set([
1089
+ "calendar_google_oauth_not_configured",
1090
+ "calendar_token_vault_not_configured",
1091
+ "calendar_db_ingress_not_configured"
1092
+ ]);
1093
+ var CalendarRequestError = class extends Error {
1094
+ /** HTTP status returned by the registry. */
1095
+ status;
1096
+ /** Machine-readable `error.code` from the response body, when present. */
1097
+ code;
1098
+ constructor(message, status, code) {
1099
+ super(message);
1100
+ this.name = "CalendarRequestError";
1101
+ this.status = status;
1102
+ if (code !== void 0) this.code = code;
1103
+ }
1104
+ };
1105
+ function isCalendarPlatformNotReady(error) {
1106
+ return error instanceof CalendarRequestError && error.code !== void 0 && PLATFORM_NOT_READY_CODES.has(error.code);
1107
+ }
1108
+
1087
1109
  // src/redact.ts
1088
1110
  var REPLACEMENTS = [
1089
1111
  [/odla_(sk|dev)_[A-Za-z0-9._-]+/g, "odla_$1_[redacted]"],
@@ -1249,7 +1271,8 @@ async function calendarJson(ctx, suffix, init) {
1249
1271
  if (!response.ok) {
1250
1272
  const code = textField(body.error?.code, 128);
1251
1273
  const message = textField(body.error?.message, 500);
1252
- throw new Error(redactSecrets(`calendar request failed (${response.status})${code ? ` ${code}` : ""}${message ? `: ${message}` : ""}`));
1274
+ const detail = `${code ? ` ${code}` : ""}${message ? `: ${message}` : ""}`;
1275
+ throw new CalendarRequestError(redactSecrets(`calendar request failed (${response.status})${detail}`), response.status, code);
1253
1276
  }
1254
1277
  return body;
1255
1278
  }
@@ -2300,17 +2323,6 @@ async function provision(options) {
2300
2323
  if (cfg.services.includes("calendar")) {
2301
2324
  const calendarCtx = { platform: cfg.platformUrl, appId: cfg.app.id, env, token, fetch: doFetch };
2302
2325
  await applyCalendarBookingPage(calendarCtx, calendarBookingPageUrl(cfg, env), out);
2303
- await ensureCalendarConnected(
2304
- calendarCtx,
2305
- {
2306
- open: options.open,
2307
- interactive: options.interactive,
2308
- openConsentUrl: options.openApprovalUrl,
2309
- wait: options.calendarPollWait,
2310
- pollTimeoutMs: options.calendarPollTimeoutMs,
2311
- stdout: out
2312
- }
2313
- );
2314
2326
  }
2315
2327
  }
2316
2328
  for (const env of cfg.envs) {
@@ -2374,6 +2386,26 @@ ${env}: credentials are already saved; retry "odla-ai secrets push --env ${env}$
2374
2386
  writeDevVars(devVarsTarget, credentials, env, o11yDevVars(cfg));
2375
2387
  out.log(`dev vars: wrote ${displayPath(devVarsTarget, cfg.rootDir)} for ${env}`);
2376
2388
  }
2389
+ if (cfg.services.includes("calendar")) {
2390
+ for (const env of cfg.envs) {
2391
+ try {
2392
+ await ensureCalendarConnected(
2393
+ { platform: cfg.platformUrl, appId: cfg.app.id, env, token, fetch: doFetch },
2394
+ {
2395
+ open: options.open,
2396
+ interactive: options.interactive,
2397
+ openConsentUrl: options.openApprovalUrl,
2398
+ wait: options.calendarPollWait,
2399
+ pollTimeoutMs: options.calendarPollTimeoutMs,
2400
+ stdout: out
2401
+ }
2402
+ );
2403
+ } catch (error) {
2404
+ if (!isCalendarPlatformNotReady(error)) throw error;
2405
+ out.log(`${env}: calendar consent skipped (${error.code}); resume with "odla-ai calendar connect --env ${env}" once the platform is configured`);
2406
+ }
2407
+ }
2408
+ }
2377
2409
  }
2378
2410
  function serviceRank(service) {
2379
2411
  if (service === "db") return 0;