commit 02a635615873c659c9bc295acecbfb6fc3bbc2a4 Author: Kyle Isom Date: Mon Feb 21 17:37:47 2022 -0800 initial import diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..94e16b1 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +ark +blobs +*.db diff --git a/src/types/core/metadata.go b/src/types/core/metadata.go new file mode 100644 index 0000000..6a93603 --- /dev/null +++ b/src/types/core/metadata.go @@ -0,0 +1,68 @@ +package core + +import ( + "errors" + "os" + "path/filepath" + + "github.com/google/uuid" +) + +// ExoBasePath is the base path to the exocortex data stores. +var ExoBasePath = filepath.Join(os.Getenv("HOME"), "exo") + +const ( + // ValueTypeUnspecified is used when the value type hasn't been explicitly + // set. It should be interpreted as a string in the absence of further + // information. + ValueTypeUnspecified = "UNSPECIFIED" + + // ValueTypeString is used when the value type should be explicitly + // interpreted as a string. + ValueTypeString = "String" +) + +// For the sake of storage, values are stored as strings; associate type +// information so that interested consumers can handle correctly. +type Value struct { + Contents string + Type string +} + +// Val creates a new Value with an unspecified type. +func Val(contents string) Value { + return Value{ + Contents: contents, + Type: ValueTypeUnspecified, + } +} + +// Vals creates a new Value with a string type. +func Vals(contents string) Value { + return Value{ + Contents: contents, + Type: ValueTypeString, + } +} + +// Metadata holds additional information that isn't explicitly part of a data +// definition. +type Metadata map[string]Value + +// UUID returns a new UUID or panics. +func UUID() string { + return uuid.NewString() +} + +// ErrNoID is returned when a lookup is done on a struct that has no +// identifier attached.. +var ErrNoID = errors.New("missing UUID identifier") + +func MapFromList(list []string) map[string]bool { + m := map[string]bool{} + for _, s := range list { + m[s] = true + } + + return m +} diff --git a/src/types/kg/cell.go b/src/types/kg/cell.go new file mode 100644 index 0000000..d1b17aa --- /dev/null +++ b/src/types/kg/cell.go @@ -0,0 +1,7 @@ +package kg + +type Cell struct { + ID string + Contents []byte + Type string +} diff --git a/src/types/kg/node.go b/src/types/kg/node.go new file mode 100644 index 0000000..333e395 --- /dev/null +++ b/src/types/kg/node.go @@ -0,0 +1,5 @@ +package kg + +type Node struct { + ID string +}