@imferno/node 3.0.2-beta.43d9cf9 → 3.0.2-beta.4e10253
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 +31 -2
- package/codes.d.ts +27 -0
- package/codes.js +27 -0
- package/index.d.ts +71 -6
- package/index.mjs +4 -0
- package/package.json +7 -7
- package/types.d.ts +76 -25
package/README.md
CHANGED
|
@@ -35,6 +35,26 @@ for (const issue of validation.errors) {
|
|
|
35
35
|
console.log("CPLs:", Object.keys(pkg.compositionPlaylists).length);
|
|
36
36
|
```
|
|
37
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.
|
|
41
|
+
|
|
42
|
+
```ts
|
|
43
|
+
import { validatePathAsync } from "@imferno/node";
|
|
44
|
+
|
|
45
|
+
const { validation } = await validatePathAsync("./my-imp");
|
|
46
|
+
```
|
|
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
|
+
|
|
38
58
|
### Validate from a URI (filesystem or S3)
|
|
39
59
|
|
|
40
60
|
```js
|
|
@@ -46,6 +66,8 @@ const result2 = validateUri("file:///abs/path/to/my-imp");
|
|
|
46
66
|
|
|
47
67
|
// S3 — prebuilt npm binaries include S3 support; uses the default AWS
|
|
48
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).
|
|
49
71
|
const result3 = validateUri("s3://my-bucket/path/to/imp/");
|
|
50
72
|
|
|
51
73
|
// Same options object as validatePath
|
|
@@ -127,13 +149,20 @@ console.log(getVersion()); // e.g. "2.0.0"
|
|
|
127
149
|
| `app2eSpec` | `"auto" \| "none" \| "v2014" \| "v2016" \| "v2020" \| "v2023" \| "v2026"` | Application spec version |
|
|
128
150
|
| `rules` | `Record<string, "off" \| "info" \| "warn" \| "error" \| "critical">` | ESLint-style per-rule severity overrides |
|
|
129
151
|
| `aggregateRepeats` | `boolean` | Collapse repeated identical findings into one issue with `additional_instances` |
|
|
130
|
-
| `skipDiskChecks` | `boolean` | Skip
|
|
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 |
|
|
131
154
|
| `credentials` | `S3Credentials \| null` | Explicit S3 credentials (URI functions only) |
|
|
132
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
|
+
|
|
133
161
|
### TypeScript
|
|
134
162
|
|
|
135
163
|
The package ships precise declarations, generated from the Rust types (no
|
|
136
|
-
`any`). Every function is synchronous
|
|
164
|
+
`any`). Every function is synchronous, except the `…Async` variants, which
|
|
165
|
+
return a Promise. All value types are exported from the
|
|
137
166
|
main entry:
|
|
138
167
|
|
|
139
168
|
```ts
|
package/codes.d.ts
CHANGED
|
@@ -19,6 +19,7 @@ export declare const codes: {
|
|
|
19
19
|
readonly ST429_8: {
|
|
20
20
|
readonly SizeMismatch: "ST429-8/SizeMismatch";
|
|
21
21
|
readonly ChecksumMismatch: "ST429-8/ChecksumMismatch";
|
|
22
|
+
readonly MalformedXml: "ST429-8/MalformedXml";
|
|
22
23
|
};
|
|
23
24
|
readonly ST429_9: {
|
|
24
25
|
readonly AssetListEmpty: "ST429-9/AssetListEmpty";
|
|
@@ -33,10 +34,18 @@ export declare const codes: {
|
|
|
33
34
|
readonly AssetMapHasNoPackingList: "ST429-9/AssetMapHasNoPackingList";
|
|
34
35
|
readonly PklIdNotInAssetMap: "ST429-9/PklIdNotInAssetMap";
|
|
35
36
|
readonly AssetMapMalformedXml: "ST429-9/AssetMapMalformedXml";
|
|
37
|
+
readonly PackingListFlagNotPkl: "ST429-9/PackingListFlagNotPkl";
|
|
38
|
+
readonly VolumeCountNotOne: "ST429-9/VolumeCountNotOne";
|
|
39
|
+
readonly ChunkCountNotOne: "ST429-9/ChunkCountNotOne";
|
|
40
|
+
readonly ChunkVolumeIndexNotOne: "ST429-9/ChunkVolumeIndexNotOne";
|
|
41
|
+
readonly ChunkOffsetNotZero: "ST429-9/ChunkOffsetNotZero";
|
|
42
|
+
readonly ChunkLengthMismatch: "ST429-9/ChunkLengthMismatch";
|
|
43
|
+
readonly SymbolicLink: "ST429-9/SymbolicLink";
|
|
36
44
|
};
|
|
37
45
|
readonly ST2067_2: {
|
|
38
46
|
readonly NotImfCompositionPlaylist: "ST2067-2/NotImfCompositionPlaylist";
|
|
39
47
|
readonly PklMalformedXml: "ST2067-2/PklMalformedXml";
|
|
48
|
+
readonly NoPackingList: "ST2067-2/NoPackingList";
|
|
40
49
|
readonly NoCpls: "ST2067-2/NoCpls";
|
|
41
50
|
readonly SizeMismatch: "ST2067-2/SizeMismatch";
|
|
42
51
|
readonly FileNotFound: "ST2067-2/FileNotFound";
|
|
@@ -88,6 +97,7 @@ export declare const codes: {
|
|
|
88
97
|
readonly TimedTextMappingKindNot0x13: "ST2067-2/TimedTextMappingKindNot0x13";
|
|
89
98
|
readonly MainImageVirtualTrackCount: "ST2067-2/MainImageVirtualTrackCount";
|
|
90
99
|
readonly AudioVirtualTrackMissing: "ST2067-2/AudioVirtualTrackMissing";
|
|
100
|
+
readonly TrackFileMediaType: "ST2067-2/TrackFileMediaType";
|
|
91
101
|
};
|
|
92
102
|
readonly ST2067_3: {
|
|
93
103
|
readonly ContentTitleEmpty: "ST2067-3/ContentTitleEmpty";
|
|
@@ -113,8 +123,22 @@ export declare const codes: {
|
|
|
113
123
|
readonly ResourceDuration: "ST2067-3/ResourceDuration";
|
|
114
124
|
readonly RepeatCount: "ST2067-3/RepeatCount";
|
|
115
125
|
readonly TrackFileId: "ST2067-3/TrackFileId";
|
|
126
|
+
readonly SourceEncodingMissing: "ST2067-3/SourceEncodingMissing";
|
|
116
127
|
readonly VirtualTrackContinuity: "ST2067-3/VirtualTrackContinuity";
|
|
128
|
+
readonly VirtualTrackSequenceKind: "ST2067-3/VirtualTrackSequenceKind";
|
|
129
|
+
readonly ExtensionSequenceNotSequenceType: "ST2067-3/ExtensionSequenceNotSequenceType";
|
|
130
|
+
readonly ResourceTypeMixed: "ST2067-3/ResourceTypeMixed";
|
|
131
|
+
readonly MarkerSequenceResourceType: "ST2067-3/MarkerSequenceResourceType";
|
|
117
132
|
readonly DanglingEssenceDescriptor: "ST2067-3/DanglingEssenceDescriptor";
|
|
133
|
+
readonly CplMediaType: "ST2067-3/CplMediaType";
|
|
134
|
+
readonly UniqueSequenceId: "ST2067-3/UniqueSequenceId";
|
|
135
|
+
readonly ContentMaturityRatingAgencyDuplicate: "ST2067-3/ContentMaturityRatingAgencyDuplicate";
|
|
136
|
+
readonly LocaleRegionInvalid: "ST2067-3/LocaleRegionInvalid";
|
|
137
|
+
readonly SignerWithoutSignature: "ST2067-3/SignerWithoutSignature";
|
|
138
|
+
readonly SignatureWithoutSigner: "ST2067-3/SignatureWithoutSigner";
|
|
139
|
+
readonly HashAlgorithmMissing: "ST2067-3/HashAlgorithmMissing";
|
|
140
|
+
readonly HashAlgorithmWithoutHash: "ST2067-3/HashAlgorithmWithoutHash";
|
|
141
|
+
readonly ResourceHashMismatch: "ST2067-3/ResourceHashMismatch";
|
|
118
142
|
};
|
|
119
143
|
readonly ST2067_5: {
|
|
120
144
|
readonly OperationalPatternQualifier: "ST2067-5/OperationalPatternQualifier";
|
|
@@ -248,11 +272,14 @@ export declare const codes: {
|
|
|
248
272
|
readonly NotValidated: "XSD/NotValidated";
|
|
249
273
|
};
|
|
250
274
|
readonly IMFERNO: {
|
|
275
|
+
readonly ExtensionSequenceNotValidated: "IMFERNO/ExtensionSequenceNotValidated";
|
|
276
|
+
readonly SequenceListUnreadable: "IMFERNO/SequenceListUnreadable";
|
|
251
277
|
readonly EditionAssumed: "IMFERNO/EditionAssumed";
|
|
252
278
|
readonly EditionConflict: "IMFERNO/EditionConflict";
|
|
253
279
|
readonly EditionPinned: "IMFERNO/EditionPinned";
|
|
254
280
|
readonly PinNotApplied: "IMFERNO/PinNotApplied";
|
|
255
281
|
readonly DeliveryNotChecked: "IMFERNO/DeliveryNotChecked";
|
|
282
|
+
readonly DiskChecksNotRun: "IMFERNO/DiskChecksNotRun";
|
|
256
283
|
readonly OpenFailed: "IMFERNO/OpenFailed";
|
|
257
284
|
readonly PartitionPackParseFailed: "IMFERNO/PartitionPackParseFailed";
|
|
258
285
|
readonly RegXmlConversionFailed: "IMFERNO/RegXmlConversionFailed";
|
package/codes.js
CHANGED
|
@@ -19,6 +19,7 @@ const codes = {
|
|
|
19
19
|
ST429_8: {
|
|
20
20
|
SizeMismatch: "ST429-8/SizeMismatch",
|
|
21
21
|
ChecksumMismatch: "ST429-8/ChecksumMismatch",
|
|
22
|
+
MalformedXml: "ST429-8/MalformedXml",
|
|
22
23
|
},
|
|
23
24
|
ST429_9: {
|
|
24
25
|
AssetListEmpty: "ST429-9/AssetListEmpty",
|
|
@@ -33,10 +34,18 @@ const codes = {
|
|
|
33
34
|
AssetMapHasNoPackingList: "ST429-9/AssetMapHasNoPackingList",
|
|
34
35
|
PklIdNotInAssetMap: "ST429-9/PklIdNotInAssetMap",
|
|
35
36
|
AssetMapMalformedXml: "ST429-9/AssetMapMalformedXml",
|
|
37
|
+
PackingListFlagNotPkl: "ST429-9/PackingListFlagNotPkl",
|
|
38
|
+
VolumeCountNotOne: "ST429-9/VolumeCountNotOne",
|
|
39
|
+
ChunkCountNotOne: "ST429-9/ChunkCountNotOne",
|
|
40
|
+
ChunkVolumeIndexNotOne: "ST429-9/ChunkVolumeIndexNotOne",
|
|
41
|
+
ChunkOffsetNotZero: "ST429-9/ChunkOffsetNotZero",
|
|
42
|
+
ChunkLengthMismatch: "ST429-9/ChunkLengthMismatch",
|
|
43
|
+
SymbolicLink: "ST429-9/SymbolicLink",
|
|
36
44
|
},
|
|
37
45
|
ST2067_2: {
|
|
38
46
|
NotImfCompositionPlaylist: "ST2067-2/NotImfCompositionPlaylist",
|
|
39
47
|
PklMalformedXml: "ST2067-2/PklMalformedXml",
|
|
48
|
+
NoPackingList: "ST2067-2/NoPackingList",
|
|
40
49
|
NoCpls: "ST2067-2/NoCpls",
|
|
41
50
|
SizeMismatch: "ST2067-2/SizeMismatch",
|
|
42
51
|
FileNotFound: "ST2067-2/FileNotFound",
|
|
@@ -88,6 +97,7 @@ const codes = {
|
|
|
88
97
|
TimedTextMappingKindNot0x13: "ST2067-2/TimedTextMappingKindNot0x13",
|
|
89
98
|
MainImageVirtualTrackCount: "ST2067-2/MainImageVirtualTrackCount",
|
|
90
99
|
AudioVirtualTrackMissing: "ST2067-2/AudioVirtualTrackMissing",
|
|
100
|
+
TrackFileMediaType: "ST2067-2/TrackFileMediaType",
|
|
91
101
|
},
|
|
92
102
|
ST2067_3: {
|
|
93
103
|
ContentTitleEmpty: "ST2067-3/ContentTitleEmpty",
|
|
@@ -113,8 +123,22 @@ const codes = {
|
|
|
113
123
|
ResourceDuration: "ST2067-3/ResourceDuration",
|
|
114
124
|
RepeatCount: "ST2067-3/RepeatCount",
|
|
115
125
|
TrackFileId: "ST2067-3/TrackFileId",
|
|
126
|
+
SourceEncodingMissing: "ST2067-3/SourceEncodingMissing",
|
|
116
127
|
VirtualTrackContinuity: "ST2067-3/VirtualTrackContinuity",
|
|
128
|
+
VirtualTrackSequenceKind: "ST2067-3/VirtualTrackSequenceKind",
|
|
129
|
+
ExtensionSequenceNotSequenceType: "ST2067-3/ExtensionSequenceNotSequenceType",
|
|
130
|
+
ResourceTypeMixed: "ST2067-3/ResourceTypeMixed",
|
|
131
|
+
MarkerSequenceResourceType: "ST2067-3/MarkerSequenceResourceType",
|
|
117
132
|
DanglingEssenceDescriptor: "ST2067-3/DanglingEssenceDescriptor",
|
|
133
|
+
CplMediaType: "ST2067-3/CplMediaType",
|
|
134
|
+
UniqueSequenceId: "ST2067-3/UniqueSequenceId",
|
|
135
|
+
ContentMaturityRatingAgencyDuplicate: "ST2067-3/ContentMaturityRatingAgencyDuplicate",
|
|
136
|
+
LocaleRegionInvalid: "ST2067-3/LocaleRegionInvalid",
|
|
137
|
+
SignerWithoutSignature: "ST2067-3/SignerWithoutSignature",
|
|
138
|
+
SignatureWithoutSigner: "ST2067-3/SignatureWithoutSigner",
|
|
139
|
+
HashAlgorithmMissing: "ST2067-3/HashAlgorithmMissing",
|
|
140
|
+
HashAlgorithmWithoutHash: "ST2067-3/HashAlgorithmWithoutHash",
|
|
141
|
+
ResourceHashMismatch: "ST2067-3/ResourceHashMismatch",
|
|
118
142
|
},
|
|
119
143
|
ST2067_5: {
|
|
120
144
|
OperationalPatternQualifier: "ST2067-5/OperationalPatternQualifier",
|
|
@@ -248,11 +272,14 @@ const codes = {
|
|
|
248
272
|
NotValidated: "XSD/NotValidated",
|
|
249
273
|
},
|
|
250
274
|
IMFERNO: {
|
|
275
|
+
ExtensionSequenceNotValidated: "IMFERNO/ExtensionSequenceNotValidated",
|
|
276
|
+
SequenceListUnreadable: "IMFERNO/SequenceListUnreadable",
|
|
251
277
|
EditionAssumed: "IMFERNO/EditionAssumed",
|
|
252
278
|
EditionConflict: "IMFERNO/EditionConflict",
|
|
253
279
|
EditionPinned: "IMFERNO/EditionPinned",
|
|
254
280
|
PinNotApplied: "IMFERNO/PinNotApplied",
|
|
255
281
|
DeliveryNotChecked: "IMFERNO/DeliveryNotChecked",
|
|
282
|
+
DiskChecksNotRun: "IMFERNO/DiskChecksNotRun",
|
|
256
283
|
OpenFailed: "IMFERNO/OpenFailed",
|
|
257
284
|
PartitionPackParseFailed: "IMFERNO/PartitionPackParseFailed",
|
|
258
285
|
RegXmlConversionFailed: "IMFERNO/RegXmlConversionFailed",
|
package/index.d.ts
CHANGED
|
@@ -13,10 +13,18 @@ import type {
|
|
|
13
13
|
export * from "./types";
|
|
14
14
|
export { codes } from "./codes";
|
|
15
15
|
|
|
16
|
-
/** Options for validating a package on disk (`validatePath`, `buildReportFromPath`). */
|
|
16
|
+
/** Options for validating a package on disk (`validatePath`, `buildReportFromPath` and their `…Async` variants). */
|
|
17
17
|
export interface PathValidateOptions extends ValidateOptions {
|
|
18
|
-
/**
|
|
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
|
+
*/
|
|
19
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;
|
|
20
28
|
}
|
|
21
29
|
|
|
22
30
|
/** Explicit S3 credentials for `s3://` URIs. Omit to use the default AWS credential chain. */
|
|
@@ -28,7 +36,12 @@ export interface S3Credentials {
|
|
|
28
36
|
endpoint?: string;
|
|
29
37
|
}
|
|
30
38
|
|
|
31
|
-
/**
|
|
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
|
+
*/
|
|
32
45
|
export interface UriValidateOptions extends PathValidateOptions {
|
|
33
46
|
/** Ignored for filesystem URIs. */
|
|
34
47
|
credentials?: S3Credentials | null;
|
|
@@ -58,13 +71,26 @@ export declare function buildReport(files: Record<string, string>, options?: Val
|
|
|
58
71
|
* Validate an IMF package directory on disk, returning the legacy
|
|
59
72
|
* `ImfReport` summary. Prefer `validatePath` for new code.
|
|
60
73
|
*
|
|
74
|
+
* Hashes the assets in parallel and blocks until done; see
|
|
75
|
+
* `buildReportFromPathAsync`.
|
|
76
|
+
*
|
|
61
77
|
* @param path - Path to the IMP directory
|
|
62
|
-
* @param options - Optional validation options (`coreSpec`, `cplSpec`, `iabSpec`, `app2eSpec`, `skipDiskChecks`, `rules`, `aggregateRepeats`)
|
|
78
|
+
* @param options - Optional validation options (`coreSpec`, `cplSpec`, `iabSpec`, `app2eSpec`, `skipDiskChecks`, `skipHashes`, `rules`, `aggregateRepeats`)
|
|
63
79
|
* @returns An `ImfReport` with `package`, `cpls`, and `validation` fields.
|
|
64
80
|
* @throws If the directory cannot be read, the package cannot be parsed, or the options are invalid.
|
|
65
81
|
*/
|
|
66
82
|
export declare function buildReportFromPath(path: string, options?: PathValidateOptions | undefined | null): ImfReport
|
|
67
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
|
+
|
|
68
94
|
/**
|
|
69
95
|
* Build the legacy `ImfReport` summary from a URI. Accepts the same URI forms
|
|
70
96
|
* as `validateUri`; prefer `validateUri` for new code.
|
|
@@ -76,6 +102,15 @@ export declare function buildReportFromPath(path: string, options?: PathValidate
|
|
|
76
102
|
*/
|
|
77
103
|
export declare function buildReportFromUri(uri: string, options?: UriValidateOptions | undefined | null): ImfReport
|
|
78
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
|
+
|
|
79
114
|
/**
|
|
80
115
|
* Pretty-print a validation result as a human-readable string.
|
|
81
116
|
*
|
|
@@ -139,25 +174,44 @@ export declare function toSarif(report: ValidationResult | ValidationReport): Sa
|
|
|
139
174
|
* @param files - A map of filename to XML content
|
|
140
175
|
* @param options - Optional validation options
|
|
141
176
|
* @returns `{ package, validation }` — the full parsed package and all findings.
|
|
142
|
-
* @throws Only if the options are invalid.
|
|
177
|
+
* @throws Only if the options are invalid (wrong type, unknown key).
|
|
143
178
|
*/
|
|
144
179
|
export declare function validate(files: Record<string, string>, options?: ValidateOptions | undefined | null): ValidationResult
|
|
145
180
|
|
|
146
181
|
/**
|
|
147
182
|
* Parse and validate an IMF package directory on disk.
|
|
148
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
|
+
*
|
|
149
189
|
* @param path - Path to the IMP directory
|
|
150
190
|
* @param options - Optional validation options
|
|
151
191
|
* @returns `{ package, validation }` — the full parsed package and all findings.
|
|
152
|
-
* @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).
|
|
153
194
|
*/
|
|
154
195
|
export declare function validatePath(path: string, options?: PathValidateOptions | undefined | null): ValidationResult
|
|
155
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
|
+
|
|
156
207
|
/**
|
|
157
208
|
* Parse and validate an IMF package from a URI.
|
|
158
209
|
*
|
|
159
210
|
* Accepts `file://` URIs, bare filesystem paths, and (when built with the
|
|
160
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.
|
|
161
215
|
*
|
|
162
216
|
* @param uri - Path or URI to the IMP
|
|
163
217
|
* @param options - Optional validation options (plus `credentials` for S3)
|
|
@@ -165,3 +219,14 @@ export declare function validatePath(path: string, options?: PathValidateOptions
|
|
|
165
219
|
* @throws If the URI cannot be read or the options are invalid.
|
|
166
220
|
*/
|
|
167
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,12 +49,16 @@ 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,
|
|
59
63
|
toSarif,
|
|
60
64
|
} = nativeModule;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@imferno/node",
|
|
3
|
-
"version": "3.0.2-beta.
|
|
3
|
+
"version": "3.0.2-beta.4e10253",
|
|
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.
|
|
49
|
-
"@imferno/node-darwin-x64": "3.0.2-beta.
|
|
50
|
-
"@imferno/node-linux-x64-gnu": "3.0.2-beta.
|
|
51
|
-
"@imferno/node-linux-arm64-gnu": "3.0.2-beta.
|
|
52
|
-
"@imferno/node-win32-x64-msvc": "3.0.2-beta.
|
|
53
|
-
"@imferno/node-win32-arm64-msvc": "3.0.2-beta.
|
|
48
|
+
"@imferno/node-darwin-arm64": "3.0.2-beta.4e10253",
|
|
49
|
+
"@imferno/node-darwin-x64": "3.0.2-beta.4e10253",
|
|
50
|
+
"@imferno/node-linux-x64-gnu": "3.0.2-beta.4e10253",
|
|
51
|
+
"@imferno/node-linux-arm64-gnu": "3.0.2-beta.4e10253",
|
|
52
|
+
"@imferno/node-win32-x64-msvc": "3.0.2-beta.4e10253",
|
|
53
|
+
"@imferno/node-win32-arm64-msvc": "3.0.2-beta.4e10253"
|
|
54
54
|
},
|
|
55
55
|
"publishConfig": {
|
|
56
56
|
"access": "public"
|
package/types.d.ts
CHANGED
|
@@ -6,6 +6,18 @@
|
|
|
6
6
|
* ship their own copy: the WASM build serialises some CPL fields in camelCase.
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
+
export type RuleValidationReason =
|
|
10
|
+
| {
|
|
11
|
+
kind: "unknown_source";
|
|
12
|
+
variant: string;
|
|
13
|
+
}
|
|
14
|
+
| {
|
|
15
|
+
kind: "matches_nothing";
|
|
16
|
+
}
|
|
17
|
+
| {
|
|
18
|
+
hint: string;
|
|
19
|
+
kind: "unsupported_pattern";
|
|
20
|
+
};
|
|
9
21
|
/**
|
|
10
22
|
* A SMPTE IMF UUID, serialised as a bare UUID string (e.g. "0eb3d1b9-b77b-4d3f-bbe5-7c69b15dca85")
|
|
11
23
|
*/
|
|
@@ -207,18 +219,6 @@ export type MimeType =
|
|
|
207
219
|
* Mirrors ESLint's `"off"` / `"warn"` / `"error"` vocabulary, extended with the two IMF severity levels.
|
|
208
220
|
*/
|
|
209
221
|
export type RuleSeverity = "off" | "info" | "warn" | "error" | "critical";
|
|
210
|
-
export type RuleValidationReason =
|
|
211
|
-
| {
|
|
212
|
-
kind: "unknown_source";
|
|
213
|
-
variant: string;
|
|
214
|
-
}
|
|
215
|
-
| {
|
|
216
|
-
kind: "matches_nothing";
|
|
217
|
-
}
|
|
218
|
-
| {
|
|
219
|
-
hint: string;
|
|
220
|
-
kind: "unsupported_pattern";
|
|
221
|
-
};
|
|
222
222
|
|
|
223
223
|
/**
|
|
224
224
|
* @deprecated
|
|
@@ -229,6 +229,10 @@ export type RuleValidationReason =
|
|
|
229
229
|
export interface ImfReport {
|
|
230
230
|
cpls: CplReport[];
|
|
231
231
|
package: PackageSummary;
|
|
232
|
+
/**
|
|
233
|
+
* Keys of the `rules` option that select no rule (typos, unknown editions); they were ignored. Absent when every key matched.
|
|
234
|
+
*/
|
|
235
|
+
ruleWarnings?: RuleValidationWarning[];
|
|
232
236
|
validation: ValidationReport;
|
|
233
237
|
}
|
|
234
238
|
export interface CplReport {
|
|
@@ -319,6 +323,18 @@ export interface UnreferencedAsset {
|
|
|
319
323
|
id: string;
|
|
320
324
|
path: string;
|
|
321
325
|
}
|
|
326
|
+
/**
|
|
327
|
+
* A diagnostic about a `RulesConfig` key that the engine couldn't match.
|
|
328
|
+
*
|
|
329
|
+
* Produced by `RulesConfig::validate`. Operators can use these at config-load time to catch typos before any validation work runs.
|
|
330
|
+
*/
|
|
331
|
+
export interface RuleValidationWarning {
|
|
332
|
+
/**
|
|
333
|
+
* The configured key that triggered the warning.
|
|
334
|
+
*/
|
|
335
|
+
key: string;
|
|
336
|
+
reason: RuleValidationReason;
|
|
337
|
+
}
|
|
322
338
|
/**
|
|
323
339
|
* Comprehensive validation report
|
|
324
340
|
*/
|
|
@@ -339,6 +355,10 @@ export interface ValidationReport {
|
|
|
339
355
|
* Whether the package is compliant with base SMPTE standards
|
|
340
356
|
*/
|
|
341
357
|
is_compliant: boolean;
|
|
358
|
+
/**
|
|
359
|
+
* Whether everything in the package was validated. False when a finding says part of it was not (e.g. `IMFERNO:Cpl/ExtensionSequenceNotValidated` for S-ADM audio): then `is_compliant` only covers what was checked. A rule override that switches such a finding `off` moves it to `suppressed` but keeps this false.
|
|
360
|
+
*/
|
|
361
|
+
is_fully_validated: boolean;
|
|
342
362
|
/**
|
|
343
363
|
* Whether the package is playable despite issues
|
|
344
364
|
*/
|
|
@@ -540,10 +560,21 @@ export interface ChunkList {
|
|
|
540
560
|
* A single file path entry in a ChunkList.
|
|
541
561
|
*/
|
|
542
562
|
export interface Chunk {
|
|
563
|
+
/**
|
|
564
|
+
* `<Length>` in bytes, when present.
|
|
565
|
+
*/
|
|
566
|
+
length?: number | null;
|
|
567
|
+
/**
|
|
568
|
+
* `<Offset>` in bytes, when present.
|
|
569
|
+
*/
|
|
570
|
+
offset?: number | null;
|
|
543
571
|
/**
|
|
544
572
|
* File path relative to the IMP root directory.
|
|
545
573
|
*/
|
|
546
574
|
path: string;
|
|
575
|
+
/**
|
|
576
|
+
* `<VolumeIndex>`; 1 when absent.
|
|
577
|
+
*/
|
|
547
578
|
volumeIndex: number;
|
|
548
579
|
}
|
|
549
580
|
/**
|
|
@@ -1138,6 +1169,10 @@ export interface Segment {
|
|
|
1138
1169
|
SequenceList: SequenceList;
|
|
1139
1170
|
}
|
|
1140
1171
|
export interface SequenceList {
|
|
1172
|
+
/**
|
|
1173
|
+
* Sequences whose element imferno does not model (ST 2067-3 §6.9.3 Extension Sequences, e.g. ST 2067-203 `MGASADMSignalSequence` or ST 2067-2 `CommentarySequence`), in document order. Filled by `parse_cpl` from the source XML so their EssenceDescriptor and Track File references resolve; no other rules are applied to them.
|
|
1174
|
+
*/
|
|
1175
|
+
ExtensionSequence?: ExtensionSequence[];
|
|
1141
1176
|
ForcedNarrativeSequence?: ForcedNarrativeSequence[];
|
|
1142
1177
|
HearingImpairedCaptionsSequence?: HearingImpairedCaptionsSequence[];
|
|
1143
1178
|
IABSequence?: IABSequence[];
|
|
@@ -1147,8 +1182,13 @@ export interface SequenceList {
|
|
|
1147
1182
|
MarkerSequence?: MarkerSequence[];
|
|
1148
1183
|
SubtitlesSequence?: SubtitlesSequence[];
|
|
1149
1184
|
}
|
|
1150
|
-
|
|
1185
|
+
/**
|
|
1186
|
+
* A Sequence of a kind imferno does not model (ST 2067-3 §6.9.3 Extension Sequence). Every Sequence derives from SequenceType, so its Id, TrackId and Resources are kept; the element is named by `name` (local name) and `namespace` (namespace URI; null when the element has no namespace).
|
|
1187
|
+
*/
|
|
1188
|
+
export interface ExtensionSequence {
|
|
1151
1189
|
Id: ImfUuid;
|
|
1190
|
+
Name?: string;
|
|
1191
|
+
Namespace?: string | null;
|
|
1152
1192
|
ResourceList: ResourceList;
|
|
1153
1193
|
TrackId: ImfUuid;
|
|
1154
1194
|
}
|
|
@@ -1163,17 +1203,40 @@ export interface Resource {
|
|
|
1163
1203
|
Id: ImfUuid;
|
|
1164
1204
|
IntrinsicDuration: number;
|
|
1165
1205
|
KeyId?: ImfUuid | null;
|
|
1206
|
+
/**
|
|
1207
|
+
* `LeftEye` of a `cc:StereoImageTrackFileResourceType` resource (ST 2067-2:2013, :2016 and :2020). A stereo resource carries its SourceEncoding and TrackFileId per eye, not on the resource itself.
|
|
1208
|
+
*/
|
|
1209
|
+
LeftEye?: StereoEye | null;
|
|
1166
1210
|
Marker?: MarkerInfo[];
|
|
1167
1211
|
RepeatCount?: number | null;
|
|
1212
|
+
/**
|
|
1213
|
+
* `RightEye` of a `cc:StereoImageTrackFileResourceType` resource.
|
|
1214
|
+
*/
|
|
1215
|
+
RightEye?: StereoEye | null;
|
|
1168
1216
|
SourceDuration?: number | null;
|
|
1169
1217
|
SourceEncoding?: ImfUuid | null;
|
|
1170
1218
|
TrackFileId?: ImfUuid | null;
|
|
1171
1219
|
}
|
|
1220
|
+
/**
|
|
1221
|
+
* One eye of a stereo resource: a `cpl:TrackFileResourceType` (ST 2067-2). Only the track file reference fields are kept; the eye's timing fields are checked by the XSD layer.
|
|
1222
|
+
*/
|
|
1223
|
+
export interface StereoEye {
|
|
1224
|
+
Hash?: string | null;
|
|
1225
|
+
Id?: ImfUuid | null;
|
|
1226
|
+
KeyId?: ImfUuid | null;
|
|
1227
|
+
SourceEncoding?: ImfUuid | null;
|
|
1228
|
+
TrackFileId?: ImfUuid | null;
|
|
1229
|
+
}
|
|
1172
1230
|
export interface MarkerInfo {
|
|
1173
1231
|
Annotation?: string | null;
|
|
1174
1232
|
Label: MarkerLabelElement;
|
|
1175
1233
|
Offset: number;
|
|
1176
1234
|
}
|
|
1235
|
+
export interface ForcedNarrativeSequence {
|
|
1236
|
+
Id: ImfUuid;
|
|
1237
|
+
ResourceList: ResourceList;
|
|
1238
|
+
TrackId: ImfUuid;
|
|
1239
|
+
}
|
|
1177
1240
|
export interface HearingImpairedCaptionsSequence {
|
|
1178
1241
|
Id: ImfUuid;
|
|
1179
1242
|
ResourceList: ResourceList;
|
|
@@ -1445,18 +1508,6 @@ export interface ValidationResult {
|
|
|
1445
1508
|
rule_warnings?: RuleValidationWarning[];
|
|
1446
1509
|
validation: ValidationReport;
|
|
1447
1510
|
}
|
|
1448
|
-
/**
|
|
1449
|
-
* A diagnostic about a `RulesConfig` key that the engine couldn't match.
|
|
1450
|
-
*
|
|
1451
|
-
* Produced by `RulesConfig::validate`. Operators can use these at config-load time to catch typos before any validation work runs.
|
|
1452
|
-
*/
|
|
1453
|
-
export interface RuleValidationWarning {
|
|
1454
|
-
/**
|
|
1455
|
-
* The configured key that triggered the warning.
|
|
1456
|
-
*/
|
|
1457
|
-
key: string;
|
|
1458
|
-
reason: RuleValidationReason;
|
|
1459
|
-
}
|
|
1460
1511
|
|
|
1461
1512
|
/**
|
|
1462
1513
|
* Core constraints (ST 2067-2) edition to validate against. `"auto"` detects
|