/*
* 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 BlueprintSettings from './BlueprintSettings'
import BlueprintMode from './BlueprintMode'
import Connection from './Connection'
import Pipeline from './Pipeline'
/**
* @typedef {object} Blueprint
* @property {number} id
* @property {Connection} connection
* @property {string} name
* @property {string?} description
* @property {Date?} createdAt
* @property {Date?} updatedAt
* @property {array} plan
* @typedef {BlueprintSettings} settings
* @property {'daily'|'weekly'|'monthly'|'hourly'|'custom'|'manual'} interval
* @property {string} cronConfig
* @property {'NORMAL'|'ADVANCED'} mode
* @property {bool} enable
* @property {bool} isManual
* @property {<Array<Pipeline>>} pipelines
* @property {function(string): string} get
* @property {function(string, string): string} set
* @property {function(): string} asJSON
* @property {function(): <Array<Connection>>} connections
* @property {function(): <BlueprintSettings>} getSettings
* @property {function(): bool} isAdvanced
* @property {function(): bool} isNormal
*/
class Blueprint {
constructor(data = {}) {
this.id = data?.id
this.connection = data?.connection
? new Connection(data?.connection)
: new Connection()
this.name = data?.name || 'MY BLUEPRINT'
this.createdAt = new Date()
this.updatedAt = null
this.settings = new BlueprintSettings({
version: data?.settings?.version || '1.0.0',
connections: data?.settings?.connections || []
})
this.cronConfig = data?.cronConfig || '0 0 * * *'
this.mode = data?.mode || 'NORMAL'
this.enable = data?.enable || false
this.isManual = data?.isManual || false
this.description = data?.description || ''
this.pipelines = data?.pipelines || []
}
get(property) {
return this[property]
}
set(property, value) {
this[property] = value
return this[property]
}
asJSON() {
return JSON.stringify(this, null, ' ')
}
getConnections() {
return this.settings.connections
}
getSettings() {
return this.settings
}
isAdvanced() {
return this.mode === 'ADVANCED'
}
isNormal() {
return this.mode === 'NORMAL'
}
}
export default Blueprint
Config-UI / Data Models / Blueprint, Pipeline+
Create the Blueprint, Pipeline and associated Data Models and adapt/integrate with existing Blueprint Components.