Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(external schema): init external schema #2973

Merged
merged 4 commits into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions src/api/cluster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,21 @@ export const putClusterLinking = (
name: string,
data: ClusterLinkingFormForUpdate,
): Promise<CreatedClusterLinking> => {
return http.put(`/cluster/links/link/${name}`, data)
return http.put(`/cluster/links/link/${encodeURIComponent(name)}`, data)
}

export const deleteClusterLinking = (name: string): Promise<void> => {
return http.delete(`/cluster/links/link/${name}`)
return http.delete(`/cluster/links/link/${encodeURIComponent(name)}`)
}

export const getClusterLinkingDetail = (name: string): Promise<CreatedClusterLinking> => {
return http.get(`/cluster/links/link/${name}`)
return http.get(`/cluster/links/link/${encodeURIComponent(name)}`)
}

export const getClusterLinkingMetrics = (name: string): Promise<ClusterLinkingMetrics> => {
return http.get(`/cluster/links/link/${name}/metrics`)
return http.get(`/cluster/links/link/${encodeURIComponent(name)}/metrics`)
}

export const resetClusterLinkingMetrics = (name: string): Promise<void> => {
return http.put(`/cluster/links/link/${encodeURIComponent(name)}/metrics/reset`)
}
24 changes: 24 additions & 0 deletions src/api/ruleengine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
RuleMetrics,
SchemaRegistry,
} from '@/types/rule'
import { ExternalSchema, ExternalSchemaMap } from '@/types/typeAlias'

