@blueking/ai-ui-sdk 0.1.2-beta.2 → 0.1.2-beta.20

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.
Files changed (140) hide show
  1. package/dist/components/render-aside/index.vue.css +9 -9
  2. package/dist/components/render-aside/index.vue.js +1 -1
  3. package/dist/components/render-auth/auth-dialog-fn.d.ts +2 -0
  4. package/dist/components/render-auth/auth-dialog-fn.ts.js +14 -0
  5. package/dist/components/render-auth/auth-dialog.script.vue.js.js +113 -0
  6. package/dist/components/render-auth/auth-dialog.vue.css +4 -0
  7. package/dist/components/render-auth/auth-dialog.vue.d.ts +5 -0
  8. package/dist/components/render-auth/auth-dialog.vue.js +4 -0
  9. package/dist/components/render-auto-height-textarea/index.vue.css +11 -11
  10. package/dist/components/render-auto-height-textarea/index.vue.d.ts +2 -2
  11. package/dist/components/render-auto-height-textarea/index.vue.js +1 -1
  12. package/dist/components/render-choose-tag/index.script.vue.js.js +242 -0
  13. package/dist/components/render-choose-tag/index.vue.css +39 -0
  14. package/dist/components/render-choose-tag/index.vue.d.ts +12 -0
  15. package/dist/components/render-choose-tag/index.vue.js +5 -0
  16. package/dist/components/render-collapse/index.vue.css +2 -2
  17. package/dist/components/render-collapse/index.vue.js +1 -1
  18. package/dist/components/render-dataset/components/edit-dataset-data/index.script.vue.js.js +163 -171
  19. package/dist/components/render-dataset/components/edit-dataset-data/index.vue.css +3 -3
  20. package/dist/components/render-dataset/components/edit-dataset-data/index.vue.d.ts +4 -0
  21. package/dist/components/render-dataset/components/edit-dataset-data/index.vue.js +1 -1
  22. package/dist/components/render-dataset/components/operation-record/index.script.vue.js.js +88 -89
  23. package/dist/components/render-dataset/components/operation-record/index.vue.css +4 -4
  24. package/dist/components/render-dataset/components/operation-record/index.vue.d.ts +7 -1
  25. package/dist/components/render-dataset/components/operation-record/index.vue.js +1 -1
  26. package/dist/components/render-dataset/components/operation-record/table/index.script.vue.js.js +4 -3
  27. package/dist/components/render-dataset/components/operation-record/table/index.vue.css +1 -1
  28. package/dist/components/render-dataset/components/operation-record/table/index.vue.d.ts +1 -0
  29. package/dist/components/render-dataset/components/operation-record/table/index.vue.js +1 -1
  30. package/dist/components/render-dataset/components/operation-record/view-op-result/index.vue.css +2 -2
  31. package/dist/components/render-dataset/components/operation-record/view-op-result/index.vue.js +1 -1
  32. package/dist/components/render-dataset/components/plus-dataset/dataset-footer.script.vue.js.js +6 -4
  33. package/dist/components/render-dataset/components/plus-dataset/dataset-footer.vue.d.ts +4 -2
  34. package/dist/components/render-dataset/components/plus-dataset/dataset-form.script.vue.js +86 -23
  35. package/dist/components/render-dataset/components/plus-dataset/dataset-form.vue.d.ts +3 -0
  36. package/dist/components/render-dataset/components/plus-dataset/index.script.vue.js.js +98 -58
  37. package/dist/components/render-dataset/components/plus-dataset/index.vue.css +2 -2
  38. package/dist/components/render-dataset/components/plus-dataset/index.vue.d.ts +6 -0
  39. package/dist/components/render-dataset/components/plus-dataset/index.vue.js +1 -1
  40. package/dist/components/render-dataset/components/plus-dataset-data/form/dataset.script.vue.js.js +10 -3
  41. package/dist/components/render-dataset/components/plus-dataset-data/form/dataset.vue.d.ts +2 -0
  42. package/dist/components/render-dataset/components/plus-dataset-data/form/file.script.vue.js.js +4 -3
  43. package/dist/components/render-dataset/components/plus-dataset-data/form/file.vue.d.ts +1 -0
  44. package/dist/components/render-dataset/components/plus-dataset-data/form/footer.script.vue.js.js +4 -3
  45. package/dist/components/render-dataset/components/plus-dataset-data/form/footer.vue.css +1 -1
  46. package/dist/components/render-dataset/components/plus-dataset-data/form/footer.vue.d.ts +1 -0
  47. package/dist/components/render-dataset/components/plus-dataset-data/form/footer.vue.js +1 -1
  48. package/dist/components/render-dataset/components/plus-dataset-data/form/index.script.vue.js.js +22 -6
  49. package/dist/components/render-dataset/components/plus-dataset-data/form/index.vue.css +2 -2
  50. package/dist/components/render-dataset/components/plus-dataset-data/form/index.vue.d.ts +2 -0
  51. package/dist/components/render-dataset/components/plus-dataset-data/form/index.vue.js +1 -1
  52. package/dist/components/render-dataset/components/plus-dataset-data/form/manual.script.vue.js +4 -3
  53. package/dist/components/render-dataset/components/plus-dataset-data/form/manual.vue.d.ts +1 -0
  54. package/dist/components/render-dataset/components/plus-dataset-data/index.script.vue.js.js +49 -7
  55. package/dist/components/render-dataset/components/plus-dataset-data/index.vue.d.ts +3 -0
  56. package/dist/components/render-dataset/components/search-dataset/index.script.vue.js.js +21 -6
  57. package/dist/components/render-dataset/components/search-dataset/index.vue.d.ts +2 -0
  58. package/dist/components/render-dataset/components/source-type-icon/index.script.vue.js.js +2 -2
  59. package/dist/components/render-dataset/components/source-type-icon/index.vue.js +0 -2
  60. package/dist/components/render-dataset/index.script.vue.js.js +34 -8
  61. package/dist/components/render-dataset/index.vue.css +1 -1
  62. package/dist/components/render-dataset/index.vue.d.ts +2 -0
  63. package/dist/components/render-dataset/index.vue.js +1 -1
  64. package/dist/components/render-dataset-detail/components/header.script.vue.js.js +10 -35
  65. package/dist/components/render-dataset-detail/components/header.vue.d.ts +1 -2
  66. package/dist/components/render-dataset-detail/index.script.vue.js.js +86 -13
  67. package/dist/components/render-dataset-detail/index.vue.d.ts +2 -0
  68. package/dist/components/render-dataset-detail-origin-data/components/batch-operation/index.script.vue.js.js +49 -17
  69. package/dist/components/render-dataset-detail-origin-data/components/batch-operation/index.vue.d.ts +4 -0
  70. package/dist/components/render-dataset-detail-origin-data/components/table/index.script.vue.js +261 -170
  71. package/dist/components/render-dataset-detail-origin-data/components/table/index.vue.css +1 -1
  72. package/dist/components/render-dataset-detail-origin-data/components/table/index.vue.d.ts +3 -0
  73. package/dist/components/render-dataset-detail-origin-data/components/table/index.vue.js +1 -1
  74. package/dist/components/render-dataset-detail-origin-data/index.script.vue.js.js +33 -6
  75. package/dist/components/render-dataset-detail-origin-data/index.vue.css +3 -3
  76. package/dist/components/render-dataset-detail-origin-data/index.vue.d.ts +3 -0
  77. package/dist/components/render-dataset-detail-origin-data/index.vue.js +1 -1
  78. package/dist/components/render-dataset-list/components/main.script.vue.js.js +56 -13
  79. package/dist/components/render-dataset-list/components/main.vue.css +3 -3
  80. package/dist/components/render-dataset-list/components/main.vue.d.ts +4 -0
  81. package/dist/components/render-dataset-list/components/main.vue.js +1 -1
  82. package/dist/components/render-dataset-list/components/table.script.vue.js.js +442 -143
  83. package/dist/components/render-dataset-list/components/table.vue.d.ts +4 -0
  84. package/dist/components/render-dataset-list/index.script.vue.js.js +13 -2
  85. package/dist/components/render-dataset-list/index.vue.d.ts +4 -0
  86. package/dist/components/render-expand-collapse/index.vue.css +3 -3
  87. package/dist/components/render-expand-collapse/index.vue.js +1 -1
  88. package/dist/components/render-file-card/index.vue.css +11 -11
  89. package/dist/components/render-file-card/index.vue.js +1 -1
  90. package/dist/components/render-file-type-icon/index.vue.css +5 -5
  91. package/dist/components/render-file-type-icon/index.vue.js +1 -1
  92. package/dist/components/render-header/index.vue.css +5 -5
  93. package/dist/components/render-header/index.vue.js +1 -1
  94. package/dist/components/render-router-tab/index.vue.css +3 -3
  95. package/dist/components/render-router-tab/index.vue.js +1 -1
  96. package/dist/{component.d.ts → components.d.ts} +3 -1
  97. package/dist/{component.ts.js → components.ts.js} +3 -1
  98. package/dist/enums.d.ts +1 -0
  99. package/dist/enums.ts.js +1 -0
  100. package/dist/event/index.d.ts +3 -3
  101. package/dist/event/index.ts.js +2 -2
  102. package/dist/events.d.ts +1 -0
  103. package/dist/events.ts.js +1 -0
  104. package/dist/helpers.d.ts +1 -0
  105. package/dist/helpers.ts.js +1 -0
  106. package/dist/hooks/use-chat.d.ts +16 -0
  107. package/dist/hooks/use-chat.ts.js +13 -12
  108. package/dist/hooks/use-dataset-http.d.ts +3 -2
  109. package/dist/hooks/use-dataset-http.ts.js +107 -21
  110. package/dist/hooks/use-form-rule.d.ts +29 -0
  111. package/dist/hooks/use-form-rule.ts.js +101 -0
  112. package/dist/hooks/use-meta-http.d.ts +16 -0
  113. package/dist/hooks/use-meta-http.ts.js +83 -0
  114. package/dist/hooks/use-permission-http.d.ts +7 -0
  115. package/dist/hooks/use-permission-http.ts.js +26 -0
  116. package/dist/hooks/use-permission.d.ts +9 -0
  117. package/dist/hooks/use-permission.ts.js +100 -0
  118. package/dist/hooks/use-session-http.d.ts +1 -1
  119. package/dist/hooks/use-session-http.ts.js +37 -11
  120. package/dist/hooks.d.ts +7 -0
  121. package/dist/hooks.ts.js +7 -0
  122. package/dist/http/fetch/index.ts.js +59 -6
  123. package/dist/http/helper/dataset.ts.js +16 -3
  124. package/dist/http/helper/permission.d.ts +7 -1
  125. package/dist/http/helper/permission.ts.js +11 -1
  126. package/dist/https.d.ts +2 -0
  127. package/dist/https.ts.js +2 -0
  128. package/dist/transforms.d.ts +4 -0
  129. package/dist/transforms.ts.js +4 -0
  130. package/dist/types/dataset.d.ts +19 -1
  131. package/dist/types/enum.d.ts +46 -1
  132. package/dist/types/enum.ts.js +48 -0
  133. package/dist/types/meta.d.ts +3 -0
  134. package/dist/types/permission.d.ts +43 -0
  135. package/dist/types.d.ts +6 -0
  136. package/dist/types.ts.js +6 -0
  137. package/package.json +35 -10
  138. package/dist/components/render-dataset/components/source-type-icon/index.vue.css +0 -10
  139. package/dist/main.d.ts +0 -22
  140. package/dist/main.ts.js +0 -28
