ts-visio 1.0.0
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/LICENSE +21 -0
- package/README.md +343 -0
- package/dist/Layer.d.ts +12 -0
- package/dist/Layer.js +35 -0
- package/dist/Page.d.ts +30 -0
- package/dist/Page.js +169 -0
- package/dist/PageManager.d.ts +8 -0
- package/dist/PageManager.js +35 -0
- package/dist/SchemaDiagram.d.ts +22 -0
- package/dist/SchemaDiagram.js +36 -0
- package/dist/Shape.d.ts +68 -0
- package/dist/Shape.js +203 -0
- package/dist/ShapeModifier.d.ts +66 -0
- package/dist/ShapeModifier.js +889 -0
- package/dist/ShapeReader.d.ts +9 -0
- package/dist/ShapeReader.js +51 -0
- package/dist/VisioDocument.d.ts +21 -0
- package/dist/VisioDocument.js +119 -0
- package/dist/VisioPackage.d.ts +10 -0
- package/dist/VisioPackage.js +112 -0
- package/dist/core/MasterManager.d.ts +15 -0
- package/dist/core/MasterManager.js +43 -0
- package/dist/core/MediaConstants.d.ts +5 -0
- package/dist/core/MediaConstants.js +16 -0
- package/dist/core/MediaManager.d.ts +13 -0
- package/dist/core/MediaManager.js +88 -0
- package/dist/core/PageManager.d.ts +28 -0
- package/dist/core/PageManager.js +244 -0
- package/dist/core/RelsManager.d.ts +11 -0
- package/dist/core/RelsManager.js +81 -0
- package/dist/core/VisioConstants.d.ts +38 -0
- package/dist/core/VisioConstants.js +41 -0
- package/dist/core/VisioValidator.d.ts +27 -0
- package/dist/core/VisioValidator.js +362 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +32 -0
- package/dist/shapes/ConnectorBuilder.d.ts +37 -0
- package/dist/shapes/ConnectorBuilder.js +173 -0
- package/dist/shapes/ContainerBuilder.d.ts +6 -0
- package/dist/shapes/ContainerBuilder.js +103 -0
- package/dist/shapes/ForeignShapeBuilder.d.ts +4 -0
- package/dist/shapes/ForeignShapeBuilder.js +47 -0
- package/dist/shapes/ShapeBuilder.d.ts +4 -0
- package/dist/shapes/ShapeBuilder.js +68 -0
- package/dist/templates/MinimalVsdx.d.ts +10 -0
- package/dist/templates/MinimalVsdx.js +66 -0
- package/dist/types/VisioTypes.d.ts +85 -0
- package/dist/types/VisioTypes.js +14 -0
- package/dist/utils/StubHelpers.d.ts +7 -0
- package/dist/utils/StubHelpers.js +16 -0
- package/dist/utils/StyleHelpers.d.ts +30 -0
- package/dist/utils/StyleHelpers.js +95 -0
- package/dist/utils/VisioParsers.d.ts +6 -0
- package/dist/utils/VisioParsers.js +45 -0
- package/package.json +27 -0
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PageManager = void 0;
|
|
4
|
+
const fast_xml_parser_1 = require("fast-xml-parser");
|
|
5
|
+
const VisioConstants_1 = require("./VisioConstants");
|
|
6
|
+
const RelsManager_1 = require("./RelsManager");
|
|
7
|
+
class PageManager {
|
|
8
|
+
constructor(pkg) {
|
|
9
|
+
this.pkg = pkg;
|
|
10
|
+
this.pages = [];
|
|
11
|
+
this.loaded = false;
|
|
12
|
+
this.parser = new fast_xml_parser_1.XMLParser({
|
|
13
|
+
ignoreAttributes: false,
|
|
14
|
+
attributeNamePrefix: "@_"
|
|
15
|
+
});
|
|
16
|
+
this.builder = new fast_xml_parser_1.XMLBuilder({
|
|
17
|
+
ignoreAttributes: false,
|
|
18
|
+
attributeNamePrefix: "@_",
|
|
19
|
+
format: true
|
|
20
|
+
});
|
|
21
|
+
this.relsManager = new RelsManager_1.RelsManager(pkg);
|
|
22
|
+
}
|
|
23
|
+
load(force = false) {
|
|
24
|
+
if (!force && this.loaded) {
|
|
25
|
+
return this.pages;
|
|
26
|
+
}
|
|
27
|
+
// 1. Load Pages Index
|
|
28
|
+
let pagesContent;
|
|
29
|
+
try {
|
|
30
|
+
pagesContent = this.pkg.getFileText('visio/pages/pages.xml');
|
|
31
|
+
}
|
|
32
|
+
catch {
|
|
33
|
+
return [];
|
|
34
|
+
}
|
|
35
|
+
const parsedPages = this.parser.parse(pagesContent);
|
|
36
|
+
let pageNodes = parsedPages.Pages ? parsedPages.Pages.Page : [];
|
|
37
|
+
if (!Array.isArray(pageNodes)) {
|
|
38
|
+
pageNodes = pageNodes ? [pageNodes] : [];
|
|
39
|
+
}
|
|
40
|
+
if (pageNodes.length === 0) {
|
|
41
|
+
this.pages = [];
|
|
42
|
+
this.loaded = true;
|
|
43
|
+
return [];
|
|
44
|
+
}
|
|
45
|
+
// 2. Load Relationships to resolve paths
|
|
46
|
+
let relsContent;
|
|
47
|
+
try {
|
|
48
|
+
relsContent = this.pkg.getFileText('visio/pages/_rels/pages.xml.rels');
|
|
49
|
+
}
|
|
50
|
+
catch {
|
|
51
|
+
relsContent = '';
|
|
52
|
+
}
|
|
53
|
+
const relsMap = new Map(); // rId -> Target
|
|
54
|
+
if (relsContent) {
|
|
55
|
+
const parsedRels = this.parser.parse(relsContent);
|
|
56
|
+
let relNodes = parsedRels.Relationships ? parsedRels.Relationships.Relationship : [];
|
|
57
|
+
if (!Array.isArray(relNodes))
|
|
58
|
+
relNodes = relNodes ? [relNodes] : [];
|
|
59
|
+
for (const r of relNodes) {
|
|
60
|
+
relsMap.set(r['@_Id'], r['@_Target']);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
// 3. Map Pages
|
|
64
|
+
this.pages = pageNodes.map((node) => {
|
|
65
|
+
// r:id is in the Rel child element, not as a Page attribute
|
|
66
|
+
const rId = node.Rel?.['@_r:id'] || node['@_r:id']; // Support both for compatibility
|
|
67
|
+
const target = relsMap.get(rId) || '';
|
|
68
|
+
// Target is usually "page1.xml" or "pages/page1.xml" depending on relative structure.
|
|
69
|
+
// pages.xml is in "visio/pages/", so "page1.xml" means "visio/pages/page1.xml"
|
|
70
|
+
const fullPath = target ? `visio/pages/${target}` : '';
|
|
71
|
+
// Parse background page attributes
|
|
72
|
+
const bgAttr = node['@_Background'];
|
|
73
|
+
const isBackground = bgAttr === 'true' || bgAttr === '1' || bgAttr === true || bgAttr === 1;
|
|
74
|
+
const backPageAttr = node['@_BackPage'];
|
|
75
|
+
const backPageId = backPageAttr ? parseInt(backPageAttr.toString()) : undefined;
|
|
76
|
+
return {
|
|
77
|
+
id: parseInt(node['@_ID']),
|
|
78
|
+
name: node['@_Name'],
|
|
79
|
+
relId: rId,
|
|
80
|
+
xmlPath: fullPath,
|
|
81
|
+
isBackground,
|
|
82
|
+
backPageId
|
|
83
|
+
};
|
|
84
|
+
});
|
|
85
|
+
this.loaded = true;
|
|
86
|
+
return this.pages;
|
|
87
|
+
}
|
|
88
|
+
async createPage(name) {
|
|
89
|
+
this.load(); // Refresh state
|
|
90
|
+
// 1. Calculate ID
|
|
91
|
+
let maxId = 0;
|
|
92
|
+
for (const p of this.pages) {
|
|
93
|
+
if (p.id > maxId)
|
|
94
|
+
maxId = p.id;
|
|
95
|
+
}
|
|
96
|
+
const newId = maxId + 1;
|
|
97
|
+
const fileName = `page${newId}.xml`;
|
|
98
|
+
const relativePath = `visio/pages/${fileName}`;
|
|
99
|
+
// 2. Create Page File
|
|
100
|
+
const pageContent = `<PageContents xmlns="${VisioConstants_1.XML_NAMESPACES.VISIO_MAIN}" xmlns:r="${VisioConstants_1.XML_NAMESPACES.RELATIONSHIPS_OFFICE}" xml:space="preserve">
|
|
101
|
+
<PageSheet LineStyle="0" FillStyle="0" TextStyle="0">
|
|
102
|
+
<Cell N="PageWidth" V="8.5"/>
|
|
103
|
+
<Cell N="PageHeight" V="11"/>
|
|
104
|
+
<Cell N="PageScale" V="1" Unit="MSG"/>
|
|
105
|
+
<Cell N="DrawingScale" V="1" Unit="MSG"/>
|
|
106
|
+
<Cell N="DrawingSizeType" V="0"/>
|
|
107
|
+
<Cell N="DrawingScaleType" V="0"/>
|
|
108
|
+
<Cell N="Inhibited" V="0"/>
|
|
109
|
+
<Cell N="UIVisibility" V="0"/>
|
|
110
|
+
<Cell N="PageDrawSizeType" V="0"/>
|
|
111
|
+
</PageSheet>
|
|
112
|
+
<Shapes/>
|
|
113
|
+
<Connects/>
|
|
114
|
+
</PageContents>`;
|
|
115
|
+
this.pkg.updateFile(relativePath, pageContent);
|
|
116
|
+
// 3. Update Content Types
|
|
117
|
+
const ctPath = '[Content_Types].xml';
|
|
118
|
+
const ctContent = this.pkg.getFileText(ctPath);
|
|
119
|
+
const parsedCt = this.parser.parse(ctContent);
|
|
120
|
+
// Format: <Override PartName="/visio/pages/page2.xml" ContentType="application/vnd.ms-visio.page+xml"/>
|
|
121
|
+
// Ensure Types.Override array exists
|
|
122
|
+
if (!parsedCt.Types.Override)
|
|
123
|
+
parsedCt.Types.Override = [];
|
|
124
|
+
if (!Array.isArray(parsedCt.Types.Override))
|
|
125
|
+
parsedCt.Types.Override = [parsedCt.Types.Override];
|
|
126
|
+
parsedCt.Types.Override.push({
|
|
127
|
+
'@_PartName': `/${relativePath}`,
|
|
128
|
+
'@_ContentType': VisioConstants_1.CONTENT_TYPES.VISIO_PAGE
|
|
129
|
+
});
|
|
130
|
+
this.pkg.updateFile(ctPath, this.builder.build(parsedCt));
|
|
131
|
+
// 4. Update Relationships (pages.xml -> new page file)
|
|
132
|
+
// Source is "visio/pages/pages.xml", Target is "page{ID}.xml" (relative to source dir)
|
|
133
|
+
const rId = await this.relsManager.ensureRelationship('visio/pages/pages.xml', fileName, VisioConstants_1.RELATIONSHIP_TYPES.PAGE);
|
|
134
|
+
// 5. Update Pages Index (visio/pages/pages.xml)
|
|
135
|
+
const pagesPath = 'visio/pages/pages.xml';
|
|
136
|
+
const pagesContent = this.pkg.getFileText(pagesPath);
|
|
137
|
+
const parsedPages = this.parser.parse(pagesContent);
|
|
138
|
+
if (!parsedPages.Pages.Page)
|
|
139
|
+
parsedPages.Pages.Page = [];
|
|
140
|
+
if (!Array.isArray(parsedPages.Pages.Page))
|
|
141
|
+
parsedPages.Pages.Page = [parsedPages.Pages.Page];
|
|
142
|
+
parsedPages.Pages.Page.push({
|
|
143
|
+
'@_ID': newId.toString(),
|
|
144
|
+
'@_Name': name,
|
|
145
|
+
'Rel': { '@_r:id': rId }
|
|
146
|
+
});
|
|
147
|
+
this.pkg.updateFile(pagesPath, this.builder.build(parsedPages));
|
|
148
|
+
// Reload to include new page
|
|
149
|
+
this.load(true);
|
|
150
|
+
return newId.toString();
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Create a background page
|
|
154
|
+
*/
|
|
155
|
+
async createBackgroundPage(name) {
|
|
156
|
+
this.load();
|
|
157
|
+
// 1. Calculate ID
|
|
158
|
+
let maxId = 0;
|
|
159
|
+
for (const p of this.pages) {
|
|
160
|
+
if (p.id > maxId)
|
|
161
|
+
maxId = p.id;
|
|
162
|
+
}
|
|
163
|
+
const newId = maxId + 1;
|
|
164
|
+
const fileName = `page${newId}.xml`;
|
|
165
|
+
const relativePath = `visio/pages/${fileName}`;
|
|
166
|
+
// 2. Create Page File
|
|
167
|
+
const pageContent = `<PageContents xmlns="${VisioConstants_1.XML_NAMESPACES.VISIO_MAIN}" xmlns:r="${VisioConstants_1.XML_NAMESPACES.RELATIONSHIPS_OFFICE}" xml:space="preserve">
|
|
168
|
+
<PageSheet LineStyle="0" FillStyle="0" TextStyle="0">
|
|
169
|
+
<Cell N="PageWidth" V="8.5"/>
|
|
170
|
+
<Cell N="PageHeight" V="11"/>
|
|
171
|
+
<Cell N="PageScale" V="1" Unit="MSG"/>
|
|
172
|
+
<Cell N="DrawingScale" V="1" Unit="MSG"/>
|
|
173
|
+
<Cell N="DrawingSizeType" V="0"/>
|
|
174
|
+
<Cell N="DrawingScaleType" V="0"/>
|
|
175
|
+
<Cell N="Inhibited" V="0"/>
|
|
176
|
+
<Cell N="UIVisibility" V="0"/>
|
|
177
|
+
<Cell N="PageDrawSizeType" V="0"/>
|
|
178
|
+
</PageSheet>
|
|
179
|
+
<Shapes/>
|
|
180
|
+
</PageContents>`;
|
|
181
|
+
this.pkg.updateFile(relativePath, pageContent);
|
|
182
|
+
// 3. Update Content Types
|
|
183
|
+
const ctPath = '[Content_Types].xml';
|
|
184
|
+
const ctContent = this.pkg.getFileText(ctPath);
|
|
185
|
+
const parsedCt = this.parser.parse(ctContent);
|
|
186
|
+
if (!parsedCt.Types.Override)
|
|
187
|
+
parsedCt.Types.Override = [];
|
|
188
|
+
if (!Array.isArray(parsedCt.Types.Override))
|
|
189
|
+
parsedCt.Types.Override = [parsedCt.Types.Override];
|
|
190
|
+
parsedCt.Types.Override.push({
|
|
191
|
+
'@_PartName': `/${relativePath}`,
|
|
192
|
+
'@_ContentType': VisioConstants_1.CONTENT_TYPES.VISIO_PAGE
|
|
193
|
+
});
|
|
194
|
+
this.pkg.updateFile(ctPath, this.builder.build(parsedCt));
|
|
195
|
+
// 4. Update Relationships
|
|
196
|
+
const rId = await this.relsManager.ensureRelationship('visio/pages/pages.xml', fileName, VisioConstants_1.RELATIONSHIP_TYPES.PAGE);
|
|
197
|
+
// 5. Update Pages Index with Background="true"
|
|
198
|
+
const pagesPath = 'visio/pages/pages.xml';
|
|
199
|
+
const pagesContent = this.pkg.getFileText(pagesPath);
|
|
200
|
+
const parsedPages = this.parser.parse(pagesContent);
|
|
201
|
+
if (!parsedPages.Pages.Page)
|
|
202
|
+
parsedPages.Pages.Page = [];
|
|
203
|
+
if (!Array.isArray(parsedPages.Pages.Page))
|
|
204
|
+
parsedPages.Pages.Page = [parsedPages.Pages.Page];
|
|
205
|
+
parsedPages.Pages.Page.push({
|
|
206
|
+
'@_ID': newId.toString(),
|
|
207
|
+
'@_Name': name,
|
|
208
|
+
'@_Background': '1', // Use '1' for boolean true attribute
|
|
209
|
+
'Rel': { '@_r:id': rId }
|
|
210
|
+
});
|
|
211
|
+
this.pkg.updateFile(pagesPath, this.builder.build(parsedPages));
|
|
212
|
+
this.load(true);
|
|
213
|
+
return newId.toString();
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* Set a background page for a foreground page
|
|
217
|
+
*/
|
|
218
|
+
async setBackgroundPage(foregroundPageId, backgroundPageId) {
|
|
219
|
+
this.load();
|
|
220
|
+
// Verify pages exist
|
|
221
|
+
const fgPage = this.pages.find(p => p.id.toString() === foregroundPageId);
|
|
222
|
+
const bgPage = this.pages.find(p => p.id.toString() === backgroundPageId);
|
|
223
|
+
if (!fgPage)
|
|
224
|
+
throw new Error(`Foreground page ${foregroundPageId} not found`);
|
|
225
|
+
if (!bgPage)
|
|
226
|
+
throw new Error(`Background page ${backgroundPageId} not found`);
|
|
227
|
+
if (!bgPage.isBackground)
|
|
228
|
+
throw new Error(`Page ${backgroundPageId} is not a background page`);
|
|
229
|
+
// Update pages.xml
|
|
230
|
+
const pagesPath = 'visio/pages/pages.xml';
|
|
231
|
+
const pagesContent = this.pkg.getFileText(pagesPath);
|
|
232
|
+
const parsedPages = this.parser.parse(pagesContent);
|
|
233
|
+
let pageNodes = parsedPages.Pages.Page;
|
|
234
|
+
if (!Array.isArray(pageNodes))
|
|
235
|
+
pageNodes = [pageNodes];
|
|
236
|
+
const fgNode = pageNodes.find((n) => n['@_ID'] === foregroundPageId);
|
|
237
|
+
if (fgNode) {
|
|
238
|
+
fgNode['@_BackPage'] = backgroundPageId.toString();
|
|
239
|
+
}
|
|
240
|
+
this.pkg.updateFile(pagesPath, this.builder.build(parsedPages));
|
|
241
|
+
this.load(true);
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
exports.PageManager = PageManager;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { VisioPackage } from '../VisioPackage';
|
|
2
|
+
export declare class RelsManager {
|
|
3
|
+
private pkg;
|
|
4
|
+
private parser;
|
|
5
|
+
private builder;
|
|
6
|
+
constructor(pkg: VisioPackage);
|
|
7
|
+
private getRelsPath;
|
|
8
|
+
ensureRelationship(sourcePath: string, target: string, type: string): Promise<string>;
|
|
9
|
+
addPageImageRel(pageId: string, mediaPath: string): Promise<string>;
|
|
10
|
+
addImageRelationship(sourcePath: string, target: string): Promise<string>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RelsManager = void 0;
|
|
4
|
+
const fast_xml_parser_1 = require("fast-xml-parser");
|
|
5
|
+
const VisioConstants_1 = require("./VisioConstants");
|
|
6
|
+
class RelsManager {
|
|
7
|
+
constructor(pkg) {
|
|
8
|
+
this.pkg = pkg;
|
|
9
|
+
this.parser = new fast_xml_parser_1.XMLParser({
|
|
10
|
+
ignoreAttributes: false,
|
|
11
|
+
attributeNamePrefix: "@_"
|
|
12
|
+
});
|
|
13
|
+
this.builder = new fast_xml_parser_1.XMLBuilder({
|
|
14
|
+
ignoreAttributes: false,
|
|
15
|
+
attributeNamePrefix: "@_",
|
|
16
|
+
format: true
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
getRelsPath(partPath) {
|
|
20
|
+
// file.xml -> _rels/file.xml.rels
|
|
21
|
+
// dir/file.xml -> dir/_rels/file.xml.rels
|
|
22
|
+
const parts = partPath.split('/');
|
|
23
|
+
const fileName = parts.pop();
|
|
24
|
+
const dir = parts.join('/');
|
|
25
|
+
return `${dir}/_rels/${fileName}.rels`;
|
|
26
|
+
}
|
|
27
|
+
async ensureRelationship(sourcePath, target, type) {
|
|
28
|
+
const relsPath = this.getRelsPath(sourcePath);
|
|
29
|
+
let content = '';
|
|
30
|
+
try {
|
|
31
|
+
content = this.pkg.getFileText(relsPath);
|
|
32
|
+
}
|
|
33
|
+
catch {
|
|
34
|
+
// If .rels doesn't exist, start fresh
|
|
35
|
+
content = `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
36
|
+
<Relationships xmlns="${VisioConstants_1.XML_NAMESPACES.RELATIONSHIPS}">
|
|
37
|
+
</Relationships>`;
|
|
38
|
+
}
|
|
39
|
+
const parsed = this.parser.parse(content);
|
|
40
|
+
if (!parsed.Relationships) {
|
|
41
|
+
parsed.Relationships = { Relationship: [] };
|
|
42
|
+
}
|
|
43
|
+
let rels = parsed.Relationships.Relationship;
|
|
44
|
+
if (!Array.isArray(rels)) {
|
|
45
|
+
rels = rels ? [rels] : [];
|
|
46
|
+
parsed.Relationships.Relationship = rels;
|
|
47
|
+
}
|
|
48
|
+
// Check for existing
|
|
49
|
+
const existing = rels.find((r) => r['@_Target'] === target && r['@_Type'] === type);
|
|
50
|
+
if (existing) {
|
|
51
|
+
return existing['@_Id'];
|
|
52
|
+
}
|
|
53
|
+
// Generate new ID (rId1, rId2...)
|
|
54
|
+
let maxId = 0;
|
|
55
|
+
for (const r of rels) {
|
|
56
|
+
const idStr = r['@_Id']; // "rId5"
|
|
57
|
+
const idNum = parseInt(idStr.replace('rId', ''));
|
|
58
|
+
if (!isNaN(idNum) && idNum > maxId)
|
|
59
|
+
maxId = idNum;
|
|
60
|
+
}
|
|
61
|
+
const newId = `rId${maxId + 1}`;
|
|
62
|
+
// Add new relationship
|
|
63
|
+
rels.push({
|
|
64
|
+
'@_Id': newId,
|
|
65
|
+
'@_Type': type,
|
|
66
|
+
'@_Target': target
|
|
67
|
+
});
|
|
68
|
+
// Save back
|
|
69
|
+
const newXml = this.builder.build(parsed);
|
|
70
|
+
this.pkg.updateFile(relsPath, newXml);
|
|
71
|
+
return newId;
|
|
72
|
+
}
|
|
73
|
+
async addPageImageRel(pageId, mediaPath) {
|
|
74
|
+
const pagePath = `visio/pages/page${pageId}.xml`;
|
|
75
|
+
return this.addImageRelationship(pagePath, mediaPath);
|
|
76
|
+
}
|
|
77
|
+
async addImageRelationship(sourcePath, target) {
|
|
78
|
+
return this.ensureRelationship(sourcePath, target, VisioConstants_1.RELATIONSHIP_TYPES.IMAGE);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
exports.RelsManager = RelsManager;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export declare const XML_NAMESPACES: {
|
|
2
|
+
readonly VISIO_MAIN: "http://schemas.microsoft.com/office/visio/2012/main";
|
|
3
|
+
readonly RELATIONSHIPS: "http://schemas.openxmlformats.org/package/2006/relationships";
|
|
4
|
+
readonly RELATIONSHIPS_OFFICE: "http://schemas.openxmlformats.org/officeDocument/2006/relationships";
|
|
5
|
+
readonly CONTENT_TYPES: "http://schemas.openxmlformats.org/package/2006/content-types";
|
|
6
|
+
readonly CORE_PROPERTIES: "http://schemas.openxmlformats.org/package/2006/metadata/core-properties";
|
|
7
|
+
readonly EXTENDED_PROPERTIES: "http://schemas.openxmlformats.org/officeDocument/2006/extended-properties";
|
|
8
|
+
readonly DOC_PROPS_VTYPES: "http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes";
|
|
9
|
+
readonly DC_ELEMENTS: "http://purl.org/dc/elements/1.1/";
|
|
10
|
+
readonly DC_TERMS: "http://purl.org/dc/terms/";
|
|
11
|
+
readonly DC_DCMITYPE: "http://purl.org/dc/dcmitype/";
|
|
12
|
+
readonly XSI: "http://www.w3.org/2001/XMLSchema-instance";
|
|
13
|
+
};
|
|
14
|
+
export declare const RELATIONSHIP_TYPES: {
|
|
15
|
+
readonly IMAGE: "http://schemas.microsoft.com/office/2006/relationships/image";
|
|
16
|
+
readonly MASTERS: "http://schemas.microsoft.com/visio/2010/relationships/masters";
|
|
17
|
+
readonly PAGES: "http://schemas.microsoft.com/visio/2010/relationships/pages";
|
|
18
|
+
readonly PAGE: "http://schemas.microsoft.com/visio/2010/relationships/page";
|
|
19
|
+
readonly WINDOWS: "http://schemas.microsoft.com/visio/2010/relationships/windows";
|
|
20
|
+
readonly DOCUMENT: "http://schemas.microsoft.com/visio/2010/relationships/document";
|
|
21
|
+
readonly CORE_PROPERTIES: "http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties";
|
|
22
|
+
readonly EXTENDED_PROPERTIES: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties";
|
|
23
|
+
};
|
|
24
|
+
export declare const CONTENT_TYPES: {
|
|
25
|
+
readonly PNG: "image/png";
|
|
26
|
+
readonly JPEG: "image/jpeg";
|
|
27
|
+
readonly GIF: "image/gif";
|
|
28
|
+
readonly BMP: "image/bmp";
|
|
29
|
+
readonly TIFF: "image/tiff";
|
|
30
|
+
readonly XML_RELATIONSHIPS: "application/vnd.openxmlformats-package.relationships+xml";
|
|
31
|
+
readonly XML: "application/xml";
|
|
32
|
+
readonly VISIO_DRAWING: "application/vnd.ms-visio.drawing.main+xml";
|
|
33
|
+
readonly VISIO_PAGES: "application/vnd.ms-visio.pages+xml";
|
|
34
|
+
readonly VISIO_PAGE: "application/vnd.ms-visio.page+xml";
|
|
35
|
+
readonly VISIO_WINDOWS: "application/vnd.ms-visio.windows+xml";
|
|
36
|
+
readonly CORE_PROPERTIES: "application/vnd.openxmlformats-package.core-properties+xml";
|
|
37
|
+
readonly EXTENDED_PROPERTIES: "application/vnd.openxmlformats-officedocument.extended-properties+xml";
|
|
38
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CONTENT_TYPES = exports.RELATIONSHIP_TYPES = exports.XML_NAMESPACES = void 0;
|
|
4
|
+
exports.XML_NAMESPACES = {
|
|
5
|
+
VISIO_MAIN: 'http://schemas.microsoft.com/office/visio/2012/main',
|
|
6
|
+
RELATIONSHIPS: 'http://schemas.openxmlformats.org/package/2006/relationships',
|
|
7
|
+
RELATIONSHIPS_OFFICE: 'http://schemas.openxmlformats.org/officeDocument/2006/relationships',
|
|
8
|
+
CONTENT_TYPES: 'http://schemas.openxmlformats.org/package/2006/content-types',
|
|
9
|
+
CORE_PROPERTIES: 'http://schemas.openxmlformats.org/package/2006/metadata/core-properties',
|
|
10
|
+
EXTENDED_PROPERTIES: 'http://schemas.openxmlformats.org/officeDocument/2006/extended-properties',
|
|
11
|
+
DOC_PROPS_VTYPES: 'http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes',
|
|
12
|
+
DC_ELEMENTS: 'http://purl.org/dc/elements/1.1/',
|
|
13
|
+
DC_TERMS: 'http://purl.org/dc/terms/',
|
|
14
|
+
DC_DCMITYPE: 'http://purl.org/dc/dcmitype/',
|
|
15
|
+
XSI: 'http://www.w3.org/2001/XMLSchema-instance'
|
|
16
|
+
};
|
|
17
|
+
exports.RELATIONSHIP_TYPES = {
|
|
18
|
+
IMAGE: 'http://schemas.microsoft.com/office/2006/relationships/image',
|
|
19
|
+
MASTERS: 'http://schemas.microsoft.com/visio/2010/relationships/masters',
|
|
20
|
+
PAGES: 'http://schemas.microsoft.com/visio/2010/relationships/pages',
|
|
21
|
+
PAGE: 'http://schemas.microsoft.com/visio/2010/relationships/page',
|
|
22
|
+
WINDOWS: 'http://schemas.microsoft.com/visio/2010/relationships/windows',
|
|
23
|
+
DOCUMENT: 'http://schemas.microsoft.com/visio/2010/relationships/document',
|
|
24
|
+
CORE_PROPERTIES: 'http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties',
|
|
25
|
+
EXTENDED_PROPERTIES: 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties'
|
|
26
|
+
};
|
|
27
|
+
exports.CONTENT_TYPES = {
|
|
28
|
+
PNG: 'image/png',
|
|
29
|
+
JPEG: 'image/jpeg',
|
|
30
|
+
GIF: 'image/gif',
|
|
31
|
+
BMP: 'image/bmp',
|
|
32
|
+
TIFF: 'image/tiff',
|
|
33
|
+
XML_RELATIONSHIPS: 'application/vnd.openxmlformats-package.relationships+xml',
|
|
34
|
+
XML: 'application/xml',
|
|
35
|
+
VISIO_DRAWING: 'application/vnd.ms-visio.drawing.main+xml',
|
|
36
|
+
VISIO_PAGES: 'application/vnd.ms-visio.pages+xml',
|
|
37
|
+
VISIO_PAGE: 'application/vnd.ms-visio.page+xml',
|
|
38
|
+
VISIO_WINDOWS: 'application/vnd.ms-visio.windows+xml',
|
|
39
|
+
CORE_PROPERTIES: 'application/vnd.openxmlformats-package.core-properties+xml',
|
|
40
|
+
EXTENDED_PROPERTIES: 'application/vnd.openxmlformats-officedocument.extended-properties+xml'
|
|
41
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { VisioPackage } from '../VisioPackage';
|
|
2
|
+
export interface ValidationResult {
|
|
3
|
+
valid: boolean;
|
|
4
|
+
errors: string[];
|
|
5
|
+
warnings: string[];
|
|
6
|
+
}
|
|
7
|
+
export declare class VisioValidator {
|
|
8
|
+
private parser;
|
|
9
|
+
constructor();
|
|
10
|
+
/**
|
|
11
|
+
* Validate a VisioPackage for structural correctness
|
|
12
|
+
*/
|
|
13
|
+
validate(pkg: VisioPackage): Promise<ValidationResult>;
|
|
14
|
+
private checkRequiredFiles;
|
|
15
|
+
private validateContentTypes;
|
|
16
|
+
private validateDocumentRels;
|
|
17
|
+
private validatePages;
|
|
18
|
+
private validatePageContent;
|
|
19
|
+
private validateShapeIds;
|
|
20
|
+
private validateConnects;
|
|
21
|
+
private validateSectionNames;
|
|
22
|
+
private validateCellNames;
|
|
23
|
+
private validateImageShapes;
|
|
24
|
+
private validateMasterReferences;
|
|
25
|
+
private validateRelationshipIntegrity;
|
|
26
|
+
private getAllShapes;
|
|
27
|
+
}
|