@eide/foir-cli 0.35.0 → 0.37.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.
Files changed (2) hide show
  1. package/dist/cli.js +62 -28
  2. package/package.json +2 -2
package/dist/cli.js CHANGED
@@ -686,8 +686,16 @@ function createIdentityMethods(client) {
686
686
  },
687
687
  // ── Admin Users ───────────────────────────────────────
688
688
  async createAdminUser(params) {
689
+ const createData = { email: params.email };
690
+ if (params.firstName !== void 0) createData.firstName = params.firstName;
691
+ if (params.lastName !== void 0) createData.lastName = params.lastName;
689
692
  const resp = await client.createAdminUser(
690
- create(CreateAdminUserRequestSchema, params)
693
+ create(CreateAdminUserRequestSchema, {
694
+ create: createData,
695
+ tenantId: params.tenantId,
696
+ projectId: params.projectId,
697
+ role: params.role
698
+ })
691
699
  );
692
700
  return { user: resp.user ?? null };
693
701
  },
@@ -698,24 +706,28 @@ function createIdentityMethods(client) {
698
706
  return { user: resp.user ?? null };
699
707
  },
700
708
  async updateAdminUser(params) {
709
+ const update = {};
710
+ if (params.firstName !== void 0) update.firstName = { set: params.firstName };
711
+ if (params.lastName !== void 0) update.lastName = { set: params.lastName };
712
+ if (params.avatarUrl !== void 0) update.avatarUrl = { set: params.avatarUrl };
713
+ if (params.status !== void 0) update.status = { set: params.status };
701
714
  const resp = await client.updateAdminUser(
702
- create(UpdateAdminUserRequestSchema, params)
715
+ create(UpdateAdminUserRequestSchema, { id: params.id, update })
703
716
  );
704
717
  return { user: resp.user ?? null };
705
718
  },
706
719
  async listAdminUsers(params = {}) {
707
720
  const resp = await client.listAdminUsers(
708
721
  create(ListAdminUsersRequestSchema, {
709
- search: params.search,
710
- status: params.status,
711
- role: params.role,
722
+ where: params.where,
712
723
  first: params.first ?? DEFAULT_PAGE_SIZE,
713
724
  after: params?.after
714
725
  })
715
726
  );
716
727
  return {
717
728
  items: resp.items ?? [],
718
- total: Number(resp.total)
729
+ total: Number(resp.total),
730
+ cursors: resp.cursors ?? []
719
731
  };
720
732
  },
