@immediately-run/sdk 0.68.2 → 0.70.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.
@@ -34,6 +34,20 @@ interface GrantRecord {
34
34
  mode: 'ro' | 'rw';
35
35
  name?: string;
36
36
  }
37
+ /** A pending invitation to a space (pull-based sharing, FILE_SHARING_SPEC §6.4). It grants NO access until accepted — the recipient accepts it from their inbox ({@link listMyInvites} → {@link acceptInvite}), materializing membership. The display fields (`name`/`login`/`avatarUrl`) are untrusted for rendering. */
38
+ interface Invite {
39
+ spaceId: string;
40
+ /** The invitee's uid — carried so the owner's pending list can {@link revokeInvite}(spaceId, uid). */
41
+ uid: string;
42
+ role: Role;
43
+ owner: string;
44
+ name?: string;
45
+ invitedBy: string;
46
+ /** epoch ms (server-stamped); absent until the write settles. */
47
+ invitedAt?: number;
48
+ login?: string;
49
+ avatarUrl?: string;
50
+ }
37
51
  type ListSpacesError = 'auth-required' | 'cancelled' | 'forbidden' | 'not-found' | 'unsupported-scheme' | 'unknown';
38
52
  /**
39
53
  * List spaces you can access — all of them, or just those bound to this app.
@@ -41,9 +55,19 @@ type ListSpacesError = 'auth-required' | 'cancelled' | 'forbidden' | 'not-found'
41
55
  * Capability: `spaces:app`. Catalog name: `spaces:list`.
42
56
  * @throws `Error & { code: ListSpacesError }` on host refusal.
43
57
  */
44
- declare const listSpaces: (opts?: {
58
+ declare const listSpaces: ((opts?: {
45
59
  app?: boolean;
46
- }) => Promise<SpaceInfo[]>;
60
+ } | undefined) => Promise<SpaceInfo[]>) & {
61
+ try: (opts?: {
62
+ app?: boolean;
63
+ } | undefined) => Promise<{
64
+ ok: true;
65
+ value: SpaceInfo[];
66
+ } | {
67
+ ok: false;
68
+ code: ListSpacesError;
69
+ }>;
70
+ };
47
71
  type ListAllSpacesError = 'auth-required' | 'cancelled' | 'forbidden' | 'not-found' | 'unsupported-scheme' | 'unknown';
48
72
  /**
49
73
  * Enumerate ALL the user's spaces (not just this app's).
@@ -51,7 +75,15 @@ type ListAllSpacesError = 'auth-required' | 'cancelled' | 'forbidden' | 'not-fou
51
75
  * Capability: `spaces:user`. Catalog name: `spaces:listAll`.
52
76
  * @throws `Error & { code: ListAllSpacesError }` on host refusal.
53
77
  */
54
- declare const listAllSpaces: () => Promise<SpaceInfo[]>;
78
+ declare const listAllSpaces: (() => Promise<SpaceInfo[]>) & {
79
+ try: () => Promise<{
80
+ ok: true;
81
+ value: SpaceInfo[];
82
+ } | {
83
+ ok: false;
84
+ code: ListAllSpacesError;
85
+ }>;
86
+ };
55
87
  type GetSpaceMembersError = 'auth-required' | 'cancelled' | 'forbidden' | 'not-found' | 'unsupported-scheme' | 'unknown';
56
88
  /**
57
89
  * Read a space's members one-shot.
@@ -59,8 +91,16 @@ type GetSpaceMembersError = 'auth-required' | 'cancelled' | 'forbidden' | 'not-f
59
91
  * Capability: `spaces:admin`. Catalog name: `spaces:members`.
60
92
  * @throws `Error & { code: GetSpaceMembersError }` on host refusal.
61
93
  */
62
- declare const getSpaceMembers: (spaceId: string) => Promise<Member[]>;
63
- type InviteToSpaceError = 'auth-required' | 'cancelled' | 'forbidden' | 'not-found' | 'unsupported-scheme' | 'unknown';
94
+ declare const getSpaceMembers: ((args_0: string) => Promise<Member[]>) & {
95
+ try: (args_0: string) => Promise<{
96
+ ok: true;
97
+ value: Member[];
98
+ } | {
99
+ ok: false;
100
+ code: GetSpaceMembersError;
101
+ }>;
102
+ };
103
+ type InviteToSpaceError = 'auth-required' | 'cancelled' | 'forbidden' | 'not-found' | 'unsupported-scheme' | 'unknown' | 'quota-exceeded';
64
104
  /**
65
105
  * Invite a user (by provider handle) to a space at a role. The host resolves
66
106
  * the handle, so the app never sees other users' uids except the one it
@@ -71,7 +111,15 @@ type InviteToSpaceError = 'auth-required' | 'cancelled' | 'forbidden' | 'not-fou
71
111
  * Capability: `spaces:admin`. Catalog name: `spaces:invite`.
72
112
  * @throws `Error & { code: InviteToSpaceError }` on host refusal.
73
113
  */
