Skip to content

Commit

Permalink
CB-4634 chore: shceme -> schema
Browse files Browse the repository at this point in the history
  • Loading branch information
s.teleshev committed Feb 26, 2024
1 parent e537ba3 commit efa745b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import {
ESqlDataSourceFeatures,
ISQLDatasourceUpdateData,
ISqlEditorTabState,
SQL_EDITOR_TAB_STATE_SCHEME,
SQL_EDITOR_TAB_STATE_SCHEMA,
SqlDataSourceService,
SqlEditorService,
SqlResultTabsService,
Expand Down Expand Up @@ -275,7 +275,7 @@ export class SqlEditorTabService extends Bootstrap {
}

private async handleTabRestore(tab: ITab<ISqlEditorTabState>): Promise<boolean> {
if (!SQL_EDITOR_TAB_STATE_SCHEME.safeParse(tab.handlerState).success) {
if (!SQL_EDITOR_TAB_STATE_SCHEMA.safeParse(tab.handlerState).success) {
await this.sqlDataSourceService.destroy(tab.handlerState.editorId);
return false;
}
Expand Down
40 changes: 20 additions & 20 deletions webapp/packages/plugin-sql-editor/src/ISqlEditorTabState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,71 +9,71 @@ import { schema } from '@cloudbeaver/core-utils';

import { OUTPUT_LOG_TYPES } from './SqlResultTabs/OutputLogs/IOutputLogTypes';

export const RESULT_TAB_SCHEME = schema.object({
export const RESULT_TAB_SCHEMA = schema.object({
tabId: schema.string(),
groupId: schema.string(),
indexInResultSet: schema.number(),
presentationId: schema.string(),
valuePresentationId: schema.nullable(schema.string()),
});

export type IResultTab = schema.infer<typeof RESULT_TAB_SCHEME>;
export type IResultTab = schema.infer<typeof RESULT_TAB_SCHEMA>;

export const STATISTIC_TAB_SCHEME = schema.object({
export const STATISTIC_TAB_SCHEMA = schema.object({
tabId: schema.string(),
order: schema.number(),
});

export type IStatisticsTab = schema.infer<typeof STATISTIC_TAB_SCHEME>;
export type IStatisticsTab = schema.infer<typeof STATISTIC_TAB_SCHEMA>;

export const RESULT_GROUP_SCHEME = schema.object({
export const RESULT_GROUP_SCHEMA = schema.object({
groupId: schema.string(),
modelId: schema.string(),
order: schema.number(),
nameOrder: schema.number(),
query: schema.string(),
});

export type IResultGroup = schema.infer<typeof RESULT_GROUP_SCHEME>;
export type IResultGroup = schema.infer<typeof RESULT_GROUP_SCHEMA>;

export const SQL_EDITOR_RESULT_TAB_SCHEME = schema.object({
export const SQL_EDITOR_RESULT_TAB_SCHEMA = schema.object({
id: schema.string(),
order: schema.number(),
name: schema.string(),
icon: schema.string(),
});

export type ISqlEditorResultTab = schema.infer<typeof SQL_EDITOR_RESULT_TAB_SCHEME>;
export type ISqlEditorResultTab = schema.infer<typeof SQL_EDITOR_RESULT_TAB_SCHEMA>;

export const EXECUTION_PLAN_TAB_SCHEME = schema.object({
export const EXECUTION_PLAN_TAB_SCHEMA = schema.object({
tabId: schema.string(),
order: schema.number(),
query: schema.string(),
options: schema.record(schema.any()).optional(),
});

export type IExecutionPlanTab = schema.infer<typeof EXECUTION_PLAN_TAB_SCHEME>;
export type IExecutionPlanTab = schema.infer<typeof EXECUTION_PLAN_TAB_SCHEMA>;

const OUTPUT_LOGS_TAB_SCHEME = SQL_EDITOR_RESULT_TAB_SCHEME.extend({
const OUTPUT_LOGS_TAB_SCHEMA = SQL_EDITOR_RESULT_TAB_SCHEMA.extend({
selectedLogTypes: schema.array(schema.enum(OUTPUT_LOG_TYPES)),
});

export type IOutputLogsTab = schema.infer<typeof OUTPUT_LOGS_TAB_SCHEME>;
export type IOutputLogsTab = schema.infer<typeof OUTPUT_LOGS_TAB_SCHEMA>;

export const SQL_EDITOR_TAB_STATE_SCHEME = schema.object({
export const SQL_EDITOR_TAB_STATE_SCHEMA = schema.object({
editorId: schema.string(),
datasourceKey: schema.string(),
source: schema.string().optional(),
order: schema.number(),
currentTabId: schema.string().optional(),
tabs: schema.array(SQL_EDITOR_RESULT_TAB_SCHEME),
resultGroups: schema.array(RESULT_GROUP_SCHEME),
resultTabs: schema.array(RESULT_TAB_SCHEME),
statisticsTabs: schema.array(STATISTIC_TAB_SCHEME),
executionPlanTabs: schema.array(EXECUTION_PLAN_TAB_SCHEME),
outputLogsTab: OUTPUT_LOGS_TAB_SCHEME.optional(),
tabs: schema.array(SQL_EDITOR_RESULT_TAB_SCHEMA),
resultGroups: schema.array(RESULT_GROUP_SCHEMA),
resultTabs: schema.array(RESULT_TAB_SCHEMA),
statisticsTabs: schema.array(STATISTIC_TAB_SCHEMA),
executionPlanTabs: schema.array(EXECUTION_PLAN_TAB_SCHEMA),
outputLogsTab: OUTPUT_LOGS_TAB_SCHEMA.optional(),
currentModeId: schema.string().optional(),
modeState: schema.array(schema.tuple([schema.string(), schema.any()])),
});

export type ISqlEditorTabState = schema.infer<typeof SQL_EDITOR_TAB_STATE_SCHEME>;
export type ISqlEditorTabState = schema.infer<typeof SQL_EDITOR_TAB_STATE_SCHEMA>;

0 comments on commit efa745b

Please sign in to comment.