@unisonlabs/sixminute-admin 0.1.1390-next → 0.1.1392-next
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/dist/sixminute-admin.mjs +34 -31
- package/package.json +1 -1
package/dist/sixminute-admin.mjs
CHANGED
|
@@ -20,7 +20,7 @@ import { homedir } from "node:os";
|
|
|
20
20
|
import { fileURLToPath } from "node:url";
|
|
21
21
|
|
|
22
22
|
// tools/admin/src/build-info.ts
|
|
23
|
-
var BUILT = { version: "0.1.
|
|
23
|
+
var BUILT = { version: "0.1.1392-next", commit: "52ec367697fe4cff6749f5809f0534e6ba9645e5", surface: "ac6c731b1016a56b" };
|
|
24
24
|
|
|
25
25
|
// tools/admin/src/run.ts
|
|
26
26
|
import { readFileSync as readFileSync4, writeFileSync as writeFileSync2 } from "node:fs";
|
|
@@ -6145,6 +6145,7 @@ var MeSchema = exports_external.object({
|
|
|
6145
6145
|
judgment_pipeline: JudgmentPipelineSchema.default("standard"),
|
|
6146
6146
|
legalsense_connector: exports_external.boolean().default(false),
|
|
6147
6147
|
timesheet_pet: exports_external.boolean().default(false),
|
|
6148
|
+
matter_codes: exports_external.boolean().default(false),
|
|
6148
6149
|
calendar_offered: exports_external.boolean().optional(),
|
|
6149
6150
|
swallow_short_pauses: exports_external.boolean().optional(),
|
|
6150
6151
|
pipeline_shadow: exports_external.boolean().optional(),
|
|
@@ -6825,6 +6826,7 @@ var AdminLearningReportSchema = exports_external.object({
|
|
|
6825
6826
|
});
|
|
6826
6827
|
// packages/contracts/src/admin-firm-acting.ts
|
|
6827
6828
|
var ACTING_AS_HEADER = "X-Six-Minute-Acting-As";
|
|
6829
|
+
var ACTING_FOR_HEADER = "X-Six-Minute-Acting-For";
|
|
6828
6830
|
var TeamApplyRequestSchema = exports_external.object({
|
|
6829
6831
|
bind: exports_external.array(exports_external.object({ external_ref: exports_external.string().min(1), member_id: MemberIdSchema })).default([]),
|
|
6830
6832
|
unbind: exports_external.array(exports_external.string().min(1)).default([]),
|
|
@@ -8777,11 +8779,12 @@ function outdatedMessage(environment) {
|
|
|
8777
8779
|
return `this sixminute-admin does not match the ${environment.name} API's operator routes. Update it:
|
|
8778
8780
|
` + ` ${installLineFor(environment.name, ADMIN_INSTALL_LINE)}`;
|
|
8779
8781
|
}
|
|
8780
|
-
async function send(ctx, token, method, path, body) {
|
|
8782
|
+
async function send(ctx, token, method, path, body, actingFor) {
|
|
8781
8783
|
const headers = {
|
|
8782
8784
|
Authorization: `Bearer ${token}`,
|
|
8783
8785
|
[ADMIN_SURFACE_HEADER]: ctx.surface,
|
|
8784
|
-
Accept: "application/json"
|
|
8786
|
+
Accept: "application/json",
|
|
8787
|
+
...actingFor === undefined ? {} : { [ACTING_FOR_HEADER]: actingFor }
|
|
8785
8788
|
};
|
|
8786
8789
|
if (body !== undefined)
|
|
8787
8790
|
headers["Content-Type"] = "application/json";
|
|
@@ -8801,12 +8804,12 @@ async function send(ctx, token, method, path, body) {
|
|
|
8801
8804
|
}
|
|
8802
8805
|
return { status: response.status, body: parsed, actingAs: response.headers.get(ACTING_AS_HEADER) };
|
|
8803
8806
|
}
|
|
8804
|
-
async function call(ctx, method, path, body) {
|
|
8807
|
+
async function call(ctx, method, path, body, actingFor) {
|
|
8805
8808
|
let session = await currentSession(ctx.io, ctx.environment);
|
|
8806
|
-
let answer = await send(ctx, session.access_token, method, path, body);
|
|
8809
|
+
let answer = await send(ctx, session.access_token, method, path, body, actingFor);
|
|
8807
8810
|
if (answer.status === 401) {
|
|
8808
8811
|
session = await refreshSession(ctx.io, ctx.environment, session);
|
|
8809
|
-
answer = await send(ctx, session.access_token, method, path, body);
|
|
8812
|
+
answer = await send(ctx, session.access_token, method, path, body, actingFor);
|
|
8810
8813
|
if (answer.status === 401) {
|
|
8811
8814
|
throw new AdminUsageError(`the ${ctx.environment.name} API refused the sign-in; ${signInAgain(ctx.environment.name)}`);
|
|
8812
8815
|
}
|
|
@@ -9170,7 +9173,7 @@ async function runMember(run2, subcommand) {
|
|
|
9170
9173
|
const { flags } = run2;
|
|
9171
9174
|
const tenant = required(flags, "tenant", "whose members");
|
|
9172
9175
|
if (subcommand === "list") {
|
|
9173
|
-
const answer = await
|
|
9176
|
+
const answer = await firmCall(run2, tenant, "GET", "/v1/members");
|
|
9174
9177
|
const { members, invitations } = MembersSchema.parse(expectOk(answer));
|
|
9175
9178
|
return render(run2, { members, invitations }, [
|
|
9176
9179
|
actingHead(tenant, answer),
|
|
@@ -9189,7 +9192,7 @@ async function runMember(run2, subcommand) {
|
|
|
9189
9192
|
if (role === undefined && active === undefined) {
|
|
9190
9193
|
throw new AdminUsageError("name what changes: --role admin|billing|timekeeper, --active true|false, or both");
|
|
9191
9194
|
}
|
|
9192
|
-
const answer = await
|
|
9195
|
+
const answer = await firmCall(run2, tenant, "PATCH", `/v1/members/${enc(member)}`, {
|
|
9193
9196
|
...role === undefined ? {} : { role },
|
|
9194
9197
|
...active === undefined ? {} : { active }
|
|
9195
9198
|
});
|
|
@@ -9201,14 +9204,14 @@ async function runMember(run2, subcommand) {
|
|
|
9201
9204
|
}
|
|
9202
9205
|
if (subcommand === "internal") {
|
|
9203
9206
|
const member = required(flags, "member", "whose own internal matters (member list prints the member_... ids)");
|
|
9204
|
-
const path =
|
|
9207
|
+
const path = `/v1/members/${enc(member)}/internal-matters`;
|
|
9205
9208
|
const matter = optional(flags, "matter");
|
|
9206
9209
|
const [on, off] = [switched(flags, "on"), switched(flags, "off")];
|
|
9207
9210
|
if (matter === undefined && (on || off))
|
|
9208
9211
|
throw new AdminUsageError("--on and --off need --matter: which matter_... to put on the list or take off");
|
|
9209
9212
|
if (matter !== undefined && on === off)
|
|
9210
9213
|
throw new AdminUsageError("say --on or --off: put the matter on the member's own internal matters, or take it off");
|
|
9211
|
-
const answer = matter === undefined ? await
|
|
9214
|
+
const answer = matter === undefined ? await firmCall(run2, tenant, "GET", path) : await firmCall(run2, tenant, "PUT", `${path}/${enc(matter)}`, { internal: on });
|
|
9212
9215
|
if (answer.status !== 200)
|
|
9213
9216
|
return refused(run2, answer, [actingHead(tenant, answer)]);
|
|
9214
9217
|
const { matter_ids } = PersonalInternalSchema.parse(answer.body);
|
|
@@ -10014,6 +10017,7 @@ async function runFirm(run2, group, subcommand) {
|
|
|
10014
10017
|
${ADMIN_USAGE}`);
|
|
10015
10018
|
}
|
|
10016
10019
|
var tenantPath = (tenant, rest = "") => `/v1/admin/tenants/${enc2(tenant)}${rest}`;
|
|
10020
|
+
var firmCall = (run2, tenant, method, path, body) => call(run2.api, method, path, body, tenant);
|
|
10017
10021
|
async function runTenantList(run2) {
|
|
10018
10022
|
const { tenants } = AdminTenantListSchema.parse(expectOk(await call(run2.api, "GET", "/v1/admin/tenants")));
|
|
10019
10023
|
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}`));
|
|
@@ -10232,12 +10236,11 @@ async function runAudit(run2) {
|
|
|
10232
10236
|
async function runVocabulary(run2, group, subcommand, action, positionals) {
|
|
10233
10237
|
const { flags } = run2;
|
|
10234
10238
|
const tenant = required(flags, "tenant", "the firm whose vocabulary this is");
|
|
10235
|
-
const base = tenantPath(tenant);
|
|
10236
10239
|
let head = null;
|
|
10237
10240
|
const firm2 = async (method, path, body) => {
|
|
10238
|
-
const answer = await
|
|
10241
|
+
const answer = await firmCall(run2, tenant, method, `/v1${path}`, body);
|
|
10239
10242
|
head ??= actingHead(tenant, answer);
|
|
10240
|
-
return expectOk(answer, `${method} ${
|
|
10243
|
+
return expectOk(answer, `${method} /v1${path}`);
|
|
10241
10244
|
};
|
|
10242
10245
|
const done = (payload, lines) => render(run2, payload, [...head === null ? [] : [head], ...lines]);
|
|
10243
10246
|
const attributes = async () => exports_external.array(AttributeSchema).parse(await firm2("GET", "/attributes"));
|
|
@@ -10359,7 +10362,7 @@ async function pullAll(run2, tenant, path, row) {
|
|
|
10359
10362
|
let head = null;
|
|
10360
10363
|
for (;; ) {
|
|
10361
10364
|
const query = since === null ? `?limit=${PULL_PAGE}` : `?limit=${PULL_PAGE}&since=${enc2(since)}`;
|
|
10362
|
-
const answer = await
|
|
10365
|
+
const answer = await firmCall(run2, tenant, "GET", `/v1${path}${query}`);
|
|
10363
10366
|
head ??= actingHead(tenant, answer);
|
|
10364
10367
|
const page = pullResultSchema(row).parse(expectOk(answer));
|
|
10365
10368
|
rows.push(...page.rows);
|
|
@@ -10390,7 +10393,7 @@ async function runClient(run2, subcommand) {
|
|
|
10390
10393
|
external_ref: optional(flags, "external-ref")
|
|
10391
10394
|
});
|
|
10392
10395
|
checkBody(ClientInputSchema, body);
|
|
10393
|
-
const answer = await
|
|
10396
|
+
const answer = await firmCall(run2, tenant, "POST", "/v1/clients", body);
|
|
10394
10397
|
if (answer.status !== 201)
|
|
10395
10398
|
return refused(run2, answer, [actingHead(tenant, answer)]);
|
|
10396
10399
|
const client2 = ClientSchema.parse(answer.body);
|
|
@@ -10420,7 +10423,7 @@ async function runClient(run2, subcommand) {
|
|
|
10420
10423
|
`));
|
|
10421
10424
|
}
|
|
10422
10425
|
}
|
|
10423
|
-
const answer = await
|
|
10426
|
+
const answer = await firmCall(run2, tenant, "PATCH", `/v1/clients/${enc2(id)}`, body);
|
|
10424
10427
|
if (answer.status !== 200)
|
|
10425
10428
|
return refused(run2, answer, [actingHead(tenant, answer)]);
|
|
10426
10429
|
const client2 = ClientSchema.parse(answer.body);
|
|
@@ -10447,7 +10450,7 @@ async function runMatter(run2, subcommand) {
|
|
|
10447
10450
|
temporary: booleanOf(flags, "temporary")
|
|
10448
10451
|
});
|
|
10449
10452
|
checkBody(MatterInputSchema, body);
|
|
10450
|
-
const answer = await
|
|
10453
|
+
const answer = await firmCall(run2, tenant, "POST", "/v1/matters", body);
|
|
10451
10454
|
if (answer.status !== 201)
|
|
10452
10455
|
return refused(run2, answer, [actingHead(tenant, answer)]);
|
|
10453
10456
|
const matter = MatterSchema.parse(answer.body);
|
|
@@ -10482,7 +10485,7 @@ async function runMatter(run2, subcommand) {
|
|
|
10482
10485
|
external_ref: optional(flags, "external-ref"),
|
|
10483
10486
|
active: booleanOf(flags, "active")
|
|
10484
10487
|
}, MatterPatchSchema, "--name, --number, --description, --external-ref, --active") : { active: subcommand === "unarchive" };
|
|
10485
|
-
const answer = await
|
|
10488
|
+
const answer = await firmCall(run2, tenant, "PATCH", `/v1/matters/${enc2(id)}`, body);
|
|
10486
10489
|
if (answer.status !== 200)
|
|
10487
10490
|
return refused(run2, answer, [actingHead(tenant, answer)]);
|
|
10488
10491
|
const matter = MatterSchema.parse(answer.body);
|
|
@@ -10493,7 +10496,7 @@ async function runMatter(run2, subcommand) {
|
|
|
10493
10496
|
const [on, off] = [switched(flags, "on"), switched(flags, "off")];
|
|
10494
10497
|
if (on === off)
|
|
10495
10498
|
throw new AdminUsageError("say --on or --off: mark the matter as the firm's own, or clear the mark");
|
|
10496
|
-
const answer = await
|
|
10499
|
+
const answer = await firmCall(run2, tenant, "PUT", `/v1/matters/${enc2(id)}/firm-internal`, { firm_internal: on });
|
|
10497
10500
|
if (answer.status !== 200)
|
|
10498
10501
|
return refused(run2, answer, [actingHead(tenant, answer)]);
|
|
10499
10502
|
const matter = MatterSchema.parse(answer.body);
|
|
@@ -10506,7 +10509,7 @@ async function runMattersImport(run2) {
|
|
|
10506
10509
|
const tenant = required(flags, "tenant", "the firm the clients and matters belong to");
|
|
10507
10510
|
const file = required(flags, "from-file", "the clients and their matters are a document: see tools/admin/examples/matters-import.json");
|
|
10508
10511
|
const { raw, parsed } = readDocument(file, MatterImportSchema, "a matters import (clients, each with its matters)");
|
|
10509
|
-
const answer = await
|
|
10512
|
+
const answer = await firmCall(run2, tenant, "POST", "/v1/matters/import", raw);
|
|
10510
10513
|
if (answer.status !== 200)
|
|
10511
10514
|
return refused(run2, answer, [actingHead(tenant, answer)]);
|
|
10512
10515
|
const report = ImportReportSchema.parse(answer.body);
|
|
@@ -10582,11 +10585,11 @@ function reviewerChoice(flags) {
|
|
|
10582
10585
|
async function runConnector(run2, subcommand) {
|
|
10583
10586
|
const { flags, environment } = run2;
|
|
10584
10587
|
const tenantId = required(flags, "firm", "every connector command names the firm it is for");
|
|
10585
|
-
const path = (rest) =>
|
|
10588
|
+
const path = (rest) => `/v1/connector${rest}`;
|
|
10586
10589
|
const head = (answer) => [actingHead(tenantId, answer)];
|
|
10587
10590
|
if (subcommand === "connect") {
|
|
10588
10591
|
const body = await connectBody(run2);
|
|
10589
|
-
const answer = await
|
|
10592
|
+
const answer = await firmCall(run2, tenantId, "PUT", path(""), body);
|
|
10590
10593
|
if (answer.status !== 200) {
|
|
10591
10594
|
const lead = answer.status === 409 && problemOf(answer).type !== "urn:six-minute:problem:no-acting-member" ? ["disconnect first: this firm is on another practice system, and there is one at a time."] : [];
|
|
10592
10595
|
return refused(run2, answer, [...head(answer), ...lead]);
|
|
@@ -10612,7 +10615,7 @@ async function runConnector(run2, subcommand) {
|
|
|
10612
10615
|
});
|
|
10613
10616
|
const unbind = flags.repeated.get("unbind") ?? [];
|
|
10614
10617
|
const confirm = switched(flags, "confirm");
|
|
10615
|
-
const answer = await
|
|
10618
|
+
const answer = await firmCall(run2, tenantId, "POST", path("/team/apply"), { bind, unbind, confirm });
|
|
10616
10619
|
if (answer.status !== 200)
|
|
10617
10620
|
return refused(run2, answer, head(answer));
|
|
10618
10621
|
const done = TeamApplyResultSchema.parse(answer.body);
|
|
@@ -10629,7 +10632,7 @@ async function runConnector(run2, subcommand) {
|
|
|
10629
10632
|
}
|
|
10630
10633
|
if (subcommand === "reviewer") {
|
|
10631
10634
|
const choice = reviewerChoice(flags);
|
|
10632
|
-
const connector2 = await
|
|
10635
|
+
const connector2 = await firmCall(run2, tenantId, "GET", path(""));
|
|
10633
10636
|
if (connector2.status !== 200)
|
|
10634
10637
|
return refused(run2, connector2, head(connector2));
|
|
10635
10638
|
const current = ConnectorSummarySchema.parse(connector2.body);
|
|
@@ -10641,7 +10644,7 @@ async function runConnector(run2, subcommand) {
|
|
|
10641
10644
|
}
|
|
10642
10645
|
let reviewer = { mode: "timekeeper" };
|
|
10643
10646
|
if (choice.mode === "person") {
|
|
10644
|
-
const team = await
|
|
10647
|
+
const team = await firmCall(run2, tenantId, "GET", path("/team"));
|
|
10645
10648
|
if (team.status !== 200)
|
|
10646
10649
|
return refused(run2, team, head(team));
|
|
10647
10650
|
const row = TeamProposalSchema.parse(team.body).rows.find((r) => r.external_ref === choice.external_ref);
|
|
@@ -10650,7 +10653,7 @@ async function runConnector(run2, subcommand) {
|
|
|
10650
10653
|
}
|
|
10651
10654
|
reviewer = { mode: "person", external_ref: row.external_ref, name: row.name };
|
|
10652
10655
|
}
|
|
10653
|
-
const answer = await
|
|
10656
|
+
const answer = await firmCall(run2, tenantId, "PUT", path("/settings"), { reviewer });
|
|
10654
10657
|
if (answer.status !== 200)
|
|
10655
10658
|
return refused(run2, answer, head(answer));
|
|
10656
10659
|
const summary = ConnectorSummarySchema.parse(answer.body);
|
|
@@ -10662,32 +10665,32 @@ async function runConnector(run2, subcommand) {
|
|
|
10662
10665
|
if (auto === switched(flags, "review")) {
|
|
10663
10666
|
throw new AdminUsageError("connector approval takes one of --review (the draft waits in the practice system until it is approved) " + "or --auto (it is written as approved time, with no draft)");
|
|
10664
10667
|
}
|
|
10665
|
-
const answer = await
|
|
10668
|
+
const answer = await firmCall(run2, tenantId, "PUT", path("/approval"), { member_id: member, mode: auto ? "auto" : "review" });
|
|
10666
10669
|
if (answer.status !== 200)
|
|
10667
10670
|
return refused(run2, answer, head(answer));
|
|
10668
10671
|
const summary = ConnectorSummarySchema.parse(answer.body);
|
|
10669
10672
|
return render(run2, { connector: summary }, [...head(answer), ...summaryLines(summary)]);
|
|
10670
10673
|
}
|
|
10671
10674
|
if (subcommand === "status") {
|
|
10672
|
-
const answer = await
|
|
10675
|
+
const answer = await firmCall(run2, tenantId, "GET", path(""));
|
|
10673
10676
|
if (answer.status !== 200)
|
|
10674
10677
|
return refused(run2, answer, head(answer));
|
|
10675
10678
|
const summary = ConnectorSummarySchema.parse(answer.body);
|
|
10676
|
-
const answered = await
|
|
10679
|
+
const answered = await firmCall(run2, tenantId, "GET", path("/team"));
|
|
10677
10680
|
if (answered.status !== 200 && answered.status !== 404)
|
|
10678
10681
|
return refused(run2, answered, head(answer));
|
|
10679
10682
|
const team = answered.status === 200 ? TeamProposalSchema.parse(answered.body) : null;
|
|
10680
10683
|
return render(run2, { connector: summary, team }, [...head(answer), ...connectorLines(summary, team, [])]);
|
|
10681
10684
|
}
|
|
10682
10685
|
if (subcommand === "sync") {
|
|
10683
|
-
const answer = await
|
|
10686
|
+
const answer = await firmCall(run2, tenantId, "POST", path("/sync"));
|
|
10684
10687
|
if (answer.status !== 200)
|
|
10685
10688
|
return refused(run2, answer, head(answer));
|
|
10686
10689
|
const report = SyncReportSchema.parse(answer.body);
|
|
10687
10690
|
return render(run2, { sync: report }, [...head(answer), ...syncLines(report)]);
|
|
10688
10691
|
}
|
|
10689
10692
|
if (subcommand === "disconnect") {
|
|
10690
|
-
const answer = await
|
|
10693
|
+
const answer = await firmCall(run2, tenantId, "DELETE", path(""));
|
|
10691
10694
|
if (answer.status !== 204)
|
|
10692
10695
|
return refused(run2, answer, head(answer));
|
|
10693
10696
|
return render(run2, { disconnected: tenantId }, [
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unisonlabs/sixminute-admin",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1392-next",
|
|
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": {
|