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

refactor(26237): Refactor the request infrastructure to the OpenAPI specs #566

Open
wants to merge 29 commits into
base: epic/23777/bi-directional-frontend
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
e981913
feat(26237): generate openAPI specs
vanch3d Sep 18, 2024
4dbab41
refactor(26237): refactor the client types
vanch3d Sep 18, 2024
b50e551
refactor(26237): refactor the client props
vanch3d Sep 18, 2024
b496b4d
fix(26237): fix bug with undefined queries
vanch3d Sep 18, 2024
920e940
refactor(26237): refactor the client hooks to utilise the stubs and p…
vanch3d Sep 18, 2024
664e515
refactor(26237): update mocks
vanch3d Sep 18, 2024
010f3f4
test(26237): update tests
vanch3d Sep 18, 2024
7cff9c8
fix(26237): fix mocks
vanch3d Sep 18, 2024
3a76684
test(26237): fix test
vanch3d Sep 18, 2024
6cd8d83
test(26237): fix test
vanch3d Sep 18, 2024
266d22d
refactor(26237): refactor the topic sampler to utilise the stubs
vanch3d Sep 18, 2024
5db4590
refactor(26237): refactor the domain tag to utilise the stubs
vanch3d Sep 19, 2024
fe2fce1
fix(26237): fix context for the RJSF form
vanch3d Sep 19, 2024
bd8f60e
refactor(26237): refactor the bidirectional utilities to reflect WRIT…
vanch3d Sep 19, 2024
87a4693
fix(26237): add hooks for all the domain tags requests
vanch3d Sep 19, 2024
d3ab7d4
fix(26237): fix mocks
vanch3d Sep 19, 2024
6501f16
refactor(26237): refactor the domain schemas to utilise the stubs
vanch3d Sep 20, 2024
d721cd9
refactor(26237): refactor the MSW startup in order to integrate the M…
vanch3d Sep 20, 2024
f64565a
chore(26237): linting
vanch3d Sep 20, 2024
0cef5a7
chore(26237): renamed test files
vanch3d Sep 23, 2024
0bba73b
test(26237): fix tests
vanch3d Sep 23, 2024
a1f850a
test(26237): add tests
vanch3d Sep 23, 2024
ca2d015
refactor(26237): refactor the payload to schema converter
vanch3d Sep 23, 2024
d67a3a9
refactor(26237): refactor the schema hooks
vanch3d Sep 23, 2024
3ee2a5b
refactor(26237): fix mocks
vanch3d Sep 23, 2024
7a77756
refactor(26237): fix react query
vanch3d Sep 23, 2024
9e51014
test(26237): fix tests
vanch3d Sep 23, 2024
2f74d78
test(26237): fix tests
vanch3d Sep 23, 2024
4f049d1
test(26237): fix tests
vanch3d Sep 23, 2024
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
16 changes: 16 additions & 0 deletions hivemq-edge/src/frontend/src/__test-utils__/msw/handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ import { handlers as DataHubBehaviorPoliciesService } from '@/extensions/datahub
import { handlers as DataHubSchemasService } from '@/extensions/datahub/api/hooks/DataHubSchemasService/__handlers__'
import { handlers as DataHubScriptsService } from '@/extensions/datahub/api/hooks/DataHubScriptsService/__handlers__'

import { handlers as ClientFilterHandlers } from '@/api/hooks/useClientSubscriptions/__handlers__'
import { deviceHandlers as DeviceHandlers } from '@/api/hooks/useProtocolAdapters/__handlers__'
import { schemaHandlers } from '@/api/hooks/useDomainModel/__handlers__'
import { MQTTSample } from '@/hooks/usePrivateMqttClient/type.ts'