@@ -0,0 +1,29 @@
1
+ import { type Ref } from 'vue';
2
+ import { Modules } from '@/types/enum';
3
+ export declare const useFormRule: (apiPrefix: string, spaceId?: Ref<string>) => {
4
+ codeRule: {
5
+ validator: (value: string) => boolean;
6
+ message: string;
7
+ trigger: string;
8
+ };
9
+ getApiUrlRule: () => {
10
+ validator: (value: string) => boolean;
11
+ message: string;
12
+ trigger: string;
13
+ };
14
+ getNameRule: (type: Modules) => {
15
+ validator: (value: string) => Promise<boolean>;
16
+ message: () => string;
17
+ trigger: string;
18
+ };
19
+ getCodeRule: (type: Modules, getIsEdit: () => boolean, getData?: () => Record<string, unknown>) => {
20
+ validator: (value: string) => Promise<boolean>;
21
+ message: () => string;
22
+ trigger: string;
23
+ };
24
+ getLengthRule: (label: string, num: number) => {
25
+ validator: (value: string) => boolean;
26
+ message: string;
27
+ trigger: string;
28
+ };
29
+ };
@@ -0,0 +1,101 @@
1
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
2
+ try {
3
+ var info = gen[key](arg);
4
+ var value = info.value;
5
+ } catch (error) {
6
+ reject(error);
7
+ return;
8
+ }
9
+ if (info.done) {
10
+ resolve(value);
11
+ } else {
12
+ Promise.resolve(value).then(_next, _throw);
13
+ }
14
+ }
15
+ function _async_to_generator(fn) {
16
+ return function() {
17
+ var self = this, args = arguments;
18
+ return new Promise(function(resolve, reject) {
19
+ var gen = fn.apply(self, args);
20
+ function _next(value) {
21
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
22
+ }
23
+ function _throw(err) {
24
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
25
+ }
26
+ _next(undefined);
27
+ });
28
+ };
29
+ }
30
+ import { useMetaHttp } from './use-meta-http.ts.js';
31
+ export const useFormRule = (apiPrefix, spaceId)=>{
32
+ const { nameValidator, codeValidator } = useMetaHttp(apiPrefix, spaceId);
33
+ let nameErrorMessage = '';
34
+ let codeErrorMessage = '';
35
+ const codeRule = {
36
+ validator: (value)=>/^[a-zA-Z0-9-]+$/.test(value),
37
+ message: '需要是英文字符、数字、中划线',
38
+ trigger: 'change'
39
+ };
40
+ const getNameRule = (type)=>({
41
+ validator: function() {
42
+ var _ref = _async_to_generator(function*(value) {
43
+ try {
44
+ nameErrorMessage = '';
45
+ const res = yield nameValidator(value, type)();
46
+ return res.data;
47
+ } catch (error) {
48
+ nameErrorMessage = error.message;
49
+ return false;
50
+ }
51
+ });
52
+ return function(value) {
53
+ return _ref.apply(this, arguments);
54
+ };
55
+ }(),
56
+ message: ()=>nameErrorMessage,
57
+ trigger: 'change'
58
+ });
59
+ const getCodeRule = (type, getIsEdit, getData)=>({
60
+ validator: function() {
61
+ var _ref = _async_to_generator(function*(value) {
62
+ try {
63
+ codeErrorMessage = '';
64
+ // 编辑态不校验code
65
+ const isEdit = getIsEdit();
66
+ if (isEdit) {
67
+ return true;
68
+ }
69
+ // 新建态校验code
70
+ const res = yield codeValidator(value, type, getData === null || getData === void 0 ? void 0 : getData())();
71
+ return res.data;
72
+ } catch (error) {
73
+ codeErrorMessage = error.message;
74
+ return false;
75
+ }
76
+ });
77
+ return function(value) {
78
+ return _ref.apply(this, arguments);
79
+ };
80
+ }(),
81
+ message: ()=>codeErrorMessage,
82
+ trigger: 'change'
83
+ });
84
+ const getLengthRule = (label, num)=>({
85
+ validator: (value)=>value.length <= num,
86
+ message: `${label}长度不能超过${num}`,
87
+ trigger: 'change'
88
+ });
89
+ const getApiUrlRule = ()=>({
90
+ validator: (value)=>/https?:\/\//.test(value),
91
+ message: '需要是http://或者https://开头的字符串',
92
+ trigger: 'change'
93
+ });
94
+ return {
95
+ codeRule,
96
+ getApiUrlRule,
97
+ getNameRule,
98
+ getCodeRule,
99
+ getLengthRule
100
+ };
101
+ };
@@ -0,0 +1,16 @@
1
+ import { type Ref } from 'vue';
2
+ import { Modules } from '@/types/enum';
3
+ import type { ITagApi } from '@/types/meta';
4
+ export declare const useMetaHttp: (apiPrefix: string, spaceId?: Ref<string>) => {
5
+ nameValidator: (name: string, type: Modules) => () => Promise<{
6
+ data: boolean;
7
+ message: string;
8
+ }>;
9
+ codeValidator: (code: string, type: Modules, data?: Record<string, unknown>) => () => Promise<{
10
+ data: boolean;
11
+ message: string;
12
+ }>;
13
+ getTags: () => Promise<string[]>;
14
+ plusTag: (tagName: string) => Promise<ITagApi>;
15
+ checkTag: (tagName: string) => Promise<boolean>;
16
+ };
@@ -0,0 +1,83 @@
1
+ function _define_property(obj, key, value) {
2
+ if (key in obj) {
3
+ Object.defineProperty(obj, key, {
4
+ value: value,
5
+ enumerable: true,
6
+ configurable: true,
7
+ writable: true
8
+ });
9
+ } else {
10
+ obj[key] = value;
11
+ }
12
+ return obj;
13
+ }
14
+ function _object_spread(target) {
15
+ for(var i = 1; i < arguments.length; i++){
16
+ var source = arguments[i] != null ? arguments[i] : {};
17
+ var ownKeys = Object.keys(source);
18
+ if (typeof Object.getOwnPropertySymbols === "function") {
19
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
20
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
21
+ }));
22
+ }
23
+ ownKeys.forEach(function(key) {
24
+ _define_property(target, key, source[key]);
25
+ });
26
+ }
27
+ return target;
28
+ }
29
+ import fetch from '../http/fetch/index.ts.js';
30
+ const metaPerfix = 'meta/v1';
31
+ export const useMetaHttp = (apiPrefix, spaceId)=>{
32
+ // 名称校验
33
+ const nameValidator = (name, type)=>()=>fetch.get(`${apiPrefix}/${metaPerfix}/name_valid/`, {
34
+ name,
35
+ type
36
+ }, {
37
+ globalError: false,
38
+ headers: {
39
+ 'x-space-id': spaceId === null || spaceId === void 0 ? void 0 : spaceId.value
40
+ }
41
+ });
42
+ // code校验
43
+ const codeValidator = (code, type, data)=>()=>fetch.get(`${apiPrefix}/${metaPerfix}/code_valid/`, _object_spread({
44
+ code,
45
+ type
46
+ }, data), {
47
+ globalError: false,
48
+ headers: {
49
+ 'x-space-id': spaceId === null || spaceId === void 0 ? void 0 : spaceId.value
50
+ }
51
+ });
52
+ // 获取tag列表
53
+ const getTags = ()=>fetch.get(`${apiPrefix}/${metaPerfix}/tag/`, undefined, {
54
+ headers: {
55
+ 'x-space-id': spaceId === null || spaceId === void 0 ? void 0 : spaceId.value
56
+ }
57
+ }).then((result)=>result.map((item)=>item.tag_name));
58
+ // 新增 tag
59
+ const plusTag = (tagName)=>fetch.post(`${apiPrefix}/${metaPerfix}/tag/`, {
60
+ tag_name: tagName
61
+ }, {
62
+ globalError: false,
63
+ headers: {
64
+ 'x-space-id': spaceId === null || spaceId === void 0 ? void 0 : spaceId.value
65
+ }
66
+ });
67
+ // check tag
68
+ const checkTag = (tagName)=>fetch.get(`${apiPrefix}/${metaPerfix}/tag/check/`, {
69
+ tag_name: tagName
70
+ }, {
71
+ globalError: false,
72
+ headers: {
73
+ 'x-space-id': spaceId === null || spaceId === void 0 ? void 0 : spaceId.value
74
+ }
75
+ });
76
+ return {
77
+ nameValidator,
78
+ codeValidator,
79
+ getTags,
80
+ plusTag,
81
+ checkTag
82
+ };
83
+ };
@@ -0,0 +1,7 @@
1
+ import { type Ref } from 'vue';
2
+ import { PlatformPermissionAction, ResourcePermissionAction } from '@/types/enum';
3
+ import type { IPermissionApplyData } from '@/types/permission';
4
+ export declare const usePermissionHttp: (apiPrefix: string, spaceId?: Ref<string>) => {
5
+ checkPermission: (action_ids: Array<ResourcePermissionAction | PlatformPermissionAction>, resources?: string | number) => Promise<import("@/types/permission").ICheckPermission>;
6
+ getPermissionData: (action_ids: Array<ResourcePermissionAction | PlatformPermissionAction>, resource_id?: string | number) => Promise<IPermissionApplyData>;
7
+ };
@@ -0,0 +1,26 @@
1
+ import fetch from '../http/fetch/index.ts.js';
2
+ import { transferCheckPermissionApi } from '../http/helper/permission.ts.js';
3
+ export const usePermissionHttp = (apiPrefix, spaceId)=>{
4
+ // 检查是否有权限
5
+ const checkPermission = (action_ids, resources)=>fetch.post(`${apiPrefix}/iam/v1/auth/is_allowed/`, {
6
+ action_ids,
7
+ resources
8
+ }, {
9
+ headers: {
10
+ 'x-space-id': spaceId === null || spaceId === void 0 ? void 0 : spaceId.value
11
+ }
12
+ }).then((res)=>transferCheckPermissionApi(res));
13
+ // 获取权限数据
14
+ const getPermissionData = (action_ids, resource_id)=>fetch.post(`${apiPrefix}/iam/v1/auth/apply_data/`, {
15
+ action_ids,
16
+ resource_id
17
+ }, {
18
+ headers: {
19
+ 'x-space-id': spaceId === null || spaceId === void 0 ? void 0 : spaceId.value
20
+ }
21
+ });
22
+ return {
23
+ checkPermission,
24
+ getPermissionData
25
+ };
26
+ };
@@ -0,0 +1,9 @@
1
+ import { type Ref } from 'vue';
2
+ import { PlatformPermissionAction, ResourcePermissionAction } from '@/types/enum';
3
+ export declare function usePermission(apiPrefix: string, spaceId?: Ref<string>, backgroundColor?: string): {
4
+ handleMouseEnter: (authorized: boolean) => void;
5
+ handleMouseMove: (event: MouseEvent, authorized: boolean) => void;
6
+ handleMouseLeave: () => void;
7
+ handleMouseClick: (callback: Function, authorized: boolean, actionIds: Array<ResourcePermissionAction>, resourceId?: string | number) => Promise<void>;
8
+ handleCheckPermission: (actionIds: Array<ResourcePermissionAction | PlatformPermissionAction>, resourceId?: string | number) => Promise<boolean>;
9
+ };
@@ -0,0 +1,100 @@
1
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
2
+ try {
3
+ var info = gen[key](arg);
4
+ var value = info.value;
5
+ } catch (error) {
6
+ reject(error);
7
+ return;
8
+ }
9
+ if (info.done) {
10
+ resolve(value);
11
+ } else {
12
+ Promise.resolve(value).then(_next, _throw);
13
+ }
14
+ }
15
+ function _async_to_generator(fn) {
16
+ return function() {
17
+ var self = this, args = arguments;
18
+ return new Promise(function(resolve, reject) {
19
+ var gen = fn.apply(self, args);
20
+ function _next(value) {
21
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
22
+ }
23
+ function _throw(err) {
24
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
25
+ }
26
+ _next(undefined);
27
+ });
28
+ };
29
+ }
30
+ import { renderAuthDialog } from '../components/render-auth/auth-dialog-fn.ts.js';
31
+ import { usePermissionHttp } from './use-permission-http.ts.js';
32
+ const element = document.createElement('div');
33
+ element.id = 'directive-ele';
34
+ element.style.position = 'absolute';
35
+ element.style.zIndex = '999999';
36
+ element.classList.add('g-permission-cursor-element');
37
+ element.style.height = '0';
38
+ document.body.appendChild(element);
39
+ // 主要处理无权限鼠标样式和点击弹框ui
40
+ export function usePermission(apiPrefix, spaceId, backgroundColor) {
41
+ const { checkPermission, getPermissionData } = usePermissionHttp(apiPrefix, spaceId);
42
+ const hideAllPopover = ()=>{
43
+ document.querySelectorAll('.bk-popover').forEach((item)=>{
44
+ item.remove();
45
+ });
46
+ };
47
+ const handleMouseEnter = (authorized)=>{
48
+ if (authorized) return;
49
+ element.style.backgroundColor = backgroundColor;
50
+ element.style.height = '16px';
51
+ };
52
+ const handleMouseMove = (event, authorized)=>{
53
+ if (authorized) return;
54
+ const { pageX, pageY } = event;
55
+ const elLeft = pageX + 15;
56
+ const elTop = pageY + -5;
57
+ element.style.left = `${elLeft}px`;
58
+ element.style.top = `${elTop}px`;
59
+ };
60
+ const handleMouseLeave = ()=>{
61
+ element.style.height = '0';
62
+ };
63
+ const handleMouseClick = function() {
64
+ var _ref = _async_to_generator(function*(callback, authorized, actionIds, resourceId) {
65
+ if (authorized) {
66
+ // 有权限直接执行
67
+ callback();
68
+ } else {
69
+ // 关闭所有的 popover
70
+ hideAllPopover();
71
+ // 无权限弹窗
72
+ renderAuthDialog((yield getPermissionData(actionIds, resourceId)));
73
+ // 弹框以后,焦点在弹框上,触发一次鼠标离开事件
74
+ handleMouseLeave();
75
+ }
76
+ });
77
+ return function handleMouseClick(callback, authorized, actionIds, resourceId) {
78
+ return _ref.apply(this, arguments);
79
+ };
80
+ }();
81
+ const handleCheckPermission = function() {
82
+ var _ref = _async_to_generator(function*(actionIds, resourceId) {
83
+ const data = yield checkPermission(actionIds, resourceId);
84
+ return actionIds.every((actionId)=>{
85
+ var _data_find;
86
+ return (_data_find = data.find((item)=>item.actionId === actionId)) === null || _data_find === void 0 ? void 0 : _data_find.isAllowed;
87
+ });
88
+ });
89
+ return function handleCheckPermission(actionIds, resourceId) {
90
+ return _ref.apply(this, arguments);
91
+ };
92
+ }();
93
+ return {
94
+ handleMouseEnter,
95
+ handleMouseMove,
96
+ handleMouseLeave,
97
+ handleMouseClick,
98
+ handleCheckPermission
99
+ };
100
+ }
@@ -1,5 +1,5 @@
1
1
  import type { ISession, ISessionContent } from '@/types/session';
