@imferno/node 3.0.2-beta.51b7476 → 3.0.2-beta.67b6b7d

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
@@ -1,102 +1,167 @@
1
- /* auto-generated by NAPI-RS */
1
+ /* auto-generated by NAPI-RS (`napi build`) — edit src/lib.rs or dts-header.d.ts instead */
2
2
  /* eslint-disable */
3
3
 
4
- /**
5
- * Returns the imferno library version string.
6
- */
7
- export declare function getVersion(): string
4
+ import type {
5
+ ImfReport,
6
+ Imferno,
7
+ RuleInfo,
8
+ ValidateOptions,
9
+ ValidationReport,
10
+ ValidationResult,
11
+ } from "./types";
12
+
13
+ export * from "./types";
14
+ export { codes } from "./codes";
15
+
16
+ /** Options for validating a package on disk (`validatePath`, `buildReportFromPath`). */
17
+ export interface PathValidateOptions extends ValidateOptions {
18
+ /** Skip file-manifest (size/presence) and MXF header checks. Default: `false`. */
19
+ skipDiskChecks?: boolean;
20
+ }
21
+
22
+ /** Explicit S3 credentials for `s3://` URIs. Omit to use the default AWS credential chain. */
23
+ export interface S3Credentials {
24
+ accessKeyId: string;
25
+ secretAccessKey: string;
26
+ sessionToken?: string;
27
+ region?: string;
28
+ endpoint?: string;
29
+ }
30
+
31
+ /** Options for `validateUri` / `buildReportFromUri`. */
32
+ export interface UriValidateOptions extends PathValidateOptions {
33
+ /** Ignored for filesystem URIs. */
34
+ credentials?: S3Credentials | null;
35
+ }
36
+
37
+ /** A SARIF 2.1.0 log (https://docs.oasis-open.org/sarif/sarif/v2.1.0/). */
38
+ export interface SarifLog {
39
+ $schema?: string;
40
+ version: "2.1.0";
41
+ runs: Array<Record<string, unknown>>;
42
+ }
8
43
 
9
44
  /**
10
- * Validate an IMF package from in-memory XML strings.
45
+ * Validate an IMF package from in-memory XML strings, returning the legacy
46
+ * `ImfReport` summary. Prefer `validate` for new code.
47
+ *
48
+ * Disk checks are always skipped (there is no package on disk).
11
49
  *
12
50
  * @param files - A map of filename to XML content (e.g. `{ "ASSETMAP.xml": "..." }`)
13
- * @param options - Optional validation options (`coreSpec`, `app2eSpec`, `rules`, etc.)
14
- * @returns An `ImfReport` object with `package`, `cpls`, and `validation` fields.
51
+ * @param options - Optional validation options (`coreSpec`, `cplSpec`, `iabSpec`, `app2eSpec`, `rules`, `aggregateRepeats`)
52
+ * @returns An `ImfReport` with `package`, `cpls`, and `validation` fields.
53
+ * @throws If the package cannot be parsed or the options are invalid.
15
54
  */
16
- export declare function buildReport(files: Record<string, string>, options?: any | undefined | null): any
55
+ export declare function buildReport(files: Record<string, string>, options?: ValidateOptions | undefined | null): ImfReport
17
56
 
18
57
  /**
19
- * Validate an IMF package directory on disk.
58
+ * Validate an IMF package directory on disk, returning the legacy
59
+ * `ImfReport` summary. Prefer `validatePath` for new code.
20
60
  *
21
61
  * @param path - Path to the IMP directory
22
- * @param options - Optional validation options (`coreSpec`, `app2eSpec`, `skipDiskChecks`, `rules`, etc.)
23
- * @returns An `ImfReport` object with `package`, `cpls`, and `validation` fields.
62
+ * @param options - Optional validation options (`coreSpec`, `cplSpec`, `iabSpec`, `app2eSpec`, `skipDiskChecks`, `rules`, `aggregateRepeats`)
63
+ * @returns An `ImfReport` with `package`, `cpls`, and `validation` fields.
64
+ * @throws If the directory cannot be read, the package cannot be parsed, or the options are invalid.
24
65
  */
25
- export declare function buildReportFromPath(path: string, options?: any | undefined | null): any
66
+ export declare function buildReportFromPath(path: string, options?: PathValidateOptions | undefined | null): ImfReport
26
67
 
27
68
  /**
28
- * Pretty-print an `ImfReport` as a human-readable string.
69
+ * Build the legacy `ImfReport` summary from a URI. Accepts the same URI forms
70
+ * as `validateUri`; prefer `validateUri` for new code.
29
71
  *
30
- * @param report - A previously returned `ImfReport` object
31
- * @returns A formatted plain-text report string.
72
+ * @param uri - Path or URI to the IMP
73
+ * @param options - Optional validation options
74
+ * @returns An `ImfReport` with `package`, `cpls`, and `validation` fields.
75
+ * @throws If the URI cannot be read, the package cannot be parsed, or the options are invalid.
32
76
  */