export const handlers = [
...useFrontendServices,
...ListenerHandlers,
Expand All @@ -23,3 +28,14 @@ export const handlers = [
...DataHubSchemasService,
...DataHubScriptsService,
]

export const createHandlersWithMQTTClient = (
onSampling?: (topicFilter: string) => Promise<MQTTSample[]> | undefined
) => {
return [
...ClientFilterHandlers,
...DeviceHandlers,
// Domain & Schemas
...schemaHandlers(onSampling),
]
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { NodeProps, Position } from 'reactflow'
import { Listener } from '@/api/__generated__'
import { BrokerClientConfiguration } from '@/api/types/api-broker-client.ts'
import { ClientFilter, Listener } from '@/api/__generated__'
import { mockAdapter, mockProtocolAdapter } from '@/api/hooks/useProtocolAdapters/__handlers__'
import { mockBridge } from '@/api/hooks/useGetBridges/__handlers__'
import { mockClientSubscription } from '@/api/hooks/useClientSubscriptions/__handlers__'
Expand Down Expand Up @@ -63,10 +62,10 @@ export const MOCK_NODE_DEVICE: NodeProps<DeviceMetadata> = {
...MOCK_DEFAULT_NODE,
}

export const MOCK_NODE_CLIENT: NodeProps<BrokerClientConfiguration> = {
export const MOCK_NODE_CLIENT: NodeProps<ClientFilter> = {
id: 'idBridge',
type: NodeTypes.BRIDGE_NODE,
sourcePosition: Position.Bottom,
data: mockClientSubscription.config,
data: mockClientSubscription,
...MOCK_DEFAULT_NODE,
}
Original file line number Diff line number Diff line change
@@ -1,70 +1,4 @@
import { RJSFSchema } from '@rjsf/utils'
import { DeviceTags } from '@/modules/Subscriptions/types.ts'

export const GENERATE_DATA_MODELS = (short = false, title?: string): RJSFSchema => {
const model: RJSFSchema = {
title: title || 'A registration form',
description: 'A simple form example.',
type: 'object',
required: ['firstName', 'lastName'],
properties: {
firstName: {
type: 'string',
title: short ? 'First String' : 'firstName',
default: 'Chuck',
examples: 'firstName',
},
lastName: {
type: 'string',
title: short ? 'Second String' : 'lastname',
},
age: {
type: 'integer',
title: short ? 'Number' : 'age',
},
subItems: {
type: 'object',
title: 'subItems',
examples: 'subItems',

properties: {
name: {
examples: 'name',
type: 'string',
title: 'name',
default: 'Default name',
},
type: {
type: 'string',
title: 'type',
default: 'Default type',
},
},
},
},
}

if (!short)
model.properties = {
...model.properties,
bio: {
type: 'string',
title: 'bio',
},
password: {
type: 'string',
title: 'password',
minLength: 3,
},
telephone: {
type: 'string',
title: 'telephone',
minLength: 10,
},
}

return model
}

export const MOCK_MQTT_SCHEMA_REFS: RJSFSchema = {
definitions: {
Expand Down Expand Up @@ -148,6 +82,20 @@ export const MOCK_MQTT_SCHEMA_PLAIN: RJSFSchema = {
title: 'Telephone',
minLength: 10,
},
nestedObject: {
type: 'object',
title: 'NestedObject',
properties: {
name: {
type: 'string',
default: 'Default name',
},
age: {
type: 'integer',
title: 'Age',
},
},
},
listOfStrings: {
type: 'array',
title: 'A list of strings',
Expand All @@ -172,16 +120,3 @@ export const MOCK_MQTT_SCHEMA_PLAIN: RJSFSchema = {
},
},
}
export const MOCK_MQTT_TOPIC_SAMPLES = [
'tmp/broker1/topic1/segment1',
'tmp/broker1/topic1/segment2',
'tmp/broker1/topic1/segment2/leaf1',
'tmp/broker2/topic1',
'tmp/broker4/topic1/segment2',
]

export const MOCK_DEVICE_TAGS: DeviceTags[] = [
{ tag: 'write/power-management/alert', node: 'ns=3;i=1002' },
{ tag: 'write/power-management/off', node: 'ns=3;i=1003' },
{ tag: 'write/log/event', node: 'ns=3;i=1008' },
]

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions hivemq-edge/src/frontend/src/api/__generated__/index.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading