@imferno/node 3.0.2-beta.2427eb9 → 3.0.2-beta.2609f57

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/index.d.ts CHANGED
@@ -2,20 +2,29 @@
2
2
  /* eslint-disable */
3
3
 
4
4
  import type {
5
- Category,
6
5
  ImfReport,
7
6
  Imferno,
7
+ RuleInfo,
8
8
  ValidateOptions,
9
+ ValidationReport,
9
10
  ValidationResult,
10
11
  } from "./types";
11
12
 
12
13
  export * from "./types";
13
14
  export { codes } from "./codes";
14
15
 
15
- /** Options for validating a package on disk (`validatePath`, `buildReportFromPath`). */
16
+ /** Options for validating a package on disk (`validatePath`, `buildReportFromPath` and their `…Async` variants). */
16
17
  export interface PathValidateOptions extends ValidateOptions {
17
- /** Skip file-manifest (size/presence) and MXF header checks. Default: `false`. */
18
+ /**
19
+ * Skip every disk read: asset presence, size and hash checks and MXF
20
+ * header checks (implies `skipHashes`). Only the XML is validated. Default: `false`.
21
+ */
18
22
  skipDiskChecks?: boolean;
23
+ /**
24
+ * Skip hashing the assets against their Packing List `<Hash>`; presence and
25
+ * size are still checked. Hashing reads every asset. Default: `false`.
26
+ */
27
+ skipHashes?: boolean;
19
28
  }
20
29
 
21
30
  /** Explicit S3 credentials for `s3://` URIs. Omit to use the default AWS credential chain. */
@@ -27,34 +36,22 @@ export interface S3Credentials {
27
36
  endpoint?: string;
28
37
  }
29
38
 
30
- /** Options for `validateUri` / `buildReportFromUri`. */
39
+ /**
40
+ * Options for `validateUri` / `buildReportFromUri` (and their `…Async` variants).
41
+ * For an `s3://` URI only the XML is read: the disk checks do not run, and the
42
+ * result carries an `IMFERNO:Package/DiskChecksNotRun` notice unless
43
+ * `skipDiskChecks` is set.
44
+ */
31
45
  export interface UriValidateOptions extends PathValidateOptions {
32
46
  /** Ignored for filesystem URIs. */
33
47
  credentials?: S3Credentials | null;
34
48
  }
35
49
 
