// // Copyright © 2022 Hardcore Engineering Inc. // // 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. // import type { Account, Doc, DocIndexState, Domain, Ref } from './classes' import { MeasureContext } from './measurements' import { DocumentQuery, FindOptions } from './storage' import type { DocumentUpdate, Tx } from './tx' import type { WorkspaceIdWithUrl } from './utils' /** * @public */ export interface DocInfo { id: string hash: string size: number // Aprox size } /** * @public */ export interface StorageIterator { next: (ctx: MeasureContext) => Promise close: (ctx: MeasureContext) => Promise } export type BroadcastTargets = Record string[] | undefined> export interface SessionData { broadcast: { txes: Tx[] targets: BroadcastTargets // A set of broadcast filters if required } contextCache: Map removedMap: Map, Doc> userEmail: string sessionId: string admin?: boolean isTriggerCtx?: boolean account: Account getAccount: (account: Ref) => Account | undefined workspace: WorkspaceIdWithUrl branding: Branding | null fulltextUpdates?: Map, DocIndexState> asyncRequests?: (() => Promise)[] } /** * @public */ export interface LowLevelStorage { // Low level streaming API to retrieve information // If recheck is passed, all %hash% for documents, will be re-calculated. find: (ctx: MeasureContext, domain: Domain, recheck?: boolean) => StorageIterator // Load passed documents from domain load: (ctx: MeasureContext, domain: Domain, docs: Ref[]) => Promise // Upload new versions of documents // docs - new/updated version of documents. upload: (ctx: MeasureContext, domain: Domain, docs: Doc[]) => Promise // Remove a list of documents. clean: (ctx: MeasureContext, domain: Domain, docs: Ref[]) => Promise // Low level direct group API groupBy: ( ctx: MeasureContext, domain: Domain, field: string, query?: DocumentQuery

) => Promise> // migrations rawFindAll: (domain: Domain, query: DocumentQuery, options?: FindOptions) => Promise rawUpdate: (domain: Domain, query: DocumentQuery, operations: DocumentUpdate) => Promise rawDeleteMany: (domain: Domain, query: DocumentQuery) => Promise // Traverse documents traverse: ( domain: Domain, query: DocumentQuery, options?: Pick, 'sort' | 'limit' | 'projection'> ) => Promise> } export interface Iterator { next: (count: number) => Promise close: () => Promise } export interface Branding { key?: string front?: string title?: string language?: string initWorkspace?: string lastNameFirst?: string protocol?: string } export type BrandingMap = Record