@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.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  runCli
4
- } from "./chunk-MWVKOIGR.js";
4
+ } from "./chunk-KUQCJ6KA.js";
5
5
 
6
6
  // src/bin.ts
7
7
  runCli().catch((err) => {
@@ -940,6 +940,28 @@ function looksSecret(value) {
940
940
  return redactSecrets(value) !== value || value.includes("-----BEGIN");
941
941
  }
942
942
 
943
+ // src/calendar-errors.ts
944
+ var PLATFORM_NOT_READY_CODES = /* @__PURE__ */ new Set([
945
+ "calendar_google_oauth_not_configured",
946
+ "calendar_token_vault_not_configured",
947
+ "calendar_db_ingress_not_configured"
948
+ ]);
949
+ var CalendarRequestError = class extends Error {
950
+ /** HTTP status returned by the registry. */
951
+ status;
952
+ /** Machine-readable `error.code` from the response body, when present. */
953
+ code;
954
+ constructor(message, status, code) {
955
+ super(message);
956
+ this.name = "CalendarRequestError";
957
+ this.status = status;
958
+ if (code !== void 0) this.code = code;
959
+ }
960
+ };
961
+ function isCalendarPlatformNotReady(error) {
962
+ return error instanceof CalendarRequestError && error.code !== void 0 && PLATFORM_NOT_READY_CODES.has(error.code);
963
+ }
964
+
943
965
  // src/calendar-http.ts
944
966
  var CALENDAR_STATES = [
945
967
  "not_connected",
@@ -1086,7 +1108,8 @@ async function calendarJson(ctx, suffix, init) {
1086
1108
  if (!response.ok) {
1087
1109
  const code = textField(body.error?.code, 128);
1088
1110
  const message = textField(body.error?.message, 500);
1089
- throw new Error(redactSecrets(`calendar request failed (${response.status})${code ? ` ${code}` : ""}${message ? `: ${message}` : ""}`));
1111
+ const detail = `${code ? ` ${code}` : ""}${message ? `: ${message}` : ""}`;
1112
+ throw new CalendarRequestError(redactSecrets(`calendar request failed (${response.status})${detail}`), response.status, code);
1090
1113
  }
1091
1114
  return body;
1092
1115
  }
@@ -2032,17 +2055,6 @@ async function provision(options) {
2032
2055
  if (cfg.services.includes("calendar")) {
2033
2056
  const calendarCtx = { platform: cfg.platformUrl, appId: cfg.app.id, env, token, fetch: doFetch };
2034
2057
  await applyCalendarBookingPage(calendarCtx, calendarBookingPageUrl(cfg, env), out);
2035
- await ensureCalendarConnected(
2036
- calendarCtx,
2037
- {
2038
- open: options.open,
2039
- interactive: options.interactive,
2040
- openConsentUrl: options.openApprovalUrl,
2041
- wait: options.calendarPollWait,
2042
- pollTimeoutMs: options.calendarPollTimeoutMs,
2043
- stdout: out
2044
- }
2045
- );
2046
2058
  }
2047
2059
  }
2048
2060
  for (const env of cfg.envs) {
@@ -2106,6 +2118,26 @@ ${env}: credentials are already saved; retry "odla-ai secrets push --env ${env}$
2106
2118
  writeDevVars(devVarsTarget, credentials, env, o11yDevVars(cfg));
2107
2119
  out.log(`dev vars: wrote ${displayPath(devVarsTarget, cfg.rootDir)} for ${env}`);
2108
2120
  }
2121
+ if (cfg.services.includes("calendar")) {
2122
+ for (const env of cfg.envs) {
2123
+ try {
2124
+ await ensureCalendarConnected(
2125
+ { platform: cfg.platformUrl, appId: cfg.app.id, env, token, fetch: doFetch },
2126
+ {
2127
+ open: options.open,
2128
+ interactive: options.interactive,
2129
+ openConsentUrl: options.openApprovalUrl,
2130
+ wait: options.calendarPollWait,
2131
+ pollTimeoutMs: options.calendarPollTimeoutMs,
2132
+ stdout: out
2133
+ }
2134
+ );
2135
+ } catch (error) {
2136
+ if (!isCalendarPlatformNotReady(error)) throw error;
2137
+ out.log(`${env}: calendar consent skipped (${error.code}); resume with "odla-ai calendar connect --env ${env}" once the platform is configured`);
2138
+ }
2139
+ }
2140
+ }
2109
2141
  }
2110
2142
  function serviceRank(service) {
2111
2143
  if (service === "db") return 0;
@@ -3982,4 +4014,4 @@ export {
3982
4014
  smoke,
3983
4015
  runCli
3984
4016
  };
3985
- //# sourceMappingURL=chunk-MWVKOIGR.js.map
4017
+ //# sourceMappingURL=chunk-KUQCJ6KA.js.map