mirror of
https://github.com/labring/FastGPT.git
synced 2025-07-24 22:03:54 +00:00

* feat: dataset controllers feat: dataset schema fix: add missing type to dataset schema Signed-off-by: FinleyGe <m13203533462@163.com> * feat: dataset list api Signed-off-by: FinleyGe <m13203533462@163.com> * chore: all dataset api Signed-off-by: FinleyGe <m13203533462@163.com> * feat: new auth dataset method Signed-off-by: FinleyGe <m13203533462@163.com> * chore: use new auth method in detail, paths. feat: add new param defaultPermission to create api Signed-off-by: FinleyGe <m13203533462@163.com> * chore: app auth params Signed-off-by: FinleyGe <m13203533462@163.com> * chore: use new auth method Signed-off-by: FinleyGe <m13203533462@163.com> * feat: new auth collection and file method Signed-off-by: FinleyGe <m13203533462@163.com> * chore: dataset collection api new auth Signed-off-by: FinleyGe <m13203533462@163.com> * chore: create/*.ts auth Signed-off-by: FinleyGe <m13203533462@163.com> * chore: dataset auth Signed-off-by: FinleyGe <m13203533462@163.com> * fix: import paths Signed-off-by: FinleyGe <m13203533462@163.com> * feat: dataset collaborator Signed-off-by: FinleyGe <m13203533462@163.com> * chore: dataset frontend feat: dataset list frontend feat: dataset detail Signed-off-by: FinleyGe <m13203533462@163.com> * feat: finish the dataset permission fix: ts errors Signed-off-by: FinleyGe <m13203533462@163.com> * fix: empty response of collection api Signed-off-by: FinleyGe <m13203533462@163.com> * chore: adjust the code * chore: adjust the code * chore: i18n * fix: ts error * fix: fe CollectionCard permission --------- Signed-off-by: FinleyGe <m13203533462@163.com>
69 lines
1.7 KiB
TypeScript
69 lines
1.7 KiB
TypeScript
import { AppDetailType } from '@fastgpt/global/core/app/type';
|
|
import { OutLinkSchema } from '@fastgpt/global/support/outLink/type';
|
|
import { parseHeaderCert } from '../controller';
|
|
import { MongoOutLink } from '../../outLink/schema';
|
|
import { OutLinkErrEnum } from '@fastgpt/global/common/error/code/outLink';
|
|
import { ManagePermissionVal } from '@fastgpt/global/support/permission/constant';
|
|
import { AuthPropsType } from '../type/auth';
|
|
import { AuthResponseType } from '../type/auth';
|
|
import { authAppByTmbId } from '../app/auth';
|
|
|
|
/* crud outlink permission */
|
|
export async function authOutLinkCrud({
|
|
outLinkId,
|
|
per,
|
|
...props
|
|
}: AuthPropsType & {
|
|
outLinkId: string;
|
|
}): Promise<
|
|
AuthResponseType & {
|
|
app: AppDetailType;
|
|
outLink: OutLinkSchema;
|
|
}
|
|
> {
|
|
const result = await parseHeaderCert(props);
|
|
const { tmbId, teamId } = result;
|
|
|
|
const { app, outLink } = await (async () => {
|
|
const outLink = await MongoOutLink.findOne({ _id: outLinkId, teamId });
|
|
if (!outLink) {
|
|
throw new Error(OutLinkErrEnum.unExist);
|
|
}
|
|
|
|
const { app } = await authAppByTmbId({
|
|
tmbId,
|
|
appId: outLink.appId,
|
|
per: ManagePermissionVal
|
|
});
|
|
|
|
return {
|
|
outLink,
|
|
app
|
|
};
|
|
})();
|
|
|
|
return {
|
|
...result,
|
|
permission: app.permission,
|
|
app,
|
|
outLink
|
|
};
|
|
}
|
|
|
|
/* outLink exist and it app exist */
|
|
export async function authOutLinkValid({ shareId }: { shareId?: string }) {
|
|
if (!shareId) {
|
|
return Promise.reject(OutLinkErrEnum.linkUnInvalid);
|
|
}
|
|
const shareChat = await MongoOutLink.findOne({ shareId });
|
|
|
|
if (!shareChat) {
|
|
return Promise.reject(OutLinkErrEnum.linkUnInvalid);
|
|
}
|
|
|
|
return {
|
|
appId: shareChat.appId,
|
|
shareChat
|
|
};
|
|
}
|