@graphql-hive/laboratory
Version:
40 lines (39 loc) • 2.18 kB
TypeScript
import { LaboratoryOperation } from './operations';
import { LaboratoryTabsActions, LaboratoryTabsState } from './tabs';
export interface LaboratoryCollectionOperation extends LaboratoryOperation {
id: string;
name: string;
description: string;
createdAt: string;
}
export interface LaboratoryCollection {
id: string;
name: string;
description?: string;
createdAt: string;
operations: LaboratoryCollectionOperation[];
}
export interface LaboratoryCollectionsActions {
addCollection: (collection: Omit<LaboratoryCollection, "id" | "createdAt" | "operations">) => void;
addOperationToCollection: (collectionId: string, operation: Omit<LaboratoryCollectionOperation, "createdAt">) => void;
deleteCollection: (collectionId: string) => void;
deleteOperationFromCollection: (collectionId: string, operationId: string) => void;
updateCollection: (collectionId: string, collection: Omit<LaboratoryCollection, "id" | "createdAt">) => void;
updateOperationInCollection: (collectionId: string, operationId: string, operation: Omit<LaboratoryCollectionOperation, "id" | "createdAt">) => void;
}
export interface LaboratoryCollectionsState {
collections: LaboratoryCollection[];
}
export interface LaboratoryCollectionsCallbacks {
onCollectionCreate?: (collection: LaboratoryCollection) => void;
onCollectionUpdate?: (collection: LaboratoryCollection) => void;
onCollectionDelete?: (collection: LaboratoryCollection) => void;
onCollectionOperationCreate?: (collection: LaboratoryCollection, operation: LaboratoryCollectionOperation) => void;
onCollectionOperationUpdate?: (collection: LaboratoryCollection, operation: LaboratoryCollectionOperation) => void;
onCollectionOperationDelete?: (collection: LaboratoryCollection, operation: LaboratoryCollectionOperation) => void;
}
export declare const useCollections: (props: {
defaultCollections?: LaboratoryCollection[];
onCollectionsChange?: (collections: LaboratoryCollection[]) => void;
tabsApi?: LaboratoryTabsState & LaboratoryTabsActions;
} & LaboratoryCollectionsCallbacks) => LaboratoryCollectionsState & LaboratoryCollectionsActions;