@shardworks/clerk-apparatus 0.1.224 → 0.1.226

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shardworks/clerk-apparatus",
3
- "version": "0.1.224",
3
+ "version": "0.1.226",
4
4
  "license": "ISC",
5
5
  "repository": {
6
6
  "type": "git",
@@ -20,12 +20,12 @@
20
20
  },
21
21
  "dependencies": {
22
22
  "zod": "4.3.6",
23
- "@shardworks/stacks-apparatus": "0.1.224",
24
- "@shardworks/tools-apparatus": "0.1.224"
23
+ "@shardworks/tools-apparatus": "0.1.226",
24
+ "@shardworks/stacks-apparatus": "0.1.226"
25
25
  },
26
26
  "devDependencies": {
27
27
  "@types/node": "25.5.0",
28
- "@shardworks/nexus-core": "0.1.224"
28
+ "@shardworks/nexus-core": "0.1.226"
29
29
  },
30
30
  "files": [
31
31
  "dist",
@@ -150,6 +150,7 @@
150
150
  let showChildren = true; // toggle state — children shown by default
151
151
  let childrenMap = {}; // { parentId: WritDoc[] } — fetched children keyed by parent id
152
152
  let repostSourceId = null;
153
+ let linkKinds = []; // [{ id, ownerPlugin, description }] — registered writ link kinds
153
154
 
154
155
  const LIMIT = 20;
155
156
 
@@ -500,9 +501,15 @@
500
501
  </div>`;
501
502
  }
502
503
 
503
- // Add link form
504
+ // Add link form — layout: [target] [kind▼] [label] [Link]
505
+ let kindOptionsHtml = '<option value="">None</option>';
506
+ for (const k of linkKinds) {
507
+ const title = k.description ? ` title="${escHtml(k.description)}"` : '';
508
+ kindOptionsHtml += `<option value="${escHtml(k.id)}"${title}>${escHtml(k.id)}</option>`;
509
+ }
504
510
  html += `<div class="add-link-form" id="add-link-form-${writ.id}">
505
511
  <input type="text" id="link-target-${writ.id}" placeholder="Target writ id" style="width:140px">
512
+ <select id="link-kind-${writ.id}" style="width:140px">${kindOptionsHtml}</select>
506
513
  <input type="text" id="link-label-${writ.id}" list="link-labels" placeholder="Link label" style="width:120px">
507
514
  <button class="btn" data-action="addlink" data-id="${writ.id}">Link</button>
508
515
  <div class="error-msg" id="link-error-${writ.id}" style="display:none"></div>
@@ -613,8 +620,10 @@
613
620
  } else if (action === 'addlink') {
614
621
  const targetInput = document.getElementById(`link-target-${id}`);
615
622
  const labelInput = document.getElementById(`link-label-${id}`);
623
+ const kindSelect = document.getElementById(`link-kind-${id}`);
616
624
  const errEl = document.getElementById(`link-error-${id}`);
617
- doAddLink(id, targetInput.value.trim(), labelInput.value.trim(), btn, errEl, targetInput, labelInput);
625
+ const kindValue = kindSelect ? kindSelect.value : '';
626
+ doAddLink(id, targetInput.value.trim(), labelInput.value.trim(), kindValue, btn, errEl, targetInput, labelInput, kindSelect);
618
627
  }
619
628
  }
620
629
 
@@ -755,7 +764,7 @@
755
764
  }
756
765
  }
757
766
 
758
- async function doAddLink(writId, targetId, label, btn, errEl, targetInput, labelInput) {
767
+ async function doAddLink(writId, targetId, label, kind, btn, errEl, targetInput, labelInput, kindSelect) {
759
768
  clearError(errEl);
760
769
  if (!targetId || !label) {
761
770
  showError(errEl, 'Target writ id and link label are required.');
@@ -765,9 +774,12 @@
765
774
  const orig = btn.textContent;
766
775
  btn.textContent = 'Linking...';
767
776
  try {
768
- await api('POST', '/api/writ/link', { sourceId: writId, targetId, label });
777
+ const payload = { sourceId: writId, targetId, label };
778
+ if (kind) payload.kind = kind;
779
+ await api('POST', '/api/writ/link', payload);
769
780
  targetInput.value = '';
770
781
  labelInput.value = '';
782
+ if (kindSelect) kindSelect.value = '';
771
783
  await refreshDetail(writId);
772
784
  } catch (e) {
773
785
  showError(errEl, e.message);
@@ -947,6 +959,16 @@
947
959
  await Promise.all(fetches);
948
960
  }
949
961
 
962
+ async function loadLinkKinds() {
963
+ try {
964
+ const kinds = await api('GET', '/api/writ/link-kinds?json=true');
965
+ linkKinds = Array.isArray(kinds) ? kinds : [];
966
+ } catch (e) {
967
+ console.error('Failed to load link kinds:', e);
968
+ linkKinds = [];
969
+ }
970
+ }
971
+
950
972
  async function loadWritTypes() {
951
973
  let types;
952
974
  try {
@@ -1270,6 +1292,7 @@
1270
1292
 
1271
1293
  // ── Init ────────────────────────────────────────────────────────────
1272
1294
  loadCodexes();
1295
+ loadLinkKinds();
1273
1296
 
1274
1297
  // Deep-link: ?writ=ID
1275
1298
  (async function () {