Skip to content

Commit 8fdb24b

Browse files
committed
fix: update readme
1 parent 3d5b970 commit 8fdb24b

File tree

2 files changed

+30
-16
lines changed

2 files changed

+30
-16
lines changed

packages/compas-open-scd/public/nsdoc/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,10 @@ Directory containing fixed nsdoc for the 'Validation' plugin:
88
Where `XX` represents the revision and release values.
99

1010
This directory should also contain a `manifest.json` file listing all available NSDOC files for dynamic discovery. If the manifest is not present, the system will fall back to pattern-based file discovery.
11+
12+
## Fallback pattern discovery
13+
14+
When manifest.json is not available, the service checks for files using these patterns:
15+
16+
- Standards 7-2, 7-3, 7-4: `2007B5` to `2007B9` (stops at first found)
17+
- Standard 8-1: `2003A2` to `2003A9` (stops at first found)

packages/compas-open-scd/src/compas-services/CompasNSDocFileService.ts

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -122,29 +122,36 @@ async function getNsDocFilesFromManifest(): Promise<string[]> {
122122

123123
// Discover NSDOC files using pattern-based approach (fallback)
124124
async function getNsDocFilesByPattern(): Promise<string[]> {
125-
const standards = ['7-2', '7-3', '7-4', '8-1'];
126-
const versions = ['2003A2', '2007B3', '2007B4', '2007B5'];
127-
128-
const potentialFiles: string[] = [];
129-
for (const standard of standards) {
130-
for (const version of versions) {
131-
potentialFiles.push(`IEC_61850-${standard}_${version}-en.nsdoc`);
125+
const discoveredFiles: string[] = [];
126+
127+
const standards2007 = ['7-2', '7-3', '7-4'];
128+
for (const standard of standards2007) {
129+
for (let release = 5; release <= 9; release++) {
130+
const filename = `IEC_61850-${standard}_2007B${release}-en.nsdoc`;
131+
try {
132+
const response = await fetch(`/public/nsdoc/${filename}`);
133+
if (response.ok) {
134+
discoveredFiles.push(filename);
135+
break;
136+
}
137+
} catch (e) {
138+
// Continue to next version
139+
}
132140
}
133141
}
134142

135-
const testPromises = potentialFiles.map(async filename => {
143+
for (let release = 2; release <= 9; release++) {
144+
const filename = `IEC_61850-8-1_2003A${release}-en.nsdoc`;
136145
try {
137146
const response = await fetch(`/public/nsdoc/${filename}`);
138-
return response.ok ? filename : null;
147+
if (response.ok) {
148+
discoveredFiles.push(filename);
149+
break;
150+
}
139151
} catch (e) {
140-
return null;
152+
// Continue to next version
141153
}
142-
});
143-
144-
const existingFiles = await Promise.all(testPromises);
145-
const discoveredFiles = existingFiles.filter(
146-
(filename): filename is string => filename !== null
147-
);
154+
}
148155

149156
return discoveredFiles;
150157
}

0 commit comments

Comments
 (0)