2
- export declare const useSessionHttp: (apiPrefix: string) => {
2
+ export declare const useSessionHttp: (apiPrefix: string, headers?: Record<string, string>) => {
3
3
  getAgentInfo: () => Promise<import("@/types/agent").IAgentInfo>;
4
4
  clearSession: (sessionCode: string) => Promise<unknown>;
5
5
  getSessions: () => Promise<ISession[]>;
@@ -2,38 +2,64 @@ import fetch from '../http/fetch/index.ts.js';
2
2
  import { transferAgentInfoApi2AgentInfo } from '../http/helper/agent.ts.js';
3
3
  import { transferSession2SessionApi, transferSessionApi2Session, transferSessionContent2SessionContentApi, transferSessionContentApi2SessionContent } from '../http/helper/session.ts.js';
4
4
  // session 相关接口
5
- export const useSessionHttp = (apiPrefix)=>{
5
+ export const useSessionHttp = (apiPrefix, headers)=>{
6
6
  // 获取 agent 信息
7
- const getAgentInfo = ()=>fetch.get(`${apiPrefix}/agent/info/`).then((res)=>transferAgentInfoApi2AgentInfo(res));
7
+ const getAgentInfo = ()=>fetch.get(`${apiPrefix}/agent/info/`, undefined, {
8
+ headers
9
+ }).then((res)=>transferAgentInfoApi2AgentInfo(res));
8
10
  // 清除聊天上下文
9
- const clearSession = (sessionCode)=>fetch.post(`${apiPrefix}/chat_completion/${sessionCode}/clear/`);
11
+ const clearSession = (sessionCode)=>fetch.post(`${apiPrefix}/chat_completion/${sessionCode}/clear/`, undefined, {
12
+ headers
13
+ });
10
14
  // 获取会话列表
11
- const getSessions = ()=>fetch.get(`${apiPrefix}/session/`).then((res)=>res.map(transferSessionApi2Session));
15
+ const getSessions = ()=>fetch.get(`${apiPrefix}/session/`, undefined, {
16
+ headers
17
+ }).then((res)=>res.map(transferSessionApi2Session));
12
18
  // 新增会话
13
- const plusSession = (data)=>fetch.post(`${apiPrefix}/session/`, transferSession2SessionApi(data)).then((res)=>transferSessionApi2Session(res));
19
+ const plusSession = (data)=>fetch.post(`${apiPrefix}/session/`, transferSession2SessionApi(data), {
20
+ headers
21
+ }).then((res)=>transferSessionApi2Session(res));
14
22
  // 修改会话
15
- const modifySession = (data)=>fetch.put(`${apiPrefix}/session/${data.sessionCode}/`, transferSession2SessionApi(data)).then((res)=>transferSessionApi2Session(res));
23
+ const modifySession = (data)=>fetch.put(`${apiPrefix}/session/${data.sessionCode}/`, transferSession2SessionApi(data), {
24
+ headers
25
+ }).then((res)=>transferSessionApi2Session(res));
16
26
  // 删除会话
17
- const deleteSession = (sessionCode)=>fetch.delete(`${apiPrefix}/session/${sessionCode}/`);
27
+ const deleteSession = (sessionCode)=>fetch.delete(`${apiPrefix}/session/${sessionCode}/`, undefined, {
28
+ headers
29
+ });
18
30
  // 批量删除会话
19
31
  const batchDeleteSessions = (sessionCodes)=>fetch.post(`${apiPrefix}/session/batch_delete/`, {
20
32
  session_codes: sessionCodes
33
+ }, {
34
+ headers
21
35
  });
22
36
  // 获取会话资源
23
- const getSession = (sessionCode)=>fetch.get(`${apiPrefix}/session/${sessionCode}/`).then((res)=>transferSessionApi2Session(res));
37
+ const getSession = (sessionCode)=>fetch.get(`${apiPrefix}/session/${sessionCode}/`, undefined, {
38
+ headers
39
+ }).then((res)=>transferSessionApi2Session(res));
24
40
  // 获取会话内容列表
25
41
  const getSessionContents = (sessionCode)=>fetch.get(`${apiPrefix}/session_content/content/`, {
26
42
  session_code: sessionCode
43
+ }, {
44
+ headers
27
45
  }).then((res)=>res.map(transferSessionContentApi2SessionContent));
28
46
  // 新增会话内容
29
- const plusSessionContent = (data)=>fetch.post(`${apiPrefix}/session_content/`, transferSessionContent2SessionContentApi(data));
47
+ const plusSessionContent = (data)=>fetch.post(`${apiPrefix}/session_content/`, transferSessionContent2SessionContentApi(data), {
48
+ headers
49
+ });
30
50
  // 修改会话内容
31
- const modifySessionContent = (data)=>fetch.put(`${apiPrefix}/session_content/${data.id}/`, transferSessionContent2SessionContentApi(data));
51
+ const modifySessionContent = (data)=>fetch.put(`${apiPrefix}/session_content/${data.id}/`, transferSessionContent2SessionContentApi(data), {
52
+ headers
53
+ });
32
54
  // 删除会话内容
33
- const deleteSessionContent = (id)=>fetch.delete(`${apiPrefix}/session_content/${id}/`);
55
+ const deleteSessionContent = (id)=>fetch.delete(`${apiPrefix}/session_content/${id}/`, undefined, {
56
+ headers
57
+ });
34
58
  // 批量删除聊天内容
35
59
  const batchDeleteSessionContents = (ids)=>fetch.post(`${apiPrefix}/session_content/batch_delete/`, {
36
60
  ids
61
+ }, {
62
+ headers
37
63
  });
38
64
  return {
39
65
  getAgentInfo,
@@ -0,0 +1,7 @@
1
+ export * from './hooks/use-click-proxy';
2
+ export * from './hooks/use-chat';
3
+ export * from './hooks/use-summary';
4
+ export * from './hooks/use-style';
5
+ export * from './hooks/use-form-leave-confirm';
6
+ export * from './hooks/use-table';
7
+ export * from './hooks/use-permission';
@@ -0,0 +1,7 @@
1
+ export * from './hooks/use-click-proxy.ts.js';
2
+ export * from './hooks/use-chat.ts.js';
3
+ export * from './hooks/use-summary.ts.js';
4
+ export * from './hooks/use-style.ts.js';
5
+ export * from './hooks/use-form-leave-confirm.ts.js';
6
+ export * from './hooks/use-table.ts.js';
7
+ export * from './hooks/use-permission.ts.js';
@@ -27,6 +27,58 @@ function _async_to_generator(fn) {
27
27
  });
28
28
  };
29
29
  }
30
+ function _define_property(obj, key, value) {
31
+ if (key in obj) {
32
+ Object.defineProperty(obj, key, {
33
+ value: value,
34
+ enumerable: true,
35
+ configurable: true,
36
+ writable: true
37
+ });
38
+ } else {
39
+ obj[key] = value;
40
+ }
41
+ return obj;
42
+ }
43
+ function _object_spread(target) {
44
+ for(var i = 1; i < arguments.length; i++){
45
+ var source = arguments[i] != null ? arguments[i] : {};
46
+ var ownKeys = Object.keys(source);
47
+ if (typeof Object.getOwnPropertySymbols === "function") {
48
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
49
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
50
+ }));
51
+ }
52
+ ownKeys.forEach(function(key) {
53
+ _define_property(target, key, source[key]);
54
+ });
55
+ }
56
+ return target;
57
+ }
58
+ function ownKeys(object, enumerableOnly) {
59
+ var keys = Object.keys(object);
60
+ if (Object.getOwnPropertySymbols) {
61
+ var symbols = Object.getOwnPropertySymbols(object);
62
+ if (enumerableOnly) {
63
+ symbols = symbols.filter(function(sym) {
64
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
65
+ });
66
+ }
67
+ keys.push.apply(keys, symbols);
68
+ }
69
+ return keys;
70
+ }
71
+ function _object_spread_props(target, source) {
72
+ source = source != null ? source : {};
73
+ if (Object.getOwnPropertyDescriptors) {
74
+ Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
75
+ } else {
76
+ ownKeys(Object(source)).forEach(function(key) {
77
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
78
+ });
79
+ }
80
+ return target;
81
+ }
30
82
  import errorInterceptor from './error-interceptor.ts.js';