74
- declare const inviteToSpace: (spaceId: string, login: string, role: Role) => Promise<void>;
114
+ declare const inviteToSpace: ((args_0: string, args_1: string, args_2: Role) => Promise<void>) & {
115
+ try: (args_0: string, args_1: string, args_2: Role) => Promise<{
116
+ ok: true;
117
+ value: void;
118
+ } | {
119
+ ok: false;
120
+ code: InviteToSpaceError;
121
+ }>;
122
+ };
75
123
  type UnshareSpaceError = 'auth-required' | 'cancelled' | 'forbidden' | 'not-found' | 'unsupported-scheme' | 'unknown' | 'conflict';
76
124
  /**
77
125
  * Remove a member from a space. Refused if it would orphan the space
@@ -80,7 +128,15 @@ type UnshareSpaceError = 'auth-required' | 'cancelled' | 'forbidden' | 'not-foun
80
128
  * Capability: `spaces:admin`. Catalog name: `spaces:unshare`.
81
129
  * @throws `Error & { code: UnshareSpaceError }` on host refusal.
82
130
  */
83
- declare const unshareSpace: (spaceId: string, uid: string) => Promise<void>;
131
+ declare const unshareSpace: ((args_0: string, args_1: string) => Promise<void>) & {
132
+ try: (args_0: string, args_1: string) => Promise<{
133
+ ok: true;
134
+ value: void;
135
+ } | {
136
+ ok: false;
137
+ code: UnshareSpaceError;
138
+ }>;
139
+ };
84
140
  type SetSpaceRoleError = 'auth-required' | 'cancelled' | 'forbidden' | 'not-found' | 'unsupported-scheme' | 'unknown' | 'conflict';
85
141
  /**
86
142
  * Change a member's role. Refused if it would drop the sole owner
@@ -89,7 +145,15 @@ type SetSpaceRoleError = 'auth-required' | 'cancelled' | 'forbidden' | 'not-foun
89
145
  * Capability: `spaces:admin`. Catalog name: `spaces:setRole`.
90
146
  * @throws `Error & { code: SetSpaceRoleError }` on host refusal.
91
147
  */
92
- declare const setSpaceRole: (spaceId: string, uid: string, role: Role) => Promise<void>;
148
+ declare const setSpaceRole: ((args_0: string, args_1: string, args_2: Role) => Promise<void>) & {
149
+ try: (args_0: string, args_1: string, args_2: Role) => Promise<{
150
+ ok: true;
151
+ value: void;
152
+ } | {
153
+ ok: false;
154
+ code: SetSpaceRoleError;
155
+ }>;
156
+ };
93
157
  type LookupUserError = 'auth-required' | 'cancelled' | 'forbidden' | 'not-found' | 'unsupported-scheme' | 'unknown';
94
158
  /**
95
159
  * Resolve a provider handle to a principal (for the invite flow).
@@ -98,7 +162,15 @@ type LookupUserError = 'auth-required' | 'cancelled' | 'forbidden' | 'not-found'
98
162
  * Capability: `spaces:admin`. Catalog name: `spaces:lookupUser`.
99
163
  * @throws `Error & { code: LookupUserError }` on host refusal.
100
164
  */
101
- declare const lookupUser: (login: string) => Promise<ResolvedUser>;
165
+ declare const lookupUser: ((args_0: string) => Promise<ResolvedUser>) & {
166
+ try: (args_0: string) => Promise<{
167
+ ok: true;
168
+ value: ResolvedUser;
169
+ } | {
170
+ ok: false;
171
+ code: LookupUserError;
172
+ }>;
173
+ };
102
174
  type ListGrantsError = 'auth-required' | 'cancelled' | 'forbidden' | 'not-found' | 'unsupported-scheme' | 'unknown';
103
175
  /**
104
176
  * Enumerate every (app, mount) grant the user holds — the audit view
@@ -107,7 +179,15 @@ type ListGrantsError = 'auth-required' | 'cancelled' | 'forbidden' | 'not-found'
107
179
  * Capability: `spaces:admin`. Catalog name: `spaces:grants`.
108
180
  * @throws `Error & { code: ListGrantsError }` on host refusal.
109
181
  */
