@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/index.cjs CHANGED
@@ -1133,6 +1133,28 @@ function unique(values) {
1133
1133
  return [...new Set(values.filter(Boolean))];
1134
1134
  }
1135
1135
 
1136
+ // src/calendar-errors.ts
1137
+ var PLATFORM_NOT_READY_CODES = /* @__PURE__ */ new Set([
1138
+ "calendar_google_oauth_not_configured",
1139
+ "calendar_token_vault_not_configured",
1140
+ "calendar_db_ingress_not_configured"
1141
+ ]);
1142
+ var CalendarRequestError = class extends Error {
1143
+ /** HTTP status returned by the registry. */
1144
+ status;
1145
+ /** Machine-readable `error.code` from the response body, when present. */
1146
+ code;
1147
+ constructor(message, status, code) {
1148
+ super(message);
1149
+ this.name = "CalendarRequestError";
1150
+ this.status = status;
1151
+ if (code !== void 0) this.code = code;
1152
+ }
1153
+ };
1154
+ function isCalendarPlatformNotReady(error) {
1155
+ return error instanceof CalendarRequestError && error.code !== void 0 && PLATFORM_NOT_READY_CODES.has(error.code);
1156
+ }
1157
+
1136
1158
  // src/redact.ts
1137
1159
  var REPLACEMENTS = [
1138
1160
  [/odla_(sk|dev)_[A-Za-z0-9._-]+/g, "odla_$1_[redacted]"],
@@ -1298,7 +1320,8 @@ async function calendarJson(ctx, suffix, init) {
1298
1320
  if (!response.ok) {
1299
1321
  const code = textField(body.error?.code, 128);
1300
1322
  const message = textField(body.error?.message, 500);
1301
- throw new Error(redactSecrets(`calendar request failed (${response.status})${code ? ` ${code}` : ""}${message ? `: ${message}` : ""}`));
1323
+ const detail = `${code ? ` ${code}` : ""}${message ? `: ${message}` : ""}`;
1324
+ throw new CalendarRequestError(redactSecrets(`calendar request failed (${response.status})${detail}`), response.status, code);
1302
1325
  }
1303
1326
  return body;
1304
1327
  }
@@ -2349,17 +2372,6 @@ async function provision(options) {
2349
2372
  if (cfg.services.includes("calendar")) {
2350
2373
  const calendarCtx = { platform: cfg.platformUrl, appId: cfg.app.id, env, token, fetch: doFetch };
2351
2374
  await applyCalendarBookingPage(calendarCtx, calendarBookingPageUrl(cfg, env), out);
2352
- await ensureCalendarConnected(
2353
- calendarCtx,
2354
- {
2355
- open: options.open,
2356
- interactive: options.interactive,
2357
- openConsentUrl: options.openApprovalUrl,
2358
- wait: options.calendarPollWait,
2359
- pollTimeoutMs: options.calendarPollTimeoutMs,
2360
- stdout: out
2361
- }
2362
- );
2363
2375
  }
2364
2376
  }
2365
2377
  for (const env of cfg.envs) {
@@ -2423,6 +2435,26 @@ ${env}: credentials are already saved; retry "odla-ai secrets push --env ${env}$
2423
2435
  writeDevVars(devVarsTarget, credentials, env, o11yDevVars(cfg));
2424
2436
  out.log(`dev vars: wrote ${displayPath(devVarsTarget, cfg.rootDir)} for ${env}`);
2425
2437
  }
2438
+ if (cfg.services.includes("calendar")) {
2439
+ for (const env of cfg.envs) {
2440
+ try {
2441
+ await ensureCalendarConnected(
2442
+ { platform: cfg.platformUrl, appId: cfg.app.id, env, token, fetch: doFetch },
2443
+ {
2444
+ open: options.open,
2445
+ interactive: options.interactive,
2446
+ openConsentUrl: options.openApprovalUrl,
2447
+ wait: options.calendarPollWait,
2448
+ pollTimeoutMs: options.calendarPollTimeoutMs,
2449
+ stdout: out
2450
+ }
2451
+ );
2452
+ } catch (error) {
2453
+ if (!isCalendarPlatformNotReady(error)) throw error;
2454
+ out.log(`${env}: calendar consent skipped (${error.code}); resume with "odla-ai calendar connect --env ${env}" once the platform is configured`);
2455
+ }
2456
+ }
2457
+ }
2426
2458
  }
2427
2459
  function serviceRank(service) {
2428
2460
  if (service === "db") return 0;