@oceanprotocol/lib 9.0.0-next.1 → 9.0.0-next.11
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 +57 -0
- package/dist/types/@types/Provider.d.ts +2 -5
- package/dist/types/@types/Services.d.ts +33 -11
- package/dist/types/contracts/Dispenser.d.ts +1 -1
- package/dist/types/contracts/NFT.d.ts +2 -2
- package/dist/types/contracts/NFTFactory.d.ts +2 -2
- package/dist/types/services/providers/BaseProvider.d.ts +33 -5
- package/dist/types/services/providers/HttpProvider.d.ts +42 -28
- package/dist/types/services/providers/P2pProvider.d.ts +32 -5
- package/package.json +57 -60
- package/dist/lib.cjs +0 -5
- package/dist/lib.umd.js +0 -5
|
@@ -81,6 +81,62 @@ export interface ComputeResult {
|
|
|
81
81
|
export type ComputeJobMetadata = {
|
|
82
82
|
[key: string]: string | number | boolean;
|
|
83
83
|
};
|
|
84
|
+
export type GpuVendor = 'nvidia' | 'amd' | 'intel';
|
|
85
|
+
export interface GpuMetricsSnapshot {
|
|
86
|
+
resourceId: string;
|
|
87
|
+
vendor: GpuVendor;
|
|
88
|
+
utilizationPercent: number | null;
|
|
89
|
+
memoryUsedBytes: number | null;
|
|
90
|
+
memoryTotalBytes: number | null;
|
|
91
|
+
temperatureC?: number;
|
|
92
|
+
powerWatts?: number;
|
|
93
|
+
shared?: boolean;
|
|
94
|
+
}
|
|
95
|
+
export interface ContainerMetricsSnapshot {
|
|
96
|
+
collectedAt: string;
|
|
97
|
+
containerState: {
|
|
98
|
+
status: string;
|
|
99
|
+
startedAt?: string;
|
|
100
|
+
finishedAt?: string;
|
|
101
|
+
exitCode?: number;
|
|
102
|
+
oomKilled: boolean;
|
|
103
|
+
error?: string;
|
|
104
|
+
restartCount: number;
|
|
105
|
+
health?: string;
|
|
106
|
+
};
|
|
107
|
+
cpu: {
|
|
108
|
+
usagePercent: number;
|
|
109
|
+
allocated: number;
|
|
110
|
+
usagePercentOfAllocated: number;
|
|
111
|
+
cumulativeSeconds: number;
|
|
112
|
+
throttledPeriods: number;
|
|
113
|
+
throttledSeconds: number;
|
|
114
|
+
};
|
|
115
|
+
memory: {
|
|
116
|
+
usageBytes: number;
|
|
117
|
+
limitBytes: number;
|
|
118
|
+
usagePercent: number;
|
|
119
|
+
peakUsageBytes: number;
|
|
120
|
+
};
|
|
121
|
+
disk: {
|
|
122
|
+
usedBytes: number;
|
|
123
|
+
quotaBytes?: number;
|
|
124
|
+
usagePercent?: number;
|
|
125
|
+
};
|
|
126
|
+
network?: {
|
|
127
|
+
rxBytes: number;
|
|
128
|
+
txBytes: number;
|
|
129
|
+
};
|
|
130
|
+
blockIO: {
|
|
131
|
+
readBytes: number;
|
|
132
|
+
writeBytes: number;
|
|
133
|
+
};
|
|
134
|
+
pids: {
|
|
135
|
+
current: number;
|
|
136
|
+
limit: number;
|
|
137
|
+
};
|
|
138
|
+
gpu?: GpuMetricsSnapshot[];
|
|
139
|
+
}
|
|
84
140
|
export interface ComputeJob {
|
|
85
141
|
owner: string;
|
|
86
142
|
did?: string;
|
|
@@ -120,6 +176,7 @@ export interface NodeComputeJob extends ComputeJob {
|
|
|
120
176
|
queueMaxWaitTime?: number;
|
|
121
177
|
jobIdHash?: string;
|
|
122
178
|
maxJobDuration?: number;
|
|
179
|
+
runtimeMetrics?: ContainerMetricsSnapshot;
|
|
123
180
|
}
|
|
124
181
|
export interface ComputeOutputEncryption {
|
|
125
182
|
encryptMethod: EncryptMethod.AES;
|
|
@@ -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[];
|
|
@@ -141,7 +136,9 @@ export declare const PROTOCOL_COMMANDS: {
|
|
|
141
136
|
SERVICE_STOP: string;
|
|
142
137
|
SERVICE_RESTART: string;
|
|
143
138
|
SERVICE_GET_STATUS: string;
|
|
139
|
+
SERVICE_LIST: string;
|
|
144
140
|
SERVICE_EXTEND: string;
|
|
141
|
+
SERVICE_GET_STREAMABLE_LOGS: string;
|
|
145
142
|
};
|
|
146
143
|
export interface NodeLogsParams {
|
|
147
144
|
logId?: 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';
|
|
@@ -13,6 +13,12 @@ export interface UserConfigurableEnvVar {
|
|
|
13
13
|
validation?: string;
|
|
14
14
|
sensitive?: boolean;
|
|
15
15
|
}
|
|
16
|
+
export interface ServiceTemplateWorkflow {
|
|
17
|
+
id: string;
|
|
18
|
+
name: string;
|
|
19
|
+
description?: string;
|
|
20
|
+
graph?: unknown;
|
|
21
|
+
}
|
|
16
22
|
export interface ServiceTemplatePublic {
|
|
17
23
|
id: string;
|
|
18
24
|
name?: string;
|
|
@@ -29,6 +35,7 @@ export interface ServiceTemplatePublic {
|
|
|
29
35
|
entrypoint?: string[];
|
|
30
36
|
requiredResources?: TemplateResourceRequirement[];
|
|
31
37
|
recommendedResources?: TemplateResourceRequirement[];
|
|
38
|
+
workflows?: ServiceTemplateWorkflow[];
|
|
32
39
|
}
|
|
33
40
|
export interface ServiceJobEndpoint {
|
|
34
41
|
containerPort: number;
|
|
@@ -36,15 +43,16 @@ export interface ServiceJobEndpoint {
|
|
|
36
43
|
url: string;
|
|
37
44
|
}
|
|
38
45
|
export declare enum ServiceStatusNumber {
|
|
39
|
-
Starting = 10
|
|
40
|
-
PullImage = 11
|
|
46
|
+
Starting = 10,// DB record created by the start handler; awaits background processing
|
|
47
|
+
PullImage = 11,// pulling pre-built image from registry
|
|
41
48
|
PullImageFailed = 12,
|
|
42
|
-
BuildImage = 13
|
|
49
|
+
BuildImage = 13,// building from Dockerfile
|
|
43
50
|
BuildImageFailed = 14,
|
|
44
|
-
VulnerableImage = 15
|
|
45
|
-
Locking = 20,
|
|
46
|
-
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
|
|
47
54
|
Running = 40,
|
|
55
|
+
Restarting = 45,// SERVICE_RESTART accepted; teardown + re-pull/build + new container in progress
|
|
48
56
|
Stopping = 50,
|
|
49
57
|
Stopped = 70,
|
|
50
58
|
Expired = 75,
|
|
@@ -76,6 +84,7 @@ export interface ServiceJob {
|
|
|
76
84
|
status: ServiceStatusNumber;
|
|
77
85
|
statusText: string;
|
|
78
86
|
dateCreated: string;
|
|
87
|
+
updatedAt?: number;
|
|
79
88
|
expiresAt: number;
|
|
80
89
|
duration: number;
|
|
81
90
|
exposedPorts: number[];
|
|
@@ -83,24 +92,37 @@ export interface ServiceJob {
|
|
|
83
92
|
resources: any[];
|
|
84
93
|
payment: ServiceJobPayment;
|
|
85
94
|
extendPayments?: ServiceJobPayment[];
|
|
95
|
+
runtimeMetrics?: ContainerMetricsSnapshot;
|
|
96
|
+
}
|
|
97
|
+
export type ServiceJobListed = Omit<ServiceJob, 'dockerCmd' | 'dockerEntrypoint' | 'dockerfile' | 'additionalDockerFiles' | 'runtimeMetrics'>;
|
|
98
|
+
export interface ServiceListFilters {
|
|
99
|
+
status?: ServiceStatusNumber;
|
|
100
|
+
includeAllStatuses?: boolean;
|
|
101
|
+
fromTimestamp?: string;
|
|
102
|
+
updatedSince?: string;
|
|
86
103
|
}
|
|
87
104
|
export interface ServicePayment {
|
|
88
105
|
chainId: number;
|
|
89
106
|
token: string;
|
|
90
107
|
}
|
|
91
108
|
export type ServiceUserData = Record<string, unknown>;
|
|
92
|
-
export interface
|
|
93
|
-
|
|
94
|
-
image: string;
|
|
109
|
+
export interface ServiceContainerSpec {
|
|
110
|
+
image?: string;
|
|
95
111
|
tag?: string;
|
|
96
112
|
checksum?: string;
|
|
97
113
|
dockerfile?: string;
|
|
98
114
|
additionalDockerFiles?: Record<string, string>;
|
|
115
|
+
userData?: ServiceUserData;
|
|
99
116
|
dockerCmd?: string[];
|
|
100
117
|
dockerEntrypoint?: string[];
|
|
118
|
+
}
|
|
119
|
+
export type ServiceRestartParams = ServiceContainerSpec;
|
|
120
|
+
export interface ServiceStartParams extends ServiceContainerSpec {
|
|
121
|
+
environment: string;
|
|
122
|
+
image: string;
|
|
101
123
|
exposedPorts?: number[];
|
|
102
124
|
resources?: ComputeResourceRequest[];
|
|
103
125
|
duration: number;
|
|
104
|
-
userData?: ServiceUserData;
|
|
105
126
|
payment: ServicePayment;
|
|
127
|
+
outputBucketId?: string;
|
|
106
128
|
}
|
|
@@ -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
|
}
|
|
@@ -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,5 +1,5 @@
|
|
|
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, 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
4
|
import { P2pProvider, type P2PConfig, type P2PRequestBodyStream } from './P2pProvider.js';
|
|
5
5
|
export { OCEAN_P2P_PROTOCOL, type P2PConfig } from './P2pProvider.js';
|
|
@@ -13,7 +13,7 @@ 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[]>;
|
|
@@ -36,9 +36,28 @@ export declare class BaseProvider {
|
|
|
36
36
|
* @param {ComputeJob} job The compute job just started.
|
|
37
37
|
*/
|
|
38
38
|
private notifyIncentiveBackendJobStarted;
|
|
39
|
+
/**
|
|
40
|
+
* @param {OceanNode} nodeUri The provider URI the service runs on.
|
|
41
|
+
* @param {ServiceJob} service The service job just started.
|
|
42
|
+
*/
|
|
43
|
+
private notifyIncentiveBackendServiceStarted;
|
|
44
|
+
private notifyIncentiveBackendServiceRestarted;
|
|
39
45
|
computeStreamableLogs(nodeUri: OceanNode, signerOrAuthToken: SignerOrAuthTokenOrSignature, jobId: string, signal?: AbortSignal): Promise<any>;
|
|
40
46
|
computeStop(jobId: string, nodeUri: OceanNode, signerOrAuthToken: SignerOrAuthTokenOrSignature, agreementId?: string, signal?: AbortSignal): Promise<ComputeJob | ComputeJob[]>;
|
|
41
|
-
|
|
47
|
+
/**
|
|
48
|
+
* Get compute status for a specific jobId/documentId/owner.
|
|
49
|
+
* @param {boolean} includeMetrics Owner-only runtime metrics (`runtimeMetrics`) on the
|
|
50
|
+
* returned job(s). To receive them, the node needs owner credentials: an auth token
|
|
51
|
+
* (`signerOrAuthToken` as a string) is ALWAYS sent, regardless of this flag; a `Signer`'s
|
|
52
|
+
* nonce+signature is only computed and sent when this flag is `true` (skipped otherwise
|
|
53
|
+
* to avoid an extra nonce round-trip on every plain status poll). Omitted (default): the
|
|
54
|
+
* node attaches metrics silently if valid owner credentials made it into the request
|
|
55
|
+
* (true automatically for token callers, false for `Signer` callers unless this flag is
|
|
56
|
+
* set), and returns exactly today's response otherwise. `true`: metrics are required —
|
|
57
|
+
* this method also computes the `Signer`'s signature, and the node answers 400/401 if
|
|
58
|
+
* credentials don't verify. `false`: metrics are never attached.
|
|
59
|
+
*/
|
|
60
|
+
computeStatus(nodeUri: OceanNode, signerOrAuthToken: SignerOrAuthTokenOrSignature, jobId?: string, agreementId?: string, signal?: AbortSignal, includeMetrics?: boolean): Promise<NodeComputeJob | NodeComputeJob[]>;
|
|
42
61
|
getComputeResultUrl(nodeUri: OceanNode, signerOrAuthToken: SignerOrAuthTokenOrSignature, jobId: string, index: number): Promise<string>;
|
|
43
62
|
getComputeResult(nodeUri: OceanNode, signerOrAuthToken: SignerOrAuthTokenOrSignature, jobId: string, index: number, offset?: number): Promise<ComputeResultStream>;
|
|
44
63
|
generateAuthToken(consumer: Signer, nodeUri: OceanNode, signal?: AbortSignal): Promise<string>;
|
|
@@ -77,8 +96,17 @@ export declare class BaseProvider {
|
|
|
77
96
|
serviceStart(nodeUri: OceanNode, signerOrAuthToken: SignerOrAuthTokenOrSignature, params: ServiceStartParams, signal?: AbortSignal): Promise<ServiceJob[]>;
|
|
78
97
|
serviceStop(nodeUri: OceanNode, signerOrAuthToken: SignerOrAuthTokenOrSignature, serviceId: string, signal?: AbortSignal): Promise<ServiceJob[]>;
|
|
79
98
|
serviceExtend(nodeUri: OceanNode, signerOrAuthToken: SignerOrAuthTokenOrSignature, serviceId: string, additionalDuration: number, payment: ServicePayment, signal?: AbortSignal): Promise<ServiceJob[]>;
|
|
80
|
-
serviceRestart(nodeUri: OceanNode, signerOrAuthToken: SignerOrAuthTokenOrSignature, serviceId: string,
|
|
81
|
-
|
|
99
|
+
serviceRestart(nodeUri: OceanNode, signerOrAuthToken: SignerOrAuthTokenOrSignature, serviceId: string, params?: ServiceRestartParams, signal?: AbortSignal): Promise<ServiceJob[]>;
|
|
100
|
+
/**
|
|
101
|
+
* Returns the caller's service jobs (userData stripped). Filter by `serviceId`,
|
|
102
|
+
* or omit it to list all of the caller's services. Requires a signature.
|
|
103
|
+
* @param {boolean} includeMetrics Owner-only runtime metrics (`runtimeMetrics`) on the
|
|
104
|
+
* returned service(s). This command is already authenticated, so metrics are included
|
|
105
|
+
* BY DEFAULT (omitted / `undefined`); pass `false` to opt out.
|
|
106
|
+
*/
|
|
107
|
+
getServiceStatus(nodeUri: OceanNode, signerOrAuthToken: SignerOrAuthTokenOrSignature, serviceId?: string, signal?: AbortSignal, includeMetrics?: boolean): Promise<ServiceJob[]>;
|
|
108
|
+
getServices(nodeUri: OceanNode, signerOrAuthToken: SignerOrAuthTokenOrSignature, filters?: ServiceListFilters, signal?: AbortSignal): Promise<ServiceJobListed[]>;
|
|
109
|
+
serviceGetStreamableLogs(nodeUri: OceanNode, signerOrAuthToken: SignerOrAuthTokenOrSignature, serviceId: string, since?: string, signal?: AbortSignal): Promise<any>;
|
|
82
110
|
fetchConfig(nodeUri: OceanNode, payload: Record<string, any>): Promise<any>;
|
|
83
111
|
pushConfig(nodeUri: OceanNode, payload: Record<string, any>): Promise<any>;
|
|
84
112
|
}
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { Signer } from 'ethers';
|
|
2
|
-
import { StorageObject, FileInfo, ComputeJob, ComputeOutput, ComputeAlgorithm, ComputeAsset, ComputeEnvironment, ProviderInitialize, ProviderComputeInitializeResults,
|
|
2
|
+
import { StorageObject, FileInfo, ComputeJob, ComputeOutput, ComputeAlgorithm, ComputeAsset, ComputeEnvironment, ProviderInitialize, ProviderComputeInitializeResults, UserCustomParameters, ComputeResourceRequest, ComputeJobMetadata, PolicyServerInitializeCommand, PolicyServerPassthroughCommand, dockerRegistryAuth, ComputeResultStream, NodeStatus, NodeComputeJob, NodeLogEntry, PersistentStorageAccessList, PersistentStorageBucket, PersistentStorageCreateBucketRequest, PersistentStorageDeleteFileResponse, PersistentStorageFileEntry, PersistentStorageObject, PersistentStorageUpdateBucketResponse, ServiceJob, ServiceJobListed, ServiceListFilters, ServiceRestartParams, ServiceTemplatePublic, ServiceStartParams, ServicePayment, SignerOrAuthTokenOrSignature } from '../../@types/index.js';
|
|
3
3
|
import { type DDO, type ValidateMetadata } from '@oceanprotocol/ddo-js';
|
|
4
4
|
import { type P2PRequestBodyStream } from './P2pProvider.js';
|
|
5
5
|
export declare class HttpProvider {
|
|
6
6
|
protected getAuthorization(s: SignerOrAuthTokenOrSignature): string;
|
|
7
|
+
private baseUrl;
|
|
7
8
|
private getSignedCommandParams;
|
|
8
|
-
private resolvePersistentStorageRoute;
|
|
9
9
|
/**
|
|
10
|
-
* Returns the
|
|
10
|
+
* Returns the node's root info document (nodeId, chainIds, providerAddress, nodePublicKey, ...).
|
|
11
11
|
* @param {string} nodeUri - the provider url
|
|
12
12
|
* @return {Promise<any>}
|
|
13
13
|
*/
|
|
14
|
-
|
|
14
|
+
private getNodeInfo;
|
|
15
15
|
getNodeStatus(nodeUri: string, signal?: AbortSignal): Promise<NodeStatus>;
|
|
16
16
|
getNodeJobs(nodeUri: string, fromTimestamp?: number, signal?: AbortSignal): Promise<NodeComputeJob[]>;
|
|
17
17
|
/**
|
|
@@ -19,30 +19,14 @@ export declare class HttpProvider {
|
|
|
19
19
|
* @return {string} The node public key
|
|
20
20
|
*/
|
|
21
21
|
private getNodePublicKey;
|
|
22
|
-
/**
|
|
23
|
-
* This function returns the endpoint URL for a given service name.
|
|
24
|
-
* @param {ServiceEndpoint[]} servicesEndpoints - The array of service endpoints
|
|
25
|
-
* @param {string} serviceName - The name of the service
|
|
26
|
-
* @returns {ServiceEndpoint} The endpoint URL for the given service name
|
|
27
|
-
*/
|
|
28
|
-
getEndpointURL(servicesEndpoints: ServiceEndpoint[], serviceName: string): ServiceEndpoint;
|
|
29
|
-
/**
|
|
30
|
-
* This function returns an array of service endpoints for a given provider endpoint.
|
|
31
|
-
* @param {string} providerEndpoint - The provider endpoint
|
|
32
|
-
* @param {any} endpoints - The endpoints object
|
|
33
|
-
* @returns {ServiceEndpoint[]} An array of service endpoints
|
|
34
|
-
*/
|
|
35
|
-
getServiceEndpoints(providerEndpoint: string, endpoints: any): Promise<ServiceEndpoint[]>;
|
|
36
22
|
/**
|
|
37
23
|
* Get current nonce from the provider.
|
|
38
24
|
* @param {string} nodeUri provider uri address
|
|
39
25
|
* @param {string} consumerAddress Publisher address
|
|
40
26
|
* @param {AbortSignal} signal abort signal
|
|
41
|
-
* @param {string} providerEndpoints Identifier of the asset to be registered in ocean
|
|
42
|
-
* @param {string} serviceEndpoints document description object (DDO)=
|
|
43
27
|
* @return {Promise<string>} urlDetails
|
|
44
28
|
*/
|
|
45
|
-
getNonce(nodeUri: string, consumerAddress: string, signal?: AbortSignal
|
|
29
|
+
getNonce(nodeUri: string, consumerAddress: string, signal?: AbortSignal): Promise<number>;
|
|
46
30
|
/**
|
|
47
31
|
* Encrypt data using the Provider's own symmetric key
|
|
48
32
|
* @param {string} data data in json format that needs to be sent , it can either be a DDO or a File array
|
|
@@ -181,9 +165,19 @@ export declare class HttpProvider {
|
|
|
181
165
|
* @param {string} jobId The ID of a compute job.
|
|
182
166
|
* @param {string} agreementId The ID of the service agreement (tx id)
|
|
183
167
|
* @param {AbortSignal} signal abort signal
|
|
184
|
-
* @
|
|
168
|
+
* @param {boolean} includeMetrics Owner-only runtime metrics (`runtimeMetrics`) on the
|
|
169
|
+
* returned job(s). To receive them, the node needs owner credentials: an auth token
|
|
170
|
+
* (`signerOrAuthToken` as a string) is ALWAYS sent, regardless of this flag; a `Signer`'s
|
|
171
|
+
* nonce+signature is only computed and sent when this flag is `true` (skipped otherwise
|
|
172
|
+
* to avoid an extra nonce round-trip on every plain status poll). Omitted (default): the
|
|
173
|
+
* node attaches metrics silently if valid owner credentials made it into the request
|
|
174
|
+
* (true automatically for token callers, false for `Signer` callers unless this flag is
|
|
175
|
+
* set), and returns exactly today's response otherwise. `true`: metrics are required —
|
|
176
|
+
* this method also computes the `Signer`'s signature, and the node answers 400/401 if
|
|
177
|
+
* credentials don't verify. `false`: metrics are never attached.
|
|
178
|
+
* @return {Promise<NodeComputeJob | NodeComputeJob[]>}
|
|
185
179
|
*/
|
|
186
|
-
computeStatus(nodeUri: string, signerOrAuthToken: SignerOrAuthTokenOrSignature, jobId?: string, agreementId?: string, signal?: AbortSignal): Promise<
|
|
180
|
+
computeStatus(nodeUri: string, signerOrAuthToken: SignerOrAuthTokenOrSignature, jobId?: string, agreementId?: string, signal?: AbortSignal, includeMetrics?: boolean): Promise<NodeComputeJob | NodeComputeJob[]>;
|
|
187
181
|
/** Get compute result url
|
|
188
182
|
* @param {string} nodeUri The URI of the provider we want to query
|
|
189
183
|
* @param {SignerOrAuthToken} signerOrAuthToken signer or auth token
|
|
@@ -260,7 +254,6 @@ export declare class HttpProvider {
|
|
|
260
254
|
uploadPersistentStorageFile(nodeUri: string, signerOrAuthToken: SignerOrAuthTokenOrSignature, bucketId: string, fileName: string, content: P2PRequestBodyStream, signal?: AbortSignal): Promise<PersistentStorageFileEntry>;
|
|
261
255
|
deletePersistentStorageFile(nodeUri: string, signerOrAuthToken: SignerOrAuthTokenOrSignature, bucketId: string, fileName: string, signal?: AbortSignal): Promise<PersistentStorageDeleteFileResponse>;
|
|
262
256
|
updatePersistentStorageBucket(nodeUri: string, signerOrAuthToken: SignerOrAuthTokenOrSignature, bucketId: string, label: string | null, signal?: AbortSignal): Promise<PersistentStorageUpdateBucketResponse>;
|
|
263
|
-
private resolveServiceRoute;
|
|
264
257
|
private encryptServiceUserData;
|
|
265
258
|
private buildQuery;
|
|
266
259
|
/**
|
|
@@ -291,15 +284,36 @@ export declare class HttpProvider {
|
|
|
291
284
|
*/
|
|
292
285
|
serviceExtend(nodeUri: string, signerOrAuthToken: SignerOrAuthTokenOrSignature, serviceId: string, additionalDuration: number, payment: ServicePayment, signal?: AbortSignal): Promise<ServiceJob[]>;
|
|
293
286
|
/**
|
|
294
|
-
* Restarts a running service (recreates the container)
|
|
295
|
-
*
|
|
287
|
+
* Restarts a running service (recreates the container) while keeping the same serviceId,
|
|
288
|
+
* payment, resources, host port(s) and expiry.
|
|
289
|
+
*
|
|
290
|
+
* The node treats the restart atomically. Passing no container-spec fields in `params`
|
|
291
|
+
* (REUSE mode) bounces the container on its stored spec unchanged. Passing ANY of
|
|
292
|
+
* `image`/`tag`/`checksum`/`dockerfile`/`additionalDockerFiles` (RESPEC mode) rebuilds the
|
|
293
|
+
* container entirely from `params`: `image` becomes mandatory, exactly one of
|
|
294
|
+
* `tag`/`checksum`/`dockerfile` applies, and a `dockerfile` requires `allowImageBuild` on
|
|
295
|
+
* the env (else the node replies 403). `userData`/`dockerCmd`/`dockerEntrypoint` are only
|
|
296
|
+
* sent when supplied — an omitted override reuses the node's stored value, whereas an
|
|
297
|
+
* explicit value (including `[]`) REPLACES it (matches ocean-node's restartService semantics).
|
|
296
298
|
* @return {Promise<ServiceJob[]>} The restarted service job (single-element array).
|
|
297
299
|
*/
|
|
298
|
-
serviceRestart(nodeUri: string, signerOrAuthToken: SignerOrAuthTokenOrSignature, serviceId: string,
|
|
300
|
+
serviceRestart(nodeUri: string, signerOrAuthToken: SignerOrAuthTokenOrSignature, serviceId: string, params?: ServiceRestartParams, signal?: AbortSignal): Promise<ServiceJob[]>;
|
|
299
301
|
/**
|
|
300
302
|
* Returns the caller's service jobs (userData stripped). Filter by `serviceId`,
|
|
301
303
|
* or omit it to list all of the caller's services. Requires a signature.
|
|
304
|
+
* @param {boolean} includeMetrics Owner-only runtime metrics (`runtimeMetrics`) on the
|
|
305
|
+
* returned service(s). This command is already authenticated, so metrics are included
|
|
306
|
+
* BY DEFAULT (omitted / `undefined`); pass `false` to opt out.
|
|
302
307
|
* @return {Promise<ServiceJob[]>} The matching service jobs.
|
|
303
308
|
*/
|
|
304
|
-
getServiceStatus(nodeUri: string, signerOrAuthToken: SignerOrAuthTokenOrSignature, serviceId?: string, signal?: AbortSignal): Promise<ServiceJob[]>;
|
|
309
|
+
getServiceStatus(nodeUri: string, signerOrAuthToken: SignerOrAuthTokenOrSignature, serviceId?: string, signal?: AbortSignal, includeMetrics?: boolean): Promise<ServiceJob[]>;
|
|
310
|
+
/**
|
|
311
|
+
* Node-wide service listing (SERVICE_LIST). Authenticated but NOT owner-scoped: any
|
|
312
|
+
* consumer identity sees every owner's services, listing-sanitized (no userData, no
|
|
313
|
+
* dockerCmd/dockerEntrypoint, no Dockerfile). Default (no filters) returns only the
|
|
314
|
+
* services currently holding a resource reservation; see ServiceListFilters.
|
|
315
|
+
* @return {Promise<ServiceJobListed[]>} The matching service jobs.
|
|
316
|
+
*/
|
|
317
|
+
getServices(nodeUri: string, signerOrAuthToken: SignerOrAuthTokenOrSignature, filters?: ServiceListFilters, signal?: AbortSignal): Promise<ServiceJobListed[]>;
|
|
318
|
+
serviceGetStreamableLogs(nodeUri: string, signerOrAuthToken: SignerOrAuthTokenOrSignature, serviceId: string, since?: string, signal?: AbortSignal): Promise<any>;
|
|
305
319
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type Libp2p, type Libp2pOptions } from 'libp2p';
|
|
2
2
|
import { Signer } from 'ethers';
|
|
3
|
-
import { StorageObject, FileInfo, ComputeJob, ComputeOutput, ComputeAlgorithm, ComputeAsset, ComputeEnvironment, ProviderInitialize, ProviderComputeInitializeResults, UserCustomParameters, ComputeResourceRequest, ComputeJobMetadata, PolicyServerInitializeCommand, PolicyServerPassthroughCommand, dockerRegistryAuth, DownloadResponse, ComputeResultStream, NodeStatus, NodeComputeJob, PersistentStorageAccessList, PersistentStorageBucket, PersistentStorageCreateBucketRequest, PersistentStorageDeleteFileResponse, PersistentStorageFileEntry, PersistentStorageObject, PersistentStorageUpdateBucketResponse, ServiceJob, ServiceTemplatePublic, ServiceStartParams,
|
|
3
|
+
import { StorageObject, FileInfo, ComputeJob, ComputeOutput, ComputeAlgorithm, ComputeAsset, ComputeEnvironment, ProviderInitialize, ProviderComputeInitializeResults, UserCustomParameters, ComputeResourceRequest, ComputeJobMetadata, PolicyServerInitializeCommand, PolicyServerPassthroughCommand, dockerRegistryAuth, DownloadResponse, ComputeResultStream, NodeStatus, NodeComputeJob, PersistentStorageAccessList, PersistentStorageBucket, PersistentStorageCreateBucketRequest, PersistentStorageDeleteFileResponse, PersistentStorageFileEntry, PersistentStorageObject, PersistentStorageUpdateBucketResponse, ServiceJob, ServiceJobListed, ServiceListFilters, ServiceRestartParams, ServiceTemplatePublic, ServiceStartParams, ServicePayment, OceanNode, SignerOrAuthTokenOrSignature } from '../../@types/index.js';
|
|
4
4
|
import { NodeLogEntry } from '../../@types/Provider.js';
|
|
5
5
|
import { type DDO, type ValidateMetadata } from '@oceanprotocol/ddo-js';
|
|
6
6
|
import { CID } from 'multiformats/cid';
|
|
@@ -145,8 +145,18 @@ export declare class P2pProvider {
|
|
|
145
145
|
computeStop(jobId: string, nodeUri: OceanNode, signerOrAuthToken: SignerOrAuthTokenOrSignature, agreementId?: string, signal?: AbortSignal): Promise<ComputeJob | ComputeJob[]>;
|
|
146
146
|
/**
|
|
147
147
|
* Get compute status via P2P.
|
|
148
|
-
|
|
149
|
-
|
|
148
|
+
* @param {boolean} includeMetrics Owner-only runtime metrics (`runtimeMetrics`) on the
|
|
149
|
+
* returned job(s). To receive them, the node needs owner credentials: an auth token
|
|
150
|
+
* (`signerOrAuthToken` as a string) is ALWAYS sent, regardless of this flag; a `Signer`'s
|
|
151
|
+
* nonce+signature is only computed and sent when this flag is `true` (skipped otherwise
|
|
152
|
+
* to avoid an extra nonce round-trip on every plain status poll). Omitted (default): the
|
|
153
|
+
* node attaches metrics silently if valid owner credentials made it into the request
|
|
154
|
+
* (true automatically for token callers, false for `Signer` callers unless this flag is
|
|
155
|
+
* set), and returns exactly today's response otherwise. `true`: metrics are required —
|
|
156
|
+
* this method also computes the `Signer`'s signature, and the node answers 400/401 if
|
|
157
|
+
* credentials don't verify. `false`: metrics are never attached.
|
|
158
|
+
*/
|
|
159
|
+
computeStatus(nodeUri: OceanNode, signerOrAuthToken: SignerOrAuthTokenOrSignature, jobId?: string, agreementId?: string, signal?: AbortSignal, includeMetrics?: boolean): Promise<NodeComputeJob | NodeComputeJob[]>;
|
|
150
160
|
/**
|
|
151
161
|
* Get compute result as an async generator of Uint8Array chunks via P2P.
|
|
152
162
|
* Supports resumable downloads via `offset` (byte position to resume from).
|
|
@@ -218,6 +228,23 @@ export declare class P2pProvider {
|
|
|
218
228
|
serviceStart(nodeUri: OceanNode, signerOrAuthToken: SignerOrAuthTokenOrSignature, params: ServiceStartParams, signal?: AbortSignal): Promise<ServiceJob[]>;
|
|
219
229
|
serviceStop(nodeUri: OceanNode, signerOrAuthToken: SignerOrAuthTokenOrSignature, serviceId: string, signal?: AbortSignal): Promise<ServiceJob[]>;
|
|
220
230
|
serviceExtend(nodeUri: OceanNode, signerOrAuthToken: SignerOrAuthTokenOrSignature, serviceId: string, additionalDuration: number, payment: ServicePayment, signal?: AbortSignal): Promise<ServiceJob[]>;
|
|
221
|
-
serviceRestart(nodeUri: OceanNode, signerOrAuthToken: SignerOrAuthTokenOrSignature, serviceId: string,
|
|
222
|
-
|
|
231
|
+
serviceRestart(nodeUri: OceanNode, signerOrAuthToken: SignerOrAuthTokenOrSignature, serviceId: string, params?: ServiceRestartParams, signal?: AbortSignal): Promise<ServiceJob[]>;
|
|
232
|
+
/**
|
|
233
|
+
* @param {boolean} includeMetrics Owner-only runtime metrics (`runtimeMetrics`) on the
|
|
234
|
+
* returned service(s). This command is already authenticated, so metrics are included
|
|
235
|
+
* BY DEFAULT (omitted / `undefined`); pass `false` to opt out.
|
|
236
|
+
*/
|
|
237
|
+
getServiceStatus(nodeUri: OceanNode, signerOrAuthToken: SignerOrAuthTokenOrSignature, serviceId?: string, signal?: AbortSignal, includeMetrics?: boolean): Promise<ServiceJob[]>;
|
|
238
|
+
/**
|
|
239
|
+
* Node-wide service listing (SERVICE_LIST) via P2P. Authenticated but NOT owner-scoped:
|
|
240
|
+
* any consumer identity sees every owner's services, listing-sanitized (no userData, no
|
|
241
|
+
* dockerCmd/dockerEntrypoint, no Dockerfile). Default (no filters) returns only the
|
|
242
|
+
* services currently holding a resource reservation; see ServiceListFilters.
|
|
243
|
+
*/
|
|
244
|
+
getServices(nodeUri: OceanNode, signerOrAuthToken: SignerOrAuthTokenOrSignature, filters?: ServiceListFilters, signal?: AbortSignal): Promise<ServiceJobListed[]>;
|
|
245
|
+
/**
|
|
246
|
+
* Stream a running service's container logs via P2P. `since` optionally bounds the lower time
|
|
247
|
+
* (Unix seconds, or a relative duration like '30s'/'2h'); omit for the full history then live.
|
|
248
|
+
*/
|
|
249
|
+
serviceGetStreamableLogs(nodeUri: OceanNode, signerOrAuthToken: SignerOrAuthTokenOrSignature, serviceId: string, since?: string, signal?: AbortSignal): Promise<any>;
|
|
223
250
|
}
|