@eide/foir-cli 0.34.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 +68 -24
  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,
@@ -2316,14 +2318,36 @@ function createSettingsMethods(client) {
2316
2318
  return resp.dimension ?? null;
2317
2319
  },
2318
2320
  async createContextDimension(params) {
2321
+ const createInput = {
2322
+ key: params.key,
2323
+ name: params.name,
2324
+ sourceType: params.sourceType,
2325
+ sourceModelKey: params.sourceModelKey
2326
+ };
2327
+ if (params.description !== void 0)
2328
+ createInput.description = params.description;
2329
+ if (params.defaultRecordKey !== void 0)
2330
+ createInput.defaultRecordKey = params.defaultRecordKey;
2319
2331
  const resp = await client.createContextDimension(
2320
- create7(CreateContextDimensionRequestSchema, params)
2332
+ create7(CreateContextDimensionRequestSchema, { create: createInput })
2321
2333
  );
2322
2334
  return resp.dimension ?? null;
2323
2335
  },
2324
2336
  async updateContextDimension(params) {
2337
+ const update = {};
2338
+ if (params.name !== void 0) update.name = { set: params.name };
2339
+ if (params.description !== void 0)
2340
+ update.description = { set: params.description };
2341
+ if (params.sourceModelKey !== void 0)
2342
+ update.sourceModelKey = { set: params.sourceModelKey };
2343
+ if (params.defaultRecordKey !== void 0)
2344
+ update.defaultRecordKey = { set: params.defaultRecordKey };
2325
2345
  const resp = await client.updateContextDimension(
2326
- create7(UpdateContextDimensionRequestSchema, params)
2346
+ create7(UpdateContextDimensionRequestSchema, {
2347
+ id: params.id,
2348
+ update,
2349
+ publish: params.publish
2350
+ })
2327
2351
  );
2328
2352
  return resp.dimension ?? null;
2329
2353
  },
@@ -2356,14 +2380,37 @@ function createSettingsMethods(client) {
2356
2380
  );
2357
2381
  return resp.data ?? null;
2358
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.
2359
2388
  async setCustomerProfile(params) {
2360
- const resp = await client.setCustomerProfile(
2361
- create7(SetCustomerProfileRequestSchema, {
2362
- customerId: params.customerId,
2363
- data: params.data
2364
- })
2365
- );
2366
- 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
+ }
2367
2414
  },
2368
2415
  async updateCustomerProfileSchema(params) {
2369
2416
  const resp = await client.updateCustomerProfileSchema(
@@ -3794,7 +3841,7 @@ function registerWhoamiCommand(program2, globalOpts) {
3794
3841
  import { promises as fs2 } from "fs";
3795
3842
  import { basename } from "path";
3796
3843
  import chalk3 from "chalk";
3797
- import { createClient } from "@connectrpc/connect";
3844
+ import { createClient as createClient2 } from "@connectrpc/connect";
3798
3845
  import { createConnectTransport as createConnectTransport2 } from "@connectrpc/connect-node";
3799
3846
  import {
3800
3847
  StorageService as StorageService3,
@@ -3948,7 +3995,7 @@ function createStorageRpcClient(getToken) {
3948
3995
  }
3949
3996
  ]
3950
3997
  });
3951
- return createStorageMethods(createClient(StorageService3, transport));
3998
+ return createStorageMethods(createClient2(StorageService3, transport));
3952
3999
  }
3953
4000
  function registerMediaCommands(program2, globalOpts) {
3954
4001
  const media = program2.command("media").description("Media file operations");
@@ -7000,11 +7047,6 @@ function registerRecordsCommands(program2, globalOpts) {
7000
7047
 
7001
7048
  // src/commands/customers.ts
7002
7049
  import { CustomerSchema } from "@eide/foir-proto-ts/identity/v1/identity_pb";
7003
- var statusMap = {
7004
- ACTIVE: CustomerStatus.ACTIVE,
7005
- PENDING: CustomerStatus.PENDING,
7006
- SUSPENDED: CustomerStatus.SUSPENDED
7007
- };
7008
7050
  function registerCustomersCommands(program2, globalOpts) {
7009
7051
  const customers = program2.command("customers").description("Manage customers");
7010
7052
  customers.command("list").description("List customers").option(
@@ -7014,9 +7056,11 @@ function registerCustomersCommands(program2, globalOpts) {
7014
7056
  withErrorHandler(globalOpts, async (cmdOpts) => {
7015
7057
  const opts = globalOpts();
7016
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() };
7017
7062
  const result = await client.identity.listCustomers({
7018
- status: cmdOpts.status ? statusMap[cmdOpts.status.toUpperCase()] : void 0,
7019
- search: cmdOpts.search,
7063
+ where: Object.keys(where).length > 0 ? where : void 0,
7020
7064
  first: parseInt(cmdOpts.first ?? "20", 10),
7021
7065
  after: cmdOpts.after
7022
7066
  });
@@ -7049,7 +7093,7 @@ function registerCustomersCommands(program2, globalOpts) {
7049
7093
  let customer;
7050
7094
  if (idOrEmail.includes("@")) {
7051
7095
  const list = await client.identity.listCustomers({
7052
- search: idOrEmail,
7096
+ where: { email: { contains: idOrEmail } },
7053
7097
  first: 1
7054
7098
  });
7055
7099
  customer = list.items[0] ?? null;
@@ -7186,7 +7230,7 @@ function registerCustomerProfilesCommands(program2, globalOpts) {
7186
7230
  customerId,
7187
7231
  data: profileData
7188
7232
  });
7189
- formatOutput({ success: result }, opts);
7233
+ formatOutput(result, opts);
7190
7234
  if (!(opts.json || opts.jsonl || opts.quiet)) {
7191
7235
  success(`Set profile for customer ${customerId}`);
7192
7236
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eide/foir-cli",
3
- "version": "0.34.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.85.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",