@imferno/node 3.0.2-beta.c5fc81a → 3.0.2-beta.cdb240a

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 CHANGED
@@ -22,17 +22,39 @@ Prebuilt binaries are provided for:
22
22
 
23
23
  ### Validate a package on disk
24
24
 
25
- ```js
26
- import { buildReportFromPath } from "@imferno/node";
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
- const report = buildReportFromPath("./my-imp");
42
+ ```ts
43
+ import { validatePathAsync } from "@imferno/node";
29
44
 
30
- console.log("Compliant:", report.validation.is_compliant);
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
- ```js
58
- import { buildReportFromPath } from "@imferno/node";
81
+ ```ts
82
+ import { validatePath, type PathValidateOptions } from "@imferno/node";
59
83
 
60
- const report = buildReportFromPath("./my-imp", {
84
+ const options: PathValidateOptions = {
61
85
  coreSpec: "v2020",
62
86
  app2eSpec: "v2023",
63
87
  skipDiskChecks: true,
64
88
  rules: {
65
- "ST2067-21:2023:7.1/AppIdMismatch": "error",
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 { buildReport } from "@imferno/node";
99
+ import { validate } from "@imferno/node";
75
100
 
76
- const report = buildReport({
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 { buildReportFromPath, formatReport } from "@imferno/node";
111
+ import { validatePath, formatReport } from "@imferno/node";
87
112
 
88
- const report = buildReportFromPath("./my-imp");
89
- console.log(formatReport(report));
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,54 @@ 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(report)` | Pretty-print a report as a human-readable string |
113
- | `listRules()` | Get the full catalogue of validation rule codes |
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 spec version |
121
- | `app2eSpec` | `"auto" \| "none" \| "v2020" \| "v2021" \| "v2023"` | Application spec version |
122
- | `skipDiskChecks` | `boolean` | Skip file manifest and MXF checks (`buildReportFromPath` only) |
123
- | `rules` | `Record<string, "error" \| "warn" \| "info" \| "off">` | ESLint-style per-rule severity overrides |
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
+ | `credentials` | `S3Credentials \| null` | Explicit S3 credentials (URI functions only) |
155
+
156
+ An option the function does not accept, or a value of the wrong type, throws.
157
+ `null` and `undefined` mean not set for every option in the table, also one
158
+ the function does not take; an unknown key throws even as `null`, so a typo
159
+ like `{ skipHash: null }` is caught.
160
+
161
+ ### TypeScript
162
+
163
+ The package ships precise declarations, generated from the Rust types (no
164
+ `any`). Every function is synchronous, except the `…Async` variants, which
165
+ return a Promise. All value types are exported from the
166
+ main entry:
167
+
168
+ ```ts
169
+ import type {
170
+ ValidationResult, // validate*, { package, validation }
171
+ Imferno, // parsePackage*, the full parsed package
172
+ ImfReport, // buildReport* (legacy)
173
+ ValidationIssue, // severity, category, code, message, location, ...
174
+ ValidateOptions, // coreSpec, app2eSpec, rules, aggregateRepeats
175
+ PathValidateOptions,
176
+ UriValidateOptions,
177
+ RuleInfo, // listRules() entries
178
+ } from "@imferno/node";
179
+ ```
180
+
181
+ Field casing follows the serialised output: the validation report uses
182
+ snake_case (`is_compliant`, `cpl_id`), the parsed package uses camelCase at the
183
+ top level (`compositionPlaylists`) and the SMPTE element names inside CPLs
184
+ (`ContentTitle`, `SegmentList`).
124
185
 
125
186
  ### Return types
126
187
 
@@ -133,6 +194,7 @@ console.log(getVersion()); // e.g. "2.0.0"
133
194
  "is_compliant": true,
134
195
  "is_playable": true,
135
196
  "profile": "SMPTE",
197
+ "timestamp": "2026-01-01T12:00:00.000000+00:00",
136
198
  "critical": [],
137
199
  "errors": [],
138
200
  "warnings": [],