31
83
  import RequestError from './request-error.ts.js';
32
84
  import successInterceptor from './success-interceptor.ts.js';
@@ -62,17 +114,18 @@ const getFetchConfig = (method, payload, config)=>{
62
114
  headers['Content-Type'] = contentTypeMap[config.requestType] || 'application/json';
63
115
  }
64
116
  // 合并配置
65
- let fetchConfig = deepMerge({
117
+ let fetchConfig = _object_spread_props(_object_spread({
66
118
  method: method.toLocaleUpperCase(),
67
119
  mode: 'cors',
68
120
  cache: 'default',
69
121
  credentials: 'include',
70
- headers,
71
122
  redirect: 'follow',
72
123
  referrerPolicy: 'no-referrer-when-downgrade',
73
124
  responseType: 'json',
74
125
  globalError: true
75
- }, config);
126
+ }, config), {
127
+ headers: _object_spread({}, headers, config === null || config === void 0 ? void 0 : config.headers)
128
+ });
76
129
  // merge payload
77
130
  if (methodsWithData.includes(method)) {
78
131
  fetchConfig = deepMerge(fetchConfig, {
@@ -120,9 +173,9 @@ const getFetchUrl = (url, method, payload = {})=>{
120
173
  };
121
174
  // /api/cr/bkaidev/intelligence/code_review/mine_list/ 接口 status 参数需要 status=xx&&status=yy 此种方式接收
122
175
  // 这里单独对此做处理,需要在参数中加上 noEncodeURI 标识,这种处理的缺陷是如果参数本身就有 noEncodeURI 就会出现问题,待处理
123
- const isNoEncodURI = !!payload.noEncodeURI;
124
- delete payload.noEncodeURI;
125
- Object.keys(payload).forEach((key)=>{
176
+ const isNoEncodURI = !!(payload === null || payload === void 0 ? void 0 : payload.noEncodeURI);
177
+ payload === null || payload === void 0 ? true : delete payload.noEncodeURI;
178
+ Object.keys(payload || {}).forEach((key)=>{
126
179
  const value = payload[key];
127
180
  if (isNoEncodURI) {
128
181
  if (Object.prototype.toString.call(value) === '[object Array]') {
@@ -77,6 +77,7 @@ function _object_without_properties_loose(source, excluded) {
77
77
  }
78
78
  return target;
79
79
  }
80
+ import { transferResourcePermission } from './permission.ts.js';
80
81
  /**
81
82
  * 接口转换为ui使用
82
83
  * @param data ICreataDatasetDataResultApi
@@ -129,6 +130,7 @@ function _object_without_properties_loose(source, excluded) {
129
130
  return {
130
131
  componentIds: data.component_ids,
131
132
  componentNames: data.component_names,
133
+ tagNames: data.tag_names,
132
134
  datasetItemCount: data.dataset_item_count,
133
135
  updatedAt: data.updated_at,
134
136
  updatedBy: data.updated_by,
@@ -138,7 +140,10 @@ function _object_without_properties_loose(source, excluded) {
138
140
  createdBy: data.created_by,
139
141
  id: data.id,
140
142
  datasetName: data.dataset_name,
141
- type: data.type
143
+ datasetCode: data.dataset_code,
144
+ type: data.type,
145
+ description: data.description,
146
+ permission: transferResourcePermission(data.permission)
142
147
  };
143
148
  };
144
149
  /**
@@ -153,7 +158,12 @@ function _object_without_properties_loose(source, excluded) {
153
158
  type: data === null || data === void 0 ? void 0 : data.type,
154
159
  component_ids: data === null || data === void 0 ? void 0 : data.componentIds,
155
160
  created_by: data === null || data === void 0 ? void 0 : data.createdBy,
156
- fuzzy: data === null || data === void 0 ? void 0 : data.fuzzy
161
+ fuzzy: data === null || data === void 0 ? void 0 : data.fuzzy,
162
+ description: data === null || data === void 0 ? void 0 : data.description,
163
+ tag_name: data === null || data === void 0 ? void 0 : data.tagName,
164
+ generate_type: data === null || data === void 0 ? void 0 : data.generateType,
165
+ page: data === null || data === void 0 ? void 0 : data.page,
166
+ limit: data === null || data === void 0 ? void 0 : data.limit
157
167
  };
158
168
  };
159
169
  /**
@@ -163,9 +173,12 @@ function _object_without_properties_loose(source, excluded) {
163
173
  */ export const transferDatasetForm2DatasetFormApi = (data)=>{
164
174
  return {
165
175
  component_ids: data.componentIds,
176
+ tag_names: data.tagNames,
166
177
  company_id: data.companyId,
167
178
  dataset_name: data.datasetName,
168
- type: data.type
179
+ dataset_code: data.datasetCode,
180
+ type: data.type,
181
+ description: data.description
169
182
  };
170
183
  };
171
184
  /**
@@ -1,7 +1,13 @@
1
- import type { IResourcePermission, IResourcePermissionApi } from '@/types/permission';
1
+ import type { ICheckPermission, ICheckPermissionApi, IResourcePermission, IResourcePermissionApi } from '@/types/permission';
2
2
  /**
3
3
  * 接口转换为ui
4
4
  * @param data IResourcePermissionApi
5
5
  * @returns IResourcePermission
6
6
  */
7
7
  export declare const transferResourcePermission: (data?: IResourcePermissionApi) => IResourcePermission | undefined;
8
+ /**
9
+ * 接口转换为ui
10
+ * @param data ICheckPermissionApi
11
+ * @returns ICheckPermission
12
+ */
13
+ export declare const transferCheckPermissionApi: (data: ICheckPermissionApi) => ICheckPermission;
@@ -24,5 +24,15 @@
24
24
  manageKnowledgebase: data.manage_knowledgebase,
25
25
  viewQueryTemplate: data.view_query_template,
26
26
  createQueryTemplate: data.create_query_template,
27
- manageQueryTemplate: data.manage_query_template
27
+ manageQueryTemplate: data.manage_query_template,
28
+ viewDataset: data.view_dataset,
29
+ manageDataset: data.manage_dataset
28
30
  } : undefined;
31
+ /**
32
+ * 接口转换为ui
33
+ * @param data ICheckPermissionApi
34
+ * @returns ICheckPermission
35
+ */ export const transferCheckPermissionApi = (data)=>data.map((item)=>({
36
+ actionId: item.action_id,
37
+ isAllowed: item.is_allowed
38
+ }));
@@ -0,0 +1,2 @@
1
+ export * from './hooks/use-dataset-http';
2
+ export * from './hooks/use-session-http';