110
- declare const listGrants: () => Promise<GrantRecord[]>;
182
+ declare const listGrants: (() => Promise<GrantRecord[]>) & {
183
+ try: () => Promise<{
184
+ ok: true;
185
+ value: GrantRecord[];
186
+ } | {
187
+ ok: false;
188
+ code: ListGrantsError;
189
+ }>;
190
+ };
111
191
  type RevokeGrantError = 'auth-required' | 'cancelled' | 'forbidden' | 'not-found' | 'unsupported-scheme' | 'unknown';
112
192
  /**
113
193
  * Revoke one app's grant on a space — durable (the app can't re-mount) plus
@@ -116,6 +196,98 @@ type RevokeGrantError = 'auth-required' | 'cancelled' | 'forbidden' | 'not-found
116
196
  * Capability: `spaces:admin`. Catalog name: `spaces:revokeGrant`.
117
197
  * @throws `Error & { code: RevokeGrantError }` on host refusal.
118
198
  */
119
- declare const revokeGrant: (appKey: string, spaceId: string) => Promise<void>;
199
+ declare const revokeGrant: ((args_0: string, args_1: string) => Promise<void>) & {
200
+ try: (args_0: string, args_1: string) => Promise<{
201
+ ok: true;
202
+ value: void;
203
+ } | {
204
+ ok: false;
205
+ code: RevokeGrantError;
206
+ }>;
207
+ };
208
+ type ListPendingInvitesError = 'auth-required' | 'cancelled' | 'forbidden' | 'not-found' | 'unsupported-scheme' | 'unknown';
209
+ /**
210
+ * The owner's outstanding invitations for a space.
211
+ *
212
+ * Capability: `spaces:admin`. Catalog name: `spaces:pendingInvites`.
213
+ * @throws `Error & { code: ListPendingInvitesError }` on host refusal.
214
+ */
215
+ declare const listPendingInvites: ((args_0: string) => Promise<Invite[]>) & {
216
+ try: (args_0: string) => Promise<{
217
+ ok: true;
218
+ value: Invite[];
219
+ } | {
220
+ ok: false;
221
+ code: ListPendingInvitesError;
222
+ }>;
223
+ };
224
+ type RevokeInviteError = 'auth-required' | 'cancelled' | 'forbidden' | 'not-found' | 'unsupported-scheme' | 'unknown';
225
+ /**
226
+ * Withdraw a pending invitation (distinct from {@link unshareSpace}, which
227
+ * removes an ACCEPTED member).
228
+ *
229
+ * Capability: `spaces:admin`. Catalog name: `spaces:revokeInvite`.
230
+ * @throws `Error & { code: RevokeInviteError }` on host refusal.
231
+ */
232
+ declare const revokeInvite: ((args_0: string, args_1: string) => Promise<void>) & {
233
+ try: (args_0: string, args_1: string) => Promise<{
234
+ ok: true;
235
+ value: void;
236
+ } | {
237
+ ok: false;
238
+ code: RevokeInviteError;
239
+ }>;
240
+ };
241
+ type ListMyInvitesError = 'auth-required' | 'cancelled' | 'forbidden' | 'not-found' | 'unsupported-scheme' | 'unknown';
242
+ /**
243
+ * The caller's OWN invitation inbox.
244
+ *
245
+ * Capability: `spaces:user`. Catalog name: `spaces:listInvites`.
246
+ * @throws `Error & { code: ListMyInvitesError }` on host refusal.
247
+ */
248
+ declare const listMyInvites: (() => Promise<Invite[]>) & {
249
+ try: () => Promise<{
250
+ ok: true;
251
+ value: Invite[];
252
+ } | {
253
+ ok: false;
254
+ code: ListMyInvitesError;
255
+ }>;
256
+ };
257
+ type AcceptInviteError = 'auth-required' | 'cancelled' | 'forbidden' | 'not-found' | 'unsupported-scheme' | 'unknown';
258
+ /**
259
+ * Accept an invitation: materialize your membership at the invited role and
260
+ * clear the invite. An invitation the caller doesn't hold rejects with
261
+ * `forbidden` (indistinguishable from a nonexistent space; no existence
262
+ * oracle).
263
+ *
264
+ * Capability: `spaces:user`. Catalog name: `spaces:acceptInvite`.
265
+ * @throws `Error & { code: AcceptInviteError }` on host refusal.
266
+ */
267
+ declare const acceptInvite: ((args_0: string) => Promise<void>) & {
268
+ try: (args_0: string) => Promise<{
269
+ ok: true;
270
+ value: void;
271
+ } | {
272
+ ok: false;
273
+ code: AcceptInviteError;
274
+ }>;
275
+ };
276
+ type DeclineInviteError = 'auth-required' | 'cancelled' | 'forbidden' | 'not-found' | 'unsupported-scheme' | 'unknown';
277
+ /**
278
+ * Decline (dismiss) an invitation from your inbox; writes no membership.
279
+ *
280
+ * Capability: `spaces:user`. Catalog name: `spaces:declineInvite`.
281
+ * @throws `Error & { code: DeclineInviteError }` on host refusal.
282
+ */
283
+ declare const declineInvite: ((args_0: string) => Promise<void>) & {
284
+ try: (args_0: string) => Promise<{
285
+ ok: true;
286
+ value: void;
287
+ } | {
288
+ ok: false;
289
+ code: DeclineInviteError;
290
+ }>;
291
+ };
120
292
 
