@wairon/cli 5.1.1-dev.64 → 5.1.1-dev.66

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli/index.js CHANGED
@@ -65,7 +65,7 @@ var init_defaults = __esm({
65
65
  copilot: ".github/prompts",
66
66
  codex: ".codex/agents"
67
67
  };
68
- WAIRON_VERSION = "5.1.1-dev.64";
68
+ WAIRON_VERSION = "5.1.1-dev.66";
69
69
  GITHUB_REPO = "SYW-Apps/Waffle-AIron";
70
70
  SUPPORTED_ALIASES = ["wai"];
71
71
  SCAN_EXCLUDE_DIRS = /* @__PURE__ */ new Set([
@@ -2423,6 +2423,24 @@ var init_specs = __esm({
2423
2423
  * stereotypes should bind tech directly (TECH_ON_LOGIC_COMPONENT).
2424
2424
  */
2425
2425
  technologies: import_zod8.z.array(import_zod8.z.string()).optional(),
2426
+ /**
2427
+ * The parameter names THIS realization takes BEFORE the ones its contract
2428
+ * declares — a config object, a data root, the transport handles a portal is
2429
+ * handed. Supplied by whatever wires the component up, never by the caller
2430
+ * the contract describes, which is why they belong to the realization and
2431
+ * not to the contract: another realization of the same contract may hold
2432
+ * them as fields instead.
2433
+ *
2434
+ * Declared rather than guessed, because a leading parameter the contract
2435
+ * does not name is otherwise indistinguishable from one it named under a
2436
+ * different name — `seed(config)` realized as `bootstrapInstance(cfg)` reads
2437
+ * as a dropped parameter to anything that infers. A leading parameter this
2438
+ * list does not name is a finding (UNDECLARED_PARAM), and only a LEADING run
2439
+ * is dropped: one of these names appearing after the contract's own
2440
+ * parameters is not wiring, it is an argument in the middle of the caller's
2441
+ * list.
2442
+ */
2443
+ injectedParams: import_zod8.z.array(import_zod8.z.string()).optional(),
2426
2444
  methods: import_zod8.z.array(MethodImplementationSchema).default([]).superRefine((methods, ctx) => {
2427
2445
  methods.forEach((m, i) => {
2428
2446
  if (!m.calls?.length || m.narrative.length === 0) return;
@@ -14080,6 +14098,173 @@ var init_type_shape = __esm({
14080
14098
  }
14081
14099
  });
14082
14100
 
14101
+ // src/core/rules/conformance/param-conformance.ts
14102
+ function omittable(optional) {
14103
+ return optional ? "may be left out" : "is required";
14104
+ }
14105
+ function unitOf2(parameter, position) {
14106
+ return parameter.name ?? `#${position + 1}`;
14107
+ }
14108
+ function judge(declared, realized, injected, typeAgrees) {
14109
+ let wiring = 0;
14110
+ while (wiring < realized.length && realized[wiring].name !== void 0 && injected.has(realized[wiring].name)) wiring++;
14111
+ const taken = realized.slice(wiring);
14112
+ const matched = Math.min(declared.length, taken.length);
14113
+ const found = {
14114
+ unrealized: /* @__PURE__ */ new Map(),
14115
+ undeclared: /* @__PURE__ */ new Map(),
14116
+ renamed: /* @__PURE__ */ new Map(),
14117
+ optionality: /* @__PURE__ */ new Map()
14118
+ };
14119
+ for (const param of declared.slice(matched)) {
14120
+ found.unrealized.set(param.name, { unit: param.name, told: `"${param.name}"` });
14121
+ }
14122
+ taken.slice(matched).forEach((param, index) => {
14123
+ const unit = unitOf2(param, wiring + matched + index);
14124
+ found.undeclared.set(unit, { unit, told: `"${unit}"` });
14125
+ });
14126
+ for (let position = 0; position < matched; position++) {
14127
+ const param = declared[position];
14128
+ const at = taken[position];
14129
+ if (at.name !== void 0 && at.name !== param.name && typeAgrees(param, at)) {
14130
+ found.renamed.set(`${param.name}\u2192${at.name}`, {
14131
+ unit: param.name,
14132
+ told: `"${param.name}" (the code calls it "${at.name}")`
14133
+ });
14134
+ }
14135
+ if (!!param.optional !== at.optional) {
14136
+ found.optionality.set(`${param.name}:${at.optional}`, {
14137
+ unit: param.name,
14138
+ told: `"${param.name}" (the contract says it ${omittable(!!param.optional)}, the code says it ${omittable(at.optional)})`
14139
+ });
14140
+ }
14141
+ }
14142
+ return found;
14143
+ }
14144
+ function agreed(judgements, reading) {
14145
+ const [first, ...rest] = judgements;
14146
+ return [...first[reading]].filter(([fact]) => rest.every((other) => other[reading].has(fact))).map(([, finding]) => finding);
14147
+ }
14148
+ var paramConformanceRule;
14149
+ var init_param_conformance = __esm({
14150
+ "src/core/rules/conformance/param-conformance.ts"() {
14151
+ "use strict";
14152
+ init_models();
14153
+ paramConformanceRule = {
14154
+ name: "param-conformance",
14155
+ description: "Code-to-contract for the SIGNATURE, the last of the three readings a spec-driven gate never made: a contract declares `params`, and nothing ever compared them to the parameters of the function that realizes the method. A contract could promise an argument the code does not take, take one the contract never mentions \u2014 including a secret \u2014 or name the same argument two different things, and the brief handed to an implementer would carry the contract's version. Parameters are matched by POSITION against the tail of the realization's list, and the declared type is what tells a rename from a dropped argument: `seed(config: HostConfig)` realized as `bootstrapInstance(cfg: HostConfig)` is one parameter under two names, which anything matching on names alone reads as a parameter the code lost. What a realization takes BEFORE the contract's own parameters is wiring, and it is declared on the implementation as `injectedParams` rather than inferred, because an inferred prefix cannot be told from a renamed first argument. A method the named file only CALLS is left to `methodRealization`, which already reports that the body is not here.",
14156
+ codes: [
14157
+ {
14158
+ code: "UNREALIZED_PARAM",
14159
+ defaultSeverity: "warning",
14160
+ summary: "A contract declares a parameter the function realizing the method does not take \u2014 the contract promises an argument that would go nowhere, and every brief and caller built from it passes one",
14161
+ // Measured code↔spec drift, parameter by parameter, at a site the
14162
+ // finding names — which is why every one of them hands over `parts`.
14163
+ carryable: true
14164
+ },
14165
+ {
14166
+ code: "UNDECLARED_PARAM",
14167
+ defaultSeverity: "warning",
14168
+ summary: "The realizing function takes a parameter no contract parameter names and no declared injection accounts for \u2014 an argument a caller must supply that the design never mentions",
14169
+ carryable: true
14170
+ },
14171
+ {
14172
+ code: "PARAM_NAME_MISMATCH",
14173
+ defaultSeverity: "warning",
14174
+ summary: "A contract parameter and the one realizing it agree on position and type but not on name \u2014 the contract, the ERD and every brief say one word while the code says another",
14175
+ carryable: true
14176
+ },
14177
+ {
14178
+ code: "PARAM_OPTIONALITY",
14179
+ defaultSeverity: "warning",
14180
+ summary: "A contract and its realization disagree about whether a parameter may be left out \u2014 one of them is telling a caller an argument is required when it is not, or the reverse",
14181
+ carryable: true
14182
+ }
14183
+ ],
14184
+ check(ctx) {
14185
+ const code = ctx.codeIndex();
14186
+ const codeNameOf = /* @__PURE__ */ new Map();
14187
+ for (const type of ctx.types) {
14188
+ const named = type.symbol ?? type.name;
14189
+ codeNameOf.set(type.id, named);
14190
+ if (type.subsystem) codeNameOf.set(`${type.subsystem}.${type.id}`, named);
14191
+ }
14192
+ const normalize3 = (text2) => text2.replace(/\s+/g, " ").trim();
14193
+ const typeAgrees = (declared, realized) => {
14194
+ if (!realized.type) return false;
14195
+ const stated = normalize3(declared.type);
14196
+ return stated === realized.type || codeNameOf.get(stated) === realized.type;
14197
+ };
14198
+ for (const { implementation, method: method2, sourceFile, draftContext } of ctx.implementationMethods()) {
14199
+ const contract = ctx.interfaceMap.get(implementation.contract);
14200
+ const declared = contract?.methods.find((m) => m.name === method2.name)?.params ?? [];
14201
+ if (declared.length === 0 || !sourceFile) continue;
14202
+ const file = pathKey(sourceFile);
14203
+ const facts = code.factsAt(file);
14204
+ if (!facts || facts.status !== "analyzed" || facts.analysisGrade !== "exact") continue;
14205
+ const symbol = method2.symbol ?? method2.name;
14206
+ const signatures = facts.functionParams;
14207
+ if (!signatures || !Object.prototype.hasOwnProperty.call(signatures, symbol)) continue;
14208
+ const candidates = signatures[symbol];
14209
+ if (candidates.length === 0) continue;
14210
+ const injected = new Set(implementation.injectedParams ?? []);
14211
+ const judgements = candidates.map((realized) => judge(declared, realized, injected, typeAgrees));
14212
+ const subject = candidates.length > 1 ? `every function called "${symbol}" in "${file}"` : `the function "${symbol}" in "${file}"`;
14213
+ const opening = subject.charAt(0).toUpperCase() + subject.slice(1);
14214
+ const unrealized = agreed(judgements, "unrealized");
14215
+ if (unrealized.length > 0) {
14216
+ ctx.addIssue(
14217
+ "warning",
14218
+ "UNREALIZED_PARAM",
14219
+ `Method "${method2.name}" of contract "${implementation.contract}" declares ${unrealized.length} parameter(s) ${subject} does not take \u2014 ${unrealized.map((found) => found.told).join(", ")}. The contract is promising an argument that would go nowhere, and nothing breaks at a call site to correct it: every brief and every caller built from the contract passes one. Take the parameter in the code, or drop it from the contract.`,
14220
+ implementation.id,
14221
+ draftContext,
14222
+ void 0,
14223
+ { at: method2.name, covers: unrealized.map((found) => found.unit) }
14224
+ );
14225
+ }
14226
+ const undeclared = agreed(judgements, "undeclared");
14227
+ if (undeclared.length > 0) {
14228
+ ctx.addIssue(
14229
+ "warning",
14230
+ "UNDECLARED_PARAM",
14231
+ `${opening} realizing method "${method2.name}" of contract "${implementation.contract}" takes ${undeclared.length} parameter(s) the contract does not declare and no declared injection accounts for \u2014 ${undeclared.map((found) => found.told).join(", ")}. An argument a caller must supply that the design never mentions is how a credential ends up in a signature nobody has read against its contract. Declare it on the contract, name it in the implementation's \`injectedParams\` when whatever wires this component up supplies it (a LEADING run only), or take it out of the signature.`,
14232
+ implementation.id,
14233
+ draftContext,
14234
+ void 0,
14235
+ { at: method2.name, covers: undeclared.map((found) => found.unit) }
14236
+ );
14237
+ }
14238
+ const renamed = agreed(judgements, "renamed");
14239
+ if (renamed.length > 0) {
14240
+ ctx.addIssue(
14241
+ "warning",
14242
+ "PARAM_NAME_MISMATCH",
14243
+ `Method "${method2.name}" of contract "${implementation.contract}" and ${subject} agree on position and type but not on name for ${renamed.length} parameter(s) \u2014 ${renamed.map((f) => f.told).join("; ")}. The contract, the ERD and every brief carry one word and the code answers to another, which is a rename nobody recorded rather than a different argument \u2014 the declared type agreeing is what says so. Rename one side to the other.`,
14244
+ implementation.id,
14245
+ draftContext,
14246
+ void 0,
14247
+ { at: method2.name, covers: renamed.map((found) => found.unit) }
14248
+ );
14249
+ }
14250
+ const disagreed = agreed(judgements, "optionality");
14251
+ if (disagreed.length > 0) {
14252
+ ctx.addIssue(
14253
+ "warning",
14254
+ "PARAM_OPTIONALITY",
14255
+ `Method "${method2.name}" of contract "${implementation.contract}" and ${subject} disagree about whether ${disagreed.length} parameter(s) may be left out \u2014 ${disagreed.map((f) => f.told).join("; ")}. One of them is telling a caller an argument is required when it is not, or the reverse. Omittable is the code's word for it: a default value and a rest parameter make an argument omittable exactly as a question mark does.`,
14256
+ implementation.id,
14257
+ draftContext,
14258
+ void 0,
14259
+ { at: method2.name, covers: disagreed.map((found) => found.unit) }
14260
+ );
14261
+ }
14262
+ }
14263
+ }
14264
+ };
14265
+ }
14266
+ });
14267
+
14083
14268
  // src/core/rules/conformance/unclaimed-source.ts
14084
14269
  var unclaimedSourceRule;
14085
14270
  var init_unclaimed_source = __esm({
@@ -15584,6 +15769,7 @@ var init_repository = __esm({
15584
15769
  init_integration_sim_coverage();
15585
15770
  init_type_realization();
15586
15771
  init_type_shape();
15772
+ init_param_conformance();
15587
15773
  init_unclaimed_source();
15588
15774
  init_export_conformance();
15589
15775
  init_carried_debt();
@@ -15752,11 +15938,14 @@ var init_repository = __esm({
15752
15938
  integrationSimWiringRule,
15753
15939
  integrationSimCoverageRule,
15754
15940
  // The data model's own claim on code — does the file hold the type, and is
15755
- // it the SHAPE the spec claims — and then the question no spec can ask from
15756
- // the spec side: which files are named by nothing at all. Last in the
15757
- // family because that one reads what all the others named.
15941
+ // it the SHAPE the spec claims — then the SIGNATURE, the third reading:
15942
+ // does the code take the arguments the contract promises. And then the
15943
+ // question no spec can ask from the spec side: which files are named by
15944
+ // nothing at all. Last in the family because that one reads what all the
15945
+ // others named.
15758
15946
  typeRealizationRule,
15759
15947
  typeShapeRule,
15948
+ paramConformanceRule,
15760
15949
  unclaimedSourceRule,
15761
15950
  exportConformanceRule,
15762
15951
  couplingRule,
@@ -15925,6 +16114,7 @@ function walkExact(ts, sourceText, fileName) {
15925
16114
  const fieldTypes = /* @__PURE__ */ new Map();
15926
16115
  const localTypes = /* @__PURE__ */ new Map();
15927
16116
  const typeShapes = /* @__PURE__ */ new Map();
16117
+ const functionParams = /* @__PURE__ */ new Map();
15928
16118
  const mutableBindings = /* @__PURE__ */ new Set();
15929
16119
  const schemaConstants = /* @__PURE__ */ new Map();
15930
16120
  const derivedAliases = [];
@@ -16054,6 +16244,14 @@ function walkExact(ts, sourceText, fileName) {
16054
16244
  }
16055
16245
  return void 0;
16056
16246
  };
16247
+ const declaredParameters = (fn) => (fn.parameters ?? []).map((parameter) => {
16248
+ const fact = {
16249
+ optional: !!parameter.questionToken || !!parameter.initializer || !!parameter.dotDotDotToken
16250
+ };
16251
+ if (ts.isIdentifier(parameter.name)) fact.name = parameter.name.text;
16252
+ if (parameter.type) fact.type = parameter.type.getText(sf).replace(/\s+/g, " ").trim();
16253
+ return fact;
16254
+ });
16057
16255
  const collectFunctionFacts = (fn) => {
16058
16256
  let score = 1;
16059
16257
  const callees = /* @__PURE__ */ new Map();
@@ -16096,6 +16294,9 @@ function walkExact(ts, sourceText, fileName) {
16096
16294
  const sites = calls.get(fnName) ?? /* @__PURE__ */ new Map();
16097
16295
  for (const [key, site] of facts.callees) sites.set(key, site);
16098
16296
  calls.set(fnName, sites);
16297
+ const signatures = functionParams.get(fnName) ?? [];
16298
+ signatures.push(declaredParameters(node));
16299
+ functionParams.set(fnName, signatures);
16099
16300
  }
16100
16301
  if (ts.isPropertyDeclaration(node)) recordFieldType(node.name, node.type);
16101
16302
  else if (ts.isParameter(node) && node.parent && ts.isConstructorDeclaration(node.parent) && isParameterProperty(node)) {
@@ -16203,7 +16404,7 @@ function walkExact(ts, sourceText, fileName) {
16203
16404
  typeShapes.set(alias.name, { origin: "derived", fields: schemaMembers(literal), methods: [] });
16204
16405
  }
16205
16406
  const reexportOnly = sf.statements.length > 0 && sf.statements.every((st) => ts.isExportDeclaration(st) && !!st.moduleSpecifier);
16206
- return { declared, anchors, exported, imports, reexports, starExports, namedReexports, complexity, calls, importBindings, typeOnlyBindings, fieldTypes, localTypes, typeShapes, mutableBindings, reexportOnly };
16407
+ return { declared, anchors, exported, imports, reexports, starExports, namedReexports, complexity, calls, importBindings, typeOnlyBindings, fieldTypes, localTypes, typeShapes, functionParams, mutableBindings, reexportOnly };
16207
16408
  }
16208
16409
  function resolveRelativeModule(fromFile, specifier) {
16209
16410
  if (!specifier.startsWith(".")) return null;
@@ -16386,6 +16587,7 @@ function buildCodeModel(implementations, types, projectRoot2, sourceRoots = [],
16386
16587
  fieldTypes: Object.fromEntries([...facts.fieldTypes].map(([k, v]) => [k, [...v]])),
16387
16588
  localTypes: Object.fromEntries([...facts.localTypes].map(([k, v]) => [k, [...v]])),
16388
16589
  typeShapes: Object.fromEntries(facts.typeShapes),
16590
+ functionParams: Object.fromEntries(facts.functionParams),
16389
16591
  topLevelMutableBindings: [...facts.mutableBindings],
16390
16592
  reexportOnly: facts.reexportOnly
16391
16593
  };
@@ -30005,6 +30207,7 @@ function createMcpServer(options = {}) {
30005
30207
  sourcePath: import_zod11.z.string().optional().describe("Optional: target source code file path relative to project root \u2014 for a chained subproject's implementation (qualified id), relative to that subproject's root; a path given relative to this root that lands inside the subproject is re-expressed for you"),
30006
30208
  simPath: import_zod11.z.string().optional().describe("Optional: the committed integration-sim harness file (project-relative; N:1 sharing allowed). The validator proves it exists and its import graph wires the REAL modules (this component + each direct dependency; technology adapters may stay faked) \u2014 running it is CI's job. Declaring the first simPath in a subsystem activates MISSING_INTEGRATION_SIM for its other complete non-leaf implementations"),
30007
30209
  technologies: import_zod11.z.array(import_zod11.z.string()).optional().describe(`External technologies this implementation binds to (e.g. ["mysql"]) \u2014 declares this component's ownership tree as the technology's home; references outside it are flagged (TECH_LEAKAGE) and contract identifiers must stay intent-language. Only for Adapter/Store/Registry/Index components.`),
30210
+ injectedParams: import_zod11.z.array(import_zod11.z.string()).optional().describe("The parameter names this realization takes BEFORE the ones its contract declares \u2014 a config object, a data root, the transport handles a portal is handed. Supplied by whatever wires the component up, never by the caller the contract describes, which is why they belong here and not to the contract: another realization may hold them as fields instead. Declared rather than guessed, because a leading parameter the contract does not name cannot be told from one it named under a different name (`seed(config)` realized as `bootstrapInstance(cfg)`); a leading parameter this list does not name is reported (UNDECLARED_PARAM). Only a LEADING run is dropped \u2014 one of these names appearing after the contract's own parameters is an argument in the middle of the caller's list, not wiring"),
30008
30211
  detail: detailEnum.optional().describe("Spec-level narrative detail default for all methods"),
30009
30212
  conformance: conformanceEnum.optional().describe("Spec-level conformance tier default: declared | anchored | off (omitted = stereotype default: Portal \u2192 anchored, else declared)"),
30010
30213
  methods: import_zod11.z.array(import_zod11.z.object(implMethodShape).strict()).optional().describe("Method implementations containing L5 narratives"),
@@ -30015,11 +30218,11 @@ function createMcpServer(options = {}) {
30015
30218
  server,
30016
30219
  "sdd_write_narrative",
30017
30220
  {
30018
- description: "Write L4 Concrete Implementation spec containing L5 method narratives. Narratives are a FLAT ordered step list; flow steps (branch/switch/loop/try/parallel/jump/return/throw) jump by step number \u2014 blocks are just skipped regions. Steps may declare a `label` anchor, and every jump field has a *Label twin (toLabel, onTrueLabel, endLabel, \u2026) resolved to step numbers at write time \u2014 prefer labels over hand-counted numbers; an unresolvable label rejects the write. Detail dial per method: full (narrative required) | calls-only (call choreography suffices) | intent (prose instead of steps); omitted = stereotype default (Portal/Observer/Adapter: calls-only, Store/Index/Registry: intent, else full). A method whose narrative shows no steps declares the calls it makes in `calls` (one \"<component>.<method>\" each): the reachability walk takes exactly those edges and no others, so an intent-level method that reaches a collaborator must name it or that collaborator is reported unused. Conformance dial per method or spec: declared | anchored | off \u2014 how strictly structural conformance requires contract methods to be realized in their source file (omitted = Portal: anchored, else declared). A method whose body lives in its own file names it in the method's sourcePath; the implementation's sourcePath is the default for every method that names none. Re-authoring an existing id REPLACES the method list: a method left out of the input is REMOVED together with its narrative (and reported); spec-level lint/ext are carried forward, and the stored status is kept unless this input states a higher one. The answer carries a write receipt as structured content beside the sentence \u2014 the status written, whether a spec already held the id, and the notices a restatement raised, each as its own entry.",
30221
+ description: "Write L4 Concrete Implementation spec containing L5 method narratives. Narratives are a FLAT ordered step list; flow steps (branch/switch/loop/try/parallel/jump/return/throw) jump by step number \u2014 blocks are just skipped regions. Steps may declare a `label` anchor, and every jump field has a *Label twin (toLabel, onTrueLabel, endLabel, \u2026) resolved to step numbers at write time \u2014 prefer labels over hand-counted numbers; an unresolvable label rejects the write. Detail dial per method: full (narrative required) | calls-only (call choreography suffices) | intent (prose instead of steps); omitted = stereotype default (Portal/Observer/Adapter: calls-only, Store/Index/Registry: intent, else full). A method whose narrative shows no steps declares the calls it makes in `calls` (one \"<component>.<method>\" each): the reachability walk takes exactly those edges and no others, so an intent-level method that reaches a collaborator must name it or that collaborator is reported unused. Conformance dial per method or spec: declared | anchored | off \u2014 how strictly structural conformance requires contract methods to be realized in their source file (omitted = Portal: anchored, else declared). A method whose body lives in its own file names it in the method's sourcePath; the implementation's sourcePath is the default for every method that names none. Parameters the realization takes BEFORE its contract's own \u2014 a config object, a data root, a portal's transport handles \u2014 are wiring, and are declared once for the spec in injectedParams; a leading parameter it does not name is reported against the contract (UNDECLARED_PARAM). Re-authoring an existing id REPLACES the method list: a method left out of the input is REMOVED together with its narrative (and reported); spec-level lint/ext are carried forward, and the stored status is kept unless this input states a higher one. The answer carries a write receipt as structured content beside the sentence \u2014 the status written, whether a spec already held the id, and the notices a restatement raised, each as its own entry.",
30019
30222
  inputSchema: implInput,
30020
30223
  outputSchema: specWriteReceiptOutput
30021
30224
  },
30022
- ({ id, name, description, contract, sourcePath, simPath, technologies, detail, conformance, methods, status: status2 }) => {
30225
+ ({ id, name, description, contract, sourcePath, simPath, technologies, injectedParams, detail, conformance, methods, status: status2 }) => {
30023
30226
  try {
30024
30227
  const { loadInterfaceSpec: loadInterfaceSpec2, loadImplementationSpec: loadImplementationSpec2, saveImplementationSpec: saveImplementationSpec2 } = requireSpecs();
30025
30228
  const intf = loadInterfaceSpec2(contract);
@@ -30051,6 +30254,7 @@ function createMcpServer(options = {}) {
30051
30254
  sourcePath,
30052
30255
  simPath,
30053
30256
  technologies,
30257
+ injectedParams,
30054
30258
  detail,
30055
30259
  conformance,
30056
30260
  // Post-resolution every cases/catches entry has its numeric step —
@@ -45038,85 +45242,71 @@ details.adv summary { cursor:pointer; color:var(--dim); font-size:12px; margin-b
45038
45242
  </body>
45039
45243
  </html>`;
45040
45244
  }
45041
- function loginWithPassword(cfg, body, res, secureCookie) {
45042
- const sessionId = signInWithPassword(cfg, String(body?.user ?? ""), String(body?.password ?? ""));
45043
- res.writeHead(200, {
45044
- "content-type": "application/json",
45045
- "set-cookie": setSessionCookie(sessionId, secureCookie)
45046
- });
45047
- res.end(JSON.stringify({ ok: true }));
45245
+ function loginWithPassword(cfg, user, password) {
45246
+ return signInWithPassword(cfg, user, password);
45048
45247
  }
45049
- function adminListUsers(cfg, sessionId, url, res) {
45050
- const project2 = url.searchParams.get("project") ?? void 0;
45051
- sendJson(res, 200, { users: listUsers3(cfg, sessionId, project2) });
45248
+ function adminListUsers(cfg, sessionId, project2) {
45249
+ return listUsers3(cfg, sessionId, project2);
45052
45250
  }
45053
- function adminUpsertUser(cfg, sessionId, body, res) {
45054
- sendJson(res, 200, upsertUser3(cfg, sessionId, body));
45251
+ function adminUpsertUser(cfg, sessionId, record2) {
45252
+ return upsertUser3(cfg, sessionId, record2);
45055
45253
  }
45056
- function adminSetUserStatus(cfg, sessionId, body, res) {
45057
- sendJson(res, 200, setUserStatus3(cfg, sessionId, String(body?.userId ?? ""), String(body?.status ?? "")));
45254
+ function adminSetUserStatus(cfg, sessionId, userId, status2) {
45255
+ return setUserStatus3(cfg, sessionId, userId, status2);
45058
45256
  }
45059
- function adminCreateShareLink(cfg, sessionId, body, res) {
45060
- sendJson(res, 201, createShareLink(cfg, sessionId, body ?? {}));
45257
+ function adminCreateShareLink(cfg, sessionId, input) {
45258
+ return createShareLink(cfg, sessionId, input);
45061
45259
  }
45062
- function adminListShareLinks(cfg, sessionId, url, res) {
45063
- sendJson(res, 200, { links: listShareLinks(cfg, sessionId, url.searchParams.get("projectId") ?? "") });
45260
+ function adminListShareLinks(cfg, sessionId, projectId) {
45261
+ return listShareLinks(cfg, sessionId, projectId);
45064
45262
  }
45065
- function adminRefreshShareSnapshot(cfg, sessionId, body, res) {
45066
- sendJson(res, 200, refreshSnapshot(cfg, sessionId, String(body?.linkId ?? "")));
45263
+ function adminRefreshShareSnapshot(cfg, sessionId, linkId) {
45264
+ return refreshSnapshot(cfg, sessionId, linkId);
45067
45265
  }
45068
- function adminUpdateShareLink(cfg, sessionId, body, res) {
45069
- sendJson(res, 200, updateShareLink(cfg, sessionId, String(body?.linkId ?? ""), body?.changes ?? {}));
45266
+ function adminUpdateShareLink(cfg, sessionId, linkId, changes) {
45267
+ return updateShareLink(cfg, sessionId, linkId, changes);
45070
45268
  }
45071
- function adminRemoveShareLink(cfg, sessionId, body, res) {
45072
- removeShareLink(cfg, sessionId, String(body?.linkId ?? ""));
45073
- sendJson(res, 200, { ok: true });
45269
+ function adminRemoveShareLink(cfg, sessionId, linkId) {
45270
+ removeShareLink(cfg, sessionId, linkId);
45074
45271
  }
45075
- function adminGetShareAccessLog(cfg, sessionId, url, res) {
45076
- const limit = Number(url.searchParams.get("limit") ?? "100") || 100;
45077
- sendJson(res, 200, { entries: getShareAccessLog(cfg, sessionId, url.searchParams.get("linkId") ?? "", limit) });
45272
+ function adminGetShareAccessLog(cfg, sessionId, linkId, limit) {
45273
+ return getShareAccessLog(cfg, sessionId, linkId, limit);
45078
45274
  }
45079
- function adminListProviders(cfg, sessionId, res) {
45080
- sendJson(res, 200, { providers: listIdentityProviders(cfg, sessionId) });
45275
+ function adminListProviders(cfg, sessionId) {
45276
+ return listIdentityProviders(cfg, sessionId);
45081
45277
  }
45082
- function adminUpsertProvider(cfg, sessionId, body, res) {
45083
- sendJson(res, 200, upsertIdentityProvider(cfg, sessionId, body));
45278
+ function adminUpsertProvider(cfg, sessionId, config) {
45279
+ return upsertIdentityProvider(cfg, sessionId, config);
45084
45280
  }
45085
- function adminRemoveProvider(cfg, sessionId, body, res) {
45086
- removeIdentityProvider(cfg, sessionId, String(body?.id ?? ""));
45087
- sendJson(res, 200, { ok: true });
45281
+ function adminRemoveProvider(cfg, sessionId, id) {
45282
+ removeIdentityProvider(cfg, sessionId, id);
45088
45283
  }
45089
- function mintAgentToken(cfg, sessionId, body, res) {
45090
- const token = mintProjectToken(cfg, sessionId, String(body?.projectId ?? ""), body?.write === true);
45091
- sendJson(res, 201, { token });
45284
+ function mintAgentToken(cfg, sessionId, projectId, write) {
45285
+ return mintProjectToken(cfg, sessionId, projectId, write);
45092
45286
  }
45093
- function revokeAgentToken(cfg, sessionId, body, res) {
45094
- revokeProjectToken(cfg, sessionId, String(body?.id ?? ""));
45095
- sendJson(res, 200, { ok: true });
45287
+ function revokeAgentToken(cfg, sessionId, tokenId) {
45288
+ revokeProjectToken(cfg, sessionId, tokenId);
45096
45289
  }
45097
- function listAgentTokens(cfg, sessionId, res) {
45098
- sendJson(res, 200, { tokens: listMyTokens(cfg, sessionId) });
45290
+ function listAgentTokens(cfg, sessionId) {
45291
+ return listMyTokens(cfg, sessionId);
45099
45292
  }
45100
- function adminListOrgUnits(cfg, sessionId, res) {
45101
- sendJson(res, 200, { units: listOrganizationUnits2(cfg, sessionId) });
45293
+ function adminListOrgUnits(cfg, sessionId) {
45294
+ return listOrganizationUnits2(cfg, sessionId);
45102
45295
  }
45103
- function adminListSecretRefs(cfg, sessionId, res) {
45104
- sendJson(res, 200, { refs: listSecretRefs(cfg, sessionId) });
45296
+ function adminListSecretRefs(cfg, sessionId) {
45297
+ return listSecretRefs(cfg, sessionId);
45105
45298
  }
45106
- function adminSetSecret(cfg, sessionId, body, res) {
45107
- setSecret3(cfg, sessionId, String(body?.key ?? ""), String(body?.value ?? ""));
45108
- sendJson(res, 200, { ok: true });
45299
+ function adminSetSecret(cfg, sessionId, key, value) {
45300
+ setSecret3(cfg, sessionId, key, value);
45109
45301
  }
45110
- function adminUpsertOrgUnit(cfg, sessionId, body, res) {
45111
- sendJson(res, 200, upsertOrganizationUnit(cfg, sessionId, body));
45302
+ function adminUpsertOrgUnit(cfg, sessionId, record2) {
45303
+ return upsertOrganizationUnit(cfg, sessionId, record2);
45112
45304
  }
45113
- function adminPlaceProject(cfg, sessionId, body, res) {
45114
- placeProject3(cfg, sessionId, String(body?.projectId ?? ""), String(body?.unitId ?? ""));
45115
- sendJson(res, 200, { ok: true });
45305
+ function adminPlaceProject(cfg, sessionId, projectId, unitId) {
45306
+ placeProject3(cfg, sessionId, projectId, unitId);
45116
45307
  }
45117
- function adminRemoveUnit(cfg, sessionId, body, res) {
45118
- removeUnit(cfg, sessionId, String(body?.unitId ?? ""), body?.disposition ?? {});
45119
- sendJson(res, 200, { ok: true });
45308
+ function adminRemoveUnit(cfg, sessionId, unitId, disposition) {
45309
+ removeUnit(cfg, sessionId, unitId, disposition);
45120
45310
  }
45121
45311
  function bodyScope(body) {
45122
45312
  return {
@@ -45124,69 +45314,44 @@ function bodyScope(body) {
45124
45314
  scopeId: body?.scopeId !== void 0 ? String(body.scopeId) : void 0
45125
45315
  };
45126
45316
  }
45127
- function adminListRoles(cfg, sessionId, res) {
45128
- sendJson(res, 200, { roles: listRoles3(cfg, sessionId) });
45129
- }
45130
- function adminCreateRole(cfg, sessionId, body, res) {
45131
- sendJson(res, 200, createRole3(cfg, sessionId, body));
45132
- }
45133
- function adminUpdateRole(cfg, sessionId, body, res) {
45134
- sendJson(res, 200, updateRole3(cfg, sessionId, body));
45135
- }
45136
- function adminDeleteRole(cfg, sessionId, body, res) {
45137
- deleteRole3(cfg, sessionId, String(body?.id ?? ""));
45138
- sendJson(res, 200, { ok: true });
45139
- }
45140
- function adminBindRole(cfg, sessionId, body, res) {
45141
- const scope = bodyScope(body);
45142
- sendJson(res, 200, bindRole2(cfg, sessionId, String(body?.userId ?? ""), String(body?.roleId ?? ""), scope.scopeKind, scope.scopeId));
45143
- }
45144
- function adminUnbindRole(cfg, sessionId, body, res) {
45145
- const scope = bodyScope(body);
45146
- sendJson(res, 200, unbindRole2(cfg, sessionId, String(body?.userId ?? ""), String(body?.roleId ?? ""), scope.scopeKind, scope.scopeId));
45147
- }
45148
- function adminListAssignments(cfg, sessionId, url, res) {
45149
- const q2 = (name) => url.searchParams.get(name) ?? void 0;
45150
- sendJson(res, 200, {
45151
- assignments: listAssignments3(
45152
- cfg,
45153
- sessionId,
45154
- q2("scopeKind"),
45155
- q2("scopeId"),
45156
- q2("subjectKind"),
45157
- q2("subjectId")
45158
- )
45159
- });
45317
+ function adminListRoles(cfg, sessionId) {
45318
+ return listRoles3(cfg, sessionId);
45160
45319
  }
45161
- function adminSetAssignment(cfg, sessionId, body, res) {
45162
- sendJson(res, 200, setAssignment3(cfg, sessionId, body));
45163
- }
45164
- function adminRemoveAssignment(cfg, sessionId, body, res) {
45165
- removeAssignment3(cfg, sessionId, String(body?.id ?? ""));
45166
- sendJson(res, 200, { ok: true });
45167
- }
45168
- function projectList(cfg, sessionId, res) {
45169
- sendJson(res, 200, { projects: listProjects2(cfg, sessionId) });
45170
- }
45171
- function projectCreate(cfg, sessionId, body, res) {
45172
- sendJson(
45173
- res,
45174
- 201,
45175
- createProject2(
45176
- cfg,
45177
- sessionId,
45178
- String(body?.id ?? ""),
45179
- String(body?.unitId ?? ""),
45180
- body?.profileSelection
45181
- )
45182
- );
45320
+ function adminCreateRole(cfg, sessionId, role) {
45321
+ return createRole3(cfg, sessionId, role);
45322
+ }
45323
+ function adminUpdateRole(cfg, sessionId, role) {
45324
+ return updateRole3(cfg, sessionId, role);
45325
+ }
45326
+ function adminDeleteRole(cfg, sessionId, roleId) {
45327
+ deleteRole3(cfg, sessionId, roleId);
45328
+ }
45329
+ function adminBindRole(cfg, sessionId, userId, roleId, scopeKind, scopeId) {
45330
+ return bindRole2(cfg, sessionId, userId, roleId, scopeKind, scopeId);
45331
+ }
45332
+ function adminUnbindRole(cfg, sessionId, userId, roleId, scopeKind, scopeId) {
45333
+ return unbindRole2(cfg, sessionId, userId, roleId, scopeKind, scopeId);
45183
45334
  }
45184
- function projectLock(cfg, sessionId, body, res) {
45185
- sendJson(res, 200, lockProject3(cfg, sessionId, String(body?.projectId ?? "")));
45335
+ function adminListAssignments(cfg, sessionId, scopeKind, scopeId, subjectKind, subjectId) {
45336
+ return listAssignments3(cfg, sessionId, scopeKind, scopeId, subjectKind, subjectId);
45186
45337
  }
45187
- function projectDestroy(cfg, sessionId, body, res) {
45188
- destroyProject2(cfg, sessionId, String(body?.id ?? ""));
45189
- sendJson(res, 200, { ok: true });
45338
+ function adminSetAssignment(cfg, sessionId, assignment) {
45339
+ return setAssignment3(cfg, sessionId, assignment);
45340
+ }
45341
+ function adminRemoveAssignment(cfg, sessionId, assignmentId) {
45342
+ removeAssignment3(cfg, sessionId, assignmentId);
45343
+ }
45344
+ function projectList(cfg, sessionId) {
45345
+ return listProjects2(cfg, sessionId);
45346
+ }
45347
+ function projectCreate(cfg, sessionId, id, unitId, profileSelection) {
45348
+ return createProject2(cfg, sessionId, id, unitId, profileSelection);
45349
+ }
45350
+ function projectLock(cfg, sessionId, projectId) {
45351
+ return lockProject3(cfg, sessionId, projectId);
45352
+ }
45353
+ function projectDestroy(cfg, sessionId, id) {
45354
+ destroyProject2(cfg, sessionId, id);
45190
45355
  }
45191
45356
  var q = (url, name) => url.searchParams.get(name) ?? void 0;
45192
45357
  function archiveBody(body) {
@@ -45198,159 +45363,107 @@ function packNameOverride(req) {
45198
45363
  const v = Array.isArray(h) ? h[0] : h;
45199
45364
  return v && v.trim() ? v.trim() : void 0;
45200
45365
  }
45201
- function opsListGlobalPacks(cfg, sessionId, res) {
45202
- sendJson(res, 200, { packs: listGlobalPacks2(cfg, sessionId) });
45366
+ function opsListGlobalPacks(cfg, sessionId) {
45367
+ return listGlobalPacks2(cfg, sessionId);
45203
45368
  }
45204
- function opsInstallGlobalPack(cfg, sessionId, body, res) {
45205
- sendJson(res, 200, installGlobalPack2(cfg, sessionId, String(body?.name ?? ""), String(body?.content ?? "")));
45369
+ function opsInstallGlobalPack(cfg, sessionId, name, content) {
45370
+ return installGlobalPack2(cfg, sessionId, name, content);
45206
45371
  }
45207
- function opsRemoveGlobalPack(cfg, sessionId, body, res) {
45208
- removeGlobalPack2(cfg, sessionId, String(body?.name ?? ""));
45209
- sendJson(res, 200, { ok: true });
45372
+ function opsRemoveGlobalPack(cfg, sessionId, name) {
45373
+ removeGlobalPack2(cfg, sessionId, name);
45210
45374
  }
45211
- function opsListProjectPacks(cfg, sessionId, url, res) {
45212
- sendJson(res, 200, { packs: listProjectPacks2(cfg, sessionId, q(url, "projectId") ?? "") });
45375
+ function opsListProjectPacks(cfg, sessionId, project2) {
45376
+ return listProjectPacks2(cfg, sessionId, project2);
45213
45377
  }
45214
- function opsInstallProjectPack(cfg, sessionId, body, res) {
45215
- sendJson(res, 200, installProjectPack2(cfg, sessionId, String(body?.projectId ?? ""), String(body?.name ?? ""), String(body?.content ?? "")));
45378
+ function opsInstallProjectPack(cfg, sessionId, project2, name, content) {
45379
+ return installProjectPack2(cfg, sessionId, project2, name, content);
45216
45380
  }
45217
- function opsRemoveProjectPack(cfg, sessionId, body, res) {
45218
- removeProjectPack2(cfg, sessionId, String(body?.projectId ?? ""), String(body?.name ?? ""));
45219
- sendJson(res, 200, { ok: true });
45381
+ function opsRemoveProjectPack(cfg, sessionId, project2, name) {
45382
+ removeProjectPack2(cfg, sessionId, project2, name);
45220
45383
  }
45221
- function opsInstallGlobalPackArchive(cfg, sessionId, req, body, res) {
45222
- sendJson(res, 200, installGlobalPackArchive2(cfg, sessionId, archiveBody(body), packNameOverride(req)));
45384
+ function opsInstallGlobalPackArchive(cfg, sessionId, archive, name) {
45385
+ return installGlobalPackArchive2(cfg, sessionId, archive, name);
45223
45386
  }
45224
- function opsInstallProjectPackArchive(cfg, sessionId, req, url, body, res) {
45225
- sendJson(res, 200, installProjectPackArchive2(cfg, sessionId, q(url, "projectId") ?? "", archiveBody(body), packNameOverride(req)));
45387
+ function opsInstallProjectPackArchive(cfg, sessionId, project2, archive, name) {
45388
+ return installProjectPackArchive2(cfg, sessionId, project2, archive, name);
45226
45389
  }
45227
- function opsExportProjectTree(cfg, sessionId, url, res) {
45228
- const result = exportProjectTree2(
45229
- cfg,
45230
- sessionId,
45231
- q(url, "projectId") ?? "",
45232
- void 0,
45233
- q(url, "includeDerived") === "1",
45234
- q(url, "allowPartial") === "1"
45235
- );
45236
- res.writeHead(200, {
45237
- "content-type": "application/zip",
45238
- "content-disposition": `attachment; filename="${result.suggestedFileName}"`
45239
- });
45240
- res.end(Buffer.from(result.archive));
45241
- }
45242
- function opsImportProjectTree(cfg, sessionId, url, body, res) {
45243
- sendJson(
45244
- res,
45245
- 200,
45246
- importProjectTree2(
45247
- cfg,
45248
- sessionId,
45249
- q(url, "projectId") ?? "",
45250
- archiveBody(body),
45251
- void 0,
45252
- q(url, "replace") === "1"
45253
- )
45254
- );
45390
+ function opsExportProjectTree(cfg, sessionId, project2, subproject, includeDerived, allowPartial) {
45391
+ return exportProjectTree2(cfg, sessionId, project2, subproject, includeDerived, allowPartial);
45255
45392
  }
45256
- function opsListAvailableProfiles(cfg, sessionId, res) {
45257
- sendJson(res, 200, { profiles: listAvailableProfiles2(cfg, sessionId) });
45393
+ function opsImportProjectTree(cfg, sessionId, project2, archive, subproject, replaceExisting) {
45394
+ return importProjectTree2(cfg, sessionId, project2, archive, subproject, replaceExisting);
45258
45395
  }
45259
- function opsListAdoptableProjectPacks(cfg, sessionId, url, res) {
45260
- sendJson(res, 200, { packs: listAdoptableProjectPacks2(cfg, sessionId, q(url, "projectId") ?? "") });
45396
+ function opsListAvailableProfiles(cfg, sessionId) {
45397
+ return listAvailableProfiles2(cfg, sessionId);
45261
45398
  }
45262
- function opsAdoptProjectPack(cfg, sessionId, body, res) {
45263
- sendJson(res, 200, adoptProjectPack2(cfg, sessionId, String(body?.projectId ?? ""), String(body?.name ?? "")));
45399
+ function opsListAdoptableProjectPacks(cfg, sessionId, project2) {
45400
+ return listAdoptableProjectPacks2(cfg, sessionId, project2);
45264
45401
  }
45265
- function opsGetPackPolicy(cfg, sessionId, res) {
45266
- sendJson(res, 200, getPackPolicy2(cfg, sessionId));
45402
+ function opsAdoptProjectPack(cfg, sessionId, project2, name) {
45403
+ return adoptProjectPack2(cfg, sessionId, project2, name);
45267
45404
  }
45268
- function opsSetPackPolicy(cfg, sessionId, body, res) {
45269
- sendJson(res, 200, setPackPolicy2(cfg, sessionId, body));
45405
+ function opsGetPackPolicy(cfg, sessionId) {
45406
+ return getPackPolicy2(cfg, sessionId);
45270
45407
  }
45271
- function opsPolicyEvaluate(cfg, sessionId, url, res) {
45272
- sendJson(res, 200, evaluateProjectPolicy2(cfg, sessionId, q(url, "projectId") ?? ""));
45408
+ function opsSetPackPolicy(cfg, sessionId, policy) {
45409
+ return setPackPolicy2(cfg, sessionId, policy);
45273
45410
  }
45274
- function opsPolicyReconcile(cfg, sessionId, body, res) {
45275
- sendJson(res, 200, reconcileProjectPolicy2(cfg, sessionId, String(body?.projectId ?? "")));
45411
+ function opsPolicyEvaluate(cfg, sessionId, projectId) {
45412
+ return evaluateProjectPolicy2(cfg, sessionId, projectId);
45276
45413
  }
45277
- function opsGetProjectConfig(cfg, sessionId, url, res) {
45278
- sendJson(res, 200, getProjectConfig2(cfg, sessionId, q(url, "projectId") ?? ""));
45414
+ function opsPolicyReconcile(cfg, sessionId, projectId) {
45415
+ return reconcileProjectPolicy2(cfg, sessionId, projectId);
45279
45416
  }
45280
- function opsSetProjectConfig(cfg, sessionId, body, res) {
45281
- sendJson(res, 200, setProjectType3(cfg, sessionId, String(body?.projectId ?? ""), String(body?.projectType ?? "")));
45417
+ function opsGetProjectConfig(cfg, sessionId, projectId) {
45418
+ return getProjectConfig2(cfg, sessionId, projectId);
45282
45419
  }
45283
- function opsListProjectProfiles(cfg, sessionId, url, res) {
45284
- sendJson(res, 200, { profiles: listProjectProfiles2(cfg, sessionId, q(url, "projectId") ?? "") });
45420
+ function opsSetProjectConfig(cfg, sessionId, projectId, projectType) {
45421
+ return setProjectType3(cfg, sessionId, projectId, projectType);
45285
45422
  }
45286
- function opsListProducers(cfg, sessionId, url, res) {
45287
- sendJson(res, 200, { producers: listProducers2(cfg, sessionId, q(url, "projectId") ?? "") });
45423
+ function opsListProjectProfiles(cfg, sessionId, project2) {
45424
+ return listProjectProfiles2(cfg, sessionId, project2);
45288
45425
  }
45289
- function opsConfigureProducer(cfg, sessionId, body, res) {
45290
- configureProducer2(cfg, sessionId, String(body?.projectId ?? ""), String(body?.target ?? ""), String(body?.parentPageId ?? ""));
45291
- sendJson(res, 200, { ok: true });
45426
+ function opsListProducers(cfg, sessionId, project2) {
45427
+ return listProducers2(cfg, sessionId, project2);
45292
45428
  }
45293
- function opsRemoveProducer(cfg, sessionId, body, res) {
45294
- removeProducer2(cfg, sessionId, String(body?.projectId ?? ""), String(body?.target ?? ""));
45295
- sendJson(res, 200, { ok: true });
45429
+ function opsConfigureProducer(cfg, sessionId, project2, target, parentPageId) {
45430
+ configureProducer2(cfg, sessionId, project2, target, parentPageId);
45296
45431
  }
45297
- async function opsRunProducer(cfg, sessionId, body, res) {
45298
- await produceProducer2(cfg, sessionId, String(body?.projectId ?? ""), String(body?.target ?? ""));
45299
- sendJson(res, 200, { ok: true });
45432
+ function opsRemoveProducer(cfg, sessionId, project2, target) {
45433
+ removeProducer2(cfg, sessionId, project2, target);
45300
45434
  }
45301
- function opsGitStatus(cfg, sessionId, url, res) {
45302
- sendJson(res, 200, getGitBinding2(cfg, sessionId, q(url, "projectId") ?? ""));
45435
+ async function opsRunProducer(cfg, sessionId, project2, target) {
45436
+ await produceProducer2(cfg, sessionId, project2, target);
45303
45437
  }
45304
- function opsGitBind(cfg, sessionId, body, res) {
45305
- const pat = body?.pat ? String(body.pat) : void 0;
45306
- sendJson(res, 200, enableGit2(cfg, sessionId, String(body?.projectId ?? ""), String(body?.remote ?? ""), String(body?.branch ?? ""), pat));
45438
+ function opsGitStatus(cfg, sessionId, project2) {
45439
+ return getGitBinding2(cfg, sessionId, project2);
45307
45440
  }
45308
- function opsGitUnbind(cfg, sessionId, body, res) {
45309
- disableGit2(cfg, sessionId, String(body?.projectId ?? ""));
45310
- sendJson(res, 200, { ok: true });
45441
+ function opsGitBind(cfg, sessionId, project2, remote, branch, pat) {
45442
+ return enableGit2(cfg, sessionId, project2, remote, branch, pat);
45311
45443
  }
45312
- function opsGitSync(cfg, sessionId, body, res) {
45313
- syncGit2(cfg, sessionId, String(body?.projectId ?? ""));
45314
- sendJson(res, 200, { ok: true });
45444
+ function opsGitUnbind(cfg, sessionId, project2) {
45445
+ disableGit2(cfg, sessionId, project2);
45315
45446
  }
45316
- function opsGitCommit(cfg, sessionId, body, res) {
45317
- sendJson(
45318
- res,
45319
- 200,
45320
- commitProject2(
45321
- cfg,
45322
- sessionId,
45323
- String(body?.projectId ?? ""),
45324
- typeof body?.subsystem === "string" && body.subsystem ? body.subsystem : void 0,
45325
- typeof body?.message === "string" && body.message ? body.message : void 0
45326
- )
45327
- );
45447
+ function opsGitSync(cfg, sessionId, project2) {
45448
+ syncGit2(cfg, sessionId, project2);
45328
45449
  }
45329
- function opsGitSyncConfig(cfg, sessionId, body, res) {
45330
- configureGitSync2(
45331
- cfg,
45332
- sessionId,
45333
- String(body?.projectId ?? ""),
45334
- typeof body?.periodicSyncMinutes === "number" ? body.periodicSyncMinutes : void 0,
45335
- typeof body?.skipIfClean === "boolean" ? body.skipIfClean : void 0
45336
- );
45337
- sendJson(res, 200, { ok: true });
45450
+ function opsGitCommit(cfg, sessionId, project2, subsystem, message) {
45451
+ return commitProject2(cfg, sessionId, project2, subsystem, message);
45338
45452
  }
45339
- function opsListGitBacking(cfg, sessionId, res) {
45340
- sendJson(res, 200, { bindings: listBackingBindings2(cfg, sessionId) });
45453
+ function opsGitSyncConfig(cfg, sessionId, project2, periodicSyncMinutes, skipIfClean) {
45454
+ configureGitSync2(cfg, sessionId, project2, periodicSyncMinutes, skipIfClean);
45341
45455
  }
45342
- function opsBindGitBacking(cfg, sessionId, body, res) {
45343
- const pat = body?.pat ? String(body.pat) : void 0;
45344
- const binding = { ...body ?? {} };
45345
- delete binding.pat;
45346
- sendJson(res, 200, bindBackingScope(cfg, sessionId, binding, pat));
45456
+ function opsListGitBacking(cfg, sessionId) {
45457
+ return listBackingBindings2(cfg, sessionId);
45347
45458
  }
45348
- function opsUnbindGitBacking(cfg, sessionId, body, res) {
45349
- unbindBackingScope(cfg, sessionId, String(body?.id ?? ""));
45350
- sendJson(res, 200, { ok: true });
45459
+ function opsBindGitBacking(cfg, sessionId, binding, pat) {
45460
+ return bindBackingScope(cfg, sessionId, binding, pat);
45351
45461
  }
45352
- function opsSyncGitBacking(cfg, sessionId, body, res) {
45353
- sendJson(res, 200, { published: syncBackingScope(cfg, sessionId, String(body?.id ?? "")) });
45462
+ function opsUnbindGitBacking(cfg, sessionId, bindingId) {
45463
+ unbindBackingScope(cfg, sessionId, bindingId);
45464
+ }
45465
+ function opsSyncGitBacking(cfg, sessionId, bindingId) {
45466
+ return syncBackingScope(cfg, sessionId, bindingId);
45354
45467
  }
45355
45468
  function auditQueryFrom(url) {
45356
45469
  const query = {};
@@ -45374,17 +45487,17 @@ function auditQueryFrom(url) {
45374
45487
  if (limit !== void 0) query.limit = Number(limit);
45375
45488
  return query;
45376
45489
  }
45377
- function opsAuditQuery(cfg, sessionId, url, res) {
45378
- sendJson(res, 200, { events: queryAuditEvents3(cfg, sessionId, auditQueryFrom(url)) });
45490
+ function opsAuditQuery(cfg, sessionId, query) {
45491
+ return queryAuditEvents3(cfg, sessionId, query);
45379
45492
  }
45380
- function opsAuditCount(cfg, sessionId, url, res) {
45381
- sendJson(res, 200, { count: countAuditEvents3(cfg, sessionId, auditQueryFrom(url)) });
45493
+ function opsAuditCount(cfg, sessionId, query) {
45494
+ return countAuditEvents3(cfg, sessionId, query);
45382
45495
  }
45383
- function opsGetExposure(cfg, sessionId, res) {
45384
- sendJson(res, 200, getExposurePolicy2(cfg, sessionId));
45496
+ function opsGetExposure(cfg, sessionId) {
45497
+ return getExposurePolicy2(cfg, sessionId);
45385
45498
  }
45386
- function opsSetExposure(cfg, sessionId, body, res) {
45387
- sendJson(res, 200, setExposurePolicy2(cfg, sessionId, body));
45499
+ function opsSetExposure(cfg, sessionId, policy) {
45500
+ return setExposurePolicy2(cfg, sessionId, policy);
45388
45501
  }
45389
45502
  async function handleWebRequest(cfg, req, res, body, url, ctx) {
45390
45503
  const parts = url.pathname.split("/").filter(Boolean).map(decodeURIComponent);
@@ -45431,7 +45544,13 @@ async function handleWebRequest(cfg, req, res, body, url, ctx) {
45431
45544
  return sendJson(res, 200, getLoginOptions(cfg));
45432
45545
  }
45433
45546
  if (req.method === "POST" && parts.length === 2 && parts[1] === "login") {
45434
- return loginWithPassword(cfg, body, res, ctx.secureCookie);
45547
+ const loginSessionId = loginWithPassword(cfg, String(body?.user ?? ""), String(body?.password ?? ""));
45548
+ res.writeHead(200, {
45549
+ "content-type": "application/json",
45550
+ "set-cookie": setSessionCookie(loginSessionId, ctx.secureCookie)
45551
+ });
45552
+ res.end(JSON.stringify({ ok: true }));
45553
+ return;
45435
45554
  }
45436
45555
  if (req.method === "POST" && parts.length === 2 && parts[1] === "logout") {
45437
45556
  signOut(cfg, sessionId);
@@ -45474,223 +45593,309 @@ async function handleWebRequest(cfg, req, res, body, url, ctx) {
45474
45593
  return;
45475
45594
  }
45476
45595
  if (req.method === "GET" && parts.length === 2 && parts[1] === "tokens") {
45477
- return listAgentTokens(cfg, sessionId, res);
45596
+ return sendJson(res, 200, { tokens: listAgentTokens(cfg, sessionId) });
45478
45597
  }
45479
45598
  if (req.method === "POST" && parts.length === 2 && parts[1] === "tokens") {
45480
- return mintAgentToken(cfg, sessionId, body, res);
45599
+ const token = mintAgentToken(cfg, sessionId, String(body?.projectId ?? ""), body?.write === true);
45600
+ return sendJson(res, 201, { token });
45481
45601
  }
45482
45602
  if (req.method === "POST" && parts.length === 3 && parts[1] === "tokens" && parts[2] === "revoke") {
45483
- return revokeAgentToken(cfg, sessionId, body, res);
45603
+ revokeAgentToken(cfg, sessionId, String(body?.id ?? ""));
45604
+ return sendJson(res, 200, { ok: true });
45484
45605
  }
45485
45606
  if (parts.length >= 2 && parts[1] === "projects") {
45486
45607
  if (req.method === "GET" && parts.length === 2) {
45487
- return projectList(cfg, sessionId, res);
45608
+ return sendJson(res, 200, { projects: projectList(cfg, sessionId) });
45488
45609
  }
45489
45610
  if (req.method === "POST" && parts.length === 2) {
45490
- return projectCreate(cfg, sessionId, body, res);
45611
+ return sendJson(
45612
+ res,
45613
+ 201,
45614
+ projectCreate(
45615
+ cfg,
45616
+ sessionId,
45617
+ String(body?.id ?? ""),
45618
+ String(body?.unitId ?? ""),
45619
+ body?.profileSelection
45620
+ )
45621
+ );
45491
45622
  }
45492
45623
  if (req.method === "POST" && parts.length === 3 && parts[2] === "lock") {
45493
- return projectLock(cfg, sessionId, body, res);
45624
+ return sendJson(res, 200, projectLock(cfg, sessionId, String(body?.projectId ?? "")));
45494
45625
  }
45495
45626
  if (req.method === "POST" && parts.length === 3 && parts[2] === "destroy") {
45496
- return projectDestroy(cfg, sessionId, body, res);
45627
+ projectDestroy(cfg, sessionId, String(body?.id ?? ""));
45628
+ return sendJson(res, 200, { ok: true });
45497
45629
  }
45498
45630
  if (req.method === "GET" && parts.length === 3 && parts[2] === "packs") {
45499
- return opsListProjectPacks(cfg, sessionId, url, res);
45631
+ return sendJson(res, 200, { packs: opsListProjectPacks(cfg, sessionId, q(url, "projectId") ?? "") });
45500
45632
  }
45501
45633
  if (req.method === "POST" && parts.length === 3 && parts[2] === "packs") {
45502
- return opsInstallProjectPack(cfg, sessionId, body, res);
45634
+ return sendJson(res, 200, opsInstallProjectPack(cfg, sessionId, String(body?.projectId ?? ""), String(body?.name ?? ""), String(body?.content ?? "")));
45503
45635
  }
45504
45636
  if (req.method === "POST" && parts.length === 4 && parts[2] === "packs" && parts[3] === "upload") {
45505
- return opsInstallProjectPackArchive(cfg, sessionId, req, url, body, res);
45637
+ return sendJson(res, 200, opsInstallProjectPackArchive(cfg, sessionId, q(url, "projectId") ?? "", archiveBody(body), packNameOverride(req)));
45506
45638
  }
45507
45639
  if (req.method === "POST" && parts.length === 4 && parts[2] === "packs" && parts[3] === "remove") {
45508
- return opsRemoveProjectPack(cfg, sessionId, body, res);
45640
+ opsRemoveProjectPack(cfg, sessionId, String(body?.projectId ?? ""), String(body?.name ?? ""));
45641
+ return sendJson(res, 200, { ok: true });
45509
45642
  }
45510
45643
  if (req.method === "GET" && parts.length === 4 && parts[2] === "packs" && parts[3] === "adoptable") {
45511
- return opsListAdoptableProjectPacks(cfg, sessionId, url, res);
45644
+ return sendJson(res, 200, { packs: opsListAdoptableProjectPacks(cfg, sessionId, q(url, "projectId") ?? "") });
45512
45645
  }
45513
45646
  if (req.method === "POST" && parts.length === 4 && parts[2] === "packs" && parts[3] === "adopt") {
45514
- return opsAdoptProjectPack(cfg, sessionId, body, res);
45647
+ return sendJson(res, 200, opsAdoptProjectPack(cfg, sessionId, String(body?.projectId ?? ""), String(body?.name ?? "")));
45515
45648
  }
45516
45649
  if (req.method === "GET" && parts.length === 4 && parts[2] === "tree" && parts[3] === "export") {
45517
- return opsExportProjectTree(cfg, sessionId, url, res);
45650
+ const result = opsExportProjectTree(
45651
+ cfg,
45652
+ sessionId,
45653
+ q(url, "projectId") ?? "",
45654
+ void 0,
45655
+ q(url, "includeDerived") === "1",
45656
+ q(url, "allowPartial") === "1"
45657
+ );
45658
+ res.writeHead(200, {
45659
+ "content-type": "application/zip",
45660
+ "content-disposition": `attachment; filename="${result.suggestedFileName}"`
45661
+ });
45662
+ res.end(Buffer.from(result.archive));
45663
+ return;
45518
45664
  }
45519
45665
  if (req.method === "POST" && parts.length === 4 && parts[2] === "tree" && parts[3] === "import") {
45520
- return opsImportProjectTree(cfg, sessionId, url, body, res);
45666
+ return sendJson(
45667
+ res,
45668
+ 200,
45669
+ opsImportProjectTree(
45670
+ cfg,
45671
+ sessionId,
45672
+ q(url, "projectId") ?? "",
45673
+ archiveBody(body),
45674
+ void 0,
45675
+ q(url, "replace") === "1"
45676
+ )
45677
+ );
45521
45678
  }
45522
45679
  if (req.method === "GET" && parts.length === 3 && parts[2] === "config") {
45523
- return opsGetProjectConfig(cfg, sessionId, url, res);
45680
+ return sendJson(res, 200, opsGetProjectConfig(cfg, sessionId, q(url, "projectId") ?? ""));
45524
45681
  }
45525
45682
  if (req.method === "POST" && parts.length === 3 && parts[2] === "config") {
45526
- return opsSetProjectConfig(cfg, sessionId, body, res);
45683
+ return sendJson(res, 200, opsSetProjectConfig(cfg, sessionId, String(body?.projectId ?? ""), String(body?.projectType ?? "")));
45527
45684
  }
45528
45685
  if (req.method === "GET" && parts.length === 3 && parts[2] === "profiles") {
45529
- return opsListProjectProfiles(cfg, sessionId, url, res);
45686
+ return sendJson(res, 200, { profiles: opsListProjectProfiles(cfg, sessionId, q(url, "projectId") ?? "") });
45530
45687
  }
45531
45688
  if (req.method === "GET" && parts.length === 3 && parts[2] === "policy") {
45532
- return opsPolicyEvaluate(cfg, sessionId, url, res);
45689
+ return sendJson(res, 200, opsPolicyEvaluate(cfg, sessionId, q(url, "projectId") ?? ""));
45533
45690
  }
45534
45691
  if (req.method === "POST" && parts.length === 4 && parts[2] === "policy" && parts[3] === "reconcile") {
45535
- return opsPolicyReconcile(cfg, sessionId, body, res);
45692
+ return sendJson(res, 200, opsPolicyReconcile(cfg, sessionId, String(body?.projectId ?? "")));
45536
45693
  }
45537
45694
  if (req.method === "GET" && parts.length === 3 && parts[2] === "producers") {
45538
- return opsListProducers(cfg, sessionId, url, res);
45695
+ return sendJson(res, 200, { producers: opsListProducers(cfg, sessionId, q(url, "projectId") ?? "") });
45539
45696
  }
45540
45697
  if (req.method === "POST" && parts.length === 3 && parts[2] === "producers") {
45541
- return opsConfigureProducer(cfg, sessionId, body, res);
45698
+ opsConfigureProducer(cfg, sessionId, String(body?.projectId ?? ""), String(body?.target ?? ""), String(body?.parentPageId ?? ""));
45699
+ return sendJson(res, 200, { ok: true });
45542
45700
  }
45543
45701
  if (req.method === "POST" && parts.length === 4 && parts[2] === "producers" && parts[3] === "remove") {
45544
- return opsRemoveProducer(cfg, sessionId, body, res);
45702
+ opsRemoveProducer(cfg, sessionId, String(body?.projectId ?? ""), String(body?.target ?? ""));
45703
+ return sendJson(res, 200, { ok: true });
45545
45704
  }
45546
45705
  if (req.method === "POST" && parts.length === 4 && parts[2] === "producers" && parts[3] === "run") {
45547
- return opsRunProducer(cfg, sessionId, body, res);
45706
+ return opsRunProducer(cfg, sessionId, String(body?.projectId ?? ""), String(body?.target ?? "")).then(() => sendJson(res, 200, { ok: true }));
45548
45707
  }
45549
45708
  if (req.method === "GET" && parts.length === 3 && parts[2] === "git") {
45550
- return opsGitStatus(cfg, sessionId, url, res);
45709
+ return sendJson(res, 200, opsGitStatus(cfg, sessionId, q(url, "projectId") ?? ""));
45551
45710
  }
45552
45711
  if (req.method === "POST" && parts.length === 3 && parts[2] === "git") {
45553
- return opsGitBind(cfg, sessionId, body, res);
45712
+ const pat = body?.pat ? String(body.pat) : void 0;
45713
+ return sendJson(res, 200, opsGitBind(cfg, sessionId, String(body?.projectId ?? ""), String(body?.remote ?? ""), String(body?.branch ?? ""), pat));
45554
45714
  }
45555
45715
  if (req.method === "POST" && parts.length === 4 && parts[2] === "git" && parts[3] === "disconnect") {
45556
- return opsGitUnbind(cfg, sessionId, body, res);
45716
+ opsGitUnbind(cfg, sessionId, String(body?.projectId ?? ""));
45717
+ return sendJson(res, 200, { ok: true });
45557
45718
  }
45558
45719
  if (req.method === "POST" && parts.length === 4 && parts[2] === "git" && parts[3] === "sync") {
45559
- return opsGitSync(cfg, sessionId, body, res);
45720
+ opsGitSync(cfg, sessionId, String(body?.projectId ?? ""));
45721
+ return sendJson(res, 200, { ok: true });
45560
45722
  }
45561
45723
  if (req.method === "POST" && parts.length === 4 && parts[2] === "git" && parts[3] === "commit") {
45562
- return opsGitCommit(cfg, sessionId, body, res);
45724
+ return sendJson(
45725
+ res,
45726
+ 200,
45727
+ opsGitCommit(
45728
+ cfg,
45729
+ sessionId,
45730
+ String(body?.projectId ?? ""),
45731
+ typeof body?.subsystem === "string" && body.subsystem ? body.subsystem : void 0,
45732
+ typeof body?.message === "string" && body.message ? body.message : void 0
45733
+ )
45734
+ );
45563
45735
  }
45564
45736
  if (req.method === "POST" && parts.length === 4 && parts[2] === "git" && parts[3] === "sync-config") {
45565
- return opsGitSyncConfig(cfg, sessionId, body, res);
45737
+ opsGitSyncConfig(
45738
+ cfg,
45739
+ sessionId,
45740
+ String(body?.projectId ?? ""),
45741
+ typeof body?.periodicSyncMinutes === "number" ? body.periodicSyncMinutes : void 0,
45742
+ typeof body?.skipIfClean === "boolean" ? body.skipIfClean : void 0
45743
+ );
45744
+ return sendJson(res, 200, { ok: true });
45566
45745
  }
45567
45746
  }
45568
45747
  if (parts.length >= 2 && parts[1] === "admin") {
45569
45748
  if (req.method === "GET" && parts.length === 3 && parts[2] === "users") {
45570
- return adminListUsers(cfg, sessionId, url, res);
45749
+ const project2 = url.searchParams.get("project") ?? void 0;
45750
+ return sendJson(res, 200, { users: adminListUsers(cfg, sessionId, project2) });
45571
45751
  }
45572
45752
  if (req.method === "POST" && parts.length === 4 && parts[2] === "users" && parts[3] === "status") {
45573
- return adminSetUserStatus(cfg, sessionId, body, res);
45753
+ return sendJson(res, 200, adminSetUserStatus(cfg, sessionId, String(body?.userId ?? ""), String(body?.status ?? "")));
45574
45754
  }
45575
45755
  if (req.method === "POST" && parts.length === 3 && parts[2] === "users") {
45576
- return adminUpsertUser(cfg, sessionId, body, res);
45756
+ return sendJson(res, 200, adminUpsertUser(cfg, sessionId, body));
45577
45757
  }
45578
45758
  if (req.method === "GET" && parts.length === 3 && parts[2] === "providers") {
45579
- return adminListProviders(cfg, sessionId, res);
45759
+ return sendJson(res, 200, { providers: adminListProviders(cfg, sessionId) });
45580
45760
  }
45581
45761
  if (req.method === "POST" && parts.length === 4 && parts[2] === "providers" && parts[3] === "remove") {
45582
- return adminRemoveProvider(cfg, sessionId, body, res);
45762
+ adminRemoveProvider(cfg, sessionId, String(body?.id ?? ""));
45763
+ return sendJson(res, 200, { ok: true });
45583
45764
  }
45584
45765
  if (req.method === "POST" && parts.length === 3 && parts[2] === "providers") {
45585
- return adminUpsertProvider(cfg, sessionId, body, res);
45766
+ return sendJson(res, 200, adminUpsertProvider(cfg, sessionId, body));
45586
45767
  }
45587
45768
  if (req.method === "GET" && parts.length === 4 && parts[2] === "org" && parts[3] === "units") {
45588
- return adminListOrgUnits(cfg, sessionId, res);
45769
+ return sendJson(res, 200, { units: adminListOrgUnits(cfg, sessionId) });
45589
45770
  }
45590
45771
  if (req.method === "GET" && parts.length === 3 && parts[2] === "secrets") {
45591
- return adminListSecretRefs(cfg, sessionId, res);
45772
+ return sendJson(res, 200, { refs: adminListSecretRefs(cfg, sessionId) });
45592
45773
  }
45593
45774
  if (req.method === "POST" && parts.length === 3 && parts[2] === "secrets") {
45594
- return adminSetSecret(cfg, sessionId, body, res);
45775
+ adminSetSecret(cfg, sessionId, String(body?.key ?? ""), String(body?.value ?? ""));
45776
+ return sendJson(res, 200, { ok: true });
45595
45777
  }
45596
45778
  if (req.method === "POST" && parts.length === 4 && parts[2] === "org" && parts[3] === "units") {
45597
- return adminUpsertOrgUnit(cfg, sessionId, body, res);
45779
+ return sendJson(res, 200, adminUpsertOrgUnit(cfg, sessionId, body));
45598
45780
  }
45599
45781
  if (req.method === "POST" && parts.length === 5 && parts[2] === "org" && parts[3] === "units" && parts[4] === "remove") {
45600
- return adminRemoveUnit(cfg, sessionId, body, res);
45782
+ adminRemoveUnit(cfg, sessionId, String(body?.unitId ?? ""), body?.disposition ?? {});
45783
+ return sendJson(res, 200, { ok: true });
45601
45784
  }
45602
45785
  if (req.method === "POST" && parts.length === 4 && parts[2] === "org" && parts[3] === "placements") {
45603
- return adminPlaceProject(cfg, sessionId, body, res);
45786
+ adminPlaceProject(cfg, sessionId, String(body?.projectId ?? ""), String(body?.unitId ?? ""));
45787
+ return sendJson(res, 200, { ok: true });
45604
45788
  }
45605
45789
  if (req.method === "GET" && parts.length === 3 && parts[2] === "roles") {
45606
- return adminListRoles(cfg, sessionId, res);
45790
+ return sendJson(res, 200, { roles: adminListRoles(cfg, sessionId) });
45607
45791
  }
45608
45792
  if (req.method === "POST" && parts.length === 3 && parts[2] === "roles") {
45609
- return adminCreateRole(cfg, sessionId, body, res);
45793
+ return sendJson(res, 200, adminCreateRole(cfg, sessionId, body));
45610
45794
  }
45611
45795
  if (req.method === "POST" && parts.length === 4 && parts[2] === "roles" && parts[3] === "update") {
45612
- return adminUpdateRole(cfg, sessionId, body, res);
45796
+ return sendJson(res, 200, adminUpdateRole(cfg, sessionId, body));
45613
45797
  }
45614
45798
  if (req.method === "POST" && parts.length === 4 && parts[2] === "roles" && parts[3] === "remove") {
45615
- return adminDeleteRole(cfg, sessionId, body, res);
45799
+ adminDeleteRole(cfg, sessionId, String(body?.id ?? ""));
45800
+ return sendJson(res, 200, { ok: true });
45616
45801
  }
45617
45802
  if (req.method === "POST" && parts.length === 4 && parts[2] === "roles" && parts[3] === "bind") {
45618
- return adminBindRole(cfg, sessionId, body, res);
45803
+ const scope = bodyScope(body);
45804
+ return sendJson(res, 200, adminBindRole(cfg, sessionId, String(body?.userId ?? ""), String(body?.roleId ?? ""), scope.scopeKind, scope.scopeId));
45619
45805
  }
45620
45806
  if (req.method === "POST" && parts.length === 4 && parts[2] === "roles" && parts[3] === "unbind") {
45621
- return adminUnbindRole(cfg, sessionId, body, res);
45807
+ const scope = bodyScope(body);
45808
+ return sendJson(res, 200, adminUnbindRole(cfg, sessionId, String(body?.userId ?? ""), String(body?.roleId ?? ""), scope.scopeKind, scope.scopeId));
45622
45809
  }
45623
45810
  if (req.method === "GET" && parts.length === 3 && parts[2] === "permissions") {
45624
- return adminListAssignments(cfg, sessionId, url, res);
45811
+ const q2 = (name) => url.searchParams.get(name) ?? void 0;
45812
+ return sendJson(res, 200, {
45813
+ assignments: adminListAssignments(
45814
+ cfg,
45815
+ sessionId,
45816
+ q2("scopeKind"),
45817
+ q2("scopeId"),
45818
+ q2("subjectKind"),
45819
+ q2("subjectId")
45820
+ )
45821
+ });
45625
45822
  }
45626
45823
  if (req.method === "POST" && parts.length === 3 && parts[2] === "permissions") {
45627
- return adminSetAssignment(cfg, sessionId, body, res);
45824
+ return sendJson(res, 200, adminSetAssignment(cfg, sessionId, body));
45628
45825
  }
45629
45826
  if (req.method === "POST" && parts.length === 4 && parts[2] === "permissions" && parts[3] === "remove") {
45630
- return adminRemoveAssignment(cfg, sessionId, body, res);
45827
+ adminRemoveAssignment(cfg, sessionId, String(body?.id ?? ""));
45828
+ return sendJson(res, 200, { ok: true });
45631
45829
  }
45632
45830
  if (req.method === "GET" && parts.length === 3 && parts[2] === "packs") {
45633
- return opsListGlobalPacks(cfg, sessionId, res);
45831
+ return sendJson(res, 200, { packs: opsListGlobalPacks(cfg, sessionId) });
45634
45832
  }
45635
45833
  if (req.method === "POST" && parts.length === 3 && parts[2] === "packs") {
45636
- return opsInstallGlobalPack(cfg, sessionId, body, res);
45834
+ return sendJson(res, 200, opsInstallGlobalPack(cfg, sessionId, String(body?.name ?? ""), String(body?.content ?? "")));
45637
45835
  }
45638
45836
  if (req.method === "POST" && parts.length === 4 && parts[2] === "packs" && parts[3] === "upload") {
45639
- return opsInstallGlobalPackArchive(cfg, sessionId, req, body, res);
45837
+ return sendJson(res, 200, opsInstallGlobalPackArchive(cfg, sessionId, archiveBody(body), packNameOverride(req)));
45640
45838
  }
45641
45839
  if (req.method === "POST" && parts.length === 4 && parts[2] === "packs" && parts[3] === "remove") {
45642
- return opsRemoveGlobalPack(cfg, sessionId, body, res);
45840
+ opsRemoveGlobalPack(cfg, sessionId, String(body?.name ?? ""));
45841
+ return sendJson(res, 200, { ok: true });
45643
45842
  }
45644
45843
  if (req.method === "GET" && parts.length === 3 && parts[2] === "profiles") {
45645
- return opsListAvailableProfiles(cfg, sessionId, res);
45844
+ return sendJson(res, 200, { profiles: opsListAvailableProfiles(cfg, sessionId) });
45646
45845
  }
45647
45846
  if (req.method === "GET" && parts.length === 3 && parts[2] === "policy") {
45648
- return opsGetPackPolicy(cfg, sessionId, res);
45847
+ return sendJson(res, 200, opsGetPackPolicy(cfg, sessionId));
45649
45848
  }
45650
45849
  if (req.method === "POST" && parts.length === 3 && parts[2] === "policy") {
45651
- return opsSetPackPolicy(cfg, sessionId, body, res);
45850
+ return sendJson(res, 200, opsSetPackPolicy(cfg, sessionId, body));
45652
45851
  }
45653
45852
  if (req.method === "GET" && parts.length === 3 && parts[2] === "audit") {
45654
- return opsAuditQuery(cfg, sessionId, url, res);
45853
+ return sendJson(res, 200, { events: opsAuditQuery(cfg, sessionId, auditQueryFrom(url)) });
45655
45854
  }
45656
45855
  if (req.method === "GET" && parts.length === 4 && parts[2] === "audit" && parts[3] === "count") {
45657
- return opsAuditCount(cfg, sessionId, url, res);
45856
+ return sendJson(res, 200, { count: opsAuditCount(cfg, sessionId, auditQueryFrom(url)) });
45658
45857
  }
45659
45858
  if (req.method === "GET" && parts.length === 3 && parts[2] === "exposure") {
45660
- return opsGetExposure(cfg, sessionId, res);
45859
+ return sendJson(res, 200, opsGetExposure(cfg, sessionId));
45661
45860
  }
45662
45861
  if (req.method === "POST" && parts.length === 3 && parts[2] === "exposure") {
45663
- return opsSetExposure(cfg, sessionId, body, res);
45862
+ return sendJson(res, 200, opsSetExposure(cfg, sessionId, body));
45664
45863
  }
45665
45864
  if (req.method === "GET" && parts.length === 3 && parts[2] === "git-backing") {
45666
- return opsListGitBacking(cfg, sessionId, res);
45865
+ return sendJson(res, 200, { bindings: opsListGitBacking(cfg, sessionId) });
45667
45866
  }
45668
45867
  if (req.method === "POST" && parts.length === 3 && parts[2] === "git-backing") {
45669
- return opsBindGitBacking(cfg, sessionId, body, res);
45868
+ const pat = body?.pat ? String(body.pat) : void 0;
45869
+ const binding = { ...body ?? {} };
45870
+ delete binding.pat;
45871
+ return sendJson(res, 200, opsBindGitBacking(cfg, sessionId, binding, pat));
45670
45872
  }
45671
45873
  if (req.method === "POST" && parts.length === 4 && parts[2] === "git-backing" && parts[3] === "remove") {
45672
- return opsUnbindGitBacking(cfg, sessionId, body, res);
45874
+ opsUnbindGitBacking(cfg, sessionId, String(body?.id ?? ""));
45875
+ return sendJson(res, 200, { ok: true });
45673
45876
  }
45674
45877
  if (req.method === "POST" && parts.length === 4 && parts[2] === "git-backing" && parts[3] === "sync") {
45675
- return opsSyncGitBacking(cfg, sessionId, body, res);
45878
+ return sendJson(res, 200, { published: opsSyncGitBacking(cfg, sessionId, String(body?.id ?? "")) });
45676
45879
  }
45677
45880
  if (req.method === "POST" && parts.length === 3 && parts[2] === "share") {
45678
- return adminCreateShareLink(cfg, sessionId, body, res);
45881
+ return sendJson(res, 201, adminCreateShareLink(cfg, sessionId, body ?? {}));
45679
45882
  }
45680
45883
  if (req.method === "GET" && parts.length === 3 && parts[2] === "share") {
45681
- return adminListShareLinks(cfg, sessionId, url, res);
45884
+ return sendJson(res, 200, { links: adminListShareLinks(cfg, sessionId, url.searchParams.get("projectId") ?? "") });
45682
45885
  }
45683
45886
  if (req.method === "POST" && parts.length === 4 && parts[2] === "share" && parts[3] === "refresh") {
45684
- return adminRefreshShareSnapshot(cfg, sessionId, body, res);
45887
+ return sendJson(res, 200, adminRefreshShareSnapshot(cfg, sessionId, String(body?.linkId ?? "")));
45685
45888
  }
45686
45889
  if (req.method === "POST" && parts.length === 4 && parts[2] === "share" && parts[3] === "update") {
45687
- return adminUpdateShareLink(cfg, sessionId, body, res);
45890
+ return sendJson(res, 200, adminUpdateShareLink(cfg, sessionId, String(body?.linkId ?? ""), body?.changes ?? {}));
45688
45891
  }
45689
45892
  if (req.method === "POST" && parts.length === 4 && parts[2] === "share" && parts[3] === "remove") {
45690
- return adminRemoveShareLink(cfg, sessionId, body, res);
45893
+ adminRemoveShareLink(cfg, sessionId, String(body?.linkId ?? ""));
45894
+ return sendJson(res, 200, { ok: true });
45691
45895
  }
45692
45896
  if (req.method === "GET" && parts.length === 4 && parts[2] === "share" && parts[3] === "access") {
45693
- return adminGetShareAccessLog(cfg, sessionId, url, res);
45897
+ const limit = Number(url.searchParams.get("limit") ?? "100") || 100;
45898
+ return sendJson(res, 200, { entries: adminGetShareAccessLog(cfg, sessionId, url.searchParams.get("linkId") ?? "", limit) });
45694
45899
  }
45695
45900
  if (req.method === "GET" && parts.length === 3 && parts[2] === "landscape") {
45696
45901
  return sendJson(res, 200, generateLandscape(cfg, sessionId));
@@ -46629,6 +46834,7 @@ var WEB_MUTATION_PATHS = /* @__PURE__ */ new Set([
46629
46834
  "/web/projects/git/sync",
46630
46835
  "/web/projects/git/commit",
46631
46836
  "/web/projects/git/sync-config",
46837
+ "/web/projects/config",
46632
46838
  "/web/tokens",
46633
46839
  "/web/tokens/revoke",
46634
46840
  "/web/projects",