@yadsh/dsh-web-fetch-authenticated 0.2.0 → 0.3.1

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/lib/client.js CHANGED
@@ -5086,6 +5086,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
5086
5086
  "outcome": string().readonly(),
5087
5087
  "detail": string().readonly().optional(),
5088
5088
  "preview": string().readonly().optional(),
5089
+ "adapter": string().readonly().optional(),
5089
5090
  "truncated": boolean().readonly()
5090
5091
  })).readonly(),
5091
5092
  "unmatchedPolicy": literal("block").readonly()
@@ -5135,6 +5136,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
5135
5136
  "outcome": string().readonly(),
5136
5137
  "detail": string().readonly().optional(),
5137
5138
  "preview": string().readonly().optional(),
5139
+ "adapter": string().readonly().optional(),
5138
5140
  "truncated": boolean().readonly()
5139
5141
  });
5140
5142
  const TYPERT_REMOTE = {
@@ -5163,7 +5165,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
5163
5165
  },
5164
5166
  sourceLocation: {
5165
5167
  "file": "packages/dsh-web-fetch-authenticated/src/index.ts",
5166
- "line": 145,
5168
+ "line": 147,
5167
5169
  "column": 9
5168
5170
  }
5169
5171
  },
@@ -5181,7 +5183,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
5181
5183
  },
5182
5184
  sourceLocation: {
5183
5185
  "file": "packages/dsh-web-fetch-authenticated/src/index.ts",
5184
- "line": 114,
5186
+ "line": 116,
5185
5187
  "column": 9
5186
5188
  }
5187
5189
  },
@@ -5218,7 +5220,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
5218
5220
  },
5219
5221
  sourceLocation: {
5220
5222
  "file": "packages/dsh-web-fetch-authenticated/src/index.ts",
5221
- "line": 135,
5223
+ "line": 137,
5222
5224
  "column": 9
5223
5225
  }
5224
5226
  }
@@ -5598,6 +5600,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
5598
5600
  }
5599
5601
  for (const pattern of patterns) if (typeof pattern !== "string" || compilePathPattern(pattern) === void 0) errors.push(`${label}: malformed ${field} pattern "${String(pattern)}" (must start with "/")`);
5600
5602
  }
5603
+ errors.push(...validateAdapter(rule.adapter, label));
5601
5604
  errors.push(...validateAuth(rule.auth, label));
5602
5605
  errors.push(...validateNetworkPolicy(rule.networkPolicy, label));
5603
5606
  errors.push(...validateRedirectPolicy(rule.redirects, label));
@@ -5615,6 +5618,19 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
5615
5618
  }
5616
5619
  return errors;
5617
5620
  }
5621
+ function validateAdapter(adapter, label) {
5622
+ if (adapter === void 0) return [];
5623
+ const errors = [];
5624
+ const type = adapter.type;
5625
+ if (type !== void 0 && type !== "none" && type !== "jira" && type !== "confluence") errors.push(`${label}: unsupported adapter type "${String(type)}"`);
5626
+ const flavor = adapter.jiraFlavor;
5627
+ if (flavor !== void 0 && flavor !== "server" && flavor !== "cloud") errors.push(`${label}: adapter.jiraFlavor must be "server" or "cloud"`);
5628
+ for (const field of ["includeComments", "includeLinks"]) {
5629
+ const value = adapter[field];
5630
+ if (value !== void 0 && typeof value !== "boolean") errors.push(`${label}: adapter.${field} must be a boolean`);
5631
+ }
5632
+ return errors;
5633
+ }
5618
5634
  function validateAuth(auth, label) {
5619
5635
  const errors = [];
5620
5636
  if (auth === void 0 || typeof auth !== "object") {
@@ -6036,6 +6052,7 @@ textarea.wfa-control{resize:vertical}
6036
6052
  }
6037
6053
  function ruleToDraft(rule) {
6038
6054
  const auth = rule.auth;
6055
+ const adapter = rule.adapter;
6039
6056
  return {
6040
6057
  id: rule.id,
6041
6058
  name: rule.name,
@@ -6054,6 +6071,10 @@ textarea.wfa-control{resize:vertical}
6054
6071
  headerName: auth.type === "header" ? auth.headerName : "",
6055
6072
  headerRef: auth.type === "header" ? auth.credential : "",
6056
6073
  headerPrefix: auth.type === "header" ? auth.prefix ?? "" : "",
6074
+ adapterType: adapter?.type ?? "none",
6075
+ jiraFlavor: adapter?.jiraFlavor ?? "server",
6076
+ includeComments: adapter?.includeComments ?? false,
6077
+ includeLinks: adapter?.includeLinks ?? false,
6057
6078
  network: networkToDraft(rule.networkPolicy),
6058
6079
  redirectMode: rule.redirects?.mode ?? "same-origin",
6059
6080
  maxRedirects: rule.redirects?.maxRedirects === void 0 ? "" : String(rule.redirects.maxRedirects),
@@ -6082,6 +6103,10 @@ textarea.wfa-control{resize:vertical}
6082
6103
  headerName: "",
6083
6104
  headerRef: "",
6084
6105
  headerPrefix: "",
6106
+ adapterType: "none",
6107
+ jiraFlavor: "server",
6108
+ includeComments: false,
6109
+ includeLinks: false,
6085
6110
  network: networkToDraft(void 0),
6086
6111
  redirectMode: "same-origin",
6087
6112
  maxRedirects: "",
@@ -6137,6 +6162,12 @@ textarea.wfa-control{resize:vertical}
6137
6162
  },
6138
6163
  limits: buildLimits(draft, errors)
6139
6164
  };
6165
+ if (draft.adapterType !== "none") rule.adapter = draft.adapterType === "jira" ? {
6166
+ type: "jira",
6167
+ ...draft.jiraFlavor !== "server" ? { jiraFlavor: draft.jiraFlavor } : {},
6168
+ ...draft.includeComments ? { includeComments: true } : {},
6169
+ ...draft.includeLinks ? { includeLinks: true } : {}
6170
+ } : { type: "confluence" };
6140
6171
  if (draft.description.trim().length > 0) rule.description = draft.description.trim();
6141
6172
  if (draft.testUrl.trim().length > 0) rule.testUrl = draft.testUrl.trim();
6142
6173
  errors.push(...validateRule(rule, 0));
@@ -6172,10 +6203,10 @@ textarea.wfa-control{resize:vertical}
6172
6203
  return;
6173
6204
  }