121
- export { type GetSpaceMembersError, type GrantRecord, type InviteToSpaceError, type ListAllSpacesError, type ListGrantsError, type ListSpacesError, type LookupUserError, type Member, type ResolvedUser, type RevokeGrantError, type Role, type SetSpaceRoleError, type SpaceInfo, type UnshareSpaceError, getSpaceMembers, inviteToSpace, listAllSpaces, listGrants, listSpaces, lookupUser, revokeGrant, setSpaceRole, unshareSpace };
293
+ export { type AcceptInviteError, type DeclineInviteError, type GetSpaceMembersError, type GrantRecord, type Invite, type InviteToSpaceError, type ListAllSpacesError, type ListGrantsError, type ListMyInvitesError, type ListPendingInvitesError, type ListSpacesError, type LookupUserError, type Member, type ResolvedUser, type RevokeGrantError, type RevokeInviteError, type Role, type SetSpaceRoleError, type SpaceInfo, type UnshareSpaceError, acceptInvite, declineInvite, getSpaceMembers, inviteToSpace, listAllSpaces, listGrants, listMyInvites, listPendingInvites, listSpaces, lookupUser, revokeGrant, revokeInvite, setSpaceRole, unshareSpace };
@@ -34,6 +34,20 @@ interface GrantRecord {
34
34
  mode: 'ro' | 'rw';
35
35
  name?: string;
36
36
  }
37
+ /** A pending invitation to a space (pull-based sharing, FILE_SHARING_SPEC §6.4). It grants NO access until accepted — the recipient accepts it from their inbox ({@link listMyInvites} → {@link acceptInvite}), materializing membership. The display fields (`name`/`login`/`avatarUrl`) are untrusted for rendering. */
38
+ interface Invite {
39
+ spaceId: string;
40
+ /** The invitee's uid — carried so the owner's pending list can {@link revokeInvite}(spaceId, uid). */
41
+ uid: string;
42
+ role: Role;
43
+ owner: string;
44
+ name?: string;
45
+ invitedBy: string;
46
+ /** epoch ms (server-stamped); absent until the write settles. */
47
+ invitedAt?: number;
48
+ login?: string;
49
+ avatarUrl?: string;
50
+ }
37
51
  type ListSpacesError = 'auth-required' | 'cancelled' | 'forbidden' | 'not-found' | 'unsupported-scheme' | 'unknown';
38
52
  /**
39
53
  * List spaces you can access — all of them, or just those bound to this app.
@@ -41,9 +55,19 @@ type ListSpacesError = 'auth-required' | 'cancelled' | 'forbidden' | 'not-found'
41
55
  * Capability: `spaces:app`. Catalog name: `spaces:list`.
42
56
  * @throws `Error & { code: ListSpacesError }` on host refusal.
43
57
  */
44
- declare const listSpaces: (opts?: {
58
+ declare const listSpaces: ((opts?: {
45
59
  app?: boolean;
46
- }) => Promise<SpaceInfo[]>;
60
+ } | undefined) => Promise<SpaceInfo[]>) & {
61
+ try: (opts?: {
62
+ app?: boolean;
63
+ } | undefined) => Promise<{
64
+ ok: true;
65
+ value: SpaceInfo[];
66
+ } | {
67
+ ok: false;
68
+ code: ListSpacesError;
69
+ }>;
70
+ };
47
71
  type ListAllSpacesError = 'auth-required' | 'cancelled' | 'forbidden' | 'not-found' | 'unsupported-scheme' | 'unknown';