36
- /** Which rule catalogue a code belongs to. */
37
- export type RuleSpec =
38
- | "core"
39
- | "cpl"
40
- | "app2e"
41
- | "volindex"
42
- | "mxf"
43
- | "scm"
44
- | "isxd"
45
- | "iab"
46
- | "imferno";
47
-
48
- /** One entry of the `listRules()` catalogue. */
49
- export interface RuleInfo {
50
- /** Normalised rule code, usable as a `rules` key. */
51
- code: string;
52
- spec: RuleSpec;
53
- description: string;
54
- defaultSeverity: "info" | "warning" | "error" | "critical";
55
- category: Extract<Category, string>;
56
- /** Present when this edition's code set is identical to an earlier edition's (that edition's prefix). */
57
- sameAsPreviousEdition?: string;
50
+ /** A SARIF 2.1.0 log (https://docs.oasis-open.org/sarif/sarif/v2.1.0/). */
51
+ export interface SarifLog {
52
+ $schema?: string;
53
+ version: "2.1.0";
54
+ runs: Array<Record<string, unknown>>;
58
55
  }
59
56
 
60
57
  /**
@@ -64,7 +61,7 @@ export interface RuleInfo {
64
61
  * Disk checks are always skipped (there is no package on disk).
65
62
  *
66
63
  * @param files - A map of filename to XML content (e.g. `{ "ASSETMAP.xml": "..." }`)
67
- * @param options - Optional validation options (`coreSpec`, `app2eSpec`, `rules`, `aggregateRepeats`)
64
+ * @param options - Optional validation options (`coreSpec`, `cplSpec`, `iabSpec`, `app2eSpec`, `rules`, `aggregateRepeats`)
68
65
  * @returns An `ImfReport` with `package`, `cpls`, and `validation` fields.
69
66
  * @throws If the package cannot be parsed or the options are invalid.
70
67
  */
@@ -74,13 +71,26 @@ export declare function buildReport(files: Record<string, string>, options?: Val
74
71
  * Validate an IMF package directory on disk, returning the legacy
75
72
  * `ImfReport` summary. Prefer `validatePath` for new code.
76
73
  *
74
+ * Hashes the assets in parallel and blocks until done; see
75
+ * `buildReportFromPathAsync`.
76
+ *
77
77
  * @param path - Path to the IMP directory
78
- * @param options - Optional validation options (`coreSpec`, `app2eSpec`, `skipDiskChecks`, `rules`, `aggregateRepeats`)
78
+ * @param options - Optional validation options (`coreSpec`, `cplSpec`, `iabSpec`, `app2eSpec`, `skipDiskChecks`, `skipHashes`, `rules`, `aggregateRepeats`)
79
79
  * @returns An `ImfReport` with `package`, `cpls`, and `validation` fields.
80
80
  * @throws If the directory cannot be read, the package cannot be parsed, or the options are invalid.
81
81
  */
82
82
  export declare function buildReportFromPath(path: string, options?: PathValidateOptions | undefined | null): ImfReport
83
83
 
84
+ /**
85
+ * `buildReportFromPath` on the libuv thread pool: the event loop keeps
86
+ * running while the assets are hashed.
87
+ *
88
+ * @param path - Path to the IMP directory
89
+ * @param options - Optional validation options, as for `buildReportFromPath`
90
+ * @returns A Promise of the `ImfReport`; rejects where `buildReportFromPath` throws.
91
+ */
92
+ export declare function buildReportFromPathAsync(path: string, options?: PathValidateOptions | undefined | null): Promise<ImfReport>
93
+
84
94
  /**
85
95
  * Build the legacy `ImfReport` summary from a URI. Accepts the same URI forms
86
96
  * as `validateUri`; prefer `validateUri` for new code.
@@ -92,6 +102,15 @@ export declare function buildReportFromPath(path: string, options?: PathValidate
92
102
  */
93
103
  export declare function buildReportFromUri(uri: string, options?: UriValidateOptions | undefined | null): ImfReport
94
104
 
105
+ /**
106
+ * `buildReportFromUri` on the libuv thread pool.
107
+ *
108
+ * @param uri - Path or URI to the IMP
109
+ * @param options - Optional validation options, as for `buildReportFromUri`
110
+ * @returns A Promise of the `ImfReport`; rejects where `buildReportFromUri` throws.
111
+ */
112
+ export declare function buildReportFromUriAsync(uri: string, options?: UriValidateOptions | undefined | null): Promise<ImfReport>
113
+
95
114
  /**
96
115
  * Pretty-print a validation result as a human-readable string.
97
116
  *
@@ -105,10 +124,10 @@ export declare function formatReport(report: ValidationResult | ImfReport): stri
105
124
  export declare function getVersion(): string
106
125
 
107
126
  /**
108
- * Returns the engine's full catalogue of validation rule codes, one entry per
109
- * per-spec enum variant. Useful for building settings UIs that render a
110
- * configurable severity dropdown per rule. The shape is stable JSON, so
111
- * downstream callers can store severity overrides keyed by `code`.
127
+ * Returns the engine's rule catalogue: one entry per rule, each with its
128
+ * table of editions (clause, strength, default severity, display code).
129
+ * Useful for building settings UIs; `id`, `name`, `SPEC:EDITION/Name` and
130
+ * the display codes are all usable as `rules` keys.
112
131
  */
113
132
  export declare function listRules(): RuleInfo[]
114
133
 
@@ -132,6 +151,19 @@ export declare function parsePackage(files: Record<string, string>): Imferno
132
151
  */
133
152
  export declare function parsePackageFromPath(path: string): Imferno
134
153
 
154
+ /**
155
+ * Convert a validation result to a SARIF 2.1.0 log.
156
+ *
157
+ * Rules are reported by rule id (`ST2067-3/SegmentDuration`); each finding
158
+ * points at the applied edition's clause in that edition's taxonomy
159
+ * (`ST2067-3:2016`).
160
+ *
161
+ * @param report - The object returned by `validate*` (or its `validation`)
162
+ * @returns A SARIF 2.1.0 log object.
163
+ * @throws If `report` is not a validation result or report.
164
+ */
165
+ export declare function toSarif(report: ValidationResult | ValidationReport): SarifLog
166
+
135
167
  /**
136
168
  * Parse and validate an IMF package from in-memory XML strings. This is the
137
169
  * recommended entry point.
@@ -142,25 +174,44 @@ export declare function parsePackageFromPath(path: string): Imferno
142
174
  * @param files - A map of filename to XML content
143
175
  * @param options - Optional validation options
144
176
  * @returns `{ package, validation }` — the full parsed package and all findings.
145
- * @throws Only if the options are invalid.
177
+ * @throws Only if the options are invalid (wrong type, unknown key).
146
178
  */
147
179
  export declare function validate(files: Record<string, string>, options?: ValidateOptions | undefined | null): ValidationResult
148
180
 
149
181
  /**
150
182
  * Parse and validate an IMF package directory on disk.
151
183
  *
184
+ * Like the CLI, checks every asset's presence and size and hashes it against
185
+ * its Packing List `<Hash>` unless `skipHashes` (or `skipDiskChecks`) is set.
186
+ * Hashing reads every asset (several at a time) and blocks until done; use
187
+ * `validatePathAsync` to keep the event loop running.
188
+ *
152
189
  * @param path - Path to the IMP directory
153
190
  * @param options - Optional validation options
154
191
  * @returns `{ package, validation }` — the full parsed package and all findings.
155
- * @throws If the directory cannot be read or the options are invalid.
192
+ * @throws If the directory cannot be read or the options are invalid
193
+ * (wrong type, unknown key).
156
194
  */
157
195
  export declare function validatePath(path: string, options?: PathValidateOptions | undefined | null): ValidationResult
158
196
 
197
+ /**
198
+ * `validatePath` on the libuv thread pool: the event loop keeps running
199
+ * while the assets are hashed. Same result as `validatePath`.
200
+ *
201
+ * @param path - Path to the IMP directory
202
+ * @param options - Optional validation options, as for `validatePath`
203
+ * @returns A Promise of `{ package, validation }`; rejects where `validatePath` throws.
204
+ */
205
+ export declare function validatePathAsync(path: string, options?: PathValidateOptions | undefined | null): Promise<ValidationResult>
206
+
159
207
  /**
160
208
  * Parse and validate an IMF package from a URI.
161
209
  *
162
210
  * Accepts `file://` URIs, bare filesystem paths, and (when built with the
163
211
  * `aws-s3` feature, as the prebuilt npm binaries are) `s3://bucket/prefix/`.
212
+ * Local packages get the disk checks of `validatePath`. An `s3://` package
213
+ * has only its XML read: presence, size and hash checks are not run, and the
214
+ * result says so with an `IMFERNO:Package/DiskChecksNotRun` notice.
164
215
  *
165
216
  * @param uri - Path or URI to the IMP
166
217
  * @param options - Optional validation options (plus `credentials` for S3)
@@ -168,3 +219,14 @@ export declare function validatePath(path: string, options?: PathValidateOptions
168
219
  * @throws If the URI cannot be read or the options are invalid.
169
220
  */
170
221
  export declare function validateUri(uri: string, options?: UriValidateOptions | undefined | null): ValidationResult
222
+
223
+ /**
224
+ * `validateUri` on the libuv thread pool: the event loop keeps running
225
+ * while the package is read and its assets are hashed. Same result as
226
+ * `validateUri`.
227
+ *
228
+ * @param uri - Path or URI to the IMP
229
+ * @param options - Optional validation options (plus `credentials` for S3)
230
+ * @returns A Promise of `{ package, validation }`; rejects where `validateUri` throws.
231
+ */
232
+ export declare function validateUriAsync(uri: string, options?: UriValidateOptions | undefined | null): Promise<ValidationResult>
package/index.mjs CHANGED
@@ -49,13 +49,18 @@ export const {
49
49
  buildReport,
50
50
  buildReportFromPath,
51
51
  buildReportFromUri,
52
+ buildReportFromPathAsync,
53
+ buildReportFromUriAsync,
52
54
  formatReport,
53
55
  parsePackage,
54
56
  parsePackageFromPath,
55
57
  validate,
56
58
  validatePath,
57
59
  validateUri,
60
+ validatePathAsync,
61
+ validateUriAsync,
58
62
  listRules,
63
+ toSarif,
59
64
  } = nativeModule;
60
65
 
61
66
  export { codes } from "./codes.mjs";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@imferno/node",
3
- "version": "3.0.2-beta.2427eb9",
3
+ "version": "3.0.2-beta.2609f57",
4
4
  "description": "Native Node.js bindings for the imferno SMPTE ST 2067 IMF validator",
5
5
  "main": "index.js",
6
6
  "module": "index.mjs",
@@ -45,12 +45,12 @@
45
45
  "test": "vitest run"
46
46
  },
47
47
  "optionalDependencies": {
48
- "@imferno/node-darwin-arm64": "3.0.2-beta.2427eb9",
49
- "@imferno/node-darwin-x64": "3.0.2-beta.2427eb9",
50
- "@imferno/node-linux-x64-gnu": "3.0.2-beta.2427eb9",
51
- "@imferno/node-linux-arm64-gnu": "3.0.2-beta.2427eb9",
52
- "@imferno/node-win32-x64-msvc": "3.0.2-beta.2427eb9",
53
- "@imferno/node-win32-arm64-msvc": "3.0.2-beta.2427eb9"
48
+ "@imferno/node-darwin-arm64": "3.0.2-beta.2609f57",
49
+ "@imferno/node-darwin-x64": "3.0.2-beta.2609f57",
50
+ "@imferno/node-linux-x64-gnu": "3.0.2-beta.2609f57",
51
+ "@imferno/node-linux-arm64-gnu": "3.0.2-beta.2609f57",
52
+ "@imferno/node-win32-x64-msvc": "3.0.2-beta.2609f57",
53
+ "@imferno/node-win32-arm64-msvc": "3.0.2-beta.2609f57"
54
54
  },
55
55
  "publishConfig": {
56
56
  "access": "public"