@lotics/app-sdk 0.20.0 → 0.21.0

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.
@@ -130,21 +130,33 @@ interface MembersState {
130
130
  loading: boolean;
131
131
  error: string | null;
132
132
  }
133
+ /** Options for `useMembers`. */
134
+ export interface MembersOptions {
135
+ /**
136
+ * Restrict to one member group (a group ID). The group must be declared on a
137
+ * `member` workflow input's `group` — listing an undeclared group errors. Omit
138
+ * to list the whole org roster.
139
+ */
140
+ group?: string;
141
+ }
133
142
  /**
134
143
  * List the members of the app's organization — the candidate set for an
135
- * "assign to a member" picker. Resolves through the host (member-only; an
136
- * anonymous public visitor gets an error). Names may be empty for members
144
+ * "assign to a member" picker. Each member is `{ id, name, email, image }`
145
+ * (`image` = avatar URL, may be null). Resolves through the host (member-only;
146
+ * an anonymous public visitor gets an error). Names may be empty for members
137
147
  * without a display name set — fall back to `email`.
138
148
  *
139
149
  * Gated: the app must DECLARE that it works with members — it needs a workflow
140
- * whose manifest declares a `member`-typed input (i.e. it assigns members).
141
- * Without one the host returns an error, so member access stays a declared,
142
- * auditable surface rather than something any app can read ambiently.
150
+ * whose manifest declares a `member`-typed input. Passing `{ group }` restricts
151
+ * to that group, and is only honored if some member input declares that
152
+ * `group` so an app can only list (and assign into) groups it declares.
143
153
  *
144
154
  * ```tsx
145
- * const { members } = useMembers();
146
- * // <Picker options={members.map((m) => ({ value: m.id, label: m.name || m.email || m.id }))} />
155
+ * const { members } = useMembers({ group: "grp_..." });
156
+ * // <Picker options={members.map((m) => ({
157
+ * // value: m.id, label: m.name || m.email || m.id, image: m.image,
158
+ * // }))} />
147
159
  * ```
148
160
  */
149
- export declare function useMembers(): MembersState;
161
+ export declare function useMembers(opts?: MembersOptions): MembersState;
150
162
  export {};
package/dist/src/hooks.js CHANGED
@@ -187,21 +187,25 @@ export function useFileUpload() {
187
187
  }
188
188
  /**
189
189
  * List the members of the app's organization — the candidate set for an
190
- * "assign to a member" picker. Resolves through the host (member-only; an
191
- * anonymous public visitor gets an error). Names may be empty for members
190
+ * "assign to a member" picker. Each member is `{ id, name, email, image }`
191
+ * (`image` = avatar URL, may be null). Resolves through the host (member-only;
192
+ * an anonymous public visitor gets an error). Names may be empty for members
192
193
  * without a display name set — fall back to `email`.
193
194
  *
194
195
  * Gated: the app must DECLARE that it works with members — it needs a workflow
195
- * whose manifest declares a `member`-typed input (i.e. it assigns members).
196
- * Without one the host returns an error, so member access stays a declared,
197
- * auditable surface rather than something any app can read ambiently.
196
+ * whose manifest declares a `member`-typed input. Passing `{ group }` restricts
197
+ * to that group, and is only honored if some member input declares that
198
+ * `group` so an app can only list (and assign into) groups it declares.
198
199
  *
199
200
  * ```tsx
200
- * const { members } = useMembers();
201
- * // <Picker options={members.map((m) => ({ value: m.id, label: m.name || m.email || m.id }))} />
201
+ * const { members } = useMembers({ group: "grp_..." });
202
+ * // <Picker options={members.map((m) => ({
203
+ * // value: m.id, label: m.name || m.email || m.id, image: m.image,
204
+ * // }))} />
202
205
  * ```
203
206
  */
204
- export function useMembers() {
207
+ export function useMembers(opts) {
208
+ const group = opts?.group;
205
209
  const [state, setState] = useState({
206
210
  members: [],
207
211
  loading: true,
@@ -210,7 +214,7 @@ export function useMembers() {
210
214
  useEffect(() => {
211
215
  let cancelled = false;
212
216
  setState((s) => ({ ...s, loading: true, error: null }));
213
- rpc("members", {})
217
+ rpc("members", { group })
214
218
  .then((r) => {
215
219
  if (!cancelled)
216
220
  setState({ members: r.members ?? [], loading: false, error: null });
@@ -222,6 +226,6 @@ export function useMembers() {
222
226
  return () => {
223
227
  cancelled = true;
224
228
  };
225
- }, []);
229
+ }, [group]);
226
230
  return state;
227
231
  }
@@ -17,7 +17,7 @@
17
17
  export { mount } from "./mount.js";
18
18
  export type { MountOptions } from "./mount.js";
19
19
  export { useWorkflow, useQuery, useFileUpload, useMembers } from "./hooks.js";
20
- export type { UploadedFile, QueryOptions, WorkflowResult } from "./hooks.js";
20
+ export type { UploadedFile, QueryOptions, WorkflowResult, MembersOptions } from "./hooks.js";
21
21
  export { rpc } from "./rpc.js";
22
22
  export type { RpcOp } from "./rpc.js";
23
23
  export { openExternal } from "./open_external.js";
@@ -18,6 +18,9 @@ export interface ResolvedMember {
18
18
  /** Present only on authenticated responses. Omitted on public-app
19
19
  * responses (no PII exposure to anonymous visitors). */
20
20
  email?: string | null;
21
+ /** Avatar URL. Present on the `useMembers` roster (may be null when the
22
+ * member has no profile image); absent on resolved `select_member` cells. */
23
+ image?: string | null;
21
24
  }
22
25
  /**
23
26
  * Parse a `useQuery` cell value into `ResolvedMember[]`. Returns `[]` for
package/dist/src/rpc.js CHANGED
@@ -218,16 +218,17 @@ function rpcStandalone(op, payload) {
218
218
  case "upload":
219
219
  return standaloneUpload(payload.file);
220
220
  case "members":
221
- return standaloneMembers();
221
+ return standaloneMembers(payload);
222
222
  case "context":
223
223
  return standaloneContext();
224
224
  case "openExternal":
225
225
  return standaloneOpenExternal(payload);
226
226
  }
227
227
  }
228
- async function standaloneMembers() {
228
+ async function standaloneMembers(p) {
229
229
  const { app_id } = await boot();
230
- const r = (await apiCall("GET", `/v1/apps/${app_id}/members`, undefined, {
230
+ const qs = p.group ? `?group_id=${encodeURIComponent(p.group)}` : "";
231
+ const r = (await apiCall("GET", `/v1/apps/${app_id}/members${qs}`, undefined, {
231
232
  appId: app_id,
232
233
  }));
233
234
  return { members: r.members ?? [] };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lotics/app-sdk",
3
- "version": "0.20.0",
3
+ "version": "0.21.0",
4
4
  "description": "Runtime SDK for Lotics custom-code apps — typed hooks, postMessage bridge, mount entry point",
5
5
  "type": "module",
6
6
  "exports": {