@@ -6,59 +6,26 @@
66 * OpenAPI spec version: 1.0.0
77 */
88import type {
9 AddMemberBody,
10 AssignRoleBody,
11 AuthOrganizationBanListParams,
12 AuthOrganizationDeleteParams,
13 AuthOrganizationInviteListParams,
14 AuthOrganizationMemberListParams,
15 AuthOrganizationMemberRemoveParams,
169 AuthSshKeyListParams,
17 BanMemberBody,
18 CheckPermissionBody,
19 CreateInviteBody,
20 CreateOrganizationBody,
21 CreateRoleBody,
22 EnvelopeBool,
2310 EnvelopeChallengeResponse,
24 EnvelopeCreateInviteResponse,
2511 EnvelopeLoginCodeResponse,
2612 EnvelopeLogoutResponse,
2713 EnvelopeMeResponse,
28 EnvelopeMemberSummary,
2914 EnvelopeNoData,
30 EnvelopeOrganizationSummary,
3115 EnvelopePasswordResetConfirmResponse,
3216 EnvelopePasswordResetResponse,
33 EnvelopePermissionCheck,
34 EnvelopeRedeemInviteResponse,
3517 EnvelopeRegisterCodeResponse,
36 EnvelopeRoleSummary,
3718 EnvelopeSshKeySummary,
3819 EnvelopeUserLoginResponse,
3920 EnvelopeUserRegisterResponse,
40 EnvelopeVecInviteSummary,
41 EnvelopeVecMemberSummary,
42 EnvelopeVecOrganizationSummary,
43 EnvelopeVecRoleSummary,
4421 EnvelopeVecSshKeySummary,
45 EnvelopeVecString,
4622 LoginCodeRequest,
4723 LoginCodeVerifyRequest,
4824 LoginVerifyRequest,
4925 PasswordResetConfirmRequest,
5026 PasswordResetRequest,
51 ReasonBody,
52 RedeemInviteBody,
5327 RegisterCodeRequest,
54 SetMemberRoleBody,
55 SetRolePermissionsBody,
5628 SshKeyAddRequest,
57 TransferBody,
58 UpdateBanBody,
59 UpdateMemberBody,
60 UpdateOrganizationBody,
61 UpdateRoleBody,
6229 UserLoginRequest,
6330 UserRegisterRequest,
6431} from "./auth.schemas";
@@ -1067,2374 +1034,4 @@
10671034 ...options,
10681035 method: "DELETE",
10691036 });
1070};
1071
1072export type authOrganizationListResponse200 = {
1073 data: EnvelopeVecOrganizationSummary;
1074 status: 200;
1075};
1076
1077export type authOrganizationListResponse401 = {
1078 data: EnvelopeNoData;
1079 status: 401;
1080};
1081
1082export type authOrganizationListResponseSuccess =
1083 authOrganizationListResponse200 & {
1084 headers: Headers;
1085 };
1086export type authOrganizationListResponseError =
1087 authOrganizationListResponse401 & {
1088 headers: Headers;
1089 };
1090
1091export type authOrganizationListResponse =
1092 authOrganizationListResponseSuccess | authOrganizationListResponseError;
1093
1094export const getAuthOrganizationListUrl = () => {
1095 return `/api/v1/organizations`;
1096};
1097
1098/**
1099 * 默认只返回 ACTIVE 组织;`include_archived=true` 时一并返回已归档组织。
1100 * @summary 列示我加入的组织
1101 */
1102export const authOrganizationList = async (
1103 options?: Parameters<typeof authClient>[1],
1104): Promise<authOrganizationListResponse> => {
1105 return authClient<authOrganizationListResponse>(
1106 getAuthOrganizationListUrl(),
1107 {
1108 ...options,
1109 method: "GET",
1110 },
1111 );
1112};
1113
1114export type authOrganizationCreateResponse200 = {
1115 data: EnvelopeOrganizationSummary;
1116 status: 200;
1117};
1118
1119export type authOrganizationCreateResponse401 = {
1120 data: EnvelopeNoData;
1121 status: 401;
1122};
1123
1124export type authOrganizationCreateResponse409 = {
1125 data: EnvelopeNoData;
1126 status: 409;
1127};
1128
1129export type authOrganizationCreateResponseSuccess =
1130 authOrganizationCreateResponse200 & {
1131 headers: Headers;
1132 };
1133export type authOrganizationCreateResponseError = (
1134 authOrganizationCreateResponse401 | authOrganizationCreateResponse409
1135) & {
1136 headers: Headers;
1137};
1138
1139export type authOrganizationCreateResponse =
1140 authOrganizationCreateResponseSuccess | authOrganizationCreateResponseError;
1141
1142export const getAuthOrganizationCreateUrl = () => {
1143 return `/api/v1/organizations`;
1144};
1145
1146/**
1147 * 创建者自动成为 OWNER 并写入 owner/admin/member 三个内置角色。slug 全局唯一且只允许小写字母、数字与连字符。
1148 * @summary 新建组织
1149 */
1150export const authOrganizationCreate = async (
1151 createOrganizationBody: CreateOrganizationBody,
1152 options?: Parameters<typeof authClient>[1],
1153): Promise<authOrganizationCreateResponse> => {
1154 const getHeaders = (
1155 h?: NonNullable<RequestInit["headers"]>,
1156 ): Record<string, string | readonly string[]> => {
1157 if (!h) return {};
1158 if (h instanceof Headers) return Object.fromEntries(h.entries());
1159 if (Symbol.iterator in h) {
1160 return Object.fromEntries(
1161 Array.from(
1162 h as Iterable<Iterable<string>>,
1163 (entry) => Array.from(entry) as [string, string],
1164 ),
1165 );
1166 }
1167 const headers: Record<string, string | readonly string[]> = {};
1168 for (const [name, value] of Object.entries<
1169 string | readonly string[] | undefined
1170 >(h)) {
1171 if (value !== undefined) headers[name] = value;
1172 }
1173 return headers;
1174 };
1175 return authClient<authOrganizationCreateResponse>(
1176 getAuthOrganizationCreateUrl(),
1177 {
1178 ...options,
1179 method: "POST",
1180 headers: {
1181 "Content-Type": "application/json",
1182 ...getHeaders(options?.headers),
1183 },
1184 body: JSON.stringify(createOrganizationBody),
1185 },
1186 );
1187};
1188
1189export type authOrganizationInviteRedeemResponse200 = {
1190 data: EnvelopeRedeemInviteResponse;
1191 status: 200;
1192};
1193
1194export type authOrganizationInviteRedeemResponse403 = {
1195 data: EnvelopeNoData;
1196 status: 403;
1197};
1198
1199export type authOrganizationInviteRedeemResponse409 = {
1200 data: EnvelopeNoData;
1201 status: 409;
1202};
1203
1204export type authOrganizationInviteRedeemResponseSuccess =
1205 authOrganizationInviteRedeemResponse200 & {
1206 headers: Headers;
1207 };
1208export type authOrganizationInviteRedeemResponseError = (
1209 | authOrganizationInviteRedeemResponse403
1210 | authOrganizationInviteRedeemResponse409
1211) & {
1212 headers: Headers;
1213};
1214
1215export type authOrganizationInviteRedeemResponse =
1216 | authOrganizationInviteRedeemResponseSuccess
1217 | authOrganizationInviteRedeemResponseError;
1218
1219export const getAuthOrganizationInviteRedeemUrl = () => {
1220 return `/api/v1/organizations/invites/redeem`;
1221};
1222
1223/**
1224 * uses 递增与兑换记录写入同事务。定向邀请只能由目标用户兑换。
1225 * @summary 兑换邀请
1226 */
1227export const authOrganizationInviteRedeem = async (
1228 redeemInviteBody: RedeemInviteBody,
1229 options?: Parameters<typeof authClient>[1],
1230): Promise<authOrganizationInviteRedeemResponse> => {
1231 const getHeaders = (
1232 h?: NonNullable<RequestInit["headers"]>,
1233 ): Record<string, string | readonly string[]> => {
1234 if (!h) return {};
1235 if (h instanceof Headers) return Object.fromEntries(h.entries());
1236 if (Symbol.iterator in h) {
1237 return Object.fromEntries(
1238 Array.from(
1239 h as Iterable<Iterable<string>>,
1240 (entry) => Array.from(entry) as [string, string],
1241 ),
1242 );
1243 }
1244 const headers: Record<string, string | readonly string[]> = {};
1245 for (const [name, value] of Object.entries<
1246 string | readonly string[] | undefined
1247 >(h)) {
1248 if (value !== undefined) headers[name] = value;
1249 }
1250 return headers;
1251 };
1252 return authClient<authOrganizationInviteRedeemResponse>(
1253 getAuthOrganizationInviteRedeemUrl(),
1254 {
1255 ...options,
1256 method: "POST",
1257 headers: {
1258 "Content-Type": "application/json",
1259 ...getHeaders(options?.headers),
1260 },
1261 body: JSON.stringify(redeemInviteBody),
1262 },
1263 );
1264};
1265
1266export type authOrganizationGetResponse200 = {
1267 data: EnvelopeOrganizationSummary;
1268 status: 200;
1269};
1270
1271export type authOrganizationGetResponse404 = {
1272 data: EnvelopeNoData;
1273 status: 404;
1274};
1275
1276export type authOrganizationGetResponseSuccess =
1277 authOrganizationGetResponse200 & {
1278 headers: Headers;
1279 };
1280export type authOrganizationGetResponseError =
1281 authOrganizationGetResponse404 & {
1282 headers: Headers;
1283 };
1284
1285export type authOrganizationGetResponse =
1286 authOrganizationGetResponseSuccess | authOrganizationGetResponseError;
1287
1288export const getAuthOrganizationGetUrl = (organizationId: string) => {
1289 return `/api/v1/organizations/${organizationId}`;
1290};
1291
1292/**
1293 * @summary 组织详情
1294 */
1295export const authOrganizationGet = async (
1296 organizationId: string,
1297 options?: Parameters<typeof authClient>[1],
1298): Promise<authOrganizationGetResponse> => {
1299 return authClient<authOrganizationGetResponse>(
1300 getAuthOrganizationGetUrl(organizationId),
1301 {
1302 ...options,
1303 method: "GET",
1304 },
1305 );
1306};
1307
1308export type authOrganizationDeleteResponse200 = {
1309 data: EnvelopeBool;
1310 status: 200;
1311};
1312
1313export type authOrganizationDeleteResponse403 = {
1314 data: EnvelopeNoData;
1315 status: 403;
1316};
1317
1318export type authOrganizationDeleteResponse409 = {
1319 data: EnvelopeNoData;
1320 status: 409;
1321};
1322
1323export type authOrganizationDeleteResponseSuccess =
1324 authOrganizationDeleteResponse200 & {
1325 headers: Headers;
1326 };
1327export type authOrganizationDeleteResponseError = (
1328 authOrganizationDeleteResponse403 | authOrganizationDeleteResponse409
1329) & {
1330 headers: Headers;
1331};
1332
1333export type authOrganizationDeleteResponse =
1334 authOrganizationDeleteResponseSuccess | authOrganizationDeleteResponseError;
1335
1336export const getAuthOrganizationDeleteUrl = (
1337 organizationId: string,
1338 params?: AuthOrganizationDeleteParams,
1339) => {
1340 const normalizedParams = new URLSearchParams();
1341
1342 Object.entries(params || {}).forEach(([key, value]) => {
1343 if (value !== undefined) {
1344 normalizedParams.append(key, value === null ? "null" : String(value));
1345 }
1346 });
1347
1348 const stringifiedParams = normalizedParams.toString();
1349
1350 return stringifiedParams.length > 0
1351 ? `/api/v1/organizations/${organizationId}?${stringifiedParams}`
1352 : `/api/v1/organizations/${organizationId}`;
1353};
1354
1355/**
1356 * 仍存在活跃成员且未指定 `force=true` 时返回 409。删除会清理成员、角色与邀请。
1357 * @summary 删除组织
1358 */
1359export const authOrganizationDelete = async (
1360 organizationId: string,
1361 params?: AuthOrganizationDeleteParams,
1362 options?: Parameters<typeof authClient>[1],
1363): Promise<authOrganizationDeleteResponse> => {
1364 return authClient<authOrganizationDeleteResponse>(
1365 getAuthOrganizationDeleteUrl(organizationId, params),
1366 {
1367 ...options,
1368 method: "DELETE",
1369 },
1370 );
1371};
1372
1373export type authOrganizationUpdateResponse200 = {
1374 data: EnvelopeOrganizationSummary;
1375 status: 200;
1376};
1377
1378export type authOrganizationUpdateResponse403 = {
1379 data: EnvelopeNoData;
1380 status: 403;
1381};
1382
1383export type authOrganizationUpdateResponse409 = {
1384 data: EnvelopeNoData;
1385 status: 409;
1386};
1387
1388export type authOrganizationUpdateResponseSuccess =
1389 authOrganizationUpdateResponse200 & {
1390 headers: Headers;
1391 };
1392export type authOrganizationUpdateResponseError = (
1393 authOrganizationUpdateResponse403 | authOrganizationUpdateResponse409
1394) & {
1395 headers: Headers;
1396};
1397
1398export type authOrganizationUpdateResponse =
1399 authOrganizationUpdateResponseSuccess | authOrganizationUpdateResponseError;
1400
1401export const getAuthOrganizationUpdateUrl = (organizationId: string) => {
1402 return `/api/v1/organizations/${organizationId}`;
1403};
1404
1405/**
1406 * 需要 `org.update`。`expected_version` 与当前 version 不一致时返回 409。
1407 * @summary 修改组织
1408 */
1409export const authOrganizationUpdate = async (
1410 organizationId: string,
1411 updateOrganizationBody: UpdateOrganizationBody,
1412 options?: Parameters<typeof authClient>[1],
1413): Promise<authOrganizationUpdateResponse> => {
1414 const getHeaders = (
1415 h?: NonNullable<RequestInit["headers"]>,
1416 ): Record<string, string | readonly string[]> => {
1417 if (!h) return {};
1418 if (h instanceof Headers) return Object.fromEntries(h.entries());
1419 if (Symbol.iterator in h) {
1420 return Object.fromEntries(
1421 Array.from(
1422 h as Iterable<Iterable<string>>,
1423 (entry) => Array.from(entry) as [string, string],
1424 ),
1425 );
1426 }
1427 const headers: Record<string, string | readonly string[]> = {};
1428 for (const [name, value] of Object.entries<
1429 string | readonly string[] | undefined
1430 >(h)) {
1431 if (value !== undefined) headers[name] = value;
1432 }
1433 return headers;
1434 };
1435 return authClient<authOrganizationUpdateResponse>(
1436 getAuthOrganizationUpdateUrl(organizationId),
1437 {
1438 ...options,
1439 method: "PATCH",
1440 headers: {
1441 "Content-Type": "application/json",
1442 ...getHeaders(options?.headers),
1443 },
1444 body: JSON.stringify(updateOrganizationBody),
1445 },
1446 );
1447};
1448
1449export type authOrganizationArchiveResponse200 = {
1450 data: EnvelopeOrganizationSummary;
1451 status: 200;
1452};
1453
1454export type authOrganizationArchiveResponse403 = {
1455 data: EnvelopeNoData;
1456 status: 403;
1457};
1458
1459export type authOrganizationArchiveResponseSuccess =
1460 authOrganizationArchiveResponse200 & {
1461 headers: Headers;
1462 };
1463export type authOrganizationArchiveResponseError =
1464 authOrganizationArchiveResponse403 & {
1465 headers: Headers;
1466 };
1467
1468export type authOrganizationArchiveResponse =
1469 authOrganizationArchiveResponseSuccess | authOrganizationArchiveResponseError;
1470
1471export const getAuthOrganizationArchiveUrl = (organizationId: string) => {
1472 return `/api/v1/organizations/${organizationId}/archive`;
1473};
1474
1475/**
1476 * 需要 `org.archive`。归档后全部权限判定返回 false,可恢复。
1477 * @summary 归档组织
1478 */
1479export const authOrganizationArchive = async (
1480 organizationId: string,
1481 reasonBody: ReasonBody,
1482 options?: Parameters<typeof authClient>[1],
1483): Promise<authOrganizationArchiveResponse> => {
1484 const getHeaders = (
1485 h?: NonNullable<RequestInit["headers"]>,
1486 ): Record<string, string | readonly string[]> => {
1487 if (!h) return {};
1488 if (h instanceof Headers) return Object.fromEntries(h.entries());
1489 if (Symbol.iterator in h) {
1490 return Object.fromEntries(
1491 Array.from(
1492 h as Iterable<Iterable<string>>,
1493 (entry) => Array.from(entry) as [string, string],
1494 ),
1495 );
1496 }
1497 const headers: Record<string, string | readonly string[]> = {};
1498 for (const [name, value] of Object.entries<
1499 string | readonly string[] | undefined
1500 >(h)) {
1501 if (value !== undefined) headers[name] = value;
1502 }
1503 return headers;
1504 };
1505 return authClient<authOrganizationArchiveResponse>(
1506 getAuthOrganizationArchiveUrl(organizationId),
1507 {
1508 ...options,
1509 method: "POST",
1510 headers: {
1511 "Content-Type": "application/json",
1512 ...getHeaders(options?.headers),
1513 },
1514 body: JSON.stringify(reasonBody),
1515 },
1516 );
1517};
1518
1519export type authOrganizationBanListResponse200 = {
1520 data: EnvelopeVecMemberSummary;
1521 status: 200;
1522};
1523
1524export type authOrganizationBanListResponse403 = {
1525 data: EnvelopeNoData;
1526 status: 403;
1527};
1528
1529export type authOrganizationBanListResponseSuccess =
1530 authOrganizationBanListResponse200 & {
1531 headers: Headers;
1532 };
1533export type authOrganizationBanListResponseError =
1534 authOrganizationBanListResponse403 & {
1535 headers: Headers;
1536 };
1537
1538export type authOrganizationBanListResponse =
1539 authOrganizationBanListResponseSuccess | authOrganizationBanListResponseError;
1540
1541export const getAuthOrganizationBanListUrl = (
1542 organizationId: string,
1543 params?: AuthOrganizationBanListParams,
1544) => {
1545 const normalizedParams = new URLSearchParams();
1546
1547 Object.entries(params || {}).forEach(([key, value]) => {
1548 if (value !== undefined) {
1549 normalizedParams.append(key, value === null ? "null" : String(value));
1550 }
1551 });
1552
1553 const stringifiedParams = normalizedParams.toString();
1554
1555 return stringifiedParams.length > 0
1556 ? `/api/v1/organizations/${organizationId}/bans?${stringifiedParams}`
1557 : `/api/v1/organizations/${organizationId}/bans`;
1558};
1559
1560/**
1561 * 需要 `member.ban`。按封禁时间倒序。
1562 * @summary 封禁列表
1563 */
1564export const authOrganizationBanList = async (
1565 organizationId: string,
1566 params?: AuthOrganizationBanListParams,
1567 options?: Parameters<typeof authClient>[1],
1568): Promise<authOrganizationBanListResponse> => {
1569 return authClient<authOrganizationBanListResponse>(
1570 getAuthOrganizationBanListUrl(organizationId, params),
1571 {
1572 ...options,
1573 method: "GET",
1574 },
1575 );
1576};
1577
1578export type authOrganizationBanGetResponse200 = {
1579 data: EnvelopeMemberSummary;
1580 status: 200;
1581};
1582
1583export type authOrganizationBanGetResponse404 = {
1584 data: EnvelopeNoData;
1585 status: 404;
1586};
1587
1588export type authOrganizationBanGetResponseSuccess =
1589 authOrganizationBanGetResponse200 & {
1590 headers: Headers;
1591 };
1592export type authOrganizationBanGetResponseError =
1593 authOrganizationBanGetResponse404 & {
1594 headers: Headers;
1595 };
1596
1597export type authOrganizationBanGetResponse =
1598 authOrganizationBanGetResponseSuccess | authOrganizationBanGetResponseError;
1599
1600export const getAuthOrganizationBanGetUrl = (
1601 organizationId: string,
1602 userId: number,
1603) => {
1604 return `/api/v1/organizations/${organizationId}/bans/${userId}`;
1605};
1606
1607/**
1608 * 需要 `member.ban`。未封禁返回 404。
1609 * @summary 封禁详情
1610 */
1611export const authOrganizationBanGet = async (
1612 organizationId: string,
1613 userId: number,
1614 options?: Parameters<typeof authClient>[1],
1615): Promise<authOrganizationBanGetResponse> => {
1616 return authClient<authOrganizationBanGetResponse>(
1617 getAuthOrganizationBanGetUrl(organizationId, userId),
1618 {
1619 ...options,
1620 method: "GET",
1621 },
1622 );
1623};
1624
1625export type authOrganizationBanDeleteResponse200 = {
1626 data: EnvelopeMemberSummary;
1627 status: 200;
1628};
1629
1630export type authOrganizationBanDeleteResponse404 = {
1631 data: EnvelopeNoData;
1632 status: 404;
1633};
1634
1635export type authOrganizationBanDeleteResponseSuccess =
1636 authOrganizationBanDeleteResponse200 & {
1637 headers: Headers;
1638 };
1639export type authOrganizationBanDeleteResponseError =
1640 authOrganizationBanDeleteResponse404 & {
1641 headers: Headers;
1642 };
1643
1644export type authOrganizationBanDeleteResponse =
1645 | authOrganizationBanDeleteResponseSuccess
1646 | authOrganizationBanDeleteResponseError;
1647
1648export const getAuthOrganizationBanDeleteUrl = (
1649 organizationId: string,
1650 userId: number,
1651) => {
1652 return `/api/v1/organizations/${organizationId}/bans/${userId}`;
1653};
1654
1655/**
1656 * 需要 `member.ban`。等价于按会籍 id 解封,便于按用户维度操作。
1657 * @summary 按用户解封
1658 */
1659export const authOrganizationBanDelete = async (
1660 organizationId: string,
1661 userId: number,
1662 options?: Parameters<typeof authClient>[1],
1663): Promise<authOrganizationBanDeleteResponse> => {
1664 return authClient<authOrganizationBanDeleteResponse>(
1665 getAuthOrganizationBanDeleteUrl(organizationId, userId),
1666 {
1667 ...options,
1668 method: "DELETE",
1669 },
1670 );
1671};
1672
1673export type authOrganizationBanUpdateResponse200 = {
1674 data: EnvelopeMemberSummary;
1675 status: 200;
1676};
1677
1678export type authOrganizationBanUpdateResponse404 = {
1679 data: EnvelopeNoData;
1680 status: 404;
1681};
1682
1683export type authOrganizationBanUpdateResponseSuccess =
1684 authOrganizationBanUpdateResponse200 & {
1685 headers: Headers;
1686 };
1687export type authOrganizationBanUpdateResponseError =
1688 authOrganizationBanUpdateResponse404 & {
1689 headers: Headers;
1690 };
1691
1692export type authOrganizationBanUpdateResponse =
1693 | authOrganizationBanUpdateResponseSuccess
1694 | authOrganizationBanUpdateResponseError;
1695
1696export const getAuthOrganizationBanUpdateUrl = (
1697 organizationId: string,
1698 userId: number,
1699) => {
1700 return `/api/v1/organizations/${organizationId}/bans/${userId}`;
1701};
1702
1703/**
1704 * 需要 `member.ban`。改原因、到期时间与四个放行位;未封禁返回 404。
1705 * @summary 更新封禁
1706 */
1707export const authOrganizationBanUpdate = async (
1708 organizationId: string,
1709 userId: number,
1710 updateBanBody: UpdateBanBody,
1711 options?: Parameters<typeof authClient>[1],
1712): Promise<authOrganizationBanUpdateResponse> => {
1713 const getHeaders = (
1714 h?: NonNullable<RequestInit["headers"]>,
1715 ): Record<string, string | readonly string[]> => {
1716 if (!h) return {};
1717 if (h instanceof Headers) return Object.fromEntries(h.entries());
1718 if (Symbol.iterator in h) {
1719 return Object.fromEntries(
1720 Array.from(
1721 h as Iterable<Iterable<string>>,
1722 (entry) => Array.from(entry) as [string, string],
1723 ),
1724 );
1725 }
1726 const headers: Record<string, string | readonly string[]> = {};
1727 for (const [name, value] of Object.entries<
1728 string | readonly string[] | undefined
1729 >(h)) {
1730 if (value !== undefined) headers[name] = value;
1731 }
1732 return headers;
1733 };
1734 return authClient<authOrganizationBanUpdateResponse>(
1735 getAuthOrganizationBanUpdateUrl(organizationId, userId),
1736 {
1737 ...options,
1738 method: "PATCH",
1739 headers: {
1740 "Content-Type": "application/json",
1741 ...getHeaders(options?.headers),
1742 },
1743 body: JSON.stringify(updateBanBody),
1744 },
1745 );
1746};
1747
1748export type authOrganizationInviteListResponse200 = {
1749 data: EnvelopeVecInviteSummary;
1750 status: 200;
1751};
1752
1753export type authOrganizationInviteListResponse403 = {
1754 data: EnvelopeNoData;
1755 status: 403;
1756};
1757
1758export type authOrganizationInviteListResponseSuccess =
1759 authOrganizationInviteListResponse200 & {
1760 headers: Headers;
1761 };
1762export type authOrganizationInviteListResponseError =
1763 authOrganizationInviteListResponse403 & {
1764 headers: Headers;
1765 };
1766
1767export type authOrganizationInviteListResponse =
1768 | authOrganizationInviteListResponseSuccess
1769 | authOrganizationInviteListResponseError;
1770
1771export const getAuthOrganizationInviteListUrl = (
1772 organizationId: string,
1773 params?: AuthOrganizationInviteListParams,
1774) => {
1775 const normalizedParams = new URLSearchParams();
1776
1777 Object.entries(params || {}).forEach(([key, value]) => {
1778 if (value !== undefined) {
1779 normalizedParams.append(key, value === null ? "null" : String(value));
1780 }
1781 });
1782
1783 const stringifiedParams = normalizedParams.toString();
1784
1785 return stringifiedParams.length > 0
1786 ? `/api/v1/organizations/${organizationId}/invites?${stringifiedParams}`
1787 : `/api/v1/organizations/${organizationId}/invites`;
1788};
1789
1790/**
1791 * 需要 `invite.view`。不含 token 明文。
1792 * @summary 列示邀请
1793 */
1794export const authOrganizationInviteList = async (
1795 organizationId: string,
1796 params?: AuthOrganizationInviteListParams,
1797 options?: Parameters<typeof authClient>[1],
1798): Promise<authOrganizationInviteListResponse> => {
1799 return authClient<authOrganizationInviteListResponse>(
1800 getAuthOrganizationInviteListUrl(organizationId, params),
1801 {
1802 ...options,
1803 method: "GET",
1804 },
1805 );
1806};
1807
1808export type authOrganizationInviteCreateResponse200 = {
1809 data: EnvelopeCreateInviteResponse;
1810 status: 200;
1811};
1812
1813export type authOrganizationInviteCreateResponse403 = {
1814 data: EnvelopeNoData;
1815 status: 403;
1816};
1817
1818export type authOrganizationInviteCreateResponseSuccess =
1819 authOrganizationInviteCreateResponse200 & {
1820 headers: Headers;
1821 };
1822export type authOrganizationInviteCreateResponseError =
1823 authOrganizationInviteCreateResponse403 & {
1824 headers: Headers;
1825 };
1826
1827export type authOrganizationInviteCreateResponse =
1828 | authOrganizationInviteCreateResponseSuccess
1829 | authOrganizationInviteCreateResponseError;
1830
1831export const getAuthOrganizationInviteCreateUrl = (organizationId: string) => {
1832 return `/api/v1/organizations/${organizationId}/invites`;
1833};
1834
1835/**
1836 * 需要 `invite.create`。明文 token 只在创建响应里返回一次,之后只存 sha256。
1837 * @summary 创建邀请
1838 */
1839export const authOrganizationInviteCreate = async (
1840 organizationId: string,
1841 createInviteBody: CreateInviteBody,
1842 options?: Parameters<typeof authClient>[1],
1843): Promise<authOrganizationInviteCreateResponse> => {
1844 const getHeaders = (
1845 h?: NonNullable<RequestInit["headers"]>,
1846 ): Record<string, string | readonly string[]> => {
1847 if (!h) return {};
1848 if (h instanceof Headers) return Object.fromEntries(h.entries());
1849 if (Symbol.iterator in h) {
1850 return Object.fromEntries(
1851 Array.from(
1852 h as Iterable<Iterable<string>>,
1853 (entry) => Array.from(entry) as [string, string],
1854 ),
1855 );
1856 }
1857 const headers: Record<string, string | readonly string[]> = {};
1858 for (const [name, value] of Object.entries<
1859 string | readonly string[] | undefined
1860 >(h)) {
1861 if (value !== undefined) headers[name] = value;
1862 }
1863 return headers;
1864 };
1865 return authClient<authOrganizationInviteCreateResponse>(
1866 getAuthOrganizationInviteCreateUrl(organizationId),
1867 {
1868 ...options,
1869 method: "POST",
1870 headers: {
1871 "Content-Type": "application/json",
1872 ...getHeaders(options?.headers),
1873 },
1874 body: JSON.stringify(createInviteBody),
1875 },
1876 );
1877};
1878
1879export type authOrganizationInviteRevokeResponse200 = {
1880 data: EnvelopeBool;
1881 status: 200;
1882};
1883
1884export type authOrganizationInviteRevokeResponse404 = {
1885 data: EnvelopeNoData;
1886 status: 404;
1887};
1888
1889export type authOrganizationInviteRevokeResponseSuccess =
1890 authOrganizationInviteRevokeResponse200 & {
1891 headers: Headers;
1892 };
1893export type authOrganizationInviteRevokeResponseError =
1894 authOrganizationInviteRevokeResponse404 & {
1895 headers: Headers;
1896 };
1897
1898export type authOrganizationInviteRevokeResponse =
1899 | authOrganizationInviteRevokeResponseSuccess
1900 | authOrganizationInviteRevokeResponseError;
1901
1902export const getAuthOrganizationInviteRevokeUrl = (
1903 organizationId: string,
1904 inviteId: string,
1905) => {
1906 return `/api/v1/organizations/${organizationId}/invites/${inviteId}`;
1907};
1908
1909/**
1910 * 需要 `invite.revoke`。已撤销的邀请再次撤销返回 false。
1911 * @summary 撤销邀请
1912 */
1913export const authOrganizationInviteRevoke = async (
1914 organizationId: string,
1915 inviteId: string,
1916 options?: Parameters<typeof authClient>[1],
1917): Promise<authOrganizationInviteRevokeResponse> => {
1918 return authClient<authOrganizationInviteRevokeResponse>(
1919 getAuthOrganizationInviteRevokeUrl(organizationId, inviteId),
1920 {
1921 ...options,
1922 method: "DELETE",
1923 },
1924 );
1925};
1926
1927export type authOrganizationLeaveResponse200 = {
1928 data: EnvelopeBool;
1929 status: 200;
1930};
1931
1932export type authOrganizationLeaveResponse409 = {
1933 data: EnvelopeNoData;
1934 status: 409;
1935};
1936
1937export type authOrganizationLeaveResponseSuccess =
1938 authOrganizationLeaveResponse200 & {
1939 headers: Headers;
1940 };
1941export type authOrganizationLeaveResponseError =
1942 authOrganizationLeaveResponse409 & {
1943 headers: Headers;
1944 };
1945
1946export type authOrganizationLeaveResponse =
1947 authOrganizationLeaveResponseSuccess | authOrganizationLeaveResponseError;
1948
1949export const getAuthOrganizationLeaveUrl = (organizationId: string) => {
1950 return `/api/v1/organizations/${organizationId}/leave`;
1951};
1952
1953/**
1954 * OWNER 必须先转移所有权,否则返回 409。
1955 * @summary 退出组织
1956 */
1957export const authOrganizationLeave = async (
1958 organizationId: string,
1959 options?: Parameters<typeof authClient>[1],
1960): Promise<authOrganizationLeaveResponse> => {
1961 return authClient<authOrganizationLeaveResponse>(
1962 getAuthOrganizationLeaveUrl(organizationId),
1963 {
1964 ...options,
1965 method: "POST",
1966 },
1967 );
1968};
1969
1970export type authOrganizationMemberListResponse200 = {
1971 data: EnvelopeVecMemberSummary;
1972 status: 200;
1973};
1974
1975export type authOrganizationMemberListResponse403 = {
1976 data: EnvelopeNoData;
1977 status: 403;
1978};
1979
1980export type authOrganizationMemberListResponseSuccess =
1981 authOrganizationMemberListResponse200 & {
1982 headers: Headers;
1983 };
1984export type authOrganizationMemberListResponseError =
1985 authOrganizationMemberListResponse403 & {
1986 headers: Headers;
1987 };
1988
1989export type authOrganizationMemberListResponse =
1990 | authOrganizationMemberListResponseSuccess
1991 | authOrganizationMemberListResponseError;
1992
1993export const getAuthOrganizationMemberListUrl = (
1994 organizationId: string,
1995 params?: AuthOrganizationMemberListParams,
1996) => {
1997 const normalizedParams = new URLSearchParams();
1998
1999 Object.entries(params || {}).forEach(([key, value]) => {
2000 if (value !== undefined) {
2001 normalizedParams.append(key, value === null ? "null" : String(value));
2002 }
2003 });
2004
2005 const stringifiedParams = normalizedParams.toString();
2006
2007 return stringifiedParams.length > 0
2008 ? `/api/v1/organizations/${organizationId}/members?${stringifiedParams}`
2009 : `/api/v1/organizations/${organizationId}/members`;
2010};
2011
2012/**
2013 * 需要 `member.view`。默认只返回活跃成员。
2014 * @summary 列示组织成员
2015 */
2016export const authOrganizationMemberList = async (
2017 organizationId: string,
2018 params?: AuthOrganizationMemberListParams,
2019 options?: Parameters<typeof authClient>[1],
2020): Promise<authOrganizationMemberListResponse> => {
2021 return authClient<authOrganizationMemberListResponse>(
2022 getAuthOrganizationMemberListUrl(organizationId, params),
2023 {
2024 ...options,
2025 method: "GET",
2026 },
2027 );
2028};
2029
2030export type authOrganizationMemberAddResponse200 = {
2031 data: EnvelopeMemberSummary;
2032 status: 200;
2033};
2034
2035export type authOrganizationMemberAddResponse403 = {
2036 data: EnvelopeNoData;
2037 status: 403;
2038};
2039
2040export type authOrganizationMemberAddResponse404 = {
2041 data: EnvelopeNoData;
2042 status: 404;
2043};
2044
2045export type authOrganizationMemberAddResponseSuccess =
2046 authOrganizationMemberAddResponse200 & {
2047 headers: Headers;
2048 };
2049export type authOrganizationMemberAddResponseError = (
2050 authOrganizationMemberAddResponse403 | authOrganizationMemberAddResponse404
2051) & {
2052 headers: Headers;
2053};
2054
2055export type authOrganizationMemberAddResponse =
2056 | authOrganizationMemberAddResponseSuccess
2057 | authOrganizationMemberAddResponseError;
2058
2059export const getAuthOrganizationMemberAddUrl = (organizationId: string) => {
2060 return `/api/v1/organizations/${organizationId}/members`;
2061};
2062
2063/**
2064 * 需要 `member.add`。已退出的会籍按复活处理,已封禁的返回 403。
2065 * @summary 直接添加成员
2066 */
2067export const authOrganizationMemberAdd = async (
2068 organizationId: string,
2069 addMemberBody: AddMemberBody,
2070 options?: Parameters<typeof authClient>[1],
2071): Promise<authOrganizationMemberAddResponse> => {
2072 const getHeaders = (
2073 h?: NonNullable<RequestInit["headers"]>,
2074 ): Record<string, string | readonly string[]> => {
2075 if (!h) return {};
2076 if (h instanceof Headers) return Object.fromEntries(h.entries());
2077 if (Symbol.iterator in h) {
2078 return Object.fromEntries(
2079 Array.from(
2080 h as Iterable<Iterable<string>>,
2081 (entry) => Array.from(entry) as [string, string],
2082 ),
2083 );
2084 }
2085 const headers: Record<string, string | readonly string[]> = {};
2086 for (const [name, value] of Object.entries<
2087 string | readonly string[] | undefined
2088 >(h)) {
2089 if (value !== undefined) headers[name] = value;
2090 }
2091 return headers;
2092 };
2093 return authClient<authOrganizationMemberAddResponse>(
2094 getAuthOrganizationMemberAddUrl(organizationId),
2095 {
2096 ...options,
2097 method: "POST",
2098 headers: {
2099 "Content-Type": "application/json",
2100 ...getHeaders(options?.headers),
2101 },
2102 body: JSON.stringify(addMemberBody),
2103 },
2104 );
2105};
2106
2107export type authOrganizationMemberUpdateSelfResponse200 = {
2108 data: EnvelopeMemberSummary;
2109 status: 200;
2110};
2111
2112export type authOrganizationMemberUpdateSelfResponse403 = {
2113 data: EnvelopeNoData;
2114 status: 403;
2115};
2116
2117export type authOrganizationMemberUpdateSelfResponseSuccess =
2118 authOrganizationMemberUpdateSelfResponse200 & {
2119 headers: Headers;
2120 };
2121export type authOrganizationMemberUpdateSelfResponseError =
2122 authOrganizationMemberUpdateSelfResponse403 & {
2123 headers: Headers;
2124 };
2125
2126export type authOrganizationMemberUpdateSelfResponse =
2127 | authOrganizationMemberUpdateSelfResponseSuccess
2128 | authOrganizationMemberUpdateSelfResponseError;
2129
2130export const getAuthOrganizationMemberUpdateSelfUrl = (
2131 organizationId: string,
2132) => {
2133 return `/api/v1/organizations/${organizationId}/members/@me`;
2134};
2135
2136/**
2137 * 只允许修改自己的别名、头像与通知偏好;无需 `member.role.update`。
2138 * @summary 更新自己的会籍资料
2139 */
2140export const authOrganizationMemberUpdateSelf = async (
2141 organizationId: string,
2142 updateMemberBody: UpdateMemberBody,
2143 options?: Parameters<typeof authClient>[1],
2144): Promise<authOrganizationMemberUpdateSelfResponse> => {
2145 const getHeaders = (
2146 h?: NonNullable<RequestInit["headers"]>,
2147 ): Record<string, string | readonly string[]> => {
2148 if (!h) return {};
2149 if (h instanceof Headers) return Object.fromEntries(h.entries());
2150 if (Symbol.iterator in h) {
2151 return Object.fromEntries(
2152 Array.from(
2153 h as Iterable<Iterable<string>>,
2154 (entry) => Array.from(entry) as [string, string],
2155 ),
2156 );
2157 }
2158 const headers: Record<string, string | readonly string[]> = {};
2159 for (const [name, value] of Object.entries<
2160 string | readonly string[] | undefined
2161 >(h)) {
2162 if (value !== undefined) headers[name] = value;
2163 }
2164 return headers;
2165 };
2166 return authClient<authOrganizationMemberUpdateSelfResponse>(
2167 getAuthOrganizationMemberUpdateSelfUrl(organizationId),
2168 {
2169 ...options,
2170 method: "PATCH",
2171 headers: {
2172 "Content-Type": "application/json",
2173 ...getHeaders(options?.headers),
2174 },
2175 body: JSON.stringify(updateMemberBody),
2176 },
2177 );
2178};
2179
2180export type authOrganizationMemberGetResponse200 = {
2181 data: EnvelopeMemberSummary;
2182 status: 200;
2183};
2184
2185export type authOrganizationMemberGetResponse404 = {
2186 data: EnvelopeNoData;
2187 status: 404;
2188};
2189
2190export type authOrganizationMemberGetResponseSuccess =
2191 authOrganizationMemberGetResponse200 & {
2192 headers: Headers;
2193 };
2194export type authOrganizationMemberGetResponseError =
2195 authOrganizationMemberGetResponse404 & {
2196 headers: Headers;
2197 };
2198
2199export type authOrganizationMemberGetResponse =
2200 | authOrganizationMemberGetResponseSuccess
2201 | authOrganizationMemberGetResponseError;
2202
2203export const getAuthOrganizationMemberGetUrl = (
2204 organizationId: string,
2205 memberId: string,
2206) => {
2207 return `/api/v1/organizations/${organizationId}/members/${memberId}`;
2208};
2209
2210/**
2211 * 需要 `member.view`。包含别名、通知偏好与封禁附加信息。
2212 * @summary 成员详情
2213 */
2214export const authOrganizationMemberGet = async (
2215 organizationId: string,
2216 memberId: string,
2217 options?: Parameters<typeof authClient>[1],
2218): Promise<authOrganizationMemberGetResponse> => {
2219 return authClient<authOrganizationMemberGetResponse>(
2220 getAuthOrganizationMemberGetUrl(organizationId, memberId),
2221 {
2222 ...options,
2223 method: "GET",
2224 },
2225 );
2226};
2227
2228export type authOrganizationMemberRemoveResponse200 = {
2229 data: EnvelopeBool;
2230 status: 200;
2231};
2232
2233export type authOrganizationMemberRemoveResponse403 = {
2234 data: EnvelopeNoData;
2235 status: 403;
2236};
2237
2238export type authOrganizationMemberRemoveResponseSuccess =
2239 authOrganizationMemberRemoveResponse200 & {
2240 headers: Headers;
2241 };
2242export type authOrganizationMemberRemoveResponseError =
2243 authOrganizationMemberRemoveResponse403 & {
2244 headers: Headers;
2245 };
2246
2247export type authOrganizationMemberRemoveResponse =
2248 | authOrganizationMemberRemoveResponseSuccess
2249 | authOrganizationMemberRemoveResponseError;
2250
2251export const getAuthOrganizationMemberRemoveUrl = (
2252 organizationId: string,
2253 memberId: string,
2254 params?: AuthOrganizationMemberRemoveParams,
2255) => {
2256 const normalizedParams = new URLSearchParams();
2257
2258 Object.entries(params || {}).forEach(([key, value]) => {
2259 if (value !== undefined) {
2260 normalizedParams.append(key, value === null ? "null" : String(value));
2261 }
2262 });
2263
2264 const stringifiedParams = normalizedParams.toString();
2265
2266 return stringifiedParams.length > 0
2267 ? `/api/v1/organizations/${organizationId}/members/${memberId}?${stringifiedParams}`
2268 : `/api/v1/organizations/${organizationId}/members/${memberId}`;
2269};
2270
2271/**
2272 * 需要 `member.remove`。OWNER 不能移除,需先转移所有权。会籍行保留用于复活。
2273 * @summary 移除成员
2274 */
2275export const authOrganizationMemberRemove = async (
2276 organizationId: string,
2277 memberId: string,
2278 params?: AuthOrganizationMemberRemoveParams,
2279 options?: Parameters<typeof authClient>[1],
2280): Promise<authOrganizationMemberRemoveResponse> => {
2281 return authClient<authOrganizationMemberRemoveResponse>(
2282 getAuthOrganizationMemberRemoveUrl(organizationId, memberId, params),
2283 {
2284 ...options,
2285 method: "DELETE",
2286 },
2287 );
2288};
2289
2290export type authOrganizationMemberUpdateResponse200 = {
2291 data: EnvelopeMemberSummary;
2292 status: 200;
2293};
2294
2295export type authOrganizationMemberUpdateResponse403 = {
2296 data: EnvelopeNoData;
2297 status: 403;
2298};
2299
2300export type authOrganizationMemberUpdateResponse409 = {
2301 data: EnvelopeNoData;
2302 status: 409;
2303};
2304
2305export type authOrganizationMemberUpdateResponseSuccess =
2306 authOrganizationMemberUpdateResponse200 & {
2307 headers: Headers;
2308 };
2309export type authOrganizationMemberUpdateResponseError = (
2310 | authOrganizationMemberUpdateResponse403
2311 | authOrganizationMemberUpdateResponse409
2312) & {
2313 headers: Headers;
2314};
2315
2316export type authOrganizationMemberUpdateResponse =
2317 | authOrganizationMemberUpdateResponseSuccess
2318 | authOrganizationMemberUpdateResponseError;
2319
2320export const getAuthOrganizationMemberUpdateUrl = (
2321 organizationId: string,
2322 memberId: string,
2323) => {
2324 return `/api/v1/organizations/${organizationId}/members/${memberId}`;
2325};
2326
2327/**
2328 * 需要 `member.role.update`。修改别名、头像、通知偏好与免打扰;封禁中的会籍走封禁接口。
2329 * @summary 更新成员资料
2330 */
2331export const authOrganizationMemberUpdate = async (
2332 organizationId: string,
2333 memberId: string,
2334 updateMemberBody: UpdateMemberBody,
2335 options?: Parameters<typeof authClient>[1],
2336): Promise<authOrganizationMemberUpdateResponse> => {
2337 const getHeaders = (
2338 h?: NonNullable<RequestInit["headers"]>,
2339 ): Record<string, string | readonly string[]> => {
2340 if (!h) return {};
2341 if (h instanceof Headers) return Object.fromEntries(h.entries());
2342 if (Symbol.iterator in h) {
2343 return Object.fromEntries(
2344 Array.from(
2345 h as Iterable<Iterable<string>>,
2346 (entry) => Array.from(entry) as [string, string],
2347 ),
2348 );
2349 }
2350 const headers: Record<string, string | readonly string[]> = {};
2351 for (const [name, value] of Object.entries<
2352 string | readonly string[] | undefined
2353 >(h)) {
2354 if (value !== undefined) headers[name] = value;
2355 }
2356 return headers;
2357 };
2358 return authClient<authOrganizationMemberUpdateResponse>(
2359 getAuthOrganizationMemberUpdateUrl(organizationId, memberId),
2360 {
2361 ...options,
2362 method: "PATCH",
2363 headers: {
2364 "Content-Type": "application/json",
2365 ...getHeaders(options?.headers),
2366 },
2367 body: JSON.stringify(updateMemberBody),
2368 },
2369 );
2370};
2371
2372export type authOrganizationMemberBanResponse200 = {
2373 data: EnvelopeMemberSummary;
2374 status: 200;
2375};
2376
2377export type authOrganizationMemberBanResponse403 = {
2378 data: EnvelopeNoData;
2379 status: 403;
2380};
2381
2382export type authOrganizationMemberBanResponseSuccess =
2383 authOrganizationMemberBanResponse200 & {
2384 headers: Headers;
2385 };
2386export type authOrganizationMemberBanResponseError =
2387 authOrganizationMemberBanResponse403 & {
2388 headers: Headers;
2389 };
2390
2391export type authOrganizationMemberBanResponse =
2392 | authOrganizationMemberBanResponseSuccess
2393 | authOrganizationMemberBanResponseError;
2394
2395export const getAuthOrganizationMemberBanUrl = (
2396 organizationId: string,
2397 memberId: string,
2398) => {
2399 return `/api/v1/organizations/${organizationId}/members/${memberId}/ban`;
2400};
2401
2402/**
2403 * 写 banned_at 并清空角色绑定与直挂权限。封禁优先于一切授权。
2404 * @summary 封禁成员
2405 */
2406export const authOrganizationMemberBan = async (
2407 organizationId: string,
2408 memberId: string,
2409 banMemberBody: BanMemberBody,
2410 options?: Parameters<typeof authClient>[1],
2411): Promise<authOrganizationMemberBanResponse> => {
2412 const getHeaders = (
2413 h?: NonNullable<RequestInit["headers"]>,
2414 ): Record<string, string | readonly string[]> => {
2415 if (!h) return {};
2416 if (h instanceof Headers) return Object.fromEntries(h.entries());
2417 if (Symbol.iterator in h) {
2418 return Object.fromEntries(
2419 Array.from(
2420 h as Iterable<Iterable<string>>,
2421 (entry) => Array.from(entry) as [string, string],
2422 ),
2423 );
2424 }
2425 const headers: Record<string, string | readonly string[]> = {};
2426 for (const [name, value] of Object.entries<
2427 string | readonly string[] | undefined
2428 >(h)) {
2429 if (value !== undefined) headers[name] = value;
2430 }
2431 return headers;
2432 };
2433 return authClient<authOrganizationMemberBanResponse>(
2434 getAuthOrganizationMemberBanUrl(organizationId, memberId),
2435 {
2436 ...options,
2437 method: "POST",
2438 headers: {
2439 "Content-Type": "application/json",
2440 ...getHeaders(options?.headers),
2441 },
2442 body: JSON.stringify(banMemberBody),
2443 },
2444 );
2445};
2446
2447export type authOrganizationMemberPermissionsResponse200 = {
2448 data: EnvelopeVecString;
2449 status: 200;
2450};
2451
2452export type authOrganizationMemberPermissionsResponse403 = {
2453 data: EnvelopeNoData;
2454 status: 403;
2455};
2456
2457export type authOrganizationMemberPermissionsResponseSuccess =
2458 authOrganizationMemberPermissionsResponse200 & {
2459 headers: Headers;
2460 };
2461export type authOrganizationMemberPermissionsResponseError =
2462 authOrganizationMemberPermissionsResponse403 & {
2463 headers: Headers;
2464 };
2465
2466export type authOrganizationMemberPermissionsResponse =
2467 | authOrganizationMemberPermissionsResponseSuccess
2468 | authOrganizationMemberPermissionsResponseError;
2469
2470export const getAuthOrganizationMemberPermissionsUrl = (
2471 organizationId: string,
2472 memberId: string,
2473) => {
2474 return `/api/v1/organizations/${organizationId}/members/${memberId}/permissions`;
2475};
2476
2477/**
2478 * 整表替换语义。需要 `role.permission.update`,OWNER 不接受直挂覆盖。
2479 * @summary 设置成员直挂权限
2480 */
2481export const authOrganizationMemberPermissions = async (
2482 organizationId: string,
2483 memberId: string,
2484 setRolePermissionsBody: SetRolePermissionsBody,
2485 options?: Parameters<typeof authClient>[1],
2486): Promise<authOrganizationMemberPermissionsResponse> => {
2487 const getHeaders = (
2488 h?: NonNullable<RequestInit["headers"]>,
2489 ): Record<string, string | readonly string[]> => {
2490 if (!h) return {};
2491 if (h instanceof Headers) return Object.fromEntries(h.entries());
2492 if (Symbol.iterator in h) {
2493 return Object.fromEntries(
2494 Array.from(
2495 h as Iterable<Iterable<string>>,
2496 (entry) => Array.from(entry) as [string, string],
2497 ),
2498 );
2499 }
2500 const headers: Record<string, string | readonly string[]> = {};
2501 for (const [name, value] of Object.entries<
2502 string | readonly string[] | undefined
2503 >(h)) {
2504 if (value !== undefined) headers[name] = value;
2505 }
2506 return headers;
2507 };
2508 return authClient<authOrganizationMemberPermissionsResponse>(
2509 getAuthOrganizationMemberPermissionsUrl(organizationId, memberId),
2510 {
2511 ...options,
2512 method: "PUT",
2513 headers: {
2514 "Content-Type": "application/json",
2515 ...getHeaders(options?.headers),
2516 },
2517 body: JSON.stringify(setRolePermissionsBody),
2518 },
2519 );
2520};
2521
2522export type authOrganizationMemberRoleResponse200 = {
2523 data: EnvelopeMemberSummary;
2524 status: 200;
2525};
2526
2527export type authOrganizationMemberRoleResponse403 = {
2528 data: EnvelopeNoData;
2529 status: 403;
2530};
2531
2532export type authOrganizationMemberRoleResponse409 = {
2533 data: EnvelopeNoData;
2534 status: 409;
2535};
2536
2537export type authOrganizationMemberRoleResponseSuccess =
2538 authOrganizationMemberRoleResponse200 & {
2539 headers: Headers;
2540 };
2541export type authOrganizationMemberRoleResponseError = (
2542 authOrganizationMemberRoleResponse403 | authOrganizationMemberRoleResponse409
2543) & {
2544 headers: Headers;
2545};
2546
2547export type authOrganizationMemberRoleResponse =
2548 | authOrganizationMemberRoleResponseSuccess
2549 | authOrganizationMemberRoleResponseError;
2550
2551export const getAuthOrganizationMemberRoleUrl = (
2552 organizationId: string,
2553 memberId: string,
2554) => {
2555 return `/api/v1/organizations/${organizationId}/members/${memberId}/role`;
2556};
2557
2558/**
2559 * 只接受 MEMBER 与 ADMIN。OWNER 只能通过转移所有权变更。
2560 * @summary 改粗粒度角色
2561 */
2562export const authOrganizationMemberRole = async (
2563 organizationId: string,
2564 memberId: string,
2565 setMemberRoleBody: SetMemberRoleBody,
2566 options?: Parameters<typeof authClient>[1],
2567): Promise<authOrganizationMemberRoleResponse> => {
2568 const getHeaders = (
2569 h?: NonNullable<RequestInit["headers"]>,
2570 ): Record<string, string | readonly string[]> => {
2571 if (!h) return {};
2572 if (h instanceof Headers) return Object.fromEntries(h.entries());
2573 if (Symbol.iterator in h) {
2574 return Object.fromEntries(
2575 Array.from(
2576 h as Iterable<Iterable<string>>,
2577 (entry) => Array.from(entry) as [string, string],
2578 ),
2579 );
2580 }
2581 const headers: Record<string, string | readonly string[]> = {};
2582 for (const [name, value] of Object.entries<
2583 string | readonly string[] | undefined
2584 >(h)) {
2585 if (value !== undefined) headers[name] = value;
2586 }
2587 return headers;
2588 };
2589 return authClient<authOrganizationMemberRoleResponse>(
2590 getAuthOrganizationMemberRoleUrl(organizationId, memberId),
2591 {
2592 ...options,
2593 method: "PATCH",
2594 headers: {
2595 "Content-Type": "application/json",
2596 ...getHeaders(options?.headers),
2597 },
2598 body: JSON.stringify(setMemberRoleBody),
2599 },
2600 );
2601};
2602
2603export type authOrganizationMemberUnbanResponse200 = {
2604 data: EnvelopeMemberSummary;
2605 status: 200;
2606};
2607
2608export type authOrganizationMemberUnbanResponse403 = {
2609 data: EnvelopeNoData;
2610 status: 403;
2611};
2612
2613export type authOrganizationMemberUnbanResponseSuccess =
2614 authOrganizationMemberUnbanResponse200 & {
2615 headers: Headers;
2616 };
2617export type authOrganizationMemberUnbanResponseError =
2618 authOrganizationMemberUnbanResponse403 & {
2619 headers: Headers;
2620 };
2621
2622export type authOrganizationMemberUnbanResponse =
2623 | authOrganizationMemberUnbanResponseSuccess
2624 | authOrganizationMemberUnbanResponseError;
2625
2626export const getAuthOrganizationMemberUnbanUrl = (
2627 organizationId: string,
2628 memberId: string,
2629) => {
2630 return `/api/v1/organizations/${organizationId}/members/${memberId}/unban`;
2631};
2632
2633/**
2634 * 清空 banned_at。已清空的角色不会自动恢复。
2635 * @summary 解封成员
2636 */
2637export const authOrganizationMemberUnban = async (
2638 organizationId: string,
2639 memberId: string,
2640 options?: Parameters<typeof authClient>[1],
2641): Promise<authOrganizationMemberUnbanResponse> => {
2642 return authClient<authOrganizationMemberUnbanResponse>(
2643 getAuthOrganizationMemberUnbanUrl(organizationId, memberId),
2644 {
2645 ...options,
2646 method: "POST",
2647 },
2648 );
2649};
2650
2651export type authOrganizationPermissionCheckResponse200 = {
2652 data: EnvelopePermissionCheck;
2653 status: 200;
2654};
2655
2656export type authOrganizationPermissionCheckResponse403 = {
2657 data: EnvelopeNoData;
2658 status: 403;
2659};
2660
2661export type authOrganizationPermissionCheckResponseSuccess =
2662 authOrganizationPermissionCheckResponse200 & {
2663 headers: Headers;
2664 };
2665export type authOrganizationPermissionCheckResponseError =
2666 authOrganizationPermissionCheckResponse403 & {
2667 headers: Headers;
2668 };
2669
2670export type authOrganizationPermissionCheckResponse =
2671 | authOrganizationPermissionCheckResponseSuccess
2672 | authOrganizationPermissionCheckResponseError;
2673
2674export const getAuthOrganizationPermissionCheckUrl = (
2675 organizationId: string,
2676) => {
2677 return `/api/v1/organizations/${organizationId}/permissions/check`;
2678};
2679
2680/**
2681 * 拒绝不作为错误返回:`allowed=false` 附 `reason` 与 `matched_by`,便于调用方聚合。
2682 * @summary 单权限判定
2683 */
2684export const authOrganizationPermissionCheck = async (
2685 organizationId: string,
2686 checkPermissionBody: CheckPermissionBody,
2687 options?: Parameters<typeof authClient>[1],
2688): Promise<authOrganizationPermissionCheckResponse> => {
2689 const getHeaders = (
2690 h?: NonNullable<RequestInit["headers"]>,
2691 ): Record<string, string | readonly string[]> => {
2692 if (!h) return {};
2693 if (h instanceof Headers) return Object.fromEntries(h.entries());
2694 if (Symbol.iterator in h) {
2695 return Object.fromEntries(
2696 Array.from(
2697 h as Iterable<Iterable<string>>,
2698 (entry) => Array.from(entry) as [string, string],
2699 ),
2700 );
2701 }
2702 const headers: Record<string, string | readonly string[]> = {};
2703 for (const [name, value] of Object.entries<
2704 string | readonly string[] | undefined
2705 >(h)) {
2706 if (value !== undefined) headers[name] = value;
2707 }
2708 return headers;
2709 };
2710 return authClient<authOrganizationPermissionCheckResponse>(
2711 getAuthOrganizationPermissionCheckUrl(organizationId),
2712 {
2713 ...options,
2714 method: "POST",
2715 headers: {
2716 "Content-Type": "application/json",
2717 ...getHeaders(options?.headers),
2718 },
2719 body: JSON.stringify(checkPermissionBody),
2720 },
2721 );
2722};
2723
2724export type authOrganizationRestoreResponse200 = {
2725 data: EnvelopeOrganizationSummary;
2726 status: 200;
2727};
2728
2729export type authOrganizationRestoreResponse403 = {
2730 data: EnvelopeNoData;
2731 status: 403;
2732};
2733
2734export type authOrganizationRestoreResponseSuccess =
2735 authOrganizationRestoreResponse200 & {
2736 headers: Headers;
2737 };
2738export type authOrganizationRestoreResponseError =
2739 authOrganizationRestoreResponse403 & {
2740 headers: Headers;
2741 };
2742
2743export type authOrganizationRestoreResponse =
2744 authOrganizationRestoreResponseSuccess | authOrganizationRestoreResponseError;
2745
2746export const getAuthOrganizationRestoreUrl = (organizationId: string) => {
2747 return `/api/v1/organizations/${organizationId}/restore`;
2748};
2749
2750/**
2751 * 仅 OWNER 或平台管理员可执行。
2752 * @summary 恢复归档组织
2753 */
2754export const authOrganizationRestore = async (
2755 organizationId: string,
2756 options?: Parameters<typeof authClient>[1],
2757): Promise<authOrganizationRestoreResponse> => {
2758 return authClient<authOrganizationRestoreResponse>(
2759 getAuthOrganizationRestoreUrl(organizationId),
2760 {
2761 ...options,
2762 method: "POST",
2763 },
2764 );
2765};
2766
2767export type authOrganizationRoleListResponse200 = {
2768 data: EnvelopeVecRoleSummary;
2769 status: 200;
2770};
2771
2772export type authOrganizationRoleListResponse403 = {
2773 data: EnvelopeNoData;
2774 status: 403;
2775};
2776
2777export type authOrganizationRoleListResponseSuccess =
2778 authOrganizationRoleListResponse200 & {
2779 headers: Headers;
2780 };
2781export type authOrganizationRoleListResponseError =
2782 authOrganizationRoleListResponse403 & {
2783 headers: Headers;
2784 };
2785
2786export type authOrganizationRoleListResponse =
2787 | authOrganizationRoleListResponseSuccess
2788 | authOrganizationRoleListResponseError;
2789
2790export const getAuthOrganizationRoleListUrl = (organizationId: string) => {
2791 return `/api/v1/organizations/${organizationId}/roles`;
2792};
2793
2794/**
2795 * 需要 `role.view`。含内置 owner/admin/member 三个系统角色。
2796 * @summary 列示组织角色
2797 */
2798export const authOrganizationRoleList = async (
2799 organizationId: string,
2800 options?: Parameters<typeof authClient>[1],
2801): Promise<authOrganizationRoleListResponse> => {
2802 return authClient<authOrganizationRoleListResponse>(
2803 getAuthOrganizationRoleListUrl(organizationId),
2804 {
2805 ...options,
2806 method: "GET",
2807 },
2808 );
2809};
2810
2811export type authOrganizationRoleCreateResponse200 = {
2812 data: EnvelopeRoleSummary;
2813 status: 200;
2814};
2815
2816export type authOrganizationRoleCreateResponse409 = {
2817 data: EnvelopeNoData;
2818 status: 409;
2819};
2820
2821export type authOrganizationRoleCreateResponseSuccess =
2822 authOrganizationRoleCreateResponse200 & {
2823 headers: Headers;
2824 };
2825export type authOrganizationRoleCreateResponseError =
2826 authOrganizationRoleCreateResponse409 & {
2827 headers: Headers;
2828 };
2829
2830export type authOrganizationRoleCreateResponse =
2831 | authOrganizationRoleCreateResponseSuccess
2832 | authOrganizationRoleCreateResponseError;
2833
2834export const getAuthOrganizationRoleCreateUrl = (organizationId: string) => {
2835 return `/api/v1/organizations/${organizationId}/roles`;
2836};
2837
2838/**
2839 * 需要 `role.create`。key 在组织内唯一,权限键必须在白名单内。
2840 * @summary 新建角色
2841 */
2842export const authOrganizationRoleCreate = async (
2843 organizationId: string,
2844 createRoleBody: CreateRoleBody,
2845 options?: Parameters<typeof authClient>[1],
2846): Promise<authOrganizationRoleCreateResponse> => {
2847 const getHeaders = (
2848 h?: NonNullable<RequestInit["headers"]>,
2849 ): Record<string, string | readonly string[]> => {
2850 if (!h) return {};
2851 if (h instanceof Headers) return Object.fromEntries(h.entries());
2852 if (Symbol.iterator in h) {
2853 return Object.fromEntries(
2854 Array.from(
2855 h as Iterable<Iterable<string>>,
2856 (entry) => Array.from(entry) as [string, string],
2857 ),
2858 );
2859 }
2860 const headers: Record<string, string | readonly string[]> = {};
2861 for (const [name, value] of Object.entries<
2862 string | readonly string[] | undefined
2863 >(h)) {
2864 if (value !== undefined) headers[name] = value;
2865 }
2866 return headers;
2867 };
2868 return authClient<authOrganizationRoleCreateResponse>(
2869 getAuthOrganizationRoleCreateUrl(organizationId),
2870 {
2871 ...options,
2872 method: "POST",
2873 headers: {
2874 "Content-Type": "application/json",
2875 ...getHeaders(options?.headers),
2876 },
2877 body: JSON.stringify(createRoleBody),
2878 },
2879 );
2880};
2881
2882export type authOrganizationRoleAssignResponse200 = {
2883 data: EnvelopeVecString;
2884 status: 200;
2885};
2886
2887export type authOrganizationRoleAssignResponse404 = {
2888 data: EnvelopeNoData;
2889 status: 404;
2890};
2891
2892export type authOrganizationRoleAssignResponseSuccess =
2893 authOrganizationRoleAssignResponse200 & {
2894 headers: Headers;
2895 };
2896export type authOrganizationRoleAssignResponseError =
2897 authOrganizationRoleAssignResponse404 & {
2898 headers: Headers;
2899 };
2900
2901export type authOrganizationRoleAssignResponse =
2902 | authOrganizationRoleAssignResponseSuccess
2903 | authOrganizationRoleAssignResponseError;
2904
2905export const getAuthOrganizationRoleAssignUrl = (organizationId: string) => {
2906 return `/api/v1/organizations/${organizationId}/roles/assign`;
2907};
2908
2909/**
2910 * 需要 `role.assign`。重复绑定幂等。
2911 * @summary 绑定角色到成员
2912 */
2913export const authOrganizationRoleAssign = async (
2914 organizationId: string,
2915 assignRoleBody: AssignRoleBody,
2916 options?: Parameters<typeof authClient>[1],
2917): Promise<authOrganizationRoleAssignResponse> => {
2918 const getHeaders = (
2919 h?: NonNullable<RequestInit["headers"]>,
2920 ): Record<string, string | readonly string[]> => {
2921 if (!h) return {};
2922 if (h instanceof Headers) return Object.fromEntries(h.entries());
2923 if (Symbol.iterator in h) {
2924 return Object.fromEntries(
2925 Array.from(
2926 h as Iterable<Iterable<string>>,
2927 (entry) => Array.from(entry) as [string, string],
2928 ),
2929 );
2930 }
2931 const headers: Record<string, string | readonly string[]> = {};
2932 for (const [name, value] of Object.entries<
2933 string | readonly string[] | undefined
2934 >(h)) {
2935 if (value !== undefined) headers[name] = value;
2936 }
2937 return headers;
2938 };
2939 return authClient<authOrganizationRoleAssignResponse>(
2940 getAuthOrganizationRoleAssignUrl(organizationId),
2941 {
2942 ...options,
2943 method: "POST",
2944 headers: {
2945 "Content-Type": "application/json",
2946 ...getHeaders(options?.headers),
2947 },
2948 body: JSON.stringify(assignRoleBody),
2949 },
2950 );
2951};
2952
2953export type authOrganizationRoleUnassignResponse200 = {
2954 data: EnvelopeVecString;
2955 status: 200;
2956};
2957
2958export type authOrganizationRoleUnassignResponse403 = {
2959 data: EnvelopeNoData;
2960 status: 403;
2961};
2962
2963export type authOrganizationRoleUnassignResponseSuccess =
2964 authOrganizationRoleUnassignResponse200 & {
2965 headers: Headers;
2966 };
2967export type authOrganizationRoleUnassignResponseError =
2968 authOrganizationRoleUnassignResponse403 & {
2969 headers: Headers;
2970 };
2971
2972export type authOrganizationRoleUnassignResponse =
2973 | authOrganizationRoleUnassignResponseSuccess
2974 | authOrganizationRoleUnassignResponseError;
2975
2976export const getAuthOrganizationRoleUnassignUrl = (organizationId: string) => {
2977 return `/api/v1/organizations/${organizationId}/roles/unassign`;
2978};
2979
2980/**
2981 * 需要 `role.assign`。系统角色不可解绑。
2982 * @summary 解绑成员角色
2983 */
2984export const authOrganizationRoleUnassign = async (
2985 organizationId: string,
2986 assignRoleBody: AssignRoleBody,
2987 options?: Parameters<typeof authClient>[1],
2988): Promise<authOrganizationRoleUnassignResponse> => {
2989 const getHeaders = (
2990 h?: NonNullable<RequestInit["headers"]>,
2991 ): Record<string, string | readonly string[]> => {
2992 if (!h) return {};
2993 if (h instanceof Headers) return Object.fromEntries(h.entries());
2994 if (Symbol.iterator in h) {
2995 return Object.fromEntries(
2996 Array.from(
2997 h as Iterable<Iterable<string>>,
2998 (entry) => Array.from(entry) as [string, string],
2999 ),
3000 );
3001 }
3002 const headers: Record<string, string | readonly string[]> = {};
3003 for (const [name, value] of Object.entries<
3004 string | readonly string[] | undefined
3005 >(h)) {
3006 if (value !== undefined) headers[name] = value;
3007 }
3008 return headers;
3009 };
3010 return authClient<authOrganizationRoleUnassignResponse>(
3011 getAuthOrganizationRoleUnassignUrl(organizationId),
3012 {
3013 ...options,
3014 method: "POST",
3015 headers: {
3016 "Content-Type": "application/json",
3017 ...getHeaders(options?.headers),
3018 },
3019 body: JSON.stringify(assignRoleBody),
3020 },
3021 );
3022};
3023
3024export type authOrganizationRoleGetResponse200 = {
3025 data: EnvelopeRoleSummary;
3026 status: 200;
3027};
3028
3029export type authOrganizationRoleGetResponse404 = {
3030 data: EnvelopeNoData;
3031 status: 404;
3032};
3033
3034export type authOrganizationRoleGetResponseSuccess =
3035 authOrganizationRoleGetResponse200 & {
3036 headers: Headers;
3037 };
3038export type authOrganizationRoleGetResponseError =
3039 authOrganizationRoleGetResponse404 & {
3040 headers: Headers;
3041 };
3042
3043export type authOrganizationRoleGetResponse =
3044 authOrganizationRoleGetResponseSuccess | authOrganizationRoleGetResponseError;
3045
3046export const getAuthOrganizationRoleGetUrl = (
3047 organizationId: string,
3048 roleId: string,
3049) => {
3050 return `/api/v1/organizations/${organizationId}/roles/${roleId}`;
3051};
3052
3053/**
3054 * 需要 `role.view`。
3055 * @summary 角色详情
3056 */
3057export const authOrganizationRoleGet = async (
3058 organizationId: string,
3059 roleId: string,
3060 options?: Parameters<typeof authClient>[1],
3061): Promise<authOrganizationRoleGetResponse> => {
3062 return authClient<authOrganizationRoleGetResponse>(
3063 getAuthOrganizationRoleGetUrl(organizationId, roleId),
3064 {
3065 ...options,
3066 method: "GET",
3067 },
3068 );
3069};
3070
3071export type authOrganizationRoleDeleteResponse200 = {
3072 data: EnvelopeBool;
3073 status: 200;
3074};
3075
3076export type authOrganizationRoleDeleteResponse409 = {
3077 data: EnvelopeNoData;
3078 status: 409;
3079};
3080
3081export type authOrganizationRoleDeleteResponseSuccess =
3082 authOrganizationRoleDeleteResponse200 & {
3083 headers: Headers;
3084 };
3085export type authOrganizationRoleDeleteResponseError =
3086 authOrganizationRoleDeleteResponse409 & {
3087 headers: Headers;
3088 };
3089
3090export type authOrganizationRoleDeleteResponse =
3091 | authOrganizationRoleDeleteResponseSuccess
3092 | authOrganizationRoleDeleteResponseError;
3093
3094export const getAuthOrganizationRoleDeleteUrl = (
3095 organizationId: string,
3096 roleId: string,
3097) => {
3098 return `/api/v1/organizations/${organizationId}/roles/${roleId}`;
3099};
3100
3101/**
3102 * 需要 `role.delete`。系统角色不可删;仍有成员绑定时返回 409。
3103 * @summary 删除角色
3104 */
3105export const authOrganizationRoleDelete = async (
3106 organizationId: string,
3107 roleId: string,
3108 options?: Parameters<typeof authClient>[1],
3109): Promise<authOrganizationRoleDeleteResponse> => {
3110 return authClient<authOrganizationRoleDeleteResponse>(
3111 getAuthOrganizationRoleDeleteUrl(organizationId, roleId),
3112 {
3113 ...options,
3114 method: "DELETE",
3115 },
3116 );
3117};
3118
3119export type authOrganizationRoleUpdateResponse200 = {
3120 data: EnvelopeRoleSummary;
3121 status: 200;
3122};
3123
3124export type authOrganizationRoleUpdateResponse409 = {
3125 data: EnvelopeNoData;
3126 status: 409;
3127};
3128
3129export type authOrganizationRoleUpdateResponseSuccess =
3130 authOrganizationRoleUpdateResponse200 & {
3131 headers: Headers;
3132 };
3133export type authOrganizationRoleUpdateResponseError =
3134 authOrganizationRoleUpdateResponse409 & {
3135 headers: Headers;
3136 };
3137
3138export type authOrganizationRoleUpdateResponse =
3139 | authOrganizationRoleUpdateResponseSuccess
3140 | authOrganizationRoleUpdateResponseError;
3141
3142export const getAuthOrganizationRoleUpdateUrl = (
3143 organizationId: string,
3144 roleId: string,
3145) => {
3146 return `/api/v1/organizations/${organizationId}/roles/${roleId}`;
3147};
3148
3149/**
3150 * 需要 `role.update`。OWNER 系统角色不允许改 rank 与 default_role。
3151 * @summary 修改角色
3152 */
3153export const authOrganizationRoleUpdate = async (
3154 organizationId: string,
3155 roleId: string,
3156 updateRoleBody: UpdateRoleBody,
3157 options?: Parameters<typeof authClient>[1],
3158): Promise<authOrganizationRoleUpdateResponse> => {
3159 const getHeaders = (
3160 h?: NonNullable<RequestInit["headers"]>,
3161 ): Record<string, string | readonly string[]> => {
3162 if (!h) return {};
3163 if (h instanceof Headers) return Object.fromEntries(h.entries());
3164 if (Symbol.iterator in h) {
3165 return Object.fromEntries(
3166 Array.from(
3167 h as Iterable<Iterable<string>>,
3168 (entry) => Array.from(entry) as [string, string],
3169 ),
3170 );
3171 }
3172 const headers: Record<string, string | readonly string[]> = {};
3173 for (const [name, value] of Object.entries<
3174 string | readonly string[] | undefined
3175 >(h)) {
3176 if (value !== undefined) headers[name] = value;
3177 }
3178 return headers;
3179 };
3180 return authClient<authOrganizationRoleUpdateResponse>(
3181 getAuthOrganizationRoleUpdateUrl(organizationId, roleId),
3182 {
3183 ...options,
3184 method: "PATCH",
3185 headers: {
3186 "Content-Type": "application/json",
3187 ...getHeaders(options?.headers),
3188 },
3189 body: JSON.stringify(updateRoleBody),
3190 },
3191 );
3192};
3193
3194export type authOrganizationRoleJoinResponse200 = {
3195 data: EnvelopeMemberSummary;
3196 status: 200;
3197};
3198
3199export type authOrganizationRoleJoinResponse403 = {
3200 data: EnvelopeNoData;
3201 status: 403;
3202};
3203
3204export type authOrganizationRoleJoinResponseSuccess =
3205 authOrganizationRoleJoinResponse200 & {
3206 headers: Headers;
3207 };
3208export type authOrganizationRoleJoinResponseError =
3209 authOrganizationRoleJoinResponse403 & {
3210 headers: Headers;
3211 };
3212
3213export type authOrganizationRoleJoinResponse =
3214 | authOrganizationRoleJoinResponseSuccess
3215 | authOrganizationRoleJoinResponseError;
3216
3217export const getAuthOrganizationRoleJoinUrl = (
3218 organizationId: string,
3219 roleId: string,
3220) => {
3221 return `/api/v1/organizations/${organizationId}/roles/${roleId}/join`;
3222};
3223
3224/**
3225 * 只允许 `self_assignable = true` 的非内置角色。
3226 * @summary 自助加入角色
3227 */
3228export const authOrganizationRoleJoin = async (
3229 organizationId: string,
3230 roleId: string,
3231 options?: Parameters<typeof authClient>[1],
3232): Promise<authOrganizationRoleJoinResponse> => {
3233 return authClient<authOrganizationRoleJoinResponse>(
3234 getAuthOrganizationRoleJoinUrl(organizationId, roleId),
3235 {
3236 ...options,
3237 method: "POST",
3238 },
3239 );
3240};
3241
3242export type authOrganizationRoleLeaveResponse200 = {
3243 data: EnvelopeMemberSummary;
3244 status: 200;
3245};
3246
3247export type authOrganizationRoleLeaveResponse403 = {
3248 data: EnvelopeNoData;
3249 status: 403;
3250};
3251
3252export type authOrganizationRoleLeaveResponseSuccess =
3253 authOrganizationRoleLeaveResponse200 & {
3254 headers: Headers;
3255 };
3256export type authOrganizationRoleLeaveResponseError =
3257 authOrganizationRoleLeaveResponse403 & {
3258 headers: Headers;
3259 };
3260
3261export type authOrganizationRoleLeaveResponse =
3262 | authOrganizationRoleLeaveResponseSuccess
3263 | authOrganizationRoleLeaveResponseError;
3264
3265export const getAuthOrganizationRoleLeaveUrl = (
3266 organizationId: string,
3267 roleId: string,
3268) => {
3269 return `/api/v1/organizations/${organizationId}/roles/${roleId}/join`;
3270};
3271
3272/**
3273 * 只允许 `self_assignable = true` 的非内置角色;重复退出视为成功。
3274 * @summary 自助退出角色
3275 */
3276export const authOrganizationRoleLeave = async (
3277 organizationId: string,
3278 roleId: string,
3279 options?: Parameters<typeof authClient>[1],
3280): Promise<authOrganizationRoleLeaveResponse> => {
3281 return authClient<authOrganizationRoleLeaveResponse>(
3282 getAuthOrganizationRoleLeaveUrl(organizationId, roleId),
3283 {
3284 ...options,
3285 method: "DELETE",
3286 },
3287 );
3288};
3289
3290export type authOrganizationRolePermissionsResponse200 = {
3291 data: EnvelopeRoleSummary;
3292 status: 200;
3293};
3294
3295export type authOrganizationRolePermissionsResponse403 = {
3296 data: EnvelopeNoData;
3297 status: 403;
3298};
3299
3300export type authOrganizationRolePermissionsResponseSuccess =
3301 authOrganizationRolePermissionsResponse200 & {
3302 headers: Headers;
3303 };
3304export type authOrganizationRolePermissionsResponseError =
3305 authOrganizationRolePermissionsResponse403 & {
3306 headers: Headers;
3307 };
3308
3309export type authOrganizationRolePermissionsResponse =
3310 | authOrganizationRolePermissionsResponseSuccess
3311 | authOrganizationRolePermissionsResponseError;
3312
3313export const getAuthOrganizationRolePermissionsUrl = (
3314 organizationId: string,
3315 roleId: string,
3316) => {
3317 return `/api/v1/organizations/${organizationId}/roles/${roleId}/permissions`;
3318};
3319
3320/**
3321 * 整体替换语义,是角色权限的唯一写入口。需要 `role.permission.update`。
3322 * @summary 设置角色权限
3323 */
3324export const authOrganizationRolePermissions = async (
3325 organizationId: string,
3326 roleId: string,
3327 setRolePermissionsBody: SetRolePermissionsBody,
3328 options?: Parameters<typeof authClient>[1],
3329): Promise<authOrganizationRolePermissionsResponse> => {
3330 const getHeaders = (
3331 h?: NonNullable<RequestInit["headers"]>,
3332 ): Record<string, string | readonly string[]> => {
3333 if (!h) return {};
3334 if (h instanceof Headers) return Object.fromEntries(h.entries());
3335 if (Symbol.iterator in h) {
3336 return Object.fromEntries(
3337 Array.from(
3338 h as Iterable<Iterable<string>>,
3339 (entry) => Array.from(entry) as [string, string],
3340 ),
3341 );
3342 }
3343 const headers: Record<string, string | readonly string[]> = {};
3344 for (const [name, value] of Object.entries<
3345 string | readonly string[] | undefined
3346 >(h)) {
3347 if (value !== undefined) headers[name] = value;
3348 }
3349 return headers;
3350 };
3351 return authClient<authOrganizationRolePermissionsResponse>(
3352 getAuthOrganizationRolePermissionsUrl(organizationId, roleId),
3353 {
3354 ...options,
3355 method: "PUT",
3356 headers: {
3357 "Content-Type": "application/json",
3358 ...getHeaders(options?.headers),
3359 },
3360 body: JSON.stringify(setRolePermissionsBody),
3361 },
3362 );
3363};
3364
3365export type authOrganizationTransferResponse200 = {
3366 data: EnvelopeOrganizationSummary;
3367 status: 200;
3368};
3369
3370export type authOrganizationTransferResponse403 = {
3371 data: EnvelopeNoData;
3372 status: 403;
3373};
3374
3375export type authOrganizationTransferResponse404 = {
3376 data: EnvelopeNoData;
3377 status: 404;
3378};
3379
3380export type authOrganizationTransferResponseSuccess =
3381 authOrganizationTransferResponse200 & {
3382 headers: Headers;
3383 };
3384export type authOrganizationTransferResponseError = (
3385 authOrganizationTransferResponse403 | authOrganizationTransferResponse404
3386) & {
3387 headers: Headers;
3388};
3389
3390export type authOrganizationTransferResponse =
3391 | authOrganizationTransferResponseSuccess
3392 | authOrganizationTransferResponseError;
3393
3394export const getAuthOrganizationTransferUrl = (organizationId: string) => {
3395 return `/api/v1/organizations/${organizationId}/transfer`;
3396};
3397
3398/**
3399 * 目标必须是活跃成员。原 Owner 降为 ADMIN。
3400 * @summary 转移 OWNER
3401 */
3402export const authOrganizationTransfer = async (
3403 organizationId: string,
3404 transferBody: TransferBody,
3405 options?: Parameters<typeof authClient>[1],
3406): Promise<authOrganizationTransferResponse> => {
3407 const getHeaders = (
3408 h?: NonNullable<RequestInit["headers"]>,
3409 ): Record<string, string | readonly string[]> => {
3410 if (!h) return {};
3411 if (h instanceof Headers) return Object.fromEntries(h.entries());
3412 if (Symbol.iterator in h) {
3413 return Object.fromEntries(
3414 Array.from(
3415 h as Iterable<Iterable<string>>,
3416 (entry) => Array.from(entry) as [string, string],
3417 ),
3418 );
3419 }
3420 const headers: Record<string, string | readonly string[]> = {};
3421 for (const [name, value] of Object.entries<
3422 string | readonly string[] | undefined
3423 >(h)) {
3424 if (value !== undefined) headers[name] = value;
3425 }
3426 return headers;
3427 };
3428 return authClient<authOrganizationTransferResponse>(
3429 getAuthOrganizationTransferUrl(organizationId),
3430 {
3431 ...options,
3432 method: "POST",
3433 headers: {
3434 "Content-Type": "application/json",
3435 ...getHeaders(options?.headers),
3436 },
3437 body: JSON.stringify(transferBody),