//Bridges
export async function getBridgeList(): Promise<any> {
Expand Down Expand Up @@ -174,3 +175,26 @@ export const updateSchema = (
): Promise<SchemaRegistry> => {
return http.put(`/schema_registry/${schemaName}`, schema)
}

export const getExternalSchemas = (): Promise<ExternalSchemaMap> => {
return http.get(`/schema_registry_external`)
}

export const postExternalSchema = (data: ExternalSchema): Promise<ExternalSchema> => {
return http.post(`/schema_registry_external`, data)
}

export const getExternalSchemaDetail = (name: string): Promise<Omit<ExternalSchema, 'name'>> => {
return http.get(`/schema_registry_external/registry/${encodeURIComponent(name)}`)
}

export const putExternalSchema = (
name: string,
data: Omit<ExternalSchema, 'name'>,
): Promise<ExternalSchema> => {
return http.put(`/schema_registry_external/registry/${encodeURIComponent(name)}`, data)
}

export const deleteExternalSchema = (name: string): Promise<void> => {
return http.delete(`/schema_registry_external/registry/${encodeURIComponent(name)}`)
}
4 changes: 2 additions & 2 deletions src/common/tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,9 +197,9 @@ export const transTimeStrToMS = (timeStr: string): number | string => {
export const getLabelFromValueInOptionList = <T>(
targetValue: T,
optionList: Array<{ value: T; label: string }>,
): string => {
): T | string => {
const target = optionList.find(({ value }) => value === targetValue)
return target?.label || ''
return target?.label || targetValue || ''
}

export const formatNumber = (num: number | string | undefined) => {
Expand Down
21 changes: 21 additions & 0 deletions src/hooks/Rule/schema/useExternalSchemaType.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { getLabelFromValueInOptionList } from '@/common/tools'
import { ExternalSchemaType } from '@/types/typeAlias'

type ExternalSchemaTypeValue = typeof ExternalSchemaType[keyof typeof ExternalSchemaType]

export default (): {
schemaTypeOpts: {
label: string
value: ExternalSchemaTypeValue
}[]
getLabelByValue: (value: ExternalSchemaTypeValue) => string
} => {
const schemaTypeOpts: Array<{ label: string; value: ExternalSchemaTypeValue }> = [
{ label: 'Confluent', value: ExternalSchemaType.Confluent },
]

const getLabelByValue = (value: ExternalSchemaTypeValue) =>
getLabelFromValueInOptionList(value, schemaTypeOpts)

return { schemaTypeOpts, getLabelByValue }
}
18 changes: 15 additions & 3 deletions src/i18n/components.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,14 @@ export default {
zh: 'Schema Registry',
en: 'Schema Registry',
},
'internal-schema': {
zh: '内部 Schema',
en: 'Internal Schema',
},
'external-schema': {
zh: '外部 Schema',
en: 'External Schema',
Comment on lines +99 to +104
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make simple: Internal & External

},
'message-transform': {
zh: '消息转换',
en: 'Message Transform',
Expand Down Expand Up @@ -420,9 +428,13 @@ export default {
zh: '慢订阅设置',
en: 'Slow Subscriptions Settings',
},
'schema-create': {
zh: '创建 Schema',
en: 'Create Schema',
'internal-schema-create': {
zh: '创建内部 Schema',
en: 'Create Internal Schema',
},
'external-schema-create': {
zh: '创建外部 Schema',
en: 'Create External Schema',
},
'schema-validation-create': {
zh: '创建 Schema 验证',
Expand Down
34 changes: 28 additions & 6 deletions src/router/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -870,25 +870,47 @@ export const routes: Array<RouteRecordRaw> = [
{
path: '/schema',
component: Layout,
redirect: '/schema/internal',
meta: {
hideKey: 'schema',
authRequired: true,
subMenu: true,
showSubMenuInFirstLevel: true,
},
children: [
{
path: '',
name: 'schema',
path: 'internal',
name: 'internal-schema',
component: () => import('@/views/RuleEngine/Schema/Schema.vue'),
},
{
path: 'create',
name: 'schema-create',
path: 'internal/create',
name: 'internal-schema-create',
component: () => import('@/views/RuleEngine/Schema/SchemaCreate.vue'),
meta: { hideInMenu: true },
},
{
path: ':schemaName',
name: 'schema-detail',
path: 'internal/:schemaName',
name: 'internal-schema-detail',
component: () => import('@/views/RuleEngine/Schema/SchemaDetail.vue'),
meta: { hideInMenu: true },
},
{
path: 'external',
name: 'external-schema',
component: () => import('@/views/RuleEngine/Schema/ExternalSchema.vue'),
},
{
path: 'external/create',
name: 'external-schema-create',
component: () => import('@/views/RuleEngine/Schema/ExternalSchemaCreate.vue'),
meta: { hideInMenu: true },
},
{
path: 'external/:schemaName',
name: 'external-schema-detail',
component: () => import('@/views/RuleEngine/Schema/ExternalSchemaDetail.vue'),
meta: { hideInMenu: true },
},
],
},
Expand Down
6 changes: 6 additions & 0 deletions src/types/schemas/actions.schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1109,6 +1109,8 @@ export interface ConfluentKafkaMessage {
export interface ConfluentProducerKafkaOpts {
topic: string
message?: ConfluentKafkaMessage
max_linger_time?: string
max_linger_bytes?: string
max_batch_bytes?: string
compression?: ConfluentProducerKafkaOptsCompression
partition_strategy?: ConfluentProducerKafkaOptsPartitionStrategy
Expand Down Expand Up @@ -2350,6 +2352,8 @@ export interface BridgeKafkaProducerBuffer {
export interface BridgeKafkaProducerKafkaOpts {
topic: string
message?: BridgeKafkaKafkaMessage
max_linger_time?: string
max_linger_bytes?: string
max_batch_bytes?: string
compression?: BridgeKafkaProducerKafkaOptsCompression
partition_strategy?: BridgeKafkaProducerKafkaOptsPartitionStrategy
Expand Down Expand Up @@ -3336,6 +3340,8 @@ export const BridgeAzureEventHubProducerKafkaOptsQueryMode = {
export interface BridgeAzureEventHubProducerKafkaOpts {
topic: string
message?: BridgeAzureEventHubKafkaMessage
max_linger_time?: string
max_linger_bytes?: string
max_batch_bytes?: string
partition_strategy?: BridgeAzureEventHubProducerKafkaOptsPartitionStrategy
required_acks?: BridgeAzureEventHubProducerKafkaOptsRequiredAcks
Expand Down
34 changes: 34 additions & 0 deletions src/types/schemas/authentication.schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export type PostAuthentication400 = {
}

export type PostAuthentication200 =
| AuthnCinfo
| AuthnKerberos
| AuthnScramRestapiPost
| AuthnScramRestapiGet
Expand All @@ -61,6 +62,7 @@ export type PostAuthentication200 =
| AuthnBuiltinDb

export type PostAuthenticationBody =
| AuthnCinfo
| AuthnKerberos
| AuthnScramRestapiPost
| AuthnScramRestapiGet
Expand All @@ -84,6 +86,7 @@ export type PostAuthenticationBody =
| AuthnBuiltinDbApi

export type GetAuthentication200Item =
| AuthnCinfo
| AuthnKerberos
| AuthnScramRestapiPost
| AuthnScramRestapiGet
Expand Down Expand Up @@ -146,6 +149,7 @@ export type PutAuthenticationId400 = {
}

export type PutAuthenticationIdBody =
| AuthnCinfo
| AuthnKerberos
| AuthnScramRestapiPost
| AuthnScramRestapiGet
Expand Down Expand Up @@ -182,6 +186,7 @@ export type GetAuthenticationId404 = {
}

export type GetAuthenticationId200 =
| AuthnCinfo
| AuthnKerberos
| AuthnScramRestapiPost
| AuthnScramRestapiGet
Expand Down Expand Up @@ -1544,6 +1549,35 @@ export interface AuthnGcpDevice {
enable?: boolean
}

export type AuthnCinfoCheckResult = typeof AuthnCinfoCheckResult[keyof typeof AuthnCinfoCheckResult]

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const AuthnCinfoCheckResult = {
allow: 'allow',
deny: 'deny',
ignore: 'ignore',
} as const

export type AuthnCinfoCheckIsMatch = string[] | string

export interface AuthnCinfoCheck {
is_match: AuthnCinfoCheckIsMatch
result: AuthnCinfoCheckResult
}

export type AuthnCinfoMechanism = typeof AuthnCinfoMechanism[keyof typeof AuthnCinfoMechanism]

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const AuthnCinfoMechanism = {
cinfo: 'cinfo',
} as const

export interface AuthnCinfo {
mechanism: AuthnCinfoMechanism
checks: AuthnCinfoCheck[]
enable?: boolean
}

export type AuthnBuiltinDbApiBootstrapType =
typeof AuthnBuiltinDbApiBootstrapType[keyof typeof AuthnBuiltinDbApiBootstrapType]

Expand Down
2 changes: 2 additions & 0 deletions src/types/schemas/bridges.schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5106,6 +5106,8 @@ export const BridgeAzureEventHubProducerKafkaOptsPartitionStrategy = {
export interface BridgeAzureEventHubProducerKafkaOpts {
topic: string
message?: BridgeAzureEventHubKafkaMessage
max_linger_time?: string
max_linger_bytes?: string
max_batch_bytes?: string
partition_strategy?: BridgeAzureEventHubProducerKafkaOptsPartitionStrategy
required_acks?: BridgeAzureEventHubProducerKafkaOptsRequiredAcks
Expand Down
41 changes: 27 additions & 14 deletions src/types/schemas/cluster.schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,20 @@ export type PutClusterLinksLinkName400 = {
message?: string
}

export type PutClusterLinksLinkNameBody = {
enable?: boolean
server: string
clientid?: string
username?: string
password?: string
ssl?: EmqxSslClientOpts
topics: string[]
pool_size?: number
retry_interval?: string
max_inflight?: number
resource_opts?: ClusterCreationOpts
}

export type GetClusterLinksLinkName404Code =
typeof GetClusterLinksLinkName404Code[keyof typeof GetClusterLinksLinkName404Code]

Expand Down Expand Up @@ -122,6 +136,19 @@ export type GetClusterLinksLinkNameMetrics404 = {
message?: string
}

export type PutClusterLinksLinkNameMetricsReset404Code =
typeof PutClusterLinksLinkNameMetricsReset404Code[keyof typeof PutClusterLinksLinkNameMetricsReset404Code]

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const PutClusterLinksLinkNameMetricsReset404Code = {
NOT_FOUND: 'NOT_FOUND',
} as const

export type PutClusterLinksLinkNameMetricsReset404 = {
code?: PutClusterLinksLinkNameMetricsReset404Code
message?: string
}

export type EmqxSslClientOptsServerNameIndication = string | 'disable'

export type EmqxSslClientOptsPartialChain =
Expand Down Expand Up @@ -182,20 +209,6 @@ export interface EmqxSslClientOpts {
server_name_indication?: EmqxSslClientOptsServerNameIndication
}

export type PutClusterLinksLinkNameBody = {
enable?: boolean
server: string
clientid?: string
username?: string
password?: string
ssl?: EmqxSslClientOpts
topics: string[]
pool_size?: number
retry_interval?: string
max_inflight?: number
resource_opts?: ClusterCreationOpts
}

export interface ClusterTimeout {
timeout?: number
}
Expand Down
Loading
Loading