Add structure and interface for csv dynamic node
All checks were successful
test / test (push) Successful in 13m41s

This commit is contained in:
2025-01-18 14:25:26 +10:30
parent 65d1e9fec4
commit 9f6fa04dcf
10 changed files with 251 additions and 57 deletions

View File

@@ -1,35 +1,47 @@
package vato007:ingey;
world dynamic {
resource row {
get: func(name: string) -> string;
interface types {
resource csv-row {
columns: func() -> list<string>;
values: func() -> list<string>;
entries: func() -> list<tuple<string, string>>;
value: func(name: string) -> option<string>;
}
resource reader {
resource csv-reader {
columns: func() -> list<string>;
next: func() -> row;
next: func() -> csv-row;
has-next: func() -> bool;
// Get a row by values in one or more columns
query: func(values: list<tuple<string, string>>) -> row;
query: func(values: list<tuple<string, string>>) -> csv-row;
read-into-string: func() -> string;
read-into-map: func() -> read-map;
}
resource write-map {
keys: func() -> list<string>;
put: func(name: string, value: string);
}
resource csv-readers {
get-reader: func(name: string) -> option<csv-reader>;
}
resource csv-writer {
write-map: func(row: write-map);
write-row: func(row: list<tuple<string, string>>);
}
resource read-map {
get: func(key: string) -> string;
}
}
resource write-map {
add: func(name: string, value: string);
}
resource readers {
get-reader: func(name: string) -> option<reader>;
}
resource writer {
write: func(row: write-map);
}
export evaluate: func(readers: readers, properties: read-map, writer: writer);
// This will apply to csv files only for simplicity. A separate node should be created for arbitrary readers/writers
world dynamic {
use types.{csv-readers, read-map, csv-writer};
export evaluate: func(properties: read-map, readers: csv-readers, writer: csv-writer);
}