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-05-27 07:25:57 +00:00
|
|
|
import type { Doc, Domain, Ref } from './classes'
|
2024-05-09 09:06:28 +00:00
|
|
|
import { MeasureContext, type FullParamsType, type ParamsType } from './measurements'
|
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 {
|
2024-04-08 04:41:14 +00:00
|
|
|
next: (ctx: MeasureContext) => Promise<DocInfo | undefined>
|
|
|
|
close: (ctx: MeasureContext) => Promise<void>
|
2022-05-23 15:53:33 +00:00
|
|
|
}
|
|
|
|
|
2024-07-08 17:04:05 +00:00
|
|
|
export type BroadcastTargets = Record<string, (tx: Tx) => string[] | undefined>
|
|
|
|
|
2024-05-09 09:06:28 +00:00
|
|
|
export interface SessionOperationContext {
|
|
|
|
ctx: MeasureContext
|
|
|
|
// A parts of derived data to deal with after operation will be complete
|
|
|
|
derived: {
|
2024-07-08 17:04:05 +00:00
|
|
|
txes: Tx[]
|
|
|
|
targets: BroadcastTargets // A set of broadcast filters if required
|
|
|
|
}
|
2024-05-09 09:06:28 +00:00
|
|
|
with: <T>(
|
|
|
|
name: string,
|
|
|
|
params: ParamsType,
|
|
|
|
op: (ctx: SessionOperationContext) => T | Promise<T>,
|
|
|
|
fullParams?: FullParamsType
|
|
|
|
) => Promise<T>
|
2024-08-16 06:54:23 +00:00
|
|
|
|
|
|
|
contextCache: Map<string, any>
|
|
|
|
removedMap: Map<Ref<Doc>, Doc>
|
2024-05-09 09:06:28 +00:00
|
|
|
}
|
|
|
|
|
2022-05-23 15:53:33 +00:00
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
|
|
|
export interface LowLevelStorage {
|
|
|
|
// Low level streaming API to retrieve information
|
2024-05-30 09:19:23 +00:00
|
|
|
// If recheck is passed, all %hash% for documents, will be re-calculated.
|
|
|
|
find: (ctx: MeasureContext, domain: Domain, recheck?: boolean) => StorageIterator
|
2022-06-01 12:05:07 +00:00
|
|
|
|
|
|
|
// Load passed documents from domain
|
2024-04-08 04:41:14 +00:00
|
|
|
load: (ctx: MeasureContext, 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.
|
2024-04-08 04:41:14 +00:00
|
|
|
upload: (ctx: MeasureContext, domain: Domain, docs: Doc[]) => Promise<void>
|
2022-06-01 12:05:07 +00:00
|
|
|
|
|
|
|
// Remove a list of documents.
|
2024-04-08 04:41:14 +00:00
|
|
|
clean: (ctx: MeasureContext, domain: Domain, docs: Ref<Doc>[]) => Promise<void>
|
2024-07-26 16:03:09 +00:00
|
|
|
|
|
|
|
// Low level direct group API
|
|
|
|
groupBy: <T>(ctx: MeasureContext, domain: Domain, field: string) => Promise<Set<T>>
|
2022-05-23 15:53:33 +00:00
|
|
|
}
|
2024-06-20 13:13:57 +00:00
|
|
|
|
|
|
|
export interface Branding {
|
|
|
|
key?: string
|
|
|
|
front?: string
|
|
|
|
title?: string
|
|
|
|
language?: string
|
|
|
|
initWorkspace?: string
|
|
|
|
lastNameFirst?: string
|
2024-07-02 14:07:24 +00:00
|
|
|
protocol?: string
|
2024-06-20 13:13:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export type BrandingMap = Record<string, Branding>
|