@smartkomm/plexus-cli 0.1.268 → 0.1.269
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 +2 -2
- package/package.json +1 -1
package/dist/cli.mjs
CHANGED
|
@@ -11525,7 +11525,7 @@ Platzhalter: ${i||"\u2014"}
|
|
|
11525
11525
|
`);for(let d of o)d.severity==="warning"&&this.context.stderr.write(` warning ${d.area}: ${d.message}
|
|
11526
11526
|
`);let a=o.filter(d=>d.severity==="error");if(a.length>0){let d=this.publish?"\u2716":"\u26A0";for(let c of a)this.context.stderr.write(` ${d} ${c.area}: ${c.message}
|
|
11527
11527
|
`);if(this.publish)throw new Error("offer: fix local validation errors before --publish");this.context.stderr.write(` \u2192 applying as DRAFT despite validation errors (publish will enforce)
|
|
11528
|
-
`)}let l=await xq(t,n,{publish:this.publish,publishStage:this.stage});return this.print(l,d=>d.steps.map(c=>({step:c.step,action:c.action,detail:c.detail??""}))),0}};var Tc=class extends P{static{s(this,"OfferListCommand")}static paths=[["offer","list"]];static usage=R.Usage({category:"Offer",description:"List offers (manifests) + publish state for a tenant"});all=f.Boolean("--all",!1,{description:"Include archived (soft-deleted) offers"});async execute(){let n=await this.caller(),t=this.requireTenant(n),r=await n.query(x.workflow.listManifests,{client:t}),i=this.all?r:r.filter(o=>o.retiredAt==null);return this.print(i,o=>o.map(a=>({slug:a.offerKey,state:a.retiredAt!=null?"archived":a.isPublished?"published":"draft",sortOrder:a.sortOrder?.toString()??"-",label:Ce(a.label)}))),0}},Rc=class extends tn{static{s(this,"OfferStatusCommand")}static paths=[["offer","status"]];static usage=R.Usage({category:"Offer",description:"Publish state + whether program/pedagogy links resolve (applyable?)"});async execute(){let n=await this.caller(),t=this.requireTenant(n),i=(await n.query(x.workflow.listManifests,{client:t})).find(d=>d.offerKey===this.offerSlug);if(!i)throw new Error(`offer: no offer "${this.offerSlug}" in "${t}"`);let o=await n.query(x.workflow.getOfferPublishState,{client:t,offerKey:this.offerSlug}),a=s(d=>d==null?"-":`v${d}`,"rev"),l={manifest:i.isPublished?"published":"draft",workflow:i.workflowDefinitionId?"bound":"MISSING",pedagogy:i.pedagogy?Ce(i.pedagogy.unitName):"UNLINKED (not applyable)",draft:a(o?.draftRevision),internal:a(o?.internalHeadRevision),live:a(o?.externalHeadRevision),publish:o===null?"-":o.draftDiffersFromExternal?"PENDING (draft is ahead of live)":"up to date"};return this.print(l,d=>[{field:"manifest",value:d.manifest},{field:"workflow",value:d.workflow},{field:"pedagogy",value:d.pedagogy},{field:"draft",value:d.draft},{field:"internal",value:d.internal},{field:"live",value:d.live},{field:"publish",value:d.publish}]),0}},J9={draft:"draft (editable)",internal:"internal (staged, testable)",published:"published (live)",archived:"archived"},$c=class extends tn{static{s(this,"OfferVersionsCommand")}static paths=[["offer","versions"]];static usage=R.Usage({category:"Offer",description:"List an offer's versions (generations) \u2014 the id `applications start-test --version` takes",details:"Every generation of the offer family, newest first: the editable draft, an internally staged candidate, the live head and the archived history (still pinned by the applications started on it). `offerVersionId` is what `applications start-test --version` runs on; `workflowVersionId` opens the read-only graph of that generation.",examples:[["The versions of an offer","$0 offer versions --tenant test --slug grundschule-havelland"],["Test the staged candidate","$0 --env staging applications start-test --offer grundschule-havelland --run <run> --stage <stage> --applicant test@example.com --version <offerVersionId>"]]});async execute(){let n=await this.caller(),t=this.requireTenant(n),i=(await n.query(x.workflow.listManifests,{client:t})).find(a=>a.offerKey===this.offerSlug);if(!i)throw new Error(`offer versions: no offer "${this.offerSlug}" in "${t}"`);if(!i.workflowDefinitionId)throw new Error(`offer versions: "${this.offerSlug}" has no workflow yet \u2014 a draft offer has no generation to test`);let o=await n.query(x.workflow.listWorkflowVersions,{workflowDefinitionId:i.workflowDefinitionId});return this.print(o,a=>a.map(l=>({revision:`v${l.revision}`,state:J9[l.state],published:l.publishedAt===null?"\u2014":new Date(l.publishedAt).toISOString().slice(0,16).replace("T"," "),offerVersionId:l.offerVersionId,workflowVersionId:l.versionId}))),0}};var ZK={de:"--title",en:"--title-en"},Ic=class extends tn{static{s(this,"OfferCreateCommand")}static paths=[["offer","create"]];static usage=R.Usage({category:"Offer",description:"Create a draft offer (manifest) \u2014 title (= program name) + optional unit"});offer=sl("New offer slug (identity key) (required)");title=f.String("--title",{required:!0,description:"Bare program name in German \u2014 no run/year or levels (those are separate; see `offer init --title`)"});titleEn=f.String("--title-en",{required:!0,description:"The same title in English (every name a reader sees has both)"});unit=f.String("--unit",{description:"Pedagogic unit (school) the offer belongs to \u2014 its config key"});async execute(){let n=await this.caller(),t=this.requireTenant(n),r=nt({de:this.title,en:this.titleEn},"offer create",ZK);if(await n.mutation(x.workflow.createManifest,{client:t,slug:this.offerSlug,label:r}),this.unit){let i=await pt(n,t,this.offerSlug);await AS(n,t,this.offerSlug,SS(i,this.unit))}return this.print({created:this.offerSlug,title:r,unit:this.unit??null},i=>[{key:"created",value:i.created},{key:"title",value:Ce(i.title)},{key:"unit",value:i.unit??"\u2014"}]),0}},Oc=class extends tn{static{s(this,"OfferShowCommand")}static paths=[["offer","show"]];static usage=R.Usage({category:"Offer",description:"Full view of an offer: title, unit, levels, runs, capacity, state (incl. archived)"});async execute(){let n=await this.caller(),t=this.requireTenant(n),r=await Vn(n,t,this.offerSlug),i=await pt(n,t,r.offerKey),o=new Map(i.stages.map(c=>[c.stageId,c.name])),a=new Map(i.runs.map(c=>[c.runId,c.name])),l=r.retiredAt!=null,d={slug:r.offerKey,title:r.label,sortOrder:r.sortOrder??null,state:l?"archived":r.isPublished?"published":"draft",unit:r.pedagogy?r.pedagogy.unitName:null,workflow:r.workflowDefinitionId?"bound":"MISSING",applyable:!!(r.workflowDefinitionId&&r.pedagogy&&!l),levels:i.stages.map(c=>({key:c.key,name:c.name,sequence:c.sequence,gradeLevel:c.gradeLevel??null,archived:c.archived})),runs:i.runs.map(c=>({key:c.key,name:c.name,status:c.status,isOpen:c.isOpen,startDate:c.startDate??null,endDate:c.endDate??null})),capacity:i.runStages.map(c=>({run:a.get(c.runId)??c.runId,level:o.get(c.stageId)??c.stageId,capacity:c.capacity,isOpen:c.isOpen}))};return this.print(d,c=>[{section:"offer",item:c.slug,detail:Ce(c.title)},{section:"state",item:c.state,detail:`unit=${c.unit?Ce(c.unit):"\u2014"} sortOrder=${c.sortOrder??"\u2014"} workflow=${c.workflow} applyable=${c.applyable}`},...c.levels.map(u=>({section:"level",item:Ce(u.name),detail:`seq=${u.sequence}${u.gradeLevel!=null?` grade=${u.gradeLevel}`:""}${u.archived?" [archived]":""}`})),...c.runs.map(u=>({section:"run",item:Ce(u.name),detail:`${u.status}${u.isOpen?" open":""}${u.startDate?` ${u.startDate}\u2192${u.endDate??"?"}`:""}`})),...c.capacity.map(u=>({section:"capacity",item:`${typeof u.run=="string"?u.run:Ce(u.run)} \xD7 ${typeof u.level=="string"?u.level:Ce(u.level)}`,detail:`${u.capacity??"\u221E"}${u.isOpen?" open":" closed"}`}))]),0}},_c=class extends tn{static{s(this,"OfferSetCommand")}static paths=[["offer","set"]];static usage=R.Usage({category:"Offer",description:"Update an offer's title and/or pedagogic unit"});title=f.String("--title",{description:"New bare offer title in German (offer_versions.label, the offer-title SoT) \u2014 no run/year or levels (those are separate entities)"});titleEn=f.String("--title-en",{description:"New offer title in English \u2014 required with --title: the English is never copied from the German, and a title without English is refused"});programName=f.String("--program-name",{description:"Rename the underlying master-data program in German (programs.name, staff master-data only \u2014 distinct from --title); needs --program-name-en"});programNameEn=f.String("--program-name-en",{description:"The program's name in English (with --program-name)"});unit=f.String("--unit",{description:"New pedagogic unit (school) \u2014 its config key"});sortOrder=f.String("--sort-order",{description:"Display order among the unit's offers (lower = first, non-negative number)"});async execute(){let n=await this.caller(),t=this.requireTenant(n);if(this.title===void 0&&this.titleEn===void 0&&this.programName===void 0&&this.programNameEn===void 0&&!this.unit&&this.sortOrder===void 0)throw new Error("offer set: pass --title/--title-en, --program-name/--program-name-en, --unit and/or --sort-order");let r=await Vn(n,t,this.offerSlug),i=[],o;if(this.sortOrder!==void 0&&(o=Number(this.sortOrder),!Number.isFinite(o)||o<0))throw new Error(`offer set: --sort-order must be a non-negative number, got "${this.sortOrder}"`);let a=ur(r.label,{de:this.title,en:this.titleEn},"offer set",ZK);if((a!==void 0||o!==void 0)&&(await n.mutation(x.workflow.createManifest,{client:t,slug:this.offerSlug,label:a??r.label,...o!==void 0?{sortOrder:o}:{}}),a!==void 0&&i.push(`title=${Ce(a)}`),o!==void 0&&i.push(`sortOrder=${o}`)),this.programName!==void 0||this.programNameEn!==void 0){let l=nt({de:this.programName,en:this.programNameEn},"offer set",{de:"--program-name",en:"--program-name-en"});await n.mutation(x.programAdmin.updateProgram,{client:t,offerKey:r.offerKey,name:l}),i.push(`programName=${Ce(l)}`)}if(this.unit){let l=await pt(n,t,r.offerKey);await AS(n,t,r.offerKey,SS(l,this.unit)),i.push(`unit=${this.unit}`)}return this.print({slug:this.offerSlug,changes:i},l=>l.changes.map(d=>({change:d}))),0}},Pc=class extends tn{static{s(this,"OfferArchiveCommand")}static paths=[["offer","archive"]];static usage=R.Usage({category:"Offer",description:"Archive (soft-delete) an offer \u2014 `offer restore` brings it back, never orphans data"});async execute(){let n=await this.caller(),t=this.requireTenant(n),r=await Vn(n,t,this.offerSlug);return await n.mutation(x.programAdmin.setManifestArchived,{client:t,offerKey:r.offerKey,archived:!0}),this.print({archived:this.offerSlug},i=>[{key:"archived (soft-deleted)",value:i.archived}]),0}},Nc=class extends tn{static{s(this,"OfferRestoreCommand")}static paths=[["offer","restore"]];static usage=R.Usage({category:"Offer",description:"Restore an archived offer"});async execute(){let n=await this.caller(),t=this.requireTenant(n),r=await Vn(n,t,this.offerSlug);return await n.mutation(x.programAdmin.setManifestArchived,{client:t,offerKey:r.offerKey,archived:!1}),this.print({restored:this.offerSlug},i=>[{key:"restored",value:i.restored}]),0}},Cc=class extends tn{static{s(this,"OfferDeleteCommand")}static paths=[["offer","delete"],["offer","hard-delete"]];static usage=R.Usage({category:"Offer",description:"HARD-delete an offer (manifest + versions + workflow + smartform + program + stages + runs) \u2014 irreversible, plan unless --confirm; refused while any application exists. To take an offer down reversibly use `offer archive`.",examples:[["Plan","$0 --env staging --tenant <slug> offer delete --offer <offer>"],["Delete","$0 --env staging --tenant <slug> offer delete --offer <offer> --confirm"]]});confirm=f.Boolean("--confirm",!1,{description:"Delete for good (without it, only the plan is printed)."});retiredYes=f.Boolean("--yes",!1,{hidden:!0});async execute(){let n=await this.caller(),t=this.requireTenant(n),r=await Vn(n,t,this.offerSlug);if(!this.confirm){let o=await pt(n,t,r.offerKey),a={offer:r.offerKey,title:r.label,levels:o.stages.length,runs:o.runs.length,deleted:!1};return this.print(a,l=>[{key:"would HARD-delete offer",value:`${l.offer} (${Ce(l.title)}) \u2014 irreversible`},{key:"with",value:`${l.levels} level(s), ${l.runs} run(s), its versions, workflow and form`},{key:"refused when",value:"any application exists"},{key:"next",value:"re-run with --confirm \u2014 or `offer archive` to take it down reversibly"}]),0}let i=await n.mutation(x.programAdmin.hardDeleteOffer,{client:t,offerKey:r.offerKey});return this.print(i,o=>[{key:"hard-deleted offer",value:this.offerSlug},{key:"offerKey",value:o.deletedOfferKey},{key:"program",value:o.deletedProgramId??"(none)"},{key:"counts",value:JSON.stringify(o.counts)}]),0}};var XK={de:"--name",en:"--name-en"},Dc=class extends tn{static{s(this,"OfferRunAddCommand")}static paths=[["offer","run","add"]];static usage=R.Usage({category:"Offer",description:"Add a run (Schuljahr) to an offer"});name=f.String("--name",{required:!0,description:"Run name in German (e.g. Schuljahr 2026/27)"});nameEn=f.String("--name-en",{required:!0,description:"Run name in English (e.g. School year 2026/27)"});key=f.String("--key",{description:"Stable run key, as in bundle.yaml program.runs[].key (lowercase slug, e.g. 2026-27). Without it the key is derived from the German --name \u2014 and keeps that value after a rename"});start=f.String("--start",{description:"Start date (ISO, e.g. 2026-08-01)"});end=f.String("--end",{description:"End date (ISO)"});capacity=f.String("--capacity",{description:"Default seat capacity per level"});closed=f.Boolean("--closed",!1,{description:"Create closed (default: open)"});async execute(){let n=await this.caller(),t=this.requireTenant(n),r=await Vn(n,t,this.offerSlug),i=xs("capacity",this.capacity),o=nt({de:this.name,en:this.nameEn},"offer run add",XK);return await n.mutation(x.programAdmin.addProgramRun,{client:t,offerKey:r.offerKey,name:o,...this.key!==void 0?{key:this.key}:{},isOpen:!this.closed,...this.start?{startDate:this.start}:{},...this.end?{endDate:this.end}:{},...i!==void 0?{defaultCapacity:i}:{}}),this.print({added:o},a=>[{key:"run added",value:Ce(a.added)}]),0}},Fc=class extends tn{static{s(this,"OfferRunSetCommand")}static paths=[["offer","run","set"]];static usage=R.Usage({category:"Offer",description:"Update a run: rename / dates"});run=f.String("--run",{required:!0,description:"Key of the run to update (bundle.yaml program.runs[].key)"});name=f.String("--name",{description:"New run name in German"});nameEn=f.String("--name-en",{description:"New run name in English"});start=f.String("--start",{description:"Start date (ISO)"});end=f.String("--end",{description:"End date (ISO)"});async execute(){let n=await this.caller(),t=this.requireTenant(n),r=await Vn(n,t,this.offerSlug),i=await pt(n,t,r.offerKey),o=il(i,this.run),a=i.runs.find(d=>d.runId===o),l=ur(a.name,{de:this.name,en:this.nameEn},"offer run set",XK);return await n.mutation(x.programAdmin.updateProgramRun,{client:t,offerKey:r.offerKey,runId:o,...l!==void 0?{name:l}:{},...this.start?{startDate:this.start}:{},...this.end?{endDate:this.end}:{}}),this.print({updated:this.run},d=>[{key:"run updated",value:d.updated}]),0}},Lc=class extends tn{static{s(this,"OfferRunArchiveCommand")}static paths=[["offer","run","archive"]];static usage=R.Usage({category:"Offer",description:"Soft-delete (archive) a run \u2014 retired from the portal, restorable"});run=f.String("--run",{required:!0,description:"Run key (bundle.yaml program.runs[].key)"});async execute(){let n=await this.caller(),t=this.requireTenant(n),r=await Vn(n,t,this.offerSlug),i=await pt(n,t,r.offerKey);return await n.mutation(x.programAdmin.updateProgramRun,{client:t,offerKey:r.offerKey,runId:il(i,this.run),status:"archived"}),this.print({archived:this.run},o=>[{key:"run archived",value:o.archived}]),0}},Mc=class extends tn{static{s(this,"OfferRunRestoreCommand")}static paths=[["offer","run","restore"]];static usage=R.Usage({category:"Offer",description:"Restore an archived run"});run=f.String("--run",{required:!0,description:"Run key (bundle.yaml program.runs[].key)"});async execute(){let n=await this.caller(),t=this.requireTenant(n),r=await Vn(n,t,this.offerSlug),i=await pt(n,t,r.offerKey);return await n.mutation(x.programAdmin.updateProgramRun,{client:t,offerKey:r.offerKey,runId:il(i,this.run),status:"active"}),this.print({restored:this.run},o=>[{key:"run restored",value:o.restored}]),0}};var ej={de:"--name",en:"--name-en"},qc=class extends tn{static{s(this,"OfferLevelAddCommand")}static paths=[["offer","level","add"]];static usage=R.Usage({category:"Offer",description:"Add a level (Klassenstufe) to an offer"});name=f.String("--name",{required:!0,description:"Level name in German"});nameEn=f.String("--name-en",{required:!0,description:"Level name in English"});grade=f.String("--grade",{description:"Grade level (integer)"});key=f.String("--key",{description:"Stable level key, as in bundle.yaml program.stages[].key (lowercase slug). Without it the key is derived from the German --name \u2014 and keeps that value after a rename"});async execute(){let n=await this.caller(),t=this.requireTenant(n),r=await Vn(n,t,this.offerSlug),i=xs("grade",this.grade),o=nt({de:this.name,en:this.nameEn},"offer level add",ej);return await n.mutation(x.programAdmin.addProgramStage,{client:t,offerKey:r.offerKey,name:o,...i!==void 0?{gradeLevel:i}:{},...this.key!==void 0?{key:this.key}:{}}),this.print({added:o},a=>[{key:"level added",value:Ce(a.added)}]),0}},Kc=class extends tn{static{s(this,"OfferLevelSetCommand")}static paths=[["offer","level","set"],["offer","level","rename"]];static usage=R.Usage({category:"Offer",description:"Change a level's name and/or grade"});level=f.String("--level",{required:!0,description:"Key of the level to update (bundle.yaml program.stages[].key)"});name=f.String("--name",{description:"New level name in German"});nameEn=f.String("--name-en",{description:"New level name in English"});grade=f.String("--grade",{description:"New grade level (integer)"});async execute(){let n=await this.caller(),t=this.requireTenant(n);if(this.name===void 0&&this.nameEn===void 0&&this.grade===void 0)throw new Error("offer level set: pass --name/--name-en and/or --grade");let r=await Vn(n,t,this.offerSlug),i=await pt(n,t,r.offerKey),o=xs("grade",this.grade),a=ol(i,this.level),l=i.stages.find(c=>c.stageId===a),d=ur(l.name,{de:this.name,en:this.nameEn},"offer level set",ej);return await n.mutation(x.programAdmin.updateProgramStage,{client:t,offerKey:r.offerKey,stageId:a,...d!==void 0?{name:d}:{},...o!==void 0?{gradeLevel:o}:{}}),this.print({updated:this.level},c=>[{key:"level updated",value:c.updated}]),0}},jc=class extends tn{static{s(this,"OfferLevelArchiveCommand")}static paths=[["offer","level","archive"],["offer","level","remove"]];static usage=R.Usage({category:"Offer",description:"Soft-delete (archive) a level \u2014 retired from the portal, restorable. Refused while an active application sits on the level"});level=f.String("--level",{required:!0,description:"Level key (bundle.yaml program.stages[].key)"});async execute(){let n=await this.caller(),t=this.requireTenant(n),r=await Vn(n,t,this.offerSlug),i=await pt(n,t,r.offerKey),{warnings:o}=await n.mutation(x.programAdmin.updateProgramStage,{client:t,offerKey:r.offerKey,stageId:ol(i,this.level),archived:!0});return this.print({removed:this.level,warnings:o},a=>[{key:"level removed (soft)",value:a.removed},...a.warnings.map(l=>({key:"warning",value:l}))]),0}},Vc=class extends tn{static{s(this,"OfferLevelRestoreCommand")}static paths=[["offer","level","restore"]];static usage=R.Usage({category:"Offer",description:"Restore an archived level"});level=f.String("--level",{required:!0,description:"Level key (bundle.yaml program.stages[].key)"});async execute(){let n=await this.caller(),t=this.requireTenant(n),r=await Vn(n,t,this.offerSlug),i=await pt(n,t,r.offerKey);return await n.mutation(x.programAdmin.updateProgramStage,{client:t,offerKey:r.offerKey,stageId:ol(i,this.level),archived:!1}),this.print({restored:this.level},o=>[{key:"level restored",value:o.restored}]),0}},Bc=class extends tn{static{s(this,"OfferLevelMoveCommand")}static paths=[["offer","level","move"]];static usage=R.Usage({category:"Offer",description:"Reorder a level among the offer's levels (--before|--after another level)"});level=f.String("--level",{required:!0,description:"Key of the level to move"});before=f.String("--before",{description:"Place before the level with this key"});after=f.String("--after",{description:"Place after the level with this key"});async execute(){let n=await this.caller(),t=this.requireTenant(n);if(this.before===void 0==(this.after===void 0))throw new Error("offer level move: pass exactly one of --before <level> / --after <level>");let r=this.before??this.after;if(r===this.level)throw new Error("offer level move: --before/--after anchor cannot be the level itself");let i=await Vn(n,t,this.offerSlug),o=await pt(n,t,i.offerKey);if(o.programKey===null)throw new Error("offer level move: the offer has no program yet");let a=o.programKey,l=o.stages.map(p=>({stageId:p.stageId,key:Jr(a,p.key),name:p.name})),d=l.find(p=>p.key===this.level);if(!d)throw new Error(`offer level move: level "${this.level}" not found. Available keys: ${l.map(p=>p.key).join(", ")||"(none)"}`);if(!l.some(p=>p.key===r))throw new Error(`offer level move: anchor level "${r}" not found. Available keys: ${l.map(p=>p.key).join(", ")}`);let c=l.filter(p=>p.key!==this.level),u=c.findIndex(p=>p.key===r);c.splice(this.before!==void 0?u:u+1,0,d);for(let p=0;p<c.length;p++)await n.mutation(x.programAdmin.updateProgramStage,{client:t,offerKey:i.offerKey,stageId:c[p].stageId,sequence:p+1});return this.print({moved:this.level,order:c.map(p=>p.key)},p=>[{key:"level moved",value:p.moved},{key:"new order",value:p.order.join(" \u2192 ")}]),0}};var Uc=class extends tn{static{s(this,"OfferCapacitySetCommand")}static paths=[["offer","capacity","set"]];static usage=R.Usage({category:"Offer",description:"Set seat capacity and/or open-state for one run \xD7 level cell"});run=f.String("--run",{required:!0,description:"Run key (bundle.yaml program.runs[].key)"});level=f.String("--level",{required:!0,description:"Level key (bundle.yaml program.stages[].key)"});capacity=f.String("--capacity",{description:'Seat capacity (whole number) or "unlimited"'});open=f.Boolean("--open",!1,{description:"Open this cell"});close=f.Boolean("--close",!1,{description:"Close this cell"});async execute(){let n=await this.caller(),t=this.requireTenant(n);if(this.open&&this.close)throw new Error("offer capacity set: pass only one of --open / --close");let r=await Vn(n,t,this.offerSlug),i=await pt(n,t,r.offerKey),o=this.capacity==="unlimited"?"unlimited":xs("capacity",this.capacity),a=this.open?!0:this.close?!1:void 0;return await n.mutation(x.programAdmin.setRunStageCapacity,{client:t,offerKey:r.offerKey,runId:il(i,this.run),stageId:ol(i,this.level),...o!==void 0?{capacity:o}:{},...a!==void 0?{isOpen:a}:{}}),this.print({run:this.run,level:this.level},l=>[{key:"capacity set",value:`${l.run} \xD7 ${l.level}`}]),0}};function RS(e,n,t){let r=e.indexOf("=");if(r<=0||r===e.length-1)throw new Error(`offer upgrade: ${n} takes ${t} (got "${e}")`);return[e.slice(0,r),e.slice(r+1)]}s(RS,"splitPair");function Q9(e,n){let t={waitlistOrder:e};if(!Rw(t))throw new Error(`offer upgrade: ${n} takes <node>=<arrival|manual> (got "${e}")`);return t}s(Q9,"parsePolicy");function eg(e,n){if(e===void 0)return{};if(e===null||typeof e!="object"||Array.isArray(e))throw new Error(`offer upgrade: ${n} must be an object`);return e}s(eg,"record");function nj(e){let n={},t={},r={},i=s((a,l,d,c)=>{if(Object.hasOwn(a,l)&&JSON.stringify(a[l])!==JSON.stringify(d))throw new Error(`offer upgrade: ${c} "${l}" is answered twice with different values`);a[l]=d},"put"),o=eg(e.answersFile,"the answers file");for(let a of Object.keys(o))if(a!=="semantics"&&a!=="waitlistPolicy"&&a!=="payee")throw new Error(`offer upgrade: the answers file has an unknown key "${a}" (semantics | waitlistPolicy | payee)`);for(let[a,l]of Object.entries(eg(o.semantics,"answers.semantics"))){if(typeof l!="string")throw new Error(`offer upgrade: answers.semantics["${a}"] must be a string`);i(n,a,l,"the outcome")}for(let[a,l]of Object.entries(eg(o.waitlistPolicy,"answers.waitlistPolicy"))){if(!Rw(l))throw new Error(`offer upgrade: answers.waitlistPolicy["${a}"] must be { waitlistOrder: arrival|manual }`);i(t,a,l,"the waitlist node")}for(let[a,l]of Object.entries(eg(o.payee,"answers.payee"))){if(typeof l!="string"||l==="")throw new Error(`offer upgrade: answers.payee["${a}"] must be a Tr\xE4ger key`);i(r,a,l,"the payment node")}for(let a of e.semantic??[]){let[l,d]=RS(a,"--semantic","<node>.<outcome>=<meaning>");if(!l.includes("."))throw new Error(`offer upgrade: --semantic takes <node>.<outcome>=<meaning> (got "${a}")`);i(n,l,d,"the outcome")}for(let a of e.waitlistPolicy??[]){let[l,d]=RS(a,"--waitlist-policy","<node>=<arrival|manual>");i(t,l,Q9(d,"--waitlist-policy"),"the waitlist node")}for(let a of e.payee??[]){let[l,d]=RS(a,"--payee","<node>=<Tr\xE4ger key>");i(r,l,d,"the payment node")}return{semantics:n,waitlistPolicy:t,payee:r}}s(nj,"parseUpgradeAnswers");function tj(e){let n=e.candidates?.join("|")??"";switch(e.answer){case"semantic":return`--semantic ${e.answerKey}=<${n}>`;case"waitlistPolicy":return`--waitlist-policy ${e.answerKey}=<arrival|manual>`;case"payee":return`--payee ${e.answerKey}=<Tr\xE4ger key>`;case"edit":return"edit the file by hand"}}s(tj,"answerHint");function rj(e){let n=e.defaulted;if(n===void 0)return"-";switch(n.answer){case"semantic":return`--semantic ${n.answerKey}=${n.value}`;case"waitlistPolicy":return`--waitlist-policy ${n.answerKey}=${n.value}`;case"undeclaredBinding":return`${n.answerKey} deleted (publish refuses an undeclared input)`}}s(rj,"defaultedHint");function ij(e,n){Bn(n,{recursive:!0});for(let t of Kr(e,{withFileTypes:!0})){let r=Y.join(e,t.name),i=Y.join(n,t.name);if(t.isDirectory())ij(r,i);else if(t.isFile())We(i,he(r));else throw new Error(`offer upgrade: ${r} is neither a file nor a directory \u2014 refusing to copy it`)}}s(ij,"copyTree");function oj(e){let n=sF(e.dir),{bundle:t,changes:r,refusals:i}=tF(n,e.answers);if(!e.write||i.length>0)return{dir:n.dir,changes:r,refusals:i,written:null};let o=n.dir;if(e.out!==void 0){if(o=Y.resolve(e.out),Ae(o)&&Kr(o).length>0)throw new Error(`offer upgrade: --out ${o} is not empty \u2014 choose a fresh directory`);ij(n.dir,o)}return Nt({...t,dir:o}),{dir:n.dir,changes:r,refusals:i,written:o}}s(oj,"runUpgrade");var Gc=class extends xe{static{s(this,"OfferUpgradeCommand")}static paths=[["offer","upgrade"]];static usage=R.Usage({category:"Offer",description:"Rewrite a bundle exported in an older format into the current one (offline; dry run unless --write)",details:`
|
|
11528
|
+
`)}let l=await xq(t,n,{publish:this.publish,publishStage:this.stage});return this.print(l,d=>d.steps.map(c=>({step:c.step,action:c.action,detail:c.detail??""}))),0}};var Tc=class extends P{static{s(this,"OfferListCommand")}static paths=[["offer","list"]];static usage=R.Usage({category:"Offer",description:"List offers (manifests) + publish state for a tenant"});all=f.Boolean("--all",!1,{description:"Include archived (soft-deleted) offers"});async execute(){let n=await this.caller(),t=this.requireTenant(n),r=await n.query(x.workflow.listManifests,{client:t}),i=this.all?r:r.filter(o=>o.retiredAt==null);return this.print(i,o=>o.map(a=>({slug:a.offerKey,state:a.retiredAt!=null?"archived":a.isPublished?"published":"draft",sortOrder:a.sortOrder?.toString()??"-",label:Ce(a.label)}))),0}},Rc=class extends tn{static{s(this,"OfferStatusCommand")}static paths=[["offer","status"]];static usage=R.Usage({category:"Offer",description:"Publish state + whether program/pedagogy links resolve (applyable?)"});async execute(){let n=await this.caller(),t=this.requireTenant(n),i=(await n.query(x.workflow.listManifests,{client:t})).find(d=>d.offerKey===this.offerSlug);if(!i)throw new Error(`offer: no offer "${this.offerSlug}" in "${t}"`);let o=await n.query(x.workflow.getOfferPublishState,{client:t,offerKey:this.offerSlug}),a=s(d=>d==null?"-":`v${d}`,"rev"),l={manifest:i.isPublished?"published":"draft",workflow:i.workflowDefinitionId?"bound":"MISSING",pedagogy:i.pedagogy?Ce(i.pedagogy.unitName):"UNLINKED (not applyable)",draft:a(o?.draftRevision),internal:a(o?.internalHeadRevision),live:a(o?.externalHeadRevision),publish:o===null?"-":o.draftDiffersFromExternal?"PENDING (draft is ahead of live)":"up to date"};return this.print(l,d=>[{field:"manifest",value:d.manifest},{field:"workflow",value:d.workflow},{field:"pedagogy",value:d.pedagogy},{field:"draft",value:d.draft},{field:"internal",value:d.internal},{field:"live",value:d.live},{field:"publish",value:d.publish}]),0}},J9={draft:"draft (editable)",internal:"internal (staged, testable)",published:"published (live)",archived:"archived"},$c=class extends tn{static{s(this,"OfferVersionsCommand")}static paths=[["offer","versions"]];static usage=R.Usage({category:"Offer",description:"List an offer's versions (generations) \u2014 the id `applications start-test --version` takes",details:"Every generation of the offer family, newest first: the editable draft, an internally staged candidate, the live head and the archived history (still pinned by the applications started on it). `offerVersionId` is what `applications start-test --version` runs on; `workflowVersionId` opens the read-only graph of that generation.",examples:[["The versions of an offer","$0 offer versions --tenant test --slug gymnasium-havelland"],["Test the staged candidate","$0 --env staging applications start-test --offer gymnasium-havelland --run <run> --stage <stage> --applicant test@example.com --version <offerVersionId>"]]});async execute(){let n=await this.caller(),t=this.requireTenant(n),i=(await n.query(x.workflow.listManifests,{client:t})).find(a=>a.offerKey===this.offerSlug);if(!i)throw new Error(`offer versions: no offer "${this.offerSlug}" in "${t}"`);if(!i.workflowDefinitionId)throw new Error(`offer versions: "${this.offerSlug}" has no workflow yet \u2014 a draft offer has no generation to test`);let o=await n.query(x.workflow.listWorkflowVersions,{workflowDefinitionId:i.workflowDefinitionId});return this.print(o,a=>a.map(l=>({revision:`v${l.revision}`,state:J9[l.state],published:l.publishedAt===null?"\u2014":new Date(l.publishedAt).toISOString().slice(0,16).replace("T"," "),offerVersionId:l.offerVersionId,workflowVersionId:l.versionId}))),0}};var ZK={de:"--title",en:"--title-en"},Ic=class extends tn{static{s(this,"OfferCreateCommand")}static paths=[["offer","create"]];static usage=R.Usage({category:"Offer",description:"Create a draft offer (manifest) \u2014 title (= program name) + optional unit"});offer=sl("New offer slug (identity key) (required)");title=f.String("--title",{required:!0,description:"Bare program name in German \u2014 no run/year or levels (those are separate; see `offer init --title`)"});titleEn=f.String("--title-en",{required:!0,description:"The same title in English (every name a reader sees has both)"});unit=f.String("--unit",{description:"Pedagogic unit (school) the offer belongs to \u2014 its config key"});async execute(){let n=await this.caller(),t=this.requireTenant(n),r=nt({de:this.title,en:this.titleEn},"offer create",ZK);if(await n.mutation(x.workflow.createManifest,{client:t,slug:this.offerSlug,label:r}),this.unit){let i=await pt(n,t,this.offerSlug);await AS(n,t,this.offerSlug,SS(i,this.unit))}return this.print({created:this.offerSlug,title:r,unit:this.unit??null},i=>[{key:"created",value:i.created},{key:"title",value:Ce(i.title)},{key:"unit",value:i.unit??"\u2014"}]),0}},Oc=class extends tn{static{s(this,"OfferShowCommand")}static paths=[["offer","show"]];static usage=R.Usage({category:"Offer",description:"Full view of an offer: title, unit, levels, runs, capacity, state (incl. archived)"});async execute(){let n=await this.caller(),t=this.requireTenant(n),r=await Vn(n,t,this.offerSlug),i=await pt(n,t,r.offerKey),o=new Map(i.stages.map(c=>[c.stageId,c.name])),a=new Map(i.runs.map(c=>[c.runId,c.name])),l=r.retiredAt!=null,d={slug:r.offerKey,title:r.label,sortOrder:r.sortOrder??null,state:l?"archived":r.isPublished?"published":"draft",unit:r.pedagogy?r.pedagogy.unitName:null,workflow:r.workflowDefinitionId?"bound":"MISSING",applyable:!!(r.workflowDefinitionId&&r.pedagogy&&!l),levels:i.stages.map(c=>({key:c.key,name:c.name,sequence:c.sequence,gradeLevel:c.gradeLevel??null,archived:c.archived})),runs:i.runs.map(c=>({key:c.key,name:c.name,status:c.status,isOpen:c.isOpen,startDate:c.startDate??null,endDate:c.endDate??null})),capacity:i.runStages.map(c=>({run:a.get(c.runId)??c.runId,level:o.get(c.stageId)??c.stageId,capacity:c.capacity,isOpen:c.isOpen}))};return this.print(d,c=>[{section:"offer",item:c.slug,detail:Ce(c.title)},{section:"state",item:c.state,detail:`unit=${c.unit?Ce(c.unit):"\u2014"} sortOrder=${c.sortOrder??"\u2014"} workflow=${c.workflow} applyable=${c.applyable}`},...c.levels.map(u=>({section:"level",item:Ce(u.name),detail:`seq=${u.sequence}${u.gradeLevel!=null?` grade=${u.gradeLevel}`:""}${u.archived?" [archived]":""}`})),...c.runs.map(u=>({section:"run",item:Ce(u.name),detail:`${u.status}${u.isOpen?" open":""}${u.startDate?` ${u.startDate}\u2192${u.endDate??"?"}`:""}`})),...c.capacity.map(u=>({section:"capacity",item:`${typeof u.run=="string"?u.run:Ce(u.run)} \xD7 ${typeof u.level=="string"?u.level:Ce(u.level)}`,detail:`${u.capacity??"\u221E"}${u.isOpen?" open":" closed"}`}))]),0}},_c=class extends tn{static{s(this,"OfferSetCommand")}static paths=[["offer","set"]];static usage=R.Usage({category:"Offer",description:"Update an offer's title and/or pedagogic unit"});title=f.String("--title",{description:"New bare offer title in German (offer_versions.label, the offer-title SoT) \u2014 no run/year or levels (those are separate entities)"});titleEn=f.String("--title-en",{description:"New offer title in English \u2014 required with --title: the English is never copied from the German, and a title without English is refused"});programName=f.String("--program-name",{description:"Rename the underlying master-data program in German (programs.name, staff master-data only \u2014 distinct from --title); needs --program-name-en"});programNameEn=f.String("--program-name-en",{description:"The program's name in English (with --program-name)"});unit=f.String("--unit",{description:"New pedagogic unit (school) \u2014 its config key"});sortOrder=f.String("--sort-order",{description:"Display order among the unit's offers (lower = first, non-negative number)"});async execute(){let n=await this.caller(),t=this.requireTenant(n);if(this.title===void 0&&this.titleEn===void 0&&this.programName===void 0&&this.programNameEn===void 0&&!this.unit&&this.sortOrder===void 0)throw new Error("offer set: pass --title/--title-en, --program-name/--program-name-en, --unit and/or --sort-order");let r=await Vn(n,t,this.offerSlug),i=[],o;if(this.sortOrder!==void 0&&(o=Number(this.sortOrder),!Number.isFinite(o)||o<0))throw new Error(`offer set: --sort-order must be a non-negative number, got "${this.sortOrder}"`);let a=ur(r.label,{de:this.title,en:this.titleEn},"offer set",ZK);if((a!==void 0||o!==void 0)&&(await n.mutation(x.workflow.createManifest,{client:t,slug:this.offerSlug,label:a??r.label,...o!==void 0?{sortOrder:o}:{}}),a!==void 0&&i.push(`title=${Ce(a)}`),o!==void 0&&i.push(`sortOrder=${o}`)),this.programName!==void 0||this.programNameEn!==void 0){let l=nt({de:this.programName,en:this.programNameEn},"offer set",{de:"--program-name",en:"--program-name-en"});await n.mutation(x.programAdmin.updateProgram,{client:t,offerKey:r.offerKey,name:l}),i.push(`programName=${Ce(l)}`)}if(this.unit){let l=await pt(n,t,r.offerKey);await AS(n,t,r.offerKey,SS(l,this.unit)),i.push(`unit=${this.unit}`)}return this.print({slug:this.offerSlug,changes:i},l=>l.changes.map(d=>({change:d}))),0}},Pc=class extends tn{static{s(this,"OfferArchiveCommand")}static paths=[["offer","archive"]];static usage=R.Usage({category:"Offer",description:"Archive (soft-delete) an offer \u2014 `offer restore` brings it back, never orphans data"});async execute(){let n=await this.caller(),t=this.requireTenant(n),r=await Vn(n,t,this.offerSlug);return await n.mutation(x.programAdmin.setManifestArchived,{client:t,offerKey:r.offerKey,archived:!0}),this.print({archived:this.offerSlug},i=>[{key:"archived (soft-deleted)",value:i.archived}]),0}},Nc=class extends tn{static{s(this,"OfferRestoreCommand")}static paths=[["offer","restore"]];static usage=R.Usage({category:"Offer",description:"Restore an archived offer"});async execute(){let n=await this.caller(),t=this.requireTenant(n),r=await Vn(n,t,this.offerSlug);return await n.mutation(x.programAdmin.setManifestArchived,{client:t,offerKey:r.offerKey,archived:!1}),this.print({restored:this.offerSlug},i=>[{key:"restored",value:i.restored}]),0}},Cc=class extends tn{static{s(this,"OfferDeleteCommand")}static paths=[["offer","delete"],["offer","hard-delete"]];static usage=R.Usage({category:"Offer",description:"HARD-delete an offer (manifest + versions + workflow + smartform + program + stages + runs) \u2014 irreversible, plan unless --confirm; refused while any application exists. To take an offer down reversibly use `offer archive`.",examples:[["Plan","$0 --env staging --tenant <slug> offer delete --offer <offer>"],["Delete","$0 --env staging --tenant <slug> offer delete --offer <offer> --confirm"]]});confirm=f.Boolean("--confirm",!1,{description:"Delete for good (without it, only the plan is printed)."});retiredYes=f.Boolean("--yes",!1,{hidden:!0});async execute(){let n=await this.caller(),t=this.requireTenant(n),r=await Vn(n,t,this.offerSlug);if(!this.confirm){let o=await pt(n,t,r.offerKey),a={offer:r.offerKey,title:r.label,levels:o.stages.length,runs:o.runs.length,deleted:!1};return this.print(a,l=>[{key:"would HARD-delete offer",value:`${l.offer} (${Ce(l.title)}) \u2014 irreversible`},{key:"with",value:`${l.levels} level(s), ${l.runs} run(s), its versions, workflow and form`},{key:"refused when",value:"any application exists"},{key:"next",value:"re-run with --confirm \u2014 or `offer archive` to take it down reversibly"}]),0}let i=await n.mutation(x.programAdmin.hardDeleteOffer,{client:t,offerKey:r.offerKey});return this.print(i,o=>[{key:"hard-deleted offer",value:this.offerSlug},{key:"offerKey",value:o.deletedOfferKey},{key:"program",value:o.deletedProgramId??"(none)"},{key:"counts",value:JSON.stringify(o.counts)}]),0}};var XK={de:"--name",en:"--name-en"},Dc=class extends tn{static{s(this,"OfferRunAddCommand")}static paths=[["offer","run","add"]];static usage=R.Usage({category:"Offer",description:"Add a run (Schuljahr) to an offer"});name=f.String("--name",{required:!0,description:"Run name in German (e.g. Schuljahr 2026/27)"});nameEn=f.String("--name-en",{required:!0,description:"Run name in English (e.g. School year 2026/27)"});key=f.String("--key",{description:"Stable run key, as in bundle.yaml program.runs[].key (lowercase slug, e.g. 2026-27). Without it the key is derived from the German --name \u2014 and keeps that value after a rename"});start=f.String("--start",{description:"Start date (ISO, e.g. 2026-08-01)"});end=f.String("--end",{description:"End date (ISO)"});capacity=f.String("--capacity",{description:"Default seat capacity per level"});closed=f.Boolean("--closed",!1,{description:"Create closed (default: open)"});async execute(){let n=await this.caller(),t=this.requireTenant(n),r=await Vn(n,t,this.offerSlug),i=xs("capacity",this.capacity),o=nt({de:this.name,en:this.nameEn},"offer run add",XK);return await n.mutation(x.programAdmin.addProgramRun,{client:t,offerKey:r.offerKey,name:o,...this.key!==void 0?{key:this.key}:{},isOpen:!this.closed,...this.start?{startDate:this.start}:{},...this.end?{endDate:this.end}:{},...i!==void 0?{defaultCapacity:i}:{}}),this.print({added:o},a=>[{key:"run added",value:Ce(a.added)}]),0}},Fc=class extends tn{static{s(this,"OfferRunSetCommand")}static paths=[["offer","run","set"]];static usage=R.Usage({category:"Offer",description:"Update a run: rename / dates"});run=f.String("--run",{required:!0,description:"Key of the run to update (bundle.yaml program.runs[].key)"});name=f.String("--name",{description:"New run name in German"});nameEn=f.String("--name-en",{description:"New run name in English"});start=f.String("--start",{description:"Start date (ISO)"});end=f.String("--end",{description:"End date (ISO)"});async execute(){let n=await this.caller(),t=this.requireTenant(n),r=await Vn(n,t,this.offerSlug),i=await pt(n,t,r.offerKey),o=il(i,this.run),a=i.runs.find(d=>d.runId===o),l=ur(a.name,{de:this.name,en:this.nameEn},"offer run set",XK);return await n.mutation(x.programAdmin.updateProgramRun,{client:t,offerKey:r.offerKey,runId:o,...l!==void 0?{name:l}:{},...this.start?{startDate:this.start}:{},...this.end?{endDate:this.end}:{}}),this.print({updated:this.run},d=>[{key:"run updated",value:d.updated}]),0}},Lc=class extends tn{static{s(this,"OfferRunArchiveCommand")}static paths=[["offer","run","archive"]];static usage=R.Usage({category:"Offer",description:"Soft-delete (archive) a run \u2014 retired from the portal, restorable"});run=f.String("--run",{required:!0,description:"Run key (bundle.yaml program.runs[].key)"});async execute(){let n=await this.caller(),t=this.requireTenant(n),r=await Vn(n,t,this.offerSlug),i=await pt(n,t,r.offerKey);return await n.mutation(x.programAdmin.updateProgramRun,{client:t,offerKey:r.offerKey,runId:il(i,this.run),status:"archived"}),this.print({archived:this.run},o=>[{key:"run archived",value:o.archived}]),0}},Mc=class extends tn{static{s(this,"OfferRunRestoreCommand")}static paths=[["offer","run","restore"]];static usage=R.Usage({category:"Offer",description:"Restore an archived run"});run=f.String("--run",{required:!0,description:"Run key (bundle.yaml program.runs[].key)"});async execute(){let n=await this.caller(),t=this.requireTenant(n),r=await Vn(n,t,this.offerSlug),i=await pt(n,t,r.offerKey);return await n.mutation(x.programAdmin.updateProgramRun,{client:t,offerKey:r.offerKey,runId:il(i,this.run),status:"active"}),this.print({restored:this.run},o=>[{key:"run restored",value:o.restored}]),0}};var ej={de:"--name",en:"--name-en"},qc=class extends tn{static{s(this,"OfferLevelAddCommand")}static paths=[["offer","level","add"]];static usage=R.Usage({category:"Offer",description:"Add a level (Klassenstufe) to an offer"});name=f.String("--name",{required:!0,description:"Level name in German"});nameEn=f.String("--name-en",{required:!0,description:"Level name in English"});grade=f.String("--grade",{description:"Grade level (integer)"});key=f.String("--key",{description:"Stable level key, as in bundle.yaml program.stages[].key (lowercase slug). Without it the key is derived from the German --name \u2014 and keeps that value after a rename"});async execute(){let n=await this.caller(),t=this.requireTenant(n),r=await Vn(n,t,this.offerSlug),i=xs("grade",this.grade),o=nt({de:this.name,en:this.nameEn},"offer level add",ej);return await n.mutation(x.programAdmin.addProgramStage,{client:t,offerKey:r.offerKey,name:o,...i!==void 0?{gradeLevel:i}:{},...this.key!==void 0?{key:this.key}:{}}),this.print({added:o},a=>[{key:"level added",value:Ce(a.added)}]),0}},Kc=class extends tn{static{s(this,"OfferLevelSetCommand")}static paths=[["offer","level","set"],["offer","level","rename"]];static usage=R.Usage({category:"Offer",description:"Change a level's name and/or grade"});level=f.String("--level",{required:!0,description:"Key of the level to update (bundle.yaml program.stages[].key)"});name=f.String("--name",{description:"New level name in German"});nameEn=f.String("--name-en",{description:"New level name in English"});grade=f.String("--grade",{description:"New grade level (integer)"});async execute(){let n=await this.caller(),t=this.requireTenant(n);if(this.name===void 0&&this.nameEn===void 0&&this.grade===void 0)throw new Error("offer level set: pass --name/--name-en and/or --grade");let r=await Vn(n,t,this.offerSlug),i=await pt(n,t,r.offerKey),o=xs("grade",this.grade),a=ol(i,this.level),l=i.stages.find(c=>c.stageId===a),d=ur(l.name,{de:this.name,en:this.nameEn},"offer level set",ej);return await n.mutation(x.programAdmin.updateProgramStage,{client:t,offerKey:r.offerKey,stageId:a,...d!==void 0?{name:d}:{},...o!==void 0?{gradeLevel:o}:{}}),this.print({updated:this.level},c=>[{key:"level updated",value:c.updated}]),0}},jc=class extends tn{static{s(this,"OfferLevelArchiveCommand")}static paths=[["offer","level","archive"],["offer","level","remove"]];static usage=R.Usage({category:"Offer",description:"Soft-delete (archive) a level \u2014 retired from the portal, restorable. Refused while an active application sits on the level"});level=f.String("--level",{required:!0,description:"Level key (bundle.yaml program.stages[].key)"});async execute(){let n=await this.caller(),t=this.requireTenant(n),r=await Vn(n,t,this.offerSlug),i=await pt(n,t,r.offerKey),{warnings:o}=await n.mutation(x.programAdmin.updateProgramStage,{client:t,offerKey:r.offerKey,stageId:ol(i,this.level),archived:!0});return this.print({removed:this.level,warnings:o},a=>[{key:"level removed (soft)",value:a.removed},...a.warnings.map(l=>({key:"warning",value:l}))]),0}},Vc=class extends tn{static{s(this,"OfferLevelRestoreCommand")}static paths=[["offer","level","restore"]];static usage=R.Usage({category:"Offer",description:"Restore an archived level"});level=f.String("--level",{required:!0,description:"Level key (bundle.yaml program.stages[].key)"});async execute(){let n=await this.caller(),t=this.requireTenant(n),r=await Vn(n,t,this.offerSlug),i=await pt(n,t,r.offerKey);return await n.mutation(x.programAdmin.updateProgramStage,{client:t,offerKey:r.offerKey,stageId:ol(i,this.level),archived:!1}),this.print({restored:this.level},o=>[{key:"level restored",value:o.restored}]),0}},Bc=class extends tn{static{s(this,"OfferLevelMoveCommand")}static paths=[["offer","level","move"]];static usage=R.Usage({category:"Offer",description:"Reorder a level among the offer's levels (--before|--after another level)"});level=f.String("--level",{required:!0,description:"Key of the level to move"});before=f.String("--before",{description:"Place before the level with this key"});after=f.String("--after",{description:"Place after the level with this key"});async execute(){let n=await this.caller(),t=this.requireTenant(n);if(this.before===void 0==(this.after===void 0))throw new Error("offer level move: pass exactly one of --before <level> / --after <level>");let r=this.before??this.after;if(r===this.level)throw new Error("offer level move: --before/--after anchor cannot be the level itself");let i=await Vn(n,t,this.offerSlug),o=await pt(n,t,i.offerKey);if(o.programKey===null)throw new Error("offer level move: the offer has no program yet");let a=o.programKey,l=o.stages.map(p=>({stageId:p.stageId,key:Jr(a,p.key),name:p.name})),d=l.find(p=>p.key===this.level);if(!d)throw new Error(`offer level move: level "${this.level}" not found. Available keys: ${l.map(p=>p.key).join(", ")||"(none)"}`);if(!l.some(p=>p.key===r))throw new Error(`offer level move: anchor level "${r}" not found. Available keys: ${l.map(p=>p.key).join(", ")}`);let c=l.filter(p=>p.key!==this.level),u=c.findIndex(p=>p.key===r);c.splice(this.before!==void 0?u:u+1,0,d);for(let p=0;p<c.length;p++)await n.mutation(x.programAdmin.updateProgramStage,{client:t,offerKey:i.offerKey,stageId:c[p].stageId,sequence:p+1});return this.print({moved:this.level,order:c.map(p=>p.key)},p=>[{key:"level moved",value:p.moved},{key:"new order",value:p.order.join(" \u2192 ")}]),0}};var Uc=class extends tn{static{s(this,"OfferCapacitySetCommand")}static paths=[["offer","capacity","set"]];static usage=R.Usage({category:"Offer",description:"Set seat capacity and/or open-state for one run \xD7 level cell"});run=f.String("--run",{required:!0,description:"Run key (bundle.yaml program.runs[].key)"});level=f.String("--level",{required:!0,description:"Level key (bundle.yaml program.stages[].key)"});capacity=f.String("--capacity",{description:'Seat capacity (whole number) or "unlimited"'});open=f.Boolean("--open",!1,{description:"Open this cell"});close=f.Boolean("--close",!1,{description:"Close this cell"});async execute(){let n=await this.caller(),t=this.requireTenant(n);if(this.open&&this.close)throw new Error("offer capacity set: pass only one of --open / --close");let r=await Vn(n,t,this.offerSlug),i=await pt(n,t,r.offerKey),o=this.capacity==="unlimited"?"unlimited":xs("capacity",this.capacity),a=this.open?!0:this.close?!1:void 0;return await n.mutation(x.programAdmin.setRunStageCapacity,{client:t,offerKey:r.offerKey,runId:il(i,this.run),stageId:ol(i,this.level),...o!==void 0?{capacity:o}:{},...a!==void 0?{isOpen:a}:{}}),this.print({run:this.run,level:this.level},l=>[{key:"capacity set",value:`${l.run} \xD7 ${l.level}`}]),0}};function RS(e,n,t){let r=e.indexOf("=");if(r<=0||r===e.length-1)throw new Error(`offer upgrade: ${n} takes ${t} (got "${e}")`);return[e.slice(0,r),e.slice(r+1)]}s(RS,"splitPair");function Q9(e,n){let t={waitlistOrder:e};if(!Rw(t))throw new Error(`offer upgrade: ${n} takes <node>=<arrival|manual> (got "${e}")`);return t}s(Q9,"parsePolicy");function eg(e,n){if(e===void 0)return{};if(e===null||typeof e!="object"||Array.isArray(e))throw new Error(`offer upgrade: ${n} must be an object`);return e}s(eg,"record");function nj(e){let n={},t={},r={},i=s((a,l,d,c)=>{if(Object.hasOwn(a,l)&&JSON.stringify(a[l])!==JSON.stringify(d))throw new Error(`offer upgrade: ${c} "${l}" is answered twice with different values`);a[l]=d},"put"),o=eg(e.answersFile,"the answers file");for(let a of Object.keys(o))if(a!=="semantics"&&a!=="waitlistPolicy"&&a!=="payee")throw new Error(`offer upgrade: the answers file has an unknown key "${a}" (semantics | waitlistPolicy | payee)`);for(let[a,l]of Object.entries(eg(o.semantics,"answers.semantics"))){if(typeof l!="string")throw new Error(`offer upgrade: answers.semantics["${a}"] must be a string`);i(n,a,l,"the outcome")}for(let[a,l]of Object.entries(eg(o.waitlistPolicy,"answers.waitlistPolicy"))){if(!Rw(l))throw new Error(`offer upgrade: answers.waitlistPolicy["${a}"] must be { waitlistOrder: arrival|manual }`);i(t,a,l,"the waitlist node")}for(let[a,l]of Object.entries(eg(o.payee,"answers.payee"))){if(typeof l!="string"||l==="")throw new Error(`offer upgrade: answers.payee["${a}"] must be a Tr\xE4ger key`);i(r,a,l,"the payment node")}for(let a of e.semantic??[]){let[l,d]=RS(a,"--semantic","<node>.<outcome>=<meaning>");if(!l.includes("."))throw new Error(`offer upgrade: --semantic takes <node>.<outcome>=<meaning> (got "${a}")`);i(n,l,d,"the outcome")}for(let a of e.waitlistPolicy??[]){let[l,d]=RS(a,"--waitlist-policy","<node>=<arrival|manual>");i(t,l,Q9(d,"--waitlist-policy"),"the waitlist node")}for(let a of e.payee??[]){let[l,d]=RS(a,"--payee","<node>=<Tr\xE4ger key>");i(r,l,d,"the payment node")}return{semantics:n,waitlistPolicy:t,payee:r}}s(nj,"parseUpgradeAnswers");function tj(e){let n=e.candidates?.join("|")??"";switch(e.answer){case"semantic":return`--semantic ${e.answerKey}=<${n}>`;case"waitlistPolicy":return`--waitlist-policy ${e.answerKey}=<arrival|manual>`;case"payee":return`--payee ${e.answerKey}=<Tr\xE4ger key>`;case"edit":return"edit the file by hand"}}s(tj,"answerHint");function rj(e){let n=e.defaulted;if(n===void 0)return"-";switch(n.answer){case"semantic":return`--semantic ${n.answerKey}=${n.value}`;case"waitlistPolicy":return`--waitlist-policy ${n.answerKey}=${n.value}`;case"undeclaredBinding":return`${n.answerKey} deleted (publish refuses an undeclared input)`}}s(rj,"defaultedHint");function ij(e,n){Bn(n,{recursive:!0});for(let t of Kr(e,{withFileTypes:!0})){let r=Y.join(e,t.name),i=Y.join(n,t.name);if(t.isDirectory())ij(r,i);else if(t.isFile())We(i,he(r));else throw new Error(`offer upgrade: ${r} is neither a file nor a directory \u2014 refusing to copy it`)}}s(ij,"copyTree");function oj(e){let n=sF(e.dir),{bundle:t,changes:r,refusals:i}=tF(n,e.answers);if(!e.write||i.length>0)return{dir:n.dir,changes:r,refusals:i,written:null};let o=n.dir;if(e.out!==void 0){if(o=Y.resolve(e.out),Ae(o)&&Kr(o).length>0)throw new Error(`offer upgrade: --out ${o} is not empty \u2014 choose a fresh directory`);ij(n.dir,o)}return Nt({...t,dir:o}),{dir:n.dir,changes:r,refusals:i,written:o}}s(oj,"runUpgrade");var Gc=class extends xe{static{s(this,"OfferUpgradeCommand")}static paths=[["offer","upgrade"]];static usage=R.Usage({category:"Offer",description:"Rewrite a bundle exported in an older format into the current one (offline; dry run unless --write)",details:`
|
|
11529
11529
|
Prints every change. Where the old format left a value to a code
|
|
11530
11530
|
default, the upgrade writes the value the process ran with and prints it
|
|
11531
11531
|
as DEFAULT with the flag that would set it (an outcome without a known
|
|
@@ -11701,6 +11701,6 @@ ${t.length} unusable ${o}:
|
|
|
11701
11701
|
`),r.length>0&&this.context.stdout.write(` ${r.length} linkable \u2014 plexus-cli platform users relink-auth <email>
|
|
11702
11702
|
`),i.length>0&&this.context.stdout.write(` ${i.length} without any login account \u2014 plexus-cli platform users provision --tenant <slug> --email <email> --name <name>
|
|
11703
11703
|
`)}else this.context.stdout.write(`No unusable identities.
|
|
11704
|
-
`);return t.length>0?1:0}},yR=class extends kr{static{s(this,"UsersRelinkAuthCommand")}static paths=[["platform","users","relink-auth"],["users","relink-auth"]];static usage=R.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 t=await(await this.caller()).mutation(x.platformAdmin.relinkAuthAccount,{email:this.email}),r=t.changed?`Relinked ${this.email} to live auth account ${t.authId}.`:`${this.email} already linked to the live auth account (no change).`;return this.report(t,r),0}};function PU(e,n){if(e===n)throw new Error("Pass exactly one of --on or --off.");return e}s(PU,"requireOnOff");var NU=[eR,nR,tR,rR,iR,oR,sR,aR,lR,dR,qu,cR,uR,fR,pR,mR,hR,gR,yR];function CU(e){return e.de??e.en??Object.values(e)[0]??""}s(CU,"titleDe");function kee(e){return{id:e._id,kind:e.kind,status:e.status,title:CU(e.title).slice(0,50),assignee:e.assigneeUserId??"",group:e.queueGroupId??"",outcome:e.outcome??""}}s(kee,"row");var bee=["id","kind","status","title","assignee","group","outcome"],bR=class extends P{static{s(this,"WorkItemsListCommand")}static paths=[["work-items","list"]];static usage=R.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 n=await this.caller(),t=this.requireTenant(n),r=await n.query(x.workItems.list,{client:t,...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(kee),bee),0}},vR=class extends P{static{s(this,"WorkItemsShowCommand")}static paths=[["work-items","show"]];static usage=R.Usage({category:"Work-Items",description:"Show one work-item by id."});workItemId=f.String({required:!0,name:"workItemId"});async execute(){let n=await this.caller(),t=this.requireTenant(n),r=await n.query(x.workItems.get,{client:t,workItemId:this.workItemId});if(r===null)throw new Error(`work-item ${this.workItemId} not found in tenant ${t}.`);return this.print(r,i=>[{field:"id",value:i._id},{field:"kind",value:i.kind},{field:"status",value:i.status},{field:"title",value:CU(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}},xR=class extends P{static{s(this,"WorkItemsCreateCommand")}static paths=[["work-items","create"]];static usage=R.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 n=await this.caller(),t=this.requireTenant(n),r=await n.mutation(x.workItems.createManual,{client:t,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}},SR=class extends P{static{s(this,"WorkItemsCompleteCommand")}static paths=[["work-items","complete"]];static usage=R.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 n=await this.caller(),t=this.requireTenant(n),r=await n.mutation(x.workItems.complete,{client:t,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}},AR=class extends P{static{s(this,"WorkItemsAssignCommand")}static paths=[["work-items","assign"]];static usage=R.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 n=await this.caller(),t=this.requireTenant(n),r=await n.mutation(x.workItems.assign,{client:t,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}},DU=[bR,vR,xR,SR,AR];var Ku=[...uO,...jF,...JF,...ZL,...QL,...A0,..._0,...O0,...OU,...NU,...IU,...mB,...bB,...EF,...b0,...yU,...dO,...VO,...cF,...C0,...N0,...L0,...M0,...w0,...i0,...DU,...sj,...Hj,...fB,...Jj,...eU,...lU,...vB,...OB,...NB,...LB,...qB,...uU,...xU,...PO];for(let e of Ku){let n=e.paths?.[0];n===void 0||!Object.hasOwn(e,"usage")||e.usage===void 0||(e.usage={...e.usage,category:E$(e.usage.category,n.join(" "))})}var FU="0.1.268";function LU(){return Ku.flatMap(e=>(e.paths??[]).map(n=>{let t=n.join(" "),r=v$[Io(t)];return{path:t,effect:Oo(t),host:r===void 0?"shared":"terminal",...r===void 0?{}:{reason:r}}})).sort((e,n)=>e.path.localeCompare(n.path))}s(LU,"plexusCommandCatalog");import Ts from"node:path";function vee(e){let n=cn()?.workspaceRoot??process.cwd(),t=Ts.resolve(n,e),r=Ts.relative(n,t);if(Ts.isAbsolute(e)||r===".."||r.startsWith(`..${Ts.sep}`))throw new Error("plexus: use a relative path inside the current workspace.");return{absolute:t,relative:r}}s(vee,"workspacePath");function xee(e){let{absolute:n,relative:t}=vee(e.path??".");if(e.operation==="list"){if(!Ae(n))return{files:[]};let r=[],i=s(o=>{for(let a of Kr(o,{withFileTypes:!0})){if(a.isSymbolicLink())throw new Error("plexus: workspace symlinks are not supported.");let l=Ts.join(o,a.name);if(a.isDirectory()?i(l):r.push(Ts.relative(n,l)),r.length>200)throw new Error("plexus: the workspace contains too many files. List a subdirectory.")}},"visit");return i(n),{files:r.sort()}}if(!t)throw new Error("plexus: name a workspace file.");if(["read","search","edit"].includes(e.operation)){let r=he(n);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:t,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:t,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 We(n,a,"utf8"),{path:t,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 Bn(Ts.dirname(n),{recursive:!0}),We(n,e.content,"utf8"),{path:t,sizeBytes:Buffer.byteLength(e.content)}}if(e.operation==="remove")return Os(n),{path:t,removed:!0};throw new Error("plexus: unknown workspace operation.")}s(xee,"plexusWorkspace");function MU(e){return s(async function(t,r){if(!r||typeof r!="object"||Array.isArray(r))throw new Error("plexus: tool input must be an object.");let i=r,o=Bl[t];if(!o||!Object.hasOwn(Bl,t))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(t==="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(t==="plexus_skill"){if(typeof i.path!="string"||i.path.length>240||!Object.hasOwn(ew,i.path))throw new Error("plexus: unknown skill reference. Start with SKILL.md.");return{path:i.path,content:ew[i.path],skillHash:Qf}}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 xee(i)},"executePlexusAgentTool")}s(MU,"createPlexusAgentToolExecutor");var Lg=MU({inspectCommand:KU,executeCommand:jU});function Mg(){let e=new Cs({binaryLabel:"Plexus CLI",binaryName:"plexus-cli",binaryVersion:FU});e.register(Al.HelpCommand),e.register(Al.VersionCommand);for(let t of Ku)e.register(t);async function n(t,r){let i;try{i=e.process(t,r)}catch(o){return(r.stderr??process.stderr).write(e.error(o,{colored:!1})),2}return Eee(i,r.stderr??process.stderr),e.run(i,r)}return s(n,"run"),{process(t,r){return e.process(t,r)},run:n,async runExit(t,r){process.exitCode=await n(t,r)}}}s(Mg,"createPlexusCli");function Eee(e,n){let t=e.path.join(" "),r=e.constructor.paths?.[0]?.join(" ");r!==void 0&&t!==r&&$l[t]===r&&ln(n,t,r),t in $l&&Oo(t)==="confirm"&&!Il(e)&&n.write(`plexus-cli: \`${$l[t]}\` only prints its plan without --confirm \u2014 nothing was changed.
|
|
11704
|
+
`);return t.length>0?1:0}},yR=class extends kr{static{s(this,"UsersRelinkAuthCommand")}static paths=[["platform","users","relink-auth"],["users","relink-auth"]];static usage=R.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 t=await(await this.caller()).mutation(x.platformAdmin.relinkAuthAccount,{email:this.email}),r=t.changed?`Relinked ${this.email} to live auth account ${t.authId}.`:`${this.email} already linked to the live auth account (no change).`;return this.report(t,r),0}};function PU(e,n){if(e===n)throw new Error("Pass exactly one of --on or --off.");return e}s(PU,"requireOnOff");var NU=[eR,nR,tR,rR,iR,oR,sR,aR,lR,dR,qu,cR,uR,fR,pR,mR,hR,gR,yR];function CU(e){return e.de??e.en??Object.values(e)[0]??""}s(CU,"titleDe");function kee(e){return{id:e._id,kind:e.kind,status:e.status,title:CU(e.title).slice(0,50),assignee:e.assigneeUserId??"",group:e.queueGroupId??"",outcome:e.outcome??""}}s(kee,"row");var bee=["id","kind","status","title","assignee","group","outcome"],bR=class extends P{static{s(this,"WorkItemsListCommand")}static paths=[["work-items","list"]];static usage=R.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 n=await this.caller(),t=this.requireTenant(n),r=await n.query(x.workItems.list,{client:t,...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(kee),bee),0}},vR=class extends P{static{s(this,"WorkItemsShowCommand")}static paths=[["work-items","show"]];static usage=R.Usage({category:"Work-Items",description:"Show one work-item by id."});workItemId=f.String({required:!0,name:"workItemId"});async execute(){let n=await this.caller(),t=this.requireTenant(n),r=await n.query(x.workItems.get,{client:t,workItemId:this.workItemId});if(r===null)throw new Error(`work-item ${this.workItemId} not found in tenant ${t}.`);return this.print(r,i=>[{field:"id",value:i._id},{field:"kind",value:i.kind},{field:"status",value:i.status},{field:"title",value:CU(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}},xR=class extends P{static{s(this,"WorkItemsCreateCommand")}static paths=[["work-items","create"]];static usage=R.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 n=await this.caller(),t=this.requireTenant(n),r=await n.mutation(x.workItems.createManual,{client:t,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}},SR=class extends P{static{s(this,"WorkItemsCompleteCommand")}static paths=[["work-items","complete"]];static usage=R.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 n=await this.caller(),t=this.requireTenant(n),r=await n.mutation(x.workItems.complete,{client:t,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}},AR=class extends P{static{s(this,"WorkItemsAssignCommand")}static paths=[["work-items","assign"]];static usage=R.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 n=await this.caller(),t=this.requireTenant(n),r=await n.mutation(x.workItems.assign,{client:t,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}},DU=[bR,vR,xR,SR,AR];var Ku=[...uO,...jF,...JF,...ZL,...QL,...A0,..._0,...O0,...OU,...NU,...IU,...mB,...bB,...EF,...b0,...yU,...dO,...VO,...cF,...C0,...N0,...L0,...M0,...w0,...i0,...DU,...sj,...Hj,...fB,...Jj,...eU,...lU,...vB,...OB,...NB,...LB,...qB,...uU,...xU,...PO];for(let e of Ku){let n=e.paths?.[0];n===void 0||!Object.hasOwn(e,"usage")||e.usage===void 0||(e.usage={...e.usage,category:E$(e.usage.category,n.join(" "))})}var FU="0.1.269";function LU(){return Ku.flatMap(e=>(e.paths??[]).map(n=>{let t=n.join(" "),r=v$[Io(t)];return{path:t,effect:Oo(t),host:r===void 0?"shared":"terminal",...r===void 0?{}:{reason:r}}})).sort((e,n)=>e.path.localeCompare(n.path))}s(LU,"plexusCommandCatalog");import Ts from"node:path";function vee(e){let n=cn()?.workspaceRoot??process.cwd(),t=Ts.resolve(n,e),r=Ts.relative(n,t);if(Ts.isAbsolute(e)||r===".."||r.startsWith(`..${Ts.sep}`))throw new Error("plexus: use a relative path inside the current workspace.");return{absolute:t,relative:r}}s(vee,"workspacePath");function xee(e){let{absolute:n,relative:t}=vee(e.path??".");if(e.operation==="list"){if(!Ae(n))return{files:[]};let r=[],i=s(o=>{for(let a of Kr(o,{withFileTypes:!0})){if(a.isSymbolicLink())throw new Error("plexus: workspace symlinks are not supported.");let l=Ts.join(o,a.name);if(a.isDirectory()?i(l):r.push(Ts.relative(n,l)),r.length>200)throw new Error("plexus: the workspace contains too many files. List a subdirectory.")}},"visit");return i(n),{files:r.sort()}}if(!t)throw new Error("plexus: name a workspace file.");if(["read","search","edit"].includes(e.operation)){let r=he(n);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:t,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:t,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 We(n,a,"utf8"),{path:t,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 Bn(Ts.dirname(n),{recursive:!0}),We(n,e.content,"utf8"),{path:t,sizeBytes:Buffer.byteLength(e.content)}}if(e.operation==="remove")return Os(n),{path:t,removed:!0};throw new Error("plexus: unknown workspace operation.")}s(xee,"plexusWorkspace");function MU(e){return s(async function(t,r){if(!r||typeof r!="object"||Array.isArray(r))throw new Error("plexus: tool input must be an object.");let i=r,o=Bl[t];if(!o||!Object.hasOwn(Bl,t))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(t==="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(t==="plexus_skill"){if(typeof i.path!="string"||i.path.length>240||!Object.hasOwn(ew,i.path))throw new Error("plexus: unknown skill reference. Start with SKILL.md.");return{path:i.path,content:ew[i.path],skillHash:Qf}}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 xee(i)},"executePlexusAgentTool")}s(MU,"createPlexusAgentToolExecutor");var Lg=MU({inspectCommand:KU,executeCommand:jU});function Mg(){let e=new Cs({binaryLabel:"Plexus CLI",binaryName:"plexus-cli",binaryVersion:FU});e.register(Al.HelpCommand),e.register(Al.VersionCommand);for(let t of Ku)e.register(t);async function n(t,r){let i;try{i=e.process(t,r)}catch(o){return(r.stderr??process.stderr).write(e.error(o,{colored:!1})),2}return Eee(i,r.stderr??process.stderr),e.run(i,r)}return s(n,"run"),{process(t,r){return e.process(t,r)},run:n,async runExit(t,r){process.exitCode=await n(t,r)}}}s(Mg,"createPlexusCli");function Eee(e,n){let t=e.path.join(" "),r=e.constructor.paths?.[0]?.join(" ");r!==void 0&&t!==r&&$l[t]===r&&ln(n,t,r),t in $l&&Oo(t)==="confirm"&&!Il(e)&&n.write(`plexus-cli: \`${$l[t]}\` only prints its plan without --confirm \u2014 nothing was changed.
|
|
11705
11705
|
`)}s(Eee,"noteRetiredPath");function KU(e){let n=Mg().process(hl(e),{executePlexusAgentTool:Lg}),t=n.path.join(" ");if(t.startsWith("agent "))throw new Error("plexus: nested agent transports are not allowed.");let r=LU().find(l=>l.path===t);if(!r){if(t===""||t==="--help"||t==="--version")return{path:t,writes:!1,host:"shared"};throw new Error(`plexus: command ${t} has no host classification.`)}let i=n,o=r.effect==="callKind"?uh(Ha(Ja),i.fn??"",i.kind):void 0,a=vf(t,{confirm:Il(n),callKind:o});return{...r,writes:a}}s(KU,"inspectPlexusCommand");async function jU(e,n){if(n)return TR(n,()=>jU(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 t="",r="",i=Mg();if(cn()){let l=KU(e.argv);if(l.host==="terminal")throw new Error(`plexus: this command requires a local machine. ${l.reason??""}`)}return{exitCode:await i.run(hl(e.argv),{executePlexusAgentTool:Lg,stdin:Aee.from(e.stdin===void 0?[]:[e.stdin]),stdout:new qU({write(l,d,c){t+=String(l),c()}}),stderr:new qU({write(l,d,c){r+=String(l),c()}})}),stdout:t,stderr:r}}s(jU,"executePlexusCommand");_R({source:Tee.join(import.meta.dirname,"skill")});Mg().runExit(hl(process.argv.slice(2)),{executePlexusAgentTool:Lg});
|
|
11706
11706
|
//# sourceMappingURL=cli.mjs.map
|