33
- export declare function formatReport(report: any): string
77
+ export declare function buildReportFromUri(uri: string, options?: UriValidateOptions | undefined | null): ImfReport
34
78
 
35
79
  /**
36
- * Parse an IMF package from in-memory XML strings, returning the full parsed package.
80
+ * Pretty-print a validation result as a human-readable string.
37
81
  *
38
- * Unlike `buildReport` which returns a validation summary, this returns the
39
- * complete `Imferno` struct with all essence descriptors, locales, content versions, etc.
82
+ * @param report - The object returned by `validate*`, or (legacy) by `buildReport*`
83
+ * @returns A formatted plain-text report.
84
+ * @throws If `report` is neither a `ValidationResult` nor an `ImfReport`.
85
+ */
86
+ export declare function formatReport(report: ValidationResult | ImfReport): string
87
+
88
+ /** Returns the imferno library version string. */
89
+ export declare function getVersion(): string
90
+
91
+ /**
92
+ * Returns the engine's rule catalogue: one entry per rule, each with its
93
+ * table of editions (clause, strength, default severity, display code).
94
+ * Useful for building settings UIs; `id`, `name`, `SPEC:EDITION/Name` and
95
+ * the display codes are all usable as `rules` keys.
96
+ */
97
+ export declare function listRules(): RuleInfo[]
98
+
99
+ /**
100
+ * Parse an IMF package from in-memory XML strings, returning the full parsed
101
+ * package without validating it.
40
102
  *
41
103
  * @param files - A map of filename to XML content (e.g. `{ "ASSETMAP.xml": "..." }`)
42
- * @returns The full parsed Imferno package object.
104
+ * @returns The full parsed `Imferno` package.
105
+ * @throws If the package cannot be parsed.
43
106
  */
44
- export declare function parsePackage(files: Record<string, string>): any
107
+ export declare function parsePackage(files: Record<string, string>): Imferno
45
108
 
46
109
  /**
47
- * Parse an IMF package directory on disk, returning the full parsed package.
48
- *
49
- * Unlike `buildReportFromPath` which returns a validation summary, this returns the
50
- * complete `Imferno` struct with all essence descriptors, locales, content versions, etc.
110
+ * Parse an IMF package directory on disk, returning the full parsed package
111
+ * without validating it.
51
112
  *
52
113
  * @param path - Path to the IMP directory
53
- * @returns The full parsed Imferno package object.
114
+ * @returns The full parsed `Imferno` package.
115
+ * @throws If the directory cannot be read or the package cannot be parsed.
54
116
  */
55
- export declare function parsePackageFromPath(path: string): any
117
+ export declare function parsePackageFromPath(path: string): Imferno
56
118
 
57
119
  /**
58
- * Parse and validate an IMF package from in-memory XML strings.
120
+ * Convert a validation result to a SARIF 2.1.0 log.
59
121
  *
60
- * This is the recommended entry point. Returns the full parsed package
61
- * plus all validation findings.
122
+ * Rules are reported by rule id (`ST2067-3/SegmentDuration`); each finding
123
+ * points at the applied edition's clause in that edition's taxonomy
124
+ * (`ST2067-3:2016`).
62
125
  *
63
- * @param files - A map of filename to XML content
64
- * @param options - Optional validation options
65
- * @returns `{ package, validation }` — full Imferno struct + ValidationReport
126
+ * @param report - The object returned by `validate*` (or its `validation`)
127
+ * @returns A SARIF 2.1.0 log object.
128
+ * @throws If `report` is not a validation result or report.
66
129
  */
67
- export declare function validate(files: Record<string, string>, options?: any | undefined | null): any
130
+ export declare function toSarif(report: ValidationResult | ValidationReport): SarifLog
68
131
 
69
132
  /**
70
- * Parse and validate an IMF package directory on disk.
133
+ * Parse and validate an IMF package from in-memory XML strings. This is the
134
+ * recommended entry point.
71
135
  *
72
- * @param path - Path to the IMP directory
136
+ * Parse failures are reported as findings in `validation`, not thrown.
137
+ * Disk checks are always skipped (there is no package on disk).
138
+ *
139
+ * @param files - A map of filename to XML content
73
140
  * @param options - Optional validation options
74
- * @returns `{ package, validation }` — full Imferno struct + ValidationReport
141
+ * @returns `{ package, validation }` — the full parsed package and all findings.
142
+ * @throws Only if the options are invalid.
75
143
  */
76
- export declare function validatePath(path: string, options?: any | undefined | null): any
144
+ export declare function validate(files: Record<string, string>, options?: ValidateOptions | undefined | null): ValidationResult
77
145
 
