@axcode/axcloud-sdk 0.3.0-dev.826249d → 0.3.1-dev.6460842
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/README.md +1 -1
- package/dist/index.d.mts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +34 -13
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +34 -13
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -993,23 +993,28 @@ function useCodeBallot({ pollId, votingApiUrl }) {
|
|
|
993
993
|
}
|
|
994
994
|
var LINKED_ACCOUNTS_QUERY_KEY = ["axcloud", "linked-accounts"];
|
|
995
995
|
function useLinkedAccounts() {
|
|
996
|
-
const { client, stage } = useAxCloudContext();
|
|
996
|
+
const { client, orgId, stage } = useAxCloudContext();
|
|
997
997
|
const { isAuthenticated } = useAuth();
|
|
998
998
|
const queryClient = useQueryClient();
|
|
999
999
|
const query = useQuery({
|
|
1000
|
-
queryKey: [...LINKED_ACCOUNTS_QUERY_KEY, stage],
|
|
1000
|
+
queryKey: [...LINKED_ACCOUNTS_QUERY_KEY, stage, orgId],
|
|
1001
1001
|
queryFn: async () => {
|
|
1002
|
-
return client.get(`/identities/api/users/me/identities
|
|
1002
|
+
return client.get(`/identities/api/users/me/identities`, {
|
|
1003
|
+
organization_id: orgId
|
|
1004
|
+
});
|
|
1003
1005
|
},
|
|
1004
|
-
enabled: isAuthenticated,
|
|
1006
|
+
enabled: isAuthenticated && Boolean(orgId),
|
|
1005
1007
|
staleTime: 1e3 * 60 * 5
|
|
1006
1008
|
// 5 minutes
|
|
1007
1009
|
});
|
|
1008
1010
|
const linkMutation = useMutation({
|
|
1009
1011
|
mutationFn: async (provider) => {
|
|
1012
|
+
if (!query.data?.account_linking?.enabled) {
|
|
1013
|
+
throw new Error("Account linking is not enabled for this organization");
|
|
1014
|
+
}
|
|
1010
1015
|
const response = await client.post(
|
|
1011
1016
|
`/identities/api/users/me/identities/${provider}/link`,
|
|
1012
|
-
{}
|
|
1017
|
+
{ organization_id: orgId }
|
|
1013
1018
|
);
|
|
1014
1019
|
if (response.authorization_url) {
|
|
1015
1020
|
window.location.href = response.authorization_url;
|
|
@@ -1032,8 +1037,9 @@ function useLinkedAccounts() {
|
|
|
1032
1037
|
});
|
|
1033
1038
|
return {
|
|
1034
1039
|
identities: query.data?.identities ?? [],
|
|
1035
|
-
availableProviders: query.data?.available_providers ?? [],
|
|
1040
|
+
availableProviders: query.data?.account_linking?.enabled ? query.data.available_providers ?? [] : [],
|
|
1036
1041
|
canUnlink: query.data?.can_unlink ?? false,
|
|
1042
|
+
accountLinkingEnabled: query.data?.account_linking?.enabled ?? false,
|
|
1037
1043
|
isLoading: query.isLoading,
|
|
1038
1044
|
error: query.error,
|
|
1039
1045
|
linkAccount: linkMutation.mutate,
|
|
@@ -1149,6 +1155,12 @@ function useMedia(mediaId) {
|
|
|
1149
1155
|
refetch: query.refetch
|
|
1150
1156
|
};
|
|
1151
1157
|
}
|
|
1158
|
+
function unwrapApiData(response) {
|
|
1159
|
+
if (response && typeof response === "object" && "data" in response && response.data !== void 0) {
|
|
1160
|
+
return response.data;
|
|
1161
|
+
}
|
|
1162
|
+
return response;
|
|
1163
|
+
}
|
|
1152
1164
|
function buildDocumentParams(options) {
|
|
1153
1165
|
return {
|
|
1154
1166
|
search: options?.search,
|
|
@@ -1162,7 +1174,11 @@ function useDocuments(options) {
|
|
|
1162
1174
|
const query = useQuery({
|
|
1163
1175
|
queryKey: ["axcloud", "documents", "list", orgId, options],
|
|
1164
1176
|
queryFn: async () => {
|
|
1165
|
-
|
|
1177
|
+
const response = await client.get(
|
|
1178
|
+
`/documents/public/${orgId}/documents`,
|
|
1179
|
+
params
|
|
1180
|
+
);
|
|
1181
|
+
return unwrapApiData(response);
|
|
1166
1182
|
},
|
|
1167
1183
|
staleTime: 1e3 * 60 * 5
|
|
1168
1184
|
});
|
|
@@ -1181,9 +1197,10 @@ function useDocumentDownload(documentId) {
|
|
|
1181
1197
|
const query = useQuery({
|
|
1182
1198
|
queryKey: ["axcloud", "documents", "download", orgId, documentId],
|
|
1183
1199
|
queryFn: async () => {
|
|
1184
|
-
|
|
1200
|
+
const response = await client.get(
|
|
1185
1201
|
`/documents/public/${orgId}/documents/${encodeURIComponent(documentId || "")}/download`
|
|
1186
1202
|
);
|
|
1203
|
+
return unwrapApiData(response);
|
|
1187
1204
|
},
|
|
1188
1205
|
enabled: !!documentId,
|
|
1189
1206
|
staleTime: 1e3 * 60 * 10,
|
|
@@ -1208,7 +1225,11 @@ function useMemberDocuments(options) {
|
|
|
1208
1225
|
const query = useQuery({
|
|
1209
1226
|
queryKey: ["axcloud", "documents", "member", "list", orgId, options],
|
|
1210
1227
|
queryFn: async () => {
|
|
1211
|
-
|
|
1228
|
+
const response = await client.get(
|
|
1229
|
+
`/documents/members/${orgId}/documents`,
|
|
1230
|
+
params
|
|
1231
|
+
);
|
|
1232
|
+
return unwrapApiData(response);
|
|
1212
1233
|
},
|
|
1213
1234
|
staleTime: 1e3 * 60 * 5
|
|
1214
1235
|
});
|
|
@@ -1229,9 +1250,8 @@ function useMemberDocumentFolders() {
|
|
|
1229
1250
|
const query = useQuery({
|
|
1230
1251
|
queryKey: ["axcloud", "documents", "member", "folders", orgId],
|
|
1231
1252
|
queryFn: async () => {
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
);
|
|
1253
|
+
const response = await client.get(`/documents/members/${orgId}/document-folders`);
|
|
1254
|
+
return unwrapApiData(response);
|
|
1235
1255
|
},
|
|
1236
1256
|
staleTime: 1e3 * 60 * 5
|
|
1237
1257
|
});
|
|
@@ -1248,9 +1268,10 @@ function useMemberDocumentDownload(documentId) {
|
|
|
1248
1268
|
const query = useQuery({
|
|
1249
1269
|
queryKey: ["axcloud", "documents", "member", "download", orgId, documentId],
|
|
1250
1270
|
queryFn: async () => {
|
|
1251
|
-
|
|
1271
|
+
const response = await client.get(
|
|
1252
1272
|
`/documents/members/${orgId}/documents/${encodeURIComponent(documentId || "")}/download`
|
|
1253
1273
|
);
|
|
1274
|
+
return unwrapApiData(response);
|
|
1254
1275
|
},
|
|
1255
1276
|
enabled: !!documentId,
|
|
1256
1277
|
staleTime: 1e3 * 60 * 10,
|