6174
6205
  let cancelled = false;
6175
- credentials.describe({ refs: [refName] }).then((response) => {
6206
+ credentials.describe([refName]).then((response) => {
6176
6207
  if (cancelled) return;
6177
- if (response.result.ok) {
6178
- const view = response.result.value.credentials[refName];
6208
+ if (response.ok) {
6209
+ const view = response.value[refName];
6179
6210
  setState({
6180
6211
  configured: view?.configured ?? false,
6181
6212
  writable: view?.writable ?? true
@@ -6191,14 +6222,14 @@ textarea.wfa-control{resize:vertical}
6191
6222
  setBusy(true);
6192
6223
  setMessage(void 0);
6193
6224
  try {
6194
- await credentials.set({
6195
- ref: refName,
6196
- value: secret
6197
- });
6225
+ if (!(await credentials.set(refName, secret)).ok) {
6226
+ setMessage("The Host refused the write (read-only source?).");
6227
+ return;
6228
+ }
6198
6229
  setSecret("");
6199
- const response = await credentials.describe({ refs: [refName] });
6200
- if (response.result.ok) {
6201
- const view = response.result.value.credentials[refName];
6230
+ const response = await credentials.describe([refName]);
6231
+ if (response.ok) {
6232
+ const view = response.value[refName];
6202
6233
  setState({
6203
6234
  configured: view?.configured ?? false,
6204
6235
  writable: view?.writable ?? true
@@ -6219,10 +6250,13 @@ textarea.wfa-control{resize:vertical}
6219
6250
  setBusy(true);
6220
6251
  setMessage(void 0);
6221
6252
  try {
6222
- await credentials.unset({ ref: refName });
6223
- const response = await credentials.describe({ refs: [refName] });
6224
- if (response.result.ok) {
6225
- const view = response.result.value.credentials[refName];
6253
+ if (!(await credentials.unset(refName)).ok) {
6254
+ setMessage("The Host refused the removal.");
6255
+ return;
6256
+ }
6257
+ const response = await credentials.describe([refName]);
6258
+ if (response.ok) {
6259
+ const view = response.value[refName];
6226
6260
  setState({
6227
6261
  configured: view?.configured ?? false,
6228
6262
  writable: view?.writable ?? true
@@ -6485,6 +6519,79 @@ textarea.wfa-control{resize:vertical}
6485
6519
  },
6486
6520
  credentials
6487
6521
  }),
6522
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
6523
+ className: "wfa-grid",
6524
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Field, {
6525
+ label: "Content adapter",
6526
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("select", {
6527
+ className: "wfa-control",
6528
+ value: draft.adapterType,
6529
+ onChange: (event) => {
6530
+ patch({ adapterType: event.target.value });
6531
+ },
6532
+ children: [
6533
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
6534
+ value: "none",
6535
+ children: "Raw HTTP/HTML"
6536
+ }),
6537
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
6538
+ value: "jira",
6539
+ children: "Jira issue (REST → clean text)"
6540
+ }),
6541
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
6542
+ value: "confluence",
6543
+ children: "Confluence page (REST → clean text)"
6544
+ })
6545
+ ]
6546
+ })
6547
+ }), draft.adapterType === "jira" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Field, {
6548
+ label: "Jira flavor",
6549
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("select", {
6550
+ className: "wfa-control",
6551
+ value: draft.jiraFlavor,
6552
+ onChange: (event) => {
6553
+ patch({ jiraFlavor: event.target.value });
6554
+ },
6555
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
6556
+ value: "server",
6557
+ children: "Server / Data Center (REST v2, wiki markup)"
6558
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
6559
+ value: "cloud",
6560
+ children: "Cloud (REST v3, Atlassian Document Format)"
6561
+ })]
6562
+ })
6563
+ })]
6564
+ }),
6565
+ draft.adapterType === "jira" && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
6566
+ className: "wfa-checks",
6567
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
6568
+ className: "wfa-check",
6569
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
6570
+ type: "checkbox",
6571
+ checked: draft.includeComments,
6572
+ onChange: (event) => {
6573
+ patch({ includeComments: event.target.checked });
6574
+ }
6575
+ }), "Include comments"]
6576
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
6577
+ className: "wfa-check",
6578
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
6579
+ type: "checkbox",
6580
+ checked: draft.includeLinks,
6581
+ onChange: (event) => {
6582
+ patch({ includeLinks: event.target.checked });
6583
+ }
6584
+ }), "Include issue links"]
6585
+ })]
6586
+ }),
6587
+ draft.adapterType !== "none" && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("p", {
6588
+ className: "wfa-note",
6589
+ children: [
6590
+ "Recognized URLs (",
6591
+ draft.adapterType === "jira" ? "/browse/ISSUE-KEY" : "/pages/<id>, /display/SPACE/Title",
6592
+ ") are fetched from the product REST API with the same credentials and policy and returned as clean Markdown text; everything else falls back to raw HTTP/HTML."
6593
+ ]
6594
+ }),
6488
6595
  /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("details", {
6489
6596
  className: "wfa-advanced",
6490
6597
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("summary", { children: "Network policy, redirects, and limits" }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
@@ -6684,7 +6791,7 @@ textarea.wfa-control{resize:vertical}
6684
6791
  className: "wfa-control",
6685
6792
  style: { flex: 1 },
6686
6793
  value: url,
6687
- placeholder: "https://jira.example.corp/browse/MDC-123",
6794
+ placeholder: "https://jira.example.corp/browse/PROJ-123",
6688
6795
  onChange: (event) => {
6689
6796
  setUrl(event.target.value);
6690
6797
  }
@@ -6743,6 +6850,12 @@ textarea.wfa-control{resize:vertical}
6743
6850
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("b", { children: "Auth applied:" }),
6744
6851
  " ",
6745
6852
  report.authApplied ? "yes" : "no",
6853
+ report.adapter !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
6854
+ " · ",
6855
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("b", { children: "Adapter:" }),
6856
+ " ",
6857
+ report.adapter
6858
+ ] }),
6746
6859
  report.credentialState !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
