Skip to content
This repository was archived by the owner on Jul 2, 2025. It is now read-only.

Commit 52f16d4

Browse files
committed
mostly refactoring parser
1 parent 703ff84 commit 52f16d4

File tree

7 files changed

+251
-43
lines changed

7 files changed

+251
-43
lines changed

graph.svg

Lines changed: 204 additions & 0 deletions
Loading

src/dataLayerLoader.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ const defaults: Configuration = {
1717
adapter: 'file',
1818
path: `${process.env.HOME}/.config/projector/entries.json`
1919
}
20+
2021
export function dispatcher(options = {}) {
2122
const props: Configuration = {...defaults, ...options}
2223
let adapter: DataStoreAdapter

src/dataStoreAdapter.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
import * as E from './entry'
2+
import { Value } from '@sinclair/typebox/value'
23

34
export abstract class DataStoreAdapter { // need separate read/write abstract classes
45
persistEntry(entry:E.Entry): boolean {
5-
this.write(JSON.stringify(entry))
6+
7+
const str = Value.Encode(E.Entry, entry)
8+
console.log(str)
9+
this.write(JSON.stringify(str))
610
return true
711
}
812

src/entry.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,9 @@ export const Default = {
6161
// EntryUpdate (compose)
6262

6363
export const Entry = Type.Object({
64-
id: Type.Number(), // READ nextID()
65-
uid: Type.String(), // uid()
66-
path: Type.String(), // path(parent?)
64+
id: Type.Number(), // required
65+
uid: Type.String(), // required
66+
path: Type.String(), // required
6767

6868
type: Type.String({ default: EntryTypes.Transient }),
6969
status: Type.String({ default: StatusNames.Capture }),
@@ -82,7 +82,6 @@ export const Entry = Type.Object({
8282

8383
depends: Type.Array(Type.String(), { default: [] }), // TODO
8484
parents: Type.Array(Type.String(), { default: [] }), // TODO
85-
// children: Type.Array(Type.String(), { default: [] }), // TODO
8685

8786
recur: Type.Array(Type.String(), { default: [] }), // TODO
8887
repeat: Type.Array(Type.String(), { default: [] }), // TODO
@@ -99,7 +98,7 @@ export const Entry = Type.Object({
9998
start: Type.Optional(Type.Date()),
10099
reviewed: Type.Optional(Type.Date()),
101100

102-
created: Type.Date({ default: new Date() }), // FIXME won't work in a long-lived process
101+
created: Type.Date(),
103102
modified: Type.Optional(Type.Date()),
104103
})
105104
export type Entry = Static<typeof Entry>

src/fileStoreAdapter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export class FileStoreAdapter extends DataStoreAdapter {
1818

1919
let fd: number
2020

21-
using cleanup = new DisposableStack();
21+
using cleanup = new DisposableStack()
2222
cleanup.defer(() => {
2323
if(fd !== undefined)
2424
fs.closeSync(fd)

0 commit comments

Comments
 (0)