@smartkomm/plexus-cli 0.1.361 → 0.1.362
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md
CHANGED
|
@@ -147,7 +147,7 @@ says to run `pnpm dev` there; `PLEXUS_LOCAL_INSTALL_ROOT=1` is the explicit opt-
|
|
|
147
147
|
the install's own checkout instead. Run
|
|
148
148
|
`plexus-cli --env local config show` to see the resolved `deployment` + `authMode`
|
|
149
149
|
(`local-bootstrap`). Full workflow + gotchas:
|
|
150
|
-
`docs/engineering/plexus-cli.md` §"Local dev across rdu worktrees".
|
|
150
|
+
`docs/engineering/cli/plexus-cli.md` §"Local dev across rdu worktrees".
|
|
151
151
|
|
|
152
152
|
### Verify it works
|
|
153
153
|
|
|
@@ -294,7 +294,7 @@ polls in a row end the command with the last error. A completed run is held to
|
|
|
294
294
|
its shape's budget (`app/shared/seedParts.ts`) and every drive key to its own;
|
|
295
295
|
each line over budget goes to stderr with the load average, as a warning. Which
|
|
296
296
|
shape a task needs and what each costs:
|
|
297
|
-
[`docs/engineering/seed-index.md`](../../../docs/engineering/seed-index.md). Recipe:
|
|
297
|
+
[`docs/engineering/development/seed-index.md`](../../../docs/engineering/development/seed-index.md). Recipe:
|
|
298
298
|
[Initialize or rebuild local demo data](playbooks/worker-ops/rebuild-local-data.md).
|
|
299
299
|
|
|
300
300
|
Every command supports `--json` (raw output; default is a table). Network commands
|
|
@@ -393,14 +393,14 @@ common CLI task, see [playbooks/](./playbooks/README.md).
|
|
|
393
393
|
`finanzen_vertraege.contracts.manage`. `start` goes out through the tenant's ACTIVE
|
|
394
394
|
connection — there is no provider to pick.
|
|
395
395
|
|
|
396
|
-
`plexus-cli signing connection {show,test}`, `plexus-cli platform signing connection {set,activate,delete,reseal}` (`delete` plans unless `--confirm`) and `plexus-cli platform signing status` (key slots: what is sealed under which key; `reseal` after a key rotation, both platform-wide under `_platform.config.manage` — docs/signing/operations.md → "Rotating the key") — the school's own
|
|
396
|
+
`plexus-cli signing connection {show,test}`, `plexus-cli platform signing connection {set,activate,delete,reseal}` (`delete` plans unless `--confirm`) and `plexus-cli platform signing status` (key slots: what is sealed under which key; `reseal` after a key rotation, both platform-wide under `_platform.config.manage` — docs/integrations/signing/operations.md → "Rotating the key") — the school's own
|
|
397
397
|
account at a provider (`signingConnections.*`). `show` and `test` need
|
|
398
398
|
`finanzen_vertraege.contracts.manage`; `set`, `activate` and `remove` the platform right
|
|
399
399
|
`_platform.config.manage`. A secret (DocuSign's Connect HMAC key, inSign's API password)
|
|
400
400
|
enters only through `--secret-stdin` or `--secret-file` and is never printed — `show`
|
|
401
401
|
lists its name and fingerprint. Recipes: `playbooks/signing/README.md`,
|
|
402
402
|
`playbooks/signing/connect-a-school.md`; setup + runbook:
|
|
403
|
-
`docs/signing/{README,docusign-setup,insign,operations}.md`.
|
|
403
|
+
`docs/integrations/signing/{README,docusign-setup,insign,operations}.md`.
|
|
404
404
|
|
|
405
405
|
### The words a school sends (`notifications letters` / `chrome`)
|
|
406
406
|
|
|
@@ -442,7 +442,7 @@ Semantics worth knowing before using them:
|
|
|
442
442
|
`config export|set|apply` promote them across environments.
|
|
443
443
|
|
|
444
444
|
Recipe: [playbooks/notifications/reword-a-letter.md](./playbooks/notifications/reword-a-letter.md).
|
|
445
|
-
Model + invariants: `docs/
|
|
445
|
+
Model + invariants: `docs/architecture/platform/messaging/notifications.md`.
|
|
446
446
|
|
|
447
447
|
### Addresses (what a node reads, and who produces it)
|
|
448
448
|
|
|
@@ -483,7 +483,7 @@ names the node (`addressesNaming`) and lists config path + address of each.
|
|
|
483
483
|
A bundle exported before addresses is refused (`[graph/retiredField]`: `wires`, a
|
|
484
484
|
binding with `path`, `adoptForm: true`) — export it again. Recipe:
|
|
485
485
|
[playbooks/offer/addresses.md](./playbooks/offer/addresses.md); model (visibility, `$env`
|
|
486
|
-
vocabulary, the store behind `$task`): `docs/
|
|
486
|
+
vocabulary, the store behind `$task`): `docs/architecture/workflow/workflow-engine.md`.
|
|
487
487
|
|
|
488
488
|
### Countersignature node („Unterschrift (intern)")
|
|
489
489
|
|
|
@@ -693,7 +693,7 @@ stderr; `set-notification --event termin:rescheduled … --disabled` switches on
|
|
|
693
693
|
|
|
694
694
|
How an argument binds (by itself when exactly one source fits, else a `--literal`) and why
|
|
695
695
|
offline validation cannot see the letter catalog is canonical in
|
|
696
|
-
[notifications.md](../../../docs/
|
|
696
|
+
[notifications.md](../../../docs/architecture/platform/messaging/notifications.md) § "When a process writes". For
|
|
697
697
|
the CLI it means: both commands run the real publish-gate validators before writing, so an
|
|
698
698
|
event the node type does not declare fails here, while an unknown `--template` id and an
|
|
699
699
|
unresolvable argument are caught only at `offer apply --publish`. Run it.
|
|
@@ -924,7 +924,7 @@ plexus-cli offer status --tenant test --offer gymnasium-havelland # applyable?
|
|
|
924
924
|
**Generator references are stamped from the environment.** How a contract node
|
|
925
925
|
names its generator (`contractGenerator` input, `generatorStamp`, the retired
|
|
926
926
|
`resolver` / `template.key` properties refused `[graph/retiredField]`) is canonical in
|
|
927
|
-
[contract-generators.md](../../../docs/
|
|
927
|
+
[contract-generators.md](../../../docs/architecture/workflow/contract-generators.md) § Packages;
|
|
928
928
|
this section covers only what the CLI does with it. `offer plan` and `offer apply` fetch the same stamp
|
|
929
929
|
(`workflow:getResolverPinStamps`) and write it onto the in-memory bundle
|
|
930
930
|
before validating, so a new combined pin produces `$node.<n>.contracts`
|
|
@@ -941,7 +941,7 @@ renames the same row, a new key adds a level, a removed key archives it (refused
|
|
|
941
941
|
an active application sits on it), a re-listed archived key restores it, and the array
|
|
942
942
|
order is the display order. `offer plan` lists each change as `~stage` / `+stage` /
|
|
943
943
|
`-stage`, and marks a `-stage` the apply would refuse (`REFUSED: n active
|
|
944
|
-
application(s)`). Rules: `docs/
|
|
944
|
+
application(s)`). Rules: `docs/architecture/data-model/config-as-code/README.md` → "Stage identity";
|
|
945
945
|
recipe: [Rename a program stage](./playbooks/config/rename-program-stage.md).
|
|
946
946
|
|
|
947
947
|
**Capacities.** Each `program.runs[]` entry carries its cells as
|
|
@@ -979,7 +979,7 @@ custom fields, lists, display groups, roles + role-field bindings, contract role
|
|
|
979
979
|
while it is in force, optionally per generator by its `key`), foundation, and search
|
|
980
980
|
config) against any environment. Tenant config is **declarative + DB-authoritative** — no
|
|
981
981
|
reseeds to change live config. The model/architecture lives in
|
|
982
|
-
[`docs/
|
|
982
|
+
[`docs/architecture/data-model/config-as-code/`](../../../docs/architecture/data-model/config-as-code/README.md);
|
|
983
983
|
the copy-paste task recipes live in [`playbooks/config/`](./playbooks/config). This section
|
|
984
984
|
is the **command reference**.
|
|
985
985
|
|
|
@@ -1141,7 +1141,7 @@ The parts, in apply order: `config` (the same content as `config export`), `stru
|
|
|
1141
1141
|
`contracts`, `offers`, `tools`, `portal`; a new part joins without a CLI change. `--platform`
|
|
1142
1142
|
(no tenant) exports the platform's own setup, the contract input registry; restore it before
|
|
1143
1143
|
a tenant whose `setup.json` names its keys (`platformRefs`). Contract:
|
|
1144
|
-
`docs/
|
|
1144
|
+
`docs/architecture/platform/storage/setup-export.md`. Platform operator only (`_platform.config.manage`, since each run records the export); a writing verb
|
|
1145
1145
|
(`--allow-prod` on production), because each run records the export. `--out` must be new and
|
|
1146
1146
|
outside any git working tree; the command writes into `<dir>.partial` and renames it once
|
|
1147
1147
|
every file is verified. Recipe: `playbooks/config/export-tenant-setup.md`.
|
|
@@ -1195,7 +1195,7 @@ held (the logo stays: sent mail links it). See [`playbooks/config/wipe-tenant-co
|
|
|
1195
1195
|
|
|
1196
1196
|
### Pre-production model changes
|
|
1197
1197
|
|
|
1198
|
-
Use the [reset and native seed policy](../../../docs/
|
|
1198
|
+
Use the [reset and native seed policy](../../../docs/architecture/data-model/domain/contract-model-reset.md). There is no migration command. Config apply changes values in the current schema.
|
|
1199
1199
|
|
|
1200
1200
|
### Deploy protocol (local + steady state)
|
|
1201
1201
|
- **Local dev:** `pnpm dev` on a fresh DB runs `config/bootstrap`, which idempotently applies the
|
package/dist/cli.mjs
CHANGED
|
@@ -3871,7 +3871,7 @@ Delete the tenant's connection at ONE provider, secrets included. Refused while
|
|
|
3871
3871
|
|
|
3872
3872
|
### \`platform signing connection reseal\`
|
|
3873
3873
|
|
|
3874
|
-
After a key rotation: seal every school's connection secrets that are still under SIGNING_CREDENTIALS_KEY_PREVIOUS anew under SIGNING_CREDENTIALS_KEY \u2014 same secrets, same binding to tenant, provider and target. Idempotent. Platform-wide, platform right \`_platform.config.manage\`. Runbook: docs/signing/operations.md \u2192 \u201ERotating the key\u201C.
|
|
3874
|
+
After a key rotation: seal every school's connection secrets that are still under SIGNING_CREDENTIALS_KEY_PREVIOUS anew under SIGNING_CREDENTIALS_KEY \u2014 same secrets, same binding to tenant, provider and target. Idempotent. Platform-wide, platform right \`_platform.config.manage\`. Runbook: docs/integrations/signing/operations.md \u2192 \u201ERotating the key\u201C.
|
|
3875
3875
|
|
|
3876
3876
|
- **Right:** platform operator \u2014 needs a \`_platform.*\` right; a school's token is refused
|
|
3877
3877
|
- **Effect:** write \u2014 needs \`--env\`; on production also \`--allow-prod\`
|
|
@@ -10370,7 +10370,7 @@ commands: [README.md](./README.md).
|
|
|
10370
10370
|
owner id (\`foruser\`). The inSign API user must hold the role
|
|
10371
10371
|
\`ROLE_INSIGN_CONTROLLER\` and the school the package \`connect\` or
|
|
10372
10372
|
\`enterprise\` (not \`365\`); what to ask the school and inSign for:
|
|
10373
|
-
\`docs/
|
|
10373
|
+
\`docs/wiki/source/insign-connect-api-and-sandbox.md\`.
|
|
10374
10374
|
|
|
10375
10375
|
## Steps
|
|
10376
10376
|
|
|
@@ -11503,7 +11503,7 @@ plexus-cli --env prod jobs list --status running # nothing unexpectedly in
|
|
|
11503
11503
|
## Related
|
|
11504
11504
|
- Command reference: \`plexus-cli jobs list --help\`, \`plexus-cli platform workers reap --help\`,
|
|
11505
11505
|
\`plexus-cli platform imports cleanup-orphaned --help\`.
|
|
11506
|
-
`,"references/worker-ops/set-import-default-unit.md":"# Set the default unit of an import source\n\n**When to use:** a unit that an import source uses as its default unit has to\ngo, or imported records should attach to another unit by default.\n`org unit delete` refuses the default unit of an import source\n(`[unit/importSourceDefault]`). Point the source at another unit first.\n\n## Prerequisites\n- **Auth:** a platform operator's token with `_platform.config.manage`. A\n school's own token is refused, because the import source belongs to the operator.\n- **Env:** a writing run needs `--env <local|staging|prod>` on the command line,\n and `--allow-prod` against production.\n- You need the source key (`imports status --tenant <slug>`, column `config`)\n and the new unit's config key (`org tree`, column `key`).\n\n## Steps\n\n```bash\n# Plan: shows the current default and the new one, and writes nothing\nplexus-cli --env prod --allow-prod platform imports source set-default-unit <source> --unit <unit-key>\n# Write\nplexus-cli --env prod --allow-prod platform imports source set-default-unit <source> --unit <unit-key> --confirm\n```\n\n## Verify\nRun the plan again. It reports `unchanged`, with the new unit as the default.\n\n## Idempotency / gotchas\n- The unit must be one the source already knows by key (every unit of the\n tenant at the time the source was set up). Otherwise the command refuses with\n `[import-source/unitUnknown]` and lists the keys the source knows.\n- Deleting any other unit removes it from the source's key list automatically.\n Only the default unit blocks a delete.\n- The tenant config names the default unit by key: `source.defaultUnitKey`\n (the order of `foundation.units` means nothing). `config export` writes the\n current default there, so an apply from a fresh export keeps it. **An apply\n from an export taken before this change names the old default and sets it\n back**; its plan shows an update on `source`. Export again after setting the\n default, or set `source.defaultUnitKey` in the scratch export by hand.\n- `config apply` refuses a source without `defaultUnitKey`\n (`[import/defaultUnitMissing]`) or with a key that is not in\n `foundation.units` (`[import/defaultUnitUnknown]`). There is no fallback to\n the first unit. An export taken before this change carries no key: add it before\n the apply.\n\n## Related\n- [Edit a school's organisation structure](../organization/edit-org-structure.md)\n- [Debug a stuck/failed import or worker job](./debug-worker-jobs.md)\n"};var bp="09e554f47c312920096a35a1ff7a41d40d7888ed22ac669da687252227813d52",Fw=q_;var lH=new Set(["ENOENT","ENOTDIR","EISDIR","EACCES","EPERM"]);function dH(e){return typeof e=="object"&&e!==null&&"code"in e?e.code:void 0}s(dH,"codeOf");function K_(e){return e instanceof Error?e.message:String(e)}s(K_,"messageOf");function Lw(e,t){try{return Ne(e)}catch(n){throw lH.has(dH(n))?new g(`${t}: ${e} is not readable (${K_(n)})`,{cause:n}):n}}s(Lw,"readBytesFile");function Mw(e,t){return Lw(e,t).toString("utf8")}s(Mw,"readTextFile");function ni(e,t){try{return JSON.parse(e)}catch(n){throw new g(`${t} is no JSON (${K_(n)})`,{cause:n})}}s(ni,"parseJsonText");function Ge(e,t){return ni(Mw(e,t),`${t}: ${e}`)}s(Ge,"readJsonFile");var qw=class extends Ae{static{s(this,"AgentToolsCommand")}static paths=[["agent","tools"]];static usage=E.Usage({category:"Agents",description:"Show the shared platform/CLI agent tool schemas and skill revision."});async execute(){return this.print({skillHash:bp,tools:sd}),0}},Kw=class extends Ae{static{s(this,"AgentInvokeCommand")}static paths=[["agent","invoke"]];static usage=E.Usage({category:"Agents",description:"Invoke a shared agent tool; pipe its JSON input on stdin."});tool=f.String("--tool",{required:!0,description:"plexus|plexus_skill|plexus_workspace"});async execute(){if("isTTY"in this.context.stdin&&this.context.stdin.isTTY===!0)throw new g("plexus: pipe the tool's JSON input on stdin.");let t=ni(await Dw(this.context.stdin),"stdin"),n=await this.context.executePlexusAgentTool(this.tool,t);return this.print(n),0}},j_=[qw,Kw];var jw=[{key:"fixture_test",email:"test@example.com",firstName:"Test",lastName:"Bewerber"}],Kfe=new Set(jw.map(e=>e.key));var ze=["de","en"];function sa(e,t){return ze.every(n=>e[n]===t[n])}s(sa,"sameText");function Ft(e){if(e===null||typeof e!="object"||Array.isArray(e))return"not-localized";let t=e;return Object.keys(t).some(r=>!ze.includes(r))?"not-localized":ze.filter(r=>{let i=t[r];return typeof i!="string"||i.trim()===""})}s(Ft,"missingLocales");function co(e){let t=Ft(e);return t!=="not-localized"&&t.length===0}s(co,"isLocalizedText");function ad(e,t){let n={};for(let r of ze){let i=e.map(o=>o[r]);n[r]=i.every(o=>typeof o=="string"&&o.trim()!=="")?t(i,r):""}return n}s(ad,"composeTexts");function vp(e){return e.toLowerCase().normalize("NFKD").replace(/[̀-ͯ]/g,"").replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}s(vp,"slugify");var V_="tenant";function B_(e){if(e.length===0||vp(e)!==e)return"must be lowercase a-z/0-9 words joined by single dashes";if(e===V_)return`"${V_}" is reserved for the tenant-wide scope`}s(B_,"unitSlugError");var cH=/^[a-z0-9]+(?:-[a-z0-9]+)*$/;function lr(e,t){return`${e}-${t}`}s(lr,"runStorageKey");function U_(e,t){typeof t!="string"&&de("CONFLICT",{de:`[run/keyNotServed] Das Deployment liefert f\xFCr ein Schuljahr von \u201E${e}\u201C keinen Schl\xFCssel \u2014 es l\xE4uft ein \xE4lteres Release als die CLI. Nach dem n\xE4chsten Release erneut versuchen.`,en:`[run/keyNotServed] The deployment provides no key for a school year of "${e}" \u2014 it runs an older release than the CLI. Try again after the next release.`});let n=`${e}-`;return(!t.startsWith(n)||t.length===n.length)&&de("CONFLICT",{de:`[run/foreignKey] Der Schl\xFCssel \u201E${t}\u201C des Schuljahrs liegt nicht unter dem Programm \u201E${e}\u201C (erwartet: \u201E${n}<key>\u201C).`,en:`[run/foreignKey] The key "${t}" of the school year is not under the program "${e}" (expected: "${n}<key>").`}),t.slice(n.length)}s(U_,"bareRunKey");function xp(e){let t=[],n=new Map;return e.forEach((r,i)=>{let o=Ft(r.name),a=o!=="not-localized"&&!o.includes("de")?r.name.de:void 0,l=`program.runs[${i}]${a!==void 0?` ("${a}")`:""}`;o==="not-localized"||o.length===2?t.push({code:"run/nameMissing",index:i,message:{de:`[run/nameMissing] ${l}: jedes Schuljahr braucht einen \`name\` auf Deutsch und Englisch (\`{ de, en }\`)`,en:`[run/nameMissing] ${l}: every run needs a \`name\` in German and English (\`{ de, en }\`)`}}):o.length>0&&t.push({code:"run/nameUntranslated",index:i,message:{de:`[i18n/missingTranslation] ${l}.name fehlt in: ${o.join(", ")} \u2014 jeder angezeigte Text braucht Deutsch und Englisch.`,en:`[i18n/missingTranslation] ${l}.name is missing in: ${o.join(", ")} \u2014 every displayed text needs German and English.`}});let d=r.key;if(d==null||d===""){t.push({code:"run/keyMissing",index:i,message:{de:`[run/keyMissing] ${l}: jedes Schuljahr braucht einen stabilen \`key\` \u2014 der Name dient nur der Anzeige`,en:`[run/keyMissing] ${l}: every run needs a stable \`key\` \u2014 the name is display only`}});return}if(typeof d!="string"||!cH.test(d)){t.push({code:"run/keyInvalid",index:i,message:{de:`[run/keyInvalid] ${l}: der Schl\xFCssel ${JSON.stringify(d)} muss ein kleingeschriebener Slug sein (a-z, 0-9, einzelnes \u201E-\u201C)`,en:`[run/keyInvalid] ${l}: key ${JSON.stringify(d)} must be a lowercase slug string (a-z, 0-9, single "-")`}});return}let c=n.get(d);if(c!==void 0){t.push({code:"run/duplicateKey",index:i,message:{de:`[run/duplicateKey] ${l}: der Schl\xFCssel \u201E${d}\u201C wird bereits von program.runs[${c}] verwendet`,en:`[run/duplicateKey] ${l}: key "${d}" is already used by program.runs[${c}]`}});return}n.set(d,i)}),t}s(xp,"runSpecIssues");var uH="-stufe-",fH=/^[a-z0-9]+(?:-[a-z0-9]+)*$/;function Vw(e){return`${e}${uH}`}s(Vw,"stageKeyPrefix");function aa(e,t){return`${Vw(e)}${t}`}s(aa,"stageStorageKey");function z_(e,t){let n=Vw(e);return t.startsWith(n)&&t.length>n.length}s(z_,"isUnderProgram");function ri(e,t){let n=Vw(e);return z_(e,t)||de("CONFLICT",{de:`[stage/foreignKey] Der Stufenschl\xFCssel \u201E${t}\u201C liegt nicht unter dem Programm \u201E${e}\u201C (erwartet: \u201E${n}<key>\u201C). F\xFChren Sie die Stufe in bundle.yaml unter einem neuen Schl\xFCssel auf; der n\xE4chste Apply archiviert diese Zeile (hinter der Archivsperre) und legt die Stufe mit dem neuen Schl\xFCssel an.`,en:`[stage/foreignKey] The level key "${t}" is not under the program "${e}" (expected: "${n}<key>"). List the level in bundle.yaml under a new key; the next apply archives this row (behind the archive lock) and creates the level with the new key.`}),t.slice(n.length)}s(ri,"bareStageKey");function Sp(e){let t=[],n=new Map;return e.forEach((r,i)=>{let o=Ft(r.name),a=o!=="not-localized"&&!o.includes("de")?r.name.de:void 0,l=`program.stages[${i}]${a!==void 0?` ("${a}")`:""}`;o==="not-localized"||o.length===2?t.push({code:"stage/nameMissing",index:i,message:{de:`[stage/nameMissing] ${l}: jede Klassenstufe braucht einen \`name\` auf Deutsch und Englisch (\`{ de, en }\`)`,en:`[stage/nameMissing] ${l}: every stage needs a \`name\` in German and English (\`{ de, en }\`)`}}):o.length>0&&t.push({code:"stage/nameUntranslated",index:i,message:{de:`[i18n/missingTranslation] ${l}.name fehlt in: ${o.join(", ")} \u2014 jeder angezeigte Text braucht Deutsch und Englisch.`,en:`[i18n/missingTranslation] ${l}.name is missing in: ${o.join(", ")} \u2014 every displayed text needs German and English.`}});let d=r.key;if(d==null||d===""){t.push({code:"stage/keyMissing",index:i,message:{de:`[stage/keyMissing] ${l}: jede Klassenstufe braucht einen stabilen \`key\` \u2014 der Name dient nur der Anzeige`,en:`[stage/keyMissing] ${l}: every stage needs a stable \`key\` \u2014 the name is display only`}});return}if(typeof d!="string"||!fH.test(d)){t.push({code:"stage/keyInvalid",index:i,message:{de:`[stage/keyInvalid] ${l}: der Schl\xFCssel ${JSON.stringify(d)} muss ein kleingeschriebener Slug sein (a-z, 0-9, einzelnes \u201E-\u201C)`,en:`[stage/keyInvalid] ${l}: key ${JSON.stringify(d)} must be a lowercase slug string (a-z, 0-9, single "-")`}});return}let c=n.get(d);if(c!==void 0){t.push({code:"stage/duplicateKey",index:i,message:{de:`[stage/duplicateKey] ${l}: der Schl\xFCssel \u201E${d}\u201C wird bereits von program.stages[${c}] verwendet`,en:`[stage/duplicateKey] ${l}: key "${d}" is already used by program.stages[${c}]`}});return}n.set(d,i)}),t}s(Sp,"stageSpecIssues");function G_(e){return{de:e.de.trim(),en:e.en.trim()}}s(G_,"trimmedText");function pH(e,t){let n=[];return e.de!==t.de&&n.push(`"${e.de}" \u2192 "${t.de}"`),e.en!==t.en&&n.push(`en "${e.en}" \u2192 "${t.en}"`),n.join(", ")}s(pH,"describeNameChange");function Ap(e,t,n){if(e===null)return t.length>0&&D("planStageReconcile: stages exist but the offer has no program key"),n.map((a,l)=>({op:"insert",key:a.key,name:G_(a.name),...a.gradeLevel!==void 0?{gradeLevel:a.gradeLevel}:{},sequence:l+1}));let r=new Map(t.map(a=>[a.key,a])),i=new Set,o=[];n.forEach(({name:a,...l},d)=>{let c={...l,name:G_(a)},u=aa(e,c.key);i.add(u);let p=d+1,h=r.get(u);if(h===void 0){o.push({op:"insert",key:c.key,name:c.name,...c.gradeLevel!==void 0?{gradeLevel:c.gradeLevel}:{},sequence:p});return}let y={};sa(h.name,c.name)||(y.name=[h.name,c.name]);let b=h.gradeLevel??null,k=c.gradeLevel??null;b!==k&&(y.gradeLevel=[b,k]),h.sequence!==p&&(y.sequence=[h.sequence,p]),(Object.keys(y).length>0||h.archived)&&o.push({op:"update",key:c.key,stageId:h.stageId,name:c.name,changes:y,unarchive:h.archived})});for(let a of[...t].sort((l,d)=>l.sequence-d.sequence))a.archived||i.has(a.key)||o.push({op:"archive",key:z_(e,a.key)?ri(e,a.key):a.key,stageId:a.stageId,name:a.name});return o}s(Ap,"planStageReconcile");function Tp(e){switch(e.op){case"insert":return`+stage ${e.key} (${e.name.de})`;case"archive":{let t=e.occupancy,n=[...t&&t.activeApplications>0?[`REFUSED: ${t.activeApplications} active application(s) \u2014 [stage/hasActiveApplications]`]:[],...t&&t.openLeads>0?[`${t.openLeads} open lead(s)`]:[]];return`-stage ${e.key} (${e.name.de})${n.length>0?` \u2014 ${n.join("; ")}`:""}`}case"update":{let t=[];if(e.unarchive&&t.push("restored"),e.changes.name&&t.push(pH(e.changes.name[0],e.changes.name[1])),e.changes.gradeLevel){let[n,r]=e.changes.gradeLevel;t.push(`grade ${n??"\u2013"} \u2192 ${r??"\u2013"}`)}return e.changes.sequence&&t.push(`position ${e.changes.sequence[0]} \u2192 ${e.changes.sequence[1]}`),`~stage ${e.key} (${t.join(", ")})`}}}s(Tp,"describeStageStep");function Rp(e,t){return t.startsWith(e)&&t.length>e.length?t.slice(e.length):void 0}s(Rp,"bareUnder");function Y_(e,t,n,r){let i=e.flatMap(y=>y.angebote).find(y=>y.offerKey===t);if(i===void 0){let y=e.flatMap(b=>b.angebote.map(k=>k.offerKey));throw new g(`applications start-test: no offer "${t}" (offers: ${y.join(", ")||"none"})`)}if(i.programKey===void 0)throw new g("applications start-test: the deployment does not serve the offer's program key \u2014 it runs an older release than the CLI; try again after the next release");let o=i.programKey;if(o===null)throw new g(`applications start-test: ${t} has no program yet \u2014 no level to start on`);let a=aa(o,""),l=lr(o,""),d=s(y=>Rp(a,y)??"(no bundle key)","stageLabel"),c=s(y=>Rp(l,y)??"(no bundle key)","runLabel"),u=i.stages.find(y=>y.stageKey===aa(o,r)||y.stageId===r);if(u===void 0){let y=i.stages.map(v=>`${d(v.stageKey)} (${v.stageId})`).join(", "),b=Rp(a,r),k=b!==void 0&&i.stages.some(v=>v.stageKey===r)?` \u2014 "${r}" is the stored key; the export names it "${b}"`:"";throw new g(`applications start-test: no level "${r}" in ${t}${k} \u2014 name it by its bundle key or id: ${y}`)}let p=d(u.stageKey),h=u.runs.find(y=>y.runKey===lr(o,n)||y.runId===n);if(h===void 0){let y=u.runs.map(v=>`${c(v.runKey)} (${v.runId})`).join(", "),b=Rp(l,n),k=b!==void 0&&u.runs.some(v=>v.runKey===n)?` \u2014 "${n}" is the stored key; the export names it "${b}"`:"";throw new g(`applications start-test: no school year "${n}" for level ${p}${k} \u2014 name it by its bundle key or id: ${y}`)}if(!h.isOpen)throw new g(`applications start-test: school year ${c(h.runKey)} is closed for level ${p}`);return{programRunId:h.runId,programStageId:u.stageId}}s(Y_,"resolveStartTarget");function mH(e){return e.kind==="named"?e.name:`(${e.standIn??e.fallback})`}s(mH,"applicantText");function H_(e){return e.map(t=>({id:t.application._id,status:t.deletedAt?`${t.application.status} (gel\xF6scht)`:t.application.status,state:t.currentProcessStateId??"",applicant:mH(t.applicantName),test:t.application.testMode===!0?"test":""}))}s(H_,"applicationRows");var W_=jw.map(e=>e.email);function J_(e,t,n,r){if(n===void 0&&r===void 0)throw new g("applications start-test: name the applicant \u2014 --party <partyId> or --applicant <email>");if(n!==void 0&&r!==void 0)throw new g("applications start-test: --party or --applicant, not both");if(Nw(e,t)&&(r===void 0||!W_.includes(r.trim().toLowerCase())))throw new g(`applications start-test: on prod only for the test account ${W_.join(", ")} (--applicant) \u2014 never a real family's`)}s(J_,"assertStartApplicant");function Q_(e){let t={};for(let{address:n,...r}of e.entries)t[n]=r;return{applicationId:e.applicationId,store:t}}s(Q_,"processStoreJson");function hH(e){switch(e.kind){case"form":return`form ${e.formInstanceId} (${e.state})`;case"document":return e.file===null?`document ${e.slotKey} (leer)`:`document ${e.slotKey} \xB7 v${e.file.versionNumber} ${e.file.filename??e.file.artifactId}`;case"contract":return`contract ${e.contractId} \xB7 ${e.revision===null?"keine Fassung":`Fassung ${e.revision.snapshotNumber}`} \xB7 ${e.contractStatus}`;case"contracts":return e.contracts.map(t=>`${t.partKey}: contract ${t.contractId} \xB7 ${t.revision===null?"keine Fassung":`Fassung ${t.revision.snapshotNumber}`} \xB7 ${t.contractStatus}`).join("; ")}}s(hH,"refText");function gH(e){return e.state!=="present"?e.reason?.de??"":e.ref!==void 0?hH(e.ref):JSON.stringify(e.value)}s(gH,"holds");function Z_(e){return e.entries.map(t=>({address:t.address,state:t.state,holds:gH(t),producer:t.producer?.label??"",written:t.writtenAt===void 0?"":new Date(t.writtenAt).toISOString()}))}s(Z_,"storeRows");function $p(e){let t={},n={};for(let r of e){let i=r.indexOf("=");if(i<=0)throw new g(`Expected key=value, got '${r}'.`);let o=r.slice(0,i);if(Object.hasOwn(n,o))throw new g(`'${o}' is given twice.`);let a=r.slice(i+1);n[o]=a;try{t[o]=JSON.parse(a)}catch{t[o]=a}}return{values:t,raw:n}}s($p,"parseKv");var Bw="started",Ep="submitted",Ip="submitted",X_="load-scenario:";var eN="(Bewerbung)";function tN(e){return{nodeId:eN,actions:e.map(t=>({id:t.id,label:{de:`${t.label??t.id}${t.count===void 0?"":` (${t.count})`}`,en:`${t.label??t.id}${t.count===void 0?"":` (${t.count})`}`},...t.disabledReason===void 0?{}:{disabledReason:t.disabledReason}}))}}s(tN,"sharedAsList");function nN(e){return e.disabledReason===void 0?"":e.disabledCount===void 0?e.disabledReason:`${e.disabledReason} (${e.disabledCount})`}s(nN,"disabledText");function rN(e){return e.flatMap(({nodeId:t,actions:n})=>n.map(r=>({node:t,action:r.id,label:r.label.de,disabled:nN(r)})))}s(rN,"actionRows");function iN(e,t,n=[]){let r=e.filter(({actions:d})=>d.some(c=>c.id===t));if(r.length===0){let d=[...new Set(e.flatMap(({actions:c})=>c.map(u=>u.id)))];throw new g(`test-actions run: no current node offers "${t}" (offered: ${d.join(", ")||"nothing"})`)}if(r.length>1)throw new g(`test-actions run: "${t}" is offered by ${r.map(d=>d.nodeId).join(", ")} \u2014 pass --node`);let{nodeId:i,actions:o}=r[0],a=o.find(d=>d.id===t);if(a.disabledReason!==void 0)throw new g(`test-actions run: "${t}" on ${i} is disabled: ${nN(a)}`);if(i!==eN)return i;let l=n[0];if(l===void 0)throw new g(`test-actions run: "${t}" needs a current node \u2014 the application has none`);return l}s(iN,"nodeOfferingAction");function oN(e,t,n){if(e.startsWith(X_)){if(Object.hasOwn(n,"autoSubmit"))throw new g(`test-actions run: ${e}: a scenario's autoSubmit is set by --auto-submit / --no-auto-submit, not --param`);return{autoSubmit:t,...n}}return Object.keys(n).length===0?void 0:{...n}}s(oN,"runParams");var yH=/^[0-9a-hjkmnp-tv-z]{31,37}$/;function ee(e,t){if(!yH.test(e))throw new g(`"${e}" is not a ${t} id \u2014 a Convex id is 31\u201337 characters of 0-9 and a-z without i, l, o, u.`);return e}s(ee,"parseDocumentId");async function wH(e,t){let n=await e.query(S.workflow.getInstance,{applicationId:t});if(n===null)throw new g(`test-actions: application ${t} has no workflow instance`);return n.instance.currentNodeIds}s(wH,"currentNodeIds");function kH(e,t){switch(t){case"notTestApplication":return`${e} is not a test application`;case"completed":case"aborted":case"deleted":return`${e} is ${t} \u2014 test actions run only on an active application`;case"missingPermission":return"the caller lacks bewerbungsmanagement.testActions.run"}}s(kH,"refusalText");async function Op(e,t,n){let r=await e.query(S.workflow.listSharedTestActions,{applicationId:t});if(!r.permitted)throw new g(`test-actions: not permitted \u2014 ${kH(t,r.reason)}`);let i=[];for(let o of n){let a=await e.query(S.workflow.listTestActions,{applicationId:t,nodeId:o});if(a===null)throw new g(`test-actions: node "${o}" is not in this application's workflow (or it has no instance)`);i.push({nodeId:o,actions:a})}return[...i,tN(r.actions)]}s(Op,"actionsOf");async function sN(e,t,n){return n!==void 0?[n]:await wH(e,t)}s(sN,"nodesOf");var Uw=class extends P{static{s(this,"TestActionsListCommand")}static paths=[["test-actions","list"]];static usage=E.Usage({category:"Admission",description:"List the test-mode actions of the application's current node(s) (scenarios, auto-fill-files, submit, \u2026) and the application-wide ones"});application=f.String("--application",{required:!0,description:"Application id (a test application)"});node=f.String("--node",{description:"Node id (default: the application's current nodes)"});async execute(){let t=ee(this.application,"application"),n=await this.caller(),r=await Op(n,t,await sN(n,t,this.node));return this.print(r,rN,["node","action","label","disabled"]),0}},Gw=class extends P{static{s(this,"TestActionsRunCommand")}application=f.String("--application",{required:!0,description:"Application id (a test application)"});node=f.String("--node",{description:"Node id (default: the application's current nodes)"});static paths=[["test-actions","run"]];static usage=E.Usage({category:"Admission",description:"Run one test-mode action; a scenario (load-scenario:<id>) also submits unless --no-auto-submit"});action=f.String("--action",{required:!0,description:"Action id, e.g. load-scenario:standard, auto-fill-files, submit-form"});autoSubmit=f.Boolean("--auto-submit",!0,{description:"Scenario only: stub the file fields and submit after loading (default on; --no-auto-submit only loads)"});param=f.Array("--param",{description:"Action parameter key=value (repeatable; the value is JSON where it parses, else text), e.g. --param confirmed=true for an action that asks a question first (its `confirm` in `test-actions list`)"});async execute(){let t=oN(this.action,this.autoSubmit,$p(this.param??[]).values),n=ee(this.application,"application"),r=await this.caller(),i=await sN(r,n,this.node),o=iN(await Op(r,n,i),this.action,i);return await r.mutation(S.workflow.runTestAction,{applicationId:n,nodeId:o,actionId:this.action,...t===void 0?{}:{params:t}}),this.print({ran:this.action,on:o},a=>[{key:"ran",value:a.ran},{key:"on",value:a.on},{key:"next",value:"test-actions list \u2014 file fills and the submit after them run asynchronously"}]),0}},aN=[Uw,Gw];var Or=/^[a-z][A-Za-z0-9]*$/;function zw(e){return typeof e=="string"&&Or.test(e)}s(zw,"isNodeId");function la(e,t){zw(e)||D(`[graph/nodeIdFormat] "${e}" cannot name a node: a node id is ${Or.source}.`);let n=new Set(t);if(!n.has(e))return e;let r=2;for(;n.has(`${e}${r}`);)r++;return`${e}${r}`}s(la,"makeNodeId");var fo="$env";function ce(e){if(e.scope==="env")return`${fo}.${e.key}`;let t=`$${e.scope}.${e.owner}.${e.key}`;return e.path===void 0?t:`${t}.${e.path}`}s(ce,"formatAddress");var uo=/^[a-z][a-zA-Z0-9_]*$/,bH=/^[A-Za-z_][A-Za-z0-9_]*$/;function Ho(e){return typeof e=="string"&&e.split(".").every(t=>bH.test(t))}s(Ho,"isPath");function Si(e){if(!e.startsWith("$"))return null;let t=e.slice(1).split("."),[n,...r]=t;switch(n){case"env":{let i=r.join(".");return r.length>0&&Ho(i)?{scope:"env",key:i}:null}case"node":case"task":{let[i,o,...a]=r;return i===void 0||o===void 0||!uo.test(o)||(n==="node"?!Or.test(i):!uo.test(i))?null:vH({scope:n,owner:i,key:o},a)}default:return null}}s(Si,"tryParseAddress");function vH(e,t){if(t.length===0)return e;let n=t.join(".");return Ho(n)?{...e,path:n}:null}s(vH,"withPath");function ke(e){if(typeof e!="object"||e===null||Array.isArray(e))return!1;let t=e,n=t.scope==="env"?["scope","key"]:["scope","owner","key","path"];if(Object.keys(t).some(r=>!n.includes(r))||t.path!==void 0&&!Ho(t.path))return!1;switch(t.scope){case"env":return Ho(t.key);case"node":return typeof t.owner=="string"&&Or.test(t.owner)&&typeof t.key=="string"&&uo.test(t.key);case"task":return typeof t.owner=="string"&&uo.test(t.owner)&&typeof t.key=="string"&&uo.test(t.key);default:return!1}}s(ke,"isAddress");var po={offer:{key:"string",title:"string"},unit:{key:"string",name:"string"},stage:{key:"string",name:"string",gradeLevel:"number"},run:{key:"string",name:"string",startDate:"date"},applicant:{language:"enum",channel:"enum"}},da=Object.keys(po);function mo(e){return Object.hasOwn(po,e)}s(mo,"isEnvKey");var Ww=["self-service","staff"];function lN(e,t){return{kind:"fixed",values:e,labels:t}}s(lN,"fixedSet");var _p={of:"applicant.language",withoutValue:"de"},Ai={"offer.key":{valueSet:{kind:"live"},nullable:!1,label:{de:"Angebot",en:"Offer"}},"offer.title":{valueSet:{kind:"unstable"},nullable:!1,label:{de:"Titel des Angebots",en:"Offer title"},nameLanguage:_p},"unit.key":{valueSet:{kind:"live"},nullable:!1,label:{de:"Einheit",en:"Unit"}},"unit.name":{valueSet:{kind:"unstable"},nullable:!1,label:{de:"Name der Einheit",en:"Unit name"},nameLanguage:_p},"stage.key":{valueSet:{kind:"unstable"},nullable:!1,label:{de:"Klassenstufe (Schl\xFCssel)",en:"Grade (key)"},cohortBound:!0},"stage.name":{valueSet:{kind:"unstable"},nullable:!1,label:{de:"Name der Klassenstufe",en:"Grade name"},cohortBound:!0,nameLanguage:_p},"stage.gradeLevel":{valueSet:{kind:"open"},nullable:!0,absent:{de:"Die Stufe hat keine Klassenstufe (Kindergarten).",en:"The stage has no grade level (Kindergarten)."},label:{de:"Klassenstufe",en:"Grade level"},cohortBound:!0},"run.key":{valueSet:{kind:"unstable"},nullable:!1,label:{de:"Schuljahr",en:"School year"},cohortBound:!0},"run.name":{valueSet:{kind:"unstable"},nullable:!1,label:{de:"Name des Schuljahrs",en:"School year name"},cohortBound:!0,nameLanguage:_p},"run.startDate":{valueSet:{kind:"open"},nullable:!0,absent:{de:"F\xFCr das Schuljahr ist kein Beginn erfasst.",en:"The school year has no start date."},label:{de:"Beginn des Schuljahrs",en:"School year start"},cohortBound:!0},"applicant.language":{valueSet:lN(ze,{de:{de:"Deutsch",en:"German"},en:{de:"Englisch",en:"English"}}),nullable:!0,absent:{de:"Die Bewerbung hat kein Bewerberkonto (intern angelegt).",en:"The application has no applicant account (started by staff)."},label:{de:"Bewerbersprache",en:"Applicant language"}},"applicant.channel":{valueSet:lN(Ww,{staff:{de:"intern",en:"in-house"},"self-service":{de:"online (Familie)",en:"online (family)"}}),nullable:!1,label:{de:"Eingangsweg",en:"Intake channel"}}},Np={types:po,fields:Ai},Pp=da.flatMap(e=>Object.keys(po[e]).map(t=>`${e}.${t}`));function dr(e){return Object.hasOwn(Ai,e)}s(dr,"isEnvLeaf");function Cp(e){return`${fo}.${e}`}s(Cp,"envIdentifier");function Jo(e){let t=Ai[e],[n,r]=e.split("."),i=po[n][r];i===void 0&&D(`[env] leaf "${e}" has no type`);let o=t.valueSet;return{leaf:e,type:i,label:t.label,nullable:t.nullable,...t.absent===void 0?{}:{absent:t.absent},...t.nameLanguage===void 0?{}:{nameLanguage:t.nameLanguage},...t.cohortBound===void 0?{}:{cohortBound:t.cohortBound},...o.kind==="fixed"?{enumOptions:o.values.map(a=>{let l=o.labels[a];return l===void 0&&D(`[env] "${e}" names the value "${a}" without a label`),{value:a,label:l}})}:{}}}s(Jo,"envLeaf");var dN="staffInput";var xH=["boolean"],ld=/^[a-z][A-Za-z0-9]*$/;function Dp(e){return e.staffInputs??[]}s(Dp,"staffInputsOf");function Fp(e){return`${dN}.${e}`}s(Fp,"staffInputLeaf");function cN(e){return`${fo}.${Fp(e)}`}s(cN,"staffInputIdentifier");function SH(e){let t=`${dN}.`;return e.startsWith(t)?e.slice(t.length):null}s(SH,"staffInputKeyOfLeaf");function ca(e,t){let n=SH(t);return n===null?void 0:Dp(e).find(r=>r.key===n)}s(ca,"declaredStaffInput");function uN(e){return[...Dp(e).map(t=>({leaf:Fp(t.key),type:t.type,label:t.label,valueSet:{kind:"open"},nullable:!1,cohortBound:!1})),...Pp.map(t=>{let n=Jo(t);return{leaf:t,type:n.type,label:n.label,valueSet:Ai[t].valueSet,nullable:n.nullable,cohortBound:n.cohortBound===!0}})]}s(uN,"envLeavesFor");function fN(e){return uN(e).filter(t=>!t.cohortBound)}s(fN,"conditionEnvLeaves");function pN(e){return hN(fN(e))}s(pN,"envConditionSchemaFor");function AH(e){return uN(e).map(t=>t.leaf==="stage.key"?{...t,valueSet:{kind:"open"}}:t)}s(AH,"offerConditionEnvLeaves");function mN(e){return hN(AH(e))}s(mN,"offerConditionSchemaFor");function hN(e){let t={},n={};for(let{leaf:r,type:i,valueSet:o,nullable:a}of e){let[l="",d=""]=r.split(".");t[l]={...t[l]??{},[d]:i},n[r]={valueSet:o,nullable:a}}return{types:t,fields:n}}s(hN,"schemaOfLeaves");function gN(e){let t=e.staffInputs;if(t===void 0)return[];if(!Array.isArray(t))return[{path:"staffInputs",reason:{de:"[staffInput/shape] graph.staffInputs muss eine Liste sein.",en:"[staffInput/shape] graph.staffInputs must be a list."}}];let n=[],r=new Set;return t.forEach((i,o)=>{let a=`staffInputs[${o}]`,l=i;if(l===null||typeof l!="object"||typeof l.key!="string"){n.push({path:a,reason:{de:"[staffInput/shape] Eine interne Angabe braucht key, type und label ({ de, en }).",en:"[staffInput/shape] An internal entry needs key, type and label ({ de, en })."}});return}let d={de:`Interne Angabe "${l.key}"`,en:`Internal entry "${l.key}"`};ld.test(l.key)||n.push({path:`${a}.key`,reason:{de:`[staffInput/keyFormat] ${d.de}: Schl\xFCssel beginnt mit einem Kleinbuchstaben und enth\xE4lt nur Buchstaben und Ziffern.`,en:`[staffInput/keyFormat] ${d.en}: the key starts with a lowercase letter and contains only letters and digits.`}}),r.has(l.key)&&n.push({path:`${a}.key`,reason:{de:`[staffInput/duplicateKey] ${d.de}: Schl\xFCssel ist doppelt vergeben.`,en:`[staffInput/duplicateKey] ${d.en}: the key is used twice.`}}),r.add(l.key),xH.includes(l.type)||n.push({path:`${a}.type`,reason:{de:`[staffInput/unknownType] ${d.de}: Typ "${String(l.type)}" \u2014 erlaubt ist nur "boolean" (K\xE4stchen).`,en:`[staffInput/unknownType] ${d.en}: type "${String(l.type)}" \u2014 only "boolean" (checkbox) is allowed.`}});let c=Ft(l.label);c==="not-localized"?n.push({path:`${a}.label`,reason:{de:`[staffInput/shape] ${d.de}: label muss { de, en } sein.`,en:`[staffInput/shape] ${d.en}: label must be { de, en }.`}}):c.length>0&&n.push({path:`${a}.label`,reason:{de:`[i18n/missingTranslation] ${d.de}: Beschriftung fehlt in ${c.join(", ")}.`,en:`[i18n/missingTranslation] ${d.en}: label is missing in ${c.join(", ")}.`}})}),n}s(gN,"staffInputIssues");function Lt(e,t){if(e instanceof $e)return new $e(t(e.message),{cause:e});if(e instanceof g)return new g(t(e.message),{cause:e});let n=ar(e);if(n!==null&&(n.message.de!==""||n.message.en!=="")){let r=e.data,i=typeof r=="string"?t(r):{...r,message:{de:n.message.de===""?"":t(n.message.de),en:n.message.en===""?"":t(n.message.en)}},o=new Dt(i);return o.cause=e,o}return new Error(t(Wl(e)),{cause:e})}s(Lt,"withContext");var ik={required:!0,description:"Offer slug (its offerKey)"},Yw=class extends P{static{s(this,"ApplicationsListCommand")}static paths=[["applications","list"]];static usage=E.Usage({category:"Admission",description:"List an offer's applications (id, status, board state, applicant, test)"});offer=f.String("--offer",ik);testOnly=f.Boolean("--test-only",!1,{description:"Only test applications"});async execute(){let t=await this.caller(),n=await t.query(S.admission.listForAngebot,{client:this.requireTenant(t),offerKey:this.offer}),r=H_(n).filter(i=>!this.testOnly||i.test==="test");return this.print(r,i=>i,["id","status","state","applicant","test"]),0}},Hw=class extends P{static{s(this,"ApplicationsCountsCommand")}static paths=[["applications","counts"]];static usage=E.Usage({category:"Admission",description:"Count an offer's applications per list"});offer=f.String("--offer",ik);async execute(){let t=await this.caller(),n=await t.query(S.admission.getCountsByListForAngebot,{client:this.requireTenant(t),offerKey:this.offer});return this.print(n,r=>[...Object.entries(r.counts).map(([i,o])=>({list:i,count:String(o)})),{list:"total",count:String(r.total)}],["list","count"]),0}},Jw=class extends P{static{s(this,"ApplicationsShowCommand")}static paths=[["applications","show"]];static usage=E.Usage({category:"Admission",description:"One application: status, test flag, offer, current workflow nodes"});application=f.String({required:!0});async execute(){let t=await this.caller(),n=ee(this.application,"application"),r=await t.query(S.admission.get,{applicationId:n});if(r===null)throw new g(`applications show: no application ${n} (or not visible to you)`);let i=await t.query(S.workflow.getInstance,{applicationId:n});return this.print({application:r,currentNodes:i?.instance.currentNodeIds??[]},o=>[{key:"id",value:n},{key:"status",value:o.application.status},{key:"test",value:o.application.testMode?"ja":"nein"},{key:"offer",value:o.application.offerId},{key:"current nodes",value:o.currentNodes.join(", ")}]),0}},Qw=class extends P{static{s(this,"ApplicationsStoreCommand")}static paths=[["applications","store"]];static usage=E.Usage({category:"Admission",description:"One application's process store: every address of its pinned graph, resolved (present / pending / absent)",details:"Staff only (applications.manage). --json prints one object keyed by the canonical address ($node\u2026, $task\u2026, $env\u2026). Values are shown whatever their audience \u2014 never hand the output to the family. Recipe: playbooks/applications/inspect-process-store.md."});application=f.String({required:!0});async execute(){let n=await(await this.caller()).query(S.processStoreView.get,{applicationId:ee(this.application,"application")});return this.print(Q_(n),()=>Z_(n),["address","state","holds","producer","written"]),0}},Zw=class extends P{static{s(this,"ApplicationsStartTestCommand")}static paths=[["applications","start-test"]];static usage=E.Usage({category:"Admission",description:"Start a TEST application for an applicant (school year and level by key or id) and show what test mode offers next",details:"Always test mode. --applicant names the account by its login address (on prod only the tenant's test account); --party names the applicant party directly. Without --version it runs on the live generation, like the cockpit."});offer=f.String("--offer",ik);run=f.String("--run",{required:!0,description:"School year: its bundle key as offer export shows it (program.runs[].key) or id \u2014 never its name"});stage=f.String("--stage",{required:!0,description:"Level: its bundle key as offer export shows it (program.stages[].key) or id \u2014 never its name"});party=f.String("--party",{description:"Applicant party id"});applicant=f.String("--applicant",{description:"Applicant account login address (e.g. the test account test@example.com)"});version=f.String("--version",{description:"Offer version id to test (default: the live generation)"});staffInput=f.Array("--staff-input",{description:"A staff input the offer declares, as key=true|false \u2014 repeat it once per input; a staff start must set every one"});proxy=f.Boolean("--proxy",{description:"Start in Stellvertretung (--proxy) or not (--no-proxy); left out, the tenant's default applies, as in the cockpit"});async execute(){let t=await this.caller();J_(this.resolvedTarget(),this.prodUrls(),this.party,this.applicant);let n=this.requireTenant(t),r=Y_(await t.query(S.admission.listAdmissionTree,{client:n}),this.offer,this.run,this.stage),i=this.party===void 0?void 0:ee(this.party,"party");if(this.applicant!==void 0){let d=await t.query(S.applicants.partyByEmail,{client:n,email:this.applicant});if(d===null)throw new g(`applications start-test: no applicant account ${this.applicant} at this school (create it in the cockpit first)`);i=d}let o=await t.mutation(S.admission.staffStartApplicationForParty,{client:n,offerKey:this.offer,partyId:i,programRunId:r.programRunId,programStageId:r.programStageId,...this.proxy===void 0?{}:{startInProxy:this.proxy},staffInputs:wN(this.staffInput??[]),testMode:!0,...this.version===void 0?{}:{offerVersionId:ee(this.version,"offer version")}}),a,l;try{let d=await t.query(S.workflow.getInstance,{applicationId:o.applicationId});if(d===null)throw new Error("the started application has no workflow instance");a=d.instance.currentNodeIds,l=(await Op(t,o.applicationId,a)).flatMap(c=>c.actions.map(u=>u.id))}catch(d){throw Lt(d,c=>`applications start-test: started ${o.applicationId}, but reading its state failed: ${c}`)}return this.print({applicationId:o.applicationId,currentNodes:a,testActions:l},d=>[{key:"application",value:d.applicationId},{key:"current nodes",value:d.currentNodes.join(", ")},{key:"test actions",value:d.testActions.join(", ")},{key:"next",value:`test-actions run --application ${d.applicationId} --action <id>`}]),0}},Xw=class extends P{static{s(this,"ApplicationsDiscardTestCommand")}static paths=[["applications","discard-test"]];static usage=E.Usage({category:"Admission",description:"Discard a TEST application (the server refuses a real one), or with --all-test every expired one of the school",details:"With an id: discards that test application. With --all-test --older-than <N>d: lists the school's test applications whose last activity is older than N days (N \u2265 14) and that are not kept as a demo \u2014 a dry run unless --confirm; --confirm discards each expired one the server re-checks, the rest are reported with the reason. Recipe: playbooks/applications/expire-test-applications.md.",examples:[["Dry run","plexus-cli --env prod --tenant <t> applications discard-test --all-test --older-than 14d --dry-run"],["Discard","plexus-cli --env prod --tenant <t> --allow-prod applications discard-test --all-test --older-than 14d --confirm"]]});application=f.String({required:!1});allTest=f.Boolean("--all-test",!1,{description:"Every expired test application of the school instead of one id"});olderThan=f.String("--older-than",{description:"With --all-test: days without activity, as <N>d (N \u2265 14)"});dryRun=f.Boolean("--dry-run",!1,{description:"With --all-test: list only (the default)"});confirm=f.Boolean("--confirm",!1,{description:"With --all-test: discard (else the dry run)"});async execute(){if(!this.allTest){if(this.application===void 0)throw new g("applications discard-test: name an application id, or use --all-test --older-than <N>d");if(this.olderThan!==void 0||this.dryRun||this.confirm)throw new g("applications discard-test: --older-than, --dry-run and --confirm belong to --all-test");return await(await this.caller()).mutation(S.admission.discardTest,{applicationId:ee(this.application,"application")}),this.print({discarded:this.application},u=>[{key:"discarded",value:u.discarded}]),0}if(this.application!==void 0)throw new g("applications discard-test: --all-test takes no application id");if(this.olderThan===void 0)throw new g("applications discard-test --all-test: --older-than <N>d is required");if(this.dryRun&&this.confirm)throw new g("applications discard-test: --dry-run and --confirm exclude each other");let t=TH(this.olderThan),n=await this.caller(),r=this.requireTenant(n),i=[],o=null;for(;;){let c=await n.query(S.admission.testTtlPlan,{client:r,olderThanDays:t,cursor:o});if(i.push(...c.rows),c.isDone)break;o=c.continueCursor}let a=i.map(c=>({...c,result:c.verdict!=="expired"?"kept":c.block!==null?"blocked":this.confirm?"pending":"would discard"})),l=i.filter(c=>c.verdict==="expired"&&c.protectedDemo).map(c=>c.applicationId);if(this.confirm&&l.length>0)throw new g(`applications discard-test --all-test: protected demo application(s) in the discard set, nothing discarded: ${l.join(", ")}`);let d=0;if(this.confirm)for(let c of a.filter(u=>u.result==="pending"))try{await n.mutation(S.admission.discardExpiredTest,{applicationId:c.applicationId,olderThanDays:t}),c.result="discarded"}catch(u){d++,c.result=`failed: ${u instanceof Error?u.message:String(u)}`}return this.print({olderThanDays:t,confirm:this.confirm,rows:a},c=>c.rows.map(u=>({id:u.applicationId,lastActivity:new Date(u.lastActivityAt).toISOString().slice(0,10),verdict:u.verdict,block:u.block??"",result:u.result})),["id","lastActivity","verdict","block","result"]),d>0?1:0}};function TH(e){let t=/^(\d+)d$/.exec(e.trim());if(t===null)throw new g(`--older-than "${e}": expected <N>d, e.g. 14d`);return Number(t[1])}s(TH,"parseDays");var ek=class extends P{static{s(this,"ApplicationsSetKeepDemoCommand")}static paths=[["applications","set-keep-demo"]];static usage=E.Usage({category:"Admission",description:"Mark a TEST application \u201EDemo behalten\u201C (never expires, never discarded), or clear the mark with --off"});application=f.String({required:!0});off=f.Boolean("--off",!1,{description:"Clear the mark"});async execute(){return await(await this.caller()).mutation(S.admission.setKeepAsDemo,{applicationId:ee(this.application,"application"),keep:!this.off}),this.print({application:this.application,keepAsDemo:!this.off},n=>[{key:"application",value:n.application},{key:"keep as demo",value:n.keepAsDemo?"ja":"nein"}]),0}},tk=class extends P{static{s(this,"ApplicationsStaffInputListCommand")}static paths=[["applications","staff-input","list"]];static usage=E.Usage({category:"Admission",description:"An application's internal inputs (set at the start): value, and why one can no longer be corrected"});application=f.String({required:!0});async execute(){let n=await(await this.caller()).query(S.admission.staffInputsOfApplication,{applicationId:ee(this.application,"application")});return this.print(n,r=>r.map(i=>({key:i.key,label:i.label.de,value:String(i.value),correctable:i.block===null?"ja":i.block.de})),["key","label","value","correctable"]),0}},nk=class extends P{static{s(this,"ApplicationsStaffInputSetCommand")}static paths=[["applications","staff-input","set"]];static usage=E.Usage({category:"Admission",description:"Correct one internal input of an application, with a reason \u2014 refused once a node that reads it was entered",examples:[["Untick \u201EKind von Mitarbeitenden\u201C",'plexus-cli --env prod --tenant <t> --allow-prod applications staff-input set <id> --input staffApplication=false --reason "falsch angehakt"']]});application=f.String({required:!0});input=f.String("--input",{required:!0,description:"key=true|false"});reason=f.String("--reason",{required:!0,description:"Why \u2014 recorded on the application's activity feed"});async execute(){let t=await this.caller(),[{key:n,value:r}]=wN([this.input]);return await t.mutation(S.admission.correctStaffInput,{applicationId:ee(this.application,"application"),key:n,value:r,reason:this.reason}),this.print({application:this.application,key:n,value:r},i=>[{key:"application",value:i.application},{key:i.key,value:String(i.value)}]),0}},rk=class extends P{static{s(this,"ApplicationsPurgeCommand")}static paths=[["platform","applications","purge"]];static usage=E.Usage({category:"Admission",description:"Hard-delete one real application staff started for a colleague and already deleted (plan unless --confirm). Needs _platform.config.manage.",details:"Refused unless all hold: a real application (a test one goes with `applications discard-test`), soft-deleted by staff, started by staff, its applicant an internal staff member of the school (also a switched-off one) whose person existed before, no data about anyone else (only empty drafts the form opened), nothing committed yet, and no contract, signing process, payment or Engage push. Deletes the application and every row it created; the staff member's person stays. Afterwards the responsible person can be deactivated.",examples:[["Plan","plexus-cli --env prod --tenant <slug> platform applications purge <applicationId>"],["Apply","plexus-cli --env prod --tenant <slug> --allow-prod platform applications purge <applicationId> --confirm"]]});application=f.String({required:!0});confirm=f.Boolean("--confirm",!1,{description:"Delete for good (without it, only the checks run)."});async execute(){let t=await this.caller(),n=await t.mutation(S.admission.purgeDeletedStaffApplication,{tenantSlug:this.requireTenant(t),applicationId:ee(this.application,"application"),dryRun:!this.confirm});if(this.json)return this.print(n),0;let r=this.context.stdout;return r.write(`${n.applied?"Deleted":"Would delete"} application ${n.applicationId} `),r.write(`(applicant ${n.applicantPartyId}, soft-deleted ${new Date(n.deletedAt).toISOString()})
|
|
11506
|
+
`,"references/worker-ops/set-import-default-unit.md":"# Set the default unit of an import source\n\n**When to use:** a unit that an import source uses as its default unit has to\ngo, or imported records should attach to another unit by default.\n`org unit delete` refuses the default unit of an import source\n(`[unit/importSourceDefault]`). Point the source at another unit first.\n\n## Prerequisites\n- **Auth:** a platform operator's token with `_platform.config.manage`. A\n school's own token is refused, because the import source belongs to the operator.\n- **Env:** a writing run needs `--env <local|staging|prod>` on the command line,\n and `--allow-prod` against production.\n- You need the source key (`imports status --tenant <slug>`, column `config`)\n and the new unit's config key (`org tree`, column `key`).\n\n## Steps\n\n```bash\n# Plan: shows the current default and the new one, and writes nothing\nplexus-cli --env prod --allow-prod platform imports source set-default-unit <source> --unit <unit-key>\n# Write\nplexus-cli --env prod --allow-prod platform imports source set-default-unit <source> --unit <unit-key> --confirm\n```\n\n## Verify\nRun the plan again. It reports `unchanged`, with the new unit as the default.\n\n## Idempotency / gotchas\n- The unit must be one the source already knows by key (every unit of the\n tenant at the time the source was set up). Otherwise the command refuses with\n `[import-source/unitUnknown]` and lists the keys the source knows.\n- Deleting any other unit removes it from the source's key list automatically.\n Only the default unit blocks a delete.\n- The tenant config names the default unit by key: `source.defaultUnitKey`\n (the order of `foundation.units` means nothing). `config export` writes the\n current default there, so an apply from a fresh export keeps it. **An apply\n from an export taken before this change names the old default and sets it\n back**; its plan shows an update on `source`. Export again after setting the\n default, or set `source.defaultUnitKey` in the scratch export by hand.\n- `config apply` refuses a source without `defaultUnitKey`\n (`[import/defaultUnitMissing]`) or with a key that is not in\n `foundation.units` (`[import/defaultUnitUnknown]`). There is no fallback to\n the first unit. An export taken before this change carries no key: add it before\n the apply.\n\n## Related\n- [Edit a school's organisation structure](../organization/edit-org-structure.md)\n- [Debug a stuck/failed import or worker job](./debug-worker-jobs.md)\n"};var bp="5a299a07b9e9bdea99400a3aad16ea461293a630af0878af015e0dd8b1d50726",Fw=q_;var lH=new Set(["ENOENT","ENOTDIR","EISDIR","EACCES","EPERM"]);function dH(e){return typeof e=="object"&&e!==null&&"code"in e?e.code:void 0}s(dH,"codeOf");function K_(e){return e instanceof Error?e.message:String(e)}s(K_,"messageOf");function Lw(e,t){try{return Ne(e)}catch(n){throw lH.has(dH(n))?new g(`${t}: ${e} is not readable (${K_(n)})`,{cause:n}):n}}s(Lw,"readBytesFile");function Mw(e,t){return Lw(e,t).toString("utf8")}s(Mw,"readTextFile");function ni(e,t){try{return JSON.parse(e)}catch(n){throw new g(`${t} is no JSON (${K_(n)})`,{cause:n})}}s(ni,"parseJsonText");function Ge(e,t){return ni(Mw(e,t),`${t}: ${e}`)}s(Ge,"readJsonFile");var qw=class extends Ae{static{s(this,"AgentToolsCommand")}static paths=[["agent","tools"]];static usage=E.Usage({category:"Agents",description:"Show the shared platform/CLI agent tool schemas and skill revision."});async execute(){return this.print({skillHash:bp,tools:sd}),0}},Kw=class extends Ae{static{s(this,"AgentInvokeCommand")}static paths=[["agent","invoke"]];static usage=E.Usage({category:"Agents",description:"Invoke a shared agent tool; pipe its JSON input on stdin."});tool=f.String("--tool",{required:!0,description:"plexus|plexus_skill|plexus_workspace"});async execute(){if("isTTY"in this.context.stdin&&this.context.stdin.isTTY===!0)throw new g("plexus: pipe the tool's JSON input on stdin.");let t=ni(await Dw(this.context.stdin),"stdin"),n=await this.context.executePlexusAgentTool(this.tool,t);return this.print(n),0}},j_=[qw,Kw];var jw=[{key:"fixture_test",email:"test@example.com",firstName:"Test",lastName:"Bewerber"}],Kfe=new Set(jw.map(e=>e.key));var ze=["de","en"];function sa(e,t){return ze.every(n=>e[n]===t[n])}s(sa,"sameText");function Ft(e){if(e===null||typeof e!="object"||Array.isArray(e))return"not-localized";let t=e;return Object.keys(t).some(r=>!ze.includes(r))?"not-localized":ze.filter(r=>{let i=t[r];return typeof i!="string"||i.trim()===""})}s(Ft,"missingLocales");function co(e){let t=Ft(e);return t!=="not-localized"&&t.length===0}s(co,"isLocalizedText");function ad(e,t){let n={};for(let r of ze){let i=e.map(o=>o[r]);n[r]=i.every(o=>typeof o=="string"&&o.trim()!=="")?t(i,r):""}return n}s(ad,"composeTexts");function vp(e){return e.toLowerCase().normalize("NFKD").replace(/[̀-ͯ]/g,"").replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}s(vp,"slugify");var V_="tenant";function B_(e){if(e.length===0||vp(e)!==e)return"must be lowercase a-z/0-9 words joined by single dashes";if(e===V_)return`"${V_}" is reserved for the tenant-wide scope`}s(B_,"unitSlugError");var cH=/^[a-z0-9]+(?:-[a-z0-9]+)*$/;function lr(e,t){return`${e}-${t}`}s(lr,"runStorageKey");function U_(e,t){typeof t!="string"&&de("CONFLICT",{de:`[run/keyNotServed] Das Deployment liefert f\xFCr ein Schuljahr von \u201E${e}\u201C keinen Schl\xFCssel \u2014 es l\xE4uft ein \xE4lteres Release als die CLI. Nach dem n\xE4chsten Release erneut versuchen.`,en:`[run/keyNotServed] The deployment provides no key for a school year of "${e}" \u2014 it runs an older release than the CLI. Try again after the next release.`});let n=`${e}-`;return(!t.startsWith(n)||t.length===n.length)&&de("CONFLICT",{de:`[run/foreignKey] Der Schl\xFCssel \u201E${t}\u201C des Schuljahrs liegt nicht unter dem Programm \u201E${e}\u201C (erwartet: \u201E${n}<key>\u201C).`,en:`[run/foreignKey] The key "${t}" of the school year is not under the program "${e}" (expected: "${n}<key>").`}),t.slice(n.length)}s(U_,"bareRunKey");function xp(e){let t=[],n=new Map;return e.forEach((r,i)=>{let o=Ft(r.name),a=o!=="not-localized"&&!o.includes("de")?r.name.de:void 0,l=`program.runs[${i}]${a!==void 0?` ("${a}")`:""}`;o==="not-localized"||o.length===2?t.push({code:"run/nameMissing",index:i,message:{de:`[run/nameMissing] ${l}: jedes Schuljahr braucht einen \`name\` auf Deutsch und Englisch (\`{ de, en }\`)`,en:`[run/nameMissing] ${l}: every run needs a \`name\` in German and English (\`{ de, en }\`)`}}):o.length>0&&t.push({code:"run/nameUntranslated",index:i,message:{de:`[i18n/missingTranslation] ${l}.name fehlt in: ${o.join(", ")} \u2014 jeder angezeigte Text braucht Deutsch und Englisch.`,en:`[i18n/missingTranslation] ${l}.name is missing in: ${o.join(", ")} \u2014 every displayed text needs German and English.`}});let d=r.key;if(d==null||d===""){t.push({code:"run/keyMissing",index:i,message:{de:`[run/keyMissing] ${l}: jedes Schuljahr braucht einen stabilen \`key\` \u2014 der Name dient nur der Anzeige`,en:`[run/keyMissing] ${l}: every run needs a stable \`key\` \u2014 the name is display only`}});return}if(typeof d!="string"||!cH.test(d)){t.push({code:"run/keyInvalid",index:i,message:{de:`[run/keyInvalid] ${l}: der Schl\xFCssel ${JSON.stringify(d)} muss ein kleingeschriebener Slug sein (a-z, 0-9, einzelnes \u201E-\u201C)`,en:`[run/keyInvalid] ${l}: key ${JSON.stringify(d)} must be a lowercase slug string (a-z, 0-9, single "-")`}});return}let c=n.get(d);if(c!==void 0){t.push({code:"run/duplicateKey",index:i,message:{de:`[run/duplicateKey] ${l}: der Schl\xFCssel \u201E${d}\u201C wird bereits von program.runs[${c}] verwendet`,en:`[run/duplicateKey] ${l}: key "${d}" is already used by program.runs[${c}]`}});return}n.set(d,i)}),t}s(xp,"runSpecIssues");var uH="-stufe-",fH=/^[a-z0-9]+(?:-[a-z0-9]+)*$/;function Vw(e){return`${e}${uH}`}s(Vw,"stageKeyPrefix");function aa(e,t){return`${Vw(e)}${t}`}s(aa,"stageStorageKey");function z_(e,t){let n=Vw(e);return t.startsWith(n)&&t.length>n.length}s(z_,"isUnderProgram");function ri(e,t){let n=Vw(e);return z_(e,t)||de("CONFLICT",{de:`[stage/foreignKey] Der Stufenschl\xFCssel \u201E${t}\u201C liegt nicht unter dem Programm \u201E${e}\u201C (erwartet: \u201E${n}<key>\u201C). F\xFChren Sie die Stufe in bundle.yaml unter einem neuen Schl\xFCssel auf; der n\xE4chste Apply archiviert diese Zeile (hinter der Archivsperre) und legt die Stufe mit dem neuen Schl\xFCssel an.`,en:`[stage/foreignKey] The level key "${t}" is not under the program "${e}" (expected: "${n}<key>"). List the level in bundle.yaml under a new key; the next apply archives this row (behind the archive lock) and creates the level with the new key.`}),t.slice(n.length)}s(ri,"bareStageKey");function Sp(e){let t=[],n=new Map;return e.forEach((r,i)=>{let o=Ft(r.name),a=o!=="not-localized"&&!o.includes("de")?r.name.de:void 0,l=`program.stages[${i}]${a!==void 0?` ("${a}")`:""}`;o==="not-localized"||o.length===2?t.push({code:"stage/nameMissing",index:i,message:{de:`[stage/nameMissing] ${l}: jede Klassenstufe braucht einen \`name\` auf Deutsch und Englisch (\`{ de, en }\`)`,en:`[stage/nameMissing] ${l}: every stage needs a \`name\` in German and English (\`{ de, en }\`)`}}):o.length>0&&t.push({code:"stage/nameUntranslated",index:i,message:{de:`[i18n/missingTranslation] ${l}.name fehlt in: ${o.join(", ")} \u2014 jeder angezeigte Text braucht Deutsch und Englisch.`,en:`[i18n/missingTranslation] ${l}.name is missing in: ${o.join(", ")} \u2014 every displayed text needs German and English.`}});let d=r.key;if(d==null||d===""){t.push({code:"stage/keyMissing",index:i,message:{de:`[stage/keyMissing] ${l}: jede Klassenstufe braucht einen stabilen \`key\` \u2014 der Name dient nur der Anzeige`,en:`[stage/keyMissing] ${l}: every stage needs a stable \`key\` \u2014 the name is display only`}});return}if(typeof d!="string"||!fH.test(d)){t.push({code:"stage/keyInvalid",index:i,message:{de:`[stage/keyInvalid] ${l}: der Schl\xFCssel ${JSON.stringify(d)} muss ein kleingeschriebener Slug sein (a-z, 0-9, einzelnes \u201E-\u201C)`,en:`[stage/keyInvalid] ${l}: key ${JSON.stringify(d)} must be a lowercase slug string (a-z, 0-9, single "-")`}});return}let c=n.get(d);if(c!==void 0){t.push({code:"stage/duplicateKey",index:i,message:{de:`[stage/duplicateKey] ${l}: der Schl\xFCssel \u201E${d}\u201C wird bereits von program.stages[${c}] verwendet`,en:`[stage/duplicateKey] ${l}: key "${d}" is already used by program.stages[${c}]`}});return}n.set(d,i)}),t}s(Sp,"stageSpecIssues");function G_(e){return{de:e.de.trim(),en:e.en.trim()}}s(G_,"trimmedText");function pH(e,t){let n=[];return e.de!==t.de&&n.push(`"${e.de}" \u2192 "${t.de}"`),e.en!==t.en&&n.push(`en "${e.en}" \u2192 "${t.en}"`),n.join(", ")}s(pH,"describeNameChange");function Ap(e,t,n){if(e===null)return t.length>0&&D("planStageReconcile: stages exist but the offer has no program key"),n.map((a,l)=>({op:"insert",key:a.key,name:G_(a.name),...a.gradeLevel!==void 0?{gradeLevel:a.gradeLevel}:{},sequence:l+1}));let r=new Map(t.map(a=>[a.key,a])),i=new Set,o=[];n.forEach(({name:a,...l},d)=>{let c={...l,name:G_(a)},u=aa(e,c.key);i.add(u);let p=d+1,h=r.get(u);if(h===void 0){o.push({op:"insert",key:c.key,name:c.name,...c.gradeLevel!==void 0?{gradeLevel:c.gradeLevel}:{},sequence:p});return}let y={};sa(h.name,c.name)||(y.name=[h.name,c.name]);let b=h.gradeLevel??null,k=c.gradeLevel??null;b!==k&&(y.gradeLevel=[b,k]),h.sequence!==p&&(y.sequence=[h.sequence,p]),(Object.keys(y).length>0||h.archived)&&o.push({op:"update",key:c.key,stageId:h.stageId,name:c.name,changes:y,unarchive:h.archived})});for(let a of[...t].sort((l,d)=>l.sequence-d.sequence))a.archived||i.has(a.key)||o.push({op:"archive",key:z_(e,a.key)?ri(e,a.key):a.key,stageId:a.stageId,name:a.name});return o}s(Ap,"planStageReconcile");function Tp(e){switch(e.op){case"insert":return`+stage ${e.key} (${e.name.de})`;case"archive":{let t=e.occupancy,n=[...t&&t.activeApplications>0?[`REFUSED: ${t.activeApplications} active application(s) \u2014 [stage/hasActiveApplications]`]:[],...t&&t.openLeads>0?[`${t.openLeads} open lead(s)`]:[]];return`-stage ${e.key} (${e.name.de})${n.length>0?` \u2014 ${n.join("; ")}`:""}`}case"update":{let t=[];if(e.unarchive&&t.push("restored"),e.changes.name&&t.push(pH(e.changes.name[0],e.changes.name[1])),e.changes.gradeLevel){let[n,r]=e.changes.gradeLevel;t.push(`grade ${n??"\u2013"} \u2192 ${r??"\u2013"}`)}return e.changes.sequence&&t.push(`position ${e.changes.sequence[0]} \u2192 ${e.changes.sequence[1]}`),`~stage ${e.key} (${t.join(", ")})`}}}s(Tp,"describeStageStep");function Rp(e,t){return t.startsWith(e)&&t.length>e.length?t.slice(e.length):void 0}s(Rp,"bareUnder");function Y_(e,t,n,r){let i=e.flatMap(y=>y.angebote).find(y=>y.offerKey===t);if(i===void 0){let y=e.flatMap(b=>b.angebote.map(k=>k.offerKey));throw new g(`applications start-test: no offer "${t}" (offers: ${y.join(", ")||"none"})`)}if(i.programKey===void 0)throw new g("applications start-test: the deployment does not serve the offer's program key \u2014 it runs an older release than the CLI; try again after the next release");let o=i.programKey;if(o===null)throw new g(`applications start-test: ${t} has no program yet \u2014 no level to start on`);let a=aa(o,""),l=lr(o,""),d=s(y=>Rp(a,y)??"(no bundle key)","stageLabel"),c=s(y=>Rp(l,y)??"(no bundle key)","runLabel"),u=i.stages.find(y=>y.stageKey===aa(o,r)||y.stageId===r);if(u===void 0){let y=i.stages.map(v=>`${d(v.stageKey)} (${v.stageId})`).join(", "),b=Rp(a,r),k=b!==void 0&&i.stages.some(v=>v.stageKey===r)?` \u2014 "${r}" is the stored key; the export names it "${b}"`:"";throw new g(`applications start-test: no level "${r}" in ${t}${k} \u2014 name it by its bundle key or id: ${y}`)}let p=d(u.stageKey),h=u.runs.find(y=>y.runKey===lr(o,n)||y.runId===n);if(h===void 0){let y=u.runs.map(v=>`${c(v.runKey)} (${v.runId})`).join(", "),b=Rp(l,n),k=b!==void 0&&u.runs.some(v=>v.runKey===n)?` \u2014 "${n}" is the stored key; the export names it "${b}"`:"";throw new g(`applications start-test: no school year "${n}" for level ${p}${k} \u2014 name it by its bundle key or id: ${y}`)}if(!h.isOpen)throw new g(`applications start-test: school year ${c(h.runKey)} is closed for level ${p}`);return{programRunId:h.runId,programStageId:u.stageId}}s(Y_,"resolveStartTarget");function mH(e){return e.kind==="named"?e.name:`(${e.standIn??e.fallback})`}s(mH,"applicantText");function H_(e){return e.map(t=>({id:t.application._id,status:t.deletedAt?`${t.application.status} (gel\xF6scht)`:t.application.status,state:t.currentProcessStateId??"",applicant:mH(t.applicantName),test:t.application.testMode===!0?"test":""}))}s(H_,"applicationRows");var W_=jw.map(e=>e.email);function J_(e,t,n,r){if(n===void 0&&r===void 0)throw new g("applications start-test: name the applicant \u2014 --party <partyId> or --applicant <email>");if(n!==void 0&&r!==void 0)throw new g("applications start-test: --party or --applicant, not both");if(Nw(e,t)&&(r===void 0||!W_.includes(r.trim().toLowerCase())))throw new g(`applications start-test: on prod only for the test account ${W_.join(", ")} (--applicant) \u2014 never a real family's`)}s(J_,"assertStartApplicant");function Q_(e){let t={};for(let{address:n,...r}of e.entries)t[n]=r;return{applicationId:e.applicationId,store:t}}s(Q_,"processStoreJson");function hH(e){switch(e.kind){case"form":return`form ${e.formInstanceId} (${e.state})`;case"document":return e.file===null?`document ${e.slotKey} (leer)`:`document ${e.slotKey} \xB7 v${e.file.versionNumber} ${e.file.filename??e.file.artifactId}`;case"contract":return`contract ${e.contractId} \xB7 ${e.revision===null?"keine Fassung":`Fassung ${e.revision.snapshotNumber}`} \xB7 ${e.contractStatus}`;case"contracts":return e.contracts.map(t=>`${t.partKey}: contract ${t.contractId} \xB7 ${t.revision===null?"keine Fassung":`Fassung ${t.revision.snapshotNumber}`} \xB7 ${t.contractStatus}`).join("; ")}}s(hH,"refText");function gH(e){return e.state!=="present"?e.reason?.de??"":e.ref!==void 0?hH(e.ref):JSON.stringify(e.value)}s(gH,"holds");function Z_(e){return e.entries.map(t=>({address:t.address,state:t.state,holds:gH(t),producer:t.producer?.label??"",written:t.writtenAt===void 0?"":new Date(t.writtenAt).toISOString()}))}s(Z_,"storeRows");function $p(e){let t={},n={};for(let r of e){let i=r.indexOf("=");if(i<=0)throw new g(`Expected key=value, got '${r}'.`);let o=r.slice(0,i);if(Object.hasOwn(n,o))throw new g(`'${o}' is given twice.`);let a=r.slice(i+1);n[o]=a;try{t[o]=JSON.parse(a)}catch{t[o]=a}}return{values:t,raw:n}}s($p,"parseKv");var Bw="started",Ep="submitted",Ip="submitted",X_="load-scenario:";var eN="(Bewerbung)";function tN(e){return{nodeId:eN,actions:e.map(t=>({id:t.id,label:{de:`${t.label??t.id}${t.count===void 0?"":` (${t.count})`}`,en:`${t.label??t.id}${t.count===void 0?"":` (${t.count})`}`},...t.disabledReason===void 0?{}:{disabledReason:t.disabledReason}}))}}s(tN,"sharedAsList");function nN(e){return e.disabledReason===void 0?"":e.disabledCount===void 0?e.disabledReason:`${e.disabledReason} (${e.disabledCount})`}s(nN,"disabledText");function rN(e){return e.flatMap(({nodeId:t,actions:n})=>n.map(r=>({node:t,action:r.id,label:r.label.de,disabled:nN(r)})))}s(rN,"actionRows");function iN(e,t,n=[]){let r=e.filter(({actions:d})=>d.some(c=>c.id===t));if(r.length===0){let d=[...new Set(e.flatMap(({actions:c})=>c.map(u=>u.id)))];throw new g(`test-actions run: no current node offers "${t}" (offered: ${d.join(", ")||"nothing"})`)}if(r.length>1)throw new g(`test-actions run: "${t}" is offered by ${r.map(d=>d.nodeId).join(", ")} \u2014 pass --node`);let{nodeId:i,actions:o}=r[0],a=o.find(d=>d.id===t);if(a.disabledReason!==void 0)throw new g(`test-actions run: "${t}" on ${i} is disabled: ${nN(a)}`);if(i!==eN)return i;let l=n[0];if(l===void 0)throw new g(`test-actions run: "${t}" needs a current node \u2014 the application has none`);return l}s(iN,"nodeOfferingAction");function oN(e,t,n){if(e.startsWith(X_)){if(Object.hasOwn(n,"autoSubmit"))throw new g(`test-actions run: ${e}: a scenario's autoSubmit is set by --auto-submit / --no-auto-submit, not --param`);return{autoSubmit:t,...n}}return Object.keys(n).length===0?void 0:{...n}}s(oN,"runParams");var yH=/^[0-9a-hjkmnp-tv-z]{31,37}$/;function ee(e,t){if(!yH.test(e))throw new g(`"${e}" is not a ${t} id \u2014 a Convex id is 31\u201337 characters of 0-9 and a-z without i, l, o, u.`);return e}s(ee,"parseDocumentId");async function wH(e,t){let n=await e.query(S.workflow.getInstance,{applicationId:t});if(n===null)throw new g(`test-actions: application ${t} has no workflow instance`);return n.instance.currentNodeIds}s(wH,"currentNodeIds");function kH(e,t){switch(t){case"notTestApplication":return`${e} is not a test application`;case"completed":case"aborted":case"deleted":return`${e} is ${t} \u2014 test actions run only on an active application`;case"missingPermission":return"the caller lacks bewerbungsmanagement.testActions.run"}}s(kH,"refusalText");async function Op(e,t,n){let r=await e.query(S.workflow.listSharedTestActions,{applicationId:t});if(!r.permitted)throw new g(`test-actions: not permitted \u2014 ${kH(t,r.reason)}`);let i=[];for(let o of n){let a=await e.query(S.workflow.listTestActions,{applicationId:t,nodeId:o});if(a===null)throw new g(`test-actions: node "${o}" is not in this application's workflow (or it has no instance)`);i.push({nodeId:o,actions:a})}return[...i,tN(r.actions)]}s(Op,"actionsOf");async function sN(e,t,n){return n!==void 0?[n]:await wH(e,t)}s(sN,"nodesOf");var Uw=class extends P{static{s(this,"TestActionsListCommand")}static paths=[["test-actions","list"]];static usage=E.Usage({category:"Admission",description:"List the test-mode actions of the application's current node(s) (scenarios, auto-fill-files, submit, \u2026) and the application-wide ones"});application=f.String("--application",{required:!0,description:"Application id (a test application)"});node=f.String("--node",{description:"Node id (default: the application's current nodes)"});async execute(){let t=ee(this.application,"application"),n=await this.caller(),r=await Op(n,t,await sN(n,t,this.node));return this.print(r,rN,["node","action","label","disabled"]),0}},Gw=class extends P{static{s(this,"TestActionsRunCommand")}application=f.String("--application",{required:!0,description:"Application id (a test application)"});node=f.String("--node",{description:"Node id (default: the application's current nodes)"});static paths=[["test-actions","run"]];static usage=E.Usage({category:"Admission",description:"Run one test-mode action; a scenario (load-scenario:<id>) also submits unless --no-auto-submit"});action=f.String("--action",{required:!0,description:"Action id, e.g. load-scenario:standard, auto-fill-files, submit-form"});autoSubmit=f.Boolean("--auto-submit",!0,{description:"Scenario only: stub the file fields and submit after loading (default on; --no-auto-submit only loads)"});param=f.Array("--param",{description:"Action parameter key=value (repeatable; the value is JSON where it parses, else text), e.g. --param confirmed=true for an action that asks a question first (its `confirm` in `test-actions list`)"});async execute(){let t=oN(this.action,this.autoSubmit,$p(this.param??[]).values),n=ee(this.application,"application"),r=await this.caller(),i=await sN(r,n,this.node),o=iN(await Op(r,n,i),this.action,i);return await r.mutation(S.workflow.runTestAction,{applicationId:n,nodeId:o,actionId:this.action,...t===void 0?{}:{params:t}}),this.print({ran:this.action,on:o},a=>[{key:"ran",value:a.ran},{key:"on",value:a.on},{key:"next",value:"test-actions list \u2014 file fills and the submit after them run asynchronously"}]),0}},aN=[Uw,Gw];var Or=/^[a-z][A-Za-z0-9]*$/;function zw(e){return typeof e=="string"&&Or.test(e)}s(zw,"isNodeId");function la(e,t){zw(e)||D(`[graph/nodeIdFormat] "${e}" cannot name a node: a node id is ${Or.source}.`);let n=new Set(t);if(!n.has(e))return e;let r=2;for(;n.has(`${e}${r}`);)r++;return`${e}${r}`}s(la,"makeNodeId");var fo="$env";function ce(e){if(e.scope==="env")return`${fo}.${e.key}`;let t=`$${e.scope}.${e.owner}.${e.key}`;return e.path===void 0?t:`${t}.${e.path}`}s(ce,"formatAddress");var uo=/^[a-z][a-zA-Z0-9_]*$/,bH=/^[A-Za-z_][A-Za-z0-9_]*$/;function Ho(e){return typeof e=="string"&&e.split(".").every(t=>bH.test(t))}s(Ho,"isPath");function Si(e){if(!e.startsWith("$"))return null;let t=e.slice(1).split("."),[n,...r]=t;switch(n){case"env":{let i=r.join(".");return r.length>0&&Ho(i)?{scope:"env",key:i}:null}case"node":case"task":{let[i,o,...a]=r;return i===void 0||o===void 0||!uo.test(o)||(n==="node"?!Or.test(i):!uo.test(i))?null:vH({scope:n,owner:i,key:o},a)}default:return null}}s(Si,"tryParseAddress");function vH(e,t){if(t.length===0)return e;let n=t.join(".");return Ho(n)?{...e,path:n}:null}s(vH,"withPath");function ke(e){if(typeof e!="object"||e===null||Array.isArray(e))return!1;let t=e,n=t.scope==="env"?["scope","key"]:["scope","owner","key","path"];if(Object.keys(t).some(r=>!n.includes(r))||t.path!==void 0&&!Ho(t.path))return!1;switch(t.scope){case"env":return Ho(t.key);case"node":return typeof t.owner=="string"&&Or.test(t.owner)&&typeof t.key=="string"&&uo.test(t.key);case"task":return typeof t.owner=="string"&&uo.test(t.owner)&&typeof t.key=="string"&&uo.test(t.key);default:return!1}}s(ke,"isAddress");var po={offer:{key:"string",title:"string"},unit:{key:"string",name:"string"},stage:{key:"string",name:"string",gradeLevel:"number"},run:{key:"string",name:"string",startDate:"date"},applicant:{language:"enum",channel:"enum"}},da=Object.keys(po);function mo(e){return Object.hasOwn(po,e)}s(mo,"isEnvKey");var Ww=["self-service","staff"];function lN(e,t){return{kind:"fixed",values:e,labels:t}}s(lN,"fixedSet");var _p={of:"applicant.language",withoutValue:"de"},Ai={"offer.key":{valueSet:{kind:"live"},nullable:!1,label:{de:"Angebot",en:"Offer"}},"offer.title":{valueSet:{kind:"unstable"},nullable:!1,label:{de:"Titel des Angebots",en:"Offer title"},nameLanguage:_p},"unit.key":{valueSet:{kind:"live"},nullable:!1,label:{de:"Einheit",en:"Unit"}},"unit.name":{valueSet:{kind:"unstable"},nullable:!1,label:{de:"Name der Einheit",en:"Unit name"},nameLanguage:_p},"stage.key":{valueSet:{kind:"unstable"},nullable:!1,label:{de:"Klassenstufe (Schl\xFCssel)",en:"Grade (key)"},cohortBound:!0},"stage.name":{valueSet:{kind:"unstable"},nullable:!1,label:{de:"Name der Klassenstufe",en:"Grade name"},cohortBound:!0,nameLanguage:_p},"stage.gradeLevel":{valueSet:{kind:"open"},nullable:!0,absent:{de:"Die Stufe hat keine Klassenstufe (Kindergarten).",en:"The stage has no grade level (Kindergarten)."},label:{de:"Klassenstufe",en:"Grade level"},cohortBound:!0},"run.key":{valueSet:{kind:"unstable"},nullable:!1,label:{de:"Schuljahr",en:"School year"},cohortBound:!0},"run.name":{valueSet:{kind:"unstable"},nullable:!1,label:{de:"Name des Schuljahrs",en:"School year name"},cohortBound:!0,nameLanguage:_p},"run.startDate":{valueSet:{kind:"open"},nullable:!0,absent:{de:"F\xFCr das Schuljahr ist kein Beginn erfasst.",en:"The school year has no start date."},label:{de:"Beginn des Schuljahrs",en:"School year start"},cohortBound:!0},"applicant.language":{valueSet:lN(ze,{de:{de:"Deutsch",en:"German"},en:{de:"Englisch",en:"English"}}),nullable:!0,absent:{de:"Die Bewerbung hat kein Bewerberkonto (intern angelegt).",en:"The application has no applicant account (started by staff)."},label:{de:"Bewerbersprache",en:"Applicant language"}},"applicant.channel":{valueSet:lN(Ww,{staff:{de:"intern",en:"in-house"},"self-service":{de:"online (Familie)",en:"online (family)"}}),nullable:!1,label:{de:"Eingangsweg",en:"Intake channel"}}},Np={types:po,fields:Ai},Pp=da.flatMap(e=>Object.keys(po[e]).map(t=>`${e}.${t}`));function dr(e){return Object.hasOwn(Ai,e)}s(dr,"isEnvLeaf");function Cp(e){return`${fo}.${e}`}s(Cp,"envIdentifier");function Jo(e){let t=Ai[e],[n,r]=e.split("."),i=po[n][r];i===void 0&&D(`[env] leaf "${e}" has no type`);let o=t.valueSet;return{leaf:e,type:i,label:t.label,nullable:t.nullable,...t.absent===void 0?{}:{absent:t.absent},...t.nameLanguage===void 0?{}:{nameLanguage:t.nameLanguage},...t.cohortBound===void 0?{}:{cohortBound:t.cohortBound},...o.kind==="fixed"?{enumOptions:o.values.map(a=>{let l=o.labels[a];return l===void 0&&D(`[env] "${e}" names the value "${a}" without a label`),{value:a,label:l}})}:{}}}s(Jo,"envLeaf");var dN="staffInput";var xH=["boolean"],ld=/^[a-z][A-Za-z0-9]*$/;function Dp(e){return e.staffInputs??[]}s(Dp,"staffInputsOf");function Fp(e){return`${dN}.${e}`}s(Fp,"staffInputLeaf");function cN(e){return`${fo}.${Fp(e)}`}s(cN,"staffInputIdentifier");function SH(e){let t=`${dN}.`;return e.startsWith(t)?e.slice(t.length):null}s(SH,"staffInputKeyOfLeaf");function ca(e,t){let n=SH(t);return n===null?void 0:Dp(e).find(r=>r.key===n)}s(ca,"declaredStaffInput");function uN(e){return[...Dp(e).map(t=>({leaf:Fp(t.key),type:t.type,label:t.label,valueSet:{kind:"open"},nullable:!1,cohortBound:!1})),...Pp.map(t=>{let n=Jo(t);return{leaf:t,type:n.type,label:n.label,valueSet:Ai[t].valueSet,nullable:n.nullable,cohortBound:n.cohortBound===!0}})]}s(uN,"envLeavesFor");function fN(e){return uN(e).filter(t=>!t.cohortBound)}s(fN,"conditionEnvLeaves");function pN(e){return hN(fN(e))}s(pN,"envConditionSchemaFor");function AH(e){return uN(e).map(t=>t.leaf==="stage.key"?{...t,valueSet:{kind:"open"}}:t)}s(AH,"offerConditionEnvLeaves");function mN(e){return hN(AH(e))}s(mN,"offerConditionSchemaFor");function hN(e){let t={},n={};for(let{leaf:r,type:i,valueSet:o,nullable:a}of e){let[l="",d=""]=r.split(".");t[l]={...t[l]??{},[d]:i},n[r]={valueSet:o,nullable:a}}return{types:t,fields:n}}s(hN,"schemaOfLeaves");function gN(e){let t=e.staffInputs;if(t===void 0)return[];if(!Array.isArray(t))return[{path:"staffInputs",reason:{de:"[staffInput/shape] graph.staffInputs muss eine Liste sein.",en:"[staffInput/shape] graph.staffInputs must be a list."}}];let n=[],r=new Set;return t.forEach((i,o)=>{let a=`staffInputs[${o}]`,l=i;if(l===null||typeof l!="object"||typeof l.key!="string"){n.push({path:a,reason:{de:"[staffInput/shape] Eine interne Angabe braucht key, type und label ({ de, en }).",en:"[staffInput/shape] An internal entry needs key, type and label ({ de, en })."}});return}let d={de:`Interne Angabe "${l.key}"`,en:`Internal entry "${l.key}"`};ld.test(l.key)||n.push({path:`${a}.key`,reason:{de:`[staffInput/keyFormat] ${d.de}: Schl\xFCssel beginnt mit einem Kleinbuchstaben und enth\xE4lt nur Buchstaben und Ziffern.`,en:`[staffInput/keyFormat] ${d.en}: the key starts with a lowercase letter and contains only letters and digits.`}}),r.has(l.key)&&n.push({path:`${a}.key`,reason:{de:`[staffInput/duplicateKey] ${d.de}: Schl\xFCssel ist doppelt vergeben.`,en:`[staffInput/duplicateKey] ${d.en}: the key is used twice.`}}),r.add(l.key),xH.includes(l.type)||n.push({path:`${a}.type`,reason:{de:`[staffInput/unknownType] ${d.de}: Typ "${String(l.type)}" \u2014 erlaubt ist nur "boolean" (K\xE4stchen).`,en:`[staffInput/unknownType] ${d.en}: type "${String(l.type)}" \u2014 only "boolean" (checkbox) is allowed.`}});let c=Ft(l.label);c==="not-localized"?n.push({path:`${a}.label`,reason:{de:`[staffInput/shape] ${d.de}: label muss { de, en } sein.`,en:`[staffInput/shape] ${d.en}: label must be { de, en }.`}}):c.length>0&&n.push({path:`${a}.label`,reason:{de:`[i18n/missingTranslation] ${d.de}: Beschriftung fehlt in ${c.join(", ")}.`,en:`[i18n/missingTranslation] ${d.en}: label is missing in ${c.join(", ")}.`}})}),n}s(gN,"staffInputIssues");function Lt(e,t){if(e instanceof $e)return new $e(t(e.message),{cause:e});if(e instanceof g)return new g(t(e.message),{cause:e});let n=ar(e);if(n!==null&&(n.message.de!==""||n.message.en!=="")){let r=e.data,i=typeof r=="string"?t(r):{...r,message:{de:n.message.de===""?"":t(n.message.de),en:n.message.en===""?"":t(n.message.en)}},o=new Dt(i);return o.cause=e,o}return new Error(t(Wl(e)),{cause:e})}s(Lt,"withContext");var ik={required:!0,description:"Offer slug (its offerKey)"},Yw=class extends P{static{s(this,"ApplicationsListCommand")}static paths=[["applications","list"]];static usage=E.Usage({category:"Admission",description:"List an offer's applications (id, status, board state, applicant, test)"});offer=f.String("--offer",ik);testOnly=f.Boolean("--test-only",!1,{description:"Only test applications"});async execute(){let t=await this.caller(),n=await t.query(S.admission.listForAngebot,{client:this.requireTenant(t),offerKey:this.offer}),r=H_(n).filter(i=>!this.testOnly||i.test==="test");return this.print(r,i=>i,["id","status","state","applicant","test"]),0}},Hw=class extends P{static{s(this,"ApplicationsCountsCommand")}static paths=[["applications","counts"]];static usage=E.Usage({category:"Admission",description:"Count an offer's applications per list"});offer=f.String("--offer",ik);async execute(){let t=await this.caller(),n=await t.query(S.admission.getCountsByListForAngebot,{client:this.requireTenant(t),offerKey:this.offer});return this.print(n,r=>[...Object.entries(r.counts).map(([i,o])=>({list:i,count:String(o)})),{list:"total",count:String(r.total)}],["list","count"]),0}},Jw=class extends P{static{s(this,"ApplicationsShowCommand")}static paths=[["applications","show"]];static usage=E.Usage({category:"Admission",description:"One application: status, test flag, offer, current workflow nodes"});application=f.String({required:!0});async execute(){let t=await this.caller(),n=ee(this.application,"application"),r=await t.query(S.admission.get,{applicationId:n});if(r===null)throw new g(`applications show: no application ${n} (or not visible to you)`);let i=await t.query(S.workflow.getInstance,{applicationId:n});return this.print({application:r,currentNodes:i?.instance.currentNodeIds??[]},o=>[{key:"id",value:n},{key:"status",value:o.application.status},{key:"test",value:o.application.testMode?"ja":"nein"},{key:"offer",value:o.application.offerId},{key:"current nodes",value:o.currentNodes.join(", ")}]),0}},Qw=class extends P{static{s(this,"ApplicationsStoreCommand")}static paths=[["applications","store"]];static usage=E.Usage({category:"Admission",description:"One application's process store: every address of its pinned graph, resolved (present / pending / absent)",details:"Staff only (applications.manage). --json prints one object keyed by the canonical address ($node\u2026, $task\u2026, $env\u2026). Values are shown whatever their audience \u2014 never hand the output to the family. Recipe: playbooks/applications/inspect-process-store.md."});application=f.String({required:!0});async execute(){let n=await(await this.caller()).query(S.processStoreView.get,{applicationId:ee(this.application,"application")});return this.print(Q_(n),()=>Z_(n),["address","state","holds","producer","written"]),0}},Zw=class extends P{static{s(this,"ApplicationsStartTestCommand")}static paths=[["applications","start-test"]];static usage=E.Usage({category:"Admission",description:"Start a TEST application for an applicant (school year and level by key or id) and show what test mode offers next",details:"Always test mode. --applicant names the account by its login address (on prod only the tenant's test account); --party names the applicant party directly. Without --version it runs on the live generation, like the cockpit."});offer=f.String("--offer",ik);run=f.String("--run",{required:!0,description:"School year: its bundle key as offer export shows it (program.runs[].key) or id \u2014 never its name"});stage=f.String("--stage",{required:!0,description:"Level: its bundle key as offer export shows it (program.stages[].key) or id \u2014 never its name"});party=f.String("--party",{description:"Applicant party id"});applicant=f.String("--applicant",{description:"Applicant account login address (e.g. the test account test@example.com)"});version=f.String("--version",{description:"Offer version id to test (default: the live generation)"});staffInput=f.Array("--staff-input",{description:"A staff input the offer declares, as key=true|false \u2014 repeat it once per input; a staff start must set every one"});proxy=f.Boolean("--proxy",{description:"Start in Stellvertretung (--proxy) or not (--no-proxy); left out, the tenant's default applies, as in the cockpit"});async execute(){let t=await this.caller();J_(this.resolvedTarget(),this.prodUrls(),this.party,this.applicant);let n=this.requireTenant(t),r=Y_(await t.query(S.admission.listAdmissionTree,{client:n}),this.offer,this.run,this.stage),i=this.party===void 0?void 0:ee(this.party,"party");if(this.applicant!==void 0){let d=await t.query(S.applicants.partyByEmail,{client:n,email:this.applicant});if(d===null)throw new g(`applications start-test: no applicant account ${this.applicant} at this school (create it in the cockpit first)`);i=d}let o=await t.mutation(S.admission.staffStartApplicationForParty,{client:n,offerKey:this.offer,partyId:i,programRunId:r.programRunId,programStageId:r.programStageId,...this.proxy===void 0?{}:{startInProxy:this.proxy},staffInputs:wN(this.staffInput??[]),testMode:!0,...this.version===void 0?{}:{offerVersionId:ee(this.version,"offer version")}}),a,l;try{let d=await t.query(S.workflow.getInstance,{applicationId:o.applicationId});if(d===null)throw new Error("the started application has no workflow instance");a=d.instance.currentNodeIds,l=(await Op(t,o.applicationId,a)).flatMap(c=>c.actions.map(u=>u.id))}catch(d){throw Lt(d,c=>`applications start-test: started ${o.applicationId}, but reading its state failed: ${c}`)}return this.print({applicationId:o.applicationId,currentNodes:a,testActions:l},d=>[{key:"application",value:d.applicationId},{key:"current nodes",value:d.currentNodes.join(", ")},{key:"test actions",value:d.testActions.join(", ")},{key:"next",value:`test-actions run --application ${d.applicationId} --action <id>`}]),0}},Xw=class extends P{static{s(this,"ApplicationsDiscardTestCommand")}static paths=[["applications","discard-test"]];static usage=E.Usage({category:"Admission",description:"Discard a TEST application (the server refuses a real one), or with --all-test every expired one of the school",details:"With an id: discards that test application. With --all-test --older-than <N>d: lists the school's test applications whose last activity is older than N days (N \u2265 14) and that are not kept as a demo \u2014 a dry run unless --confirm; --confirm discards each expired one the server re-checks, the rest are reported with the reason. Recipe: playbooks/applications/expire-test-applications.md.",examples:[["Dry run","plexus-cli --env prod --tenant <t> applications discard-test --all-test --older-than 14d --dry-run"],["Discard","plexus-cli --env prod --tenant <t> --allow-prod applications discard-test --all-test --older-than 14d --confirm"]]});application=f.String({required:!1});allTest=f.Boolean("--all-test",!1,{description:"Every expired test application of the school instead of one id"});olderThan=f.String("--older-than",{description:"With --all-test: days without activity, as <N>d (N \u2265 14)"});dryRun=f.Boolean("--dry-run",!1,{description:"With --all-test: list only (the default)"});confirm=f.Boolean("--confirm",!1,{description:"With --all-test: discard (else the dry run)"});async execute(){if(!this.allTest){if(this.application===void 0)throw new g("applications discard-test: name an application id, or use --all-test --older-than <N>d");if(this.olderThan!==void 0||this.dryRun||this.confirm)throw new g("applications discard-test: --older-than, --dry-run and --confirm belong to --all-test");return await(await this.caller()).mutation(S.admission.discardTest,{applicationId:ee(this.application,"application")}),this.print({discarded:this.application},u=>[{key:"discarded",value:u.discarded}]),0}if(this.application!==void 0)throw new g("applications discard-test: --all-test takes no application id");if(this.olderThan===void 0)throw new g("applications discard-test --all-test: --older-than <N>d is required");if(this.dryRun&&this.confirm)throw new g("applications discard-test: --dry-run and --confirm exclude each other");let t=TH(this.olderThan),n=await this.caller(),r=this.requireTenant(n),i=[],o=null;for(;;){let c=await n.query(S.admission.testTtlPlan,{client:r,olderThanDays:t,cursor:o});if(i.push(...c.rows),c.isDone)break;o=c.continueCursor}let a=i.map(c=>({...c,result:c.verdict!=="expired"?"kept":c.block!==null?"blocked":this.confirm?"pending":"would discard"})),l=i.filter(c=>c.verdict==="expired"&&c.protectedDemo).map(c=>c.applicationId);if(this.confirm&&l.length>0)throw new g(`applications discard-test --all-test: protected demo application(s) in the discard set, nothing discarded: ${l.join(", ")}`);let d=0;if(this.confirm)for(let c of a.filter(u=>u.result==="pending"))try{await n.mutation(S.admission.discardExpiredTest,{applicationId:c.applicationId,olderThanDays:t}),c.result="discarded"}catch(u){d++,c.result=`failed: ${u instanceof Error?u.message:String(u)}`}return this.print({olderThanDays:t,confirm:this.confirm,rows:a},c=>c.rows.map(u=>({id:u.applicationId,lastActivity:new Date(u.lastActivityAt).toISOString().slice(0,10),verdict:u.verdict,block:u.block??"",result:u.result})),["id","lastActivity","verdict","block","result"]),d>0?1:0}};function TH(e){let t=/^(\d+)d$/.exec(e.trim());if(t===null)throw new g(`--older-than "${e}": expected <N>d, e.g. 14d`);return Number(t[1])}s(TH,"parseDays");var ek=class extends P{static{s(this,"ApplicationsSetKeepDemoCommand")}static paths=[["applications","set-keep-demo"]];static usage=E.Usage({category:"Admission",description:"Mark a TEST application \u201EDemo behalten\u201C (never expires, never discarded), or clear the mark with --off"});application=f.String({required:!0});off=f.Boolean("--off",!1,{description:"Clear the mark"});async execute(){return await(await this.caller()).mutation(S.admission.setKeepAsDemo,{applicationId:ee(this.application,"application"),keep:!this.off}),this.print({application:this.application,keepAsDemo:!this.off},n=>[{key:"application",value:n.application},{key:"keep as demo",value:n.keepAsDemo?"ja":"nein"}]),0}},tk=class extends P{static{s(this,"ApplicationsStaffInputListCommand")}static paths=[["applications","staff-input","list"]];static usage=E.Usage({category:"Admission",description:"An application's internal inputs (set at the start): value, and why one can no longer be corrected"});application=f.String({required:!0});async execute(){let n=await(await this.caller()).query(S.admission.staffInputsOfApplication,{applicationId:ee(this.application,"application")});return this.print(n,r=>r.map(i=>({key:i.key,label:i.label.de,value:String(i.value),correctable:i.block===null?"ja":i.block.de})),["key","label","value","correctable"]),0}},nk=class extends P{static{s(this,"ApplicationsStaffInputSetCommand")}static paths=[["applications","staff-input","set"]];static usage=E.Usage({category:"Admission",description:"Correct one internal input of an application, with a reason \u2014 refused once a node that reads it was entered",examples:[["Untick \u201EKind von Mitarbeitenden\u201C",'plexus-cli --env prod --tenant <t> --allow-prod applications staff-input set <id> --input staffApplication=false --reason "falsch angehakt"']]});application=f.String({required:!0});input=f.String("--input",{required:!0,description:"key=true|false"});reason=f.String("--reason",{required:!0,description:"Why \u2014 recorded on the application's activity feed"});async execute(){let t=await this.caller(),[{key:n,value:r}]=wN([this.input]);return await t.mutation(S.admission.correctStaffInput,{applicationId:ee(this.application,"application"),key:n,value:r,reason:this.reason}),this.print({application:this.application,key:n,value:r},i=>[{key:"application",value:i.application},{key:i.key,value:String(i.value)}]),0}},rk=class extends P{static{s(this,"ApplicationsPurgeCommand")}static paths=[["platform","applications","purge"]];static usage=E.Usage({category:"Admission",description:"Hard-delete one real application staff started for a colleague and already deleted (plan unless --confirm). Needs _platform.config.manage.",details:"Refused unless all hold: a real application (a test one goes with `applications discard-test`), soft-deleted by staff, started by staff, its applicant an internal staff member of the school (also a switched-off one) whose person existed before, no data about anyone else (only empty drafts the form opened), nothing committed yet, and no contract, signing process, payment or Engage push. Deletes the application and every row it created; the staff member's person stays. Afterwards the responsible person can be deactivated.",examples:[["Plan","plexus-cli --env prod --tenant <slug> platform applications purge <applicationId>"],["Apply","plexus-cli --env prod --tenant <slug> --allow-prod platform applications purge <applicationId> --confirm"]]});application=f.String({required:!0});confirm=f.Boolean("--confirm",!1,{description:"Delete for good (without it, only the checks run)."});async execute(){let t=await this.caller(),n=await t.mutation(S.admission.purgeDeletedStaffApplication,{tenantSlug:this.requireTenant(t),applicationId:ee(this.application,"application"),dryRun:!this.confirm});if(this.json)return this.print(n),0;let r=this.context.stdout;return r.write(`${n.applied?"Deleted":"Would delete"} application ${n.applicationId} `),r.write(`(applicant ${n.applicantPartyId}, soft-deleted ${new Date(n.deletedAt).toISOString()})
|
|
11507
11507
|
`),n.applicantGone&&r.write(`The applicant's party no longer exists \u2014 the staff check was not run.
|
|
11508
11508
|
`),n.applied?(r.write(`Rows deleted: ${n.deleted}${n.continuing?" so far \u2014 the purge goes on in scheduled steps":""}
|
|
11509
11509
|
`),0):(r.write(`Dry run \u2014 every check passed; re-run with --confirm to delete.
|
|
@@ -11956,7 +11956,7 @@ A task with --result closes only by recording it: freetext (text, always require
|
|
|
11956
11956
|
`),this.context.stdout.write(`Run took ${(i.elapsedMs/1e3).toFixed(1)} s.
|
|
11957
11957
|
`),0)}},lz=[l$,d$];import{loadavg as zee}from"node:os";var sf={add:{budgetMs:3e4},addFinance:{budgetMs:6e4},lean:{budgetMs:12e4,selects:{applicants:"none",finance:"none"}},financeCases:{budgetMs:18e4,selects:{applicants:"none",finance:"cases"}},financeFull:{budgetMs:3e5,selects:{applicants:"none",finance:"full"}},minimal:{budgetMs:45e4,selects:{applicants:"minimal",finance:"none"}},full:{budgetMs:6e5,selects:{applicants:"full",finance:"full"}}};function dz(e){if(e.only)return null;for(let[t,n]of Object.entries(sf))if(n.selects?.applicants===e.applicants&&n.selects.finance===e.finance)return t;return null}s(dz,"seedShapeOf");var cz={fullSeedMs:sf.full.budgetMs,applicantCallsMs:4e4,driveWaitMs:75e3};var fz=6e5,c$="drive:",Iee="driveWait:";function Oee(e){return{drive:`${c$}${e}`,wait:`${Iee}${e}`}}s(Oee,"driveTimingKeys");function pz(e){let t=e.perPhaseMs??{},n=[],r=s((o,a,l)=>{a>l&&n.push({over:a/l,line:`${o} ${uz(a)} > budget ${uz(l)}`})},"check");if(e.shape!==null){let o=sf[e.shape].budgetMs;e.shape==="add"&&(o*=Math.max(1,e.addedCases??1)),e.shape==="addFinance"&&(o+=sf.add.budgetMs*(e.addedCases??0)),r(`${e.shape} seed`,e.elapsedMs,o)}let i=0;for(let[o,a]of Object.entries(t)){if(!o.startsWith(c$))continue;let l=o.slice(c$.length),d=t[Oee(l).wait]??0;i+=d,r(`applicant ${l}: own calls`,a-d,cz.applicantCallsMs)}return e.shape==="full"&&r("drive waits on scheduled work",i,cz.driveWaitMs),n.sort((o,a)=>a.over-o.over).map(o=>o.line)}s(pz,"seedBudgetBreaches");var uz=s(e=>`${(e/1e3).toFixed(1)} s`,"seconds");var u$=["none","cases","full"],mz="finance";function hz(e){return u$.includes(e)}s(hz,"isFinanceShowcase");function f$(e){return e.financeShowcase!==void 0?e.financeShowcase:e.applicantKeys!==void 0&&e.applicantKeys.length>0?"none":"full"}s(f$,"resolveFinanceShowcase");var _ee=5;async function p$(e){let t=e.now??Date.now,n=e.sleep??(d=>new Promise(c=>setTimeout(c,d))),r=e.maxConsecutiveFailures??_ee,i=`seed run ${e.runId}`,o=s(d=>`${Math.round(d/1e3)}s`,"seconds"),a=0,l="";for(;;){let d;try{d=e.poll(),a=0}catch(c){if(a++,a>=r)throw Lt(c,u=>`could not read the status of ${i} ${a} times in a row (it may still be running); last error: ${u}`)}if(d===null)throw new Error(`${i} not found in seed_runs.`);if(d!==void 0){if(d.phase&&d.phase!==l&&(l=d.phase,e.onPhase(d.phase,d.elapsedMs)),d.status==="completed")return d;if(d.status==="failed")throw new Error(`${i} FAILED in phase "${d.phase??"?"}" after ${o(d.elapsedMs)} \u2014 ${d.error??"no error recorded"}`);if(d.status==="unknown")throw new Error(`${i} has no status (phase "${d.phase??"?"}").`);if(!d.live)throw new Error(`${i} is no longer live: its owner died in phase "${d.phase??"?"}" after ${o(d.elapsedMs)}. Rebuild explicitly (pnpm seed / pnpm seed:lean).`)}if(t()>=e.deadline){let c=e.budgetMs===void 0?"":` after ${o(e.budgetMs)}`;throw new Error(`timed out${c} waiting for ${i} (phase "${l||"?"}"; it may still be running \u2014 poll init/seed:seedStatus).`)}await n(e.pollMs)}}s(p$,"pollSeedRun");import{spawnSync as Nee}from"node:child_process";import{closeSync as m$,ftruncateSync as Pee,mkdirSync as Cee,openSync as Dee,readFileSync as Fee,writeSync as Lee}from"node:fs";import{homedir as Mee}from"node:os";import gz from"node:path";var qee=2;function yz(e=process.env){let t=e.PLEXUS_SEED_SLOTS;if(t===void 0||t==="")return qee;if(!/^[1-9][0-9]*$/.test(t))throw new g(`PLEXUS_SEED_SLOTS must be a positive integer, got '${t}'.`);return Number.parseInt(t,10)}s(yz,"seedSlotCount");function wz(){return gz.join(Mee(),".cache","plexus","seed-slots")}s(wz,"seedSlotDir");function Kee(e,t){return gz.join(e,`slot-${t}.lock`)}s(Kee,"slotFile");function jee(e){Cee(e.dir,{recursive:!0});let t=[];for(let n=0;n<e.slots;n++){let r=Kee(e.dir,n),i=Dee(r,"a+"),o=Nee("flock",["--nonblock","--exclusive","3"],{stdio:["ignore","ignore","pipe",i],encoding:"utf8"});if(o.error)throw m$(i),new Error(`seed slot: cannot run flock(1) \u2014 ${o.error.message}`);if(o.status===0){Pee(i,0),Lee(i,`${e.holder}
|
|
11958
11958
|
`);let a=!1;return{index:n,release:s(()=>{a||(a=!0,m$(i))},"release")}}if(m$(i),o.status!==1)throw new Error(`seed slot: flock ${r} exited ${o.status} \u2014 ${(o.stderr??"").trim()}`);t.push(Fee(r,"utf8").trim()||"unknown holder")}return{busy:t}}s(jee,"tryAcquireSeedSlot");async function kz(e){let t=e.now??Date.now,n=e.sleep??(i=>new Promise(o=>setTimeout(o,i))),r="";for(;;){let i=jee(e);if("index"in i)return i;let o=`${i.busy.length} in use: ${i.busy.join(", ")}`;if(t()>=e.deadline)throw new Error(`no seed slot became free before the timeout (${o})`);let a=`waiting for a seed slot (${o})`;a!==r&&(e.onWait(a),r=a),await n(e.pollMs)}}s(kz,"acquireSeedSlot");import{statSync as Vee}from"node:fs";var Bee=Uo("_system/frontend/deploymentEvents:lastPushEvent");function Uee(e,t){return e!==null&&e._creationTime>t}s(Uee,"isSessionPush");function Gee(e){return Vee(iw({cwd:e})).mtimeMs}s(Gee,"sessionStartMs");async function bz(e,t){let n=mp({cwd:e}),r=Gee(e),i=pp({cwd:e}),o=new na(i,{logger:!1});o.setAdminAuth(n);let a,l;try{await new Promise((d,c)=>{l=setTimeout(()=>{let u=o.connectionState().hasEverConnected?"Its pane shows why the push did not finish (a schema validation error, a bundling error, or no watcher running for this deployment).":`The backend at ${i} was never reachable.`;c(new Error(`the local watcher pushed no functions within ${t/1e3}s (--push-timeout); nothing was seeded. ${u}`))},t),a=o.onUpdate(Bee,{},u=>{Uee(u,r)&&d()},u=>c(u))})}finally{clearTimeout(l),a?.(),await o.close()}}s(bz,"waitForWatcherPush");function y$(){let e=process.cwd();for(;;){if(Re(H.join(e,"convex")))return e;let t=H.dirname(e);if(t===e)throw new g("plexus seed: no Convex project found above the current directory \u2014 run this from inside the worktree (e.g. the app/ dir).");e=t}}s(y$,"findConvexProjectDir");function Wee(e,t){let n=["convex","run",e];t!==void 0&&n.push(t);let r=Vq("npx",n,{cwd:y$(),encoding:"utf8",stdio:["ignore","pipe","pipe"]});if(r.status!==0){let l=(r.stderr??"").trim();throw new Error(l||`convex run ${e} exited ${r.status}`)}let i=(r.stdout??"").trim();try{return JSON.parse(i)}catch{}let o=i.indexOf("{"),a=i.lastIndexOf("}");if(o<0||a<o)throw new Error(`convex run ${e}: no JSON in output:
|
|
11959
|
-
${i}`);return JSON.parse(i.slice(o,a+1))}s(Wee,"convexRun");function h$(){return zee().map(e=>e.toFixed(2)).join(" ")}s(h$,"loadAverage");var Yee={convexRun:Wee,waitForWatcherPush:s(e=>bz(y$(),e),"waitForWatcherPush"),now:Date.now,sleep:s(e=>new Promise(t=>setTimeout(t,e)),"sleep"),slotDir:wz,worktree:s(()=>H.basename(H.dirname(y$())),"worktree")},vz=fz/1e3,g$=s((e,t)=>{if(!/^[1-9]\d*$/.test(t.trim()))throw new g(`${e} takes a positive whole number of seconds, got '${t}'.`);return Number.parseInt(t,10)},"secondsOption"),xz=s(e=>(e??"").split(",").map(t=>t.trim()).filter(t=>t.length>0),"splitList"),w$=class extends Ae{static{s(this,"SeedCommand")}static paths=[["seed"]];static usage=E.Usage({category:"Operations",description:"Kick off the destructive local reseed and poll its run marker to completion.",details:`Which shape to seed for a task, what each costs and its budget: docs/engineering/seed-index.md.
|
|
11959
|
+
${i}`);return JSON.parse(i.slice(o,a+1))}s(Wee,"convexRun");function h$(){return zee().map(e=>e.toFixed(2)).join(" ")}s(h$,"loadAverage");var Yee={convexRun:Wee,waitForWatcherPush:s(e=>bz(y$(),e),"waitForWatcherPush"),now:Date.now,sleep:s(e=>new Promise(t=>setTimeout(t,e)),"sleep"),slotDir:wz,worktree:s(()=>H.basename(H.dirname(y$())),"worktree")},vz=fz/1e3,g$=s((e,t)=>{if(!/^[1-9]\d*$/.test(t.trim()))throw new g(`${e} takes a positive whole number of seconds, got '${t}'.`);return Number.parseInt(t,10)},"secondsOption"),xz=s(e=>(e??"").split(",").map(t=>t.trim()).filter(t=>t.length>0),"splitList"),w$=class extends Ae{static{s(this,"SeedCommand")}static paths=[["seed"]];static usage=E.Usage({category:"Operations",description:"Kick off the destructive local reseed and poll its run marker to completion.",details:`Which shape to seed for a task, what each costs and its budget: docs/engineering/development/seed-index.md.
|
|
11960
11960
|
|
|
11961
11961
|
Fires init/seed:kickoffSeed (returns immediately, holds a run-lock) and polls init/seed:seedStatus, printing live phase progress. Exit 0 on completed, 1 on failed. The client disconnect can no longer masquerade as a failure \u2014 the seed_runs marker is the only source of truth. Runs \`convex run\` in the current worktree (admin key), so invoke it from the app dir.
|
|
11962
11962
|
|
|
@@ -11968,7 +11968,7 @@ At most PLEXUS_SEED_SLOTS (default 2) seeds run at once on this machine, across
|
|
|
11968
11968
|
`),v=d.convexRun("init/seed:seedStartupState","{}")}c=this.seedDeadline(),v.disposition==="needed"?(p=await this.takeSlot(c),h=d.convexRun("init/seed:kickoffSeed",JSON.stringify(u))):h={...v,mode:"dev"}}catch(v){return l(`could not start \u2014 ${xi(v)}`)}if(h.disposition!=="started"&&(p?.release(),p=void 0),h.disposition==="ready")return a.write(`Seed already completed (runId=${h.runId}); preserving local data. Use pnpm seed or pnpm seed:lean for an explicit rebuild.
|
|
11969
11969
|
`),0;let y=r.length>0?`only=${r.join(",")}`:`applicants=${t}`;a.write(`Seed ${h.disposition==="running"?"already running":"kicked off"} (${y}, finance=${f$(u)}, runId=${h.runId}).
|
|
11970
11970
|
`);let b;try{b=await p$({runId:h.runId,poll:s(()=>d.convexRun("init/seed:seedStatus",JSON.stringify({runId:h.runId})),"poll"),pollMs:i,deadline:c,budgetMs:this.seedBudgetMs(),now:d.now,sleep:d.sleep,onPhase:s((v,T)=>a.write(` \xB7 ${v} (${Math.round(T/1e3)}s)
|
|
11971
|
-
`),"onPhase")})}catch(v){return l(xi(v))}let k=Math.round(b.elapsedMs/1e3);return this.print({status:"completed",mode:b.mode,totalSeconds:k,accounts:b.accounts,applicants:b.applicants},()=>[{status:"completed",seconds:String(k),accounts:String(b.accounts),applicants:String(b.applicants)}],["status","seconds","accounts","applicants"]),this.reportBudget(b,dz({applicants:t,only:r.length>0,finance:f$(u)})),0}finally{p?.release()}}pollMs(){return g$("--poll-interval",this.pollSeconds)*1e3}seedBudgetMs(){return g$("--timeout",this.timeoutSeconds)*1e3}seedDeadline(){return this.seedRuntime().now()+this.seedBudgetMs()}reportBudget(t,n,r){let i=pz({elapsedMs:t.elapsedMs,perPhaseMs:t.perPhaseMs??null,shape:n,addedCases:r});i.length!==0&&this.context.stderr.write(`plexus seed: over budget (load ${h$()}; docs/engineering/seed-index.md):
|
|
11971
|
+
`),"onPhase")})}catch(v){return l(xi(v))}let k=Math.round(b.elapsedMs/1e3);return this.print({status:"completed",mode:b.mode,totalSeconds:k,accounts:b.accounts,applicants:b.applicants},()=>[{status:"completed",seconds:String(k),accounts:String(b.accounts),applicants:String(b.applicants)}],["status","seconds","accounts","applicants"]),this.reportBudget(b,dz({applicants:t,only:r.length>0,finance:f$(u)})),0}finally{p?.release()}}pollMs(){return g$("--poll-interval",this.pollSeconds)*1e3}seedBudgetMs(){return g$("--timeout",this.timeoutSeconds)*1e3}seedDeadline(){return this.seedRuntime().now()+this.seedBudgetMs()}reportBudget(t,n,r){let i=pz({elapsedMs:t.elapsedMs,perPhaseMs:t.perPhaseMs??null,shape:n,addedCases:r});i.length!==0&&this.context.stderr.write(`plexus seed: over budget (load ${h$()}; docs/engineering/development/seed-index.md):
|
|
11972
11972
|
`+i.map(o=>` \xB7 ${o}
|
|
11973
11973
|
`).join(""))}fail(t){return this.context.stderr.write(`plexus seed: ${t}
|
|
11974
11974
|
`),1}async executeAdd(){let t=[this.only!==void 0&&"--only",this.applicants!==void 0&&"--applicants",this.financeShowcase!==void 0&&"--finance-showcase",this.ifNeeded&&"--if-needed"].filter(u=>u!==!1);if(t.length>0)throw new g(`--add drives cases onto the existing base and takes no ${t.join(", ")}.`);let n=xz(this.add);if(n.length===0)throw new g("--add needs at least one case (e.g. --add vera-klein).");let r=this.pollMs(),i=this.seedDeadline(),o=this.context.stdout,a=this.seedRuntime(),l=a.now(),d=h$(),c;try{let u;try{c=await this.takeSlot(i),u=a.convexRun("init/seed:kickoffSeedAdd",JSON.stringify({applicantKeys:n}))}catch(v){return this.fail(`could not add \u2014 ${xi(v)}`)}let p=[...u.finance?[mz]:[],...u.keys];o.write(`Seed add kicked off (add=${p.join(",")}, runId=${u.runId}, load ${d}).
|
|
@@ -11976,7 +11976,7 @@ At most PLEXUS_SEED_SLOTS (default 2) seeds run at once on this machine, across
|
|
|
11976
11976
|
`),"onPhase")})}catch(v){return this.fail(xi(v))}let y=Math.round(h.elapsedMs/1e3),b=Math.round((a.now()-l)/1e3),k=h$();return this.print({status:"completed",added:p,seconds:y,wallSeconds:b,applicants:h.applicants,load:k},()=>[{status:"completed",added:p.join(","),seconds:String(y),wall:String(b),applicants:String(h.applicants),load:k}],["status","added","seconds","wall","applicants","load"]),this.reportBudget(h,u.finance?"addFinance":"add",u.keys.length),0}finally{c?.release()}}async takeSlot(t){let n=this.seedRuntime();return await kz({dir:n.slotDir(),slots:yz(),holder:`${n.worktree()} (pid ${process.pid})`,deadline:t,pollMs:2e3,now:n.now,sleep:n.sleep,onWait:s(r=>this.context.stdout.write(`${r}
|
|
11977
11977
|
`),"onWait")})}},Sz=[w$];import{existsSync as $$,mkdirSync as E$,readFileSync as Hee,renameSync as Jee,writeFileSync as Qee}from"node:fs";import cn from"node:path";function Zee(e,t=$$){let n=cn.resolve(e);if(t(n))return`${n} already exists \u2014 name a new directory.`;if(t(`${n}.partial`))return`${n}.partial exists \u2014 a former export stopped half-way; remove it first.`;for(let r=cn.dirname(n);;r=cn.dirname(r)){if(t(cn.join(r,".git")))return`${n} lies inside the git working tree ${r} \u2014 a tenant's setup is never committed; export outside any repository.`;if(cn.dirname(r)===r)return null}}s(Zee,"outDirRefusal");async function b$(e,t,n){if(e===null)throw new Error(`${n}: its stored object is gone.`);let r=await fetch(e,{signal:AbortSignal.timeout(12e4)});if(!r.ok)throw new Error(`download of ${n} failed (${r.status}).`);let i=new Uint8Array(await r.arrayBuffer());if(el(i)!==t)throw new Error(`download of ${n} does not match its sha256 ${t}.`);return i}s(b$,"download");function k$(e,t){E$(cn.dirname(e),{recursive:!0}),Qee(e,t)}s(k$,"write");var Az=/^[a-z][a-z0-9-]*$/;async function Xee(e,t,n){let r=t===null?await e.action(S.setupExport.platformRecordPlatformExport,{}):await e.action(S.setupExport.platformRecordExport,{tenant:t}),i=await b$(r.setupFile.url,r.setupFile.sha256,`setup.json of ${t??"the platform"}`);k$(cn.join(n,"setup.json"),i);let o=JSON.parse(new TextDecoder().decode(i));for(let[a,l]of Object.entries(o.parts)){if(!Az.test(a))throw new Error(`setup export: part name "${a}" is not a safe directory name.`);k$(cn.join(n,a,`${a}.json`),`${JSON.stringify(l.data,null,2)}
|
|
11978
11978
|
`),E$(cn.join(n,a,"files"),{recursive:!0})}for(let{part:a,file:l}of r.files){let d=As(l.filename);if(d!==null||!/^[0-9a-f]{64}$/.test(l.sha256)||!Az.test(a))throw new Error(`setup export: "${l.filename}" (${a}) is not a safe path (${d??"bad hash or part"}).`);let c=await b$(l.url,l.sha256,`${a}/${l.filename}`);k$(cn.join(n,a,"files",l.sha256,l.filename),c)}return{tenant:t??"(platform)",out:n,parts:Object.entries(r.partHashes).map(([a,l])=>`${a}:${l.slice(0,12)}`).join(" "),files:r.files.length}}s(Xee,"exportTenant");var v$=class extends P{static{s(this,"SetupExportCommand")}static paths=[["setup","export"]];static usage=E.Usage({category:"Setup",description:"Export a tenant's setup (Einrichtung) with its files (platform-admin) / Einrichtung exportieren",details:"Records an export on the server and downloads it: setup.json, one folder per part and every referenced file, each checked against its sha256. --out must be a new directory outside any git working tree. --platform exports the platform's own setup instead (the contract input registry every tenant names), with no tenant; restore it before a tenant whose setup names its keys."});out=f.String("--out",{required:!0,description:"New directory to write the export into"});allTenants=f.Boolean("--all-tenants",!1,{description:"Every tenant, one sub-directory each"});platform=f.Boolean("--platform",!1,{description:"The platform export (no tenant)"});async execute(){if(this.platform&&(this.allTenants||this.tenant!==void 0))throw new g("setup export: --platform takes no tenant (--tenant, --all-tenants).");let t=Zee(this.out);if(t!==null)throw new g(`setup export: ${t}`);let n=cn.resolve(this.out),r=`${n}.partial`,i=await this.caller(),o=this.platform?[null]:this.allTenants?(await i.query(S.platformAdmin.listAllTenants,{})).map(l=>l.slug).sort():[this.requireTenant(i)];E$(r,{recursive:!0});let a=[];for(let l of o){let d=await Xee(i,l,this.allTenants&&l!==null?cn.join(r,l):r);a.push({...d,out:this.allTenants&&l!==null?cn.join(n,l):n})}return Jee(r,n),this.print(a,l=>l.map(d=>({tenant:d.tenant,parts:d.parts,files:String(d.files),out:d.out})),["tenant","parts","files","out"]),0}},ete="plexus.setup-export/1",Tz="plexus.platform-setup-export/1";function Iz(e,t,n){let r=cn.join(cn.resolve(e),"setup.json");if(!$$(r))throw new g(`setup: ${r} does not exist \u2014 point --dir at a directory written by setup export.`);let i=Ge(r,"--dir"),o=n?Tz:ete;if(i.format!==o){let l=i.format===Tz?" \u2014 it is the platform export: add --platform":n?" \u2014 drop --platform for a tenant's export":"";throw new g(`setup: ${r} is not a ${n?"platform ":""}setup export (format ${String(i.format)})${l}.`)}if(!n&&i.platformRefs===void 0)throw new g(`setup: ${r} lists no platformRefs \u2014 it predates the platform export; export the tenant again.`);let a=t.filter(l=>!i.partOrder.includes(l));if(a.length>0)throw new g(`setup: --part ${a.join(", ")} is not in this export (${i.partOrder.join(", ")}).`);return{...i,selected:i.partOrder.filter(l=>t.length===0||t.includes(l))}}s(Iz,"readExport");function tte(e,t,n,r){let i=r.find(l=>l.sha256===n);if(i===void 0)throw new g(`setup: ${t} needs ${n}, which its files[] does not name.`);if(As(i.filename)!==null||!/^[0-9a-f]{64}$/.test(n))throw new g(`setup: "${i.filename}" is not a safe path.`);let o=cn.join(cn.resolve(e),t,"files",n,i.filename);if(!$$(o))throw new g(`setup: ${o} is missing \u2014 the export directory is incomplete.`);let a=new Uint8Array(Hee(o));if(el(a)!==n)throw new g(`setup: ${o} does not match its sha256 ${n}.`);return a}s(tte,"exportedBytes");function cy(e,t){return[...t.create.map(n=>({part:e,change:"+ create",...n})),...t.update.map(n=>({part:e,change:"~ update",...n})),...t.delete.map(n=>({part:e,change:"- delete",...n})),...t.extra.map(n=>({part:e,change:"? extra (kept)",...n})),{part:e,change:"\xB7 unchanged",table:"",key:String(t.unchanged)}]}s(cy,"planRows");var x$=class extends P{static{s(this,"SetupPlanCommand")}static paths=[["setup","plan"]];static usage=E.Usage({category:"Setup",description:"Preview restoring a setup export directory (platform-admin) / Wiederherstellung pr\xFCfen",details:"Read-only: per part and table what an apply would create, update, delete, or keep as extra."});dir=f.String("--dir",{required:!0,description:"Directory written by setup export"});part=f.Array("--part",[],{description:"Only these parts (repeatable)"});prune=f.Boolean("--prune",!1,{description:"Preview an apply with --prune (a part that refuses it refuses here)"});platform=f.Boolean("--platform",!1,{description:"The directory is the platform export (setup export --platform)"});async execute(){let t=Iz(this.dir,this.part,this.platform),n=await this.caller(),r=[];for(let i of t.selected){let o={data:t.parts[i].data,files:t.parts[i].files};if(t.tenant===void 0){r.push(...cy(i,await n.action(S.setupExport.platformPlanPlatformPart,{part:i,section:o,prune:this.prune})));continue}let{plan:a,uploads:l,missingPlatformRefs:d}=await n.action(S.setupExport.platformPlanPart,{tenant:t.tenant,part:i,section:o,platformRefs:t.platformRefs,prune:this.prune});r.push(...cy(i,a),{part:i,change:"\u2191 upload",table:"files",key:String(l.length)});for(let[c,u]of Object.entries(d))for(let p of u)r.push({part:i,change:"\u2716 missing platform key",table:c,key:p})}return this.print(r,i=>i.map(o=>({...o})),["part","change","table","key"]),0}},S$=class extends P{static{s(this,"SetupApplyCommand")}static paths=[["setup","apply"]];static usage=E.Usage({category:"Setup",description:"Restore a setup export directory onto its tenant (platform-admin) / Einrichtung wiederherstellen",details:"Applies part by part in the export's order. Uploads only the files the target lacks, each checked against its hash. Rows the target holds that the export lacks are kept unless --prune."});dir=f.String("--dir",{required:!0,description:"Directory written by setup export"});part=f.Array("--part",[],{description:"Only these parts (repeatable)"});confirm=f.Boolean("--confirm",!1,{description:"Required: actually apply"});prune=f.Boolean("--prune",!1,{description:"Also delete rows the export lacks"});platform=f.Boolean("--platform",!1,{description:"The directory is the platform export (setup export --platform)"});async execute(){if(!this.confirm)throw new g("setup apply writes \u2014 add --confirm (preview with setup plan).");let t=Iz(this.dir,this.part,this.platform),n=await this.caller(),r=[],i=[],o=s(p=>({data:t.parts[p].data,files:t.parts[p].files}),"sectionOf");if(t.tenant===void 0){for(let p of t.selected)r.push(...cy(p,await n.action(S.setupExport.platformApplyPlatformPart,{part:p,section:o(p),staged:[],prune:this.prune})));return this.print(r,p=>p.map(h=>({...h})),["part","change","table","key"]),0}let a=t.tenant,l=t.platformRefs,d=[];for(let p of t.selected)d.push({part:p,...await n.action(S.setupExport.platformPlanPart,{tenant:a,part:p,section:o(p),platformRefs:l,prune:this.prune})});let c=d.flatMap(p=>Object.entries(p.missingPlatformRefs).flatMap(([h,y])=>y.map(b=>`${h}:${b}`)));if(c.length>0)throw new g(`setup apply: the target lacks platform keys this export names: ${[...new Set(c)].join(", ")} \u2014 apply the platform export first (setup apply --platform).`);let u=s(()=>i.map(p=>({part:"accounts",change:"password",table:p.email,key:p.password})),"mintedRows");try{for(let{part:p,uploads:h}of d){let y=o(p),b=[];for(let v of h){let T=tte(this.dir,p,v.sha256,t.parts[p].files);b.push({sha256:v.sha256,storageId:await Vi(n,a,T,v.mimeType,v.surface)})}let k=await n.action(S.setupExport.platformApplyPart,{tenant:a,part:p,section:y,staged:b,prune:this.prune,platformRefs:l});r.push(...cy(p,k),{part:p,change:"\u2191 uploaded",table:"files",key:String(b.length)}),i.push(...k.minted)}}catch(p){throw i.length>0&&this.print([...r,...u()],h=>h.map(y=>({...y})),["part","change","table","key"]),p}return this.print([...r,...u()],p=>p.map(h=>({...h})),["part","change","table","key"]),0}},nte=/^[A-Za-z_$][A-Za-z0-9_$-]*$/,Rz=120;function $z(e,t){return typeof t=="number"?`${e}[${t}]`:nte.test(t)?e===""?t:`${e}.${t}`:`${e}[${JSON.stringify(t)}]`}s($z,"pathOf");function dy(e){if(e===void 0)return"";let t=JSON.stringify(e);return t.length>Rz?`${t.slice(0,Rz-1)}\u2026`:t}s(dy,"shown");var Ez=s(e=>typeof e=="object"&&e!==null&&!Array.isArray(e),"isObject");function A$(e,t,n,r){if(!(t===void 0&&n===void 0)){if(t===void 0){r.push({path:e,change:"+",before:"",after:dy(n)});return}if(n===void 0){r.push({path:e,change:"-",before:dy(t),after:""});return}if(Ez(t)&&Ez(n)){let i=[...new Set([...Object.keys(t),...Object.keys(n)])].sort();for(let o of i)A$($z(e,o),t[o],n[o],r);return}if(Array.isArray(t)&&Array.isArray(n)){for(let i=0;i<Math.max(t.length,n.length);i+=1)A$($z(e,i),t[i],n[i],r);return}JSON.stringify(t)!==JSON.stringify(n)&&r.push({path:e,change:"~",before:dy(t),after:dy(n)})}}s(A$,"walk");function rte(e,t){let n=s(({generatedAt:i,...o})=>o,"strip"),r=[];return A$("",n(e),n(t),r),r}s(rte,"diffSetupDocuments");var ite=s(e=>new Date(e).toISOString().replace(".000Z","Z"),"day"),T$=class extends P{static{s(this,"SetupListCommand")}static paths=[["setup","list"]];static usage=E.Usage({category:"Setup",description:"List a tenant's recorded setup exports (platform-admin) / Einrichtungsexporte auflisten",details:"Newest first: the nightly exports (prod, 7 daily + 4 weekly) and the manual ones, with status, size and part hashes. --platform lists the platform export's instead. Compare two with setup diff <a> <b>."});platform=f.Boolean("--platform",!1,{description:"List the platform export (no tenant) instead of a tenant's"});async execute(){if(this.platform&&this.tenant!==void 0)throw new g("setup list: --platform takes no --tenant.");let t=await this.caller(),n=await t.query(S.setupExport.platformSetupHistory,this.platform?{platform:!0}:{tenant:this.requireTenant(t)});return this.print(n,r=>r.map(i=>({id:i.exportId,created:ite(i.createdAt),trigger:i.trigger,status:i.status,bytes:i.sizeBytes===null?"":String(i.sizeBytes),parts:i.status==="failed"?i.error??"":i.partHashes.map(o=>`${o.part}:${o.hash.slice(0,12)}`).join(" ")})),["id","created","trigger","status","bytes","parts"]),0}},R$=class extends P{static{s(this,"SetupDiffCommand")}static paths=[["setup","diff"]];static usage=E.Usage({category:"Setup",description:"Show what changed between two setup exports (platform-admin) / Zwei Einrichtungsexporte vergleichen",details:"Downloads both stored setup.json files (ids from setup list), checks each against its sha256 and lists every changed leaf: + added, - removed, ~ changed. The run time (generatedAt) is ignored. Both must be exports of one tenant. Lists compare by position, so read the snapshot section (rows keyed by identity) for an inserted row.",examples:[["Compare two nightly exports","plexus-cli --env prod setup diff <older-id> <newer-id>"]]});before=f.String({required:!0,name:"a"});after=f.String({required:!0,name:"b"});async execute(){let t=ee(this.before,"setup export"),n=ee(this.after,"setup export"),r=await this.caller(),i=s(async d=>{let{tenantSlug:c,file:u}=await r.query(S.setupExport.platformSetupExportFile,{exportId:d}),p=await b$(u.url,u.sha256,`export ${d}`);return{tenantSlug:c,document:JSON.parse(new TextDecoder().decode(p))}},"load"),[o,a]=[await i(t),await i(n)];if(o.tenantSlug!==a.tenantSlug){let d=s(c=>c===null?"the platform":`"${c}"`,"owner");throw new g(`setup diff: ${this.before} is an export of ${d(o.tenantSlug)}, ${this.after} of ${d(a.tenantSlug)} \u2014 compare two exports of one owner.`)}let l=rte(o.document,a.document);return this.print(l,d=>d.map(c=>({...c})),["change","path","before","after"]),0}},Oz=[v$,x$,S$,T$,R$];var _z={docusign:"hmacKey",insign:"password"};function Nz(e){let t=e.detail??"?";switch(e.code){case"credentialsKeyMissing":return{de:"SIGNING_CREDENTIALS_KEY ist auf dieser Installation nicht gesetzt",en:"SIGNING_CREDENTIALS_KEY is not set on this installation"};case"credentialsKeyInvalid":return{de:"SIGNING_CREDENTIALS_KEY ist keine 32 Byte in base64",en:"SIGNING_CREDENTIALS_KEY is not 32 bytes in base64"};case"credentialsKeyPreviousInvalid":return{de:"SIGNING_CREDENTIALS_KEY_PREVIOUS ist gesetzt, aber unbrauchbar (kein 32-Byte-Schl\xFCssel, gleich dem aktuellen oder ohne aktuellen)",en:"SIGNING_CREDENTIALS_KEY_PREVIOUS is set but unusable (not a 32-byte key, equal to the current one, or without a current one)"};case"sealedWithUnknownKey":return{de:`das Geheimnis ist mit Schl\xFCssel ${t} versiegelt, den weder SIGNING_CREDENTIALS_KEY noch SIGNING_CREDENTIALS_KEY_PREVIOUS tr\xE4gt \u2014 vorherigen Schl\xFCssel wieder setzen oder Geheimnis neu eingeben`,en:`the secret is sealed with key ${t}, which neither SIGNING_CREDENTIALS_KEY nor SIGNING_CREDENTIALS_KEY_PREVIOUS holds \u2014 set the previous key again or re-enter the secret`};case"docusignPlatformMissing":return{de:`${t} fehlt auf dieser Installation`,en:`${t} is missing on this installation`};case"environmentMismatch":return{de:`das Konto wurde als ${t} gespeichert, die Installation spricht inzwischen ein anderes an \u2014 neu speichern`,en:`the account was saved as ${t}, but the installation now speaks a different one \u2014 save again`};case"productionOutsideProd":return{de:"Ein Produktivkonto wird nur auf der Produktionsumgebung verwendet.",en:"A production account is only used in the production environment."};case"redirectRequired":return{de:"Ein Demo-/Sandbox-Konto braucht eine Umleitungsadresse \u2014 niemand darf aus einer Sandbox echte Familien anschreiben.",en:"A demo/sandbox account needs a redirect address \u2014 nobody may email real families from a sandbox."};case"redirectForbidden":return{de:"Ein Produktivkonto darf keine Umleitungsadresse tragen \u2014 sonst ginge jeder Vertrag an ein einziges Postfach.",en:"A production account must not carry a redirect address \u2014 otherwise every contract would go to a single mailbox."};case"secretMissing":return{de:`das Geheimnis \u201E${t}\u201C ist nicht hinterlegt`,en:`the secret \u201C${t}\u201D is not stored`}}}s(Nz,"describeProblem");function Br(e){return e==null?"":new Date(e).toISOString().replace("T"," ").replace(/\.\d+Z$/,"Z")}s(Br,"ts");function ote(e){return e.map(t=>({id:t.id,contract:t.contractId,rev:String(t.snapshotNumber),provider:t.provider,env:t.environment??"",status:t.status,ref:t.providerRef??"",signers:t.signers.map(n=>`${n.name}:${n.status}`).join(", "),sent:Br(t.sentAt),completed:Br(t.completedAt),reconciled:Br(t.lastReconciledAt),error:t.error?.de??""}))}s(ote,"requestRows");var ste=["id","contract","rev","provider","env","status","ref","signers","sent","completed","reconciled","error"];function uy(e){if($o.includes(e))return e;throw new g(`--provider must be one of ${$o.join(" | ")}, got "${e}"`)}s(uy,"parseProvider");var I$=class extends P{static{s(this,"SigningConnectionShowCommand")}static paths=[["signing","connection","show"]];static usage=E.Usage({category:"Signing",description:"The tenant's e-signature connections: which provider its contracts go out through (\u201EE-Signatur: \u2026\u201C), and per provider the state, what keeps it from `ready`, the non-secret settings and which secrets are held (name + fingerprint, never the value). No network call.",examples:[["Show","$0 signing connection show --env local --tenant test"]]});async execute(){let t=await this.caller(),n=this.requireTenant(t),r=await t.query(S.signingConnections.list,{client:n});return this.json||this.context.stdout.write(`E-Signatur: ${r.activeProvider===null?"keine":Pc[r.activeProvider]}
|
|
11979
|
-
`),this.print(r,i=>i.providers.map(o=>{let a=o.connection,l=a===null?"":a.settings.provider==="docusign"?`userId=${a.settings.userId}${a.settings.accountId?` accountId=${a.settings.accountId}`:""}`:`baseUrl=${a.settings.baseUrl} username=${a.settings.username} ownerId=${a.settings.ownerId}`,d=[...o.platformProblems,...a?.problems??[]];return{provider:Pc[o.provider],state:a===null?"nicht eingerichtet":a.state,active:a?.active?"yes":"no",environment:a?.environment??"",settings:l,redirect:a?.settings.signerRedirectTo??"",secrets:a===null||a.secrets.names.length===0?"":`${a.secrets.names.join(", ")} \xB7 ${a.secrets.fingerprint??"?"} \xB7 ${Br(a.secrets.setAt)}${ate[a.secrets.sealedWith??"current"]}`,lastCheck:a?.lastCheck?`${a.lastCheck.ok?"ok":"FAILED"} ${Br(a.lastCheck.at)}${a.lastCheck.message?` \u2014 ${a.lastCheck.message}`:""}`:"",webhook:o.webhookConfigured?"configured":"none (poll only)",problems:[...new Set(d.map(c=>Nz(c).de))].join("; ")}})),0}},O$=class extends P{static{s(this,"SigningConnectionSetCommand")}static paths=[["platform","signing","connection","set"],["signing","connection","set"]];static usage=E.Usage({category:"Signing",description:"Set up or change the tenant's connection at ONE provider (platform right `_platform.config.manage`). Non-secret fields are written as given; the secret (DocuSign: Connect HMAC key, inSign: API password) comes ONLY from stdin or a file and is left unchanged when neither is given. A demo/sandbox account needs --redirect-to, a production account forbids it and is refused outside prod.",examples:[["inSign sandbox",'printf %s "$INSIGN_PASSWORD" | $0 signing connection set --provider insign --base-url https://sandbox.test.getinsign.show --username controller --owner-id plexus-dev --redirect-to admin@plexus.swop.schule --secret-stdin --env local --tenant test'],["DocuSign sender, HMAC key from a file","$0 signing connection set --provider docusign --user-id <GUID> --redirect-to admin@plexus.swop.schule --secret-file ./hmac.txt --env staging --tenant <slug>"],["Remove the HMAC key (poll only)","$0 signing connection set --provider docusign --user-id <GUID> --clear-secret hmacKey --env staging --tenant <slug>"]]});provider=f.String("--provider",{required:!0,description:$o.join(" | ")});userId=f.String("--user-id",{description:"DocuSign: the school's sender (API user id, GUID)."});baseUrl=f.String("--base-url",{description:"inSign: bare https origin of the account."});username=f.String("--username",{description:"inSign: API user."});ownerId=f.String("--owner-id",{description:"inSign: owner (`foruser`) of every session."});redirectTo=f.String("--redirect-to",{description:"Demo/sandbox only: every recipient address is replaced by this one. Omit on a production account."});secretStdin=f.Boolean("--secret-stdin",!1,{description:"Read the secret from stdin."});secretFile=f.String("--secret-file",{description:"Read the secret from this file."});clearSecret=f.String("--clear-secret",{description:"Remove the stored secret of this name (hmacKey | password)."});async execute(){let t=uy(this.provider),r=this.secretStdin||this.secretFile!==void 0?await lo({stdin:this.secretStdin,file:this.secretFile},ao(this.context.stdin)):void 0,i=this.redirectTo!==void 0?{signerRedirectTo:this.redirectTo}:{},o;if(t==="docusign"){if(this.userId===void 0)throw new g("--user-id is required for docusign");o={provider:t,userId:this.userId,...i}}else{if(this.baseUrl===void 0||this.username===void 0||this.ownerId===void 0)throw new g("--base-url, --username and --owner-id are required for insign");o={provider:t,baseUrl:this.baseUrl,username:this.username,ownerId:this.ownerId,...i}}let a=await this.caller(),l=this.requireTenant(a),d=await a.action(S.signingConnections.save,{client:l,settings:o,...r!==void 0?{secrets:{[_z[t]]:r}}:{},...this.clearSecret!==void 0?{clearSecrets:[this.clearSecret]}:{}});return this.print(d,c=>[{connectionId:c.connectionId,next:"signing connection test --provider "+t}]),0}},_$=class extends P{static{s(this,"SigningConnectionTestCommand")}static paths=[["signing","connection","test"]];static usage=E.Usage({category:"Signing",description:"\u201EVerbindung testen\u201C: reach the school's account (DocuSign: JWT grant \u2192 token \u2192 userinfo; inSign: version + owner) and record the result on the connection. A DocuSign consent_required answer prints the URL the school's sender must open once. Exit 1 when the test fails.",examples:[["Test inSign","$0 signing connection test --provider insign --env local --tenant test"]]});provider=f.String("--provider",{required:!0,description:$o.join(" | ")});async execute(){let t=await this.caller(),n=this.requireTenant(t),r=await t.action(S.signingActions.testConnection,{client:n,provider:uy(this.provider)});return this.print(r,i=>[{ok:i.ok?"yes":"NO",provider:i.provider,environment:i.environment,accountId:i.accountId??"",baseUri:i.baseUri??"",sender:i.sender?`${i.sender.email??i.sender.userId}${i.sender.name?` (${i.sender.name})`:""}`:"",error:i.error??"",consentUrl:i.consentUrl??""}]),r.ok?0:1}},ate={current:"",previous:" \xB7 mit vorherigem Schl\xFCssel versiegelt (signing connection reseal)",unknown:" \xB7 mit unbekanntem Schl\xFCssel versiegelt \u2014 nicht zu \xF6ffnen"},N$=class extends P{static{s(this,"SigningConnectionResealCommand")}static paths=[["platform","signing","connection","reseal"],["signing","connection","reseal"]];static usage=E.Usage({category:"Signing",description:"After a key rotation: seal every school's connection secrets that are still under SIGNING_CREDENTIALS_KEY_PREVIOUS anew under SIGNING_CREDENTIALS_KEY \u2014 same secrets, same binding to tenant, provider and target. Idempotent. Platform-wide, platform right `_platform.config.manage`. Runbook: docs/signing/operations.md \u2192 \u201ERotating the key\u201C.",examples:[["Reseal on staging","$0 signing connection reseal --env staging"]]});async execute(){let n=await(await this.caller()).action(S.signingConnections.reseal,{});return this.print(n,r=>[{resealed:String(r.resealed),changedMeanwhile:String(r.changedMeanwhile),remainingUnderPrevious:String(r.remainingUnderPrevious),underUnknownKey:String(r.underUnknownKey),previousRemovable:r.previousRemovable?"yes \u2014 SIGNING_CREDENTIALS_KEY_PREVIOUS can go":"no"}]),lte(n)?1:0}};function lte(e){return e.remainingUnderPrevious>0||e.underUnknownKey>0}s(lte,"resealLeftWork");var P$=class extends P{static{s(this,"SigningStatusCommand")}static paths=[["platform","signing","status"],["signing","status"]];static usage=E.Usage({category:"Signing",description:"The installation's signing key slots: which key every school's secrets are sealed under (current / previous / unknown), and whether SIGNING_CREDENTIALS_KEY_PREVIOUS can be removed because nothing is sealed under it any more. Platform right `_platform.config.manage`.",examples:[["Key status on prod","$0 signing status --env prod"]]});async execute(){let n=await(await this.caller()).query(S.signingConnections.keyStatus,{});return this.print(n,r=>[{currentKey:r.currentKeyId??"\u2014 (SIGNING_CREDENTIALS_KEY unset)",previousKey:r.previousKeyId??"\u2014",sealedCurrent:String(r.sealed.current),sealedPrevious:String(r.sealed.previous),sealedUnknown:String(r.sealed.unknown),previousSlot:r.previousConfigured?r.previousRemovable?"nothing sealed under it \u2014 can be removed":"still in use \u2014 run `platform signing connection reseal`":"unset"}]),n.sealed.unknown>0?1:0}},C$=class extends P{static{s(this,"SigningConnectionActivateCommand")}static paths=[["platform","signing","connection","activate"],["signing","connection","activate"]];static usage=E.Usage({category:"Signing",description:"\u201EF\xFCr Vertr\xE4ge verwenden\u201C: make this provider the one the tenant's contracts go out through (any other connection is deactivated in the same step), or switch it off with --off. Open Vorg\xE4nge stay on the account they started on. Platform right `_platform.config.manage`.",examples:[["Activate inSign","$0 signing connection activate --provider insign --env local --tenant test"],["No provider any more","$0 signing connection activate --provider insign --off --env local --tenant test"]]});provider=f.String("--provider",{required:!0,description:$o.join(" | ")});off=f.Boolean("--off",!1,{description:"Deactivate instead."});async execute(){let t=await this.caller(),n=this.requireTenant(t),r=uy(this.provider);return await t.mutation(S.signingConnections.setActive,{client:n,provider:r,active:!this.off}),this.print({provider:r,active:!this.off},i=>[{provider:i.provider,active:i.active?"yes":"no"}]),0}},D$=class extends P{static{s(this,"SigningConnectionDeleteCommand")}static paths=[["platform","signing","connection","delete"],["signing","connection","delete"],["signing","connection","remove"]];static usage=E.Usage({category:"Signing",description:"Delete the tenant's connection at ONE provider, secrets included. Refused while an open Vorgang talks through it. Dry-run unless --confirm. Platform right `_platform.config.manage`.",examples:[["Delete","$0 signing connection delete --provider docusign --confirm --env staging --tenant <slug>"]]});provider=f.String("--provider",{required:!0,description:$o.join(" | ")});confirm=f.Boolean("--confirm",!1,{description:"Actually delete (default: say what would go)."});async execute(){let t=await this.caller(),n=this.requireTenant(t),r=uy(this.provider);return this.confirm?(await t.mutation(S.signingConnections.remove,{client:n,provider:r}),this.print({provider:r,deleted:!0},i=>[{provider:i.provider,deleted:"yes"}]),0):(this.context.stdout.write(`Would delete the ${Pc[r]} connection of ${n} (secrets included). Re-run with --confirm.
|
|
11979
|
+
`),this.print(r,i=>i.providers.map(o=>{let a=o.connection,l=a===null?"":a.settings.provider==="docusign"?`userId=${a.settings.userId}${a.settings.accountId?` accountId=${a.settings.accountId}`:""}`:`baseUrl=${a.settings.baseUrl} username=${a.settings.username} ownerId=${a.settings.ownerId}`,d=[...o.platformProblems,...a?.problems??[]];return{provider:Pc[o.provider],state:a===null?"nicht eingerichtet":a.state,active:a?.active?"yes":"no",environment:a?.environment??"",settings:l,redirect:a?.settings.signerRedirectTo??"",secrets:a===null||a.secrets.names.length===0?"":`${a.secrets.names.join(", ")} \xB7 ${a.secrets.fingerprint??"?"} \xB7 ${Br(a.secrets.setAt)}${ate[a.secrets.sealedWith??"current"]}`,lastCheck:a?.lastCheck?`${a.lastCheck.ok?"ok":"FAILED"} ${Br(a.lastCheck.at)}${a.lastCheck.message?` \u2014 ${a.lastCheck.message}`:""}`:"",webhook:o.webhookConfigured?"configured":"none (poll only)",problems:[...new Set(d.map(c=>Nz(c).de))].join("; ")}})),0}},O$=class extends P{static{s(this,"SigningConnectionSetCommand")}static paths=[["platform","signing","connection","set"],["signing","connection","set"]];static usage=E.Usage({category:"Signing",description:"Set up or change the tenant's connection at ONE provider (platform right `_platform.config.manage`). Non-secret fields are written as given; the secret (DocuSign: Connect HMAC key, inSign: API password) comes ONLY from stdin or a file and is left unchanged when neither is given. A demo/sandbox account needs --redirect-to, a production account forbids it and is refused outside prod.",examples:[["inSign sandbox",'printf %s "$INSIGN_PASSWORD" | $0 signing connection set --provider insign --base-url https://sandbox.test.getinsign.show --username controller --owner-id plexus-dev --redirect-to admin@plexus.swop.schule --secret-stdin --env local --tenant test'],["DocuSign sender, HMAC key from a file","$0 signing connection set --provider docusign --user-id <GUID> --redirect-to admin@plexus.swop.schule --secret-file ./hmac.txt --env staging --tenant <slug>"],["Remove the HMAC key (poll only)","$0 signing connection set --provider docusign --user-id <GUID> --clear-secret hmacKey --env staging --tenant <slug>"]]});provider=f.String("--provider",{required:!0,description:$o.join(" | ")});userId=f.String("--user-id",{description:"DocuSign: the school's sender (API user id, GUID)."});baseUrl=f.String("--base-url",{description:"inSign: bare https origin of the account."});username=f.String("--username",{description:"inSign: API user."});ownerId=f.String("--owner-id",{description:"inSign: owner (`foruser`) of every session."});redirectTo=f.String("--redirect-to",{description:"Demo/sandbox only: every recipient address is replaced by this one. Omit on a production account."});secretStdin=f.Boolean("--secret-stdin",!1,{description:"Read the secret from stdin."});secretFile=f.String("--secret-file",{description:"Read the secret from this file."});clearSecret=f.String("--clear-secret",{description:"Remove the stored secret of this name (hmacKey | password)."});async execute(){let t=uy(this.provider),r=this.secretStdin||this.secretFile!==void 0?await lo({stdin:this.secretStdin,file:this.secretFile},ao(this.context.stdin)):void 0,i=this.redirectTo!==void 0?{signerRedirectTo:this.redirectTo}:{},o;if(t==="docusign"){if(this.userId===void 0)throw new g("--user-id is required for docusign");o={provider:t,userId:this.userId,...i}}else{if(this.baseUrl===void 0||this.username===void 0||this.ownerId===void 0)throw new g("--base-url, --username and --owner-id are required for insign");o={provider:t,baseUrl:this.baseUrl,username:this.username,ownerId:this.ownerId,...i}}let a=await this.caller(),l=this.requireTenant(a),d=await a.action(S.signingConnections.save,{client:l,settings:o,...r!==void 0?{secrets:{[_z[t]]:r}}:{},...this.clearSecret!==void 0?{clearSecrets:[this.clearSecret]}:{}});return this.print(d,c=>[{connectionId:c.connectionId,next:"signing connection test --provider "+t}]),0}},_$=class extends P{static{s(this,"SigningConnectionTestCommand")}static paths=[["signing","connection","test"]];static usage=E.Usage({category:"Signing",description:"\u201EVerbindung testen\u201C: reach the school's account (DocuSign: JWT grant \u2192 token \u2192 userinfo; inSign: version + owner) and record the result on the connection. A DocuSign consent_required answer prints the URL the school's sender must open once. Exit 1 when the test fails.",examples:[["Test inSign","$0 signing connection test --provider insign --env local --tenant test"]]});provider=f.String("--provider",{required:!0,description:$o.join(" | ")});async execute(){let t=await this.caller(),n=this.requireTenant(t),r=await t.action(S.signingActions.testConnection,{client:n,provider:uy(this.provider)});return this.print(r,i=>[{ok:i.ok?"yes":"NO",provider:i.provider,environment:i.environment,accountId:i.accountId??"",baseUri:i.baseUri??"",sender:i.sender?`${i.sender.email??i.sender.userId}${i.sender.name?` (${i.sender.name})`:""}`:"",error:i.error??"",consentUrl:i.consentUrl??""}]),r.ok?0:1}},ate={current:"",previous:" \xB7 mit vorherigem Schl\xFCssel versiegelt (signing connection reseal)",unknown:" \xB7 mit unbekanntem Schl\xFCssel versiegelt \u2014 nicht zu \xF6ffnen"},N$=class extends P{static{s(this,"SigningConnectionResealCommand")}static paths=[["platform","signing","connection","reseal"],["signing","connection","reseal"]];static usage=E.Usage({category:"Signing",description:"After a key rotation: seal every school's connection secrets that are still under SIGNING_CREDENTIALS_KEY_PREVIOUS anew under SIGNING_CREDENTIALS_KEY \u2014 same secrets, same binding to tenant, provider and target. Idempotent. Platform-wide, platform right `_platform.config.manage`. Runbook: docs/integrations/signing/operations.md \u2192 \u201ERotating the key\u201C.",examples:[["Reseal on staging","$0 signing connection reseal --env staging"]]});async execute(){let n=await(await this.caller()).action(S.signingConnections.reseal,{});return this.print(n,r=>[{resealed:String(r.resealed),changedMeanwhile:String(r.changedMeanwhile),remainingUnderPrevious:String(r.remainingUnderPrevious),underUnknownKey:String(r.underUnknownKey),previousRemovable:r.previousRemovable?"yes \u2014 SIGNING_CREDENTIALS_KEY_PREVIOUS can go":"no"}]),lte(n)?1:0}};function lte(e){return e.remainingUnderPrevious>0||e.underUnknownKey>0}s(lte,"resealLeftWork");var P$=class extends P{static{s(this,"SigningStatusCommand")}static paths=[["platform","signing","status"],["signing","status"]];static usage=E.Usage({category:"Signing",description:"The installation's signing key slots: which key every school's secrets are sealed under (current / previous / unknown), and whether SIGNING_CREDENTIALS_KEY_PREVIOUS can be removed because nothing is sealed under it any more. Platform right `_platform.config.manage`.",examples:[["Key status on prod","$0 signing status --env prod"]]});async execute(){let n=await(await this.caller()).query(S.signingConnections.keyStatus,{});return this.print(n,r=>[{currentKey:r.currentKeyId??"\u2014 (SIGNING_CREDENTIALS_KEY unset)",previousKey:r.previousKeyId??"\u2014",sealedCurrent:String(r.sealed.current),sealedPrevious:String(r.sealed.previous),sealedUnknown:String(r.sealed.unknown),previousSlot:r.previousConfigured?r.previousRemovable?"nothing sealed under it \u2014 can be removed":"still in use \u2014 run `platform signing connection reseal`":"unset"}]),n.sealed.unknown>0?1:0}},C$=class extends P{static{s(this,"SigningConnectionActivateCommand")}static paths=[["platform","signing","connection","activate"],["signing","connection","activate"]];static usage=E.Usage({category:"Signing",description:"\u201EF\xFCr Vertr\xE4ge verwenden\u201C: make this provider the one the tenant's contracts go out through (any other connection is deactivated in the same step), or switch it off with --off. Open Vorg\xE4nge stay on the account they started on. Platform right `_platform.config.manage`.",examples:[["Activate inSign","$0 signing connection activate --provider insign --env local --tenant test"],["No provider any more","$0 signing connection activate --provider insign --off --env local --tenant test"]]});provider=f.String("--provider",{required:!0,description:$o.join(" | ")});off=f.Boolean("--off",!1,{description:"Deactivate instead."});async execute(){let t=await this.caller(),n=this.requireTenant(t),r=uy(this.provider);return await t.mutation(S.signingConnections.setActive,{client:n,provider:r,active:!this.off}),this.print({provider:r,active:!this.off},i=>[{provider:i.provider,active:i.active?"yes":"no"}]),0}},D$=class extends P{static{s(this,"SigningConnectionDeleteCommand")}static paths=[["platform","signing","connection","delete"],["signing","connection","delete"],["signing","connection","remove"]];static usage=E.Usage({category:"Signing",description:"Delete the tenant's connection at ONE provider, secrets included. Refused while an open Vorgang talks through it. Dry-run unless --confirm. Platform right `_platform.config.manage`.",examples:[["Delete","$0 signing connection delete --provider docusign --confirm --env staging --tenant <slug>"]]});provider=f.String("--provider",{required:!0,description:$o.join(" | ")});confirm=f.Boolean("--confirm",!1,{description:"Actually delete (default: say what would go)."});async execute(){let t=await this.caller(),n=this.requireTenant(t),r=uy(this.provider);return this.confirm?(await t.mutation(S.signingConnections.remove,{client:n,provider:r}),this.print({provider:r,deleted:!0},i=>[{provider:i.provider,deleted:"yes"}]),0):(this.context.stdout.write(`Would delete the ${Pc[r]} connection of ${n} (secrets included). Re-run with --confirm.
|
|
11980
11980
|
`),0)}},F$=class extends P{static{s(this,"SigningListCommand")}static paths=[["signing","list"]];static usage=E.Usage({category:"Signing",description:"List Signaturvorg\xE4nge of a tenant (newest first), optionally for one contract or one status.",examples:[["Everything open","$0 signing list --env local --tenant test --status sent"],["One contract","$0 signing list --env local --tenant test --contract <contractId>"]]});contract=f.String("--contract",{description:"Contract id (contracts table)."});status=f.String("--status",{description:"pending | sent | partially_signed | completed | declined | voided | expired | failed"});async execute(){let t=await this.caller(),n=this.requireTenant(t),r=this.contract?await t.query(S.signing.listForContract,{client:n,contractId:ee(this.contract,"contract")}):await t.query(S.signing.listForTenant,{client:n,...this.status?{status:this.status}:{}});return this.print(r,ote,ste),0}},L$=class extends P{static{s(this,"SigningStartCommand")}static paths=[["signing","start"]];static usage=E.Usage({category:"Signing",description:"Start a Signaturvorgang on a frozen contract revision (contract_snapshots id) through the tenant's ACTIVE connection (`signing connection show`) \u2014 there is no provider to choose. Inserts the request and schedules the provider call; follow with `signing show`.",examples:[["Start","$0 signing start --env local --tenant test --snapshot <contractSnapshotId>"]]});snapshot=f.String("--snapshot",{required:!0,description:"contract_snapshots id of the revision to sign."});async execute(){let t=await this.caller(),n=this.requireTenant(t),r=await t.mutation(S.signing.start,{client:n,contractSnapshotId:ee(this.snapshot,"contract snapshot")});return this.print(r,i=>[{signingRequestId:i.signingRequestId,next:"signing show <id> (the provider call runs async)"}]),0}},M$=class extends P{static{s(this,"SigningShowCommand")}static paths=[["signing","show"]];static usage=E.Usage({category:"Signing",description:"One Signaturvorgang with its signers, artefact URLs and received provider callbacks.",examples:[["Show","$0 signing show <signingRequestId> --env local --tenant test"]]});id=f.String({required:!0,name:"signingRequestId"});async execute(){let t=await this.caller(),n=this.requireTenant(t),r=await t.query(S.signing.get,{client:n,signingRequestId:ee(this.id,"signing request")});return r===null?(this.context.stderr.write(`signing: request ${this.id} not found in tenant ${n}
|
|
11981
11981
|
`),1):(this.print(r,i=>{let o=i.request,a=[{key:"id",value:o.id},{key:"provider",value:o.provider},{key:"status",value:o.status},...o.environment!==null?[{key:"environment",value:o.environment}]:[],{key:"contract",value:o.contractId},{key:"snapshot",value:`${o.contractSnapshotId} (rev ${o.snapshotNumber})`},...o.providerRef!==null?[{key:"providerRef",value:o.providerRef}]:[],{key:"created",value:Br(o.createdAt)},{key:"sent",value:Br(o.sentAt)},{key:"completed",value:Br(o.completedAt)},...o.lastReconciledAt!==null?[{key:"reconciled",value:Br(o.lastReconciledAt)}]:[],...o.note!==null?[{key:"note",value:o.note}]:[],...o.error!==null?[{key:"error",value:o.error.de}]:[],...o.voidedReason!==null?[{key:"voidedReason",value:o.voidedReason.de}]:[],...o.declinedReason!==null?[{key:"declinedReason",value:o.declinedReason}]:[],...o.certificateUrl!==null?[{key:"certificate",value:o.certificateUrl}]:[]],l=o.signedDocuments.map((u,p)=>({key:`signedDocument ${p+1}`,value:`${u.filename} sha256=${u.sha256} uploaded=${Br(u.uploadedAt)} signers=${u.signers.map(h=>h.role).join(", ")} url=${u.url??"-"}`})),d=o.signers.map(u=>({key:`signer ${u.recipientId??u.role}`,value:[u.name,...u.email!==void 0?[`<${u.email}>`]:[],...u.originalEmail!==void 0?[`(orig ${u.originalEmail})`]:[],`role=${u.role}`,`status=${u.status}`,...u.signedAt!==void 0?[`signedAt=${u.signedAt}`]:[],...u.declinedReason!==void 0?[`declined="${u.declinedReason}"`]:[]].join(" ")})),c=i.receipts.map(u=>({key:`receipt ${u.event}`,value:`generated=${u.generatedDateTime} retry=${u.retryCount} received=${Br(u.receivedAt)}`}));return[...a,...l,...d,...c]},["key","value"]),0)}},q$=class extends P{static{s(this,"SigningVoidCommand")}static paths=[["signing","void"]];static usage=E.Usage({category:"Signing",description:"Withdraw the process at the provider (schedules the void; the request ends `voided`) \u2014 irreversible, plan unless --confirm.",examples:[["Plan",'$0 signing void <signingRequestId> --reason "Neuer Vertrag folgt" --env local --tenant test'],["Void",'$0 signing void <signingRequestId> --reason "Neuer Vertrag folgt" --confirm --env local --tenant test']]});id=f.String({required:!0,name:"signingRequestId"});reason=f.String("--reason",{required:!0,description:"Recorded on the request (and shown to the recipients where the provider supports it, e.g. DocuSign)."});confirm=f.Boolean("--confirm",!1,{description:"Void (without it, only the plan is printed)."});async execute(){let t=await this.caller(),n=this.requireTenant(t);if(!this.confirm){let r=await t.query(S.signing.get,{client:n,signingRequestId:ee(this.id,"signing request")});if(r===null)throw new g(`signing: request ${this.id} not found in tenant ${n}.`);let i=r.request;return this.print({signingRequestId:i.id,provider:i.provider,status:i.status,voided:!1},o=>[{ok:"would void",signingRequestId:`${o.signingRequestId} (${o.provider}, ${o.status})`},{ok:"next",signingRequestId:"re-run with --confirm"}]),0}return await t.mutation(S.signing.voidRequest,{client:n,signingRequestId:ee(this.id,"signing request"),reason:this.reason}),this.print({ok:!0,signingRequestId:this.id},r=>[{ok:r.ok?"yes":"no",signingRequestId:r.signingRequestId}]),0}},K$=class extends P{static{s(this,"SigningResendCommand")}static paths=[["signing","resend"]];static usage=E.Usage({category:"Signing",description:"Re-notify one signer (by party id) of an open envelope.",examples:[["Resend","$0 signing resend <signingRequestId> --party <partyId> --env local --tenant test"]]});id=f.String({required:!0,name:"signingRequestId"});party=f.String("--party",{required:!0,description:"parties id of the signer."});async execute(){let t=await this.caller(),n=this.requireTenant(t);return await t.mutation(S.signing.resend,{client:n,signingRequestId:ee(this.id,"signing request"),partyId:ee(this.party,"party")}),this.print({ok:!0,signingRequestId:this.id,partyId:this.party},r=>[{ok:r.ok?"yes":"no",signingRequestId:r.signingRequestId,partyId:r.partyId}]),0}},j$=class extends P{static{s(this,"SigningReconcileCommand")}static paths=[["signing","reconcile"]];static usage=E.Usage({category:"Signing",description:"Re-read the process from its provider now and apply it (bypasses the 15-minute poll window on purpose \u2014 the local-dev return path without a webhook).",examples:[["Reconcile","$0 signing reconcile <signingRequestId> --env local --tenant test"]]});id=f.String({required:!0,name:"signingRequestId"});async execute(){let t=await this.caller(),n=this.requireTenant(t);return await t.mutation(S.signing.reconcileNow,{client:n,signingRequestId:ee(this.id,"signing request")}),this.print({ok:!0,signingRequestId:this.id,next:"signing show <id> in a few seconds"},r=>[{ok:r.ok?"yes":"no",signingRequestId:r.signingRequestId,next:r.next}]),0}},Pz=[I$,O$,_$,C$,D$,N$,P$,F$,L$,M$,q$,K$,j$];var V$="unasked";var dte=/^[a-z0-9][a-z0-9._-]*$/,cte=/^\d{4}-\d{2}-\d{2}$/,B$=["first_name","last_name"];function Lz(e){let t=[];if(!Vn(e))return["The mapping is not a JSON object."];e.version!==1&&t.push(`version must be 1 (got ${JSON.stringify(e.version)}).`),[";",","," "].includes(e.delimiter)||t.push('delimiter must be ";", "," or "\\t".'),(typeof e.sourceKey!="string"||!dte.test(e.sourceKey))&&t.push("sourceKey must be a lower-case key (letters, digits, . _ -), e.g. altsystem-schueler.");let n=e.person;if((!Vn(n)||typeof n.key!="string"||n.key==="")&&t.push("person.key must name the column of the person's stable key."),Vn(n)&&t.push(...Cz("person",n)),!Array.isArray(e.related))t.push("related must be a list (empty when the file has no related persons).");else{let i=new Set;for(let[o,a]of e.related.entries()){let l=`related[${o}]`;if(!Vn(a)){t.push(`${l} is not an object.`);continue}if(typeof a.block!="string"||a.block.trim()===""?t.push(`${l}.block must name the block.`):i.has(a.block)?t.push(`${l}.block "${a.block}" is used twice.`):i.add(a.block),t.push(...Cz(l,a)),(!fy(a.presentWhen)||a.presentWhen.length===0)&&t.push(`${l}.presentWhen must list at least one column.`),a.mergeOn!==void 0&&(!fy(a.mergeOn)||a.mergeOn.length===0))t.push(`${l}.mergeOn must list field keys (or be left out: the person then belongs to the row alone).`);else if(fy(a.mergeOn)&&Vn(a.fields)){let d=a.mergeOn.filter(c=>!(c in a.fields));d.length>0&&t.push(`${l}.mergeOn names fields the block does not map: ${d.join(", ")}.`)}if(!Array.isArray(a.relationships)||a.relationships.length===0)t.push(`${l}.relationships must list at least one edge \u2014 a related person without an edge links to nobody.`);else for(let[d,c]of a.relationships.entries()){if(!Vn(c)||typeof c.field!="string"||!Vn(c.edge)){t.push(`${l}.relationships[${d}] must be { field, edge }.`);continue}for(let[u,p]of Object.entries(c.edge))pte(p)||t.push(`${l}.relationships[${d}].edge.${u} must be a column or { value }.`)}}}e.values!==void 0&&(!Vn(e.values)||!Object.values(e.values).every(i=>Vn(i)&&Object.values(i).every(o=>typeof o=="string"&&o!=="")))&&t.push("values must map column \u2192 raw value \u2192 list element key.");let r=e.enrollment;if(r!==void 0)if(!Vn(r)||typeof r.unit!="string"||typeof r.code!="string"||typeof r.schoolYear!="string"||r.schoolYear.trim()==="")t.push("enrollment must name the unit and class columns and the school year (the key learning-groups apply used).");else for(let i of["startDate","endDate"])r[i]!==void 0&&typeof r[i]!="string"&&t.push(`enrollment.${i} must name a column.`);return(!Array.isArray(e.ignoredColumns)||!e.ignoredColumns.every(i=>Vn(i)&&typeof i.column=="string"&&typeof i.reason=="string"&&i.reason.trim()!==""))&&t.push("ignoredColumns must list { column, reason } entries, each with a reason."),t}s(Lz,"personMappingProblems");function Cz(e,t){let n=[];if(!Vn(t.fields))return[`${e}.fields must map field keys to columns.`];for(let r of B$)typeof t.fields[r]!="string"&&n.push(`${e}.fields.${r} must name a column \u2014 every person has a first and last name.`);for(let[r,i]of Object.entries(t.fields))typeof i!="string"&&(!Vn(i)||!Object.values(i).every(o=>typeof o=="string"))&&n.push(`${e}.fields.${r} must be a column, or property \u2192 column for an object field.`);return(!fy(t.roles)||t.roles.length===0)&&n.push(`${e}.roles must list at least one role key.`),n}s(Cz,"blockProblems");function ute(e){let t=[e.person.key,...Dz(e.person)];for(let n of e.related){t.push(...Dz(n),...n.presentWhen);for(let r of n.relationships)for(let i of Object.values(r.edge))typeof i=="string"&&t.push(i)}if(e.enrollment!==void 0){let{unit:n,code:r,startDate:i,endDate:o}=e.enrollment;t.push(n,r,...[i,o].filter(a=>a!==void 0))}return[...new Set(t)]}s(ute,"personMappingColumns");function Dz(e){return Object.values(e.fields).flatMap(t=>typeof t=="string"?[t]:Object.values(t))}s(Dz,"blockColumns");function Mz(e,t){let n=[],r=ute(t),i=t.ignoredColumns.map(y=>y.column),o=new Set(e.columns),a=new Set([...r,...i]),l=e.columns.filter(y=>!a.has(y));l.length>0&&n.push(`Columns neither read by the mapping nor in ignoredColumns: ${l.join(", ")}.`);let d=i.filter(y=>r.includes(y));d.length>0&&n.push(`Columns both read by the mapping and in ignoredColumns: ${d.join(", ")}.`);let c=[...new Set([...r,...i])].filter(y=>!o.has(y));c.length>0&&n.push(`The mapping names columns the file does not have: ${c.join(", ")}.`);let u=Object.keys(t.values??{}).filter(y=>!r.includes(y));if(u.length>0&&n.push(`values maps columns the mapping does not read: ${u.join(", ")}.`),n.length>0)return{rows:[],problems:n};let p=[],h=new Map;for(let y of e.rows){let b=`line ${y.line}`,k=Fo(y,t.person.key);if(k===""){n.push(`${b}: the key column "${t.person.key}" is empty.`);continue}let v=h.get(k);if(v!==void 0){n.push(`${b}: the key "${k}" was already used on line ${v}.`);continue}h.set(k,y.line);let T=Fz(t.person,y,t),$=B$.filter(N=>T[N]===void 0);if($.length>0){n.push(`${b} (${k}): ${$.join(" and ")} is empty.`);continue}let I=[],C=!1;for(let N of t.related){if(N.presentWhen.every(x=>Fo(y,x)===""))continue;let M=Fz(N,y,t),A=B$.filter(x=>M[x]===void 0);if(A.length>0){n.push(`${b} (${k}): block ${N.block} names a person but ${A.join(" and ")} is empty.`),C=!0;continue}I.push({block:N.block,mergeOn:N.mergeOn??[],roles:N.roles,values:M,edges:N.relationships.map(x=>({field:x.field,edge:Object.fromEntries(Object.entries(x.edge).map(([q,V])=>[q,typeof V=="string"?U$(t,V,Fo(y,V)):V.value]).filter(([,q])=>q!==""))}))})}if(C)continue;let F=fte(t,y,b,n);F!==void 0&&p.push({line:y.line,key:k,roles:t.person.roles,values:T,related:I,enrollment:F})}return n.length===0&&p.length===0&&n.push("The file holds no data row."),{rows:p,problems:n}}s(Mz,"personRows");function fte(e,t,n,r){let i=e.enrollment;if(i===void 0)return null;let o=Fo(t,i.unit),a=Fo(t,i.code);if(o===""||a===""){r.push(`${n}: the class columns "${i.unit}"/"${i.code}" are empty.`);return}let l={startDate:null,endDate:null};for(let d of["startDate","endDate"]){let c=i[d];if(c===void 0)continue;let u=Fo(t,c);if(u!==""){if(!cte.test(u)){r.push(`${n}: ${c} "${u}" is no YYYY-MM-DD date.`);return}l[d]=u}}return{groupKey:qv(o,i.schoolYear,a),...l}}s(fte,"enrollmentOf");function Fz(e,t,n){let r={};for(let[i,o]of Object.entries(e.fields)){if(typeof o=="string"){let l=U$(n,o,Fo(t,o));l!==""&&(r[i]=l);continue}let a=Object.fromEntries(Object.entries(o).map(([l,d])=>[l,U$(n,d,Fo(t,d))]).filter(([,l])=>l!==""));Object.keys(a).length>0&&(r[i]=a)}return r}s(Fz,"blockValues");function U$(e,t,n){let r=e.values!==void 0&&Object.hasOwn(e.values,t)?e.values[t]:void 0;return r!==void 0&&Object.hasOwn(r,n)?r[n]:n}s(U$,"mapped");function Fo(e,t){return(e.cells[t]??"").trim()}s(Fo,"cell");function pte(e){return typeof e=="string"||Vn(e)&&["string","boolean","number"].includes(typeof e.value)}s(pte,"isCellSource");function fy(e){return Array.isArray(e)&&e.every(t=>typeof t=="string"&&t!=="")}s(fy,"isStringList");function Vn(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}s(Vn,"isRecord");var G$=class extends P{static{s(this,"PersonsListCommand")}static paths=[["persons","list"],["stammdaten","persons"]];static usage=E.Usage({category:"Persons",description:"Search persons in the active tenant"});query=f.String("-q,--query","",{description:"Free-text search"});limit=f.String("--limit","25",{description:"Max rows (default 25)"});all=f.Boolean("--all",!1,{description:"Fetch every page (ignores --limit)"});deleted=f.Boolean("--deleted",!1,{description:"List the persons staff deleted (the app's \u201EGel\xF6schte\u201C view) instead"});async execute(){let t=oa(this.limit,25),n=this.all?void 0:t,r=await this.caller(),i=this.requireTenant(r),o=await this.paginate(r,S.parties.listForMainPage,this.deleted?{client:i,deleted:!0}:{client:i,q:this.query},{max:n});return this.print(o,a=>a.map(l=>({id:l.id,name:l.name,roles:l.roles.map(d=>d.key).join(",")})),["id","name","roles"]),0}},z$=class extends P{static{s(this,"PersonsPurgeCommand")}static paths=[["platform","persons","purge"],["persons","purge"],["stammdaten","persons","purge"]];static usage=E.Usage({category:"Persons",description:"Hard-delete a person staff already deleted, with everything that belongs to it (plan unless --confirm). Needs _platform.config.manage.",details:"Only a person in the app's \u201EGel\xF6schte\u201C view can be purged. The plan lists the rows per table, the person's stored files (taken unless something else still holds them) and every receipt (contract, invoice, signature, \u2026) that refuses the commit. A person a running application still holds, or one linked to a user account, is refused. A person finished applications name as applicant is deleted in two steps: each --confirm starts the purge of the next such application and deletes nothing else (JSON: purgingApplications non-empty, applied false); once none is listed, --confirm deletes the person.",examples:[["Plan","plexus-cli --env staging --tenant test platform persons purge <partyId>"],["Apply","plexus-cli --env prod --tenant <slug> platform persons purge <partyId> --confirm --allow-prod"]]});partyId=f.String({required:!0});confirm=f.Boolean("--confirm",!1,{description:"Delete for good (without it, only the plan is printed)."});async execute(){let t=await this.caller(),n=this.requireTenant(t),r=await t.mutation(S.parties.purgeDeletedParty,{tenantSlug:n,partyId:ee(this.partyId,"party"),dryRun:!this.confirm});if(this.json)return this.print(r),0;let i=this.context.stdout,o=r.purgingApplications.length>0,a=r.applied?"Deleted":o?"Not deleted yet \u2014":"Would delete";i.write(`${a} ${r.name??"(unbenannt)"} (${r.partyId}), `),i.write(`soft-deleted ${new Date(r.deletedAt).toISOString()}
|
|
11982
11982
|
`);for(let u of r.rows)i.write(` ${u.table}: ${u.count}
|
|
@@ -12033,7 +12033,7 @@ ${n.length} unusable ${o}:
|
|
|
12033
12033
|
`),r.length>0&&this.context.stdout.write(` ${r.length} linkable \u2014 plexus-cli platform users relink-auth <email>
|
|
12034
12034
|
`),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>
|
|
12035
12035
|
`)}else this.context.stdout.write(`No unusable identities.
|
|
12036
|
-
`);return n.length>0?1:0}},qE=class extends Tr{static{s(this,"UsersRelinkAuthCommand")}static paths=[["platform","users","relink-auth"],["users","relink-auth"]];static usage=E.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 eW(e,t){if(e===t)throw new g("Pass exactly one of --on or --off.");return e}s(eW,"requireOnOff");var tW=[xE,SE,AE,TE,RE,$E,EE,IE,OE,_E,lf,NE,PE,CE,DE,FE,LE,ME,qE];function nW(e){return e.de??e.en??Object.values(e)[0]??""}s(nW,"titleDe");function Kte(e){return{id:e._id,kind:e.kind,status:e.status,title:nW(e.title).slice(0,50),assignee:e.assigneeUserId??"",group:e.queueGroupId??"",outcome:e.outcome??""}}s(Kte,"row");var jte=["id","kind","status","title","assignee","group","outcome"],VE=class extends P{static{s(this,"WorkItemsListCommand")}static paths=[["work-items","list"]];static usage=E.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:ee(this.application,"application")}:{},...this.group?{queueGroupId:ee(this.group,"permission group")}:{},...this.assignee?{assigneeUserId:ee(this.assignee,"user")}:{},...this.openOnly?{openOnly:!0}:{}});return this.print(r,i=>i.map(Kte),jte),0}},BE=class extends P{static{s(this,"WorkItemsShowCommand")}static paths=[["work-items","show"]];static usage=E.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:ee(this.workItemId,"work item")});if(r===null)throw new g(`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:nW(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}},UE=class extends P{static{s(this,"WorkItemsCreateCommand")}static paths=[["work-items","create"]];static usage=E.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:ee(this.application,"application")}:{},...this.group?{queueGroupId:ee(this.group,"permission group")}:{},...this.assignee?{assigneeUserId:ee(this.assignee,"user")}:{}});return this.print({workItemId:r.workItemId},i=>[{field:"workItemId",value:i.workItemId}]),0}},GE=class extends P{static{s(this,"WorkItemsCompleteCommand")}static paths=[["work-items","complete"]];static usage=E.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:ee(this.workItemId,"work item"),...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}},zE=class extends P{static{s(this,"WorkItemsAssignCommand")}static paths=[["work-items","assign"]];static usage=E.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:ee(this.workItemId,"work item"),...this.user?{userId:ee(this.user,"user")}:{}});return this.print({workItemId:r.workItemId,assignee:this.user??"(cleared)"},i=>[{field:"workItemId",value:i.workItemId},{field:"assignee",value:i.assignee}]),0}},rW=[VE,BE,UE,GE,zE];var Rl=[...j_,...uM,...bM,...Oq,...Cq,...Iq,...sK,...pK,...fK,...Zz,...tW,...Qz,...NG,...MG,...BG,...H0,...nK,...qz,...M_,...yN,...C0,...gK,...hK,...kK,...xK,...eK,...Kq,...rW,...BB,...NU,...OG,...PU,...Sz,...Oz,...UG,...XG,...nz,...sz,...lz,...Pz,...Uz,...aN];for(let e of Rl){let t=e.paths?.[0];t===void 0||!Object.hasOwn(e,"usage")||e.usage===void 0||(e.usage={...e.usage,category:eO(e.usage.category,t.join(" "))})}var iW="0.1.361";function WE(){return Rl.flatMap(e=>(e.paths??[]).map(t=>{let n=t.join(" "),r=JI[Go(n)];return{path:n,effect:vi(n),host:r===void 0?"shared":"terminal",...r===void 0?{}:{reason:r}}})).sort((e,t)=>e.path.localeCompare(t.path))}s(WE,"plexusCommandCatalog");import js from"node:path";function Vte(e){let t=ht()?.workspaceRoot??process.cwd(),n=js.resolve(t,e),r=js.relative(t,n);if(js.isAbsolute(e)||r===".."||r.startsWith(`..${js.sep}`))throw new g("plexus: use a relative path inside the current workspace.");return{absolute:n,relative:r}}s(Vte,"workspacePath");function Bte(e){let{absolute:t,relative:n}=Vte(e.path??".");if(e.operation==="list"){if(!Re(t))return{files:[]};let r=[],i=s(o=>{for(let a of zr(o,{withFileTypes:!0})){if(a.isSymbolicLink())throw new g("plexus: workspace symlinks are not supported.");let l=js.join(o,a.name);if(a.isDirectory()?i(l):r.push(js.relative(t,l)),r.length>200)throw new g("plexus: the workspace contains too many files. List a subdirectory.")}},"visit");return i(t),{files:r.sort()}}if(!n)throw new g("plexus: name a workspace file.");if(["read","search","edit"].includes(e.operation)){let r=Ne(t);if(r.length>10*1024*1024)throw new g("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 g("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 g("plexus: edit needs oldText and replacement content.");let o=i.indexOf(e.oldText);if(o<0||o!==i.lastIndexOf(e.oldText))throw new g("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 g("plexus: the edited file exceeds 10 MB.");return Ze(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 g("plexus: file content is missing or too large.");return Gt(js.dirname(t),{recursive:!0}),Ze(t,e.content,"utf8"),{path:n,sizeBytes:Buffer.byteLength(e.content)}}if(e.operation==="remove")return Gs(t),{path:n,removed:!0};throw new g("plexus: unknown workspace operation.")}s(Bte,"plexusWorkspace");function oW(e){return s(async function(n,r){if(!r||typeof r!="object"||Array.isArray(r))throw new g("plexus: tool input must be an object.");let i=r,o=sd[n];if(!o||!Object.hasOwn(sd,n))throw new g("plexus: unknown agent tool.");if(Object.keys(i).some(a=>!Object.hasOwn(o.inputSchema.properties,a)))throw new g("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 g("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(Fw,i.path))throw new g("plexus: unknown skill reference. Start with SKILL.md.");return{path:i.path,content:Fw[i.path],skillHash:bp}}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 g("plexus: invalid workspace input.");return Bte(i)},"executePlexusAgentTool")}s(oW,"createPlexusAgentToolExecutor");var Ute=["--env","--tenant"];function sW(e){let t=[],n=[];for(let r=0;r<e.length;r++){let i=e[r];if(i==="--"){t.push(...e.slice(r));break}let o=Ute.find(l=>i===l||i.startsWith(`${l}=`)),a=e[r+1];o===void 0?t.push(i):i!==o?n.push({name:o,value:i.slice(o.length+1)}):a!==void 0&&!a.startsWith("-")?(n.push({name:o,value:a}),r++):t.push(i)}return{rest:t,given:n}}s(sW,"splitGlobalOptions");function aW(e,t){let n=Hy(e)==="offline";if(n&&vi(e)==="read")return t.map(i=>`plexus-cli: ${i.name} ${i.value} has no effect: \`${e}\` runs offline (this CLI's own files, no deployment).
|
|
12036
|
+
`);return n.length>0?1:0}},qE=class extends Tr{static{s(this,"UsersRelinkAuthCommand")}static paths=[["platform","users","relink-auth"],["users","relink-auth"]];static usage=E.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 eW(e,t){if(e===t)throw new g("Pass exactly one of --on or --off.");return e}s(eW,"requireOnOff");var tW=[xE,SE,AE,TE,RE,$E,EE,IE,OE,_E,lf,NE,PE,CE,DE,FE,LE,ME,qE];function nW(e){return e.de??e.en??Object.values(e)[0]??""}s(nW,"titleDe");function Kte(e){return{id:e._id,kind:e.kind,status:e.status,title:nW(e.title).slice(0,50),assignee:e.assigneeUserId??"",group:e.queueGroupId??"",outcome:e.outcome??""}}s(Kte,"row");var jte=["id","kind","status","title","assignee","group","outcome"],VE=class extends P{static{s(this,"WorkItemsListCommand")}static paths=[["work-items","list"]];static usage=E.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:ee(this.application,"application")}:{},...this.group?{queueGroupId:ee(this.group,"permission group")}:{},...this.assignee?{assigneeUserId:ee(this.assignee,"user")}:{},...this.openOnly?{openOnly:!0}:{}});return this.print(r,i=>i.map(Kte),jte),0}},BE=class extends P{static{s(this,"WorkItemsShowCommand")}static paths=[["work-items","show"]];static usage=E.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:ee(this.workItemId,"work item")});if(r===null)throw new g(`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:nW(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}},UE=class extends P{static{s(this,"WorkItemsCreateCommand")}static paths=[["work-items","create"]];static usage=E.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:ee(this.application,"application")}:{},...this.group?{queueGroupId:ee(this.group,"permission group")}:{},...this.assignee?{assigneeUserId:ee(this.assignee,"user")}:{}});return this.print({workItemId:r.workItemId},i=>[{field:"workItemId",value:i.workItemId}]),0}},GE=class extends P{static{s(this,"WorkItemsCompleteCommand")}static paths=[["work-items","complete"]];static usage=E.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:ee(this.workItemId,"work item"),...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}},zE=class extends P{static{s(this,"WorkItemsAssignCommand")}static paths=[["work-items","assign"]];static usage=E.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:ee(this.workItemId,"work item"),...this.user?{userId:ee(this.user,"user")}:{}});return this.print({workItemId:r.workItemId,assignee:this.user??"(cleared)"},i=>[{field:"workItemId",value:i.workItemId},{field:"assignee",value:i.assignee}]),0}},rW=[VE,BE,UE,GE,zE];var Rl=[...j_,...uM,...bM,...Oq,...Cq,...Iq,...sK,...pK,...fK,...Zz,...tW,...Qz,...NG,...MG,...BG,...H0,...nK,...qz,...M_,...yN,...C0,...gK,...hK,...kK,...xK,...eK,...Kq,...rW,...BB,...NU,...OG,...PU,...Sz,...Oz,...UG,...XG,...nz,...sz,...lz,...Pz,...Uz,...aN];for(let e of Rl){let t=e.paths?.[0];t===void 0||!Object.hasOwn(e,"usage")||e.usage===void 0||(e.usage={...e.usage,category:eO(e.usage.category,t.join(" "))})}var iW="0.1.362";function WE(){return Rl.flatMap(e=>(e.paths??[]).map(t=>{let n=t.join(" "),r=JI[Go(n)];return{path:n,effect:vi(n),host:r===void 0?"shared":"terminal",...r===void 0?{}:{reason:r}}})).sort((e,t)=>e.path.localeCompare(t.path))}s(WE,"plexusCommandCatalog");import js from"node:path";function Vte(e){let t=ht()?.workspaceRoot??process.cwd(),n=js.resolve(t,e),r=js.relative(t,n);if(js.isAbsolute(e)||r===".."||r.startsWith(`..${js.sep}`))throw new g("plexus: use a relative path inside the current workspace.");return{absolute:n,relative:r}}s(Vte,"workspacePath");function Bte(e){let{absolute:t,relative:n}=Vte(e.path??".");if(e.operation==="list"){if(!Re(t))return{files:[]};let r=[],i=s(o=>{for(let a of zr(o,{withFileTypes:!0})){if(a.isSymbolicLink())throw new g("plexus: workspace symlinks are not supported.");let l=js.join(o,a.name);if(a.isDirectory()?i(l):r.push(js.relative(t,l)),r.length>200)throw new g("plexus: the workspace contains too many files. List a subdirectory.")}},"visit");return i(t),{files:r.sort()}}if(!n)throw new g("plexus: name a workspace file.");if(["read","search","edit"].includes(e.operation)){let r=Ne(t);if(r.length>10*1024*1024)throw new g("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 g("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 g("plexus: edit needs oldText and replacement content.");let o=i.indexOf(e.oldText);if(o<0||o!==i.lastIndexOf(e.oldText))throw new g("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 g("plexus: the edited file exceeds 10 MB.");return Ze(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 g("plexus: file content is missing or too large.");return Gt(js.dirname(t),{recursive:!0}),Ze(t,e.content,"utf8"),{path:n,sizeBytes:Buffer.byteLength(e.content)}}if(e.operation==="remove")return Gs(t),{path:n,removed:!0};throw new g("plexus: unknown workspace operation.")}s(Bte,"plexusWorkspace");function oW(e){return s(async function(n,r){if(!r||typeof r!="object"||Array.isArray(r))throw new g("plexus: tool input must be an object.");let i=r,o=sd[n];if(!o||!Object.hasOwn(sd,n))throw new g("plexus: unknown agent tool.");if(Object.keys(i).some(a=>!Object.hasOwn(o.inputSchema.properties,a)))throw new g("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 g("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(Fw,i.path))throw new g("plexus: unknown skill reference. Start with SKILL.md.");return{path:i.path,content:Fw[i.path],skillHash:bp}}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 g("plexus: invalid workspace input.");return Bte(i)},"executePlexusAgentTool")}s(oW,"createPlexusAgentToolExecutor");var Ute=["--env","--tenant"];function sW(e){let t=[],n=[];for(let r=0;r<e.length;r++){let i=e[r];if(i==="--"){t.push(...e.slice(r));break}let o=Ute.find(l=>i===l||i.startsWith(`${l}=`)),a=e[r+1];o===void 0?t.push(i):i!==o?n.push({name:o,value:i.slice(o.length+1)}):a!==void 0&&!a.startsWith("-")?(n.push({name:o,value:a}),r++):t.push(i)}return{rest:t,given:n}}s(sW,"splitGlobalOptions");function aW(e,t){let n=Hy(e)==="offline";if(n&&vi(e)==="read")return t.map(i=>`plexus-cli: ${i.name} ${i.value} has no effect: \`${e}\` runs offline (this CLI's own files, no deployment).
|
|
12037
12037
|
`);let r=[...new Set(t.map(i=>i.name))].join(", ");throw new g(n?`\`${e}\` does not take ${r}: it never targets a chosen deployment \u2014 drop the option.`:`\`${e}\` does not take ${r}.`)}s(aW,"globalOptionNotes");var by=oW({inspectCommand:dW,executeCommand:cW});function vy(){let e=new Hs({binaryLabel:"Plexus CLI",binaryName:"plexus-cli",binaryVersion:iW});e.register(Ml.HelpCommand),e.register(Ml.VersionCommand);for(let r of Rl)e.register(r);function t(r,i){try{return{command:e.process(r,i),notes:[]}}catch(o){let{rest:a,given:l}=sW(r);if(l.length===0)throw o;let d;try{d=e.process(a,i)}catch{throw o}if(!Rl.some(u=>d instanceof u))return{command:d,notes:[]};let c=d.path.join(" ");if(!WE().some(u=>u.path===c))throw o;return{command:d,notes:aW(c,l)}}}s(t,"resolve");async function n(r,i){let o=i.stderr??process.stderr,a;try{a=t(r,i)}catch(l){return o.write(e.error(l,{colored:!1})),2}for(let l of a.notes)o.write(l);return Wte(a.command,o),e.run(a.command,i)}return s(n,"run"),{process(r,i){return t(r,i).command},run:n,async runExit(r,i){process.exitCode=await n(r,i)}}}s(vy,"createPlexusCli");function Wte(e,t){let n=e.path.join(" "),r=e.constructor.paths?.[0]?.join(" ");r!==void 0&&n!==r&&Ul[n]===r&&ft(t,n,r),n in Ul&&vi(n)==="confirm"&&!Gl(e)&&t.write(`plexus-cli: \`${Ul[n]}\` only prints its plan without --confirm \u2014 nothing was changed.
|
|
12038
12038
|
`)}s(Wte,"noteRetiredPath");function dW(e){let t=vy().process(Il(e),{executePlexusAgentTool:by}),n=t.path.join(" ");if(n.startsWith("agent "))throw new Error("plexus: nested agent transports are not allowed.");let r=WE().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"?Nh(al(ll),i.fn??"",i.kind):void 0,a=Bf(n,{confirm:Gl(t),callKind:o});return{...r,writes:a}}s(dW,"inspectPlexusCommand");async function cW(e,t){if(t)return eI(t,()=>cW(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=vy();if(ht()){let l=dW(e.argv);if(l.host==="terminal")throw new Error(`plexus: this command requires a local machine. ${l.reason??""}`)}return{exitCode:await i.run(Il(e.argv),{executePlexusAgentTool:by,stdin:zte.from(e.stdin===void 0?[]:[e.stdin]),stdout:new lW({write(l,d,c){n+=String(l),c()}}),stderr:new lW({write(l,d,c){r+=String(l),c()}})}),stdout:n,stderr:r}}s(cW,"executePlexusCommand");ZE();oI({source:Yte.join(import.meta.dirname,"skill")});vy().runExit(Il(process.argv.slice(2)),{executePlexusAgentTool:by});
|
|
12039
12039
|
//# sourceMappingURL=cli.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
5a299a07b9e9bdea99400a3aad16ea461293a630af0878af015e0dd8b1d50726
|
|
@@ -3476,7 +3476,7 @@ Delete the tenant's connection at ONE provider, secrets included. Refused while
|
|
|
3476
3476
|
|
|
3477
3477
|
### `platform signing connection reseal`
|
|
3478
3478
|
|
|
3479
|
-
After a key rotation: seal every school's connection secrets that are still under SIGNING_CREDENTIALS_KEY_PREVIOUS anew under SIGNING_CREDENTIALS_KEY — same secrets, same binding to tenant, provider and target. Idempotent. Platform-wide, platform right `_platform.config.manage`. Runbook: docs/signing/operations.md → „Rotating the key“.
|
|
3479
|
+
After a key rotation: seal every school's connection secrets that are still under SIGNING_CREDENTIALS_KEY_PREVIOUS anew under SIGNING_CREDENTIALS_KEY — same secrets, same binding to tenant, provider and target. Idempotent. Platform-wide, platform right `_platform.config.manage`. Runbook: docs/integrations/signing/operations.md → „Rotating the key“.
|
|
3480
3480
|
|
|
3481
3481
|
- **Right:** platform operator — needs a `_platform.*` right; a school's token is refused
|
|
3482
3482
|
- **Effect:** write — needs `--env`; on production also `--allow-prod`
|
|
@@ -26,7 +26,7 @@ commands: [README.md](./README.md).
|
|
|
26
26
|
owner id (`foruser`). The inSign API user must hold the role
|
|
27
27
|
`ROLE_INSIGN_CONTROLLER` and the school the package `connect` or
|
|
28
28
|
`enterprise` (not `365`); what to ask the school and inSign for:
|
|
29
|
-
`docs/
|
|
29
|
+
`docs/wiki/source/insign-connect-api-and-sandbox.md`.
|
|
30
30
|
|
|
31
31
|
## Steps
|
|
32
32
|
|