@smartkomm/plexus-cli 0.1.23 → 0.1.24
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/cli.mjs +3 -3
- package/dist/spec.snapshot.json +1 -1
- package/package.json +1 -1
package/dist/cli.mjs
CHANGED
|
@@ -10007,8 +10007,8 @@ At most PLEXUS_SEED_SLOTS (default 2) seeds run at once on this machine, across
|
|
|
10007
10007
|
`);if(r.blockers.length>0){i.write(`Refused \u2014 still referenced:
|
|
10008
10008
|
`);for(let a of r.blockers)i.write(` ${a}
|
|
10009
10009
|
`);return 1}return r.applied||i.write(`Dry run \u2014 re-run with --confirm to delete.
|
|
10010
|
-
`),0}},yM=[ES,TS];async function wM(e,t,n){if(n!==void 0){if(n!=="test"&&n!=="live")throw new Error(`--mode must be test or live, got "${n}".`);return n}let{modes:r}=await e.query(S.stripe.status,{client:t}),i=r.length===1?r[0]:void 0;if(i===void 0)throw new Error(`This deployment speaks ${r.length===0?"no Stripe mode":"test and live"} \u2014 name the account with --mode test|live.`);return i.mode}s(wM,"stripeMode");function bM(e){let t=e?.trim()??"";if(t==="")throw new Error("Name the Tr\xE4ger whose account this is: --traeger <key> (foundation.legalEntities[].key; `stripe status` lists them).");return t}s(bM,"requireTraeger");var kM="The Tr\xE4ger whose account (legal_entities.configKey, e.g. test_operator); `stripe status` lists them";function xm(e){return e==null||e===0?"":new Date(e).toISOString().replace("T"," ").replace(/\.\d+Z$/,"Z")}s(xm,"ts");function $S(e){return e.reasons.length===0?e.status:`${e.status}: ${e.reasons.join(", ")}`}s($S,"capability");var RS=class extends C{static{s(this,"StripeConnectionStatusCommand")}static paths=[["stripe","status"]];static usage=A.Usage({category:"Stripe",description:"What each Tr\xE4ger's Stripe connection can do \u2014 `status` is the one the staff page shows (needs_info, in_review, restricted, not_enabled, ready, \u2026): whose account its money goes to, whether the school consented, Stripe's capability verdicts (card, SEPA, payouts) and what Stripe still wants from it.",examples:[["Local demo tenant","$0 stripe status --env local --tenant test"]]});async execute(){let t=await this.caller(),n=this.requireTenant(t),r=await t.query(S.stripe.status,{client:n}),o=(await Promise.all(r.modes.map(async({mode:a})=>{let{traeger:l}=await t.query(S.stripeConnect.traegerConnections,{client:n,mode:a});return await Promise.all(l.map(({key:d})=>t.query(S.stripeConnect.connection,{client:n,mode:a,traeger:d})))}))).flat();return this.print(o,a=>a.map(l=>({traeger:l.traeger.key,mode:l.mode,status:l.status,state:l.state,account:l.accountId??"",deployment:l.platformMode??"unconfigured",consented:l.enabled?"yes":"no",connectedBy:l.connectedBy===null?"":l.connectedBy.kind==="platform"?`platform ${xm(l.connectedBy.at)}`:`${l.connectedBy.name??"(deleted user)"} ${xm(l.connectedBy.at)}`,card:l.view===null?"":$S(l.view.cardPayments),sepa:l.view===null?"":$S(l.view.sepaDebitPayments)+(l.sepaInactive?" (!)":""),payouts:l.view===null?"":$S(l.view.payouts),due:l.view?.requirementsDue.join(", ")??"",email:l.view?.contactEmail??"",asked:xm(l.view?.askedAt),error:l.refreshError===null?"":`${xm(l.refreshError.at)} ${l.refreshError.message}`}))),0}},IS=class extends C{static{s(this,"StripeRefreshCommand")}static paths=[["stripe","refresh"]];static usage=A.Usage({category:"Stripe",description:"Ask Stripe what one Tr\xE4ger's account may do, now. The mirror is normally refreshed by the v2.core.account* events; this is the way out of a stale NO, which is the expensive direction \u2014 the school cannot collect although it may. A failed read shows in `stripe status` (error).",examples:[["Demo tenant","$0 stripe refresh --env local --tenant test --traeger test_operator --mode test"]]});traeger=f.String("--traeger",{description:kM});mode=f.String("--mode",{description:"Which of the school's accounts: test (the sandbox) or live; optional where the deployment speaks one mode"});async execute(){let t=await this.caller(),n=this.requireTenant(t),r=bM(this.traeger),i=await wM(t,n,this.mode);return await t.mutation(S.stripeConnect.refreshNow,{client:n,mode:i,traeger:r}),this.print({ok:!0,traeger:r,mode:i,next:"stripe status in a moment"},o=>[{ok:o.ok?"yes":"no",traeger:o.traeger,mode:o.mode,next:o.next}]),0}},OS=class extends C{static{s(this,"StripeAllowCommand")}static paths=[["stripe","allow"]];static usage=A.Usage({category:"Stripe",description:"The school's own half of the decision: may Plexus collect in its name? Off until set, and never implied by Stripe having cleared the account.",examples:[["Allow","$0 stripe allow --env local --tenant test --traeger test_operator --mode test"],["Withdraw","$0 stripe allow --env local --tenant test --traeger test_operator --mode test --off"]]});traeger=f.String("--traeger",{description:kM});mode=f.String("--mode",{description:"Which of the school's accounts: test (the sandbox) or live; optional where the deployment speaks one mode"});off=f.Boolean("--off",!1,{description:"Withdraw the consent instead of giving it"});async execute(){let t=await this.caller(),n=this.requireTenant(t),r=bM(this.traeger),i=await wM(t,n,this.mode);return await t.mutation(S.stripeConnect.setEnabled,{client:n,mode:i,traeger:r,enabled:!this.off}),this.print({tenant:n,traeger:r,mode:i,enabled:!this.off},o=>[{tenant:o.tenant,traeger:o.traeger,mode:o.mode,consented:o.enabled?"yes":"no"}]),0}},vM=[RS,IS,OS];async function PS(e,t,n={}){return e.query(S.tenantUsers.list,{client:t,...n})}s(PS,"listRows");async function oi(e,t,n){let r=n.trim();if(!r.includes("@")){if(!/^[a-z0-9]+$/.test(r))throw new Error(`"${r}" is neither an address nor an account id \u2014 a person is never named by name.`);return r}let i=r.toLowerCase(),o=[...await PS(e,t,{search:r}),...await PS(e,t,{search:r,status:"archived"})],a=[...new Set(o.filter(c=>c.email.toLowerCase()===i).map(c=>c.userId))],[l,...d]=a;if(l===void 0)throw new Error(`No user with the address "${r}" in "${t}".`);if(d.length>0)throw new Error(`The address "${r}" names ${a.length} accounts in "${t}" \u2014 pass the account id (${a.join(", ")}).`);return l}s(oi,"resolveTenantUser");async function xM(e,t){return e.query(S.tenantUsers.groups,{client:t})}s(xM,"groupsOf");async function SM(e,t,n){let r=await xM(e,t),i=r.filter(d=>d.key===n||d.id===n||d.label===n),[o,...a]=i,l=r.map(d=>`${d.label} (${d.key})`).join(", ");if(o===void 0)throw new Error(`No staff group "${n}" in "${t}". Groups: ${l||"(none)"}.`);if(a.length>0)throw new Error(`"${n}" names ${i.length} groups \u2014 pass the group id. Groups: ${i.map(d=>`${d.label} (${d.key}, ${d.id})`).join(", ")}.`);return o}s(SM,"resolveGroup");async function AM(e,t){return e.query(S.tenantUsers.units,{client:t})}s(AM,"unitsOf");async function T4(e,t,n){return(await SM(e,t,n)).id}s(T4,"resolveGroupFilter");function $4(e){let t=/^([A-Za-z]+)=(on|off)$/.exec(e.trim()),n=t?.[1];if(t===null||n===void 0)throw new Error(`--set takes <category>=on|off \u2014 got "${e}".`);if(!of.includes(n))throw new Error(`Unknown mail category "${n}". Categories: ${of.join(", ")}.`);return{category:n,enabled:t[2]==="on"}}s($4,"parseMailSetting");function R4(e){let t=e.map($4),n=t.map(r=>r.category).filter((r,i,o)=>o.indexOf(r)!==i);if(n.length>0)throw new Error(`--set names ${n.join(", ")} more than once.`);return t}s(R4,"parseMailSettings");var I4=s(e=>e===null?"":new Date(e).toISOString().slice(0,10),"day");function O4(e){return e.status==="active"&&e.invited?"invited":e.status}s(O4,"shownStatus");function EM(e){return{email:e.email,name:e.name,status:O4(e),groups:e.groups.map(t=>t.label).join(", "),signature:e.hasSignature?"yes":"no",lastSignIn:I4(e.lastSignInAt),userId:e.userId}}s(EM,"rowCells");async function TM(e,t,n){return e.query(S.tenantUsers.preferencesOf,{client:t,userId:n})}s(TM,"settingsOf");var Sn=class extends C{static{s(this,"TenantUsersCommand")}report(t,n){this.json?this.print(t):this.context.stdout.write(`${n}
|
|
10011
|
-
`)}printSettings(t){this.print(t,n=>n.map(r=>({category:r.category,email:r.email?"on":"off",decision:r.decision})),["category","email","decision"])}},_S=class extends Sn{static{s(this,"TenantUsersListCommand")}static paths=[["tenant-users","list"]];static usage=A.Usage({category:"Tenant users",description:"List the school's users (Administration \u2192 Nutzer); archived ones only with --status archived.",examples:[["Who has not signed in yet","plexus-cli --tenant <slug> tenant-users list --status invited"]]});status=f.String("--status",{description:"active, deactivated, archived or invited (active, never signed in)."});group=f.String("--group",{description:"A staff group, by id or exact label (`tenant-users groups list`)."});search=f.String("--search",{description:"Part of a name or address."});async execute(){let t=await this.caller(),n=this.requireTenant(t),r=this.status,i=this.group!==void 0?await T4(t,n,this.group):void 0,o=await PS(t,n,{...this.search!==void 0?{search:this.search}:{},...r!==void 0?{status:r}:{},...i!==void 0?{groupId:i}:{}});return this.print(o,a=>a.map(EM),["email","name","status","groups","signature","lastSignIn","userId"]),0}},NS=class extends Sn{static{s(this,"TenantUsersGroupsCommand")}static paths=[["tenant-users","groups","list"]];static usage=A.Usage({category:"Tenant users",description:"List the school's staff groups \u2014 the options of `tenant-users list --group` and `tenant-users invite --group`."});async execute(){let t=await this.caller(),n=this.requireTenant(t),r=await xM(t,n);return this.print(r,i=>i.map(o=>({label:o.label,key:o.key,id:o.id})),["label","key","id"]),0}},CS=class extends Sn{static{s(this,"TenantUsersUnitsCommand")}static paths=[["tenant-users","units","list"]];static usage=A.Usage({category:"Tenant users",description:"List the school's units by key \u2014 the options of `tenant-users invite --unit`."});async execute(){let t=await this.caller(),n=this.requireTenant(t),r=await AM(t,n);return this.print(r,i=>i.map(o=>({label:o.label,key:o.key})),["label","key"]),0}},DS=class extends Sn{static{s(this,"TenantUsersShowCommand")}static paths=[["tenant-users","show"]];static usage=A.Usage({category:"Tenant users",description:"Show one user of the school: status, groups, last sign-in, whether a signature is stored."});user=f.String({required:!0,name:"email|userId"});async execute(){let t=await this.caller(),n=this.requireTenant(t),r=await oi(t,n,this.user),i=await t.query(S.tenantUsers.get,{client:n,userId:r});return this.print(i,o=>[EM(o)],["email","name","status","groups","signature","lastSignIn","userId"]),0}},FS=class extends Sn{static{s(this,"TenantUsersHistoryCommand")}static paths=[["tenant-users","history"]];static usage=A.Usage({category:"Tenant users",description:"The Verlauf of one user in the school: who changed what, newest first."});user=f.String({required:!0,name:"email|userId"});async execute(){let t=await this.caller(),n=this.requireTenant(t),r=await oi(t,n,this.user),i=await P4(t,n,r);return this.print(i,o=>o.map(a=>({at:new Date(a.at).toISOString(),by:a.actorName??a.actorUserId,what:_4(a.detail)})),["at","by","what"]),0}};async function P4(e,t,n){return e.query(S.tenantUsers.events,{client:t,userId:n})}s(P4,"eventsOf");function _4(e){switch(e.kind){case"statusChanged":return`${e.from} \u2192 ${e.to}`+(e.groupsRemoved>0?`, ${e.groupsRemoved} group(s) removed`:"")+(e.successorUserId!==void 0?`, work handed to ${e.successorUserId}`:"");case"mailPreferenceChanged":return`mail ${e.category} ${e.email?"on":"off"}`;case"signatureRequested":return"signature requested";case"invited":return"invited"+(e.groupId!==void 0?` (group ${e.groupId})`:"");case"loginLinkSent":return"sign-in link sent";case"passwordResetSent":return"password-reset link sent"}}s(_4,"eventText");async function N4(e,t,n){return e.query(S.tenantUsers.handoverPreview,{client:t,userId:n})}s(N4,"previewOf");function C4(e,t,n){let r=[`DRY RUN \u2014 would ${e} ${t.person.name}.`];if(t.ruleRefusal!==null&&r.push(` refused: ${t.ruleRefusal}`),!t.endsStaff)r.push(" nothing to hand over (stays staff through another group).");else if(r.push(` to the successor: ${t.applicationCount} application(s), ${t.tasksToSuccessor} task(s)`,` back to the queue: ${t.tasksToQueue} team task(s), ${t.teamOwners} team owner role(s)`,` ended: ${t.teamMemberships} team membership(s); taken off ${t.tasksShared} shared task(s)`),t.successorRefusal!==null&&n!==void 0)r.push(` successor: ${n}`);else if(t.successorRefusal!==null){r.push(` needs --successor: ${t.successorRefusal}`),r.push(" candidates:");for(let i of t.candidates)r.push(` ${i.email} ${i.name} ${i.userId}`);t.candidates.length===0&&r.push(" (none)")}return n!==void 0&&t.successorRefusal===null&&r.push(" --successor: nothing needs one; it is passed on as given."),r.push(t.ruleRefusal!==null?"Replace them in the rule first, then re-run with --confirm.":"Re-run with --confirm."),r.join(`
|
|
10010
|
+
`),0}},yM=[ES,TS];async function wM(e,t,n){if(n!==void 0){if(n!=="test"&&n!=="live")throw new Error(`--mode must be test or live, got "${n}".`);return n}let{modes:r}=await e.query(S.stripe.status,{client:t}),i=r.length===1?r[0]:void 0;if(i===void 0)throw new Error(`This deployment speaks ${r.length===0?"no Stripe mode":"test and live"} \u2014 name the account with --mode test|live.`);return i.mode}s(wM,"stripeMode");function bM(e){let t=e?.trim()??"";if(t==="")throw new Error("Name the Tr\xE4ger whose account this is: --traeger <key> (foundation.legalEntities[].key; `stripe status` lists them).");return t}s(bM,"requireTraeger");var kM="The Tr\xE4ger whose account (legal_entities.configKey, e.g. test_operator); `stripe status` lists them";function xm(e){return e==null||e===0?"":new Date(e).toISOString().replace("T"," ").replace(/\.\d+Z$/,"Z")}s(xm,"ts");function $S(e){return e.reasons.length===0?e.status:`${e.status}: ${e.reasons.join(", ")}`}s($S,"capability");var RS=class extends C{static{s(this,"StripeConnectionStatusCommand")}static paths=[["stripe","status"]];static usage=A.Usage({category:"Stripe",description:"What each Tr\xE4ger's Stripe connection can do \u2014 `status` is the one the staff page shows (needs_info, in_review, restricted, not_enabled, ready, \u2026): whose account its money goes to, whether the school consented, Stripe's capability verdicts (card, SEPA, payouts) and what Stripe still wants from it.",examples:[["Local demo tenant","$0 stripe status --env local --tenant test"]]});async execute(){let t=await this.caller(),n=this.requireTenant(t),r=await t.query(S.stripe.status,{client:n}),o=(await Promise.all(r.modes.map(async({mode:a})=>{let{traeger:l}=await t.query(S.stripeConnect.traegerConnections,{client:n,mode:a});return await Promise.all(l.map(({key:d})=>t.query(S.stripeConnect.connection,{client:n,mode:a,traeger:d})))}))).flat();return this.print(o,a=>a.map(l=>({traeger:l.traeger.key,mode:l.mode,status:l.status,state:l.state,account:l.accountId??"",deployment:l.platformMode??"unconfigured",consented:l.enabled?"yes":"no",connectedBy:l.connectedBy===null?"":l.connectedBy.kind==="platform"?`platform ${xm(l.connectedBy.at)}`:`${l.connectedBy.name??"(deleted user)"} ${xm(l.connectedBy.at)}`,card:l.view===null?"":$S(l.view.cardPayments),sepa:l.view===null?"":$S(l.view.sepaDebitPayments)+(l.sepaInactive?" (!)":""),payouts:l.view===null?"":$S(l.view.payouts),due:l.view?.requirementsDue.join(", ")??"",email:l.view?.contactEmail??"",asked:xm(l.view?.askedAt),error:l.refreshError===null?"":`${xm(l.refreshError.at)} ${l.refreshError.message}`}))),0}},IS=class extends C{static{s(this,"StripeRefreshCommand")}static paths=[["stripe","refresh"]];static usage=A.Usage({category:"Stripe",description:"Ask Stripe what one Tr\xE4ger's account may do, now. The mirror is normally refreshed by the v2.core.account* events; this is the way out of a stale NO, which is the expensive direction \u2014 the school cannot collect although it may. A failed read shows in `stripe status` (error).",examples:[["Demo tenant","$0 stripe refresh --env local --tenant test --traeger test_operator --mode test"]]});traeger=f.String("--traeger",{description:kM});mode=f.String("--mode",{description:"Which of the school's accounts: test (the sandbox) or live; optional where the deployment speaks one mode"});async execute(){let t=await this.caller(),n=this.requireTenant(t),r=bM(this.traeger),i=await wM(t,n,this.mode);return await t.mutation(S.stripeConnect.refreshNow,{client:n,mode:i,traeger:r}),this.print({ok:!0,traeger:r,mode:i,next:"stripe status in a moment"},o=>[{ok:o.ok?"yes":"no",traeger:o.traeger,mode:o.mode,next:o.next}]),0}},OS=class extends C{static{s(this,"StripeAllowCommand")}static paths=[["stripe","allow"]];static usage=A.Usage({category:"Stripe",description:"The school's own half of the decision: may Plexus collect in its name? Off until set, and never implied by Stripe having cleared the account.",examples:[["Allow","$0 stripe allow --env local --tenant test --traeger test_operator --mode test"],["Withdraw","$0 stripe allow --env local --tenant test --traeger test_operator --mode test --off"]]});traeger=f.String("--traeger",{description:kM});mode=f.String("--mode",{description:"Which of the school's accounts: test (the sandbox) or live; optional where the deployment speaks one mode"});off=f.Boolean("--off",!1,{description:"Withdraw the consent instead of giving it"});async execute(){let t=await this.caller(),n=this.requireTenant(t),r=bM(this.traeger),i=await wM(t,n,this.mode);return await t.mutation(S.stripeConnect.setEnabled,{client:n,mode:i,traeger:r,enabled:!this.off}),this.print({tenant:n,traeger:r,mode:i,enabled:!this.off},o=>[{tenant:o.tenant,traeger:o.traeger,mode:o.mode,consented:o.enabled?"yes":"no"}]),0}},vM=[RS,IS,OS];async function PS(e,t,n={}){return e.query(S.tenantUsers.list,{client:t,...n})}s(PS,"listRows");async function oi(e,t,n){let r=n.trim();if(!r.includes("@")){if(!/^[a-z0-9]+$/.test(r))throw new Error(`"${r}" is neither an address nor an account id \u2014 a person is never named by name.`);return r}let i=r.toLowerCase(),o=[...await PS(e,t,{search:r}),...await PS(e,t,{search:r,status:"archived"})],a=[...new Set(o.filter(c=>c.email.toLowerCase()===i).map(c=>c.userId))],[l,...d]=a;if(l===void 0)throw new Error(`No user with the address "${r}" in "${t}".`);if(d.length>0)throw new Error(`The address "${r}" names ${a.length} accounts in "${t}" \u2014 pass the account id (${a.join(", ")}).`);return l}s(oi,"resolveTenantUser");async function xM(e,t){return e.query(S.tenantUsers.groups,{client:t})}s(xM,"groupsOf");async function SM(e,t,n){let r=await xM(e,t),i=r.filter(d=>d.key===n||d.id===n||d.label===n),[o,...a]=i,l=r.map(d=>`${d.label} (${d.key})`).join(", ");if(o===void 0)throw new Error(`No staff group "${n}" in "${t}". Groups: ${l||"(none)"}.`);if(a.length>0)throw new Error(`"${n}" names ${i.length} groups \u2014 pass the group id. Groups: ${i.map(d=>`${d.label} (${d.key}, ${d.id})`).join(", ")}.`);return o}s(SM,"resolveGroup");async function AM(e,t){return(await e.query(S.tenantUsers.units,{client:t})).units}s(AM,"unitsOf");async function T4(e,t,n){return(await SM(e,t,n)).id}s(T4,"resolveGroupFilter");function $4(e){let t=/^([A-Za-z]+)=(on|off)$/.exec(e.trim()),n=t?.[1];if(t===null||n===void 0)throw new Error(`--set takes <category>=on|off \u2014 got "${e}".`);if(!of.includes(n))throw new Error(`Unknown mail category "${n}". Categories: ${of.join(", ")}.`);return{category:n,enabled:t[2]==="on"}}s($4,"parseMailSetting");function R4(e){let t=e.map($4),n=t.map(r=>r.category).filter((r,i,o)=>o.indexOf(r)!==i);if(n.length>0)throw new Error(`--set names ${n.join(", ")} more than once.`);return t}s(R4,"parseMailSettings");var I4=s(e=>e===null?"":new Date(e).toISOString().slice(0,10),"day");function O4(e){return e.status==="active"&&e.invited?"invited":e.status}s(O4,"shownStatus");function EM(e){return{email:e.email,name:e.name,status:O4(e),groups:e.groups.map(t=>t.label).join(", "),signature:e.hasSignature?"yes":"no",lastSignIn:I4(e.lastSignInAt),userId:e.userId}}s(EM,"rowCells");async function TM(e,t,n){return e.query(S.tenantUsers.preferencesOf,{client:t,userId:n})}s(TM,"settingsOf");var Sn=class extends C{static{s(this,"TenantUsersCommand")}report(t,n){this.json?this.print(t):this.context.stdout.write(`${n}
|
|
10011
|
+
`)}printSettings(t){this.print(t,n=>n.map(r=>({category:r.category,email:r.email?"on":"off",decision:r.decision})),["category","email","decision"])}},_S=class extends Sn{static{s(this,"TenantUsersListCommand")}static paths=[["tenant-users","list"]];static usage=A.Usage({category:"Tenant users",description:"List the school's users (Administration \u2192 Nutzer); archived ones only with --status archived.",examples:[["Who has not signed in yet","plexus-cli --tenant <slug> tenant-users list --status invited"]]});status=f.String("--status",{description:"active, deactivated, archived or invited (active, never signed in)."});group=f.String("--group",{description:"A staff group, by id or exact label (`tenant-users groups list`)."});search=f.String("--search",{description:"Part of a name or address."});async execute(){let t=await this.caller(),n=this.requireTenant(t),r=this.status,i=this.group!==void 0?await T4(t,n,this.group):void 0,o=await PS(t,n,{...this.search!==void 0?{search:this.search}:{},...r!==void 0?{status:r}:{},...i!==void 0?{groupId:i}:{}});return this.print(o,a=>a.map(EM),["email","name","status","groups","signature","lastSignIn","userId"]),0}},NS=class extends Sn{static{s(this,"TenantUsersGroupsCommand")}static paths=[["tenant-users","groups","list"]];static usage=A.Usage({category:"Tenant users",description:"List the school's staff groups \u2014 the options of `tenant-users list --group` and `tenant-users invite --group`."});async execute(){let t=await this.caller(),n=this.requireTenant(t),r=await xM(t,n);return this.print(r,i=>i.map(o=>({label:o.label,key:o.key,id:o.id})),["label","key","id"]),0}},CS=class extends Sn{static{s(this,"TenantUsersUnitsCommand")}static paths=[["tenant-users","units","list"]];static usage=A.Usage({category:"Tenant users",description:"List the school's units by key \u2014 the options of `tenant-users invite --unit`."});async execute(){let t=await this.caller(),n=this.requireTenant(t),r=await AM(t,n);return this.print(r,i=>i.map(o=>({label:o.label,key:o.key,assignable:o.assignable?"yes":"no"})),["label","key","assignable"]),0}},DS=class extends Sn{static{s(this,"TenantUsersShowCommand")}static paths=[["tenant-users","show"]];static usage=A.Usage({category:"Tenant users",description:"Show one user of the school: status, groups, last sign-in, whether a signature is stored."});user=f.String({required:!0,name:"email|userId"});async execute(){let t=await this.caller(),n=this.requireTenant(t),r=await oi(t,n,this.user),i=await t.query(S.tenantUsers.get,{client:n,userId:r});return this.print(i,o=>[EM(o)],["email","name","status","groups","signature","lastSignIn","userId"]),0}},FS=class extends Sn{static{s(this,"TenantUsersHistoryCommand")}static paths=[["tenant-users","history"]];static usage=A.Usage({category:"Tenant users",description:"The Verlauf of one user in the school: who changed what, newest first."});user=f.String({required:!0,name:"email|userId"});async execute(){let t=await this.caller(),n=this.requireTenant(t),r=await oi(t,n,this.user),i=await P4(t,n,r);return this.print(i,o=>o.map(a=>({at:new Date(a.at).toISOString(),by:a.actorName??a.actorUserId,what:_4(a.detail)})),["at","by","what"]),0}};async function P4(e,t,n){return e.query(S.tenantUsers.events,{client:t,userId:n})}s(P4,"eventsOf");function _4(e){switch(e.kind){case"statusChanged":return`${e.from} \u2192 ${e.to}`+(e.groupsRemoved>0?`, ${e.groupsRemoved} group(s) removed`:"")+(e.successorUserId!==void 0?`, work handed to ${e.successorUserId}`:"");case"mailPreferenceChanged":return`mail ${e.category} ${e.email?"on":"off"}`;case"signatureRequested":return"signature requested";case"invited":return"invited"+(e.groupId!==void 0?` (group ${e.groupId})`:"");case"loginLinkSent":return"sign-in link sent";case"passwordResetSent":return"password-reset link sent"}}s(_4,"eventText");async function N4(e,t,n){return e.query(S.tenantUsers.handoverPreview,{client:t,userId:n})}s(N4,"previewOf");function C4(e,t,n){let r=[`DRY RUN \u2014 would ${e} ${t.person.name}.`];if(t.ruleRefusal!==null&&r.push(` refused: ${t.ruleRefusal}`),!t.endsStaff)r.push(" nothing to hand over (stays staff through another group).");else if(r.push(` to the successor: ${t.applicationCount} application(s), ${t.tasksToSuccessor} task(s)`,` back to the queue: ${t.tasksToQueue} team task(s), ${t.teamOwners} team owner role(s)`,` ended: ${t.teamMemberships} team membership(s); taken off ${t.tasksShared} shared task(s)`),t.successorRefusal!==null&&n!==void 0)r.push(` successor: ${n}`);else if(t.successorRefusal!==null){r.push(` needs --successor: ${t.successorRefusal}`),r.push(" candidates:");for(let i of t.candidates)r.push(` ${i.email} ${i.name} ${i.userId}`);t.candidates.length===0&&r.push(" (none)")}return n!==void 0&&t.successorRefusal===null&&r.push(" --successor: nothing needs one; it is passed on as given."),r.push(t.ruleRefusal!==null?"Replace them in the rule first, then re-run with --confirm.":"Re-run with --confirm."),r.join(`
|
|
10012
10012
|
`)}s(C4,"handoverText");var Sm=class extends Sn{static{s(this,"TransitionCommand")}user=f.String({required:!0,name:"email|userId"});successor=f.String("--successor",{description:"Who takes over their open applications and tasks (email or account id) \u2014 required while they hold any; the dry run lists the candidates."});confirm=f.Boolean("--confirm",!1,{description:"Write (without it, only the handover plan is printed)."});async execute(){let t=await this.caller(),n=this.requireTenant(t),r=await D4(t,n,{to:this.to,user:this.user,successor:this.successor,confirm:this.confirm});return this.report(r.payload,r.text),0}};async function D4(e,t,n){let r=await oi(e,t,n.user),i=await N4(e,t,r),o=n.successor!==void 0?{userId:await F4(e,t,i,n.successor)}:void 0;if(!n.confirm)return{payload:{tenant:t,userId:r,to:n.to,written:!1,preview:i},text:C4(n.to,i,n.successor)};let a={client:t,userId:r,...o!==void 0?{replaceWith:o}:{}};n.to==="deactivate"?await e.mutation(S.tenantUsers.deactivate,a):await e.mutation(S.tenantUsers.archive,a);let l=await e.query(S.tenantUsers.get,{client:t,userId:r});return{payload:l,text:`${l.email} in "${t}": ${l.status}.`}}s(D4,"transitionRun");async function F4(e,t,n,r){let i=r.trim().toLowerCase(),o=n.candidates.filter(l=>l.email.toLowerCase()===i),[a]=o;return a!==void 0&&o.length===1?a.userId:await oi(e,t,r)}s(F4,"resolveSuccessor");var LS=class extends Sm{static{s(this,"TenantUsersDeactivateCommand")}to="deactivate";static paths=[["tenant-users","deactivate"]];static usage=A.Usage({category:"Tenant users",description:"Deactivate a user in this school (reversible, groups kept but without effect, API tokens revoked) \u2014 plan unless --confirm.",examples:[["Hand the open work to a colleague","plexus-cli --env staging --tenant <slug> tenant-users deactivate a@example.com --successor b@example.com --confirm"]]})},MS=class extends Sm{static{s(this,"TenantUsersArchiveCommand")}to="archive";static paths=[["tenant-users","archive"]];static usage=A.Usage({category:"Tenant users",description:"Archive a user in this school (groups removed, hidden from lists and pickers) \u2014 plan unless --confirm."})},qS=class extends Sn{static{s(this,"TenantUsersReactivateCommand")}static paths=[["tenant-users","reactivate"]];static usage=A.Usage({category:"Tenant users",description:"Reactivate a deactivated or archived user in this school (an archived one starts without groups)."});user=f.String({required:!0,name:"email|userId"});async execute(){let t=await this.caller(),n=this.requireTenant(t),r=await oi(t,n,this.user);await t.mutation(S.tenantUsers.reactivate,{client:n,userId:r});let i=await t.query(S.tenantUsers.get,{client:n,userId:r});return this.report(i,`${i.email} in "${n}": ${i.status}.`),0}},KS=class extends Sn{static{s(this,"TenantUsersNotificationsListCommand")}static paths=[["tenant-users","notifications","list"]];static usage=A.Usage({category:"Tenant users",description:"A user's personal mail categories in this school and what an internal letter of each does today."});user=f.String({required:!0,name:"email|userId"});async execute(){let t=await this.caller(),n=this.requireTenant(t),r=await oi(t,n,this.user),i=await TM(t,n,r);return this.printSettings(i),0}},jS=class extends Sn{static{s(this,"TenantUsersNotificationsSetCommand")}static paths=[["tenant-users","notifications","set"]];static usage=A.Usage({category:"Tenant users",description:"Switch a user's personal mail categories in this school (the person is told by mail; the latest change, theirs or yours, holds).",examples:[["Turn one category off","plexus-cli --env staging --tenant <slug> tenant-users notifications set a@example.com --set <category>=off"]]});user=f.String({required:!0,name:"email|userId"});set=f.Array("--set",{required:!0,description:"<category>=on|off (repeatable)."});async execute(){let t=R4(this.set),n=await this.caller(),r=this.requireTenant(n),i=await oi(n,r,this.user);for(let a of t)await n.mutation(S.tenantUsers.setPreference,{client:r,userId:i,...a});let o=await TM(n,r,i);return this.printSettings(o),0}},BS=class extends Sn{static{s(this,"TenantUsersSignatureRequestCommand")}static paths=[["tenant-users","signature","request"]];static usage=A.Usage({category:"Tenant users",description:"Ask a user by mail to store their own signature \u2014 only while none is stored, at most once a day."});user=f.String({required:!0,name:"email|userId"});async execute(){let t=await this.caller(),n=this.requireTenant(t),r=await oi(t,n,this.user);return await t.mutation(S.tenantUsers.requestSignature,{client:n,userId:r}),this.report({tenant:n,userId:r,requested:!0},`Asked ${this.user} in "${n}" to store a signature.`),0}};function L4(e){if(!ze.includes(e))throw new Error(`--language takes ${ze.join(" or ")} \u2014 got "${e}".`);return e}s(L4,"inviteLanguage");async function M4(e,t,n){let r=L4(n.language);if(n.unit!==void 0&&n.group===void 0)throw new Error("--unit is the group's unit \u2014 pass it together with --group.");let i=n.group!==void 0?await SM(e,t,n.group):void 0,o=`${n.firstName} ${n.lastName} <${n.email}>`;if(!n.confirm){let l=[];if(n.unit!==void 0){let c=await AM(e,t),u=c.find(p=>p.key===n.unit);if(u===void 0)throw new Error(`No unit "${n.unit}" in "${t}". Units: ${c.map(p=>`${p.label} (${p.key})`).join(", ")||"(none)"}.`);l=[` unit: ${u.label} (${u.key})`]}let d=[`DRY RUN \u2014 would invite ${o} to "${t}" (language ${r} for a new account; an existing one keeps its own).`,` group: ${i!==void 0?`${i.label} (${i.key})`:"(none)"}`,...l," A one-time sign-in link is mailed to the address.","Re-run with --confirm."];return{payload:{tenant:t,email:n.email,written:!1,language:r,groupKey:i?.key??null,unitKey:n.unit??null},text:d.join(`
|
|
10013
10013
|
`)}}let{userId:a}=await e.mutation(S.tenantUsers.invite,{client:t,firstName:n.firstName,lastName:n.lastName,email:n.email,language:r,...i!==void 0?{groupKey:i.key}:{},...n.unit!==void 0?{unitKey:n.unit}:{}});return{payload:{tenant:t,userId:a,email:n.email,invited:!0},text:`Invited ${o} to "${t}" (${a}); a sign-in link is on its way.`}}s(M4,"inviteRun");var US=class extends Sn{static{s(this,"TenantUsersInviteCommand")}static paths=[["tenant-users","invite"]];static usage=A.Usage({category:"Tenant users",description:"Invite a new member of staff to this school: account, access and a one-time sign-in link by mail \u2014 plan unless --confirm.",examples:[["Invite into a group","plexus-cli --env staging --tenant <slug> tenant-users invite --first-name Ada --last-name Example --email ada@example.com --language de --group <key> --confirm"]]});firstName=f.String("--first-name",{required:!0,description:"The person's first name."});lastName=f.String("--last-name",{required:!0,description:"The person's last name."});email=f.String("--email",{required:!0,description:"The sign-in address; the link goes there."});language=f.String("--language",{required:!0,description:"de or en \u2014 the letters' language of a new account."});group=f.String("--group",{description:"A staff group, by key, id or exact label (`tenant-users groups list`); needs administration.permissions.manage."});unit=f.String("--unit",{description:"The group's unit, by its key (`tenant-users units list`); only with --group."});confirm=f.Boolean("--confirm",!1,{description:"Write and mail (without it, only the plan is printed)."});async execute(){let t=await this.caller(),n=this.requireTenant(t),r=await M4(t,n,{firstName:this.firstName,lastName:this.lastName,email:this.email,language:this.language,...this.group!==void 0?{group:this.group}:{},...this.unit!==void 0?{unit:this.unit}:{},confirm:this.confirm});return this.report(r.payload,r.text),0}};async function q4(e,t,n,r){let i=await oi(e,t,r);return n==="loginLink"?await e.mutation(S.tenantUsers.sendLoginLink,{client:t,userId:i}):await e.mutation(S.tenantUsers.sendPasswordReset,{client:t,userId:i}),{payload:{tenant:t,userId:i,sent:n},text:`Sent ${n==="loginLink"?"a one-time sign-in link":"a password-reset link"} to ${r} in "${t}".`}}s(q4,"linkRun");var Am=class extends Sn{static{s(this,"LinkCommand")}user=f.String({required:!0,name:"email|userId"});async execute(){let t=await this.caller(),n=this.requireTenant(t),r=await q4(t,n,this.link,this.user);return this.report(r.payload,r.text),0}},VS=class extends Am{static{s(this,"TenantUsersSendLoginLinkCommand")}link="loginLink";static paths=[["tenant-users","send-login-link"]];static usage=A.Usage({category:"Tenant users",description:"Mail a user of this school a fresh one-time sign-in link (active users only) \u2014 e.g. an invitation that expired."})},GS=class extends Am{static{s(this,"TenantUsersSendPasswordResetCommand")}link="passwordReset";static paths=[["tenant-users","send-password-reset"]];static usage=A.Usage({category:"Tenant users",description:"Mail a user of this school a password-reset link (active users only); only the person sets the new password."})},$M=[_S,NS,CS,DS,FS,LS,MS,qS,KS,jS,BS,US,VS,GS];var zS=class extends C{static{s(this,"TokensListCommand")}static paths=[["tokens","list"]];static usage=A.Usage({category:"Identity",description:"List your API tokens."});async execute(){let n=await(await this.caller()).query(S.apiTokens.listMine,{});return this.print(n,r=>r.map(i=>({id:i.id,name:i.name,prefix:i.prefix,active:i.active?"\u2713":"\u2717"})),["id","name","prefix","active"]),0}},WS=class extends C{static{s(this,"TokensCreateCommand")}static paths=[["tokens","create"]];static usage=A.Usage({category:"Identity",description:"Create a new API token (shown once) \u2014 for yourself, or with --for for a tenant administrator to hand over (platform right `_platform.users.manage`).",examples:[["Your own token","plexus-cli --env staging tokens create laptop"],["A token for a tenant administrator, kept out of the terminal","plexus-cli --env staging tokens create cli --for admin@schule.example --out /tmp/token.csv --quiet"]]});name=f.String({required:!0,name:"name"});forEmail=f.String("--for",{description:"Create the token FOR this account instead of yourself (platform rights `_platform.users.manage` and `_platform.apiTokens.manage`). The account must hold `administration.apiTokens.manage` in at least one tenant or, as a platform operator, `_platform.apiTokens.manage`."});out=f.String("--out",{description:"Append the `email,token` row to this CSV file (created with a header; never overwritten). Needs --for."});retiredOutput=ws();quiet=f.Boolean("--quiet",!1,{description:"Do not echo the token to stdout (use with --out)."});async execute(){let t={name:this.name,forEmail:this.forEmail,output:bs(this),quiet:this.quiet};K4(t);let n=await j4(await this.caller(),t);return this.json?(this.print(this.quiet?{id:n.id,prefix:n.prefix}:n),0):(this.context.stdout.write(B4(t,n)),0)}};function K4(e){if(e.forEmail===void 0&&(e.output!==void 0||e.quiet))throw new Error("plexus: --out/--quiet go with --for \u2014 your own token is printed for you to copy.");if(e.quiet&&e.output===void 0)throw new Error("plexus: --quiet without --out would lose the token \u2014 it is shown only once.");e.output!==void 0&&mo(e.output,"token")}s(K4,"assertCreateFlags");async function j4(e,t){let n=t.forEmail===void 0?await e.mutation(S.apiTokens.createToken,{name:t.name}):await e.mutation(S.apiTokens.createTokenFor,{email:t.forEmail,name:t.name});return t.forEmail!==void 0&&t.output!==void 0&&mf(t.output,t.forEmail.trim().toLowerCase(),n.plaintextKey,"token"),n}s(j4,"createTokenRun");function B4(e,t){let n=e.forEmail===void 0?"":` for ${e.forEmail}`,r=e.output!==void 0?` \u2192 ${e.output}`:"";return e.quiet?`Token created${n}${r} (prefix: ${t.prefix}).
|
|
10014
10014
|
`:`Token created${n}${r}. Copy it now \u2014 it is shown only once:
|
|
@@ -10045,6 +10045,6 @@ ${n.length} unusable ${o}:
|
|
|
10045
10045
|
`),r.length>0&&this.context.stdout.write(` ${r.length} linkable \u2014 plexus-cli users relink-auth <email>
|
|
10046
10046
|
`),i.length>0&&this.context.stdout.write(` ${i.length} without any login account \u2014 plexus-cli users provision --tenant <slug> --email <email> --name <name>
|
|
10047
10047
|
`)}else this.context.stdout.write(`No unusable identities.
|
|
10048
|
-
`);return n.length>0?1:0}},mA=class extends An{static{s(this,"UsersRelinkAuthCommand")}static paths=[["users","relink-auth"]];static usage=A.Usage({category:"Users",description:"Relink a user's identity row to its live Better Auth account (heals an orphan)."});email=f.String({required:!0});async execute(){let n=await(await this.caller()).mutation(S.platformAdmin.relinkAuthAccount,{email:this.email}),r=n.changed?`Relinked ${this.email} to live auth account ${n.authId}.`:`${this.email} already linked to the live auth account (no change).`;return this.report(n,r),0}};function OM(e,t){if(e===t)throw new Error("Pass exactly one of --on or --off.");return e}s(OM,"requireOnOff");var PM=[YS,JS,QS,ZS,XS,eA,tA,nA,rA,iA,oA,sA,xc,aA,lA,dA,cA,uA,fA,pA,mA];function _M(e){return e.de??e.en??Object.values(e)[0]??""}s(_M,"titleDe");function H4(e){return{id:e._id,kind:e.kind,status:e.status,title:_M(e.title).slice(0,50),assignee:e.assigneeUserId??"",group:e.queueGroupId??"",outcome:e.outcome??""}}s(H4,"row");var Y4=["id","kind","status","title","assignee","group","outcome"],gA=class extends C{static{s(this,"WorkItemsListCommand")}static paths=[["work-items","list"]];static usage=A.Usage({category:"Work-Items",description:"List work-items for the active tenant (filter by --mine/--application/--group)."});mine=f.Boolean("--mine",!1,{description:"Only items assigned to me."});application=f.String("--application",{description:"Filter by application id."});group=f.String("--group",{description:"Filter by team (permission-group) id."});assignee=f.String("--assignee",{description:"Filter by assignee users._id."});openOnly=f.Boolean("--open-only",!1,{description:"Only open items."});async execute(){let t=await this.caller(),n=this.requireTenant(t),r=await t.query(S.workItems.list,{client:n,...this.mine?{mine:!0}:{},...this.application?{applicationId:this.application}:{},...this.group?{queueGroupId:this.group}:{},...this.assignee?{assigneeUserId:this.assignee}:{},...this.openOnly?{openOnly:!0}:{}});return this.print(r,i=>i.map(H4),Y4),0}},yA=class extends C{static{s(this,"WorkItemsShowCommand")}static paths=[["work-items","show"]];static usage=A.Usage({category:"Work-Items",description:"Show one work-item by id."});workItemId=f.String({required:!0,name:"workItemId"});async execute(){let t=await this.caller(),n=this.requireTenant(t),r=await t.query(S.workItems.get,{client:n,workItemId:this.workItemId});if(r===null)throw new Error(`work-item ${this.workItemId} not found in tenant ${n}.`);return this.print(r,i=>[{field:"id",value:i._id},{field:"kind",value:i.kind},{field:"status",value:i.status},{field:"title",value:_M(i.title)},{field:"assignee",value:i.assigneeUserId??""},{field:"group",value:i.queueGroupId??""},{field:"application",value:i.applicationId??""},{field:"node",value:i.nodeId??""},{field:"outcome",value:i.outcome??""}]),0}},wA=class extends C{static{s(this,"WorkItemsCreateCommand")}static paths=[["work-items","create"]];static usage=A.Usage({category:"Work-Items",description:"Create a manual task work-item."});title=f.String("--title",{required:!0,description:"Task title."});description=f.String("--description",{description:"Task description."});application=f.String("--application",{description:"Link to an application id."});group=f.String("--group",{description:"Team (permission-group) id whose queue holds the task."});assignee=f.String("--assignee",{description:"Assignee users._id."});async execute(){let t=await this.caller(),n=this.requireTenant(t),r=await t.mutation(S.workItems.createManual,{client:n,title:this.title,...this.description?{description:this.description}:{},...this.application?{applicationId:this.application}:{},...this.group?{queueGroupId:this.group}:{},...this.assignee?{assigneeUserId:this.assignee}:{}});return this.print({workItemId:r.workItemId},i=>[{field:"workItemId",value:i.workItemId}]),0}},bA=class extends C{static{s(this,"WorkItemsCompleteCommand")}static paths=[["work-items","complete"]];static usage=A.Usage({category:"Work-Items",description:"Complete a work-item (optionally with an outcome)."});workItemId=f.String({required:!0,name:"workItemId"});outcome=f.String("--outcome",{description:"Outcome id to record."});async execute(){let t=await this.caller(),n=this.requireTenant(t),r=await t.mutation(S.workItems.complete,{client:n,workItemId:this.workItemId,...this.outcome?{outcome:this.outcome}:{}});return this.print({workItemId:r.workItemId,status:"done"},i=>[{field:"workItemId",value:i.workItemId},{field:"status",value:i.status}]),0}},kA=class extends C{static{s(this,"WorkItemsAssignCommand")}static paths=[["work-items","assign"]];static usage=A.Usage({category:"Work-Items",description:"Assign a work-item to a user (omit --user to unassign)."});workItemId=f.String({required:!0,name:"workItemId"});user=f.String("--user",{description:"Assignee users._id (omit to clear)."});async execute(){let t=await this.caller(),n=this.requireTenant(t),r=await t.mutation(S.workItems.assign,{client:n,workItemId:this.workItemId,...this.user?{userId:this.user}:{}});return this.print({workItemId:r.workItemId,assignee:this.user??"(cleared)"},i=>[{field:"workItemId",value:i.workItemId},{field:"assignee",value:i.assignee}]),0}},NM=[gA,yA,wA,bA,kA];var Om=[...XT,...KR,...lO,...aO,...CO,...WO,...zO,...RM,...PM,...$M,...N0,...ER,...OO,...yM,...QT,...A$,...xR,...JO,...YO,...XO,...eP,...RO,...mO,...NM,...NF,...wL,...P0,...bL,...oM,...pM,...C0,...U0,...z0,...gM,...vM,...g$];var CM="0.1.23";function DM(){return Om.flatMap(e=>(e.paths??[]).map(t=>{let n=t.join(" "),r=WT[Da(n)];return{path:n,effect:no(n),host:r===void 0?"shared":"terminal",...r===void 0?{}:{reason:r}}})).sort((e,t)=>e.path.localeCompare(t.path))}s(DM,"plexusCommandCatalog");import Mo from"node:path";function J4(e){let t=st()?.workspaceRoot??process.cwd(),n=Mo.resolve(t,e),r=Mo.relative(t,n);if(Mo.isAbsolute(e)||r===".."||r.startsWith(`..${Mo.sep}`))throw new Error("plexus: use a relative path inside the current workspace.");return{absolute:n,relative:r}}s(J4,"workspacePath");function Q4(e){let{absolute:t,relative:n}=J4(e.path??".");if(e.operation==="list"){if(!Oe(t))return{files:[]};let r=[],i=s(o=>{for(let a of Gi(o,{withFileTypes:!0})){if(a.isSymbolicLink())throw new Error("plexus: workspace symlinks are not supported.");let l=Mo.join(o,a.name);if(a.isDirectory()?i(l):r.push(Mo.relative(t,l)),r.length>200)throw new Error("plexus: the workspace contains too many files. List a subdirectory.")}},"visit");return i(t),{files:r.sort()}}if(!n)throw new Error("plexus: name a workspace file.");if(["read","search","edit"].includes(e.operation)){let r=ke(t);if(r.length>10*1024*1024)throw new Error("plexus: the workspace file exceeds 10 MB.");let i=new TextDecoder("utf-8",{fatal:!0}).decode(r);if(e.operation==="read"){let l=e.offset??0,d=e.maxChars??8e3,c=i.slice(l,l+d);return{path:n,content:c,...l||c.length<i.length?{offset:l,nextOffset:l+c.length<i.length?l+c.length:null,totalCharacters:i.length}:{}}}if(e.operation==="search"){if(!e.query)throw new Error("plexus: search needs a nonempty query.");let l=[],d=e.offset??0;for(;l.length<10;){let c=i.indexOf(e.query,d);if(c<0)break;l.push({offset:c,text:i.slice(Math.max(0,c-160),c+e.query.length+240)}),d=c+e.query.length}return{path:n,matches:l,nextOffset:l.length===10?d:null}}if(!e.oldText||typeof e.content!="string")throw new Error("plexus: edit needs oldText and replacement content.");let o=i.indexOf(e.oldText);if(o<0||o!==i.lastIndexOf(e.oldText))throw new Error("plexus: oldText must match exactly once. Read the current file and choose unique context.");let a=i.slice(0,o)+e.content+i.slice(o+e.oldText.length);if(Buffer.byteLength(a)>10*1024*1024)throw new Error("plexus: the edited file exceeds 10 MB.");return gt(t,a,"utf8"),{path:n,sizeBytes:Buffer.byteLength(a)}}if(e.operation==="write"){if(typeof e.content!="string"||Buffer.byteLength(e.content)>1e6)throw new Error("plexus: file content is missing or too large.");return Wt(Mo.dirname(t),{recursive:!0}),gt(t,e.content,"utf8"),{path:n,sizeBytes:Buffer.byteLength(e.content)}}if(e.operation==="remove")return Bo(t),{path:n,removed:!0};throw new Error("plexus: unknown workspace operation.")}s(Q4,"plexusWorkspace");function FM(e){return s(async function(n,r){if(!r||typeof r!="object"||Array.isArray(r))throw new Error("plexus: tool input must be an object.");let i=r,o=La[n];if(!o||!Object.hasOwn(La,n))throw new Error("plexus: unknown agent tool.");if(Object.keys(i).some(a=>!Object.hasOwn(o.inputSchema.properties,a)))throw new Error("plexus: unexpected tool argument.");if(n==="plexus"){if(!Array.isArray(i.argv)||i.argv.some(a=>typeof a!="string")||i.stdin!==void 0&&typeof i.stdin!="string")throw new Error("plexus: invalid command input.");return e.inspectCommand(i.argv),e.executeCommand({argv:i.argv,...i.stdin===void 0?{}:{stdin:i.stdin}})}if(n==="plexus_skill"){if(typeof i.path!="string"||i.path.length>240||!Object.hasOwn(zh,i.path))throw new Error("plexus: unknown skill reference. Start with SKILL.md.");return{path:i.path,content:zh[i.path],skillHash:wu}}if(typeof i.operation!="string"||!["list","read","search","edit","write","remove"].includes(i.operation)||i.path!==void 0&&(typeof i.path!="string"||i.path.length>500)||i.content!==void 0&&(typeof i.content!="string"||i.content.length>1e6)||i.oldText!==void 0&&(typeof i.oldText!="string"||i.oldText.length>1e6)||i.query!==void 0&&(typeof i.query!="string"||!i.query.length||i.query.length>1e3)||i.offset!==void 0&&(typeof i.offset!="number"||!Number.isSafeInteger(i.offset)||i.offset<0)||i.maxChars!==void 0&&(typeof i.maxChars!="number"||!Number.isSafeInteger(i.maxChars)||i.maxChars<1||i.maxChars>24e3))throw new Error("plexus: invalid workspace input.");return Q4(i)},"executePlexusAgentTool")}s(FM,"createPlexusAgentToolExecutor");var Pm=FM({inspectCommand:MM,executeCommand:qM});function _m(){let e=new zo({binaryLabel:"Plexus CLI",binaryName:"plexus-cli",binaryVersion:CM});e.register(ba.HelpCommand),e.register(ba.VersionCommand);for(let n of Om)e.register(n);async function t(n,r){let i;try{i=e.process(n,r)}catch(o){return(r.stderr??process.stderr).write(e.error(o,{colored:!1})),2}return e6(i,r.stderr??process.stderr),e.run(i,r)}return s(t,"run"),{process(n,r){return e.process(n,r)},run:t,async runExit(n,r){process.exitCode=await t(n,r)}}}s(_m,"createPlexusCli");function e6(e,t){let n=e.path.join(" "),r=e.constructor.paths?.[0]?.join(" ");r!==void 0&&n!==r&&Ca[n]===r&&dt(t,n,r),n in Ca&&no(n)==="confirm"&&!Fa(e)&&t.write(`plexus-cli: \`${Ca[n]}\` only prints its plan without --confirm \u2014 nothing was changed.
|
|
10048
|
+
`);return n.length>0?1:0}},mA=class extends An{static{s(this,"UsersRelinkAuthCommand")}static paths=[["users","relink-auth"]];static usage=A.Usage({category:"Users",description:"Relink a user's identity row to its live Better Auth account (heals an orphan)."});email=f.String({required:!0});async execute(){let n=await(await this.caller()).mutation(S.platformAdmin.relinkAuthAccount,{email:this.email}),r=n.changed?`Relinked ${this.email} to live auth account ${n.authId}.`:`${this.email} already linked to the live auth account (no change).`;return this.report(n,r),0}};function OM(e,t){if(e===t)throw new Error("Pass exactly one of --on or --off.");return e}s(OM,"requireOnOff");var PM=[YS,JS,QS,ZS,XS,eA,tA,nA,rA,iA,oA,sA,xc,aA,lA,dA,cA,uA,fA,pA,mA];function _M(e){return e.de??e.en??Object.values(e)[0]??""}s(_M,"titleDe");function H4(e){return{id:e._id,kind:e.kind,status:e.status,title:_M(e.title).slice(0,50),assignee:e.assigneeUserId??"",group:e.queueGroupId??"",outcome:e.outcome??""}}s(H4,"row");var Y4=["id","kind","status","title","assignee","group","outcome"],gA=class extends C{static{s(this,"WorkItemsListCommand")}static paths=[["work-items","list"]];static usage=A.Usage({category:"Work-Items",description:"List work-items for the active tenant (filter by --mine/--application/--group)."});mine=f.Boolean("--mine",!1,{description:"Only items assigned to me."});application=f.String("--application",{description:"Filter by application id."});group=f.String("--group",{description:"Filter by team (permission-group) id."});assignee=f.String("--assignee",{description:"Filter by assignee users._id."});openOnly=f.Boolean("--open-only",!1,{description:"Only open items."});async execute(){let t=await this.caller(),n=this.requireTenant(t),r=await t.query(S.workItems.list,{client:n,...this.mine?{mine:!0}:{},...this.application?{applicationId:this.application}:{},...this.group?{queueGroupId:this.group}:{},...this.assignee?{assigneeUserId:this.assignee}:{},...this.openOnly?{openOnly:!0}:{}});return this.print(r,i=>i.map(H4),Y4),0}},yA=class extends C{static{s(this,"WorkItemsShowCommand")}static paths=[["work-items","show"]];static usage=A.Usage({category:"Work-Items",description:"Show one work-item by id."});workItemId=f.String({required:!0,name:"workItemId"});async execute(){let t=await this.caller(),n=this.requireTenant(t),r=await t.query(S.workItems.get,{client:n,workItemId:this.workItemId});if(r===null)throw new Error(`work-item ${this.workItemId} not found in tenant ${n}.`);return this.print(r,i=>[{field:"id",value:i._id},{field:"kind",value:i.kind},{field:"status",value:i.status},{field:"title",value:_M(i.title)},{field:"assignee",value:i.assigneeUserId??""},{field:"group",value:i.queueGroupId??""},{field:"application",value:i.applicationId??""},{field:"node",value:i.nodeId??""},{field:"outcome",value:i.outcome??""}]),0}},wA=class extends C{static{s(this,"WorkItemsCreateCommand")}static paths=[["work-items","create"]];static usage=A.Usage({category:"Work-Items",description:"Create a manual task work-item."});title=f.String("--title",{required:!0,description:"Task title."});description=f.String("--description",{description:"Task description."});application=f.String("--application",{description:"Link to an application id."});group=f.String("--group",{description:"Team (permission-group) id whose queue holds the task."});assignee=f.String("--assignee",{description:"Assignee users._id."});async execute(){let t=await this.caller(),n=this.requireTenant(t),r=await t.mutation(S.workItems.createManual,{client:n,title:this.title,...this.description?{description:this.description}:{},...this.application?{applicationId:this.application}:{},...this.group?{queueGroupId:this.group}:{},...this.assignee?{assigneeUserId:this.assignee}:{}});return this.print({workItemId:r.workItemId},i=>[{field:"workItemId",value:i.workItemId}]),0}},bA=class extends C{static{s(this,"WorkItemsCompleteCommand")}static paths=[["work-items","complete"]];static usage=A.Usage({category:"Work-Items",description:"Complete a work-item (optionally with an outcome)."});workItemId=f.String({required:!0,name:"workItemId"});outcome=f.String("--outcome",{description:"Outcome id to record."});async execute(){let t=await this.caller(),n=this.requireTenant(t),r=await t.mutation(S.workItems.complete,{client:n,workItemId:this.workItemId,...this.outcome?{outcome:this.outcome}:{}});return this.print({workItemId:r.workItemId,status:"done"},i=>[{field:"workItemId",value:i.workItemId},{field:"status",value:i.status}]),0}},kA=class extends C{static{s(this,"WorkItemsAssignCommand")}static paths=[["work-items","assign"]];static usage=A.Usage({category:"Work-Items",description:"Assign a work-item to a user (omit --user to unassign)."});workItemId=f.String({required:!0,name:"workItemId"});user=f.String("--user",{description:"Assignee users._id (omit to clear)."});async execute(){let t=await this.caller(),n=this.requireTenant(t),r=await t.mutation(S.workItems.assign,{client:n,workItemId:this.workItemId,...this.user?{userId:this.user}:{}});return this.print({workItemId:r.workItemId,assignee:this.user??"(cleared)"},i=>[{field:"workItemId",value:i.workItemId},{field:"assignee",value:i.assignee}]),0}},NM=[gA,yA,wA,bA,kA];var Om=[...XT,...KR,...lO,...aO,...CO,...WO,...zO,...RM,...PM,...$M,...N0,...ER,...OO,...yM,...QT,...A$,...xR,...JO,...YO,...XO,...eP,...RO,...mO,...NM,...NF,...wL,...P0,...bL,...oM,...pM,...C0,...U0,...z0,...gM,...vM,...g$];var CM="0.1.24";function DM(){return Om.flatMap(e=>(e.paths??[]).map(t=>{let n=t.join(" "),r=WT[Da(n)];return{path:n,effect:no(n),host:r===void 0?"shared":"terminal",...r===void 0?{}:{reason:r}}})).sort((e,t)=>e.path.localeCompare(t.path))}s(DM,"plexusCommandCatalog");import Mo from"node:path";function J4(e){let t=st()?.workspaceRoot??process.cwd(),n=Mo.resolve(t,e),r=Mo.relative(t,n);if(Mo.isAbsolute(e)||r===".."||r.startsWith(`..${Mo.sep}`))throw new Error("plexus: use a relative path inside the current workspace.");return{absolute:n,relative:r}}s(J4,"workspacePath");function Q4(e){let{absolute:t,relative:n}=J4(e.path??".");if(e.operation==="list"){if(!Oe(t))return{files:[]};let r=[],i=s(o=>{for(let a of Gi(o,{withFileTypes:!0})){if(a.isSymbolicLink())throw new Error("plexus: workspace symlinks are not supported.");let l=Mo.join(o,a.name);if(a.isDirectory()?i(l):r.push(Mo.relative(t,l)),r.length>200)throw new Error("plexus: the workspace contains too many files. List a subdirectory.")}},"visit");return i(t),{files:r.sort()}}if(!n)throw new Error("plexus: name a workspace file.");if(["read","search","edit"].includes(e.operation)){let r=ke(t);if(r.length>10*1024*1024)throw new Error("plexus: the workspace file exceeds 10 MB.");let i=new TextDecoder("utf-8",{fatal:!0}).decode(r);if(e.operation==="read"){let l=e.offset??0,d=e.maxChars??8e3,c=i.slice(l,l+d);return{path:n,content:c,...l||c.length<i.length?{offset:l,nextOffset:l+c.length<i.length?l+c.length:null,totalCharacters:i.length}:{}}}if(e.operation==="search"){if(!e.query)throw new Error("plexus: search needs a nonempty query.");let l=[],d=e.offset??0;for(;l.length<10;){let c=i.indexOf(e.query,d);if(c<0)break;l.push({offset:c,text:i.slice(Math.max(0,c-160),c+e.query.length+240)}),d=c+e.query.length}return{path:n,matches:l,nextOffset:l.length===10?d:null}}if(!e.oldText||typeof e.content!="string")throw new Error("plexus: edit needs oldText and replacement content.");let o=i.indexOf(e.oldText);if(o<0||o!==i.lastIndexOf(e.oldText))throw new Error("plexus: oldText must match exactly once. Read the current file and choose unique context.");let a=i.slice(0,o)+e.content+i.slice(o+e.oldText.length);if(Buffer.byteLength(a)>10*1024*1024)throw new Error("plexus: the edited file exceeds 10 MB.");return gt(t,a,"utf8"),{path:n,sizeBytes:Buffer.byteLength(a)}}if(e.operation==="write"){if(typeof e.content!="string"||Buffer.byteLength(e.content)>1e6)throw new Error("plexus: file content is missing or too large.");return Wt(Mo.dirname(t),{recursive:!0}),gt(t,e.content,"utf8"),{path:n,sizeBytes:Buffer.byteLength(e.content)}}if(e.operation==="remove")return Bo(t),{path:n,removed:!0};throw new Error("plexus: unknown workspace operation.")}s(Q4,"plexusWorkspace");function FM(e){return s(async function(n,r){if(!r||typeof r!="object"||Array.isArray(r))throw new Error("plexus: tool input must be an object.");let i=r,o=La[n];if(!o||!Object.hasOwn(La,n))throw new Error("plexus: unknown agent tool.");if(Object.keys(i).some(a=>!Object.hasOwn(o.inputSchema.properties,a)))throw new Error("plexus: unexpected tool argument.");if(n==="plexus"){if(!Array.isArray(i.argv)||i.argv.some(a=>typeof a!="string")||i.stdin!==void 0&&typeof i.stdin!="string")throw new Error("plexus: invalid command input.");return e.inspectCommand(i.argv),e.executeCommand({argv:i.argv,...i.stdin===void 0?{}:{stdin:i.stdin}})}if(n==="plexus_skill"){if(typeof i.path!="string"||i.path.length>240||!Object.hasOwn(zh,i.path))throw new Error("plexus: unknown skill reference. Start with SKILL.md.");return{path:i.path,content:zh[i.path],skillHash:wu}}if(typeof i.operation!="string"||!["list","read","search","edit","write","remove"].includes(i.operation)||i.path!==void 0&&(typeof i.path!="string"||i.path.length>500)||i.content!==void 0&&(typeof i.content!="string"||i.content.length>1e6)||i.oldText!==void 0&&(typeof i.oldText!="string"||i.oldText.length>1e6)||i.query!==void 0&&(typeof i.query!="string"||!i.query.length||i.query.length>1e3)||i.offset!==void 0&&(typeof i.offset!="number"||!Number.isSafeInteger(i.offset)||i.offset<0)||i.maxChars!==void 0&&(typeof i.maxChars!="number"||!Number.isSafeInteger(i.maxChars)||i.maxChars<1||i.maxChars>24e3))throw new Error("plexus: invalid workspace input.");return Q4(i)},"executePlexusAgentTool")}s(FM,"createPlexusAgentToolExecutor");var Pm=FM({inspectCommand:MM,executeCommand:qM});function _m(){let e=new zo({binaryLabel:"Plexus CLI",binaryName:"plexus-cli",binaryVersion:CM});e.register(ba.HelpCommand),e.register(ba.VersionCommand);for(let n of Om)e.register(n);async function t(n,r){let i;try{i=e.process(n,r)}catch(o){return(r.stderr??process.stderr).write(e.error(o,{colored:!1})),2}return e6(i,r.stderr??process.stderr),e.run(i,r)}return s(t,"run"),{process(n,r){return e.process(n,r)},run:t,async runExit(n,r){process.exitCode=await t(n,r)}}}s(_m,"createPlexusCli");function e6(e,t){let n=e.path.join(" "),r=e.constructor.paths?.[0]?.join(" ");r!==void 0&&n!==r&&Ca[n]===r&&dt(t,n,r),n in Ca&&no(n)==="confirm"&&!Fa(e)&&t.write(`plexus-cli: \`${Ca[n]}\` only prints its plan without --confirm \u2014 nothing was changed.
|
|
10049
10049
|
`)}s(e6,"noteRetiredPath");function MM(e){let t=_m().process(ca(e),{executePlexusAgentTool:Pm}),n=t.path.join(" ");if(n.startsWith("agent "))throw new Error("plexus: nested agent transports are not allowed.");let r=DM().find(l=>l.path===n);if(!r){if(n===""||n==="--help"||n==="--version")return{path:n,writes:!1,host:"shared"};throw new Error(`plexus: command ${n} has no host classification.`)}let i=t,o=r.effect==="callKind"?Ef(As(Es),i.fn??"",i.kind):void 0,a=gu(n,{confirm:Fa(t),callKind:o});return{...r,writes:a}}s(MM,"inspectPlexusCommand");async function qM(e,t){if(t)return SA(t,()=>qM(e));if(!Array.isArray(e.argv)||e.argv.length===0||e.argv.length>128||e.argv.some(l=>typeof l!="string"||l.length>128e3)||(e.stdin?.length??0)>1e6)throw new Error("plexus: invalid command invocation.");let n="",r="",i=_m();if(st()){let l=MM(e.argv);if(l.host==="terminal")throw new Error(`plexus: this command requires a local machine. ${l.reason??""}`)}return{exitCode:await i.run(ca(e.argv),{executePlexusAgentTool:Pm,stdin:X4.from(e.stdin===void 0?[]:[e.stdin]),stdout:new LM({write(l,d,c){n+=String(l),c()}}),stderr:new LM({write(l,d,c){r+=String(l),c()}})}),stdout:n,stderr:r}}s(qM,"executePlexusCommand");RA({source:t6.join(import.meta.dirname,"skill")});_m().runExit(ca(process.argv.slice(2)),{executePlexusAgentTool:Pm});
|
|
10050
10050
|
//# sourceMappingURL=cli.mjs.map
|