mirror of
https://github.com/oceanprotocol-archive/squid-js.git
synced 2024-02-02 15:31:51 +01:00
add Output interface
This commit is contained in:
parent
6e2289b27d
commit
9cf716ebe4
@ -4,7 +4,7 @@ import { noZeroX } from '../utils'
|
|||||||
import { Instantiable, InstantiableConfig } from '../Instantiable.abstract'
|
import { Instantiable, InstantiableConfig } from '../Instantiable.abstract'
|
||||||
import { DDO } from '../ddo/DDO'
|
import { DDO } from '../ddo/DDO'
|
||||||
import { ServiceType } from '../ddo/Service'
|
import { ServiceType } from '../ddo/Service'
|
||||||
import { ComputeJob } from '../ocean/OceanCompute'
|
import { ComputeJob, Output } from '../ocean/OceanCompute'
|
||||||
|
|
||||||
const apiPath = '/api/v1/brizo/services'
|
const apiPath = '/api/v1/brizo/services'
|
||||||
|
|
||||||
@ -117,7 +117,7 @@ export class Brizo extends Instantiable {
|
|||||||
algorithmDid?: string,
|
algorithmDid?: string,
|
||||||
algorithmMeta?: MetaData,
|
algorithmMeta?: MetaData,
|
||||||
jobId?: string,
|
jobId?: string,
|
||||||
output?: Record<string, any>
|
output?: Output
|
||||||
): Promise<ComputeJob | ComputeJob[]> {
|
): Promise<ComputeJob | ComputeJob[]> {
|
||||||
const signature = await this.createSignature(consumerAccount, serviceAgreementId)
|
const signature = await this.createSignature(consumerAccount, serviceAgreementId)
|
||||||
const address = consumerAccount.getId()
|
const address = consumerAccount.getId()
|
||||||
|
@ -17,6 +17,19 @@ export enum ComputeJobStatus {
|
|||||||
Deleted
|
Deleted
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface Output {
|
||||||
|
publishAlgorithmLog?: boolean
|
||||||
|
publishOutput?: boolean
|
||||||
|
brizoAddress?: string
|
||||||
|
brizoUrl?: string
|
||||||
|
metadata?: Record<string, any>
|
||||||
|
metadataUrl?: string
|
||||||
|
nodeUri?: string
|
||||||
|
owner?: string
|
||||||
|
secretStoreUrl?: string
|
||||||
|
whitelist?: Array<string>
|
||||||
|
}
|
||||||
|
|
||||||
export interface ComputeJob {
|
export interface ComputeJob {
|
||||||
owner: string
|
owner: string
|
||||||
agreementId: string
|
agreementId: string
|
||||||
@ -78,31 +91,26 @@ export class OceanCompute extends Instantiable {
|
|||||||
* return minimal output object
|
* return minimal output object
|
||||||
* @return {Promise<Object>} Returns output object
|
* @return {Promise<Object>} Returns output object
|
||||||
*/
|
*/
|
||||||
public async getminimaloutput(): Promise<Record<string, any>> {
|
public async getminimaloutput(): Promise<Output> {
|
||||||
const minimaloutput = Object()
|
const minimaloutput: Output = {
|
||||||
minimaloutput.publishAlgorithmLog = false
|
publishAlgorithmLog: false,
|
||||||
minimaloutput.publishOutput = false
|
publishOutput: false
|
||||||
return minimaloutput
|
}
|
||||||
|
return minimaloutput as Output
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check the output object and add default properties if needed
|
* Check the output object and add default properties if needed
|
||||||
* @param {Account} consumerAccount The account of the consumer ordering the service.
|
* @param {Account} consumerAccount The account of the consumer ordering the service.
|
||||||
* @param {Object} output Output section used for publishing the result.
|
* @param {Object} output Output section used for publishing the result.
|
||||||
* @return {Promise<Object>} Returns output object
|
* @return {Promise<Output>} Returns output object
|
||||||
*/
|
*/
|
||||||
public async checkoutput(
|
public async checkoutput(consumerAccount: Account, output?: Output): Promise<Output> {
|
||||||
consumerAccount: Account,
|
|
||||||
output?: Record<string, any>
|
|
||||||
): Promise<Record<string, any>> {
|
|
||||||
if (!output) {
|
if (!output) {
|
||||||
// build a minimal object and return it
|
// build a minimal object and return it
|
||||||
return this.getminimaloutput()
|
return this.getminimaloutput()
|
||||||
}
|
}
|
||||||
if (
|
if (!output.publishAlgorithmLog && !output.publishOutput) {
|
||||||
(!output.publishAlgorithmLog || output.publishAlgorithmLog === false) &&
|
|
||||||
(!output.publishOutput || output.publishOutput === false)
|
|
||||||
) {
|
|
||||||
return this.getminimaloutput()
|
return this.getminimaloutput()
|
||||||
}
|
}
|
||||||
if (!output.brizoAddress) output.brizoAddress = this.config.brizoAddress
|
if (!output.brizoAddress) output.brizoAddress = this.config.brizoAddress
|
||||||
@ -128,7 +136,7 @@ export class OceanCompute extends Instantiable {
|
|||||||
agreementId: string,
|
agreementId: string,
|
||||||
algorithmDid?: string,
|
algorithmDid?: string,
|
||||||
algorithmMeta?: MetaData,
|
algorithmMeta?: MetaData,
|
||||||
output?: Record<string, any>
|
output?: Output
|
||||||
): Promise<ComputeJob> {
|
): Promise<ComputeJob> {
|
||||||
output = await this.checkoutput(consumerAccount, output)
|
output = await this.checkoutput(consumerAccount, output)
|
||||||
const status = await this.ocean.brizo.compute(
|
const status = await this.ocean.brizo.compute(
|
||||||
|
Loading…
Reference in New Issue
Block a user