forked from KaotoIO/kaoto
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(gh_112) - BaseVisualCamelEntity for Pipe
- Loading branch information
Showing
9 changed files
with
122 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { isPipe } from './is-pipe'; | ||
import { pipeJson } from '../stubs/pipe-route'; | ||
|
||
describe('isPipe', () => { | ||
it.each([ | ||
[{ apiVersion: 'camel.apache.org/v1', kind: 'Pipe' }, true], | ||
[pipeJson, true], | ||
[undefined, false], | ||
[null, false], | ||
[true, false], | ||
[false, false], | ||
])('should mark %s as isPipe: %s', (route, result) => { | ||
expect(isPipe(route)).toEqual(result); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { Pipe } from '@kaoto-next/camel-catalog/types'; | ||
import { isDefined } from '../utils'; | ||
|
||
/** Very basic check to determine whether this object is a Pipe */ | ||
export const isPipe = (rawEntity: unknown): rawEntity is Pipe => { | ||
if (!isDefined(rawEntity) || Array.isArray(rawEntity) || typeof rawEntity !== 'object') { | ||
return false; | ||
} | ||
|
||
return ( | ||
typeof rawEntity === 'object' && 'apiVersion' in rawEntity! && 'kind' in rawEntity! && rawEntity.kind == 'Pipe' | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export * from './kamelet-binding'; | ||
export * from './pipe'; | ||
export * from './route'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { Pipe as PipeModel } from '@kaoto-next/camel-catalog/types'; | ||
import { v4 as uuidv4 } from 'uuid'; | ||
import { BaseVisualCamelEntity, EntityType } from '../base-entity'; | ||
import { KameletBinding } from './kamelet-binding'; | ||
|
||
export class Pipe extends KameletBinding implements BaseVisualCamelEntity { | ||
readonly id = uuidv4(); | ||
type = EntityType.Pipe; | ||
|
||
constructor(public route: Partial<PipeModel> = {}) { | ||
super(); | ||
} | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import { Pipe } from '../models/camel-entities'; | ||
|
||
/** | ||
* This is a stub Pipe in YAML format. | ||
* It is used to test the Canvas component. | ||
*/ | ||
export const pipeYaml = ` | ||
apiVersion: camel.apache.org/v1 | ||
kind: Pipe | ||
metadata: | ||
name: webhook-binding | ||
spec: | ||
source: | ||
ref: | ||
kind: Kamelet | ||
apiVersion: camel.apache.org/v1 | ||
name: webhook-source | ||
steps: | ||
- ref: | ||
kind: Kamelet | ||
apiVersion: camel.apache.org/v1 | ||
name: delay-action | ||
sink: | ||
ref: | ||
kind: Kamelet | ||
apiVersion: camel.apache.org/v1 | ||
name: log-sink`; | ||
|
||
/** | ||
* This is a stub Pipe in JSON format. | ||
* It is used to test the Canvas component. | ||
*/ | ||
export const pipeJson = { | ||
apiVersion: 'camel.apache.org/v1', | ||
kind: 'Pipe', | ||
metadata: { | ||
name: 'webhook-binding', | ||
}, | ||
spec: { | ||
source: { | ||
ref: { | ||
kind: 'Kamelet', | ||
apiVersion: 'camel.apache.org/v1', | ||
name: 'webhook-source', | ||
}, | ||
}, | ||
steps: [ | ||
{ | ||
ref: { | ||
kind: 'Kamelet', | ||
apiVersion: 'camel.apache.org/v1', | ||
name: 'delay-action', | ||
}, | ||
}, | ||
], | ||
sink: { | ||
ref: { | ||
kind: 'Kamelet', | ||
apiVersion: 'camel.apache.org/v1alpha1', | ||
name: 'log-sink', | ||
}, | ||
}, | ||
}, | ||
}; | ||
|
||
export const pipe = new Pipe(pipeJson); |