@nextclaw/server 0.5.3 → 0.5.4

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.
Files changed (2) hide show
  1. package/dist/index.js +21 -9
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -899,12 +899,13 @@ function collectMarketplaceInstalledView(options) {
899
899
  records
900
900
  };
901
901
  }
902
- function resolvePluginManageTargetId(options, rawTargetId) {
902
+ function resolvePluginManageTargetId(options, rawTargetId, rawSpec) {
903
903
  const targetId = rawTargetId.trim();
904
- if (!targetId) {
904
+ if (!targetId && !rawSpec) {
905
905
  return rawTargetId;
906
906
  }
907
- const normalizedTarget = normalizePluginNpmSpec(targetId).toLowerCase();
907
+ const normalizedTarget = targetId ? normalizePluginNpmSpec(targetId).toLowerCase() : "";
908
+ const normalizedSpec = rawSpec ? normalizePluginNpmSpec(rawSpec).toLowerCase() : "";
908
909
  const installed = collectMarketplaceInstalledView(options);
909
910
  const pluginRecords = installed.records.filter((record) => record.type === "plugin");
910
911
  const lowerTargetId = targetId.toLowerCase();
@@ -914,13 +915,23 @@ function resolvePluginManageTargetId(options, rawTargetId) {
914
915
  return recordId;
915
916
  }
916
917
  }
917
- for (const record of pluginRecords) {
918
- const normalizedSpec = normalizePluginNpmSpec(record.spec).toLowerCase();
919
- if (normalizedSpec === normalizedTarget && record.id && record.id.trim().length > 0) {
920
- return record.id;
918
+ if (normalizedTarget) {
919
+ for (const record of pluginRecords) {
920
+ const normalizedRecordSpec = normalizePluginNpmSpec(record.spec).toLowerCase();
921
+ if (normalizedRecordSpec === normalizedTarget && record.id && record.id.trim().length > 0) {
922
+ return record.id;
923
+ }
924
+ }
925
+ }
926
+ if (normalizedSpec && normalizedSpec !== normalizedTarget) {
927
+ for (const record of pluginRecords) {
928
+ const normalizedRecordSpec = normalizePluginNpmSpec(record.spec).toLowerCase();
929
+ if (normalizedRecordSpec === normalizedSpec && record.id && record.id.trim().length > 0) {
930
+ return record.id;
931
+ }
921
932
  }
922
933
  }
923
- return targetId;
934
+ return targetId || rawSpec || rawTargetId;
924
935
  }
925
936
  function sanitizeMarketplaceItem(item) {
926
937
  const next = { ...item };
@@ -1022,7 +1033,8 @@ async function manageMarketplaceItem(params) {
1022
1033
  const type = params.body.type;
1023
1034
  const action = params.body.action;
1024
1035
  const requestedTargetId = typeof params.body.id === "string" && params.body.id.trim().length > 0 ? params.body.id.trim() : typeof params.body.spec === "string" && params.body.spec.trim().length > 0 ? params.body.spec.trim() : "";
1025
- const targetId = type === "plugin" ? resolvePluginManageTargetId(params.options, requestedTargetId) : requestedTargetId;
1036
+ const rawSpec = typeof params.body.spec === "string" ? params.body.spec.trim() : "";
1037
+ const targetId = type === "plugin" ? resolvePluginManageTargetId(params.options, requestedTargetId, rawSpec) : requestedTargetId;
1026
1038
  if (type !== "plugin" && type !== "skill" || action !== "enable" && action !== "disable" && action !== "uninstall" || !targetId) {
1027
1039
  throw new Error("INVALID_BODY:type, action and non-empty id/spec are required");
1028
1040
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nextclaw/server",
3
- "version": "0.5.3",
3
+ "version": "0.5.4",
4
4
  "private": false,
5
5
  "description": "Nextclaw UI/API server.",
6
6
  "type": "module",