48
72
  /**
49
73
  * Enumerate ALL the user's spaces (not just this app's).
@@ -51,7 +75,15 @@ type ListAllSpacesError = 'auth-required' | 'cancelled' | 'forbidden' | 'not-fou
51
75
  * Capability: `spaces:user`. Catalog name: `spaces:listAll`.
52
76
  * @throws `Error & { code: ListAllSpacesError }` on host refusal.
53
77
  */
54
- declare const listAllSpaces: () => Promise<SpaceInfo[]>;
78
+ declare const listAllSpaces: (() => Promise<SpaceInfo[]>) & {
79
+ try: () => Promise<{
80
+ ok: true;
81
+ value: SpaceInfo[];
82
+ } | {
83
+ ok: false;
84
+ code: ListAllSpacesError;
85
+ }>;
86
+ };
55
87
  type GetSpaceMembersError = 'auth-required' | 'cancelled' | 'forbidden' | 'not-found' | 'unsupported-scheme' | 'unknown';
56
88
  /**
57
89
  * Read a space's members one-shot.
@@ -59,8 +91,16 @@ type GetSpaceMembersError = 'auth-required' | 'cancelled' | 'forbidden' | 'not-f
59
91
  * Capability: `spaces:admin`. Catalog name: `spaces:members`.
60
92
  * @throws `Error & { code: GetSpaceMembersError }` on host refusal.
61
93
  */
62
- declare const getSpaceMembers: (spaceId: string) => Promise<Member[]>;
63
- type InviteToSpaceError = 'auth-required' | 'cancelled' | 'forbidden' | 'not-found' | 'unsupported-scheme' | 'unknown';
94
+ declare const getSpaceMembers: ((args_0: string) => Promise<Member[]>) & {
95
+ try: (args_0: string) => Promise<{
96
+ ok: true;
97
+ value: Member[];
98
+ } | {
99
+ ok: false;
100
+ code: GetSpaceMembersError;
101
+ }>;
102
+ };
103
+ type InviteToSpaceError = 'auth-required' | 'cancelled' | 'forbidden' | 'not-found' | 'unsupported-scheme' | 'unknown' | 'quota-exceeded';
64
104
  /**
65
105
  * Invite a user (by provider handle) to a space at a role. The host resolves
66
106
  * the handle, so the app never sees other users' uids except the one it
@@ -71,7 +111,15 @@ type InviteToSpaceError = 'auth-required' | 'cancelled' | 'forbidden' | 'not-fou
71
111
  * Capability: `spaces:admin`. Catalog name: `spaces:invite`.
72
112
  * @throws `Error & { code: InviteToSpaceError }` on host refusal.
73
113
  */
74
- declare const inviteToSpace: (spaceId: string, login: string, role: Role) => Promise<void>;
114
+ declare const inviteToSpace: ((args_0: string, args_1: string, args_2: Role) => Promise<void>) & {
115
+ try: (args_0: string, args_1: string, args_2: Role) => Promise<{
116
+ ok: true;
117
+ value: void;
118
+ } | {
119
+ ok: false;
120
+ code: InviteToSpaceError;
121
+ }>;
122
+ };
75
123
  type UnshareSpaceError = 'auth-required' | 'cancelled' | 'forbidden' | 'not-found' | 'unsupported-scheme' | 'unknown' | 'conflict';
76
124
  /**
77
125
  * Remove a member from a space. Refused if it would orphan the space
@@ -80,7 +128,15 @@ type UnshareSpaceError = 'auth-required' | 'cancelled' | 'forbidden' | 'not-foun
80
128
  * Capability: `spaces:admin`. Catalog name: `spaces:unshare`.
81
129
  * @throws `Error & { code: UnshareSpaceError }` on host refusal.
82
130
  */
83
- declare const unshareSpace: (spaceId: string, uid: string) => Promise<void>;
131
+ declare const unshareSpace: ((args_0: string, args_1: string) => Promise<void>) & {
132
+ try: (args_0: string, args_1: string) => Promise<{
133
+ ok: true;
134
+ value: void;
135
+ } | {
136
+ ok: false;
137
+ code: UnshareSpaceError;
138
+ }>;
139
+ };
84
140
  type SetSpaceRoleError = 'auth-required' | 'cancelled' | 'forbidden' | 'not-found' | 'unsupported-scheme' | 'unknown' | 'conflict';
