@streamoid/settings 0.6.5 → 0.6.6

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
@@ -159,9 +159,19 @@ function dataOf(value) {
159
159
  async function loadWorkspaceOrganization(workspaceId, request, signal) {
160
160
  const rows = dataOf(await request("/workspace", signal));
161
161
  if (!Array.isArray(rows)) throw new Error("Invalid workspace list");
162
- const row = rows.find((item) => (item.workspace?._id ?? item._id) === workspaceId);
163
- if (!row) throw new Error("Workspace not found");
164
- const workspace = row.workspace ?? row;
162
+ let row = rows.find((item) => (item.workspace?._id ?? item._id) === workspaceId);
163
+ let workspace = row?.workspace ?? row;
164
+ const ownerId = workspace?.organizationId ?? row?.organizationId;
165
+ const ownerName = workspace?.organizationName ?? row?.organizationName ?? workspace?.organization?.name ?? row?.organization?.name;
166
+ const explicitlyUnowned = workspace?.organizationId === null || workspace?.organization === null;
167
+ if (!workspace || !explicitlyUnowned && ownerId && !ownerName) {
168
+ const detail2 = dataOf(await request(`/workspace/${encodeURIComponent(workspaceId)}`, signal));
169
+ if (!detail2 || (detail2.workspace?._id ?? detail2._id) !== workspaceId) {
170
+ throw new Error("Workspace not found");
171
+ }
172
+ row = detail2;
173
+ workspace = row.workspace ?? row;
174
+ }
165
175
  const owner = workspace.organization !== void 0 ? workspace.organization : row.organization;
166
176
  const ownerRef = workspace.organizationId !== void 0 ? workspace.organizationId : row.organizationId;
167
177
  if (ownerRef === null || owner === null) return null;
package/dist/index.mjs CHANGED
@@ -93,9 +93,19 @@ function dataOf(value) {
93
93
  async function loadWorkspaceOrganization(workspaceId, request, signal) {
94
94
  const rows = dataOf(await request("/workspace", signal));
95
95
  if (!Array.isArray(rows)) throw new Error("Invalid workspace list");
96
- const row = rows.find((item) => (item.workspace?._id ?? item._id) === workspaceId);
97
- if (!row) throw new Error("Workspace not found");
98
- const workspace = row.workspace ?? row;
96
+ let row = rows.find((item) => (item.workspace?._id ?? item._id) === workspaceId);
97
+ let workspace = row?.workspace ?? row;
98
+ const ownerId = workspace?.organizationId ?? row?.organizationId;
99
+ const ownerName = workspace?.organizationName ?? row?.organizationName ?? workspace?.organization?.name ?? row?.organization?.name;
100
+ const explicitlyUnowned = workspace?.organizationId === null || workspace?.organization === null;
101
+ if (!workspace || !explicitlyUnowned && ownerId && !ownerName) {
102
+ const detail2 = dataOf(await request(`/workspace/${encodeURIComponent(workspaceId)}`, signal));
103
+ if (!detail2 || (detail2.workspace?._id ?? detail2._id) !== workspaceId) {
104
+ throw new Error("Workspace not found");
105
+ }
106
+ row = detail2;
107
+ workspace = row.workspace ?? row;
108
+ }
99
109
  const owner = workspace.organization !== void 0 ? workspace.organization : row.organization;
100
110
  const ownerRef = workspace.organizationId !== void 0 ? workspace.organizationId : row.organizationId;
101
111
  if (ownerRef === null || owner === null) return null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@streamoid/settings",
3
- "version": "0.6.5",
3
+ "version": "0.6.6",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.mjs",
6
6
  "types": "./dist/index.d.ts",