2021-08-11 09:35:56 +00:00
|
|
|
//
|
2022-04-14 05:30:30 +00:00
|
|
|
// Copyright © 2022 Hardcore Engineering Inc.
|
2021-08-11 09:35:56 +00:00
|
|
|
//
|
|
|
|
// Licensed under the Eclipse Public License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License. You may
|
|
|
|
// obtain a copy of the License at https://www.eclipse.org/legal/epl-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
//
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
//
|
|
|
|
|
2024-02-02 15:50:22 +00:00
|
|
|
import { LoadModelResponse } from '.'
|
|
|
|
import type { Class, Doc, Domain, Ref, Timestamp } from './classes'
|
2022-04-14 05:30:30 +00:00
|
|
|
import { Hierarchy } from './hierarchy'
|
2024-02-02 15:50:22 +00:00
|
|
|
import { MeasureContext } from './measurements'
|
2022-04-14 05:30:30 +00:00
|
|
|
import { ModelDb } from './memdb'
|
2023-11-17 07:35:09 +00:00
|
|
|
import type {
|
|
|
|
DocumentQuery,
|
|
|
|
FindOptions,
|
|
|
|
FindResult,
|
|
|
|
SearchOptions,
|
2024-02-02 15:50:22 +00:00
|
|
|
SearchQuery,
|
|
|
|
SearchResult,
|
|
|
|
TxResult
|
2023-11-17 07:35:09 +00:00
|
|
|
} from './storage'
|
2021-08-11 09:35:56 +00:00
|
|
|
import type { Tx } from './tx'
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
2022-05-23 15:53:33 +00:00
|
|
|
export interface DocInfo {
|
|
|
|
id: string
|
|
|
|
hash: string
|
|
|
|
size: number // Aprox size
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
|
|
|
export interface StorageIterator {
|
|
|
|
next: () => Promise<DocInfo | undefined>
|
|
|
|
close: () => Promise<void>
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
|
|
|
export interface LowLevelStorage {
|
|
|
|
// Low level streaming API to retrieve information
|
|
|
|
find: (domain: Domain) => StorageIterator
|
2022-06-01 12:05:07 +00:00
|
|
|
|
|
|
|
// Load passed documents from domain
|
2022-05-23 15:53:33 +00:00
|
|
|
load: (domain: Domain, docs: Ref<Doc>[]) => Promise<Doc[]>
|
2022-06-01 12:05:07 +00:00
|
|
|
|
|
|
|
// Upload new versions of documents
|
|
|
|
// docs - new/updated version of documents.
|
|
|
|
upload: (domain: Domain, docs: Doc[]) => Promise<void>
|
|
|
|
|
|
|
|
// Remove a list of documents.
|
|
|
|
clean: (domain: Domain, docs: Ref<Doc>[]) => Promise<void>
|
2022-05-23 15:53:33 +00:00
|
|
|
}
|
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
|
|
|
export interface ServerStorage extends LowLevelStorage {
|
2022-04-14 05:30:30 +00:00
|
|
|
hierarchy: Hierarchy
|
|
|
|
modelDb: ModelDb
|
2021-08-11 09:35:56 +00:00
|
|
|
findAll: <T extends Doc>(
|
2021-12-22 09:02:51 +00:00
|
|
|
ctx: MeasureContext,
|
2021-08-11 09:35:56 +00:00
|
|
|
_class: Ref<Class<T>>,
|
|
|
|
query: DocumentQuery<T>,
|
2024-02-02 15:50:22 +00:00
|
|
|
options?: FindOptions<T> & {
|
|
|
|
domain?: Domain // Allow to find for Doc's in specified domain only.
|
2024-02-07 07:51:46 +00:00
|
|
|
prefix?: string
|
2024-02-02 15:50:22 +00:00
|
|
|
}
|
2021-08-11 09:35:56 +00:00
|
|
|
) => Promise<FindResult<T>>
|
2023-11-17 07:35:09 +00:00
|
|
|
searchFulltext: (ctx: MeasureContext, query: SearchQuery, options: SearchOptions) => Promise<SearchResult>
|
2021-12-22 09:02:51 +00:00
|
|
|
tx: (ctx: MeasureContext, tx: Tx) => Promise<[TxResult, Tx[]]>
|
2023-12-26 05:27:51 +00:00
|
|
|
apply: (ctx: MeasureContext, tx: Tx[], broadcast: boolean) => Promise<TxResult>
|
2022-01-12 09:06:04 +00:00
|
|
|
close: () => Promise<void>
|
2023-10-13 09:28:02 +00:00
|
|
|
loadModel: (last: Timestamp, hash?: string) => Promise<Tx[] | LoadModelResponse>
|
2021-08-11 09:35:56 +00:00
|
|
|
}
|