@field-studio/sdk 0.1.1 → 0.1.2

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.
@@ -8,8 +8,7 @@ export interface RoleDefinition {
8
8
  }
9
9
  export interface PublicUser {
10
10
  id: string;
11
- username: string;
12
- display_name: string;
11
+ email: string;
13
12
  role: string;
14
13
  status: string;
15
14
  workspace_id: string;
@@ -58,7 +57,7 @@ export interface IdentityOperations {
58
57
  result: null;
59
58
  };
60
59
  update_user: {
61
- args: [userId: string, changes: Record<string, string>, actor: string];
60
+ args: [userId: string, changes: Partial<Pick<PublicUser, "role" | "status">>, actor: string];
62
61
  result: PublicUser;
63
62
  };
64
63
  check_health: {
@@ -3,8 +3,7 @@ import './auth.css';
3
3
  import { type RoleDataScopeConfig } from './RoleManager.js';
4
4
  export type User = {
5
5
  id: string;
6
- username: string;
7
- display_name: string;
6
+ email: string;
8
7
  role: string;
9
8
  role_name?: string;
10
9
  permissions?: string[];
@@ -122,7 +122,7 @@ export default function AuthShell({ children, brand = 'Field Studio', tagline =
122
122
  openUserManagement: () => setView('users'),
123
123
  logout,
124
124
  };
125
- return (_jsxs("div", { className: "authenticated-shell", children: [view === 'users' && (_jsxs("header", { className: "account-bar", children: [_jsx("span", { children: _jsx("strong", { children: session.user.display_name || session.user.username }) }), _jsx("nav", { "aria-label": "Account actions", children: _jsx("button", { className: "button small", onClick: () => setView('app'), children: "Back to workspace" }) })] })), error && (_jsx("p", { className: "auth-error", role: "alert", children: error })), view === 'users' ? (_jsx(UserManager, { currentUserId: session.user.id, request: request, roleDataScope: roleDataScope })) : (_jsx(AuthContext.Provider, { value: handle, children: _jsx("div", { className: "private-application", children: children }, epoch) }))] }));
125
+ return (_jsxs("div", { className: "authenticated-shell", children: [view === 'users' && (_jsxs("header", { className: "account-bar", children: [_jsx("span", { children: _jsx("strong", { children: session.user.email }) }), _jsx("nav", { "aria-label": "Account actions", children: _jsx("button", { className: "button small", onClick: () => setView('app'), children: "Back to workspace" }) })] })), error && (_jsx("p", { className: "auth-error", role: "alert", children: error })), view === 'users' ? (_jsx(UserManager, { currentUserId: session.user.id, request: request, roleDataScope: roleDataScope })) : (_jsx(AuthContext.Provider, { value: handle, children: _jsx("div", { className: "private-application", children: children }, epoch) }))] }));
126
126
  }
127
127
  function Login({ brand, tagline, description, error, onRetry, }) {
128
128
  return (_jsx("main", { className: "auth-page", children: _jsxs("section", { className: "auth-panel", children: [_jsxs("a", { className: "auth-brand", href: "/", children: [brand, " ", _jsx("span", { children: tagline })] }), _jsx("h1", { children: "Sign in to the workspace" }), _jsx("p", { className: "auth-description", children: description }), error && _jsx("p", { className: "auth-error", role: "alert", children: error }), _jsx("a", { className: "button primary auth-submit", href: "/auth/login", children: "Sign in with SSO" }), error && (_jsx("div", { className: "auth-links", children: _jsx("button", { type: "button", onClick: () => void onRetry(), children: "Reconnect" }) }))] }) }));
@@ -186,12 +186,10 @@ function UserManager({ currentUserId, request, roleDataScope, }) {
186
186
  setBusy(false);
187
187
  }
188
188
  }
189
- return (_jsxs("main", { className: "auth-settings user-management", children: [_jsx("h1", { children: "User management" }), _jsx("p", { children: "Manage roles and access for provisioned accounts." }), error && (_jsx("p", { className: "auth-error", role: "alert", children: error })), _jsxs("section", { className: "auth-user-section", children: [_jsx("div", { className: "user-list-header", children: _jsxs("h2", { children: ["Accounts", ' ', _jsxs("span", { className: "account-scope", children: [total.toLocaleString(), " users"] })] }) }), loading ? (_jsx("p", { role: "status", children: "Loading users\u2026" })) : !users.length ? (_jsx("p", { children: "No users yet" })) : (_jsx("div", { className: "auth-table-scroll", children: _jsxs("table", { children: [_jsx("thead", { children: _jsxs("tr", { children: [_jsx("th", { children: "Username" }), _jsx("th", { children: "Name" }), _jsx("th", { children: "Role" }), _jsx("th", { children: "Status" }), _jsx("th", { children: "Actions" })] }) }), _jsx("tbody", { children: users.map((user) => (_jsx(UserRow, { user: user, self: currentUserId === user.id, busy: busy, roles: roles ?? defaultRoles, onEdit: (changes) => action(async () => {
189
+ return (_jsxs("main", { className: "auth-settings user-management", children: [_jsx("h1", { children: "User management" }), _jsx("p", { children: "Manage roles and access for provisioned accounts." }), error && (_jsx("p", { className: "auth-error", role: "alert", children: error })), _jsxs("section", { className: "auth-user-section", children: [_jsx("div", { className: "user-list-header", children: _jsxs("h2", { children: ["Accounts", ' ', _jsxs("span", { className: "account-scope", children: [total.toLocaleString(), " users"] })] }) }), loading ? (_jsx("p", { role: "status", children: "Loading users\u2026" })) : !users.length ? (_jsx("p", { children: "No users yet" })) : (_jsx("div", { className: "auth-table-scroll", children: _jsxs("table", { children: [_jsx("thead", { children: _jsxs("tr", { children: [_jsx("th", { children: "Email" }), _jsx("th", { children: "Role" }), _jsx("th", { children: "Status" }), _jsx("th", { children: "Actions" })] }) }), _jsx("tbody", { children: users.map((user) => (_jsx(UserRow, { user: user, self: currentUserId === user.id, busy: busy, roles: roles ?? defaultRoles, onEdit: (changes) => action(async () => {
190
190
  await request(`/api/admin/users/${user.id}`, 'PATCH', changes);
191
191
  }) }, user.id))) })] }) })), _jsxs("div", { className: "user-pagination", children: [_jsx("button", { className: "button small", disabled: !page || busy, onClick: () => setPage((p) => p - 1), children: "Previous page" }), _jsxs("span", { children: ["Page ", page + 1] }), _jsx("button", { className: "button small", disabled: (page + 1) * 50 >= total || busy, onClick: () => setPage((p) => p + 1), children: "Next page" })] })] }), roles && _jsx(RoleManager, { roles: roles, reload: reloadRoles, request: request, dataScope: roleDataScope })] }));
192
192
  }
193
193
  function UserRow({ user, self, busy, roles, onEdit, }) {
194
- const [name, setName] = useState(user.display_name);
195
- useEffect(() => setName(user.display_name), [user.display_name]);
196
- return (_jsxs("tr", { children: [_jsxs("td", { children: [user.username, self && ' (you)'] }), _jsx("td", { children: _jsxs("div", { className: "user-name-editor", children: [_jsx("input", { "aria-label": `${user.username}'s name`, value: name, onChange: (e) => setName(e.target.value) }), _jsx("button", { className: "button small", disabled: busy || !name.trim() || name === user.display_name, onClick: () => void onEdit({ display_name: name }), children: "Save name" })] }) }), _jsx("td", { children: _jsx(Select, { "aria-label": `${user.username}'s role`, disabled: busy || (user.role === 'admin' && !self), value: user.role, onChange: (e) => void onEdit({ role: e.target.value }), children: roles.map((role) => _jsx("option", { value: role.id, children: role.name }, role.id)) }) }), _jsx("td", { children: user.status === 'active' ? 'Enabled' : 'Disabled' }), _jsx("td", { children: _jsx("div", { className: "action-row user-actions", children: _jsx("button", { className: "button small", disabled: busy, onClick: () => void onEdit({ status: user.status === 'active' ? 'disabled' : 'active' }), children: user.status === 'active' ? 'Disable' : 'Enable' }) }) })] }));
194
+ return (_jsxs("tr", { children: [_jsxs("td", { children: [user.email, self && ' (you)'] }), _jsx("td", { children: _jsx(Select, { "aria-label": `${user.email}'s role`, disabled: busy || (user.role === 'admin' && !self), value: user.role, onChange: (e) => void onEdit({ role: e.target.value }), children: roles.map((role) => _jsx("option", { value: role.id, children: role.name }, role.id)) }) }), _jsx("td", { children: user.status === 'active' ? 'Enabled' : 'Disabled' }), _jsx("td", { children: _jsx("div", { className: "action-row user-actions", children: _jsx("button", { className: "button small", disabled: busy, onClick: () => void onEdit({ status: user.status === 'active' ? 'disabled' : 'active' }), children: user.status === 'active' ? 'Disable' : 'Enable' }) }) })] }));
197
195
  }
@@ -36,9 +36,6 @@
36
36
  sidebar spans the full viewport instead of reserving a 46px bar. */
37
37
  .private-application .sidebar { position: sticky; top: 0; height: 100dvh; grid-row: 1; }
38
38
 
39
- .user-name-editor { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
40
- .user-name-editor input { flex: 1 1 130px; }
41
- .auth-settings .user-name-editor input { margin: 0; }
42
39
  .user-actions { min-width: 168px; white-space: normal; }
43
40
  .auth-settings .ui-select { width: 100%; min-width: 120px; }
44
41
  .auth-settings .ui-select-trigger { min-height: 38px; }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@field-studio/sdk",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "Field Studio clients for browsers and Node.js, with React integration and components",
5
5
  "license": "MIT",
6
6
  "repository": {