85
141
  /**
86
142
  * Change a member's role. Refused if it would drop the sole owner
@@ -89,7 +145,15 @@ type SetSpaceRoleError = 'auth-required' | 'cancelled' | 'forbidden' | 'not-foun
89
145
  * Capability: `spaces:admin`. Catalog name: `spaces:setRole`.
90
146
  * @throws `Error & { code: SetSpaceRoleError }` on host refusal.
91
147
  */
92
- declare const setSpaceRole: (spaceId: string, uid: string, role: Role) => Promise<void>;
148
+ declare const setSpaceRole: ((args_0: string, args_1: string, args_2: Role) => Promise<void>) & {
149
+ try: (args_0: string, args_1: string, args_2: Role) => Promise<{
150
+ ok: true;
151
+ value: void;
152
+ } | {
153
+ ok: false;
154
+ code: SetSpaceRoleError;
155
+ }>;
156
+ };
93
157
  type LookupUserError = 'auth-required' | 'cancelled' | 'forbidden' | 'not-found' | 'unsupported-scheme' | 'unknown';
94
158
  /**
95
159
  * Resolve a provider handle to a principal (for the invite flow).
@@ -98,7 +162,15 @@ type LookupUserError = 'auth-required' | 'cancelled' | 'forbidden' | 'not-found'
98
162
  * Capability: `spaces:admin`. Catalog name: `spaces:lookupUser`.
99
163
  * @throws `Error & { code: LookupUserError }` on host refusal.
100
164
  */
101
- declare const lookupUser: (login: string) => Promise<ResolvedUser>;
165
+ declare const lookupUser: ((args_0: string) => Promise<ResolvedUser>) & {
166
+ try: (args_0: string) => Promise<{
167
+ ok: true;
168
+ value: ResolvedUser;
169
+ } | {
170
+ ok: false;
171
+ code: LookupUserError;
172
+ }>;
173
+ };
102
174
  type ListGrantsError = 'auth-required' | 'cancelled' | 'forbidden' | 'not-found' | 'unsupported-scheme' | 'unknown';
103
175
  /**
104
176
  * Enumerate every (app, mount) grant the user holds — the audit view
@@ -107,7 +179,15 @@ type ListGrantsError = 'auth-required' | 'cancelled' | 'forbidden' | 'not-found'
107
179
  * Capability: `spaces:admin`. Catalog name: `spaces:grants`.
108
180
  * @throws `Error & { code: ListGrantsError }` on host refusal.
109
181
  */
110
- declare const listGrants: () => Promise<GrantRecord[]>;
182
+ declare const listGrants: (() => Promise<GrantRecord[]>) & {
183
+ try: () => Promise<{
184
+ ok: true;
185
+ value: GrantRecord[];
186
+ } | {
187
+ ok: false;
188
+ code: ListGrantsError;
189
+ }>;
190
+ };
111
191
  type RevokeGrantError = 'auth-required' | 'cancelled' | 'forbidden' | 'not-found' | 'unsupported-scheme' | 'unknown';
112
192
  /**
113
193
  * Revoke one app's grant on a space — durable (the app can't re-mount) plus
@@ -116,6 +196,98 @@ type RevokeGrantError = 'auth-required' | 'cancelled' | 'forbidden' | 'not-found
116
196
  * Capability: `spaces:admin`. Catalog name: `spaces:revokeGrant`.
117
197
  * @throws `Error & { code: RevokeGrantError }` on host refusal.
118
198
  */
