@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.
- package/dist/src/hooks.d.ts +20 -8
- package/dist/src/hooks.js +14 -10
- package/dist/src/index.d.ts +1 -1
- package/dist/src/members.d.ts +3 -0
- package/dist/src/rpc.js +4 -3
- package/package.json +1 -1
package/dist/src/hooks.d.ts
CHANGED
|
@@ -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.
|
|
136
|
-
*
|
|
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
|
|
141
|
-
*
|
|
142
|
-
*
|
|
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) => ({
|
|
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.
|
|
191
|
-
*
|
|
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
|
|
196
|
-
*
|
|
197
|
-
*
|
|
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) => ({
|
|
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
|
}
|
package/dist/src/index.d.ts
CHANGED
|
@@ -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";
|
package/dist/src/members.d.ts
CHANGED
|
@@ -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
|
|
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 ?? [] };
|