UNPKG

pesco-karavan-core

Version:
123 lines (102 loc) 3.33 kB
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import {v4 as uuidv4} from 'uuid'; import {NamedBeanDefinition} from "./CamelDefinition"; export class Dependency { group: string = ''; artifact: string = ''; version: string = ''; uuid: string = ''; dslName: string = ''; public constructor(init?: Partial<Dependency>) { Object.assign(this, init); this.dslName = 'Dependency'; this.uuid = uuidv4(); } static createNew(url: string): Dependency { const parts = url.split(":"); return new Dependency({group:parts[1], artifact:parts[2], version:parts[3]}) } getFullName(): string { return this.group + ":" + this.artifact + ":" + this.version; } } export class EnvironmentVars { vars?: string[]; } export class Traits { environment?: EnvironmentVars; } export class Spec { flows?: any[] = []; dependencies?: Dependency[] = []; traits?: Traits; public constructor(init?: Partial<Spec>) { Object.assign(this, init); } } export class Metadata { name: string = ''; public constructor(init?: Partial<Metadata>) { Object.assign(this, init); } } export class Integration { apiVersion: string = 'camel.apache.org/v1'; // camel.apache.org/v1alpha1 kind: string = 'Integration'; // Kamelet metadata: Metadata = new Metadata(); spec: Spec = new Spec(); type: 'crd' | 'plain' | 'kamelet' = 'crd'; public constructor(init?: Partial<Integration>) { Object.assign(this, init); } static createNew(name?: string): Integration { return new Integration({metadata: new Metadata({name: name}), spec: new Spec({flows: []})}) } } export class CamelElement { uuid: string = '' dslName: string = '' show: boolean = true constructor(dslName: string) { this.uuid = uuidv4() this.dslName = dslName } hasSteps(): boolean { return this.hasOwnProperty('steps'); } hasStepName(): boolean { return this.hasOwnProperty('stepName'); } } export class Beans extends CamelElement { beans: NamedBeanDefinition[] = [] public constructor(init?: Partial<Beans>) { super("Beans") Object.assign(this, init); } } export class CamelElementMeta { step?: CamelElement parentUuid?: string position: number = 0; constructor(step?: CamelElement, parentUuid?: string, position?: number) { this.step = step; this.parentUuid = parentUuid; this.position = position || 0; } }