@imferno/node 3.0.2-beta.af1c617 → 3.0.2-beta.b4d4242
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/README.md +86 -23
- package/codes.d.ts +485 -327
- package/codes.js +485 -327
- package/index.d.ts +177 -47
- package/index.mjs +5 -0
- package/package.json +27 -8
- package/types.d.ts +1671 -0
package/README.md
CHANGED
|
@@ -22,17 +22,39 @@ Prebuilt binaries are provided for:
|
|
|
22
22
|
|
|
23
23
|
### Validate a package on disk
|
|
24
24
|
|
|
25
|
-
```
|
|
26
|
-
import {
|
|
25
|
+
```ts
|
|
26
|
+
import { validatePath } from "@imferno/node";
|
|
27
|
+
|
|
28
|
+
const { package: pkg, validation } = validatePath("./my-imp");
|
|
29
|
+
|
|
30
|
+
console.log("Compliant:", validation.is_compliant);
|
|
31
|
+
console.log("Errors:", validation.errors.length);
|
|
32
|
+
for (const issue of validation.errors) {
|
|
33
|
+
console.log(issue.severity, issue.code, issue.message, issue.location.file);
|
|
34
|
+
}
|
|
35
|
+
console.log("CPLs:", Object.keys(pkg.compositionPlaylists).length);
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
`validatePath` hashes every asset (several at a time, like the CLI) and
|
|
39
|
+
blocks until done. To keep the event loop running, use the async variant:
|
|
40
|
+
same arguments, same result, on the libuv thread pool.
|
|
27
41
|
|
|
28
|
-
|
|
42
|
+
```ts
|
|
43
|
+
import { validatePathAsync } from "@imferno/node";
|
|
29
44
|
|
|
30
|
-
|
|
31
|
-
console.log("Errors:", report.validation.errors.length);
|
|
32
|
-
console.log("Warnings:", report.validation.warnings.length);
|
|
33
|
-
console.log("CPLs:", report.package.cplCount);
|
|
45
|
+
const { validation } = await validatePathAsync("./my-imp");
|
|
34
46
|
```
|
|
35
47
|
|
|
48
|
+
`validateUriAsync`, `buildReportFromPathAsync` and `buildReportFromUriAsync`
|
|
49
|
+
work the same way.
|
|
50
|
+
|
|
51
|
+
Each running `…Async` call holds one libuv worker thread for its whole run
|
|
52
|
+
(the hashing itself runs on imferno's own threads). The pool has 4 workers
|
|
53
|
+
by default and is shared with `fs`, `dns.lookup`, `crypto` and `zlib`, so
|
|
54
|
+
more than a few concurrent validations queue each other and that I/O. To
|
|
55
|
+
run more at once, raise the pool size before Node starts it, e.g.
|
|
56
|
+
`UV_THREADPOOL_SIZE=16 node app.js` (max 1024).
|
|
57
|
+
|
|
36
58
|
### Validate from a URI (filesystem or S3)
|
|
37
59
|
|
|
38
60
|
```js
|
|
@@ -44,6 +66,8 @@ const result2 = validateUri("file:///abs/path/to/my-imp");
|
|
|
44
66
|
|
|
45
67
|
// S3 — prebuilt npm binaries include S3 support; uses the default AWS
|
|
46
68
|
// credential chain (env vars, profile, or EC2/ECS/EKS IMDS)
|
|
69
|
+
// Only the XML is read from S3: presence, size and hash checks do not run,
|
|
70
|
+
// and the result says so (IMFERNO:Package/DiskChecksNotRun).
|
|
47
71
|
const result3 = validateUri("s3://my-bucket/path/to/imp/");
|
|
48
72
|
|
|
49
73
|
// Same options object as validatePath
|
|
@@ -54,26 +78,27 @@ const report = buildReportFromUri("s3://my-bucket/path/to/imp/", {
|
|
|
54
78
|
|
|
55
79
|
### Validate with options
|
|
56
80
|
|
|
57
|
-
```
|
|
58
|
-
import {
|
|
81
|
+
```ts
|
|
82
|
+
import { validatePath, type PathValidateOptions } from "@imferno/node";
|
|
59
83
|
|
|
60
|
-
const
|
|
84
|
+
const options: PathValidateOptions = {
|
|
61
85
|
coreSpec: "v2020",
|
|
62
86
|
app2eSpec: "v2023",
|
|
63
87
|
skipDiskChecks: true,
|
|
64
88
|
rules: {
|
|
65
|
-
"ST2067-21:2023
|
|
89
|
+
"ST2067-21:2023/AppIdMismatch": "error",
|
|
66
90
|
"IMFERNO:Package/UnreferencedAsset": "off",
|
|
67
91
|
},
|
|
68
|
-
}
|
|
92
|
+
};
|
|
93
|
+
const result = validatePath("./my-imp", options);
|
|
69
94
|
```
|
|
70
95
|
|
|
71
96
|
### Validate from in-memory strings
|
|
72
97
|
|
|
73
98
|
```js
|
|
74
|
-
import {
|
|
99
|
+
import { validate } from "@imferno/node";
|
|
75
100
|
|
|
76
|
-
const
|
|
101
|
+
const result = validate({
|
|
77
102
|
"ASSETMAP.xml": assetmapXml,
|
|
78
103
|
"PKL_abc.xml": pklXml,
|
|
79
104
|
"CPL_def.xml": cplXml,
|
|
@@ -83,10 +108,10 @@ const report = buildReport({
|
|
|
83
108
|
### Pretty-print a report
|
|
84
109
|
|
|
85
110
|
```js
|
|
86
|
-
import {
|
|
111
|
+
import { validatePath, formatReport } from "@imferno/node";
|
|
87
112
|
|
|
88
|
-
const
|
|
89
|
-
console.log(formatReport(
|
|
113
|
+
const result = validatePath("./my-imp");
|
|
114
|
+
console.log(formatReport(result)); // same text as `imferno validate`
|
|
90
115
|
```
|
|
91
116
|
|
|
92
117
|
### Get the library version
|
|
@@ -109,18 +134,55 @@ console.log(getVersion()); // e.g. "2.0.0"
|
|
|
109
134
|
| `buildReport(files, options?)` | Legacy: validate from strings (returns `ImfReport`) |
|
|
110
135
|
| `buildReportFromPath(path, options?)` | Legacy: validate from disk (returns `ImfReport`) |
|
|
111
136
|
| `buildReportFromUri(uri, options?)` | Legacy: validate via URI (returns `ImfReport`) |
|
|
112
|
-
| `formatReport(
|
|
113
|
-
| `listRules()` | Get the
|
|
137
|
+
| `formatReport(result)` | Pretty-print a `ValidationResult` (or legacy `ImfReport`) as text |
|
|
138
|
+
| `listRules()` | Get the rule catalogue (one entry per rule, with its per-edition table) |
|
|
139
|
+
| `toSarif(result)` | Convert a validation result to a SARIF 2.1.0 log |
|
|
114
140
|
| `getVersion()` | Get the library version |
|
|
115
141
|
|
|
116
142
|
### Options
|
|
117
143
|
|
|
118
144
|
| Option | Type | Description |
|
|
119
145
|
|--------|------|-------------|
|
|
120
|
-
| `coreSpec` | `"auto" \| "v2013" \| "v2016" \| "v2020"` | Core constraints
|
|
121
|
-
| `
|
|
122
|
-
| `
|
|
123
|
-
| `
|
|
146
|
+
| `coreSpec` | `"auto" \| "v2013" \| "v2016" \| "v2020"` | Core constraints (ST 2067-2) edition; a pin also pins the editions it cites (ST 2067-3, ST 2067-201, ST 377-1/-4) |
|
|
147
|
+
| `cplSpec` | `"auto" \| "v2013" \| "v2016" \| "v2020"` | Composition Playlist (ST 2067-3) edition; wins over the one `coreSpec` implies |
|
|
148
|
+
| `iabSpec` | `"auto" \| "v2019" \| "v2021" \| "v2026"` | IAB plug-in (ST 2067-201) edition; wins over the one `coreSpec` implies |
|
|
149
|
+
| `app2eSpec` | `"auto" \| "none" \| "v2014" \| "v2016" \| "v2020" \| "v2023" \| "v2026"` | Application spec version |
|
|
150
|
+
| `rules` | `Record<string, "off" \| "info" \| "warn" \| "error" \| "critical">` | ESLint-style per-rule severity overrides |
|
|
151
|
+
| `aggregateRepeats` | `boolean` | Collapse repeated identical findings into one issue with `additional_instances` |
|
|
152
|
+
| `skipDiskChecks` | `boolean` | Skip every disk read: asset existence, size and hash checks and MXF checks (path / URI functions only; in-memory input never touches disk) |
|
|
153
|
+
| `skipHashes` | `boolean` | Skip hashing the assets; existence and size are still checked (path / URI functions only). Hashes are verified by default, like the CLI |
|
|
154
|
+
| `with` | `Array<string \| Record<string, string>>` | Packages this one depends on (the original of a supplemental package): package directories or file maps. Track files its CPLs use are looked up there too |
|
|
155
|
+
| `credentials` | `S3Credentials \| null` | Explicit S3 credentials (URI functions only) |
|
|
156
|
+
|
|
157
|
+
An option the function does not accept, or a value of the wrong type, throws.
|
|
158
|
+
`null` and `undefined` mean not set for every option in the table, also one
|
|
159
|
+
the function does not take; an unknown key throws even as `null`, so a typo
|
|
160
|
+
like `{ skipHash: null }` is caught.
|
|
161
|
+
|
|
162
|
+
### TypeScript
|
|
163
|
+
|
|
164
|
+
The package ships precise declarations, generated from the Rust types (no
|
|
165
|
+
`any`). Every function is synchronous, except the `…Async` variants, which
|
|
166
|
+
return a Promise. All value types are exported from the
|
|
167
|
+
main entry:
|
|
168
|
+
|
|
169
|
+
```ts
|
|
170
|
+
import type {
|
|
171
|
+
ValidationResult, // validate*, { package, validation }
|
|
172
|
+
Imferno, // parsePackage*, the full parsed package
|
|
173
|
+
ImfReport, // buildReport* (legacy)
|
|
174
|
+
ValidationIssue, // severity, category, code, message, location, ...
|
|
175
|
+
ValidateOptions, // coreSpec, app2eSpec, rules, aggregateRepeats
|
|
176
|
+
PathValidateOptions,
|
|
177
|
+
UriValidateOptions,
|
|
178
|
+
RuleInfo, // listRules() entries
|
|
179
|
+
} from "@imferno/node";
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
Field casing follows the serialised output: the validation report uses
|
|
183
|
+
snake_case (`is_compliant`, `cpl_id`), the parsed package uses camelCase at the
|
|
184
|
+
top level (`compositionPlaylists`) and the SMPTE element names inside CPLs
|
|
185
|
+
(`ContentTitle`, `SegmentList`).
|
|
124
186
|
|
|
125
187
|
### Return types
|
|
126
188
|
|
|
@@ -133,6 +195,7 @@ console.log(getVersion()); // e.g. "2.0.0"
|
|
|
133
195
|
"is_compliant": true,
|
|
134
196
|
"is_playable": true,
|
|
135
197
|
"profile": "SMPTE",
|
|
198
|
+
"timestamp": "2026-01-01T12:00:00.000000+00:00",
|
|
136
199
|
"critical": [],
|
|
137
200
|
"errors": [],
|
|
138
201
|
"warnings": [],
|