@shaztech/video-pipeline 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin.js +19 -0
- package/dist/editor/assets/index-DV6clFYC.js +71 -0
- package/dist/editor/assets/index-K7ALkYj6.css +1 -0
- package/dist/editor/index.html +18 -0
- package/package.json +42 -0
- package/src/cli.js +35 -0
- package/src/commands/create.js +43 -0
- package/src/commands/edit.js +57 -0
- package/src/commands/run.js +64 -0
- package/src/commands/validate.js +79 -0
- package/src/executor/index.js +148 -0
- package/src/executor/nodeHandlers/input-file.js +41 -0
- package/src/executor/nodeHandlers/input-folder.js +55 -0
- package/src/executor/nodeHandlers/video-cutter.js +145 -0
- package/src/executor/nodeHandlers/video-stitcher.js +190 -0
- package/src/executor/runner.js +75 -0
- package/src/executor/topoSort.js +61 -0
- package/src/server/index.js +81 -0
- package/src/server/routes.js +123 -0
- package/src/spec/defaultSpec.js +24 -0
- package/src/spec/schema.js +80 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2026 Shazron Abdullah
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
export function createDefaultSpec(name = 'my-pipeline') {
|
|
18
|
+
return {
|
|
19
|
+
version: '1',
|
|
20
|
+
name,
|
|
21
|
+
nodes: [],
|
|
22
|
+
edges: []
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2026 Shazron Abdullah
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
const KNOWN_NODE_TYPES = new Set(['video-cutter', 'video-stitcher', 'output-folder', 'input-file', 'input-folder'])
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Validates a pipeline spec object.
|
|
21
|
+
* Returns { valid: true } or { valid: false, errors: string[] }
|
|
22
|
+
*/
|
|
23
|
+
export function validateSpec(spec) {
|
|
24
|
+
const errors = []
|
|
25
|
+
|
|
26
|
+
if (!spec || typeof spec !== 'object') {
|
|
27
|
+
return { valid: false, errors: ['Spec must be a JSON object'] }
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
if (spec.version !== '1') {
|
|
31
|
+
errors.push(`Unsupported spec version: ${spec.version} (expected "1")`)
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (!spec.name || typeof spec.name !== 'string') {
|
|
35
|
+
errors.push('spec.name must be a non-empty string')
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (!Array.isArray(spec.nodes)) {
|
|
39
|
+
errors.push('spec.nodes must be an array')
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (!Array.isArray(spec.edges)) {
|
|
43
|
+
errors.push('spec.edges must be an array')
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
if (errors.length > 0) return { valid: false, errors }
|
|
47
|
+
|
|
48
|
+
const nodeIds = new Set()
|
|
49
|
+
|
|
50
|
+
for (const node of spec.nodes) {
|
|
51
|
+
if (!node.id || typeof node.id !== 'string') {
|
|
52
|
+
errors.push(`Node missing valid id: ${JSON.stringify(node)}`)
|
|
53
|
+
continue
|
|
54
|
+
}
|
|
55
|
+
if (nodeIds.has(node.id)) {
|
|
56
|
+
errors.push(`Duplicate node id: ${node.id}`)
|
|
57
|
+
}
|
|
58
|
+
nodeIds.add(node.id)
|
|
59
|
+
|
|
60
|
+
if (!KNOWN_NODE_TYPES.has(node.type)) {
|
|
61
|
+
errors.push(`Node "${node.id}" has unknown type: ${node.type}`)
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if (!node.config || typeof node.config !== 'object') {
|
|
65
|
+
errors.push(`Node "${node.id}" missing config object`)
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
for (const edge of spec.edges) {
|
|
70
|
+
if (!edge.id) errors.push(`Edge missing id: ${JSON.stringify(edge)}`)
|
|
71
|
+
if (!nodeIds.has(edge.source)) {
|
|
72
|
+
errors.push(`Edge "${edge.id}" references unknown source node: ${edge.source}`)
|
|
73
|
+
}
|
|
74
|
+
if (!nodeIds.has(edge.target)) {
|
|
75
|
+
errors.push(`Edge "${edge.id}" references unknown target node: ${edge.target}`)
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
return errors.length === 0 ? { valid: true } : { valid: false, errors }
|
|
80
|
+
}
|