import type { Signer, Link } from '@ucanto/interface' import { PieceLink } from '@web3-storage/data-segment' import { DealerService, DealTrackerService, } from '@web3-storage/filecoin-client/types' import { Store, UpdatableStore, QueryableStore, ServiceConfig, } from '../types.js' export type OfferStore = Store & UpdatableStore export type AggregateStore = Store & UpdatableStore & QueryableStore, AggregateRecord> export interface ServiceContext { id: Signer /** * Stores serialized broker specific offer document containing details of the * aggregate and it's pieces. */ offerStore: OfferStore /** * Stores aggregates and their deal proofs. */ aggregateStore: AggregateStore /** * Deal tracker connection to find out available deals for an aggregate. */ dealTrackerService: ServiceConfig } export interface AggregateInsertEventContext extends Pick {} export interface AggregateUpdatedStatusEventContext { /** * Dealer connection to offer aggregates for deals. */ dealerService: ServiceConfig } export interface CronContext extends Pick {} export interface AggregateRecord { /** * Piece CID of an aggregate. */ aggregate: PieceLink /** * List of pieces in an aggregate. */ pieces: Link /** * Status of the offered aggregate piece. * - offered = acknowledged received for inclusion in filecoin deals. * - accepted = accepted and included a filecoin deal(s). * - invalid = not valid for storage. */ status: 'offered' | 'accepted' | 'invalid' /** * Insertion date ISO string. */ insertedAt: string /** * Update date ISO string. */ updatedAt: string } export interface AggregateRecordKey { /** * Piece CID of an aggregate. */ aggregate: PieceLink } export interface OfferDocument { /** * Key of the offer document */ key: string /** * Value of the offer document */ value: OfferValue } export interface OfferValue { /** * Issuer of the aggregate offer. */ issuer: `did:${string}:${string}` /** * Piece CID of an aggregate. */ aggregate: PieceLink /** * Pieces part of the aggregate */ pieces: PieceLink[] }