atris 3.15.53 → 3.15.54

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.
@@ -1126,15 +1126,35 @@ async function resolveComputerCommandContext(token, options = {}) {
1126
1126
  ? await resolveBusinessContextBySlug(token, options.businessSlug, { preferCache: true })
1127
1127
  : await resolveBusinessContext(token);
1128
1128
  if (!ctx?.businessId) return null;
1129
+ const workspaceId = options.workspaceId
1130
+ ? await resolveWorkspaceSelector(token, ctx, options.workspaceId)
1131
+ : ctx.workspaceId;
1129
1132
  return {
1130
1133
  ...ctx,
1131
- workspaceId: options.workspaceId || ctx.workspaceId,
1134
+ workspaceId,
1132
1135
  };
1133
1136
  }
1134
1137
 
1135
1138
  return resolveBusinessContext(token);
1136
1139
  }
1137
1140
 
1141
+ function looksLikeWorkspaceId(input) {
1142
+ const value = String(input || '').trim();
1143
+ if (!value) return false;
1144
+ return /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(value)
1145
+ || /^ws-[a-z0-9_-]+$/i.test(value);
1146
+ }
1147
+
1148
+ async function resolveWorkspaceSelector(token, ctx, input) {
1149
+ const selector = String(input || '').trim();
1150
+ if (!selector) return ctx.workspaceId;
1151
+ if (selector === ctx.workspaceId || looksLikeWorkspaceId(selector)) return selector;
1152
+
1153
+ const workspaces = await listBusinessWorkspaces(token, ctx);
1154
+ const workspace = resolveWorkspaceFromList(workspaces, selector);
1155
+ return workspace?.id || selector;
1156
+ }
1157
+
1138
1158
  async function resolveBusinessOwnerForCreate(token, businessSlug = null) {
1139
1159
  const wantedSlug = businessSlug ? String(businessSlug).trim() : null;
1140
1160
  if (wantedSlug) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "atris",
3
- "version": "3.15.53",
3
+ "version": "3.15.54",
4
4
  "main": "bin/atris.js",
5
5
  "bin": {
6
6
  "atris": "bin/atris.js",