@eide/foir-cli 0.35.0 → 0.36.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 +44 -22
  2. package/package.json +2 -2
package/dist/cli.js CHANGED
@@ -773,15 +773,15 @@ function createIdentityMethods(client) {
773
773
  async listCustomers(params = {}) {
774
774
  const resp = await client.listCustomers(
775
775
  create(ListCustomersRequestSchema, {
776
- search: params.search,
777
- status: params.status,
776
+ where: params.where,
778
777
  first: params.first ?? DEFAULT_PAGE_SIZE,
779
778
  after: params?.after
780
779
  })
781
780
  );
782
781
  return {
783
782
  items: resp.items ?? [],
784
- total: Number(resp.total)
783
+ total: Number(resp.total),
784
+ cursors: resp.cursors ?? []
785
785
  };
786
786
  },
787
787
  async suspendCustomer(id) {
@@ -2161,6 +2161,7 @@ function createSegmentsMethods(client) {
2161
2161
  }
2162
2162
 
2163
2163
  // src/lib/rpc/settings.ts
2164
+ import { ConnectError as ConnectError2, Code as Code2 } from "@connectrpc/connect";
2164
2165
  import { create as create7 } from "@bufbuild/protobuf";
2165
2166
  import {
2166
2167
  GetSettingsRequestSchema,
@@ -2173,7 +2174,8 @@ import {
2173
2174
  GetContextDimensionValuesRequestSchema,
2174
2175
  GetCustomerProfileSchemaRequestSchema,
2175
2176
  GetCustomerProfileRequestSchema,
2176
- SetCustomerProfileRequestSchema,
2177
+ CreateCustomerProfileRequestSchema,
2178
+ UpdateCustomerProfileRequestSchema,
2177
2179
  UpdateCustomerProfileSchemaRequestSchema,
2178
2180
  PublishProfileSchemaRequestSchema,
2179
2181
  GetCustomerResolutionAttributesRequestSchema,
@@ -2378,14 +2380,37 @@ function createSettingsMethods(client) {
2378
2380
  );
2379
2381
  return resp.data ?? null;
2380
2382
  },
2383
+ // setCustomerProfile writes a customer's profile data. It tries a
2384
+ // partial-patch update first (the common case) and falls back to a
2385
+ // create when no profile exists yet. The platform validates the data
2386
+ // against the published profile schema (required fields enforced on
2387
+ // create, partial-patch on update). Returns the resulting profile data.
2381
2388
  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;
2389
+ const data = params.data ?? {};
2390
+ const update = {};
2391
+ for (const [key, value] of Object.entries(data)) {
2392
+ update[key] = { set: value };
2393
+ }
2394
+ try {
2395
+ const resp = await client.updateCustomerProfile(
2396
+ create7(UpdateCustomerProfileRequestSchema, {
2397
+ customerId: params.customerId,
2398
+ update
2399
+ })
2400
+ );
2401
+ return resp.data ?? {};
2402
+ } catch (err) {
2403
+ if (!(err instanceof ConnectError2) || err.code !== Code2.NotFound) {
2404
+ throw err;
2405
+ }
2406
+ const resp = await client.createCustomerProfile(
2407
+ create7(CreateCustomerProfileRequestSchema, {
2408
+ customerId: params.customerId,
2409
+ create: data
2410
+ })
2411
+ );
2412
+ return resp.data ?? {};
2413
+ }
2389
2414
  },
2390
2415
  async updateCustomerProfileSchema(params) {
2391
2416
  const resp = await client.updateCustomerProfileSchema(
@@ -3816,7 +3841,7 @@ function registerWhoamiCommand(program2, globalOpts) {
3816
3841
  import { promises as fs2 } from "fs";
3817
3842
  import { basename } from "path";
3818
3843
  import chalk3 from "chalk";
3819
- import { createClient } from "@connectrpc/connect";
3844
+ import { createClient as createClient2 } from "@connectrpc/connect";
3820
3845
  import { createConnectTransport as createConnectTransport2 } from "@connectrpc/connect-node";
3821
3846
  import {
3822
3847
  StorageService as StorageService3,
@@ -3970,7 +3995,7 @@ function createStorageRpcClient(getToken) {
3970
3995
  }
3971
3996
  ]
3972
3997
  });
3973
- return createStorageMethods(createClient(StorageService3, transport));
3998
+ return createStorageMethods(createClient2(StorageService3, transport));
3974
3999
  }
3975
4000
  function registerMediaCommands(program2, globalOpts) {
3976
4001
  const media = program2.command("media").description("Media file operations");
@@ -7022,11 +7047,6 @@ function registerRecordsCommands(program2, globalOpts) {
7022
7047
 
7023
7048
  // src/commands/customers.ts
7024
7049
  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
7050
  function registerCustomersCommands(program2, globalOpts) {
7031
7051
  const customers = program2.command("customers").description("Manage customers");
7032
7052
  customers.command("list").description("List customers").option(
@@ -7036,9 +7056,11 @@ function registerCustomersCommands(program2, globalOpts) {
7036
7056
  withErrorHandler(globalOpts, async (cmdOpts) => {
7037
7057
  const opts = globalOpts();
7038
7058
  const client = await createPlatformClient(opts);
7059
+ const where = {};
7060
+ if (cmdOpts.search) where.email = { contains: cmdOpts.search };
7061
+ if (cmdOpts.status) where.status = { eq: cmdOpts.status.toUpperCase() };
7039
7062
  const result = await client.identity.listCustomers({
7040
- status: cmdOpts.status ? statusMap[cmdOpts.status.toUpperCase()] : void 0,
7041
- search: cmdOpts.search,
7063
+ where: Object.keys(where).length > 0 ? where : void 0,
7042
7064
  first: parseInt(cmdOpts.first ?? "20", 10),
7043
7065
  after: cmdOpts.after
7044
7066
  });
@@ -7071,7 +7093,7 @@ function registerCustomersCommands(program2, globalOpts) {
7071
7093
  let customer;
7072
7094
  if (idOrEmail.includes("@")) {
7073
7095
  const list = await client.identity.listCustomers({
7074
- search: idOrEmail,
7096
+ where: { email: { contains: idOrEmail } },
7075
7097
  first: 1
7076
7098
  });
7077
7099
  customer = list.items[0] ?? null;
@@ -7208,7 +7230,7 @@ function registerCustomerProfilesCommands(program2, globalOpts) {
7208
7230
  customerId,
7209
7231
  data: profileData
7210
7232
  });
7211
- formatOutput({ success: result }, opts);
7233
+ formatOutput(result, opts);
7212
7234
  if (!(opts.json || opts.jsonl || opts.quiet)) {
7213
7235
  success(`Set profile for customer ${customerId}`);
7214
7236
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eide/foir-cli",
3
- "version": "0.35.0",
3
+ "version": "0.36.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.87.0",
54
54
  "chalk": "^5.3.0",
55
55
  "commander": "^12.1.0",
56
56
  "dotenv": "^16.4.5",