78
146
  /**
79
- * Parse and validate an IMF package from a URI.
80
- *
81
- * Accepts `file://` URIs, bare filesystem paths, and (when the binary is built
82
- * with the `aws-s3` feature) `s3://bucket/prefix/` URIs. The prebuilt binaries
83
- * on npm include `aws-s3` enabled.
147
+ * Parse and validate an IMF package directory on disk.
84
148
  *
85
- * @param uri - Path or URI to the IMP
149
+ * @param path - Path to the IMP directory
86
150
  * @param options - Optional validation options
87
- * @returns `{ package, validation }` — full Imferno struct + ValidationReport
151
+ * @returns `{ package, validation }` — the full parsed package and all findings.
152
+ * @throws If the directory cannot be read or the options are invalid.
88
153
  */
89
- export declare function validateUri(uri: string, options?: any | undefined | null): any
154
+ export declare function validatePath(path: string, options?: PathValidateOptions | undefined | null): ValidationResult
90
155
 
91
156
  /**
92
- * Build an ImfReport summary from a URI.
157
+ * Parse and validate an IMF package from a URI.
93
158
  *
94
- * Accepts the same URI forms as `validateUri`. Prefer `validateUri` for new
95
- * code — `buildReportFromUri` is kept for parity with `buildReport` /
96
- * `buildReportFromPath`.
159
+ * Accepts `file://` URIs, bare filesystem paths, and (when built with the
160
+ * `aws-s3` feature, as the prebuilt npm binaries are) `s3://bucket/prefix/`.
97
161
  *
98
162
  * @param uri - Path or URI to the IMP
99
- * @param options - Optional validation options
100
- * @returns An `ImfReport` object with `package`, `cpls`, and `validation` fields.
163
+ * @param options - Optional validation options (plus `credentials` for S3)
164
+ * @returns `{ package, validation }` — the full parsed package and all findings.
165
+ * @throws If the URI cannot be read or the options are invalid.
101
166
  */
102
- export declare function buildReportFromUri(uri: string, options?: any | undefined | null): any
167
+ export declare function validateUri(uri: string, options?: UriValidateOptions | undefined | null): ValidationResult
package/index.mjs CHANGED
@@ -56,6 +56,7 @@ export const {
56
56
  validatePath,
57
57
  validateUri,
58
58
  listRules,
59
+ toSarif,
59
60
  } = nativeModule;
60
61
 
61
62
  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.51b7476",
3
+ "version": "3.0.2-beta.67b6b7d",
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",
@@ -26,25 +26,31 @@
26
26
  "aarch64-unknown-linux-gnu",
27
27
  "x86_64-pc-windows-msvc",
28
28
  "aarch64-pc-windows-msvc"
29
- ]
29
+ ],
30
+ "dtsHeaderFile": "dts-header.d.ts"
30
31
  },
31
32
  "files": [
32
33
  "index.js",
33
34
  "index.mjs",
34
35
  "index.d.ts",
36
+ "types.d.ts",
35
37
  "codes.js",
36
38
  "codes.mjs",
37
39
  "codes.d.ts",
38
40
  "README.md",
39
41
  "LICENSE"
40
42
  ],
43
+ "scripts": {
44
+ "build": "napi build --release",
45
+ "test": "vitest run"
46
+ },
41
47
  "optionalDependencies": {
42
- "@imferno/node-darwin-arm64": "3.0.2-beta.51b7476",
43
- "@imferno/node-darwin-x64": "3.0.2-beta.51b7476",
44
- "@imferno/node-linux-x64-gnu": "3.0.2-beta.51b7476",
45
- "@imferno/node-linux-arm64-gnu": "3.0.2-beta.51b7476",
46
- "@imferno/node-win32-x64-msvc": "3.0.2-beta.51b7476",
47
- "@imferno/node-win32-arm64-msvc": "3.0.2-beta.51b7476"
48
+ "@imferno/node-darwin-arm64": "3.0.2-beta.67b6b7d",
49
+ "@imferno/node-darwin-x64": "3.0.2-beta.67b6b7d",
50
+ "@imferno/node-linux-x64-gnu": "3.0.2-beta.67b6b7d",
51
+ "@imferno/node-linux-arm64-gnu": "3.0.2-beta.67b6b7d",
52
+ "@imferno/node-win32-x64-msvc": "3.0.2-beta.67b6b7d",
53
+ "@imferno/node-win32-arm64-msvc": "3.0.2-beta.67b6b7d"
48
54
  },
49
55
  "publishConfig": {
50
56
  "access": "public"
@@ -60,5 +66,18 @@
60
66
  },
61
67
  "engines": {
62
68
  "node": ">=16.0.0"
69
+ },
70
+ "devDependencies": {
71
+ "@napi-rs/cli": "3.10.12",
72
+ "ajv": "^8.20.0",
73
+ "json-schema-to-typescript": "16.0.0",
74
+ "prettier": "3.9.10",
75
+ "ts-json-schema-generator": "2.9.0",
76
+ "typescript": "^5.9.3",
77
+ "vitest": "^4.0.18"
78
+ },
79
+ "overrides": {
80
+ "prettier": "3.9.10",
81
+ "@apidevtools/json-schema-ref-parser": "11.9.3"
63
82
  }
64
83
  }