Skip to content
This repository has been archived by the owner on Jan 16, 2024. It is now read-only.

Commit

Permalink
remove backend-affecting types and reexport them from "@tesler-ui/sch…
Browse files Browse the repository at this point in the history
…ema"
  • Loading branch information
Dergash committed Jan 28, 2021
1 parent 2c9b080 commit 8ba7f39
Show file tree
Hide file tree
Showing 8 changed files with 208 additions and 561 deletions.
8 changes: 6 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@
"test:coverage": "jest --coverage --coverageProvider=v8",
"lint": "yarn eslint ./src",
"check": "yarn run lint && yarn run test",
"doc:gen": "typedoc --out docs --categorizeByGroup src/index.ts src/interfaces/index.ts --categorizeByGroup false --readme none"
"gen:schema": "node ./node_modules/@tesler-ui/schema/bin/build-schema"
},
"devDependencies": {
"@tesler-ui/schema": "^0.2.0",
"@types/classnames": "2.2.6",
"@types/diff": "4.0.2",
"@types/enzyme": "3.10.3",
"@types/enzyme": "3.10.7",
"@types/enzyme-adapter-react-16": "1.0.5",
"@types/history": "4.7.2",
"@types/jest": "24.0.18",
Expand Down Expand Up @@ -99,5 +100,8 @@
"redux": "^4.0.5",
"redux-observable": "^0.14.1",
"rxjs": "^5.5.12"
},
"browser": {
"@tesler-ui/schema": false
}
}
65 changes: 2 additions & 63 deletions src/interfaces/data.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { OperationPostInvokeAny, OperationPreInvoke } from './operation'
import { DrillDownType } from './router'
import { DataValue, DataItem } from '@tesler-ui/schema'
export { DataValue, DataItem, MultivalueSingleValue, MultivalueSingleValueOptions, RecordSnapshotState } from '@tesler-ui/schema'

/**
* API's response on Business Component's data request
Expand All @@ -9,37 +10,13 @@ export interface BcDataResponse {
hasNext: boolean
}

/**
* Instance of `Business component` data
* Has unlimited number of fields, which available to widget
*/
export interface DataItem {
/**
* Record's identificator
*/
id: string
/**
* Version of last record's edit
*/
vstamp: number
/**
* User fields
*/
[fieldName: string]: DataValue
}

/**
* Edited changes
*/
export interface PendingDataItem {
[fieldName: string]: DataValue
}

/**
* Possible types of fields values
*/
export type DataValue = string | number | boolean | null | MultivalueSingleValue[] | undefined | DataItem[]

/**
* State of `data` in global store
*/
Expand Down Expand Up @@ -73,44 +50,6 @@ export interface DataItemResponse {
}
}

export const enum RecordSnapshotState {
noChange = 'noChange',
new = 'new',
deleted = 'deleted'
}

/**
* Structure which contain `Multivalue` field's values
*/
export interface MultivalueSingleValue {
/**
* Record's identificator
*/
id: string
/**
* Showed value
*/
value: string
options?: MultivalueSingleValueOptions
}

/**
* `Multivalue` field's options
*/
export interface MultivalueSingleValueOptions {
/**
* Hint for value
*/
hint?: string
/**
* Type of Icon
*/
icon?: string
drillDown?: string
drillDownType?: DrillDownType
snapshotState?: RecordSnapshotState
}

/**
* `x` is name of field, for which the value will be set up.
* A value of `x` is name of field, from which the value will be gotten.
Expand Down
51 changes: 2 additions & 49 deletions src/interfaces/navigation.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,5 @@
/**
* Description of the destination in the navigation menu.
*
* @param viewName Identifier of view.
*/
export interface ViewNavigationItem {
// TODO: Should not be optional in 2.0.0
viewName?: string
hidden?: boolean
/** TODO: remove in 2.0.0 */
id?: string
}

import { ViewNavigationGroup, MenuItem, ViewNavigationCategory, ViewNavigationItem } from '@tesler-ui/schema'
export { ViewNavigationGroup, MenuItem, ViewNavigationCategory, ViewNavigationItem } from '@tesler-ui/schema'
/**
* Returns MenuItem if it is ViewNavigationItem
*
Expand All @@ -21,20 +10,6 @@ export function isViewNavigationItem(item: MenuItem): item is ViewNavigationItem
return !!item && 'viewName' in item
}

/**
* Description of the category in the navigation menu.
* Used to create nesting levels of menu items.
*
* @param categoryName The name of the category.
* @param child list of categories or menu items included in a category.
* @deprecated ViewNavigationCategory will be deleted in 2.0.0
* @category Type Guards
*/
export interface ViewNavigationCategory {
categoryName: string
child: Array<ViewNavigationCategory | ViewNavigationItem>
}

/**
* @param item
* @deprecated ViewNavigationCategory will be deleted in 2.0.0
Expand All @@ -44,23 +19,6 @@ export function isViewNavigationCategory(item: any): item is ViewNavigationCateg
return !!item && 'categoryName' in item
}

/**
* Description of groups in the navigation menu.
*
* Used to create nesting levels of menu items.
*
* @param title Title of group. Navigation element shows it to user.
* @param child Array of navigation elements specified below group(View or inner Group)
*/
export interface ViewNavigationGroup {
/** TODO identifier will be nullable and string-only in 2.0.0 */
id?: string | number
title: string
child: Array<ViewNavigationGroup | ViewNavigationItem>
hidden?: boolean
defaultView?: string
}