119
- declare const revokeGrant: (appKey: string, spaceId: string) => Promise<void>;
199
+ declare const revokeGrant: ((args_0: string, args_1: string) => Promise<void>) & {
200
+ try: (args_0: string, args_1: string) => Promise<{
201
+ ok: true;
202
+ value: void;
203
+ } | {
204
+ ok: false;
205
+ code: RevokeGrantError;
206
+ }>;
207
+ };
208
+ type ListPendingInvitesError = 'auth-required' | 'cancelled' | 'forbidden' | 'not-found' | 'unsupported-scheme' | 'unknown';
209
+ /**
210
+ * The owner's outstanding invitations for a space.
211
+ *
212
+ * Capability: `spaces:admin`. Catalog name: `spaces:pendingInvites`.
213
+ * @throws `Error & { code: ListPendingInvitesError }` on host refusal.
214
+ */
215
+ declare const listPendingInvites: ((args_0: string) => Promise<Invite[]>) & {
216
+ try: (args_0: string) => Promise<{
217
+ ok: true;
218
+ value: Invite[];
219
+ } | {
220
+ ok: false;
221
+ code: ListPendingInvitesError;
222
+ }>;
223
+ };
224
+ type RevokeInviteError = 'auth-required' | 'cancelled' | 'forbidden' | 'not-found' | 'unsupported-scheme' | 'unknown';
225
+ /**
226
+ * Withdraw a pending invitation (distinct from {@link unshareSpace}, which
227
+ * removes an ACCEPTED member).
228
+ *
229
+ * Capability: `spaces:admin`. Catalog name: `spaces:revokeInvite`.
230
+ * @throws `Error & { code: RevokeInviteError }` on host refusal.
231
+ */
232
+ declare const revokeInvite: ((args_0: string, args_1: string) => Promise<void>) & {
233
+ try: (args_0: string, args_1: string) => Promise<{
234
+ ok: true;
235
+ value: void;
236
+ } | {
237
+ ok: false;
238
+ code: RevokeInviteError;
239
+ }>;
240
+ };
241
+ type ListMyInvitesError = 'auth-required' | 'cancelled' | 'forbidden' | 'not-found' | 'unsupported-scheme' | 'unknown';
242
+ /**
243
+ * The caller's OWN invitation inbox.
244
+ *
245
+ * Capability: `spaces:user`. Catalog name: `spaces:listInvites`.
246
+ * @throws `Error & { code: ListMyInvitesError }` on host refusal.
247
+ */
248
+ declare const listMyInvites: (() => Promise<Invite[]>) & {
249
+ try: () => Promise<{
250
+ ok: true;
251
+ value: Invite[];
252
+ } | {
253
+ ok: false;
254
+ code: ListMyInvitesError;
255
+ }>;
256
+ };
257
+ type AcceptInviteError = 'auth-required' | 'cancelled' | 'forbidden' | 'not-found' | 'unsupported-scheme' | 'unknown';
258
+ /**
259
+ * Accept an invitation: materialize your membership at the invited role and
260
+ * clear the invite. An invitation the caller doesn't hold rejects with
261
+ * `forbidden` (indistinguishable from a nonexistent space; no existence
262
+ * oracle).
263
+ *
264
+ * Capability: `spaces:user`. Catalog name: `spaces:acceptInvite`.
265
+ * @throws `Error & { code: AcceptInviteError }` on host refusal.
266
+ */
267
+ declare const acceptInvite: ((args_0: string) => Promise<void>) & {
268
+ try: (args_0: string) => Promise<{
269
+ ok: true;
270
+ value: void;
271
+ } | {
272
+ ok: false;
273
+ code: AcceptInviteError;
274
+ }>;
275
+ };
276
+ type DeclineInviteError = 'auth-required' | 'cancelled' | 'forbidden' | 'not-found' | 'unsupported-scheme' | 'unknown';
277
+ /**
278
+ * Decline (dismiss) an invitation from your inbox; writes no membership.
279
+ *
280
+ * Capability: `spaces:user`. Catalog name: `spaces:declineInvite`.
281
+ * @throws `Error & { code: DeclineInviteError }` on host refusal.
282
+ */
283
+ declare const declineInvite: ((args_0: string) => Promise<void>) & {
284
+ try: (args_0: string) => Promise<{
285
+ ok: true;
286
+ value: void;
287
+ } | {
288
+ ok: false;
289
+ code: DeclineInviteError;
290
+ }>;
291
+ };
120
292
 
121
- export { type GetSpaceMembersError, type GrantRecord, type InviteToSpaceError, type ListAllSpacesError, type ListGrantsError, type ListSpacesError, type LookupUserError, type Member, type ResolvedUser, type RevokeGrantError, type Role, type SetSpaceRoleError, type SpaceInfo, type UnshareSpaceError, getSpaceMembers, inviteToSpace, listAllSpaces, listGrants, listSpaces, lookupUser, revokeGrant, setSpaceRole, unshareSpace };
293
+ export { type AcceptInviteError, type DeclineInviteError, type GetSpaceMembersError, type GrantRecord, type Invite, type InviteToSpaceError, type ListAllSpacesError, type ListGrantsError, type ListMyInvitesError, type ListPendingInvitesError, type ListSpacesError, type LookupUserError, type Member, type ResolvedUser, type RevokeGrantError, type RevokeInviteError, type Role, type SetSpaceRoleError, type SpaceInfo, type UnshareSpaceError, acceptInvite, declineInvite, getSpaceMembers, inviteToSpace, listAllSpaces, listGrants, listMyInvites, listPendingInvites, listSpaces, lookupUser, revokeGrant, revokeInvite, setSpaceRole, unshareSpace };
@@ -1,30 +1,97 @@
1
1
  import "../chunk-VHAA22YE.js";
