@unisonlabs/sixminute-admin 0.1.1305-next → 0.1.1306

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.
package/README.md CHANGED
@@ -55,6 +55,7 @@ sixminute-admin tier set --env production --tenant tenant_... --tier standard
55
55
  sixminute-admin versions --env production --tenant tenant_...
56
56
  sixminute-admin entries purge --env staging --tenant tenant_... --author member_... --demo --dry-run
57
57
  sixminute-admin member list --env production --tenant tenant_...
58
+ sixminute-admin member internal --env production --tenant tenant_... --member member_... --matter matter_... --on
58
59
  sixminute-admin matters import --env production --tenant tenant_... --from-file matters.json
59
60
  sixminute-admin matter list --env production --tenant tenant_... --all
60
61
  sixminute-admin matter edit --env production --tenant tenant_... --matter matter_... --name "Example Holding: lease review"
@@ -21,7 +21,7 @@ import { homedir } from "node:os";
21
21
  import { fileURLToPath } from "node:url";
22
22
 
23
23
  // tools/admin/src/build-info.ts
24
- var BUILT = { version: "0.1.1305-next", commit: "9c270c5e8d103bdad141e2d063af45667c7f9111", surface: "ff1e9e5f4891b2e4" };
24
+ var BUILT = { version: "0.1.1306", commit: "73042f5923e8702680a46a38bb95b42a3749ec1d", surface: "f49f14b46968a210" };
25
25
 
26
26
  // tools/admin/src/run.ts
27
27
  import { readFileSync as readFileSync4, writeFileSync as writeFileSync2 } from "node:fs";
@@ -4348,6 +4348,10 @@ var MatterSchema = exports_external.object({
4348
4348
  created_at: TimestampSchema,
4349
4349
  updated_at: TimestampSchema
4350
4350
  });
4351
+ var FirmInternalPutSchema = exports_external.object({ firm_internal: exports_external.boolean() });
4352
+ var INTERNAL_LIST_LIMIT = 10;
4353
+ var PersonalInternalSchema = exports_external.object({ matter_ids: exports_external.array(MatterIdSchema) });
4354
+ var PersonalInternalPutSchema = exports_external.object({ internal: exports_external.boolean() });
4351
4355
  var strings = (value) => Array.isArray(value) ? value.filter((v) => typeof v === "string") : [];
4352
4356
  var legacyRules = (raw) => {
4353
4357
  if (raw === null || typeof raw !== "object" || Array.isArray(raw))
@@ -5675,7 +5679,9 @@ var CATALOGUE = {
5675
5679
  "narratives",
5676
5680
  "practice-system",
5677
5681
  "matters",
5678
- "member"
5682
+ "member",
5683
+ "desktop",
5684
+ "entries"
5679
5685
  ]),
5680
5686
  from_screen: TelemetryScreenSchema,
5681
5687
  day_offset: dayOffset()
