Skip to content

Commit

Permalink
mostly refactoring parser
Browse files Browse the repository at this point in the history
  • Loading branch information
davidlee committed Aug 30, 2023
1 parent 703ff84 commit 52f16d4
Show file tree
Hide file tree
Showing 7 changed files with 251 additions and 43 deletions.
204 changes: 204 additions & 0 deletions graph.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/dataLayerLoader.ts
Expand Up @@ -17,6 +17,7 @@ const defaults: Configuration = {
adapter: 'file',
path: `${process.env.HOME}/.config/projector/entries.json`
}

export function dispatcher(options = {}) {
const props: Configuration = {...defaults, ...options}
let adapter: DataStoreAdapter
Expand Down
6 changes: 5 additions & 1 deletion src/dataStoreAdapter.ts
@@ -1,8 +1,12 @@
import * as E from './entry'
import { Value } from '@sinclair/typebox/value'

export abstract class DataStoreAdapter { // need separate read/write abstract classes
persistEntry(entry:E.Entry): boolean {
this.write(JSON.stringify(entry))

const str = Value.Encode(E.Entry, entry)
console.log(str)
this.write(JSON.stringify(str))
return true
}

Expand Down
9 changes: 4 additions & 5 deletions src/entry.ts
Expand Up @@ -61,9 +61,9 @@ export const Default = {
// EntryUpdate (compose)

export const Entry = Type.Object({
id: Type.Number(), // READ nextID()
uid: Type.String(), // uid()
path: Type.String(), // path(parent?)
id: Type.Number(), // required
uid: Type.String(), // required
path: Type.String(), // required

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

depends: Type.Array(Type.String(), { default: [] }), // TODO
parents: Type.Array(Type.String(), { default: [] }), // TODO
// children: Type.Array(Type.String(), { default: [] }), // TODO

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

created: Type.Date({ default: new Date() }), // FIXME won't work in a long-lived process
created: Type.Date(),
modified: Type.Optional(Type.Date()),
})
export type Entry = Static<typeof Entry>
Expand Down
2 changes: 1 addition & 1 deletion src/fileStoreAdapter.ts
Expand Up @@ -18,7 +18,7 @@ export class FileStoreAdapter extends DataStoreAdapter {

let fd: number

using cleanup = new DisposableStack();
using cleanup = new DisposableStack()
cleanup.defer(() => {
if(fd !== undefined)
fs.closeSync(fd)
Expand Down

0 comments on commit 52f16d4

Please sign in to comment.