-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
11ebafd
commit 09df6b0
Showing
11 changed files
with
93 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
# User preference encodings | ||
|
||
### One-for-all | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// import { | ||
// PersistenceError, | ||
// VersionedObject, | ||
// VolatileStorageMetadata, | ||
// } from "@snickerdoodlelabs/objects"; | ||
import { DataObject, PersistenceError } from "crunchDB/objects"; | ||
import { ResultAsync } from "neverthrow"; | ||
|
||
export interface IVolatileCursor<T extends DataObject> { | ||
nextValue(): ResultAsync<T | null, PersistenceError>; | ||
allValues(): ResultAsync<T[] | null, PersistenceError>; | ||
|
||
_next(): ResultAsync<VolatileStorageMetadata<T> | null, PersistenceError>; | ||
_all(): ResultAsync<VolatileStorageMetadata<T>[], PersistenceError>; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import { ResultAsync } from "neverthrow"; | ||
import { ECollectionName, DataObject, PersistenceError } from "crunchDB/objects"; | ||
|
||
import { IVolatileCursor } from "@persistence/volatile/IVolatileCursor.js"; | ||
import { CollectionKeys } from "crunchDB/objects/primitive/CollectionKey"; | ||
|
||
export interface IPersistence { | ||
getObject<T extends DataObject>( | ||
recordKey: ECollectionName, | ||
key: CollectionKeys, | ||
): ResultAsync<T | null, PersistenceError>; | ||
getCursor<T extends DataObject>( | ||
recordKey: ECollectionName, | ||
indexName?: string, | ||
query?: IDBValidKey | IDBKeyRange, | ||
direction?: IDBCursorDirection | undefined, | ||
mode?: IDBTransactionMode, | ||
): ResultAsync<IVolatileCursor<T>, PersistenceError>; | ||
getAll<T extends DataObject>( | ||
recordKey: ECollectionName, | ||
indexName?: string, | ||
): ResultAsync<T[], PersistenceError>; | ||
getAllByIndex<T extends DataObject>( | ||
recordKey: ECollectionName, | ||
indexName: string, | ||
query: IDBValidKey | IDBKeyRange, | ||
): ResultAsync<T[], PersistenceError>; | ||
getAllByMultiIndex<T extends DataObject>( | ||
recordKey: ECollectionName, | ||
indices: string[], | ||
values: IDBValidKey | IDBKeyRange, | ||
): ResultAsync<T[], PersistenceError>; | ||
getAllKeys<T extends DataObject>( | ||
recordKey: ECollectionName, | ||
indexName?: string, | ||
query?: IDBValidKey | IDBKeyRange, | ||
count?: number | undefined, | ||
): ResultAsync<T[], PersistenceError>; | ||
updateRecord<T extends DataObject>( | ||
recordKey: ECollectionName, | ||
value: T, | ||
): ResultAsync<void, PersistenceError>; | ||
deleteRecord( | ||
recordKey: ECollectionName, | ||
key: CollectionKeys, | ||
): ResultAsync<void, PersistenceError>; | ||
// #endregion | ||
|
||
} | ||
|
||
export const IPersistenceType = Symbol.for("IPersistence"); | ||
|
4 changes: 1 addition & 3 deletions
4
src/objects/business/SimpleObject.ts → src/objects/business/DataObject.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,4 @@ | ||
//@TODO add properties and rename the file to VolatileObject.ts | ||
export interface SimpleObject { | ||
export interface DataObject { | ||
id: number; | ||
name: string; | ||
value: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export * from './nlp'; | ||
export * from './ranking'; | ||
export * from './vectorDB'; | ||
export * from './vectorDB'; | ||
export * from './DataObject'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export enum ECollectionName { | ||
Vector = "Vector", | ||
VectorMeta = "VectorMeta", | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
export * from "./ELanguageCode"; | ||
export * from "./ECollectionName"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { BaseError } from "./BaseError"; | ||
import errorCodes from "./errorCodes"; | ||
|
||
export class PersistenceError extends BaseError { | ||
protected errorCode: string = errorCodes[PersistenceError.name]; | ||
constructor( | ||
message: string, | ||
public src?: unknown, | ||
) { | ||
super(message, errorCodes[PersistenceError.name], src); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export type CollectionKey = string | number; | ||
export type CollectionKeys = CollectionKey[]; |