@@ -6076,7 +6082,8 @@ var MeSystemLinkSchema = exports_external.object({
6076
6082
  var MeSchema = exports_external.object({
6077
6083
  user: UserSchema,
6078
6084
  tenant: TenantSchema.extend({
6079
- connector: MeConnectorSchema.nullable()
6085
+ connector: MeConnectorSchema.nullable(),
6086
+ administrators: exports_external.array(exports_external.string()).default([])
6080
6087
  }),
6081
6088
  member: MemberSchema.extend({
6082
6089
  system_link: MeSystemLinkSchema.nullable().default(null),
@@ -6183,7 +6190,6 @@ var MatterPatchSchema = MatterSchema.omit({
6183
6190
  attribute_required: true,
6184
6191
  firm_internal: true
6185
6192
  }).extend({ narrative_language: NarrativeLanguageSchema.nullable() }).partial();
6186
- var FirmInternalPutSchema = exports_external.object({ firm_internal: exports_external.boolean() });
6187
6193
  var AttributeSetPutSchema = AttributeSetSchema.omit({ updated_at: true });
6188
6194
  var AttributeSetsQuerySchema = exports_external.object({ attribute: AttributeKeySchema.optional() });
6189
6195
  var MatterImportSchema = exports_external.object({
@@ -8454,6 +8460,64 @@ async function runDemo(run2, subcommand) {
8454
8460
  throw new AdminUsageError(`unknown command: demo ${subcommand ?? ""}`.trim());
8455
8461
  }
8456
8462
 
8463
+ // tools/admin/src/member.ts
8464
+ var enc = encodeURIComponent;
8465
+ async function runMember(run2, subcommand) {
8466
+ const { flags } = run2;
8467
+ const tenant = required(flags, "tenant", "whose members");
8468
+ if (subcommand === "list") {
8469
+ const answer = await call(run2.api, "GET", tenantPath(tenant, "/members"));
8470
+ const { members, invitations } = MembersSchema.parse(expectOk(answer));
8471
+ return render(run2, { members, invitations }, [
8472
+ actingHead(tenant, answer),
8473
+ `${members.length} member(s)`,
8474
+ ...members.map((m) => ` ${m.id} ${m.role.padEnd(10)} ${m.active ? "active " : "inactive"} ${m.email} ${m.name}`),
8475
+ ...invitations.length === 0 ? [] : ["", `${invitations.length} pending invitation(s)`, ...invitations.map((i) => ` ${i.id} ${i.email} ${i.role} expires ${i.expires_at}`)]
8476
+ ]);
8477
+ }
8478
+ if (subcommand === "set") {
8479
+ const member = required(flags, "member", "which membership to change");
8480
+ const role = optional(flags, "role");
8481
+ if (role !== undefined && !["admin", "billing", "timekeeper"].includes(role)) {
8482
+ throw new AdminUsageError(`--role is admin, billing or timekeeper, got ${JSON.stringify(role)}`);
8483
+ }
8484
+ const active = booleanOf(flags, "active");
8485
+ if (role === undefined && active === undefined) {
8486
+ throw new AdminUsageError("name what changes: --role admin|billing|timekeeper, --active true|false, or both");
8487
+ }
8488
+ const answer = await call(run2.api, "PATCH", tenantPath(tenant, `/members/${enc(member)}`), {
8489
+ ...role === undefined ? {} : { role },
8490
+ ...active === undefined ? {} : { active }
8491
+ });
8492
+ const written = MemberSchema.parse(expectOk(answer));
8493
+ return render(run2, { member: written }, [
8494
+ actingHead(tenant, answer),
8495
+ `member ${written.id} ${written.role} ${written.active ? "active" : "inactive"}`
8496
+ ]);
8497
+ }
8498
+ if (subcommand === "internal") {
8499
+ const member = required(flags, "member", "whose own internal matters (member list prints the member_... ids)");
8500
+ const path = tenantPath(tenant, `/members/${enc(member)}/internal-matters`);
8501
+ const matter = optional(flags, "matter");
8502
+ const [on, off] = [switched(flags, "on"), switched(flags, "off")];
8503
+ if (matter === undefined && (on || off))
8504
+ throw new AdminUsageError("--on and --off need --matter: which matter_... to put on the list or take off");
8505
+ if (matter !== undefined && on === off)
8506
+ throw new AdminUsageError("say --on or --off: put the matter on the member's own internal matters, or take it off");
8507
+ const answer = matter === undefined ? await call(run2.api, "GET", path) : await call(run2.api, "PUT", `${path}/${enc(matter)}`, { internal: on });
8508
+ if (answer.status !== 200)
8509
+ return refused(run2, answer, [actingHead(tenant, answer)]);
8510
+ const { matter_ids } = PersonalInternalSchema.parse(answer.body);
8511
+ return render(run2, { member, matter_ids }, [
8512
+ actingHead(tenant, answer),
8513
+ `member ${member}`,
8514
+ `${matter_ids.length} of ${INTERNAL_LIST_LIMIT} own internal matter(s)`,
8515
+ ...matter_ids.map((id) => ` ${id}`)
8516
+ ]);
8517
+ }
8518
+ throw new AdminUsageError(`unknown command: member ${subcommand ?? ""}`.trim());
8519
+ }
8520
+
8457
8521
  // tools/admin/src/telemetry.ts
8458
8522
  var POSTHOG_API = "https://eu.posthog.com";
8459
8523
  var ALERT_PREFIX = "sixminute alert:";
@@ -8840,6 +8904,12 @@ is required; without one every command answers 403.
8840
8904
  sixminute-admin member set --env <env> --tenant tenant_... --member member_... [--role admin|billing|timekeeper] [--active true|false] [--json]
8841
8905
  Changes one membership's role or switches it off, as the firm's own
8842
8906
  administrator would.
8907
+ sixminute-admin member internal --env <env> --tenant tenant_... --member member_... [--matter matter_... --on|--off] [--json]
8908
+ One member's own internal matters, which the matching lists for every
8909
+ interval of theirs beside the firm's. Without --matter it prints the
8910
+ list; with it, puts the matter on the list (--on) or takes it off
8911
+ (--off) and prints the list as it now stands. A list holds at most 10
8912
+ active matters: one more is refused, exit 2. Works on ANY firm.
8843
8913
 
8844
8914
  sixminute-admin audit --env <env> [--tenant tenant_...] [--since 2026-09-01T00:00:00Z] [--limit 100] [--json]
8845
8915
  The operator log, newest first: every operator write, who made it, and
@@ -9013,7 +9083,7 @@ function dayOf2(flags, name, why) {
9013
9083
  }
9014
9084
  return value;
9015
9085
  }
9016
- var enc = encodeURIComponent;
9086
+ var enc2 = encodeURIComponent;
9017
9087
  function render(run2, payload, lines, code = 0) {
9018
9088
  const { name, clientId } = run2.environment;
9019
9089
  if (run2.flags.json)
@@ -9207,7 +9277,7 @@ async function runFirm(run2, group, subcommand) {
9207
9277
  const organizationId = required(flags, "org", "an invitation names the firm it is to");
9208
9278
  const email = required(flags, "email", "an invitation names the address it goes to");
9209
9279
  const role = roleOf(flags, "member");
9210
- const done = FirmInviteResultSchema.parse(expectOk(await call(api2, "POST", `/v1/admin/firms/${enc(organizationId)}/invitations`, { email, role })));
9280
+ const done = FirmInviteResultSchema.parse(expectOk(await call(api2, "POST", `/v1/admin/firms/${enc2(organizationId)}/invitations`, { email, role })));
9211
9281
  const { invitation } = done;
9212
9282
  return render(run2, done, [
9213
9283
  `invitation ${invitation.id} ${invitation.email} ${invitation.role} expires ${invitation.expires_at}`,
@@ -9219,19 +9289,19 @@ async function runFirm(run2, group, subcommand) {
9219
9289
  }
9220
9290
  if (group === "firm" && subcommand === "invitations") {
9221
9291
  const organizationId = required(flags, "org", "the pending invitations of which firm");
9222
- const { invitations } = FirmInvitationsSchema.parse(expectOk(await call(api2, "GET", `/v1/admin/firms/${enc(organizationId)}/invitations`)));
9292
+ const { invitations } = FirmInvitationsSchema.parse(expectOk(await call(api2, "GET", `/v1/admin/firms/${enc2(organizationId)}/invitations`)));
9223
9293
  return render(run2, { invitations }, invitations.length === 0 ? ["no pending invitations"] : invitations.map((row) => `${row.id} ${row.email} ${row.role} expires ${row.expires_at}`));
9224
9294
  }
9225
9295
  if (group === "invite" && subcommand === "revoke") {
9226
9296
  const id = required(flags, "id", "which invitation to revoke");
9227
- const done = InvitationRevokedSchema.parse(expectOk(await call(api2, "DELETE", `/v1/admin/invitations/${enc(id)}`)));
9297
+ const done = InvitationRevokedSchema.parse(expectOk(await call(api2, "DELETE", `/v1/admin/invitations/${enc2(id)}`)));
9228
9298
  return render(run2, done, [`revoked ${done.invitation.id} ${done.invitation.email}`]);
9229
9299
  }
9230
9300
  throw new AdminUsageError(`unknown command ${JSON.stringify([group, subcommand].filter(Boolean).join(" "))}.
9231
9301
 
9232
9302
  ${ADMIN_USAGE}`);
9233
9303
  }
9234
- var tenantPath = (tenant, rest = "") => `/v1/admin/tenants/${enc(tenant)}${rest}`;
9304
+ var tenantPath = (tenant, rest = "") => `/v1/admin/tenants/${enc2(tenant)}${rest}`;
9235
9305
  async function runTenantList(run2) {
9236
9306
  const { tenants } = AdminTenantListSchema.parse(expectOk(await call(run2.api, "GET", "/v1/admin/tenants")));
9237
9307
  return render(run2, { tenants }, tenants.length === 0 ? ["no firms"] : tenants.map((t) => `${t.id} ${t.workos_org_id} ${t.security_tier.padEnd(12)} ${t.internal ? "internal " : " "}${t.name}`));
@@ -9498,14 +9568,14 @@ async function runVocabulary(run2, group, subcommand, action, positionals) {
9498
9568
  if (id !== undefined && id !== set.id)
9499
9569
  throw new AdminUsageError(`--id ${id} and ${file}'s own id ${set.id} disagree`);
9500
9570
  const written = { ...set, ...name === undefined ? {} : { name } };
9501
- await firm("PUT", `/attributes/${enc(written.attribute_key)}/sets/${enc(written.id)}`, written);
9571
+ await firm("PUT", `/attributes/${enc2(written.attribute_key)}/sets/${enc2(written.id)}`, written);
9502
9572
  return done({ attribute_set: written }, [
9503
9573
  `option set ${written.id} ${written.attribute_key} ${written.name} ${written.options.length} option(s)`
9504
9574
  ]);
9505
9575
  }
9506
9576
  if (action === "list") {
9507
9577
  const attribute = optional(flags, "attribute");
9508
- const rows = exports_external.array(AttributeSetSchema).parse(await firm("GET", `/attribute-sets${attribute === undefined ? "" : `?attribute=${enc(attribute)}`}`));
9578
+ const rows = exports_external.array(AttributeSetSchema).parse(await firm("GET", `/attribute-sets${attribute === undefined ? "" : `?attribute=${enc2(attribute)}`}`));
9509
9579
  return done({ attribute_sets: rows }, [
9510
9580
  `${rows.length} option set(s)`,
9511
9581
  ...rows.map((row) => ` ${row.id} ${row.attribute_key} ${row.name} ${row.options.length} option(s)`)
@@ -9514,7 +9584,7 @@ async function runVocabulary(run2, group, subcommand, action, positionals) {
9514
9584
  if (action === "delete") {
9515
9585
  const attribute = required(flags, "attribute", "a set belongs to one attribute");
9516
9586
  const id = required(flags, "id", "which set to delete");
9517
- await firm("DELETE", `/attributes/${enc(attribute)}/sets/${enc(id)}`);
9587
+ await firm("DELETE", `/attributes/${enc2(attribute)}/sets/${enc2(id)}`);
9518
9588
  return done({ deleted: { attribute, id } }, [
9519
9589
  `option set ${id} deleted. The API refuses this for a set any entry carries.`
9520
9590
  ]);
@@ -9534,7 +9604,7 @@ async function runVocabulary(run2, group, subcommand, action, positionals) {
9534
9604
  proposed: switched(flags, "proposed"),
9535
9605
  default_set_ids: defaults
9536
9606
  });
9537
- const written = AttributeSchema.parse(await firm("PUT", `/attributes/${enc(row.key)}`, row));
9607
+ const written = AttributeSchema.parse(await firm("PUT", `/attributes/${enc2(row.key)}`, row));
9538
9608
  return done({ attribute: written }, [
9539
9609
  `attribute ${written.key} ${written.label} ` + `${written.required ? "required" : "optional"} ${written.proposed ? "proposed" : "not proposed"} ` + `sets ${written.default_set_ids.join(", ") || "none"}`
9540
9610
  ]);
@@ -9553,7 +9623,7 @@ async function runVocabulary(run2, group, subcommand, action, positionals) {
9553
9623
  if (row === undefined) {
9554
9624
  throw new AdminUsageError(`this firm has no active attribute ${key}; it holds ${rows.map((one) => one.key).join(", ") || "none"}`);
9555
9625
  }
9556
- const written = AttributeSchema.parse(await firm("PUT", `/attributes/${enc(key)}`, { ...row, active: false }));
9626
+ const written = AttributeSchema.parse(await firm("PUT", `/attributes/${enc2(key)}`, { ...row, active: false }));
9557
9627
  return done({ attribute: written }, [`attribute ${written.key} retired (active false). Nothing was deleted.`]);
9558
9628
  }
9559
9629
  }
@@ -9564,7 +9634,7 @@ async function runVocabulary(run2, group, subcommand, action, positionals) {
9564
9634
  throw new AdminUsageError("--attribute is required: key=id,id, key=none or key=inherit");
9565
9635
  const wanted = parseMatterSets([pair]);
9566
9636
  const merged = { ...await readMatterSets(firm, matterId), ...wanted };
9567
- await firm("PATCH", `/matters/${enc(matterId)}`, { attribute_sets: merged });
9637
+ await firm("PATCH", `/matters/${enc2(matterId)}`, { attribute_sets: merged });
9568
9638
  return done({ matter: matterId, attribute_sets: merged }, [
9569
9639
  `matter ${matterId} ` + Object.entries(merged).map(([key, ids3]) => `${key}=${ids3 === null ? "inherit" : ids3.length === 0 ? "none" : ids3.join(",")}`).join(" ")
9570
9640
  ]);
@@ -9576,7 +9646,7 @@ var MATTER_PAGE = 2000;
9576
9646
  async function readMatterSets(firm, matterId) {
9577
9647
  let since = null;
9578
9648
  for (;; ) {
9579
- const query = since === null ? `?limit=${MATTER_PAGE}` : `?limit=${MATTER_PAGE}&since=${enc(since)}`;
9649
+ const query = since === null ? `?limit=${MATTER_PAGE}` : `?limit=${MATTER_PAGE}&since=${enc2(since)}`;
9580
9650
  const page = MatterSetsPageSchema.parse(await firm("GET", `/matters${query}`));
9581
9651
  const found = page.rows.find((row) => row.id === matterId);
9582
9652
  if (found !== undefined)
@@ -9593,7 +9663,7 @@ async function pullAll(run2, tenant, path, row) {
9593
9663
  let since = null;
9594
9664
  let head = null;
9595
9665
  for (;; ) {
9596
- const query = since === null ? `?limit=${PULL_PAGE}` : `?limit=${PULL_PAGE}&since=${enc(since)}`;
9666
+ const query = since === null ? `?limit=${PULL_PAGE}` : `?limit=${PULL_PAGE}&since=${enc2(since)}`;
9597
9667
  const answer = await call(run2.api, "GET", tenantPath(tenant, `${path}${query}`));
9598
9668
  head ??= actingHead(tenant, answer);
9599
9669
  const page = pullResultSchema(row).parse(expectOk(answer));
@@ -9655,7 +9725,7 @@ async function runClient(run2, subcommand) {
9655
9725
  `));
9656
9726
  }
9657
9727
  }
9658
- const answer = await call(run2.api, "PATCH", tenantPath(tenant, `/clients/${enc(id)}`), body);
9728
+ const answer = await call(run2.api, "PATCH", tenantPath(tenant, `/clients/${enc2(id)}`), body);
9659
9729
  if (answer.status !== 200)
9660
9730
  return refused(run2, answer, [actingHead(tenant, answer)]);
9661
9731
  const client2 = ClientSchema.parse(answer.body);
@@ -9717,7 +9787,7 @@ async function runMatter(run2, subcommand) {
9717
9787
  external_ref: optional(flags, "external-ref"),
9718
9788
  active: booleanOf(flags, "active")
9719
9789
  }, MatterPatchSchema, "--name, --number, --description, --external-ref, --active") : { active: subcommand === "unarchive" };
9720
- const answer = await call(run2.api, "PATCH", tenantPath(tenant, `/matters/${enc(id)}`), body);
9790
+ const answer = await call(run2.api, "PATCH", tenantPath(tenant, `/matters/${enc2(id)}`), body);
9721
9791
  if (answer.status !== 200)
9722
9792
  return refused(run2, answer, [actingHead(tenant, answer)]);
9723
9793
  const matter = MatterSchema.parse(answer.body);
@@ -9728,7 +9798,7 @@ async function runMatter(run2, subcommand) {
9728
9798
  const [on, off] = [switched(flags, "on"), switched(flags, "off")];
9729
9799
  if (on === off)
9730
9800
  throw new AdminUsageError("say --on or --off: mark the matter as the firm's own, or clear the mark");
9731
- const answer = await call(run2.api, "PUT", tenantPath(tenant, `/matters/${enc(id)}/firm-internal`), { firm_internal: on });
9801
+ const answer = await call(run2.api, "PUT", tenantPath(tenant, `/matters/${enc2(id)}/firm-internal`), { firm_internal: on });
9732
9802
  if (answer.status !== 200)
9733
9803
  return refused(run2, answer, [actingHead(tenant, answer)]);
9734
9804
  const matter = MatterSchema.parse(answer.body);
@@ -9767,41 +9837,6 @@ function checkBody(schema, body) {
9767
9837
  return `--${flagOf[field] ?? field} ${i.message}`;
9768
9838
  }).join("; "));
9769
9839
  }
9770
- async function runMember(run2, subcommand) {
9771
- const { flags } = run2;
9772
- const tenant = required(flags, "tenant", "whose members");
9773
- if (subcommand === "list") {
9774
- const answer = await call(run2.api, "GET", tenantPath(tenant, "/members"));
9775
- const { members, invitations } = MembersSchema.parse(expectOk(answer));
9776
- return render(run2, { members, invitations }, [
9777
- actingHead(tenant, answer),
9778
- `${members.length} member(s)`,
9779
- ...members.map((m) => ` ${m.id} ${m.role.padEnd(10)} ${m.active ? "active " : "inactive"} ${m.email} ${m.name}`),
9780
- ...invitations.length === 0 ? [] : ["", `${invitations.length} pending invitation(s)`, ...invitations.map((i) => ` ${i.id} ${i.email} ${i.role} expires ${i.expires_at}`)]
9781
- ]);
9782
- }
9783
- if (subcommand === "set") {
9784
- const member = required(flags, "member", "which membership to change");
9785
- const role = optional(flags, "role");
9786
- if (role !== undefined && !["admin", "billing", "timekeeper"].includes(role)) {
9787
- throw new AdminUsageError(`--role is admin, billing or timekeeper, got ${JSON.stringify(role)}`);
9788
- }
9789
- const active = booleanOf(flags, "active");
9790
- if (role === undefined && active === undefined) {
9791
- throw new AdminUsageError("name what changes: --role admin|billing|timekeeper, --active true|false, or both");
9792
- }
9793
- const answer = await call(run2.api, "PATCH", tenantPath(tenant, `/members/${enc(member)}`), {
9794
- ...role === undefined ? {} : { role },
9795
- ...active === undefined ? {} : { active }
9796
- });
9797
- const written = MemberSchema.parse(expectOk(answer));
9798
- return render(run2, { member: written }, [
9799
- actingHead(tenant, answer),
9800
- `member ${written.id} ${written.role} ${written.active ? "active" : "inactive"}`
9801
- ]);
9802
- }
9803
- throw new AdminUsageError(`unknown command: member ${subcommand ?? ""}`.trim());
9804
- }
9805
9840
  async function pipedPassword(run2) {
9806
9841
  const read = run2.deps.readStdin;
9807
9842
  if (read === undefined)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unisonlabs/sixminute-admin",
3
- "version": "0.1.1305-next",
3
+ "version": "0.1.1306",
4
4
  "description": "Sixminute operator tool: the admin commands of the Sixminute API, run with your own operator sign-in.",
5
5
  "license": "UNLICENSED",
6
6
  "repository": {