karavan-core 4.8.0 → 99.0.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of karavan-core might be problematic. Click here for more details.
- package/index.js +3 -0
- package/package.json +8 -58
- package/.bebelrc +0 -3
- package/.mocharc.json +0 -11
- package/.prettierignore +0 -9
- package/.prettierrc +0 -14
- package/src/core/api/CamelDefinitionApi.ts +0 -3271
- package/src/core/api/CamelDefinitionApiExt.ts +0 -757
- package/src/core/api/CamelDefinitionYaml.ts +0 -412
- package/src/core/api/CamelDefinitionYamlStep.ts +0 -4733
- package/src/core/api/CamelDisplayUtil.ts +0 -143
- package/src/core/api/CamelUtil.ts +0 -360
- package/src/core/api/ComponentApi.ts +0 -368
- package/src/core/api/KameletApi.ts +0 -147
- package/src/core/api/MainConfigurationApi.ts +0 -47
- package/src/core/api/ProjectModelApi.ts +0 -75
- package/src/core/api/SpiBeanApi.ts +0 -104
- package/src/core/api/TemplateApi.ts +0 -58
- package/src/core/api/TopologyUtils.ts +0 -392
- package/src/core/api/VariableUtil.ts +0 -104
- package/src/core/model/CamelDefinition.ts +0 -3783
- package/src/core/model/CamelMetadata.ts +0 -2714
- package/src/core/model/ComponentModels.ts +0 -106
- package/src/core/model/IntegrationDefinition.ts +0 -188
- package/src/core/model/KameletModels.ts +0 -223
- package/src/core/model/MainConfigurationModel.ts +0 -37
- package/src/core/model/ProjectModel.ts +0 -43
- package/src/core/model/SpiBeanModels.ts +0 -53
- package/src/core/model/TopologyDefinition.ts +0 -117
- package/test/addStep.spec.ts +0 -124
- package/test/addStep1.yaml +0 -27
- package/test/allowableValues.camel.yaml +0 -19
- package/test/allowableValues.spec.ts +0 -30
- package/test/avro-serialize-action.kamelet.yaml +0 -70
- package/test/beans.spec.ts +0 -92
- package/test/beans1.yaml +0 -36
- package/test/beans2.yaml +0 -42
- package/test/beans3.yaml +0 -7
- package/test/checkRequired.spec.ts +0 -53
- package/test/circuitBreaker.spec.ts +0 -57
- package/test/circuitBreaker.yaml +0 -19
- package/test/cloneDefinition.spec.ts +0 -106
- package/test/createKamelet.spec.ts +0 -38
- package/test/cxf.json +0 -615
- package/test/cxf.spec.ts +0 -44
- package/test/cxf.yaml +0 -15
- package/test/deleteStep.spec.ts +0 -74
- package/test/demo.spec.ts +0 -49
- package/test/demo.yaml +0 -32
- package/test/doCatchOnWhen.camel.yaml +0 -20
- package/test/doCatchOnWhen.spec.ts +0 -36
- package/test/errorHandler.spec.ts +0 -38
- package/test/errorHandler1.yaml +0 -27
- package/test/expression.spec.ts +0 -55
- package/test/findStep.spec.ts +0 -112
- package/test/findStep.yaml +0 -65
- package/test/getElementProperties.spec.ts +0 -32
- package/test/getElementPropertiesByName.spec.ts +0 -31
- package/test/getExpressionLanguage.spec.ts +0 -40
- package/test/hasElementWithId.camel.yaml +0 -98
- package/test/hasElementWithId.spec.ts +0 -57
- package/test/hasElementWithId1.camel.yaml +0 -16
- package/test/hasElementWithIdError.camel.yaml +0 -98
- package/test/integration.spec.ts +0 -60
- package/test/integration1.yaml +0 -24
- package/test/integration2.yaml +0 -23
- package/test/integrationToYaml.spec.ts +0 -51
- package/test/intercept.spec.ts +0 -62
- package/test/intercept.yaml +0 -19
- package/test/is-not-integration.yaml +0 -5114
- package/test/isIntegration.spec.ts +0 -45
- package/test/kamelet.spec.ts +0 -61
- package/test/metadata/components.json +0 -697
- package/test/metadata/kamelets.yaml +0 -23414
- package/test/metadata/spiBeans.json +0 -3094
- package/test/multiObjectProperties.spec.ts +0 -46
- package/test/multiObjectProperties1.yaml +0 -19
- package/test/multiple.spec.ts +0 -38
- package/test/multiple.yaml +0 -29
- package/test/openapi.spec.ts +0 -48
- package/test/openapi.yaml +0 -7
- package/test/placeholder.spec.ts +0 -32
- package/test/placeholder.yaml +0 -133
- package/test/plain-try-catch.yaml +0 -31
- package/test/plain.spec.ts +0 -72
- package/test/plain1.yaml +0 -22
- package/test/plain2.yaml +0 -13
- package/test/plain3.yaml +0 -5
- package/test/plain4.yaml +0 -5
- package/test/postgresql-source.kamelet.yaml +0 -113
- package/test/restConfigDsl.yaml +0 -15
- package/test/restDsl.spec.ts +0 -83
- package/test/restDsl.yaml +0 -29
- package/test/routes.spec.ts +0 -37
- package/test/routes1.yaml +0 -31
- package/test/supported-components.json +0 -1221
- package/test/supportedComponents.spec.ts +0 -34
- package/test/template1.AggregationStrategy.java +0 -21
- package/test/template1.Processor.java +0 -13
- package/test/template2.AggregationStrategy.java +0 -21
- package/test/template2.Processor.java +0 -13
- package/test/templateApi.spec.ts +0 -45
- package/test/timer-source.kamelet.yaml +0 -75
- package/test/tod.spec.ts +0 -31
- package/test/tod.yaml +0 -9
- package/test/topology.spec.ts +0 -51
- package/test/topology1.camel.yaml +0 -56
- package/test/topology2.camel.yaml +0 -44
- package/test/topology3.camel.yaml +0 -27
- package/test/tsconfig.testing.json +0 -14
- package/test/updateStep.spec.ts +0 -72
- package/test/variable1.camel.yaml +0 -42
- package/test/variable2.camel.yaml +0 -42
- package/test/variables.spec.ts +0 -34
- package/tsconfig.json +0 -34
@@ -1,57 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
* Licensed to the Apache Software Foundation (ASF) under one or more
|
3
|
-
* contributor license agreements. See the NOTICE file distributed with
|
4
|
-
* this work for additional information regarding copyright ownership.
|
5
|
-
* The ASF licenses this file to You under the Apache License, Version 2.0
|
6
|
-
* (the "License"); you may not use this file except in compliance with
|
7
|
-
* the License. You may obtain a copy of the License at
|
8
|
-
*
|
9
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
10
|
-
*
|
11
|
-
* Unless required by applicable law or agreed to in writing, software
|
12
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
-
* See the License for the specific language governing permissions and
|
15
|
-
* limitations under the License.
|
16
|
-
*/
|
17
|
-
import {expect} from 'chai';
|
18
|
-
import 'mocha';
|
19
|
-
import {
|
20
|
-
FromDefinition,
|
21
|
-
LogDefinition,
|
22
|
-
WhenDefinition,
|
23
|
-
ChoiceDefinition,
|
24
|
-
MulticastDefinition,
|
25
|
-
ExpressionDefinition,
|
26
|
-
RouteDefinition, TryDefinition,CatchDefinition
|
27
|
-
} from "../src/core/model/CamelDefinition";
|
28
|
-
import {CamelDefinitionApiExt} from "../src/core/api/CamelDefinitionApiExt";
|
29
|
-
import {CamelDefinitionYaml} from "../src/core/api/CamelDefinitionYaml";
|
30
|
-
import {SimpleExpression} from "../src/core/model/CamelDefinition";
|
31
|
-
import {Integration} from "../src/core/model/IntegrationDefinition";
|
32
|
-
import * as fs from 'fs';
|
33
|
-
import {CamelModelMetadata, ElementMeta} from "../src/core/model/CamelMetadata";
|
34
|
-
import {CircuitBreakerDefinition, Resilience4jConfigurationDefinition} from "../src/core/model/CamelDefinition";
|
35
|
-
|
36
|
-
describe('Circuit Breaker', () => {
|
37
|
-
|
38
|
-
it('Add Step', () => {
|
39
|
-
const i = Integration.createNew("circuitBreaker");
|
40
|
-
i.type = "plain"
|
41
|
-
|
42
|
-
const circuitBreaker = new CircuitBreakerDefinition({ id: 'cb-1',
|
43
|
-
resilience4jConfiguration: new Resilience4jConfigurationDefinition({id: 'rc-1',minimumNumberOfCalls: 5, failureRateThreshold: 50}),
|
44
|
-
steps: [new LogDefinition({id: 'log-1',logName: 'log11', message: "hello11"})]
|
45
|
-
})
|
46
|
-
const flow1 = new FromDefinition({uri: "direct", id: 'from-1', parameters: {name: "direct1"}});
|
47
|
-
|
48
|
-
flow1.steps?.push(circuitBreaker);
|
49
|
-
i.spec.flows?.push(new RouteDefinition({id: 'route-1', from:flow1}));
|
50
|
-
|
51
|
-
const yaml = CamelDefinitionYaml.integrationToYaml(i);
|
52
|
-
const yaml2 = fs.readFileSync('test/circuitBreaker.yaml',{encoding:'utf8', flag:'r'});
|
53
|
-
const i2 = CamelDefinitionYaml.yamlToIntegration("circuitBreaker.yaml", yaml2);
|
54
|
-
const yaml3 = CamelDefinitionYaml.integrationToYaml(i2);
|
55
|
-
expect(yaml).to.equal(yaml3);
|
56
|
-
});
|
57
|
-
});
|
package/test/circuitBreaker.yaml
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
- route:
|
2
|
-
id: route-1
|
3
|
-
from:
|
4
|
-
uri: direct
|
5
|
-
parameters:
|
6
|
-
name: direct1
|
7
|
-
id: from-1
|
8
|
-
steps:
|
9
|
-
- circuitBreaker:
|
10
|
-
id: cb-1
|
11
|
-
resilience4jConfiguration:
|
12
|
-
id: rc-1
|
13
|
-
minimumNumberOfCalls: 5
|
14
|
-
failureRateThreshold: 50
|
15
|
-
steps:
|
16
|
-
- log:
|
17
|
-
message: hello11
|
18
|
-
id: log-1
|
19
|
-
logName: log11
|
@@ -1,106 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
* Licensed to the Apache Software Foundation (ASF) under one or more
|
3
|
-
* contributor license agreements. See the NOTICE file distributed with
|
4
|
-
* this work for additional information regarding copyright ownership.
|
5
|
-
* The ASF licenses this file to You under the Apache License, Version 2.0
|
6
|
-
* (the "License"); you may not use this file except in compliance with
|
7
|
-
* the License. You may obtain a copy of the License at
|
8
|
-
*
|
9
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
10
|
-
*
|
11
|
-
* Unless required by applicable law or agreed to in writing, software
|
12
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
-
* See the License for the specific language governing permissions and
|
15
|
-
* limitations under the License.
|
16
|
-
*/
|
17
|
-
import {expect} from 'chai';
|
18
|
-
import 'mocha';
|
19
|
-
import { FilterDefinition, LogDefinition, ChoiceDefinition,
|
20
|
-
FromDefinition, OtherwiseDefinition,
|
21
|
-
SimpleExpression,
|
22
|
-
ToDefinition,
|
23
|
-
WhenDefinition} from "../src/core/model/CamelDefinition";
|
24
|
-
import {CamelDefinitionApi} from "../src/core/api/CamelDefinitionApi";
|
25
|
-
import {ExpressionDefinition} from "../src/core/model/CamelDefinition";
|
26
|
-
import {Integration} from "../src/core/model/IntegrationDefinition";
|
27
|
-
import {RouteDefinition} from "../src/core/model/CamelDefinition";
|
28
|
-
import {CamelUtil} from "../src/core/api/CamelUtil";
|
29
|
-
|
30
|
-
describe('Clone', () => {
|
31
|
-
|
32
|
-
it('Clone integration', () => {
|
33
|
-
const i1 = Integration.createNew("test")
|
34
|
-
|
35
|
-
const when1 = new WhenDefinition({
|
36
|
-
expression: new ExpressionDefinition({simple: new SimpleExpression({expression:'${body} != null'})}),
|
37
|
-
steps: [new LogDefinition({logName: 'log11', message: "hello11"})]
|
38
|
-
})
|
39
|
-
const when2 = new WhenDefinition({
|
40
|
-
expression: new ExpressionDefinition({simple: '${body} == null'}),
|
41
|
-
steps: [new LogDefinition({logName: 'log22', message: "hello22"})]
|
42
|
-
})
|
43
|
-
const otherwise = new OtherwiseDefinition({steps: [new LogDefinition({logName: 'logX', message: "helloX"})]})
|
44
|
-
const choice = new ChoiceDefinition({when: [when1, when2], otherwise: otherwise})
|
45
|
-
|
46
|
-
const flow1 = new FromDefinition({uri: "direct1"});
|
47
|
-
flow1.steps?.push(choice);
|
48
|
-
flow1.steps?.push(new ToDefinition({uri: 'kamelet:kamelet2'}));
|
49
|
-
flow1.steps?.push(new ToDefinition({uri: 'kamelet:kamelet2'}));
|
50
|
-
flow1.parameters = {httpMethodRestrict: 'POST'}
|
51
|
-
i1.spec.flows?.push(new RouteDefinition({from: flow1}));
|
52
|
-
|
53
|
-
const flow2 = new FromDefinition({uri: "direct2"});
|
54
|
-
flow2.steps?.push(new LogDefinition({logName: 'log1', message: "hello1"}));
|
55
|
-
flow2.steps?.push(new LogDefinition({logName: 'log2', message: "hello2"}));
|
56
|
-
|
57
|
-
i1.spec.flows?.push(new RouteDefinition({from: flow2}));
|
58
|
-
const i2 = cloneIntegration(i1);
|
59
|
-
|
60
|
-
expect(i1.metadata.name).to.equal(i2.metadata.name);
|
61
|
-
expect(i1.spec.flows?.length).to.equal(i2.spec.flows?.length);
|
62
|
-
if (i1.spec.flows && i2.spec.flows){
|
63
|
-
const f1:FromDefinition = i1.spec.flows[0].from;
|
64
|
-
const f2:FromDefinition = i2.spec.flows[0].from;
|
65
|
-
expect(f1.parameters?.httpMethodRestrict).to.equal(f2.parameters?.httpMethodRestrict);
|
66
|
-
expect(f1.steps.length).to.equal(f2.steps.length);
|
67
|
-
|
68
|
-
const c1: ChoiceDefinition = f1.steps[0];
|
69
|
-
const c2: ChoiceDefinition = f2.steps[0];
|
70
|
-
|
71
|
-
expect(c1.when?.length).to.equal(c2.when?.length);
|
72
|
-
if (c1.when && c2.when){
|
73
|
-
const e1:SimpleExpression = <SimpleExpression>c1.when[0].expression?.simple;
|
74
|
-
const e2:SimpleExpression = <SimpleExpression>c1.when[0].expression?.simple;
|
75
|
-
expect(e1.expression).to.equal(e2.expression);
|
76
|
-
}
|
77
|
-
}
|
78
|
-
});
|
79
|
-
|
80
|
-
function cloneIntegration (integration: Integration): Integration {
|
81
|
-
const clone = JSON.parse(JSON.stringify(integration));
|
82
|
-
const int: Integration = new Integration({...clone});
|
83
|
-
const flows = int.spec.flows?.map(f => CamelDefinitionApi.createFromDefinition(f))
|
84
|
-
int.spec.flows = flows;
|
85
|
-
return int;
|
86
|
-
}
|
87
|
-
|
88
|
-
it('Clone Log step', () => {
|
89
|
-
const log1: LogDefinition = new LogDefinition({logName: 'log1', message: "hello1"});
|
90
|
-
const log2: LogDefinition = <LogDefinition> CamelUtil.cloneStep(log1);
|
91
|
-
expect(log1.dslName).to.equal(log2.dslName);
|
92
|
-
expect(log1.logName).to.equal(log2.logName);
|
93
|
-
expect(log1.message).to.equal(log2.message);
|
94
|
-
});
|
95
|
-
|
96
|
-
it('Clone Filter step', () => {
|
97
|
-
const filter1: FilterDefinition = new FilterDefinition({
|
98
|
-
expression: new ExpressionDefinition({simple: new SimpleExpression({expression:"${body} == null"})}),
|
99
|
-
steps: [new LogDefinition({logName:"log1", message:"Hello world"})]
|
100
|
-
});
|
101
|
-
const filter2: FilterDefinition = <LogDefinition> CamelUtil.cloneStep(filter1);
|
102
|
-
expect(filter1.dslName).to.equal(filter2.dslName);
|
103
|
-
expect((filter1?.expression?.simple as SimpleExpression).expression).to.equal((filter2?.expression?.simple as SimpleExpression).expression);
|
104
|
-
expect(filter1?.steps?.length).to.equal(filter2?.steps?.length);
|
105
|
-
});
|
106
|
-
});
|
@@ -1,38 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
* Licensed to the Apache Software Foundation (ASF) under one or more
|
3
|
-
* contributor license agreements. See the NOTICE file distributed with
|
4
|
-
* this work for additional information regarding copyright ownership.
|
5
|
-
* The ASF licenses this file to You under the Apache License, Version 2.0
|
6
|
-
* (the "License"); you may not use this file except in compliance with
|
7
|
-
* the License. You may obtain a copy of the License at
|
8
|
-
*
|
9
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
10
|
-
*
|
11
|
-
* Unless required by applicable law or agreed to in writing, software
|
12
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
-
* See the License for the specific language governing permissions and
|
15
|
-
* limitations under the License.
|
16
|
-
*/
|
17
|
-
import { expect } from 'chai';
|
18
|
-
import * as fs from 'fs';
|
19
|
-
import 'mocha';
|
20
|
-
import { CamelUtil } from '../src/core/api/CamelUtil';
|
21
|
-
import { KameletApi } from '../src/core/api/KameletApi';
|
22
|
-
|
23
|
-
|
24
|
-
describe('Create Kamelet', () => {
|
25
|
-
|
26
|
-
it('Create new Kamelet from existing', () => {
|
27
|
-
const kamelet = fs.readFileSync('test/timer-source.kamelet.yaml', { encoding: 'utf8', flag: 'r' });
|
28
|
-
KameletApi.saveKamelets([kamelet]);
|
29
|
-
const code = CamelUtil.createNewKameletCode("custom-timer-source.kamelet.yaml", 'source', "timer-source")
|
30
|
-
console.log(code);
|
31
|
-
// if (i.spec.flows) {
|
32
|
-
// expect(i.spec.flows[2].beans[0].name).to.equal('myNested');
|
33
|
-
// expect(i.spec.flows[2].beans[0].type).to.equal('${MyBean.class.name}');
|
34
|
-
// expect(i.spec.flows[2].beans[0].properties['nested.foo']).to.equal('valueFoo');
|
35
|
-
// expect(i.spec.flows[2].beans[1].name).to.equal('myProps');
|
36
|
-
// }
|
37
|
-
});
|
38
|
-
});
|