0 votes
14 views
ago by (30.6k points)
We keep .twx exports in Git but they are binary blobs to us. What is the structure of a twx, can it be read or compared with scripts, and is editing it a supported practice?

1 Answer

0 votes
ago by (30.6k points)

A .twx is a zip file. Inside:

META-INF/package.xml        manifest: project (process app / toolkit), branch, snapshot, dependencies (toolkit snapshot ids), and the list of every object with id, type and version id
objects/<type>.<uuid>.xml   one XML per library artifact: 25.* BPDs (BPMN 2.0 + BAW extensions), 1.* services / human services (flow + scripts inside <script> elements),
                            64.* coach views (layout XML, inline JavaScript in <scriptBlock>, config options), 12.* business objects, 7.* teams, 61.* managed files (metadata),
                            4.* tracking groups, 24.* UCAs, 50.* EPVs, 21.* decisions, 2094.* environment variables …
files/<asset id>/<file>     the binary content of managed files (web assets, jars, zips)
<toolkit>.twx (nested)      dependent toolkits included as nested twx when "include toolkits" was chosen at export
# inspect: counts per type and the snapshot
unzip -l app.twx | head; unzip -p app.twx META-INF/package.xml | grep -o '<snapshot [^>]*name="[^"]*"'
unzip -p app.twx META-INF/package.xml | grep -o 'type="[^"]*"' | sort | uniq -c
# extract the JavaScript of every service and coach view for grep / lint (they are XML-escaped inside the XML)
mkdir x && cd x && unzip -q ../app.twx && python3 - <<'EOF'
import glob, re, html
for f in glob.glob('objects/*.xml'):
    t = open(f, encoding='utf-8').read()
    for i, s in enumerate(re.findall(r'<(?:script|scriptBlock)>(.*?)</(?:script|scriptBlock)>', t, re.S)):
        open(f + f'.{i}.js', 'w').write(html.unescape(s))
EOF
grep -l "console.log\|debugger" objects/*.js                # things that should not ship
# diff two snapshots: normalise the volatile parts (version ids, timestamps) then diff the object XML files by artifact id

Reading and analysing a twx is common practice (static analysers, dependency checks, searching for a hard-coded host across every app); editing a twx by hand and re-importing is possible but unsupported - the import validates ids and the manifest, and mistakes surface as "check the server logs" import failures; if you do it, regenerate version ids, keep the manifest consistent, and treat the result as a new snapshot in a test environment first. For diffs the designer's snapshot comparison (Process Center > snapshot > compare) is the supported view; scripted diffs on the extracted XML are what CI pipelines use for change reports.

References

Related questions

0 votes
1 answer 1.4k views

723 questions

807 answers

98 comments

4.8k users

Join BPM Community Discord Channel

Welcome to BPM Tips Q&A, Community wiki/forum where you can ask questions and receive answers from other IBM BPM experts and members of the community. Users with 2000 points will automatically be promoted to expert level.
Created by Dosvak LLC
Our Youtube Channel
...