@oceanprotocol/lib 9.0.0-next.9 → 9.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +24 -2
- package/dist/lib.modern.mjs +3 -0
- package/dist/lib.module.mjs +3 -5
- package/dist/types/@types/Compute.d.ts +124 -1
- package/dist/types/@types/Datatoken.d.ts +1 -1
- package/dist/types/@types/File.d.ts +1 -1
- package/dist/types/@types/NFTFactory.d.ts +1 -1
- package/dist/types/@types/PolicyServer.d.ts +3 -1
- package/dist/types/@types/Provider.d.ts +1 -5
- package/dist/types/@types/Services.d.ts +10 -9
- package/dist/types/config/Config.d.ts +2 -2
- package/dist/types/config/ConfigHelper.d.ts +1 -1
- package/dist/types/contracts/Dispenser.d.ts +1 -1
- package/dist/types/contracts/EnterpriseFeeCollector.d.ts +3 -3
- package/dist/types/contracts/Escrow.d.ts +3 -3
- package/dist/types/contracts/NFT.d.ts +2 -2
- package/dist/types/contracts/NFTFactory.d.ts +2 -2
- package/dist/types/services/Provider.d.ts +1 -1
- package/dist/types/services/providers/BaseProvider.d.ts +127 -14
- package/dist/types/services/providers/HttpProvider.d.ts +46 -29
- package/dist/types/services/providers/P2pProvider.d.ts +478 -19
- package/dist/types/services/providers/lpFraming.d.ts +173 -0
- package/dist/types/utils/C2dCapability.d.ts +78 -0
- package/dist/types/utils/General.d.ts +15 -0
- package/dist/types/utils/index.d.ts +1 -0
- package/package.json +57 -60
- package/dist/lib.cjs +0 -5
- package/dist/lib.umd.js +0 -5
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { MetadataAlgorithm, ConsumerParameter } from '@oceanprotocol/ddo-js';
|
|
2
|
-
import { StorageObject, EncryptMethod } from './File';
|
|
2
|
+
import { StorageObject, EncryptMethod } from './File.js';
|
|
3
|
+
import { NodeP2P } from './Provider.js';
|
|
3
4
|
export type ComputeResultType = 'algorithmLog' | 'output' | 'configrationLog' | 'publishLog';
|
|
4
5
|
export interface RunningPlatform {
|
|
5
6
|
architecture: string;
|
|
@@ -81,6 +82,62 @@ export interface ComputeResult {
|
|
|
81
82
|
export type ComputeJobMetadata = {
|
|
82
83
|
[key: string]: string | number | boolean;
|
|
83
84
|
};
|
|
85
|
+
export type GpuVendor = 'nvidia' | 'amd' | 'intel';
|
|
86
|
+
export interface GpuMetricsSnapshot {
|
|
87
|
+
resourceId: string;
|
|
88
|
+
vendor: GpuVendor;
|
|
89
|
+
utilizationPercent: number | null;
|
|
90
|
+
memoryUsedBytes: number | null;
|
|
91
|
+
memoryTotalBytes: number | null;
|
|
92
|
+
temperatureC?: number;
|
|
93
|
+
powerWatts?: number;
|
|
94
|
+
shared?: boolean;
|
|
95
|
+
}
|
|
96
|
+
export interface ContainerMetricsSnapshot {
|
|
97
|
+
collectedAt: string;
|
|
98
|
+
containerState: {
|
|
99
|
+
status: string;
|
|
100
|
+
startedAt?: string;
|
|
101
|
+
finishedAt?: string;
|
|
102
|
+
exitCode?: number;
|
|
103
|
+
oomKilled: boolean;
|
|
104
|
+
error?: string;
|
|
105
|
+
restartCount: number;
|
|
106
|
+
health?: string;
|
|
107
|
+
};
|
|
108
|
+
cpu: {
|
|
109
|
+
usagePercent: number;
|
|
110
|
+
allocated: number;
|
|
111
|
+
usagePercentOfAllocated: number;
|
|
112
|
+
cumulativeSeconds: number;
|
|
113
|
+
throttledPeriods: number;
|
|
114
|
+
throttledSeconds: number;
|
|
115
|
+
};
|
|
116
|
+
memory: {
|
|
117
|
+
usageBytes: number;
|
|
118
|
+
limitBytes: number;
|
|
119
|
+
usagePercent: number;
|
|
120
|
+
peakUsageBytes: number;
|
|
121
|
+
};
|
|
122
|
+
disk: {
|
|
123
|
+
usedBytes: number;
|
|
124
|
+
quotaBytes?: number;
|
|
125
|
+
usagePercent?: number;
|
|
126
|
+
};
|
|
127
|
+
network?: {
|
|
128
|
+
rxBytes: number;
|
|
129
|
+
txBytes: number;
|
|
130
|
+
};
|
|
131
|
+
blockIO: {
|
|
132
|
+
readBytes: number;
|
|
133
|
+
writeBytes: number;
|
|
134
|
+
};
|
|
135
|
+
pids: {
|
|
136
|
+
current: number;
|
|
137
|
+
limit: number;
|
|
138
|
+
};
|
|
139
|
+
gpu?: GpuMetricsSnapshot[];
|
|
140
|
+
}
|
|
84
141
|
export interface ComputeJob {
|
|
85
142
|
owner: string;
|
|
86
143
|
did?: string;
|
|
@@ -120,6 +177,7 @@ export interface NodeComputeJob extends ComputeJob {
|
|
|
120
177
|
queueMaxWaitTime?: number;
|
|
121
178
|
jobIdHash?: string;
|
|
122
179
|
maxJobDuration?: number;
|
|
180
|
+
runtimeMetrics?: ContainerMetricsSnapshot;
|
|
123
181
|
}
|
|
124
182
|
export interface ComputeOutputEncryption {
|
|
125
183
|
encryptMethod: EncryptMethod.AES;
|
|
@@ -182,3 +240,68 @@ export interface dockerRegistryAuth {
|
|
|
182
240
|
auth?: string;
|
|
183
241
|
}
|
|
184
242
|
export type ComputeResultStream = AsyncIterable<Uint8Array>;
|
|
243
|
+
/**
|
|
244
|
+
* One resource dimension of a compute-provider search, e.g. `{ resource: 'cpu', value: 4 }`.
|
|
245
|
+
* `resource` is deliberately an open string here too, matching the underlying capability
|
|
246
|
+
* format — a caller can ask for a resource type this package has no built-in knowledge of
|
|
247
|
+
* (`'fpga'`, `'pcie'`, anything a compute engine reports) and still get a well-typed request.
|
|
248
|
+
*/
|
|
249
|
+
export interface ComputeSearchDimension {
|
|
250
|
+
resource: string;
|
|
251
|
+
value: number;
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* A typed request to `BaseProvider.findComputeProviders`. Built entirely from ordinary typed
|
|
255
|
+
* values — never a hand-built JSON string, never a content id.
|
|
256
|
+
*/
|
|
257
|
+
export interface FindComputeProvidersRequest {
|
|
258
|
+
free: boolean;
|
|
259
|
+
/** One entry per resource dimension. The result is the intersection of all of them. */
|
|
260
|
+
resources: ComputeSearchDimension[];
|
|
261
|
+
/**
|
|
262
|
+
* Optional per-resource qualifier (e.g. `{ gpu: 'A100' }`) applied only at the verification
|
|
263
|
+
* step, against a candidate's real compute environments. Never hashed and never part of a
|
|
264
|
+
* lookup string — nothing that discriminates within a resource is.
|
|
265
|
+
*/
|
|
266
|
+
models?: Record<string, string>;
|
|
267
|
+
signal?: AbortSignal;
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* A compute provider that announced a matching bucket for every requested dimension *and*
|
|
271
|
+
* whose real compute environments (fetched during verification) actually satisfy the request.
|
|
272
|
+
* `node` is directly usable as the `node` argument to other typed calls on this SDK's provider
|
|
273
|
+
* client (e.g. `getComputeEnvironments`, `initializeCompute`).
|
|
274
|
+
*/
|
|
275
|
+
export interface ComputeProviderMatch {
|
|
276
|
+
node: NodeP2P;
|
|
277
|
+
environments: ComputeEnvironment[];
|
|
278
|
+
}
|
|
279
|
+
/**
|
|
280
|
+
* The outcome of one requested dimension's provider lookup, before verification and before it
|
|
281
|
+
* is intersected with any other requested dimension. Carried on the result specifically so an
|
|
282
|
+
* empty search is never a mystery — a caller can see exactly which dimension(s) had nothing,
|
|
283
|
+
* instead of a single opaque empty list.
|
|
284
|
+
*/
|
|
285
|
+
export interface ComputeSearchDimensionResult {
|
|
286
|
+
resource: string;
|
|
287
|
+
/** The value as requested, before bucketing. */
|
|
288
|
+
value: number;
|
|
289
|
+
/** The bucket this dimension's lookup actually used. */
|
|
290
|
+
bucket: number;
|
|
291
|
+
/** Provider ids that announced this bucket, before verification or intersection with other dimensions. */
|
|
292
|
+
providerIds: string[];
|
|
293
|
+
/** Set when this dimension's lookup ended early. `providerIds` is still real, just possibly incomplete. */
|
|
294
|
+
partial?: true;
|
|
295
|
+
/** Present alongside `partial`, describing why the lookup ended early. */
|
|
296
|
+
error?: string;
|
|
297
|
+
}
|
|
298
|
+
/**
|
|
299
|
+
* Result of `BaseProvider.findComputeProviders`. Always a typed value, even when nothing
|
|
300
|
+
* matched — "nothing found" is a normal outcome here, never a thrown error.
|
|
301
|
+
*/
|
|
302
|
+
export interface FindComputeProvidersResult {
|
|
303
|
+
/** Providers that satisfy every requested dimension, verified against their real environments. */
|
|
304
|
+
providers: ComputeProviderMatch[];
|
|
305
|
+
/** One entry per requested dimension, in request order. */
|
|
306
|
+
dimensions: ComputeSearchDimensionResult[];
|
|
307
|
+
}
|
|
@@ -4,6 +4,8 @@ export interface PolicyServerPassthroughCommand {
|
|
|
4
4
|
export interface PolicyServerInitializeCommand {
|
|
5
5
|
documentId?: string;
|
|
6
6
|
serviceId?: string;
|
|
7
|
-
consumerAddress?: string;
|
|
8
7
|
policyServer?: any;
|
|
8
|
+
consumerAddress?: string;
|
|
9
|
+
nonce?: string;
|
|
10
|
+
signature?: string;
|
|
9
11
|
}
|
|
@@ -36,11 +36,6 @@ export interface ProviderComputeInitializeResults {
|
|
|
36
36
|
datasets?: ProviderComputeInitialize[];
|
|
37
37
|
payment?: ProviderComputeInitializePayment;
|
|
38
38
|
}
|
|
39
|
-
export interface ServiceEndpoint {
|
|
40
|
-
serviceName: string;
|
|
41
|
-
method: string;
|
|
42
|
-
urlPath: string;
|
|
43
|
-
}
|
|
44
39
|
export interface NodeP2P {
|
|
45
40
|
nodeId: string;
|
|
46
41
|
multiaddress?: Multiaddr[];
|
|
@@ -119,6 +114,7 @@ export declare const PROTOCOL_COMMANDS: {
|
|
|
119
114
|
HANDLE_INDEXING_THREAD: string;
|
|
120
115
|
COLLECT_FEES: string;
|
|
121
116
|
POLICY_SERVER_PASSTHROUGH: string;
|
|
117
|
+
POLICY_SERVER_INITIALIZE: string;
|
|
122
118
|
GET_P2P_PEER: string;
|
|
123
119
|
GET_P2P_PEERS: string;
|
|
124
120
|
GET_P2P_NETWORK_STATS: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ComputeResourceRequest } from './Compute.js';
|
|
1
|
+
import { ComputeResourceRequest, ContainerMetricsSnapshot } from './Compute.js';
|
|
2
2
|
export interface TemplateResourceRequirement {
|
|
3
3
|
id?: string;
|
|
4
4
|
kind?: 'discrete' | 'fungible';
|
|
@@ -43,16 +43,16 @@ export interface ServiceJobEndpoint {
|
|
|
43
43
|
url: string;
|
|
44
44
|
}
|
|
45
45
|
export declare enum ServiceStatusNumber {
|
|
46
|
-
Starting = 10
|
|
47
|
-
PullImage = 11
|
|
46
|
+
Starting = 10,// DB record created by the start handler; awaits background processing
|
|
47
|
+
PullImage = 11,// pulling pre-built image from registry
|
|
48
48
|
PullImageFailed = 12,
|
|
49
|
-
BuildImage = 13
|
|
49
|
+
BuildImage = 13,// building from Dockerfile
|
|
50
50
|
BuildImageFailed = 14,
|
|
51
|
-
VulnerableImage = 15
|
|
52
|
-
Locking = 20,
|
|
53
|
-
Claiming = 30,
|
|
51
|
+
VulnerableImage = 15,// image scan found critical vulnerabilities
|
|
52
|
+
Locking = 20,// escrow createLock in progress (funds locked, not yet claimed)
|
|
53
|
+
Claiming = 30,// payment phase: claimLock on success, or cancelLock if the image step failed
|
|
54
54
|
Running = 40,
|
|
55
|
-
Restarting = 45
|
|
55
|
+
Restarting = 45,// SERVICE_RESTART accepted; teardown + re-pull/build + new container in progress
|
|
56
56
|
Stopping = 50,
|
|
57
57
|
Stopped = 70,
|
|
58
58
|
Expired = 75,
|
|
@@ -92,8 +92,9 @@ export interface ServiceJob {
|
|
|
92
92
|
resources: any[];
|
|
93
93
|
payment: ServiceJobPayment;
|
|
94
94
|
extendPayments?: ServiceJobPayment[];
|
|
95
|
+
runtimeMetrics?: ContainerMetricsSnapshot;
|
|
95
96
|
}
|
|
96
|
-
export type ServiceJobListed = Omit<ServiceJob, 'dockerCmd' | 'dockerEntrypoint' | 'dockerfile' | 'additionalDockerFiles'>;
|
|
97
|
+
export type ServiceJobListed = Omit<ServiceJob, 'dockerCmd' | 'dockerEntrypoint' | 'dockerfile' | 'additionalDockerFiles' | 'runtimeMetrics'>;
|
|
97
98
|
export interface ServiceListFilters {
|
|
98
99
|
status?: ServiceStatusNumber;
|
|
99
100
|
includeAllStatuses?: boolean;
|
|
@@ -76,5 +76,5 @@ export declare class Dispenser extends SmartContractWithAddress {
|
|
|
76
76
|
* @param {String} amount amount of datatokens required.
|
|
77
77
|
* @return {Promise<Boolean>}
|
|
78
78
|
*/
|
|
79
|
-
isDispensable(dtAddress: string, datatoken: Datatoken, address: string, amount?: string): Promise<
|
|
79
|
+
isDispensable(dtAddress: string, datatoken: Datatoken, address: string, amount?: string): Promise<boolean>;
|
|
80
80
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Signer } from 'ethers';
|
|
2
|
-
import { AbiItem } from '../@types';
|
|
3
|
-
import { Config } from '../config';
|
|
4
|
-
import { SmartContractWithAddress } from './SmartContractWithAddress';
|
|
2
|
+
import { AbiItem } from '../@types/index.js';
|
|
3
|
+
import { Config } from '../config/index.js';
|
|
4
|
+
import { SmartContractWithAddress } from './SmartContractWithAddress.js';
|
|
5
5
|
export declare class EnterpriseFeeCollectorContract extends SmartContractWithAddress {
|
|
6
6
|
getDefaultAbi(): AbiItem[];
|
|
7
7
|
/**
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Signer, TransactionRequest } from 'ethers';
|
|
2
|
-
import { AbiItem, ReceiptOrEstimate, ValidationResponse, DepositData, PermitData, AuthData, LockData } from '../@types';
|
|
3
|
-
import { Config } from '../config';
|
|
4
|
-
import { SmartContractWithAddress } from './SmartContractWithAddress';
|
|
2
|
+
import { AbiItem, ReceiptOrEstimate, ValidationResponse, DepositData, PermitData, AuthData, LockData } from '../@types/index.js';
|
|
3
|
+
import { Config } from '../config/index.js';
|
|
4
|
+
import { SmartContractWithAddress } from './SmartContractWithAddress.js';
|
|
5
5
|
export declare class EscrowContract extends SmartContractWithAddress {
|
|
6
6
|
abiEnterprise: AbiItem[];
|
|
7
7
|
getDefaultAbi(): AbiItem[];
|
|
@@ -20,7 +20,7 @@ export declare class Nft extends SmartContract {
|
|
|
20
20
|
* @param {Boolean} estimateGas if True, return gas estimate
|
|
21
21
|
* @return {Promise<string>} ERC20 Datatoken address
|
|
22
22
|
*/
|
|
23
|
-
createDatatoken<G extends boolean = false>(nftAddress: string, address: string, minter: string, paymentCollector: string, mpFeeAddress: string, feeToken: string, feeAmount: string, cap: string, name?: string, symbol?: string, templateIndex?: number, filesObject?: string, accessListContract?: string, allowAccessList?: string, denyAccessList?: string, estimateGas?: G): Promise<G extends false ? string :
|
|
23
|
+
createDatatoken<G extends boolean = false>(nftAddress: string, address: string, minter: string, paymentCollector: string, mpFeeAddress: string, feeToken: string, feeAmount: string, cap: string, name?: string, symbol?: string, templateIndex?: number, filesObject?: string, accessListContract?: string, allowAccessList?: string, denyAccessList?: string, estimateGas?: G): Promise<G extends false ? string : bigint>;
|
|
24
24
|
createDatatokenTx(nftAddress: string, address: string, minter: string, paymentCollector: string, mpFeeAddress: string, feeToken: string, feeAmount: string, cap: string, name?: string, symbol?: string, templateIndex?: number, filesObject?: string, accessListContract?: string, allowAccessList?: string, denyAccessList?: string): Promise<TransactionRequest>;
|
|
25
25
|
/**
|
|
26
26
|
* Add Manager for NFT Contract (only NFT Owner can succeed)
|
|
@@ -201,7 +201,7 @@ export declare class Nft extends SmartContract {
|
|
|
201
201
|
* @param {String} nftAddress NFT contract address
|
|
202
202
|
* @return {Promise<Objecta>}
|
|
203
203
|
*/
|
|
204
|
-
getMetadata(nftAddress: string): Promise<
|
|
204
|
+
getMetadata(nftAddress: string): Promise<object>;
|
|
205
205
|
/**
|
|
206
206
|
* Checks if user has DatatokenDeployer role
|
|
207
207
|
* @param {String} nftAddress NFT contract address
|
|
@@ -56,13 +56,13 @@ export declare class NftFactory extends SmartContractWithAddress {
|
|
|
56
56
|
* @param {String} datatoken Datatoken address to check
|
|
57
57
|
* @return {Promise<Boolean>} return true if deployed from this factory
|
|
58
58
|
*/
|
|
59
|
-
checkDatatoken(datatoken: string): Promise<
|
|
59
|
+
checkDatatoken(datatoken: string): Promise<boolean>;
|
|
60
60
|
/**
|
|
61
61
|
* Check if NFT is deployed from the factory
|
|
62
62
|
* @param {String} nftAddress nftAddress address to check
|
|
63
63
|
* @return {Promise<String>} return address(0) if it's not, or the nftAddress if true
|
|
64
64
|
*/
|
|
65
|
-
checkNFT(nftAddress: string): Promise<
|
|
65
|
+
checkNFT(nftAddress: string): Promise<string>;
|
|
66
66
|
/**
|
|
67
67
|
* Add a new NFT token template - only factory Owner
|
|
68
68
|
* @param {String} address caller address
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { BaseProvider } from './providers/BaseProvider.js';
|
|
2
|
-
export { BaseProvider as Provider, isP2pUri, OCEAN_P2P_PROTOCOL, type P2PConfig } from './providers/BaseProvider.js';
|
|
2
|
+
export { BaseProvider as Provider, isP2pUri, OCEAN_P2P_PROTOCOL, type P2PConfig, type P2pProviderRecord, type Multiaddr, P2pError, type P2pErrorType, classifyP2pError, isRetryableP2pError } from './providers/BaseProvider.js';
|
|
3
3
|
export declare const ProviderInstance: BaseProvider;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Signer } from 'ethers';
|
|
2
|
-
import { StorageObject, FileInfo, ComputeJob, ComputeOutput, ComputeAlgorithm, ComputeAsset, ComputeEnvironment, ComputeResultStream, ProviderInitialize, ProviderComputeInitializeResults,
|
|
2
|
+
import { StorageObject, FileInfo, ComputeJob, ComputeOutput, ComputeAlgorithm, ComputeAsset, ComputeEnvironment, ComputeResultStream, FindComputeProvidersRequest, FindComputeProvidersResult, ProviderInitialize, ProviderComputeInitializeResults, UserCustomParameters, ComputeResourceRequest, ComputeJobMetadata, PolicyServerInitializeCommand, PolicyServerPassthroughCommand, dockerRegistryAuth, DownloadResponse, NodeStatus, NodeComputeJob, NodeLogEntry, PersistentStorageAccessList, PersistentStorageBucket, PersistentStorageCreateBucketRequest, PersistentStorageDeleteFileResponse, PersistentStorageFileEntry, PersistentStorageObject, PersistentStorageUpdateBucketResponse, ServiceJob, ServiceJobListed, ServiceListFilters, ServiceRestartParams, ServiceTemplatePublic, ServiceStartParams, ServicePayment, OceanNode, CompleteSignature, SignerOrAuthTokenOrSignature } from '../../@types/index.js';
|
|
3
3
|
import { type DDO, type ValidateMetadata } from '@oceanprotocol/ddo-js';
|
|
4
|
-
import { P2pProvider, type P2PConfig, type P2PRequestBodyStream } from './P2pProvider.js';
|
|
5
|
-
export { OCEAN_P2P_PROTOCOL, type P2PConfig } from './P2pProvider.js';
|
|
4
|
+
import { type P2pProvider, type P2PConfig, type P2PRequestBodyStream } from './P2pProvider.js';
|
|
5
|
+
export { OCEAN_P2P_PROTOCOL, type P2PConfig, type P2pProviderRecord, type Multiaddr, P2pError, type P2pErrorType, classifyP2pError, isRetryableP2pError } from './P2pProvider.js';
|
|
6
6
|
export declare function getConsumerAddress(signerOrAuthToken: SignerOrAuthTokenOrSignature): Promise<string>;
|
|
7
7
|
export declare function getSignature(signerOrAuthToken: SignerOrAuthTokenOrSignature, nonce: string, command: string, issuerPeerId?: string): Promise<string | null>;
|
|
8
8
|
export declare function getAuthorization(signerOrAuthToken: SignerOrAuthTokenOrSignature): string | undefined;
|
|
@@ -13,14 +13,47 @@ export declare class BaseProvider {
|
|
|
13
13
|
private p2pProvider;
|
|
14
14
|
protected getImpl(node: OceanNode): any;
|
|
15
15
|
getP2PProvider(): P2pProvider;
|
|
16
|
-
getNonce(nodeUri: OceanNode, consumerAddress: string, signal?: AbortSignal
|
|
16
|
+
getNonce(nodeUri: OceanNode, consumerAddress: string, signal?: AbortSignal): Promise<number>;
|
|
17
17
|
encrypt(data: any, chainId: number, nodeUri: OceanNode, signerOrAuthToken: SignerOrAuthTokenOrSignature, policyServer?: any, signal?: AbortSignal): Promise<string>;
|
|
18
18
|
checkDidFiles(did: string, serviceId: string, nodeUri: OceanNode, withChecksum?: boolean, signal?: AbortSignal): Promise<FileInfo[]>;
|
|
19
19
|
getFileInfo(file: StorageObject, nodeUri: OceanNode, withChecksum?: boolean, signal?: AbortSignal): Promise<FileInfo[]>;
|
|
20
20
|
getComputeEnvironments(nodeUri: OceanNode, signal?: AbortSignal): Promise<ComputeEnvironment[]>;
|
|
21
|
+
/**
|
|
22
|
+
* Searches for compute providers that can satisfy a typed resource request — a caller never
|
|
23
|
+
* builds a lookup string, computes a bucket, or sees a content id; it passes ordinary typed
|
|
24
|
+
* values in and gets typed providers back.
|
|
25
|
+
*
|
|
26
|
+
* `node` selects the transport the same way every other method on this class does. Provider
|
|
27
|
+
* discovery here is a DHT lookup, so it must identify the P2P network — a peer id, a
|
|
28
|
+
* multiaddr, or a {@link NodeP2P} — rather than a plain HTTP provider URL; there is no HTTP
|
|
29
|
+
* equivalent for it (yet).
|
|
30
|
+
*
|
|
31
|
+
* A multi-dimension request (e.g. `cpu` *and* `ram`) is handled as an intersection of one
|
|
32
|
+
* lookup per dimension, never as a single wider lookup string. Because bucketing rounds down
|
|
33
|
+
* on both the announcing and the querying side, a bucket match is a prefilter, not proof of
|
|
34
|
+
* anything: a request for `cpu: 9` buckets to `8` and matches a provider whose real maximum
|
|
35
|
+
* is exactly `8`. Every candidate surviving the intersection is therefore verified here
|
|
36
|
+
* against its real compute environments before it is returned; `models` — a per-resource
|
|
37
|
+
* qualifier such as a GPU name — is applied only at that step, never as part of a lookup
|
|
38
|
+
* string, because nothing that discriminates within a resource is ever hashed.
|
|
39
|
+
*
|
|
40
|
+
* Never throws for "nothing found". A fleet that has not heard of a requested resource (or,
|
|
41
|
+
* dimension by dimension, any resource) simply yields no providers for it, and `dimensions`
|
|
42
|
+
* says exactly which requested resource that was — a caller is never left staring at a
|
|
43
|
+
* silently empty result with no way to tell which part of the request came up short.
|
|
44
|
+
*/
|
|
45
|
+
findComputeProviders(node: OceanNode, request: FindComputeProvidersRequest): Promise<FindComputeProvidersResult>;
|
|
21
46
|
initialize(did: string, serviceId: string, fileIndex: number, consumerAddress: string, nodeUri: OceanNode, signal?: AbortSignal, userCustomParameters?: UserCustomParameters, computeEnv?: string, validUntil?: number): Promise<ProviderInitialize>;
|
|
22
47
|
initializeCompute(assets: ComputeAsset[], algorithm: ComputeAlgorithm, computeEnv: string, token: string, validUntil: number, nodeUri: OceanNode, consumerAddress: string, resources: ComputeResourceRequest[], chainId: number, policyServer?: any, signal?: AbortSignal, queueMaxWaitTime?: number, dockerRegistryAuthData?: dockerRegistryAuth, output?: ComputeOutput): Promise<ProviderComputeInitializeResults>;
|
|
23
|
-
|
|
48
|
+
/**
|
|
49
|
+
* @param signal Cancels the operation. On the P2P transport it covers the whole
|
|
50
|
+
* transfer — the nonce round-trip, the dial and every frame of the body — so a
|
|
51
|
+
* download already running stops when it fires. The HTTP transport returns a URL for
|
|
52
|
+
* the caller to fetch and so performs no transfer here, but building that URL from a
|
|
53
|
+
* `Signer` does fetch a nonce from the node, and the signal covers that request.
|
|
54
|
+
* Optional; omitting it keeps the previous behaviour.
|
|
55
|
+
*/
|
|
56
|
+
getDownloadUrl(did: string, serviceId: string, fileIndex: number, transferTxId: string, nodeUri: OceanNode, signerOrAuthToken: SignerOrAuthTokenOrSignature, policyServer?: any, userCustomParameters?: UserCustomParameters, signal?: AbortSignal): Promise<string | DownloadResponse>;
|
|
24
57
|
computeStart(nodeUri: OceanNode, signerOrAuthToken: SignerOrAuthTokenOrSignature, computeEnv: string, datasets: ComputeAsset[], algorithm: ComputeAlgorithm, maxJobDuration: number, token: string, resources: ComputeResourceRequest[], chainId: number, metadata?: ComputeJobMetadata, additionalViewers?: string[], output?: ComputeOutput, policyServer?: any, signal?: AbortSignal, queueMaxWaitTime?: number, dockerRegistryAuth?: dockerRegistryAuth, outputBucketId?: string): Promise<ComputeJob | ComputeJob[]>;
|
|
25
58
|
freeComputeStart(nodeUri: OceanNode, signerOrAuthToken: SignerOrAuthTokenOrSignature, computeEnv: string, datasets: ComputeAsset[], algorithm: ComputeAlgorithm, resources?: ComputeResourceRequest[], metadata?: ComputeJobMetadata, additionalViewers?: string[], output?: ComputeOutput, policyServer?: any, signal?: AbortSignal, queueMaxWaitTime?: number, dockerRegistryAuth?: dockerRegistryAuth, outputBucketId?: string): Promise<ComputeJob | ComputeJob[]>;
|
|
26
59
|
/**
|
|
@@ -44,9 +77,42 @@ export declare class BaseProvider {
|
|
|
44
77
|
private notifyIncentiveBackendServiceRestarted;
|
|
45
78
|
computeStreamableLogs(nodeUri: OceanNode, signerOrAuthToken: SignerOrAuthTokenOrSignature, jobId: string, signal?: AbortSignal): Promise<any>;
|
|
46
79
|
computeStop(jobId: string, nodeUri: OceanNode, signerOrAuthToken: SignerOrAuthTokenOrSignature, agreementId?: string, signal?: AbortSignal): Promise<ComputeJob | ComputeJob[]>;
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
80
|
+
/**
|
|
81
|
+
* Get compute status for a specific jobId/documentId/owner.
|
|
82
|
+
* @param {boolean} includeMetrics Owner-only runtime metrics (`runtimeMetrics`) on the
|
|
83
|
+
* returned job(s). To receive them, the node needs owner credentials: an auth token
|
|
84
|
+
* (`signerOrAuthToken` as a string) is ALWAYS sent, regardless of this flag; a `Signer`'s
|
|
85
|
+
* nonce+signature is only computed and sent when this flag is `true` (skipped otherwise
|
|
86
|
+
* to avoid an extra nonce round-trip on every plain status poll). Omitted (default): the
|
|
87
|
+
* node attaches metrics silently if valid owner credentials made it into the request
|
|
88
|
+
* (true automatically for token callers, false for `Signer` callers unless this flag is
|
|
89
|
+
* set), and returns exactly today's response otherwise. `true`: metrics are required —
|
|
90
|
+
* this method also computes the `Signer`'s signature, and the node answers 400/401 if
|
|
91
|
+
* credentials don't verify. `false`: metrics are never attached.
|
|
92
|
+
*/
|
|
93
|
+
computeStatus(nodeUri: OceanNode, signerOrAuthToken: SignerOrAuthTokenOrSignature, jobId?: string, agreementId?: string, signal?: AbortSignal, includeMetrics?: boolean): Promise<NodeComputeJob | NodeComputeJob[]>;
|
|
94
|
+
/**
|
|
95
|
+
* A fetchable URL for a compute result.
|
|
96
|
+
*
|
|
97
|
+
* HTTP-transport only. A P2P peer answers with the result bytes themselves and the
|
|
98
|
+
* protocol carries no location for them, so this rejects for a P2P target — use
|
|
99
|
+
* {@link getComputeResult} there, which returns the bytes as an async iterable.
|
|
100
|
+
*
|
|
101
|
+
* @param signal Cancels the nonce round-trip the URL is built from. Only reaches the
|
|
102
|
+
* network when `signerOrAuthToken` is a `Signer`; a token or a pre-made signature
|
|
103
|
+
* needs no nonce and this becomes pure string assembly. Optional; omitting it keeps
|
|
104
|
+
* the previous behaviour.
|
|
105
|
+
*/
|
|
106
|
+
getComputeResultUrl(nodeUri: OceanNode, signerOrAuthToken: SignerOrAuthTokenOrSignature, jobId: string, index: number, signal?: AbortSignal): Promise<string>;
|
|
107
|
+
/**
|
|
108
|
+
* @param signal Cancels the operation. On the P2P transport it covers the whole
|
|
109
|
+
* transfer — the nonce round-trip, the dial and every frame the returned generator
|
|
110
|
+
* reads — so a result already being transferred stops when it fires. The HTTP
|
|
111
|
+
* transport covers the same ground: the nonce round-trip, the request and the
|
|
112
|
+
* response body. On both, aborting mid-transfer makes the iterable throw rather than
|
|
113
|
+
* end quietly. Optional; omitting it keeps the previous behaviour.
|
|
114
|
+
*/
|
|
115
|
+
getComputeResult(nodeUri: OceanNode, signerOrAuthToken: SignerOrAuthTokenOrSignature, jobId: string, index: number, offset?: number, signal?: AbortSignal): Promise<ComputeResultStream>;
|
|
50
116
|
generateAuthToken(consumer: Signer, nodeUri: OceanNode, signal?: AbortSignal): Promise<string>;
|
|
51
117
|
generateSignedAuthToken(address: string, signature: string, nonce: string, nodeUri: OceanNode, validUntil?: number, signal?: AbortSignal): Promise<string>;
|
|
52
118
|
invalidateAuthToken(consumer: Signer, token: string, nodeUri: OceanNode, signal?: AbortSignal): Promise<{
|
|
@@ -56,17 +122,57 @@ export declare class BaseProvider {
|
|
|
56
122
|
validateDdo(nodeUri: OceanNode, ddo: DDO, signerOrAuthToken: SignerOrAuthTokenOrSignature, signal?: AbortSignal): Promise<ValidateMetadata>;
|
|
57
123
|
isValidProvider(url: OceanNode, signal?: AbortSignal): Promise<boolean>;
|
|
58
124
|
PolicyServerPassthrough(nodeUri: OceanNode, request: PolicyServerPassthroughCommand, signal?: AbortSignal): Promise<any>;
|
|
59
|
-
initializePSVerification(nodeUri: OceanNode, request: PolicyServerInitializeCommand, signal?: AbortSignal): Promise<any>;
|
|
125
|
+
initializePSVerification(nodeUri: OceanNode, signerOrAuthToken: SignerOrAuthTokenOrSignature, request: PolicyServerInitializeCommand, signal?: AbortSignal): Promise<any>;
|
|
60
126
|
downloadNodeLogs(nodeUri: OceanNode, signerOrAuthToken: SignerOrAuthTokenOrSignature, startTime: string, endTime: string, maxLogs?: number, moduleName?: string, level?: string, page?: number, signal?: AbortSignal): Promise<NodeLogEntry[]>;
|
|
61
127
|
getNodeStatus(nodeUri: OceanNode, signal?: AbortSignal): Promise<NodeStatus>;
|
|
62
128
|
getNodeJobs(nodeUri: OceanNode, fromTimestamp?: number, signal?: AbortSignal): Promise<NodeComputeJob[]>;
|
|
63
129
|
setupP2P(config: P2PConfig): Promise<void>;
|
|
64
130
|
getLibp2pNode(): import("libp2p").Libp2p<import("@libp2p/interface").ServiceMap>;
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
131
|
+
/**
|
|
132
|
+
* Stop the shared libp2p node: close connections and release the node, so nothing
|
|
133
|
+
* keeps the process alive. Long-lived Node.js processes should call this on
|
|
134
|
+
* shutdown. There is no relay reservation to release — ocean.js listens on nothing
|
|
135
|
+
* and only ever *dials* through a relay. Safe to call when P2P was never started,
|
|
136
|
+
* and safe to call twice.
|
|
137
|
+
*/
|
|
138
|
+
stopP2P(): Promise<void>;
|
|
139
|
+
/** Alias for {@link stopP2P}. */
|
|
140
|
+
dispose(): Promise<void>;
|
|
141
|
+
/**
|
|
142
|
+
* Every peer this client knows about, with the state of the connection to it.
|
|
143
|
+
*
|
|
144
|
+
* `peerId` and `multiaddrs` are unchanged; the connection fields are added. They are
|
|
145
|
+
* what tells a known peer apart from a reachable one — a peer can sit in the peer store
|
|
146
|
+
* with three addresses and be unreachable, or be connected only over a circuit relay
|
|
147
|
+
* that will cut the connection off after a byte budget.
|
|
148
|
+
*/
|
|
149
|
+
getDiscoveredNodes(): Promise<Awaited<ReturnType<P2pProvider['getDiscoveredNodes']>>>;
|
|
150
|
+
/**
|
|
151
|
+
* Whether P2P can do anything, as opposed to whether it is switched on: routing-table
|
|
152
|
+
* size, DHT mode, the peer store lifetimes the running node applies, and the resolution
|
|
153
|
+
* lanes.
|
|
154
|
+
*
|
|
155
|
+
* The routing table is the one to read first. A DHT lookup against an empty table finds
|
|
156
|
+
* nothing however many connections are open, because a connection to a peer that does
|
|
157
|
+
* not speak the DHT protocol is not a place a walk can start.
|
|
158
|
+
*/
|
|
159
|
+
getP2pDiagnostics(): ReturnType<P2pProvider['getP2pDiagnostics']>;
|
|
69
160
|
getMultiaddrFromPeerId(peerId: string): Promise<string>;
|
|
161
|
+
/**
|
|
162
|
+
* Which tier answered each peer-address resolution — an open connection, the peer
|
|
163
|
+
* store, or a DHT walk — plus cache hits, misses and invalidations.
|
|
164
|
+
*
|
|
165
|
+
* Read this to see whether the peer store is doing its job: an address now lives
|
|
166
|
+
* there as long as the DHT provider record that names it, and the visible effect of
|
|
167
|
+
* that should be resolutions moving out of the `dht` lane and into `peer-store`.
|
|
168
|
+
*/
|
|
169
|
+
getPeerResolutionStats(): Record<string, number>;
|
|
170
|
+
/**
|
|
171
|
+
* Forgets the cached addresses for a peer, so the next call to it resolves afresh.
|
|
172
|
+
* Failed dials already do this; call it directly when something outside the library
|
|
173
|
+
* knows a node has moved.
|
|
174
|
+
*/
|
|
175
|
+
invalidatePeerResolution(peerId: string): void;
|
|
70
176
|
createPersistentStorageBucket(nodeUri: OceanNode, signerOrAuthToken: SignerOrAuthTokenOrSignature, payload: PersistentStorageCreateBucketRequest, signal?: AbortSignal): Promise<{
|
|
71
177
|
bucketId: string;
|
|
72
178
|
owner: string;
|
|
@@ -84,7 +190,14 @@ export declare class BaseProvider {
|
|
|
84
190
|
serviceStop(nodeUri: OceanNode, signerOrAuthToken: SignerOrAuthTokenOrSignature, serviceId: string, signal?: AbortSignal): Promise<ServiceJob[]>;
|
|
85
191
|
serviceExtend(nodeUri: OceanNode, signerOrAuthToken: SignerOrAuthTokenOrSignature, serviceId: string, additionalDuration: number, payment: ServicePayment, signal?: AbortSignal): Promise<ServiceJob[]>;
|
|
86
192
|
serviceRestart(nodeUri: OceanNode, signerOrAuthToken: SignerOrAuthTokenOrSignature, serviceId: string, params?: ServiceRestartParams, signal?: AbortSignal): Promise<ServiceJob[]>;
|
|
87
|
-
|
|
193
|
+
/**
|
|
194
|
+
* Returns the caller's service jobs (userData stripped). Filter by `serviceId`,
|
|
195
|
+
* or omit it to list all of the caller's services. Requires a signature.
|
|
196
|
+
* @param {boolean} includeMetrics Owner-only runtime metrics (`runtimeMetrics`) on the
|
|
197
|
+
* returned service(s). This command is already authenticated, so metrics are included
|
|
198
|
+
* BY DEFAULT (omitted / `undefined`); pass `false` to opt out.
|
|
199
|
+
*/
|
|
200
|
+
getServiceStatus(nodeUri: OceanNode, signerOrAuthToken: SignerOrAuthTokenOrSignature, serviceId?: string, signal?: AbortSignal, includeMetrics?: boolean): Promise<ServiceJob[]>;
|
|
88
201
|
getServices(nodeUri: OceanNode, signerOrAuthToken: SignerOrAuthTokenOrSignature, filters?: ServiceListFilters, signal?: AbortSignal): Promise<ServiceJobListed[]>;
|
|
89
202
|
serviceGetStreamableLogs(nodeUri: OceanNode, signerOrAuthToken: SignerOrAuthTokenOrSignature, serviceId: string, since?: string, signal?: AbortSignal): Promise<any>;
|
|
90
203
|
fetchConfig(nodeUri: OceanNode, payload: Record<string, any>): Promise<any>;
|