6747
6860
  " · ",
6748
6861
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("b", { children: "Credential" }),
@@ -6789,7 +6902,7 @@ textarea.wfa-control{resize:vertical}
6789
6902
  className: "wfa-control",
6790
6903
  style: { flex: 1 },
6791
6904
  value: url,
6792
- placeholder: "https://jira.example.corp/browse/MDC-123",
6905
+ placeholder: "https://jira.example.corp/browse/PROJ-123",
6793
6906
  onChange: (event) => {
6794
6907
  setUrl(event.target.value);
6795
6908
  }
@@ -6917,13 +7030,20 @@ textarea.wfa-control{resize:vertical}
6917
7030
  /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
6918
7031
  className: "wfa-actions",
6919
7032
  style: { gap: 5 },
6920
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Pill, {
6921
- tone: rule.enabled ? "ok" : "warn",
6922
- children: rule.enabled ? "enabled" : "disabled"
6923
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Pill, {
6924
- tone: "warn",
6925
- children: authSummary(rule.auth)
6926
- })]
7033
+ children: [
7034
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Pill, {
7035
+ tone: rule.enabled ? "ok" : "warn",
7036
+ children: rule.enabled ? "enabled" : "disabled"
7037
+ }),
7038
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Pill, {
7039
+ tone: "warn",
7040
+ children: authSummary(rule.auth)
7041
+ }),
7042
+ rule.adapter !== void 0 && rule.adapter.type !== "none" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Pill, {
7043
+ tone: "ok",
7044
+ children: rule.adapter.type
7045
+ })
7046
+ ]
6927
7047
  }),
6928
7048
  /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
6929
7049
  className: "wfa-actions",
@@ -7105,8 +7225,8 @@ textarea.wfa-control{resize:vertical}
7105
7225
  const inject = [
7106
7226
  "slots",
7107
7227
  "settingsScope",
7108
- "connection",
7109
- "remote"
7228
+ "remote",
7229
+ "remote.credentials"
7110
7230
  ];
7111
7231
  /** Mount the generated Remote contribution and register the native Settings card. */
7112
7232
  async function apply(ctx) {
@@ -7119,7 +7239,7 @@ textarea.wfa-control{resize:vertical}
7119
7239
  status: () => injectedRemote.webFetchAuth.status(),
7120
7240
  testRule: (ruleId, url) => injectedRemote.webFetchAuth.testRule(ruleId, url),
7121
7241
  diagnose: (url) => injectedRemote.webFetchAuth.diagnose(url),
7122
- credentials: remoteCtx.connection?.api?.credentials
7242
+ credentials: injectedRemote.credentials
7123
7243
  };
7124
7244
  return registerSettingsCard(remoteCtx, {
7125
7245
  key: SETTINGS_NAMESPACE,