types.ts 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. /*
  2. * <<
  3. * Davinci
  4. * ==
  5. * Copyright (C) 2016 - 2017 EDP
  6. * ==
  7. * Licensed under the Apache License, Version 2.0 (the "License");
  8. * you may not use this file except in compliance with the License.
  9. * You may obtain a copy of the License at
  10. *
  11. * http://www.apache.org/licenses/LICENSE-2.0
  12. *
  13. * Unless required by applicable law or agreed to in writing, software
  14. * distributed under the License is distributed on an "AS IS" BASIS,
  15. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  16. * See the License for the specific language governing permissions and
  17. * limitations under the License.
  18. * >>
  19. */
  20. import { SqlTypes } from 'app/globalConstants'
  21. import { ISourceSimple, ISourceBase, ISchema } from 'containers/Source/types'
  22. import {
  23. ViewModelTypes,
  24. ViewModelVisualTypes,
  25. ViewVariableTypes,
  26. ViewVariableValueTypes
  27. } from './constants'
  28. import { CancelTokenSource } from 'axios'
  29. export interface IViewBase {
  30. id: number
  31. name: string
  32. description: string
  33. sourceName: string
  34. }
  35. type IViewTemp = Omit<IViewBase, 'sourceName'>
  36. export interface IView extends IViewTemp {
  37. sql: string
  38. model: string
  39. variable: string
  40. config: string
  41. projectId: number
  42. source?: ISourceSimple
  43. sourceId: number
  44. roles: IViewRoleRaw[]
  45. }
  46. type IViewTemp2 = Omit<Omit<Omit<IView, 'model'>, 'variable'>, 'roles'>
  47. export interface IFormedView extends IViewTemp2 {
  48. model: IViewModel
  49. variable: IViewVariable[]
  50. roles: IViewRole[]
  51. }
  52. export interface ISqlValidation {
  53. code: number
  54. message: string
  55. }
  56. export interface IViewLoading {
  57. view: boolean
  58. table: boolean
  59. modal: boolean
  60. execute: boolean
  61. copy: boolean
  62. }
  63. export interface IExecuteSqlParams {
  64. sourceId: number
  65. sql: string
  66. limit: number
  67. variables: IViewVariableBase[]
  68. }
  69. export interface ISqlColumn {
  70. name: string
  71. type: SqlTypes
  72. }
  73. export interface IExecuteSqlResponse {
  74. columns: ISqlColumn[]
  75. totalCount: number
  76. resultList: Array<{ [key: string]: string | number }>
  77. }
  78. export interface IViewModelProps {
  79. name: string
  80. sqlType: SqlTypes
  81. visualType: ViewModelVisualTypes
  82. modelType: ViewModelTypes
  83. }
  84. export type IKeyOfViewModelProps = keyof Omit<IViewModelProps, 'name'>
  85. export interface IViewModel {
  86. [name: string]: Omit<IViewModelProps, 'name'>
  87. }
  88. interface IViewVariableChannel {
  89. bizId: number
  90. name: string
  91. tenantId: number
  92. }
  93. interface IViewVariableBase {
  94. name: string
  95. type: ViewVariableTypes
  96. valueType: ViewVariableValueTypes
  97. defaultValues: Array<string | number | boolean>
  98. channel?: IViewVariableChannel
  99. udf: boolean
  100. }
  101. export interface IViewVariable extends IViewVariableBase {
  102. key: string
  103. alias: string
  104. fromService: boolean
  105. }
  106. export interface IViewRoleRaw {
  107. roleId: number
  108. columnAuth: string
  109. rowAuth: string
  110. }
  111. export interface IViewRoleRowAuth {
  112. name: string
  113. values: Array<string | number | boolean>
  114. enable: boolean
  115. }
  116. export interface IViewRole {
  117. roleId: number
  118. /**
  119. * view columns name
  120. * @type {string[]}
  121. * @memberof IViewRole
  122. */
  123. columnAuth: string[]
  124. /**
  125. * query variable values
  126. * @type {(Array<string | number>)}
  127. * @memberof IViewRole
  128. */
  129. rowAuth: IViewRoleRowAuth[]
  130. }
  131. export interface IViewInfo {
  132. model: IViewModel
  133. variable: IViewVariable[]
  134. roles: IViewRole[]
  135. }
  136. export interface IFormedViews {
  137. [viewId: string]: IFormedView
  138. }
  139. export interface IShareFormedViews {
  140. [viewId: string]: Pick<IFormedView, 'name' | 'model' | 'variable'> & {
  141. dataToken: string
  142. }
  143. }
  144. export type IDacChannel = string
  145. export interface IDacTenant {
  146. id: number
  147. name: string
  148. }
  149. export interface IDacBiz {
  150. id: number
  151. name: string
  152. }
  153. export interface IViewQueryResponse {
  154. columns: Array<{ name: string; type: SqlTypes }>
  155. pageNo: number
  156. pageSize: number
  157. totalCount: number
  158. resultList: any[]
  159. }
  160. export interface IViewState {
  161. views: IViewBase[]
  162. formedViews: IFormedViews
  163. editingView: IView
  164. editingViewInfo: IViewInfo
  165. sources: ISourceBase[]
  166. schema: ISchema
  167. sqlValidation: ISqlValidation
  168. sqlDataSource: IExecuteSqlResponse
  169. sqlLimit: number
  170. loading: IViewLoading
  171. channels: IDacChannel[]
  172. tenants: IDacTenant[]
  173. bizs: IDacBiz[]
  174. cancelTokenSources: CancelTokenSource[]
  175. isLastExecuteWholeSql: boolean
  176. }