@cascateer/database 0.0.6 → 0.0.8
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/package.json +1 -1
- package/src/table.ts +11 -9
- package/src/types.ts +6 -0
package/package.json
CHANGED
package/src/table.ts
CHANGED
|
@@ -21,6 +21,7 @@ import { defaults } from "./defaults";
|
|
|
21
21
|
import { File } from "./file";
|
|
22
22
|
import { reduceActions } from "./observables/reduceActions";
|
|
23
23
|
import {
|
|
24
|
+
FileTable,
|
|
24
25
|
FileTableRecord,
|
|
25
26
|
TableAction,
|
|
26
27
|
TableActionCreator,
|
|
@@ -287,13 +288,14 @@ export const createTable = memoize(
|
|
|
287
288
|
|
|
288
289
|
export const createFileTable = (
|
|
289
290
|
id: string,
|
|
290
|
-
key: "url",
|
|
291
291
|
records: TableRecordCreator<FileTableRecord, "url">,
|
|
292
|
-
) =>
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
292
|
+
) =>
|
|
293
|
+
class
|
|
294
|
+
extends createTable<FileTableRecord, "url">(id, "url", records)
|
|
295
|
+
implements FileTable
|
|
296
|
+
{
|
|
297
|
+
toFile = (url: string, spinner?: Ora) =>
|
|
298
|
+
this.accessSome([url], spinner).then(([{ name, checksum }]) =>
|
|
299
|
+
new File(name).verified(checksum),
|
|
300
|
+
);
|
|
301
|
+
};
|
package/src/types.ts
CHANGED
|
@@ -2,6 +2,8 @@ import { MaybePromise } from "@cascateer/lib";
|
|
|
2
2
|
import { LazyPromise } from "@cascateer/lib/promises";
|
|
3
3
|
import { Function1 } from "lodash";
|
|
4
4
|
import { Ora } from "ora";
|
|
5
|
+
import { File } from "./file";
|
|
6
|
+
import { Table } from "./table";
|
|
5
7
|
|
|
6
8
|
interface BaseTableAction<Type> {
|
|
7
9
|
id: string;
|
|
@@ -72,3 +74,7 @@ export interface FileTableRecord {
|
|
|
72
74
|
name: string;
|
|
73
75
|
checksum: string;
|
|
74
76
|
}
|
|
77
|
+
|
|
78
|
+
export interface FileTable extends Table<FileTableRecord, "url"> {
|
|
79
|
+
toFile: (url: string, spinner?: Ora) => Promise<File>;
|
|
80
|
+
}
|