{"version":3,"sources":["jsdelivr-header.js","/npm/@elyra/pipeline-schemas@3.0.100/common-pipeline/pipeline-flow/upgrade/upgrade-flow.js"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA,ACgBA,MAAM,cAAgB,EAGhB,eAAiB,EAGjB,YAAc,CACnB,YACA,YACA,aAcD,SAAS,eAAe,GACvB,IAAI,EAEJ,IAAK,IAAiB,EAAa,SACA,iBAAzB,EAAa,SACU,IAAhC,EAAa,QAAQ,OACrB,MAAM,IAAI,MAAM,iFAGhB,KADA,EAAc,SAAS,EAAa,QAAS,KAE5C,MAAM,IAAI,MAAM,4EAGlB,OAAO,CACR,CAWA,SAAS,YAAY,GAEpB,OADA,EAAa,QAAU,MAChB,CACR,CAWA,SAAS,YAAY,GACpB,EAAa,QAAU,MACvB,EAAa,YAAc,sGAM3B,IAAK,IAAI,EAAM,EAAG,EAAM,EAAa,UAAU,OAAQ,IAAO,CAE7D,6BADiB,EAAa,UAAU,GAEzC,CAGA,IAAK,IAAI,EAAM,EAAG,EAAM,EAAa,UAAU,OAAQ,IAAO,CAE7D,qBADiB,EAAa,UAAU,GAEzC,CAGK,EAAa,WACjB,EAAa,SAAW,IAEzB,IAAK,IAAI,EAAM,EAAG,EAAM,EAAa,UAAU,OAAQ,IAAO,CAC7D,MAAM,EAAW,EAAa,UAAU,GACxC,GAAI,EAAS,QAAS,CACrB,MAAM,EAAc,EAAS,QAC7B,EAAS,YAAc,EACwB,OAA3C,YAAY,EAAc,IAE7B,EAAa,SAAS,KAAK,CAC1B,GAAM,EACN,KAAQ,WAGH,EAAS,OACjB,CACD,CAEA,OAAO,CACR,CASA,SAAS,YAAY,GAIpB,OAHA,EAAa,QAAU,MACvB,EAAa,YAAc,sGAEpB,CACR,CAUA,SAAS,YAAY,EAAc,GAClC,GAAI,EAAa,SAChB,IAAK,IAAI,EAAM,EAAG,EAAM,EAAa,SAAU,IAAO,CACrD,MAAM,EAAU,EAAa,SAAS,GACtC,GAAI,EAAQ,OAAS,EACpB,OAAO,CAET,CAED,OAAO,IACR,CAQA,SAAS,6BAA6B,GACrC,IAAK,IAAI,EAAM,EAAG,EAAM,EAAS,MAAM,OAAQ,IAAO,CACrD,MAAM,EAAO,EAAS,MAAM,GACV,YAAd,EAAK,YAEkB,IAAf,EAAK,OACX,EAAK,MAAM,OACd,EAAK,MAAM,MAAQ,CAAC,EAAK,MAAM,aACxB,EAAK,MAAM,MAEnB,EAAK,OAAS,CAAC,EAAK,cACb,EAAK,YACqB,IAAhB,EAAK,SACtB,EAAK,QAAU,CAAC,EAAK,eACd,EAAK,QAGf,CACD,CAQA,SAAS,qBAAqB,GAC7B,IAAK,IAAI,EAAM,EAAG,EAAM,EAAS,MAAM,OAAQ,IAAO,CACrD,MAAM,EAAO,EAAS,MAAM,GAC5B,GAAI,EAAK,MACR,IAAK,IAAI,EAAM,EAAG,EAAM,EAAK,MAAM,OAAQ,IAAO,CACjD,MAAM,EAAO,EAAK,MAAM,GACpB,EAAK,wBACD,EAAK,eAEd,CAEF,CACD,CAYA,SAAS,QAAQ,GAChB,MAAM,EAAc,KAAK,IAAI,eAAe,GAnMvB,GAqMrB,IADA,IAAI,EAAO,KAAK,MAAM,KAAK,UAAU,IAC5B,EAAM,EAAa,EAlMN,EAkM4B,IACjD,EAAO,YAAY,GAAK,GAEzB,OAAO,CACR,CAGA,OAAO,QAAU,CAChB,oBAAqB,QACrB,eAAgB,eAChB,eA5MsB","file":"/npm/@elyra/pipeline-schemas@3.0.100/common-pipeline/pipeline-flow/upgrade/upgrade-flow.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/@elyra/pipeline-schemas@3.0.100/common-pipeline/pipeline-flow/upgrade/upgrade-flow.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","/*\n * Copyright 2017-2025 Elyra Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n /* eslint max-depth: [\"error\", 6] */\n\n// Modules\n\n// Globals -------------------------------------------------------------------->\n\n// The lowest version accepted\nconst FIRST_VERSION = 1;\n\n// The latest pipeline-flow version - update as new versions are developed\nconst LATEST_VERSION = 3;\n\n// Array of major version upgrade functions\nconst updateFuncs = [\n\t_update0to1,\n\t_update1to2,\n\t_update2to3\n];\n\n// Private Methods ------------------------------------------------------------>\n\n/**\n * Extracts the version from the given pipeline-flow.\n *\n * @param {Object} pipelineFlow: A pipeline-flow JSON object\n *\n * @return {integer} An integer version number\n *\n * @throws {Error} If the version number cannot be extracted\n */\nfunction extractVersion(pipelineFlow) {\n\tvar baseVersion;\n\t// Validate the incoming pipeline-flow\n\tif (!pipelineFlow || !pipelineFlow.version ||\n\t\t!(typeof pipelineFlow.version === \"string\") ||\n\t\tpipelineFlow.version.length === 0) {\n\t\tthrow new Error(\"Invalid pipeline-flow document: The 'version' attribute is missing or invalid\");\n\t} else {\n\t\tbaseVersion = parseInt(pipelineFlow.version, 10);\n\t\tif (!baseVersion) {\n\t\t\tthrow new Error(\"Invalid pipeline-flow document: The 'version' attribute cannot be parsed\");\n\t\t}\n\t}\n\treturn baseVersion;\n}\n\n// Version 1 methods ------------------------>\n\n/**\n * Updates version 0 to version 1.\n *\n * @param {object} pipelineFlow: A pipeline-flow JSON object\n *\n * @return A pipeline-flow object that has been upgraded to version 1\n */\nfunction _update0to1(pipelineFlow) {\n\tpipelineFlow.version = \"1.0\";\n\treturn pipelineFlow;\n}\n\n// Version 2 methods ------------------------>\n\n/**\n * Updates version 1 to version 2.\n *\n * @param {object} pipelineFlow: A pipeline-flow JSON object\n *\n * @return A pipeline-flow object that has been upgraded to version 2\n */\nfunction _update1to2(pipelineFlow) {\n\tpipelineFlow.version = \"2.0\";\n\tpipelineFlow.json_schema = \"https://api.dataplatform.ibm.com/schemas/common-pipeline/pipeline-flow/pipeline-flow-v2-schema.json\";\n\n\t// --> Changed the binding node. Instead of just a single input or output port,\n\t// binding nodes can have either an array of input ports or an array of output ports.\n\t// Also added \"parameters\" and \"op\" elements in the binding node *\n\t// Cycle the pipelines...\n\tfor (var id1 = 0; id1 < pipelineFlow.pipelines.length; id1++) {\n\t\tconst pipeline = pipelineFlow.pipelines[id1];\n\t\tupdateBindingNodesInPipeline(pipeline);\n\t}\n\n\t// --> \"pipeline_id_ref\" was removed from \"link_def\"\n\tfor (var id2 = 0; id2 < pipelineFlow.pipelines.length; id2++) {\n\t\tconst pipeline = pipelineFlow.pipelines[id2];\n\t\tupdatePipelinesIdRef(pipeline);\n\t}\n\n\t// --> Renamed \"runtime\" to \"runtime_ref\" and added an array of runtime objects that \"runtime_ref\" refers to\n\tif (!pipelineFlow.runtimes) {\n\t\tpipelineFlow.runtimes = [];\n\t}\n\tfor (var id3 = 0; id3 < pipelineFlow.pipelines.length; id3++) {\n\t\tconst pipeline = pipelineFlow.pipelines[id3];\n\t\tif (pipeline.runtime) {\n\t\t\tconst runtimeName = pipeline.runtime;\n\t\t\tpipeline.runtime_ref = runtimeName;\n\t\t\tif (_getRuntime(pipelineFlow, runtimeName) === null) {\n\t\t\t\t// Add a new runtime object\n\t\t\t\tpipelineFlow.runtimes.push({\n\t\t\t\t\t\"id\": runtimeName,\n\t\t\t\t\t\"name\": runtimeName\n\t\t\t\t});\n\t\t\t}\n\t\t\tdelete pipeline.runtime;\n\t\t}\n\t}\n\n\treturn pipelineFlow;\n}\n\n/**\n * Updates version 2 to version 3.\n *\n * @param {object} pipelineFlow: A pipeline-flow JSON object\n *\n * @return A pipeline-flow object that has been upgraded to version 2\n */\nfunction _update2to3(pipelineFlow) {\n\tpipelineFlow.version = \"3.0\";\n\tpipelineFlow.json_schema = \"https://api.dataplatform.ibm.com/schemas/common-pipeline/pipeline-flow/pipeline-flow-v3-schema.json\";\n\n\treturn pipelineFlow;\n}\n\n/**\n * Attempts to locate a runtime object with the given name.\n *\n * @param {Object} pipelineFlow: A pipeline-flow JSON object\n * @param {String} name: The name of the runtime to search for\n *\n * @return {Object} a runtime object or null if not found\n */\nfunction _getRuntime(pipelineFlow, runtimeName) {\n\tif (pipelineFlow.runtimes) {\n\t\tfor (var idx = 0; idx < pipelineFlow.runtimes; idx++) {\n\t\t\tconst runtime = pipelineFlow.runtimes[idx];\n\t\t\tif (runtime.name === runtimeName) {\n\t\t\t\treturn runtime;\n\t\t\t}\n\t\t}\n\t}\n\treturn null;\n}\n\n/**\n * Updates the binding nodes in the given pipeline to 2.0 state.\n *\n * @param {object} pipeline: A single pipeline\n * @return {void}\n */\nfunction updateBindingNodesInPipeline(pipeline) {\n\tfor (var id2 = 0; id2 < pipeline.nodes.length; id2++) {\n\t\tconst node = pipeline.nodes[id2];\n\t\tif (node.type === \"binding\") {\n\t\t\t// Extract the port and add it to a new array of ports instead\n\t\t\tif (typeof node.input !== \"undefined\") {\n\t\t\t\tif (node.input.link) {\n\t\t\t\t\tnode.input.links = [node.input.link];\n\t\t\t\t\tdelete node.input.link;\n\t\t\t\t}\n\t\t\t\tnode.inputs = [node.input];\n\t\t\t\tdelete node.input;\n\t\t\t} else if (typeof node.output !== \"undefined\") {\n\t\t\t\tnode.outputs = [node.output];\n\t\t\t\tdelete node.output;\n\t\t\t}\n\t\t}\n\t}\n}\n\n/**\n * Removes all pipeline_id_ref elements from ports.\n *\n * @param {object} pipeline: A single pipeline\n * @return {void}\n */\nfunction updatePipelinesIdRef(pipeline) {\n\tfor (var id2 = 0; id2 < pipeline.nodes.length; id2++) {\n\t\tconst node = pipeline.nodes[id2];\n\t\tif (node.links) {\n\t\t\tfor (var id3 = 0; id3 < node.links.length; id3++) {\n\t\t\t\tconst link = node.links[id3];\n\t\t\t\tif (link.pipeline_id_ref) {\n\t\t\t\t\tdelete link.pipeline_id_ref;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\n\n// Public Methods ------------------------------------------------------------->\n\n/**\n * Upgrades the given pipeline-flow object to the current version.\n *\n * @param {Object} pipelineFlow: A pipeline-flow JSON object\n *\n * @returns A pipeline-flow object that has been upgraded to the latest version\n */\nfunction upgrade(pipelineFlow) {\n\tconst baseVersion = Math.max(extractVersion(pipelineFlow), FIRST_VERSION);\n\tvar flow = JSON.parse(JSON.stringify(pipelineFlow));\n\tfor (var idx = baseVersion; idx < LATEST_VERSION; idx++) {\n\t\tflow = updateFuncs[idx](flow);\n\t}\n\treturn flow;\n}\n\n\nmodule.exports = {\n\tupgradePipelineFlow: upgrade,\n\textractVersion: extractVersion,\n\tLATEST_VERSION: LATEST_VERSION\n};\n"]}