internal: incomplete vault systems behind feature flag (#2340)

This commit is contained in:
Mo
2023-06-30 09:01:56 -05:00
committed by GitHub
parent d16e401bb9
commit b032eb9c9b
638 changed files with 20321 additions and 4813 deletions

View File

@@ -1,5 +0,0 @@
import { SNNote, SNTag, ItemCounts } from '@standardnotes/models'
export interface ItemCounterInterface {
countNotesAndTags(items: Array<SNNote | SNTag>): ItemCounts
}

View File

@@ -1,11 +1,7 @@
import { ContentType } from '@standardnotes/common'
import {
MutationType,
ItemsKeyInterface,
ItemsKeyMutatorInterface,
DecryptedItemInterface,
DecryptedItemMutator,
DecryptedPayloadInterface,
PayloadEmitSource,
EncryptedItemInterface,
DeletedItemInterface,
@@ -13,6 +9,20 @@ import {
PredicateInterface,
DecryptedPayload,
SNTag,
ItemInterface,
AnyItemInterface,
KeySystemIdentifier,
ItemCollection,
SNNote,
SmartView,
TagItemCountChangeObserver,
SNComponent,
SNTheme,
DecryptedPayloadInterface,
DecryptedTransferPayload,
FileItem,
VaultDisplayOptions,
NotesAndFilesDisplayControllerOptions,
} from '@standardnotes/models'
import { AbstractService } from '../Service/AbstractService'
@@ -41,26 +51,20 @@ export type ItemManagerChangeObserverCallback<I extends DecryptedItemInterface =
) => void
export interface ItemManagerInterface extends AbstractService {
getCollection(): ItemCollection
addObserver<I extends DecryptedItemInterface = DecryptedItemInterface>(
contentType: ContentType | ContentType[],
callback: ItemManagerChangeObserverCallback<I>,
): () => void
setItemToBeDeleted(itemToLookupUuidFor: DecryptedItemInterface, source?: PayloadEmitSource): Promise<void>
setItemsToBeDeleted(itemsToLookupUuidsFor: DecryptedItemInterface[]): Promise<void>
setItemsDirty(
itemsToLookupUuidsFor: DecryptedItemInterface[],
isUserModified?: boolean,
): Promise<DecryptedItemInterface[]>
get items(): DecryptedItemInterface[]
insertItem(item: DecryptedItemInterface): Promise<DecryptedItemInterface>
emitItemFromPayload(payload: DecryptedPayloadInterface, source: PayloadEmitSource): Promise<DecryptedItemInterface>
getItems<T extends DecryptedItemInterface>(contentType: ContentType | ContentType[]): T[]
get invalidItems(): EncryptedItemInterface[]
allTrackedItems(): ItemInterface[]
getDisplayableItemsKeys(): ItemsKeyInterface[]
createItem<T extends DecryptedItemInterface, C extends ItemContent = ItemContent>(
contentType: ContentType,
content: C,
needsSync?: boolean,
): Promise<T>
createTemplateItem<
C extends ItemContent = ItemContent,
I extends DecryptedItemInterface<C> = DecryptedItemInterface<C>,
@@ -69,23 +73,7 @@ export interface ItemManagerInterface extends AbstractService {
content?: C,
override?: Partial<DecryptedPayload<C>>,
): I
changeItem<
M extends DecryptedItemMutator = DecryptedItemMutator,
I extends DecryptedItemInterface = DecryptedItemInterface,
>(
itemToLookupUuidFor: I,
mutate?: (mutator: M) => void,
mutationType?: MutationType,
emitSource?: PayloadEmitSource,
payloadSourceKey?: string,
): Promise<I>
changeItemsKey(
itemToLookupUuidFor: ItemsKeyInterface,
mutate: (mutator: ItemsKeyMutatorInterface) => void,
mutationType?: MutationType,
emitSource?: PayloadEmitSource,
payloadSourceKey?: string,
): Promise<ItemsKeyInterface>
itemsMatchingPredicate<T extends DecryptedItemInterface>(
contentType: ContentType,
predicate: PredicateInterface<T>,
@@ -96,12 +84,47 @@ export interface ItemManagerInterface extends AbstractService {
): T[]
subItemsMatchingPredicates<T extends DecryptedItemInterface>(items: T[], predicates: PredicateInterface<T>[]): T[]
removeAllItemsFromMemory(): Promise<void>
removeItemsLocally(items: AnyItemInterface[]): void
getDirtyItems(): (DecryptedItemInterface | DeletedItemInterface)[]
getTagLongTitle(tag: SNTag): string
getSortedTagsForItem(item: DecryptedItemInterface<ItemContent>): SNTag[]
itemsReferencingItem<I extends DecryptedItemInterface = DecryptedItemInterface>(
itemToLookupUuidFor: { uuid: string },
contentType?: ContentType,
): I[]
referencesForItem<I extends DecryptedItemInterface = DecryptedItemInterface>(
itemToLookupUuidFor: DecryptedItemInterface,
contentType?: ContentType,
): I[]
findItem<T extends DecryptedItemInterface = DecryptedItemInterface>(uuid: string): T | undefined
findItems<T extends DecryptedItemInterface>(uuids: string[]): T[]
findSureItem<T extends DecryptedItemInterface = DecryptedItemInterface>(uuid: string): T
get trashedItems(): SNNote[]
itemsBelongingToKeySystem(systemIdentifier: KeySystemIdentifier): DecryptedItemInterface[]
hasTagsNeedingFoldersMigration(): boolean
get invalidNonVaultedItems(): EncryptedItemInterface[]
isTemplateItem(item: DecryptedItemInterface): boolean
getSmartViews(): SmartView[]
addNoteCountChangeObserver(observer: TagItemCountChangeObserver): () => void
allCountableNotesCount(): number
allCountableFilesCount(): number
countableNotesForTag(tag: SNTag | SmartView): number
getNoteCount(): number
getDisplayableTags(): SNTag[]
getTagChildren(itemToLookupUuidFor: SNTag): SNTag[]
getTagParent(itemToLookupUuidFor: SNTag): SNTag | undefined
isValidTagParent(parentTagToLookUpUuidFor: SNTag, childToLookUpUuidFor: SNTag): boolean
isSmartViewTitle(title: string): boolean
getDisplayableComponents(): (SNComponent | SNTheme)[]
createItemFromPayload(payload: DecryptedPayloadInterface): DecryptedItemInterface
createPayloadFromObject(object: DecryptedTransferPayload): DecryptedPayloadInterface
getDisplayableFiles(): FileItem[]
setVaultDisplayOptions(options: VaultDisplayOptions): void
numberOfNotesWithConflicts(): number
getDisplayableNotes(): SNNote[]
getDisplayableNotesAndFiles(): (SNNote | FileItem)[]
setPrimaryItemDisplayOptions(options: NotesAndFilesDisplayControllerOptions): void
getTagPrefixTitle(tag: SNTag): string | undefined
getNoteLinkedFiles(note: SNNote): FileItem[]
conflictsOf(uuid: string): AnyItemInterface[]
}

View File

@@ -1,174 +0,0 @@
/* istanbul ignore file */
import { ContentType } from '@standardnotes/common'
import {
SNNote,
FileItem,
SNTag,
SmartView,
TagItemCountChangeObserver,
DecryptedPayloadInterface,
EncryptedItemInterface,
DecryptedTransferPayload,
PredicateInterface,
DecryptedItemInterface,
SNComponent,
SNTheme,
DisplayOptions,
ItemsKeyInterface,
ItemContent,
DecryptedPayload,
AnyItemInterface,
} from '@standardnotes/models'
export interface ItemsClientInterface {
get invalidItems(): EncryptedItemInterface[]
associateFileWithNote(file: FileItem, note: SNNote): Promise<FileItem>
disassociateFileWithNote(file: FileItem, note: SNNote): Promise<FileItem>
renameFile(file: FileItem, name: string): Promise<FileItem>
addTagToNote(note: SNNote, tag: SNTag, addHierarchy: boolean): Promise<SNTag[]>
addTagToFile(file: FileItem, tag: SNTag, addHierarchy: boolean): Promise<SNTag[]>
/** Creates an unmanaged, un-inserted item from a payload. */
createItemFromPayload(payload: DecryptedPayloadInterface): DecryptedItemInterface
createPayloadFromObject(object: DecryptedTransferPayload): DecryptedPayloadInterface
createTemplateItem<
C extends ItemContent = ItemContent,
I extends DecryptedItemInterface<C> = DecryptedItemInterface<C>,
>(
contentType: ContentType,
content?: C,
override?: Partial<DecryptedPayload<C>>,
): I
get trashedItems(): SNNote[]
setPrimaryItemDisplayOptions(options: DisplayOptions): void
getDisplayableNotes(): SNNote[]
getDisplayableTags(): SNTag[]
getDisplayableItemsKeys(): ItemsKeyInterface[]
getDisplayableFiles(): FileItem[]
getDisplayableNotesAndFiles(): (SNNote | FileItem)[]
getDisplayableComponents(): (SNComponent | SNTheme)[]
getItems<T extends DecryptedItemInterface>(contentType: ContentType | ContentType[]): T[]
insertItem(item: DecryptedItemInterface): Promise<DecryptedItemInterface>
notesMatchingSmartView(view: SmartView): SNNote[]
addNoteCountChangeObserver(observer: TagItemCountChangeObserver): () => void
allCountableNotesCount(): number
allCountableFilesCount(): number
countableNotesForTag(tag: SNTag | SmartView): number
findTagByTitle(title: string): SNTag | undefined
getTagPrefixTitle(tag: SNTag): string | undefined
getTagLongTitle(tag: SNTag): string
hasTagsNeedingFoldersMigration(): boolean
referencesForItem(itemToLookupUuidFor: DecryptedItemInterface, contentType?: ContentType): DecryptedItemInterface[]
itemsReferencingItem(itemToLookupUuidFor: DecryptedItemInterface, contentType?: ContentType): DecryptedItemInterface[]
linkNoteToNote(note: SNNote, otherNote: SNNote): Promise<SNNote>
linkFileToFile(file: FileItem, otherFile: FileItem): Promise<FileItem>
unlinkItems(
itemOne: DecryptedItemInterface<ItemContent>,
itemTwo: DecryptedItemInterface<ItemContent>,
): Promise<DecryptedItemInterface<ItemContent>>
/**
* Finds tags with title or component starting with a search query and (optionally) not associated with a note
* @param searchQuery - The query string to match
* @param note - The note whose tags should be omitted from results
* @returns Array containing tags matching search query and not associated with note
*/
searchTags(searchQuery: string, note?: SNNote): SNTag[]
isValidTagParent(parentTagToLookUpUuidFor: SNTag, childToLookUpUuidFor: SNTag): boolean
/**
* Returns the parent for a tag
*/
getTagParent(itemToLookupUuidFor: SNTag): SNTag | undefined
/**
* Returns the hierarchy of parents for a tag
* @returns Array containing all parent tags
*/
getTagParentChain(itemToLookupUuidFor: SNTag): SNTag[]
/**
* Returns all descendants for a tag
* @returns Array containing all descendant tags
*/
getTagChildren(itemToLookupUuidFor: SNTag): SNTag[]
/**
* Get tags for a note sorted in natural order
* @param item - The item whose tags will be returned
* @returns Array containing tags associated with an item
*/
getSortedTagsForItem(item: DecryptedItemInterface<ItemContent>): SNTag[]
isSmartViewTitle(title: string): boolean
getSmartViews(): SmartView[]
getNoteCount(): number
/**
* Finds an item by UUID.
*/
findItem<T extends DecryptedItemInterface = DecryptedItemInterface>(uuid: string): T | undefined
/**
* Finds an item by predicate.
*/
findItems<T extends DecryptedItemInterface>(uuids: string[]): T[]
findSureItem<T extends DecryptedItemInterface = DecryptedItemInterface>(uuid: string): T
/**
* Finds an item by predicate.
*/
itemsMatchingPredicate<T extends DecryptedItemInterface>(
contentType: ContentType,
predicate: PredicateInterface<T>,
): T[]
/**
* @param item item to be checked
* @returns Whether the item is a template (unmanaged)
*/
isTemplateItem(item: DecryptedItemInterface): boolean
createSmartView<T extends DecryptedItemInterface<ItemContent>>(
title: string,
predicate: PredicateInterface<T>,
iconString?: string,
): Promise<SmartView>
conflictsOf(uuid: string): AnyItemInterface[]
numberOfNotesWithConflicts(): number
}

View File

@@ -1,9 +1,9 @@
import { ContentType } from '@standardnotes/common'
import { SNNote, SNTag } from '@standardnotes/models'
import { ItemCounter } from './ItemCounter'
import { StaticItemCounter } from './StaticItemCounter'
describe('ItemCounter', () => {
const createCounter = () => new ItemCounter()
const createCounter = () => new StaticItemCounter()
it('should count distinct item counts', () => {
const items = [

View File

@@ -1,9 +1,7 @@
import { ContentType } from '@standardnotes/common'
import { SNNote, SNTag, ItemCounts } from '@standardnotes/models'
import { ItemCounterInterface } from './ItemCounterInterface'
export class ItemCounter implements ItemCounterInterface {
export class StaticItemCounter {
countNotesAndTags(items: Array<SNNote | SNTag>): ItemCounts {
const counts: ItemCounts = {
notes: 0,