@sublay/js 7.7.0 → 7.8.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/index.d.mts +482 -66
- package/dist/index.d.ts +3 -2
- package/dist/index.js +208 -37
- package/dist/index.mjs +208 -37
- package/dist/interfaces/Push.d.ts +54 -0
- package/dist/interfaces/Report.d.ts +7 -1
- package/dist/interfaces/Workspace.d.ts +74 -1
- package/dist/modules/auth/changePassword.d.ts +23 -0
- package/dist/modules/auth/signOut.d.ts +95 -1
- package/dist/modules/chat/index.d.ts +0 -1
- package/dist/modules/collections/updateCollection.d.ts +1 -1
- package/dist/modules/comments/updateComment.d.ts +4 -1
- package/dist/modules/reports/createReport.d.ts +2 -2
- package/dist/modules/spaces/fetchUserSpaces.d.ts +6 -0
- package/dist/modules/workspaces/acceptWorkspaceInvite.d.ts +13 -0
- package/dist/modules/workspaces/createWorkspaceInvite.d.ts +17 -0
- package/dist/modules/workspaces/declineWorkspaceInvite.d.ts +14 -0
- package/dist/modules/workspaces/deleteWorkspace.d.ts +13 -0
- package/dist/modules/workspaces/fetchMyWorkspaceInvites.d.ts +15 -0
- package/dist/modules/workspaces/fetchWorkspaceAuthority.d.ts +11 -0
- package/dist/modules/workspaces/fetchWorkspaceInvites.d.ts +17 -0
- package/dist/modules/workspaces/fetchWorkspaceMemberStanding.d.ts +11 -0
- package/dist/modules/workspaces/fetchWorkspaceMembers.d.ts +13 -0
- package/dist/modules/workspaces/index.d.ts +18 -6
- package/dist/modules/workspaces/leaveWorkspace.d.ts +11 -0
- package/dist/modules/workspaces/removeWorkspaceMember.d.ts +12 -0
- package/dist/modules/workspaces/removeWorkspaceMemberFromSubtree.d.ts +16 -0
- package/dist/modules/workspaces/resendWorkspaceInvite.d.ts +12 -0
- package/dist/modules/workspaces/revokeWorkspaceInvite.d.ts +13 -0
- package/dist/modules/workspaces/transferWorkspaceOwnership.d.ts +15 -0
- package/dist/modules/workspaces/updateWorkspace.d.ts +12 -0
- package/dist/modules/workspaces/updateWorkspaceInheritFlag.d.ts +13 -0
- package/dist/modules/workspaces/updateWorkspaceMember.d.ts +17 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -56,9 +56,10 @@ export type { ClientConfig, AuthTokens } from "./core/client";
|
|
|
56
56
|
export type { PaginatedResponse, PaginationMetadata, } from "./interfaces/IPaginatedResponse";
|
|
57
57
|
export type { SpaceReputationContextParams, SpaceReputationUserParams, } from "./interfaces/SpaceReputation";
|
|
58
58
|
export type { UserSearchParams } from "./interfaces/UserSearch";
|
|
59
|
-
export type { Workspace, WorkspaceInvitation, WorkspaceCapability, WorkspaceInvitationStatus, WorkspaceAuthorityReason, WorkspaceRosterReason, WorkspaceRosterEntry, WorkspaceRosterResponse, WorkspaceRosterCountsResponse, WorkspaceAuthority, } from "./interfaces/Workspace";
|
|
59
|
+
export type { Workspace, WorkspaceMember, WorkspaceInvitation, WorkspaceCapability, WorkspaceInvitationStatus, WorkspaceAuthorityReason, WorkspaceAuthorityReasonDetail, WorkspaceRosterReason, WorkspaceRosterEntry, WorkspaceRosterResponse, WorkspaceRosterCountsResponse, WorkspaceStandingUser, WorkspaceMemberStanding, WorkspaceAuthority, RemoveWorkspaceMemberFromSubtreeResponse, SkippedWorkspace, } from "./interfaces/Workspace";
|
|
60
60
|
export { PUSH_EVENT_TYPES, MUTE_DURATIONS } from "./interfaces/Push";
|
|
61
|
-
export type { PushEventType, MuteDuration, NotificationPreferences, } from "./interfaces/Push";
|
|
61
|
+
export type { PushEventType, MuteDuration, NotificationPreferences, PushDeviceIdentifier, WebPushSubscription, } from "./interfaces/Push";
|
|
62
|
+
export type { SignOutResult, PushUnbindSkipReason, } from "./modules/auth/signOut";
|
|
62
63
|
export type { UpdateNotificationPreferencesProps } from "./modules/push/updateNotificationPreferences";
|
|
63
64
|
export type { MuteConversationProps, MuteConversationResponse, } from "./modules/chat/muteConversation";
|
|
64
65
|
export type { TableAccessor, TableRow, TableQuery, DbFilter, DbFilterOperator, BulkDeleteProps, DeleteResult, BulkDeleteResult, } from "./interfaces/Table";
|
package/dist/index.js
CHANGED
|
@@ -212,13 +212,54 @@ async function signIn(client, data) {
|
|
|
212
212
|
}
|
|
213
213
|
|
|
214
214
|
// src/modules/auth/signOut.ts
|
|
215
|
+
var PUSH_UNBIND_STATUS_UNKNOWN_CODE = "auth/push-unbind-status-unknown";
|
|
216
|
+
var UNBIND_FAILURE_CODES = [
|
|
217
|
+
"auth/device-deregistration-failed",
|
|
218
|
+
"auth/sign-out-failed"
|
|
219
|
+
];
|
|
220
|
+
function isUnbindFailure(error) {
|
|
221
|
+
const code = error?.response?.data?.code;
|
|
222
|
+
return typeof code === "string" && UNBIND_FAILURE_CODES.includes(code);
|
|
223
|
+
}
|
|
215
224
|
async function signOut(client, data) {
|
|
216
225
|
const refreshToken = data?.refreshToken ?? client.getRefreshToken();
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
226
|
+
const localUnbindSkipped = Boolean(data?.pushDevice) && !refreshToken;
|
|
227
|
+
const body = refreshToken ? { refreshToken } : {};
|
|
228
|
+
if (data?.pushDevice && !localUnbindSkipped) body.pushDevice = data.pushDevice;
|
|
229
|
+
let response;
|
|
230
|
+
try {
|
|
231
|
+
response = await client.projectInstance.post(
|
|
232
|
+
"/auth/sign-out",
|
|
233
|
+
body
|
|
234
|
+
);
|
|
235
|
+
} catch (error) {
|
|
236
|
+
if (isUnbindFailure(error)) throw error;
|
|
237
|
+
console.warn(
|
|
238
|
+
"signOut: the server sign-out did not complete, so the session may still be live on the server until its refresh token expires. Signing out locally anyway \u2014 a user must always be able to sign out; only a refused push unbind keeps the local session, because that is the one failure that leaves a binding to retry against.",
|
|
239
|
+
error
|
|
240
|
+
);
|
|
241
|
+
}
|
|
221
242
|
client.clearTokens();
|
|
243
|
+
const serverUnbindSkipped = typeof response?.data === "object" && response.data !== null && response.data.code === PUSH_UNBIND_STATUS_UNKNOWN_CODE;
|
|
244
|
+
if (localUnbindSkipped) {
|
|
245
|
+
console.warn(
|
|
246
|
+
"signOut: signed out, but the push unbind was SKIPPED \u2014 `pushDevice` was supplied and no refresh token could be resolved (none stored and none provided). The unbind is scoped to the refresh token's subject, so the server would have unbound nothing. This device keeps receiving that account's notifications until something else removes the binding. Pass `refreshToken` alongside `pushDevice` \u2014 required in host-managed mode, where the SDK stores no refresh token."
|
|
247
|
+
);
|
|
248
|
+
return {
|
|
249
|
+
pushUnbindSkipped: true,
|
|
250
|
+
pushUnbindSkipReason: "no-refresh-token"
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
if (serverUnbindSkipped) {
|
|
254
|
+
console.warn(
|
|
255
|
+
"signOut: signed out, but the push unbind was SKIPPED \u2014 the server could not determine whether this project has push devices, so it did not attempt one. This device may still be bound to that account and can keep receiving its notifications. The sign-out itself committed, so there is no credential left to retry with: the binding clears when that account next registers on this device, or when the server prunes the token as undeliverable."
|
|
256
|
+
);
|
|
257
|
+
return {
|
|
258
|
+
pushUnbindSkipped: true,
|
|
259
|
+
pushUnbindSkipReason: "push-unbind-status-unknown"
|
|
260
|
+
};
|
|
261
|
+
}
|
|
262
|
+
return { pushUnbindSkipped: false };
|
|
222
263
|
}
|
|
223
264
|
|
|
224
265
|
// src/modules/auth/requestNewAccessToken.ts
|
|
@@ -266,7 +307,11 @@ async function resetPassword(client, data) {
|
|
|
266
307
|
async function changePassword(client, data) {
|
|
267
308
|
const response = await client.projectInstance.post(
|
|
268
309
|
"/auth/change-password",
|
|
269
|
-
|
|
310
|
+
{
|
|
311
|
+
password: data.password,
|
|
312
|
+
newPassword: data.newPassword,
|
|
313
|
+
...data.pushDevice ? { pushDevice: data.pushDevice } : {}
|
|
314
|
+
}
|
|
270
315
|
);
|
|
271
316
|
return response.data;
|
|
272
317
|
}
|
|
@@ -2211,7 +2256,6 @@ __export(chat_exports, {
|
|
|
2211
2256
|
markAsRead: () => markAsRead,
|
|
2212
2257
|
muteConversation: () => muteConversation,
|
|
2213
2258
|
removeMember: () => removeMember,
|
|
2214
|
-
reportMessage: () => reportMessage,
|
|
2215
2259
|
sendMessage: () => sendMessage,
|
|
2216
2260
|
toggleReaction: () => toggleReaction,
|
|
2217
2261
|
updateConversation: () => updateConversation
|
|
@@ -2501,16 +2545,6 @@ async function muteConversation(client, data) {
|
|
|
2501
2545
|
return response.data;
|
|
2502
2546
|
}
|
|
2503
2547
|
|
|
2504
|
-
// src/modules/chat/reportMessage.ts
|
|
2505
|
-
async function reportMessage(client, data) {
|
|
2506
|
-
const { conversationId, messageId, ...body } = data;
|
|
2507
|
-
const response = await client.projectInstance.post(
|
|
2508
|
-
`/chat/conversations/${conversationId}/messages/${messageId}/report`,
|
|
2509
|
-
body
|
|
2510
|
-
);
|
|
2511
|
-
return response.data;
|
|
2512
|
-
}
|
|
2513
|
-
|
|
2514
2548
|
// src/modules/push/index.ts
|
|
2515
2549
|
var push_exports = {};
|
|
2516
2550
|
__export(push_exports, {
|
|
@@ -2539,22 +2573,36 @@ async function updateNotificationPreferences(client, data) {
|
|
|
2539
2573
|
// src/modules/workspaces/index.ts
|
|
2540
2574
|
var workspaces_exports = {};
|
|
2541
2575
|
__export(workspaces_exports, {
|
|
2542
|
-
|
|
2543
|
-
createInvite: () => createInvite,
|
|
2576
|
+
acceptWorkspaceInvite: () => acceptWorkspaceInvite,
|
|
2544
2577
|
createWorkspace: () => createWorkspace,
|
|
2545
|
-
|
|
2578
|
+
createWorkspaceInvite: () => createWorkspaceInvite,
|
|
2579
|
+
declineWorkspaceInvite: () => declineWorkspaceInvite,
|
|
2580
|
+
deleteWorkspace: () => deleteWorkspace,
|
|
2546
2581
|
fetchManyWorkspaces: () => fetchManyWorkspaces,
|
|
2547
|
-
|
|
2548
|
-
fetchMyInvites: () => fetchMyInvites,
|
|
2582
|
+
fetchMyWorkspaceInvites: () => fetchMyWorkspaceInvites,
|
|
2549
2583
|
fetchWorkspace: () => fetchWorkspace,
|
|
2550
|
-
|
|
2584
|
+
fetchWorkspaceAuthority: () => fetchWorkspaceAuthority,
|
|
2585
|
+
fetchWorkspaceInvites: () => fetchWorkspaceInvites,
|
|
2586
|
+
fetchWorkspaceMemberStanding: () => fetchWorkspaceMemberStanding,
|
|
2587
|
+
fetchWorkspaceMembers: () => fetchWorkspaceMembers,
|
|
2588
|
+
leaveWorkspace: () => leaveWorkspace,
|
|
2589
|
+
removeWorkspaceMember: () => removeWorkspaceMember,
|
|
2590
|
+
removeWorkspaceMemberFromSubtree: () => removeWorkspaceMemberFromSubtree,
|
|
2591
|
+
resendWorkspaceInvite: () => resendWorkspaceInvite,
|
|
2592
|
+
revokeWorkspaceInvite: () => revokeWorkspaceInvite,
|
|
2593
|
+
transferWorkspaceOwnership: () => transferWorkspaceOwnership,
|
|
2594
|
+
updateWorkspace: () => updateWorkspace,
|
|
2595
|
+
updateWorkspaceInheritFlag: () => updateWorkspaceInheritFlag,
|
|
2596
|
+
updateWorkspaceMember: () => updateWorkspaceMember
|
|
2551
2597
|
});
|
|
2552
2598
|
|
|
2553
2599
|
// src/modules/workspaces/createWorkspace.ts
|
|
2554
2600
|
async function createWorkspace(client, data) {
|
|
2601
|
+
const body = { ...data };
|
|
2602
|
+
delete body.userId;
|
|
2555
2603
|
const response = await client.projectInstance.post(
|
|
2556
2604
|
"/workspaces",
|
|
2557
|
-
|
|
2605
|
+
body
|
|
2558
2606
|
);
|
|
2559
2607
|
return response.data;
|
|
2560
2608
|
}
|
|
@@ -2571,19 +2619,113 @@ async function fetchWorkspace(client, data) {
|
|
|
2571
2619
|
|
|
2572
2620
|
// src/modules/workspaces/fetchManyWorkspaces.ts
|
|
2573
2621
|
async function fetchManyWorkspaces(client, data = {}) {
|
|
2574
|
-
const
|
|
2622
|
+
const params = { ...data };
|
|
2623
|
+
delete params.userId;
|
|
2624
|
+
const response = await client.projectInstance.get("/workspaces", { params });
|
|
2625
|
+
return response.data;
|
|
2626
|
+
}
|
|
2627
|
+
|
|
2628
|
+
// src/modules/workspaces/updateWorkspace.ts
|
|
2629
|
+
async function updateWorkspace(client, data) {
|
|
2630
|
+
const { workspaceId, ...rest } = data;
|
|
2631
|
+
const body = { ...rest };
|
|
2632
|
+
delete body.userId;
|
|
2633
|
+
const response = await client.projectInstance.patch(
|
|
2634
|
+
`/workspaces/${workspaceId}`,
|
|
2635
|
+
body
|
|
2636
|
+
);
|
|
2575
2637
|
return response.data;
|
|
2576
2638
|
}
|
|
2577
2639
|
|
|
2578
|
-
// src/modules/workspaces/
|
|
2579
|
-
async function
|
|
2580
|
-
const { workspaceId,
|
|
2640
|
+
// src/modules/workspaces/updateWorkspaceInheritFlag.ts
|
|
2641
|
+
async function updateWorkspaceInheritFlag(client, data) {
|
|
2642
|
+
const { workspaceId, inheritsFromParent } = data;
|
|
2643
|
+
const response = await client.projectInstance.patch(
|
|
2644
|
+
`/workspaces/${workspaceId}/inherit-flag`,
|
|
2645
|
+
{ inheritsFromParent }
|
|
2646
|
+
);
|
|
2647
|
+
return response.data;
|
|
2648
|
+
}
|
|
2649
|
+
|
|
2650
|
+
// src/modules/workspaces/deleteWorkspace.ts
|
|
2651
|
+
async function deleteWorkspace(client, data) {
|
|
2652
|
+
const { workspaceId } = data;
|
|
2653
|
+
const response = await client.projectInstance.delete(
|
|
2654
|
+
`/workspaces/${workspaceId}`
|
|
2655
|
+
);
|
|
2656
|
+
return response.data;
|
|
2657
|
+
}
|
|
2658
|
+
|
|
2659
|
+
// src/modules/workspaces/transferWorkspaceOwnership.ts
|
|
2660
|
+
async function transferWorkspaceOwnership(client, data) {
|
|
2661
|
+
const { workspaceId, ...rest } = data;
|
|
2662
|
+
const body = { ...rest };
|
|
2663
|
+
delete body.userId;
|
|
2664
|
+
const response = await client.projectInstance.post(
|
|
2665
|
+
`/workspaces/${workspaceId}/transfer-ownership`,
|
|
2666
|
+
body
|
|
2667
|
+
);
|
|
2668
|
+
return response.data;
|
|
2669
|
+
}
|
|
2670
|
+
|
|
2671
|
+
// src/modules/workspaces/fetchWorkspaceMembers.ts
|
|
2672
|
+
async function fetchWorkspaceMembers(client, data) {
|
|
2673
|
+
const { workspaceId, ...rest } = data;
|
|
2674
|
+
const params = { ...rest };
|
|
2675
|
+
delete params.userId;
|
|
2581
2676
|
const response = await client.projectInstance.get(`/workspaces/${workspaceId}/members`, { params });
|
|
2582
2677
|
return response.data;
|
|
2583
2678
|
}
|
|
2584
2679
|
|
|
2585
|
-
// src/modules/workspaces/
|
|
2586
|
-
async function
|
|
2680
|
+
// src/modules/workspaces/fetchWorkspaceMemberStanding.ts
|
|
2681
|
+
async function fetchWorkspaceMemberStanding(client, data) {
|
|
2682
|
+
const { workspaceId, targetUserId } = data;
|
|
2683
|
+
const response = await client.projectInstance.get(
|
|
2684
|
+
`/workspaces/${workspaceId}/members/${targetUserId}`
|
|
2685
|
+
);
|
|
2686
|
+
return response.data;
|
|
2687
|
+
}
|
|
2688
|
+
|
|
2689
|
+
// src/modules/workspaces/updateWorkspaceMember.ts
|
|
2690
|
+
async function updateWorkspaceMember(client, data) {
|
|
2691
|
+
const { workspaceId, targetUserId, ...rest } = data;
|
|
2692
|
+
const body = { ...rest };
|
|
2693
|
+
delete body.userId;
|
|
2694
|
+
const response = await client.projectInstance.patch(
|
|
2695
|
+
`/workspaces/${workspaceId}/members/${targetUserId}`,
|
|
2696
|
+
body
|
|
2697
|
+
);
|
|
2698
|
+
return response.data;
|
|
2699
|
+
}
|
|
2700
|
+
|
|
2701
|
+
// src/modules/workspaces/removeWorkspaceMember.ts
|
|
2702
|
+
async function removeWorkspaceMember(client, data) {
|
|
2703
|
+
const { workspaceId, targetUserId } = data;
|
|
2704
|
+
await client.projectInstance.delete(
|
|
2705
|
+
`/workspaces/${workspaceId}/members/${targetUserId}`
|
|
2706
|
+
);
|
|
2707
|
+
}
|
|
2708
|
+
|
|
2709
|
+
// src/modules/workspaces/leaveWorkspace.ts
|
|
2710
|
+
async function leaveWorkspace(client, data) {
|
|
2711
|
+
const { workspaceId } = data;
|
|
2712
|
+
await client.projectInstance.delete(
|
|
2713
|
+
`/workspaces/${workspaceId}/members/me`
|
|
2714
|
+
);
|
|
2715
|
+
}
|
|
2716
|
+
|
|
2717
|
+
// src/modules/workspaces/removeWorkspaceMemberFromSubtree.ts
|
|
2718
|
+
async function removeWorkspaceMemberFromSubtree(client, data) {
|
|
2719
|
+
const { workspaceId, targetUserId } = data;
|
|
2720
|
+
const response = await client.projectInstance.post(
|
|
2721
|
+
`/workspaces/${workspaceId}/members/${targetUserId}/remove-from-subtree`,
|
|
2722
|
+
{}
|
|
2723
|
+
);
|
|
2724
|
+
return response.data;
|
|
2725
|
+
}
|
|
2726
|
+
|
|
2727
|
+
// src/modules/workspaces/createWorkspaceInvite.ts
|
|
2728
|
+
async function createWorkspaceInvite(client, data) {
|
|
2587
2729
|
const { workspaceId, ...body } = data;
|
|
2588
2730
|
const response = await client.projectInstance.post(
|
|
2589
2731
|
`/workspaces/${workspaceId}/invites`,
|
|
@@ -2592,8 +2734,37 @@ async function createInvite(client, data) {
|
|
|
2592
2734
|
return response.data;
|
|
2593
2735
|
}
|
|
2594
2736
|
|
|
2595
|
-
// src/modules/workspaces/
|
|
2596
|
-
async function
|
|
2737
|
+
// src/modules/workspaces/fetchWorkspaceInvites.ts
|
|
2738
|
+
async function fetchWorkspaceInvites(client, data) {
|
|
2739
|
+
const { workspaceId } = data;
|
|
2740
|
+
const response = await client.projectInstance.get(
|
|
2741
|
+
`/workspaces/${workspaceId}/invites`
|
|
2742
|
+
);
|
|
2743
|
+
return response.data;
|
|
2744
|
+
}
|
|
2745
|
+
|
|
2746
|
+
// src/modules/workspaces/revokeWorkspaceInvite.ts
|
|
2747
|
+
async function revokeWorkspaceInvite(client, data) {
|
|
2748
|
+
const { workspaceId, inviteId } = data;
|
|
2749
|
+
const response = await client.projectInstance.post(
|
|
2750
|
+
`/workspaces/${workspaceId}/invites/${inviteId}/revoke`,
|
|
2751
|
+
{}
|
|
2752
|
+
);
|
|
2753
|
+
return response.data;
|
|
2754
|
+
}
|
|
2755
|
+
|
|
2756
|
+
// src/modules/workspaces/resendWorkspaceInvite.ts
|
|
2757
|
+
async function resendWorkspaceInvite(client, data) {
|
|
2758
|
+
const { workspaceId, inviteId } = data;
|
|
2759
|
+
const response = await client.projectInstance.post(
|
|
2760
|
+
`/workspaces/${workspaceId}/invites/${inviteId}/resend`,
|
|
2761
|
+
{}
|
|
2762
|
+
);
|
|
2763
|
+
return response.data;
|
|
2764
|
+
}
|
|
2765
|
+
|
|
2766
|
+
// src/modules/workspaces/acceptWorkspaceInvite.ts
|
|
2767
|
+
async function acceptWorkspaceInvite(client, data) {
|
|
2597
2768
|
const { inviteId } = data;
|
|
2598
2769
|
const response = await client.projectInstance.post(
|
|
2599
2770
|
`/workspace-invites/${inviteId}/accept`,
|
|
@@ -2602,8 +2773,8 @@ async function acceptInvite(client, data) {
|
|
|
2602
2773
|
return response.data;
|
|
2603
2774
|
}
|
|
2604
2775
|
|
|
2605
|
-
// src/modules/workspaces/
|
|
2606
|
-
async function
|
|
2776
|
+
// src/modules/workspaces/declineWorkspaceInvite.ts
|
|
2777
|
+
async function declineWorkspaceInvite(client, data) {
|
|
2607
2778
|
const { inviteId } = data;
|
|
2608
2779
|
const response = await client.projectInstance.post(
|
|
2609
2780
|
`/workspace-invites/${inviteId}/decline`,
|
|
@@ -2612,16 +2783,16 @@ async function declineInvite(client, data) {
|
|
|
2612
2783
|
return response.data;
|
|
2613
2784
|
}
|
|
2614
2785
|
|
|
2615
|
-
// src/modules/workspaces/
|
|
2616
|
-
async function
|
|
2786
|
+
// src/modules/workspaces/fetchMyWorkspaceInvites.ts
|
|
2787
|
+
async function fetchMyWorkspaceInvites(client) {
|
|
2617
2788
|
const response = await client.projectInstance.get(
|
|
2618
2789
|
"/me/workspace-invites"
|
|
2619
2790
|
);
|
|
2620
2791
|
return response.data;
|
|
2621
2792
|
}
|
|
2622
2793
|
|
|
2623
|
-
// src/modules/workspaces/
|
|
2624
|
-
async function
|
|
2794
|
+
// src/modules/workspaces/fetchWorkspaceAuthority.ts
|
|
2795
|
+
async function fetchWorkspaceAuthority(client, data) {
|
|
2625
2796
|
const { workspaceId } = data;
|
|
2626
2797
|
const response = await client.projectInstance.get(
|
|
2627
2798
|
`/workspaces/${workspaceId}/authority/me`
|
package/dist/index.mjs
CHANGED
|
@@ -180,13 +180,54 @@ async function signIn(client, data) {
|
|
|
180
180
|
}
|
|
181
181
|
|
|
182
182
|
// src/modules/auth/signOut.ts
|
|
183
|
+
var PUSH_UNBIND_STATUS_UNKNOWN_CODE = "auth/push-unbind-status-unknown";
|
|
184
|
+
var UNBIND_FAILURE_CODES = [
|
|
185
|
+
"auth/device-deregistration-failed",
|
|
186
|
+
"auth/sign-out-failed"
|
|
187
|
+
];
|
|
188
|
+
function isUnbindFailure(error) {
|
|
189
|
+
const code = error?.response?.data?.code;
|
|
190
|
+
return typeof code === "string" && UNBIND_FAILURE_CODES.includes(code);
|
|
191
|
+
}
|
|
183
192
|
async function signOut(client, data) {
|
|
184
193
|
const refreshToken = data?.refreshToken ?? client.getRefreshToken();
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
194
|
+
const localUnbindSkipped = Boolean(data?.pushDevice) && !refreshToken;
|
|
195
|
+
const body = refreshToken ? { refreshToken } : {};
|
|
196
|
+
if (data?.pushDevice && !localUnbindSkipped) body.pushDevice = data.pushDevice;
|
|
197
|
+
let response;
|
|
198
|
+
try {
|
|
199
|
+
response = await client.projectInstance.post(
|
|
200
|
+
"/auth/sign-out",
|
|
201
|
+
body
|
|
202
|
+
);
|
|
203
|
+
} catch (error) {
|
|
204
|
+
if (isUnbindFailure(error)) throw error;
|
|
205
|
+
console.warn(
|
|
206
|
+
"signOut: the server sign-out did not complete, so the session may still be live on the server until its refresh token expires. Signing out locally anyway \u2014 a user must always be able to sign out; only a refused push unbind keeps the local session, because that is the one failure that leaves a binding to retry against.",
|
|
207
|
+
error
|
|
208
|
+
);
|
|
209
|
+
}
|
|
189
210
|
client.clearTokens();
|
|
211
|
+
const serverUnbindSkipped = typeof response?.data === "object" && response.data !== null && response.data.code === PUSH_UNBIND_STATUS_UNKNOWN_CODE;
|
|
212
|
+
if (localUnbindSkipped) {
|
|
213
|
+
console.warn(
|
|
214
|
+
"signOut: signed out, but the push unbind was SKIPPED \u2014 `pushDevice` was supplied and no refresh token could be resolved (none stored and none provided). The unbind is scoped to the refresh token's subject, so the server would have unbound nothing. This device keeps receiving that account's notifications until something else removes the binding. Pass `refreshToken` alongside `pushDevice` \u2014 required in host-managed mode, where the SDK stores no refresh token."
|
|
215
|
+
);
|
|
216
|
+
return {
|
|
217
|
+
pushUnbindSkipped: true,
|
|
218
|
+
pushUnbindSkipReason: "no-refresh-token"
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
if (serverUnbindSkipped) {
|
|
222
|
+
console.warn(
|
|
223
|
+
"signOut: signed out, but the push unbind was SKIPPED \u2014 the server could not determine whether this project has push devices, so it did not attempt one. This device may still be bound to that account and can keep receiving its notifications. The sign-out itself committed, so there is no credential left to retry with: the binding clears when that account next registers on this device, or when the server prunes the token as undeliverable."
|
|
224
|
+
);
|
|
225
|
+
return {
|
|
226
|
+
pushUnbindSkipped: true,
|
|
227
|
+
pushUnbindSkipReason: "push-unbind-status-unknown"
|
|
228
|
+
};
|
|
229
|
+
}
|
|
230
|
+
return { pushUnbindSkipped: false };
|
|
190
231
|
}
|
|
191
232
|
|
|
192
233
|
// src/modules/auth/requestNewAccessToken.ts
|
|
@@ -234,7 +275,11 @@ async function resetPassword(client, data) {
|
|
|
234
275
|
async function changePassword(client, data) {
|
|
235
276
|
const response = await client.projectInstance.post(
|
|
236
277
|
"/auth/change-password",
|
|
237
|
-
|
|
278
|
+
{
|
|
279
|
+
password: data.password,
|
|
280
|
+
newPassword: data.newPassword,
|
|
281
|
+
...data.pushDevice ? { pushDevice: data.pushDevice } : {}
|
|
282
|
+
}
|
|
238
283
|
);
|
|
239
284
|
return response.data;
|
|
240
285
|
}
|
|
@@ -2179,7 +2224,6 @@ __export(chat_exports, {
|
|
|
2179
2224
|
markAsRead: () => markAsRead,
|
|
2180
2225
|
muteConversation: () => muteConversation,
|
|
2181
2226
|
removeMember: () => removeMember,
|
|
2182
|
-
reportMessage: () => reportMessage,
|
|
2183
2227
|
sendMessage: () => sendMessage,
|
|
2184
2228
|
toggleReaction: () => toggleReaction,
|
|
2185
2229
|
updateConversation: () => updateConversation
|
|
@@ -2469,16 +2513,6 @@ async function muteConversation(client, data) {
|
|
|
2469
2513
|
return response.data;
|
|
2470
2514
|
}
|
|
2471
2515
|
|
|
2472
|
-
// src/modules/chat/reportMessage.ts
|
|
2473
|
-
async function reportMessage(client, data) {
|
|
2474
|
-
const { conversationId, messageId, ...body } = data;
|
|
2475
|
-
const response = await client.projectInstance.post(
|
|
2476
|
-
`/chat/conversations/${conversationId}/messages/${messageId}/report`,
|
|
2477
|
-
body
|
|
2478
|
-
);
|
|
2479
|
-
return response.data;
|
|
2480
|
-
}
|
|
2481
|
-
|
|
2482
2516
|
// src/modules/push/index.ts
|
|
2483
2517
|
var push_exports = {};
|
|
2484
2518
|
__export(push_exports, {
|
|
@@ -2507,22 +2541,36 @@ async function updateNotificationPreferences(client, data) {
|
|
|
2507
2541
|
// src/modules/workspaces/index.ts
|
|
2508
2542
|
var workspaces_exports = {};
|
|
2509
2543
|
__export(workspaces_exports, {
|
|
2510
|
-
|
|
2511
|
-
createInvite: () => createInvite,
|
|
2544
|
+
acceptWorkspaceInvite: () => acceptWorkspaceInvite,
|
|
2512
2545
|
createWorkspace: () => createWorkspace,
|
|
2513
|
-
|
|
2546
|
+
createWorkspaceInvite: () => createWorkspaceInvite,
|
|
2547
|
+
declineWorkspaceInvite: () => declineWorkspaceInvite,
|
|
2548
|
+
deleteWorkspace: () => deleteWorkspace,
|
|
2514
2549
|
fetchManyWorkspaces: () => fetchManyWorkspaces,
|
|
2515
|
-
|
|
2516
|
-
fetchMyInvites: () => fetchMyInvites,
|
|
2550
|
+
fetchMyWorkspaceInvites: () => fetchMyWorkspaceInvites,
|
|
2517
2551
|
fetchWorkspace: () => fetchWorkspace,
|
|
2518
|
-
|
|
2552
|
+
fetchWorkspaceAuthority: () => fetchWorkspaceAuthority,
|
|
2553
|
+
fetchWorkspaceInvites: () => fetchWorkspaceInvites,
|
|
2554
|
+
fetchWorkspaceMemberStanding: () => fetchWorkspaceMemberStanding,
|
|
2555
|
+
fetchWorkspaceMembers: () => fetchWorkspaceMembers,
|
|
2556
|
+
leaveWorkspace: () => leaveWorkspace,
|
|
2557
|
+
removeWorkspaceMember: () => removeWorkspaceMember,
|
|
2558
|
+
removeWorkspaceMemberFromSubtree: () => removeWorkspaceMemberFromSubtree,
|
|
2559
|
+
resendWorkspaceInvite: () => resendWorkspaceInvite,
|
|
2560
|
+
revokeWorkspaceInvite: () => revokeWorkspaceInvite,
|
|
2561
|
+
transferWorkspaceOwnership: () => transferWorkspaceOwnership,
|
|
2562
|
+
updateWorkspace: () => updateWorkspace,
|
|
2563
|
+
updateWorkspaceInheritFlag: () => updateWorkspaceInheritFlag,
|
|
2564
|
+
updateWorkspaceMember: () => updateWorkspaceMember
|
|
2519
2565
|
});
|
|
2520
2566
|
|
|
2521
2567
|
// src/modules/workspaces/createWorkspace.ts
|
|
2522
2568
|
async function createWorkspace(client, data) {
|
|
2569
|
+
const body = { ...data };
|
|
2570
|
+
delete body.userId;
|
|
2523
2571
|
const response = await client.projectInstance.post(
|
|
2524
2572
|
"/workspaces",
|
|
2525
|
-
|
|
2573
|
+
body
|
|
2526
2574
|
);
|
|
2527
2575
|
return response.data;
|
|
2528
2576
|
}
|
|
@@ -2539,19 +2587,113 @@ async function fetchWorkspace(client, data) {
|
|
|
2539
2587
|
|
|
2540
2588
|
// src/modules/workspaces/fetchManyWorkspaces.ts
|
|
2541
2589
|
async function fetchManyWorkspaces(client, data = {}) {
|
|
2542
|
-
const
|
|
2590
|
+
const params = { ...data };
|
|
2591
|
+
delete params.userId;
|
|
2592
|
+
const response = await client.projectInstance.get("/workspaces", { params });
|
|
2593
|
+
return response.data;
|
|
2594
|
+
}
|
|
2595
|
+
|
|
2596
|
+
// src/modules/workspaces/updateWorkspace.ts
|
|
2597
|
+
async function updateWorkspace(client, data) {
|
|
2598
|
+
const { workspaceId, ...rest } = data;
|
|
2599
|
+
const body = { ...rest };
|
|
2600
|
+
delete body.userId;
|
|
2601
|
+
const response = await client.projectInstance.patch(
|
|
2602
|
+
`/workspaces/${workspaceId}`,
|
|
2603
|
+
body
|
|
2604
|
+
);
|
|
2543
2605
|
return response.data;
|
|
2544
2606
|
}
|
|
2545
2607
|
|
|
2546
|
-
// src/modules/workspaces/
|
|
2547
|
-
async function
|
|
2548
|
-
const { workspaceId,
|
|
2608
|
+
// src/modules/workspaces/updateWorkspaceInheritFlag.ts
|
|
2609
|
+
async function updateWorkspaceInheritFlag(client, data) {
|
|
2610
|
+
const { workspaceId, inheritsFromParent } = data;
|
|
2611
|
+
const response = await client.projectInstance.patch(
|
|
2612
|
+
`/workspaces/${workspaceId}/inherit-flag`,
|
|
2613
|
+
{ inheritsFromParent }
|
|
2614
|
+
);
|
|
2615
|
+
return response.data;
|
|
2616
|
+
}
|
|
2617
|
+
|
|
2618
|
+
// src/modules/workspaces/deleteWorkspace.ts
|
|
2619
|
+
async function deleteWorkspace(client, data) {
|
|
2620
|
+
const { workspaceId } = data;
|
|
2621
|
+
const response = await client.projectInstance.delete(
|
|
2622
|
+
`/workspaces/${workspaceId}`
|
|
2623
|
+
);
|
|
2624
|
+
return response.data;
|
|
2625
|
+
}
|
|
2626
|
+
|
|
2627
|
+
// src/modules/workspaces/transferWorkspaceOwnership.ts
|
|
2628
|
+
async function transferWorkspaceOwnership(client, data) {
|
|
2629
|
+
const { workspaceId, ...rest } = data;
|
|
2630
|
+
const body = { ...rest };
|
|
2631
|
+
delete body.userId;
|
|
2632
|
+
const response = await client.projectInstance.post(
|
|
2633
|
+
`/workspaces/${workspaceId}/transfer-ownership`,
|
|
2634
|
+
body
|
|
2635
|
+
);
|
|
2636
|
+
return response.data;
|
|
2637
|
+
}
|
|
2638
|
+
|
|
2639
|
+
// src/modules/workspaces/fetchWorkspaceMembers.ts
|
|
2640
|
+
async function fetchWorkspaceMembers(client, data) {
|
|
2641
|
+
const { workspaceId, ...rest } = data;
|
|
2642
|
+
const params = { ...rest };
|
|
2643
|
+
delete params.userId;
|
|
2549
2644
|
const response = await client.projectInstance.get(`/workspaces/${workspaceId}/members`, { params });
|
|
2550
2645
|
return response.data;
|
|
2551
2646
|
}
|
|
2552
2647
|
|
|
2553
|
-
// src/modules/workspaces/
|
|
2554
|
-
async function
|
|
2648
|
+
// src/modules/workspaces/fetchWorkspaceMemberStanding.ts
|
|
2649
|
+
async function fetchWorkspaceMemberStanding(client, data) {
|
|
2650
|
+
const { workspaceId, targetUserId } = data;
|
|
2651
|
+
const response = await client.projectInstance.get(
|
|
2652
|
+
`/workspaces/${workspaceId}/members/${targetUserId}`
|
|
2653
|
+
);
|
|
2654
|
+
return response.data;
|
|
2655
|
+
}
|
|
2656
|
+
|
|
2657
|
+
// src/modules/workspaces/updateWorkspaceMember.ts
|
|
2658
|
+
async function updateWorkspaceMember(client, data) {
|
|
2659
|
+
const { workspaceId, targetUserId, ...rest } = data;
|
|
2660
|
+
const body = { ...rest };
|
|
2661
|
+
delete body.userId;
|
|
2662
|
+
const response = await client.projectInstance.patch(
|
|
2663
|
+
`/workspaces/${workspaceId}/members/${targetUserId}`,
|
|
2664
|
+
body
|
|
2665
|
+
);
|
|
2666
|
+
return response.data;
|
|
2667
|
+
}
|
|
2668
|
+
|
|
2669
|
+
// src/modules/workspaces/removeWorkspaceMember.ts
|
|
2670
|
+
async function removeWorkspaceMember(client, data) {
|
|
2671
|
+
const { workspaceId, targetUserId } = data;
|
|
2672
|
+
await client.projectInstance.delete(
|
|
2673
|
+
`/workspaces/${workspaceId}/members/${targetUserId}`
|
|
2674
|
+
);
|
|
2675
|
+
}
|
|
2676
|
+
|
|
2677
|
+
// src/modules/workspaces/leaveWorkspace.ts
|
|
2678
|
+
async function leaveWorkspace(client, data) {
|
|
2679
|
+
const { workspaceId } = data;
|
|
2680
|
+
await client.projectInstance.delete(
|
|
2681
|
+
`/workspaces/${workspaceId}/members/me`
|
|
2682
|
+
);
|
|
2683
|
+
}
|
|
2684
|
+
|
|
2685
|
+
// src/modules/workspaces/removeWorkspaceMemberFromSubtree.ts
|
|
2686
|
+
async function removeWorkspaceMemberFromSubtree(client, data) {
|
|
2687
|
+
const { workspaceId, targetUserId } = data;
|
|
2688
|
+
const response = await client.projectInstance.post(
|
|
2689
|
+
`/workspaces/${workspaceId}/members/${targetUserId}/remove-from-subtree`,
|
|
2690
|
+
{}
|
|
2691
|
+
);
|
|
2692
|
+
return response.data;
|
|
2693
|
+
}
|
|
2694
|
+
|
|
2695
|
+
// src/modules/workspaces/createWorkspaceInvite.ts
|
|
2696
|
+
async function createWorkspaceInvite(client, data) {
|
|
2555
2697
|
const { workspaceId, ...body } = data;
|
|
2556
2698
|
const response = await client.projectInstance.post(
|
|
2557
2699
|
`/workspaces/${workspaceId}/invites`,
|
|
@@ -2560,8 +2702,37 @@ async function createInvite(client, data) {
|
|
|
2560
2702
|
return response.data;
|
|
2561
2703
|
}
|
|
2562
2704
|
|
|
2563
|
-
// src/modules/workspaces/
|
|
2564
|
-
async function
|
|
2705
|
+
// src/modules/workspaces/fetchWorkspaceInvites.ts
|
|
2706
|
+
async function fetchWorkspaceInvites(client, data) {
|
|
2707
|
+
const { workspaceId } = data;
|
|
2708
|
+
const response = await client.projectInstance.get(
|
|
2709
|
+
`/workspaces/${workspaceId}/invites`
|
|
2710
|
+
);
|
|
2711
|
+
return response.data;
|
|
2712
|
+
}
|
|
2713
|
+
|
|
2714
|
+
// src/modules/workspaces/revokeWorkspaceInvite.ts
|
|
2715
|
+
async function revokeWorkspaceInvite(client, data) {
|
|
2716
|
+
const { workspaceId, inviteId } = data;
|
|
2717
|
+
const response = await client.projectInstance.post(
|
|
2718
|
+
`/workspaces/${workspaceId}/invites/${inviteId}/revoke`,
|
|
2719
|
+
{}
|
|
2720
|
+
);
|
|
2721
|
+
return response.data;
|
|
2722
|
+
}
|
|
2723
|
+
|
|
2724
|
+
// src/modules/workspaces/resendWorkspaceInvite.ts
|
|
2725
|
+
async function resendWorkspaceInvite(client, data) {
|
|
2726
|
+
const { workspaceId, inviteId } = data;
|
|
2727
|
+
const response = await client.projectInstance.post(
|
|
2728
|
+
`/workspaces/${workspaceId}/invites/${inviteId}/resend`,
|
|
2729
|
+
{}
|
|
2730
|
+
);
|
|
2731
|
+
return response.data;
|
|
2732
|
+
}
|
|
2733
|
+
|
|
2734
|
+
// src/modules/workspaces/acceptWorkspaceInvite.ts
|
|
2735
|
+
async function acceptWorkspaceInvite(client, data) {
|
|
2565
2736
|
const { inviteId } = data;
|
|
2566
2737
|
const response = await client.projectInstance.post(
|
|
2567
2738
|
`/workspace-invites/${inviteId}/accept`,
|
|
@@ -2570,8 +2741,8 @@ async function acceptInvite(client, data) {
|
|
|
2570
2741
|
return response.data;
|
|
2571
2742
|
}
|
|
2572
2743
|
|
|
2573
|
-
// src/modules/workspaces/
|
|
2574
|
-
async function
|
|
2744
|
+
// src/modules/workspaces/declineWorkspaceInvite.ts
|
|
2745
|
+
async function declineWorkspaceInvite(client, data) {
|
|
2575
2746
|
const { inviteId } = data;
|
|
2576
2747
|
const response = await client.projectInstance.post(
|
|
2577
2748
|
`/workspace-invites/${inviteId}/decline`,
|
|
@@ -2580,16 +2751,16 @@ async function declineInvite(client, data) {
|
|
|
2580
2751
|
return response.data;
|
|
2581
2752
|
}
|
|
2582
2753
|
|
|
2583
|
-
// src/modules/workspaces/
|
|
2584
|
-
async function
|
|
2754
|
+
// src/modules/workspaces/fetchMyWorkspaceInvites.ts
|
|
2755
|
+
async function fetchMyWorkspaceInvites(client) {
|
|
2585
2756
|
const response = await client.projectInstance.get(
|
|
2586
2757
|
"/me/workspace-invites"
|
|
2587
2758
|
);
|
|
2588
2759
|
return response.data;
|
|
2589
2760
|
}
|
|
2590
2761
|
|
|
2591
|
-
// src/modules/workspaces/
|
|
2592
|
-
async function
|
|
2762
|
+
// src/modules/workspaces/fetchWorkspaceAuthority.ts
|
|
2763
|
+
async function fetchWorkspaceAuthority(client, data) {
|
|
2593
2764
|
const { workspaceId } = data;
|
|
2594
2765
|
const response = await client.projectInstance.get(
|
|
2595
2766
|
`/workspaces/${workspaceId}/authority/me`
|