2
2
  import { invoke } from "../catalog.js";
3
- const listSpaces = (opts = {}) => invoke("spaces:list", opts);
4
- const listAllSpaces = () => invoke("spaces:listAll", {});
5
- const getSpaceMembers = (spaceId) => invoke("spaces:members", { spaceId });
6
- const inviteToSpace = async (spaceId, login, role) => {
7
- await invoke("spaces:invite", { spaceId, login, role });
8
- };
9
- const unshareSpace = async (spaceId, uid) => {
10
- await invoke("spaces:unshare", { spaceId, uid });
11
- };
12
- const setSpaceRole = async (spaceId, uid, role) => {
13
- await invoke("spaces:setRole", { spaceId, uid, role });
14
- };
15
- const lookupUser = (login) => invoke("spaces:lookupUser", { login });
16
- const listGrants = () => invoke("spaces:grants", {});
17
- const revokeGrant = async (appKey, spaceId) => {
18
- await invoke("spaces:revokeGrant", { appKey, spaceId });
19
- };
3
+ const withTry = (fn, fallback) => Object.assign(fn, {
4
+ try: async (...args) => {
5
+ try {
6
+ return { ok: true, value: await fn(...args) };
7
+ } catch (e) {
8
+ return { ok: false, code: e.code ?? fallback };
9
+ }
10
+ }
11
+ });
12
+ const listSpaces = withTry(
13
+ (opts = {}) => invoke("spaces:list", opts),
14
+ "unknown"
15
+ );
16
+ const listAllSpaces = withTry(
17
+ () => invoke("spaces:listAll", {}),
18
+ "unknown"
19
+ );
20
+ const getSpaceMembers = withTry(
21
+ (spaceId) => invoke("spaces:members", { spaceId }),
22
+ "unknown"
23
+ );
24
+ const inviteToSpace = withTry(
25
+ async (spaceId, login, role) => {
26
+ await invoke("spaces:invite", { spaceId, login, role });
27
+ },
28
+ "unknown"
29
+ );
30
+ const unshareSpace = withTry(
31
+ async (spaceId, uid) => {
32
+ await invoke("spaces:unshare", { spaceId, uid });
33
+ },
34
+ "unknown"
35
+ );
36
+ const setSpaceRole = withTry(
37
+ async (spaceId, uid, role) => {
38
+ await invoke("spaces:setRole", { spaceId, uid, role });
39
+ },
40
+ "unknown"
41
+ );
42
+ const lookupUser = withTry(
43
+ (login) => invoke("spaces:lookupUser", { login }),
44
+ "unknown"
45
+ );
46
+ const listGrants = withTry(
47
+ () => invoke("spaces:grants", {}),
48
+ "unknown"
49
+ );
50
+ const revokeGrant = withTry(
51
+ async (appKey, spaceId) => {
52
+ await invoke("spaces:revokeGrant", { appKey, spaceId });
53
+ },
54
+ "unknown"
55
+ );
56
+ const listPendingInvites = withTry(
57
+ (spaceId) => invoke("spaces:pendingInvites", { spaceId }),
58
+ "unknown"
59
+ );
60
+ const revokeInvite = withTry(
61
+ async (spaceId, uid) => {
62
+ await invoke("spaces:revokeInvite", { spaceId, uid });
63
+ },
64
+ "unknown"
65
+ );
66
+ const listMyInvites = withTry(
67
+ () => invoke("spaces:listInvites", {}),
68
+ "unknown"
69
+ );
70
+ const acceptInvite = withTry(
71
+ async (spaceId) => {
72
+ await invoke("spaces:acceptInvite", { spaceId });
73
+ },
74
+ "unknown"
75
+ );
76
+ const declineInvite = withTry(
77
+ async (spaceId) => {
78
+ await invoke("spaces:declineInvite", { spaceId });
79
+ },
80
+ "unknown"
81
+ );
20
82
  export {
83
+ acceptInvite,
84
+ declineInvite,
21
85
  getSpaceMembers,
22
86
  inviteToSpace,
23
87
  listAllSpaces,
24
88
  listGrants,
89
+ listMyInvites,
90
+ listPendingInvites,
25
91
  listSpaces,
26
92
  lookupUser,
27
93
  revokeGrant,
94
+ revokeInvite,
28
95
  setSpaceRole,
29
96
  unshareSpace
30
97
  };