import { ConnectionToCore } from '@ulixee/net'; import ICoreEventPayload from '@ulixee/net/interfaces/ICoreEventPayload'; import { IPayment } from '@ulixee/platform-specification'; import { IDatastoreApis, IDatastoreApiTypes, IChannelHoldApis, IChannelHoldEvents } from '@ulixee/platform-specification/datastore'; import { IDatastoreQueryResult } from '@ulixee/platform-specification/datastore/DatastoreApis'; import IChannelHoldApiTypes from '@ulixee/platform-specification/datastore/ChannelHoldApis'; import IBalanceChange from '@ulixee/platform-specification/types/IBalanceChange'; import Identity from '@ulixee/platform-utils/lib/Identity'; import IDatastoreEvents from '../interfaces/IDatastoreEvents'; import { IDatastoreHost } from '../interfaces/IDatastoreHostLookup'; import IItemInputOutput from '../interfaces/IItemInputOutput'; import IPaymentService from '../interfaces/IPaymentService'; import { IQueryOptionsWithoutId } from '../interfaces/IQueryOptions'; import ITypes from '../types'; import DatastorePricing from './PricingManager'; import ResultIterable from './ResultIterable'; export type IDatastoreExecRelayArgs = Pick; export type IDatastoreMeta = IDatastoreApiTypes['Datastore.meta']['result']; export default class DatastoreApiClient { connectionToCore: ConnectionToCore; host: string; validateApiParameters: boolean; pricing: DatastorePricing; protected activeStreamByQueryId: Map>; private manifestByDatastoreUrl; private options; private queryLog; constructor(host: string, options?: { consoleLogErrors?: boolean; storeQueryLog?: boolean; }); disconnect(): Promise; getMetaAndSchema(id: string, version: string): Promise; registerChannelHold(datastoreId: string, balanceChange: IBalanceChange): Promise<{ accepted: boolean; }>; getMeta(id: string, version: string): Promise; install(id: string, version: string, alias?: string): Promise; /** * NOTE: any caller must handle tracking local balances of Credits and removing them if they're depleted! */ stream(id: string, version: IVersion, name: IItemName, input: ISchemaDbx['input'], options?: IQueryOptionsWithoutId & { paymentService?: IPaymentService; }): ResultIterable; /** * NOTE: any caller must handle tracking local balances of Credits and removing them if they're depleted! */ query(id: string, version: IVersion, sql: string, options?: IQueryOptionsWithoutId & { paymentService?: IPaymentService; boundValues?: any[]; }): Promise; upload(compressedDbx: Buffer, options?: { timeoutMs?: number; identity?: Identity; forwardedSignature?: { adminIdentity: string; adminSignature: Buffer; }; }): Promise<{ success: boolean; }>; download(id: string, version: string, identity: Identity, options?: { timeoutMs?: number; }): Promise; startDatastore(id: string, dbxPath: string, watch?: boolean): Promise<{ success: boolean; }>; getCreditsBalance(id: string, version: string, creditId: string): Promise; createCredits(id: string, version: string, microgons: number | bigint, adminIdentity: Identity): Promise<{ id: string; remainingCredits: bigint; secret: string; }>; administer(id: string, version: string, adminIdentity: Identity, adminFunction: { ownerType: 'datastore' | 'crawler' | 'extractor' | 'table'; ownerName: string; functionName: string; }, functionArgs: any[]): Promise; request(command: T, args: IDatastoreApiTypes[T]['args'], timeoutMs?: number): Promise; protected onEvent(evt: { event: ICoreEventPayload; }): void; protected runApi(command: T, args: IChannelHoldApiTypes[T]['args'], timeoutMs?: number): Promise; protected runApi(command: T, args: IDatastoreApiTypes[T]['args'], timeoutMs?: number): Promise; static lookupDatastoreHost(datastoreUrl: string, argonMainchainUrl: string): Promise; static createExecSignatureMessage(payment: IPayment, nonce: string): Buffer; static createExecAuthentication(payment: IPayment, authenticationIdentity: Identity, nonce?: string): IDatastoreExecRelayArgs['authentication']; static createAdminFunctionMessage(datastoreId: string, adminIdentity: string, ownerType: string, ownerName: string, functionName: string, args: any[]): Buffer; static createUploadSignatureMessage(compressedDbx: Buffer): Buffer; static createDownloadSignatureMessage(id: string, version: string, requestDate: number): Buffer; }