apiblaze 0.19.8 → 0.19.9

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 +14 -12
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -933,7 +933,7 @@ var import_commander = require("commander");
933
933
  var import_chalk44 = __toESM(require("chalk"));
934
934
 
935
935
  // package.json
936
- var version = "0.19.8";
936
+ var version = "0.19.9";
937
937
 
938
938
  // src/index.ts
939
939
  init_types();
@@ -5254,6 +5254,17 @@ async function userByRef(t, ref) {
5254
5254
  return u;
5255
5255
  }
5256
5256
  var label2 = (u) => u.display_name || u.email || u.abz_sub;
5257
+ async function userByRefOrCreate(t, ref) {
5258
+ try {
5259
+ return await userByRef(t, ref);
5260
+ } catch (e) {
5261
+ if (!ref.includes("@")) throw e;
5262
+ const created = await t.call("/v1/admin/users", "POST", { email: ref.trim().toLowerCase() });
5263
+ if (!created?.abz_sub) throw e;
5264
+ console.log(import_chalk34.default.dim(` ${ref} wasn't a user yet \u2014 created.`));
5265
+ return { abz_sub: created.abz_sub, email: created.email ?? ref, display_name: null };
5266
+ }
5267
+ }
5257
5268
  async function runGroupList(opts) {
5258
5269
  const t = await resolveTransport(opts);
5259
5270
  const groups = await listGroups(t);
@@ -5268,7 +5279,7 @@ async function runGroupList(opts) {
5268
5279
  async function runGroupCreate(name, opts) {
5269
5280
  const t = await resolveTransport(opts);
5270
5281
  let adminSub;
5271
- if (opts.admin) adminSub = (await userByRef(t, opts.admin)).abz_sub;
5282
+ if (opts.admin) adminSub = (await userByRefOrCreate(t, opts.admin)).abz_sub;
5272
5283
  else {
5273
5284
  const users = await listUsers(t);
5274
5285
  if (t.selfEmail) adminSub = users.find((u) => (u.email ?? "").toLowerCase() === t.selfEmail.toLowerCase())?.abz_sub;
@@ -5324,16 +5335,7 @@ async function runGroupMembers(name, opts) {
5324
5335
  async function runGroupAddUser(userRef, groupName, opts) {
5325
5336
  const t = await resolveTransport(opts);
5326
5337
  const g = await groupByName(t, groupName);
5327
- let u;
5328
- try {
5329
- u = await userByRef(t, userRef);
5330
- } catch (e) {
5331
- if (!userRef.includes("@")) throw e;
5332
- const created = await t.call("/v1/admin/users", "POST", { email: userRef.trim().toLowerCase() });
5333
- if (!created?.abz_sub) throw e;
5334
- console.log(import_chalk34.default.dim(` ${userRef} wasn't a user yet \u2014 created.`));
5335
- u = { abz_sub: created.abz_sub, email: created.email ?? userRef, display_name: null };
5336
- }
5338
+ const u = await userByRefOrCreate(t, userRef);
5337
5339
  const role = opts.role === "admin" ? "admin" : "member";
5338
5340
  const spinner = (0, import_ora17.default)(`Adding ${label2(u)} to ${g.name}...`).start();
5339
5341
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "apiblaze",
3
- "version": "0.19.8",
3
+ "version": "0.19.9",
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",