apiblaze 0.21.34 → 0.21.35

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 (2) hide show
  1. package/dist/index.js +19 -7
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -34,7 +34,7 @@ var __toESM = (mod, isNodeMode, target2) => (target2 = mod != null ? __create(__
34
34
  var version;
35
35
  var init_package = __esm({
36
36
  "package.json"() {
37
- version = "0.21.34";
37
+ version = "0.21.35";
38
38
  }
39
39
  });
40
40
 
@@ -159,7 +159,8 @@ async function fetchPolicy() {
159
159
  try {
160
160
  const res = await fetch(`${DASHBOARD_BASE}/api/cli/policy`, { signal: AbortSignal.timeout(1500) });
161
161
  if (!res.ok) return null;
162
- return normalizePolicy(await res.json());
162
+ const raw = await res.json();
163
+ return { policy: normalizePolicy(raw), beta: raw?.beta === true };
163
164
  } catch {
164
165
  return null;
165
166
  }
@@ -168,18 +169,24 @@ function readCache() {
168
169
  try {
169
170
  const raw = JSON.parse(import_fs.default.readFileSync(cacheFile(), "utf8"));
170
171
  if (!raw || typeof raw !== "object" || typeof raw.at !== "number" || !Number.isFinite(raw.at)) return null;
171
- return { at: raw.at, policy: raw.policy === null ? null : normalizePolicy(raw.policy) };
172
+ return { at: raw.at, policy: raw.policy === null ? null : normalizePolicy(raw.policy), beta: raw.beta === true };
172
173
  } catch {
173
174
  return null;
174
175
  }
175
176
  }
176
- function writeCache(policy) {
177
+ function writeCache(policy, beta) {
177
178
  try {
178
179
  import_fs.default.mkdirSync(import_path.default.dirname(cacheFile()), { recursive: true });
179
- import_fs.default.writeFileSync(cacheFile(), JSON.stringify({ at: Date.now(), policy }));
180
+ import_fs.default.writeFileSync(cacheFile(), JSON.stringify({ at: Date.now(), policy, beta }));
180
181
  } catch {
181
182
  }
182
183
  }
184
+ function isBetaCached() {
185
+ return readCache()?.beta === true;
186
+ }
187
+ function betaNotice() {
188
+ return `${import_chalk.default.bgYellow.black.bold(" BETA ")} ${import_chalk.default.yellow("APIblaze is in beta: recharging credits is free, up to a capped balance. Questions? support@apiblaze.com")}`;
189
+ }
183
190
  async function checkCliPolicy(version2, opts = {}) {
184
191
  if (process.env.APIBLAZE_SKIP_VERSION_CHECK === "1") return;
185
192
  const cached = opts.fresh ? null : readCache();
@@ -187,8 +194,9 @@ async function checkCliPolicy(version2, opts = {}) {
187
194
  if (cached && Date.now() - cached.at >= 0 && Date.now() - cached.at < CACHE_MS) {
188
195
  policy = cached.policy;
189
196
  } else {
190
- policy = await fetchPolicy();
191
- writeCache(policy);
197
+ const fetched = await fetchPolicy();
198
+ policy = fetched?.policy ?? null;
199
+ writeCache(policy, fetched?.beta === true);
192
200
  }
193
201
  if (policy && cliRefusal(policy, version2)) throw new CliUpgradeRequired(version2, policy.min_version, policy.message);
194
202
  }
@@ -790,6 +798,7 @@ ${import_chalk4.default.cyan("\u2192")} Team: ${import_chalk4.default.bold(teamN
790
798
  teamName
791
799
  });
792
800
  console.log(import_chalk4.default.green("\n\u2714 Logged in successfully!"));
801
+ if (isBetaCached()) console.log(betaNotice());
793
802
  await offerClaimPendingAnon();
794
803
  }
795
804
  async function offerClaimPendingAnon() {
@@ -837,6 +846,7 @@ var init_login = __esm({
837
846
  init_auth();
838
847
  init_team();
839
848
  init_legal();
849
+ init_version_guard();
840
850
  DASHBOARD_BASE3 = process.env.APIBLAZE_DASHBOARD_BASE || "https://dashboard.apiblaze.com";
841
851
  }
842
852
  });
@@ -18566,6 +18576,8 @@ program.configureHelp({
18566
18576
  return cmd === program ? [] : all;
18567
18577
  }
18568
18578
  });
18579
+ program.addHelpText("before", () => isBetaCached() ? `${betaNotice()}
18580
+ ` : "");
18569
18581
  program.addHelpText("after", () => `
18570
18582
  ${import_chalk72.default.bold("Don't like reading docs?")} Run ${import_chalk72.default.bgCyan.black.bold(` npx ${B.cli} docs `)} ${import_chalk72.default.cyan(`\u2014 ask an AI chatbot about ${B.product}, and let it act on your account.`)}
18571
18583
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "apiblaze",
3
- "version": "0.21.34",
3
+ "version": "0.21.35",
4
4
  "description": "APIblaze CLI — Chat with your APIs, Manage your API keys, users and groups with the APIblaze serverless proxy",
5
5
  "keywords": [
6
6
  "apiblaze",