@nirs4all/io-wasm 0.1.11 → 0.1.13

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.
@@ -42,6 +42,16 @@ export function inferFiles(files: any, options: any): any;
42
42
  */
43
43
  export function inferRecords(record_sets: any): any;
44
44
 
45
+ /**
46
+ * Materialize the same fs-free inputs as [`assemble_dataset`] and return the
47
+ * canonical structural summary used by the native CLI and C ABI.
48
+ *
49
+ * Keeping this as canonical JSON (rather than a re-serialized JS object) makes
50
+ * the cross-language qualification byte-exact and preserves source, sample,
51
+ * observation, repetition, group, and fold provenance without host-side logic.
52
+ */
53
+ export function loadSummary(files: any, record_sets: any, spec: string): string;
54
+
45
55
  /**
46
56
  * Iterative, user-validatable dataset inference.
47
57
  *
@@ -84,6 +84,40 @@ function inferRecords(record_sets) {
84
84
  }
85
85
  exports.inferRecords = inferRecords;
86
86
 
87
+ /**
88
+ * Materialize the same fs-free inputs as [`assemble_dataset`] and return the
89
+ * canonical structural summary used by the native CLI and C ABI.
90
+ *
91
+ * Keeping this as canonical JSON (rather than a re-serialized JS object) makes
92
+ * the cross-language qualification byte-exact and preserves source, sample,
93
+ * observation, repetition, group, and fold provenance without host-side logic.
94
+ * @param {any} files
95
+ * @param {any} record_sets
96
+ * @param {string} spec
97
+ * @returns {string}
98
+ */
99
+ function loadSummary(files, record_sets, spec) {
100
+ let deferred3_0;
101
+ let deferred3_1;
102
+ try {
103
+ const ptr0 = passStringToWasm0(spec, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
104
+ const len0 = WASM_VECTOR_LEN;
105
+ const ret = wasm.loadSummary(files, record_sets, ptr0, len0);
106
+ var ptr2 = ret[0];
107
+ var len2 = ret[1];
108
+ if (ret[3]) {
109
+ ptr2 = 0; len2 = 0;
110
+ throw takeFromExternrefTable0(ret[2]);
111
+ }
112
+ deferred3_0 = ptr2;
113
+ deferred3_1 = len2;
114
+ return getStringFromWasm0(ptr2, len2);
115
+ } finally {
116
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
117
+ }
118
+ }
119
+ exports.loadSummary = loadSummary;
120
+
87
121
  /**
88
122
  * Iterative, user-validatable dataset inference.
89
123
  *
Binary file
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "Gregory Beurier <gregory.beurier@cirad.fr>"
5
5
  ],
6
6
  "description": "wasm-bindgen binding for nirs4all-io: the fs-free JSON surface (to_spec / validate over a spec dict). Excluded from the cargo workspace; built with wasm-pack.",
7
- "version": "0.1.11",
7
+ "version": "0.1.13",
8
8
  "license": "CECILL-2.1 OR AGPL-3.0-or-later",
9
9
  "repository": {
10
10
  "type": "git",
@@ -14,12 +14,36 @@
14
14
  "files": [
15
15
  "nirs4all_io_wasm_bg.wasm",
16
16
  "nirs4all_io_wasm.js",
17
- "nirs4all_io_wasm.d.ts"
17
+ "nirs4all_io_wasm.d.ts",
18
+ "idiomatic.mjs",
19
+ "idiomatic.d.ts",
20
+ "types/nirs4all-io.d.ts",
21
+ "LICENSE",
22
+ "LICENSES",
23
+ "LICENSING.md",
24
+ "THIRD_PARTY_NOTICES.md",
25
+ "COPY_PROVENANCE.md",
26
+ "nirs4all-io-wasm.cdx.json"
18
27
  ],
19
28
  "main": "nirs4all_io_wasm.js",
20
29
  "types": "nirs4all_io_wasm.d.ts",
21
30
  "publishConfig": {
22
31
  "access": "public",
23
32
  "provenance": true
33
+ },
34
+ "exports": {
35
+ ".": {
36
+ "types": "./nirs4all_io_wasm.d.ts",
37
+ "require": "./nirs4all_io_wasm.js",
38
+ "default": "./nirs4all_io_wasm.js"
39
+ },
40
+ "./idiomatic": {
41
+ "types": "./idiomatic.d.ts",
42
+ "import": "./idiomatic.mjs",
43
+ "default": "./idiomatic.mjs"
44
+ },
45
+ "./types": {
46
+ "types": "./types/nirs4all-io.d.ts"
47
+ }
24
48
  }
25
49
  }
@@ -0,0 +1,143 @@
1
+ // SPDX-License-Identifier: CeCILL-2.1 OR AGPL-3.0-or-later
2
+ //
3
+ // Hand-written TypeScript types for the nirs4all-io wasm binding.
4
+ //
5
+ // wasm-bindgen generates `any` for every `JsValue` parameter and return value
6
+ // (see the generated `nirs4all_io_wasm.d.ts`). This file gives the real shapes
7
+ // of the inputs and results so editors and `tsc` can check call sites. Import it
8
+ // alongside the generated module, or re-export through `idiomatic.mjs`.
9
+
10
+ /** A raw file: its name (used for source matching) and its bytes. */
11
+ export interface NamedFile {
12
+ name: string;
13
+ bytes: Uint8Array;
14
+ }
15
+
16
+ /** A set of decoded `nirs4all-formats` records for one source. */
17
+ export interface RecordSet {
18
+ source: string;
19
+ format?: string;
20
+ records: unknown[];
21
+ }
22
+
23
+ /** Options for the inference entry points. */
24
+ export interface InferOptions {
25
+ /** Override the default `nirs4all-classic` convention list. */
26
+ conventions?: string[];
27
+ }
28
+
29
+ /** A user lock fed back into `proposeDataset` to honour a confirmed decision. */
30
+ export interface ConfirmedLock {
31
+ kind: string;
32
+ target: string;
33
+ value?: unknown;
34
+ status?: string;
35
+ }
36
+
37
+ /** Options for the iterative `proposeDataset` builder. */
38
+ export interface ProposeOptions extends InferOptions {
39
+ confirmed?: ConfirmedLock[];
40
+ }
41
+
42
+ /** A single scored inference decision (structure, signal type, task type, ...). */
43
+ export interface Decision<T = unknown> {
44
+ value: T;
45
+ score: number;
46
+ ambiguous: boolean;
47
+ evidence: string[];
48
+ alternatives: unknown[];
49
+ }
50
+
51
+ /** One source of a `DatasetSpec`. */
52
+ export interface SourceSpec {
53
+ id: string;
54
+ role: string;
55
+ input: string;
56
+ partition?: string;
57
+ join?: unknown;
58
+ params?: Record<string, unknown>;
59
+ [key: string]: unknown;
60
+ }
61
+
62
+ /** A canonical dataset specification. */
63
+ export interface DatasetSpec {
64
+ schema_version: number;
65
+ name?: string;
66
+ sources: SourceSpec[];
67
+ params?: Record<string, unknown>;
68
+ partitions?: unknown;
69
+ folds?: unknown;
70
+ [key: string]: unknown;
71
+ }
72
+
73
+ /** A scored dataset plan produced by the inference entry points. */
74
+ export interface DatasetPlan {
75
+ resolved_spec: DatasetSpec;
76
+ overall_score: number;
77
+ recommendations: string[];
78
+ warnings: string[];
79
+ structure: Decision<string>;
80
+ signal_type: Decision<string>;
81
+ task_type: Decision<string>;
82
+ columns: unknown[];
83
+ input: Record<string, unknown>;
84
+ [key: string]: unknown;
85
+ }
86
+
87
+ /** A still-open (or echoed confirmed) decision from `proposeDataset`. */
88
+ export interface Proposal {
89
+ kind: string;
90
+ target: string;
91
+ value: unknown;
92
+ alternatives: unknown[];
93
+ evidence: string[];
94
+ score: number;
95
+ ambiguous: boolean;
96
+ status?: string;
97
+ }
98
+
99
+ /** The iterative builder result. */
100
+ export interface ProposeResult {
101
+ plan: DatasetPlan;
102
+ proposals: Proposal[];
103
+ spec: DatasetSpec;
104
+ valid: boolean;
105
+ validation_errors: string[];
106
+ }
107
+
108
+ /** A materialized dataset (per-partition X/y/metadata blocks). */
109
+ export interface AssembledDataset {
110
+ name: string;
111
+ blocks: Record<string, unknown>;
112
+ folds?: unknown;
113
+ [key: string]: unknown;
114
+ }
115
+
116
+ // --- typed views of the wasm-pack exports -------------------------------------
117
+
118
+ export function to_spec(specJson: string): string;
119
+ export function validate(specJson: string): void;
120
+ export function version(): string;
121
+ export function inferFiles(files: NamedFile[], options?: InferOptions): DatasetPlan;
122
+ export function inferRecords(recordSets: RecordSet[]): DatasetPlan;
123
+ export function inferDataset(
124
+ files: NamedFile[],
125
+ recordSets: RecordSet[],
126
+ options?: InferOptions,
127
+ ): DatasetPlan;
128
+ export function proposeDataset(
129
+ files: NamedFile[],
130
+ recordSets: RecordSet[],
131
+ options?: ProposeOptions,
132
+ ): ProposeResult;
133
+ export function assembleDataset(
134
+ files: NamedFile[],
135
+ recordSets: RecordSet[],
136
+ specJson: string,
137
+ ): AssembledDataset;
138
+ /** Canonical structural summary from the same native fs-free assembler. */
139
+ export function loadSummary(
140
+ files: NamedFile[],
141
+ recordSets: RecordSet[],
142
+ specJson: string,
143
+ ): string;