/**
* Returns MenuItem if it is ViewNavigationGroup
*
Expand All @@ -72,11 +30,6 @@ export function isViewNavigationGroup(item: MenuItem): item is ViewNavigationGro
return !!item && 'child' in item && !('categoryName' in item)
}

/**
* The type of object to describe the menu items in the navigation.
*/
export type MenuItem = ViewNavigationGroup | ViewNavigationCategory | ViewNavigationItem

/**
* 1 - for static, top level navigation
* 2 - `SecondLevelMenu` tab widgets
Expand Down
49 changes: 2 additions & 47 deletions src/interfaces/operation.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,8 @@
import { DrillDownType } from './router'
import { AppNotificationType } from './objectMap'
import { DataItem } from './data'

/**
* TODO: Rename to CoreOperationRole in 2.0.0
*/
export const enum OperationTypeCrud {
create = 'create',
save = 'save',
delete = 'delete',
associate = 'associate',
cancelCreate = 'cancel-create',
fileUpload = 'file-upload'
}
import { OperationTypeCrud, OperationType } from '@tesler-ui/schema'
export { OperationTypeCrud, OperationType, OperationInclusionDescriptor } from '@tesler-ui/schema'

export const coreOperations = [
OperationTypeCrud.create,
Expand All @@ -23,14 +13,6 @@ export const coreOperations = [
OperationTypeCrud.fileUpload
]

/**
*
* @param operationType
*/
export function isCoreOperation(operationType: string): operationType is OperationTypeCrud {
return coreOperations.includes(operationType as OperationTypeCrud)
}

/**
*
* @param operation
Expand All @@ -39,11 +21,6 @@ export function isOperationGroup(operation: Operation | OperationGroup): operati
return Array.isArray((operation as OperationGroup).actions)
}

/**
* String that uniquely identifies an operation on widget
*/
export type OperationType = OperationTypeCrud | string

/**
* User operation: CRUD or any custom business action.
*
Expand Down Expand Up @@ -374,28 +351,6 @@ export interface AssociatedItem extends DataItem {
_associate: boolean
}

/**
* Descriptor enabling operation on widget:
* - string (if you just need to include / exclude operation or groups)
* - object, if this is group in which you want to selectively include or exclude the operation
*/
export type OperationInclusionDescriptor =
| string
| {
/**
* Type of transaction; a string that uniquely identifies the operation on the widget
*/
type: OperationType
/**
* List of included operations or groups operations
*/
include?: OperationInclusionDescriptor[]
/**
* List of excluded operations or groups operations
*/
exclude?: OperationType[]
}

export interface OperationError {
success: false
error: {
Expand Down
27 changes: 1 addition & 26 deletions src/interfaces/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export { DrillDownType } from '@tesler-ui/schema'

export interface Route {
type: RouteType
Expand All @@ -31,29 +32,3 @@ export const enum RouteType {
invalid = 'invalid',
unknown = 'unknown'
}

/**
* Types of drilldowns in the application, specified by Tesler API
*/
export const enum DrillDownType {
/**
* Drilldown to inner entity of the application (screen, view), i.e. url will be places after route hash sy: `#/${inner}`
*/
inner = 'inner',
/**
* Drilldown to an url relative to the current url: `/${relative}`
*/
relative = 'relative',
/**
* Drilldown to an url relative to the current url: `/${relative}` that opens in a new browser tab
*/
relativeNew = 'relativeNew',
/**
* An external redirect, i.e. `http://${external}`
*/
external = 'external',
/**
* An external redirect, i.e. `http://${external}` that opens in a new browser tab
*/
externalNew = 'externalNew'
}
38 changes: 1 addition & 37 deletions src/interfaces/view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { PendingDataItem, PickMap } from '../interfaces/data'
import { SystemNotification } from './objectMap'
import { OperationTypeCrud, OperationPostInvokeConfirm } from './operation'
import { AxiosError } from 'axios'
export { FieldType } from '@tesler-ui/schema'

export interface ViewSelectedCell {
widgetName: string
Expand Down Expand Up @@ -180,43 +181,6 @@ export interface PopupData {
isFilter?: boolean
}

export const enum FieldType {
number = 'number',
input = 'input',
monthYear = 'monthYear',
date = 'date',
dateTime = 'dateTime',
dateTimeWithSeconds = 'dateTimeWithSeconds',
checkbox = 'checkbox',
/**
* @deprecated TODO: project-specific, remove in 2.0.0
*/
checkboxSql = 'checkboxSql',
/**
* @deprecated TODO: project-specific, remove in 2.0.0
*/
DMN = 'DMN',
pickList = 'pickList',
inlinePickList = 'inline-pickList',
dictionary = 'dictionary',
hidden = 'hidden', // @deprecated TODO: Remove in 2.0.0 in favor of `hidden` flag of widget meta field description
text = 'text',
percent = 'percent',
fileUpload = 'fileUpload',
money = 'money',
/**
* @deprecated TODO: project-specific, remove in 2.0.0
*/
comboCondition = 'combo-condition',
richText = 'richText',
printForm = 'printForm',
multifield = 'multifield',
multivalue = 'multivalue',
multivalueHover = 'multivalueHover',
hint = 'hint',
radio = 'radio'
}

export type ApplicationError = BusinessError | SystemError | ApplicationErrorBase

export const enum ApplicationErrorType {
Expand Down
Loading

0 comments on commit 8ba7f39

Please sign in to comment.