@codemem/server 0.31.2 → 0.31.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.
package/dist/index.js CHANGED
@@ -1707,6 +1707,20 @@ function coordinatorAdminStatusPayload(config = readCoordinatorSyncConfig()) {
1707
1707
  has_groups: hasGroups
1708
1708
  };
1709
1709
  }
1710
+ function removeConfiguredCoordinatorGroup(groupId) {
1711
+ const targetGroup = groupId.trim();
1712
+ if (!targetGroup) return [];
1713
+ const config = readCodememConfigFile();
1714
+ const rawGroups = config.sync_coordinator_groups;
1715
+ const groups = Array.isArray(rawGroups) ? rawGroups.map((group) => String(group).trim()).filter(Boolean) : typeof rawGroups === "string" ? rawGroups.split(",").map((group) => group.trim()).filter(Boolean) : typeof config.sync_coordinator_group === "string" && config.sync_coordinator_group.trim() ? [config.sync_coordinator_group.trim()] : [];
1716
+ const nextGroups = groups.filter((group) => group !== targetGroup);
1717
+ if (nextGroups.length === groups.length) return groups;
1718
+ config.sync_coordinator_groups = nextGroups;
1719
+ if (nextGroups.length) config.sync_coordinator_group = nextGroups[0];
1720
+ else delete config.sync_coordinator_group;
1721
+ writeCodememConfigFile(config);
1722
+ return nextGroups;
1723
+ }
1710
1724
  function coordinatorAdminUnavailable(status) {
1711
1725
  if (status.readiness === "not_configured") return {
1712
1726
  body: {
@@ -3998,10 +4012,13 @@ function syncRoutes(getStore, getSyncRuntimeStatus) {
3998
4012
  error: "group_not_found_or_already_archived",
3999
4013
  status
4000
4014
  }, 404);
4015
+ const groups = removeConfiguredCoordinatorGroup(groupId);
4001
4016
  return c.json({
4002
4017
  ok: true,
4003
4018
  group,
4004
- status
4019
+ status: coordinatorAdminStatusPayload(),
4020
+ disconnected_group_id: groupId,
4021
+ groups
4005
4022
  });
4006
4023
  } catch (error) {
4007
4024
  return c.json({