/** * Copyright 2022 Google LLC * * Licensed under the Apache 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 * * http://www.apache.org/licenses/LICENSE-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 { Clock, HandlerRegistration, Logger, OfferChange, OfferListingPolicy, OfferModel, OfferSetUpdate, Signer, OfferProducerMetadata } from 'opr-core'; import { ListOffersPayload, ListOffersResponse, Offer, DecodedReshareChain, AcceptOfferResponse, RejectOfferResponse, ReserveOfferResponse, HistoryPayload, HistoryResponse } from 'opr-models'; import { DataSourceOptions, EntityManager } from 'typeorm'; export { DataSourceOptions } from 'typeorm'; import { TimelineEntry } from './model/timelineentry'; export interface SqlOfferModelOptions { clock?: Clock; dsOptions: DataSourceOptions; listingPolicy: OfferListingPolicy; signer: Signer; hostOrgUrl: string; enableInternalChecks?: boolean; logger?: Logger; } /** * Original OfferModel implementation that provides all storage and business * logic in one place. This approach is deprecated. New code should use * PersistentOfferModel, which separates business logic from storage * capabilities. This class will be deleted in a future release. * @deprecated */ export declare class SqlOfferModel implements OfferModel { private readonly db; private initialized; private readonly clock; private readonly listingPolicy; private changeHandlers; private signer; private hostOrgUrl; private enableInternalChecks; private logger; constructor(options: SqlOfferModelOptions); initialize(): Promise; shutdown(): Promise; synchronize(dropBeforeSync: boolean): Promise; writeOfferProducerMetadata(metadata: OfferProducerMetadata): Promise; getOfferProducerMetadata(organizationUrl: string): Promise; private runInTransaction; list(orgUrl: string, payload: ListOffersPayload): Promise; handleListRequestInTransaction(entityManager: EntityManager, orgUrl: string, payload: ListOffersPayload): Promise; listOffersAtTime(entityManager: EntityManager, orgUrl: string, time: number): Promise>; /** * Returns the timeline entry for the given offer, org and time. The offer is * identified by a combination of offer id and postingOrgUrl. If there is * no timeline entry for that offer, org and time, undefined is returned. */ getOfferTimelineEntryForOrg(entityManager: EntityManager, requestingOrgUrl: string, postingOrgUrl: string, offerId: string, time: number): Promise; processUpdate(producerId: string, update: OfferSetUpdate): Promise; getAllOffers(): Promise>; private getAllSnapshots; /** * A helper method for process update that is guaranteed to be called inside * a transaction. If this method throws an error, the error will be caught * by the caller and will cause a database rollback. */ private processUpdateInTransaction; private filterBadOffers; private updateListingsWithTransaction; private deleteFutureTimelineEntriesWithTransaction; private generateLocalServerTimelineEntriesWithTransaction; private generateRemoteServerTimelineEntriesWithTransaction; private truncateLiveTimelineEntriesWithTransaction; private getCurrentRejectionsWithTransaction; private getCurrentReservationWithTransaction; private checkTimelineEntries; /** * Returns the index of the shortest, defined reshare chain that provides * RESHARE permissions. */ private findBestReshareChainIndex; /** * Returns the index of the first undefined reshare chain (which means the * local server can accept), or the shortest reshare chain that ends with an * ACCEPT permission. */ private findBestLocalAcceptChainIndex; dump(...tables: Array): Promise; dumpTable(table: string, entityManager?: EntityManager): Promise; accept(offerId: string, orgUrl: string, ifNotNewerThanTimestampUTC?: number, decodedReshareChain?: DecodedReshareChain): Promise; private acceptInTransaction; reject(rejectingOrgUrl: string, offerId: string, offeringOrgUrl?: string): Promise; rejectInTransaction(entityManager: EntityManager, rejectingOrgUrl: string, offerId: string, offeringOrgUrl?: string): Promise; reserve(offerId: string, requestedReservationSecs: number, orgUrl: string): Promise; reserveInTransaction(entityManager: EntityManager, offerId: string, requestedReservationSecs: number, orgUrl: string): Promise; getHistory(orgUrl: string, payload: HistoryPayload): Promise; private fireChange; registerChangeHandler(handlerFn: (change: OfferChange) => Promise): HandlerRegistration; } //# sourceMappingURL=sqloffermodel.d.ts.map