721
733
  async grantAccess(params) {
@@ -773,15 +785,15 @@ function createIdentityMethods(client) {
773
785
  async listCustomers(params = {}) {
774
786
  const resp = await client.listCustomers(
775
787
  create(ListCustomersRequestSchema, {
776
- search: params.search,
777
- status: params.status,
788
+ where: params.where,
778
789
  first: params.first ?? DEFAULT_PAGE_SIZE,
779
790
  after: params?.after
780
791
  })
781
792
  );
782
793
  return {
783
794
  items: resp.items ?? [],
784
- total: Number(resp.total)
795
+ total: Number(resp.total),
796
+ cursors: resp.cursors ?? []
785
797
  };
786
798
  },
787
799
  async suspendCustomer(id) {
@@ -2161,6 +2173,7 @@ function createSegmentsMethods(client) {
2161
2173
  }
2162
2174
 
2163
2175
  // src/lib/rpc/settings.ts
2176
+ import { ConnectError as ConnectError2, Code as Code2 } from "@connectrpc/connect";
2164
2177
  import { create as create7 } from "@bufbuild/protobuf";
2165
2178
  import {
2166
2179
  GetSettingsRequestSchema,
@@ -2173,7 +2186,8 @@ import {
2173
2186
  GetContextDimensionValuesRequestSchema,
2174
2187
  GetCustomerProfileSchemaRequestSchema,
2175
2188
  GetCustomerProfileRequestSchema,
2176
- SetCustomerProfileRequestSchema,
2189
+ CreateCustomerProfileRequestSchema,
2190
+ UpdateCustomerProfileRequestSchema,
2177
2191
  UpdateCustomerProfileSchemaRequestSchema,
2178
2192
  PublishProfileSchemaRequestSchema,
2179
2193
  GetCustomerResolutionAttributesRequestSchema,
@@ -2378,14 +2392,37 @@ function createSettingsMethods(client) {
2378
2392
  );
2379
2393
  return resp.data ?? null;
2380
2394
  },
2395
+ // setCustomerProfile writes a customer's profile data. It tries a
2396
+ // partial-patch update first (the common case) and falls back to a
2397
+ // create when no profile exists yet. The platform validates the data
2398
+ // against the published profile schema (required fields enforced on
2399
+ // create, partial-patch on update). Returns the resulting profile data.
2381
2400
  async setCustomerProfile(params) {
2382
- const resp = await client.setCustomerProfile(
2383
- create7(SetCustomerProfileRequestSchema, {
2384
- customerId: params.customerId,
2385
- data: params.data
2386
- })
2387
- );
2388
- return resp.success;
2401
+ const data = params.data ?? {};
2402
+ const update = {};
2403
+ for (const [key, value] of Object.entries(data)) {
2404
+ update[key] = { set: value };
2405
+ }
2406
+ try {
2407
+ const resp = await client.updateCustomerProfile(
2408
+ create7(UpdateCustomerProfileRequestSchema, {
2409
+ customerId: params.customerId,
2410
+ update
2411
+ })
2412
+ );
2413
+ return resp.data ?? {};
2414
+ } catch (err) {
2415
+ if (!(err instanceof ConnectError2) || err.code !== Code2.NotFound) {
2416
+ throw err;
2417
+ }
2418
+ const resp = await client.createCustomerProfile(
2419
+ create7(CreateCustomerProfileRequestSchema, {
2420
+ customerId: params.customerId,
2421
+ create: data
2422
+ })
2423
+ );
2424
+ return resp.data ?? {};
2425
+ }
2389
2426
  },
2390
2427
  async updateCustomerProfileSchema(params) {
2391
2428
  const resp = await client.updateCustomerProfileSchema(
@@ -3816,7 +3853,7 @@ function registerWhoamiCommand(program2, globalOpts) {
3816
3853
  import { promises as fs2 } from "fs";
3817
3854
  import { basename } from "path";
3818
3855
  import chalk3 from "chalk";
3819
- import { createClient } from "@connectrpc/connect";
3856
+ import { createClient as createClient2 } from "@connectrpc/connect";
3820
3857
  import { createConnectTransport as createConnectTransport2 } from "@connectrpc/connect-node";
3821
3858
  import {
3822
3859
  StorageService as StorageService3,
@@ -3970,7 +4007,7 @@ function createStorageRpcClient(getToken) {
3970
4007
  }
3971
4008
  ]
3972
4009
  });
3973
- return createStorageMethods(createClient(StorageService3, transport));
4010
+ return createStorageMethods(createClient2(StorageService3, transport));
3974
4011
  }
3975
4012
  function registerMediaCommands(program2, globalOpts) {
3976
4013
  const media = program2.command("media").description("Media file operations");
@@ -7022,11 +7059,6 @@ function registerRecordsCommands(program2, globalOpts) {
7022
7059
 
7023
7060
  // src/commands/customers.ts
7024
7061
  import { CustomerSchema } from "@eide/foir-proto-ts/identity/v1/identity_pb";
7025
- var statusMap = {
7026
- ACTIVE: CustomerStatus.ACTIVE,
7027
- PENDING: CustomerStatus.PENDING,
7028
- SUSPENDED: CustomerStatus.SUSPENDED
7029
- };
7030
7062
  function registerCustomersCommands(program2, globalOpts) {
7031
7063
  const customers = program2.command("customers").description("Manage customers");
7032
7064
  customers.command("list").description("List customers").option(
@@ -7036,9 +7068,11 @@ function registerCustomersCommands(program2, globalOpts) {
7036
7068
  withErrorHandler(globalOpts, async (cmdOpts) => {
7037
7069
  const opts = globalOpts();
7038
7070
  const client = await createPlatformClient(opts);
7071
+ const where = {};
7072
+ if (cmdOpts.search) where.email = { contains: cmdOpts.search };
7073
+ if (cmdOpts.status) where.status = { eq: cmdOpts.status.toUpperCase() };
7039
7074
  const result = await client.identity.listCustomers({
7040
- status: cmdOpts.status ? statusMap[cmdOpts.status.toUpperCase()] : void 0,
7041
- search: cmdOpts.search,
7075
+ where: Object.keys(where).length > 0 ? where : void 0,
7042
7076
  first: parseInt(cmdOpts.first ?? "20", 10),
7043
7077
  after: cmdOpts.after
7044
7078
  });
@@ -7071,7 +7105,7 @@ function registerCustomersCommands(program2, globalOpts) {
7071
7105
  let customer;
7072
7106
  if (idOrEmail.includes("@")) {
7073
7107
  const list = await client.identity.listCustomers({
7074
- search: idOrEmail,
7108
+ where: { email: { contains: idOrEmail } },
7075
7109
  first: 1
7076
7110
  });
7077
7111
  customer = list.items[0] ?? null;
@@ -7208,7 +7242,7 @@ function registerCustomerProfilesCommands(program2, globalOpts) {
7208
7242
  customerId,
7209
7243
  data: profileData
7210
7244
  });
7211
- formatOutput({ success: result }, opts);
7245
+ formatOutput(result, opts);
7212
7246
  if (!(opts.json || opts.jsonl || opts.quiet)) {
7213
7247
  success(`Set profile for customer ${customerId}`);
7214
7248
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eide/foir-cli",
3
- "version": "0.35.0",
3
+ "version": "0.37.0",
4
4
  "description": "Universal platform CLI for Foir platform",
5
5
  "type": "module",
6
6
  "publishConfig": {
@@ -50,7 +50,7 @@
50
50
  "@bufbuild/protovalidate": "^1.1.1",
51
51
  "@connectrpc/connect": "^2.0.0",
52
52
  "@connectrpc/connect-node": "^2.0.0",
53
- "@eide/foir-proto-ts": "^0.86.0",
53
+ "@eide/foir-proto-ts": "^0.88.0",
54
54
  "chalk": "^5.3.0",
55
55
  "commander": "^12.1.0",
56
56
  "dotenv": "^16.4.5",