@oceanprotocol/lib 9.3.0-next.5 → 9.3.0-next.6

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.
@@ -81,6 +81,7 @@ export interface NodeStatus {
81
81
  uptime: number;
82
82
  persistentStorage?: {
83
83
  accessLists?: AccessList[];
84
+ allowBucketSharing?: boolean;
84
85
  };
85
86
  }
86
87
  /**
@@ -244,6 +245,7 @@ export declare const PROTOCOL_COMMANDS: {
244
245
  SERVICE_EXTEND: string;
245
246
  SERVICE_GET_STREAMABLE_LOGS: string;
246
247
  GET_ESCROW_EVENTS: string;
248
+ SERVICE_GET_RESULT: string;
247
249
  };
248
250
  export interface NodeLogsParams {
249
251
  logId?: string;
@@ -66,6 +66,13 @@ export interface ServiceJobPayment {
66
66
  cost?: string | number;
67
67
  [key: string]: any;
68
68
  }
69
+ export interface ServiceOutputArchive {
70
+ index: number;
71
+ filename: string;
72
+ filesize: number;
73
+ createdAt: number;
74
+ containerId: string;
75
+ }
69
76
  export interface ServiceJob {
70
77
  serviceId: string;
71
78
  clusterHash: string;
@@ -94,8 +101,10 @@ export interface ServiceJob {
94
101
  extendPayments?: ServiceJobPayment[];
95
102
  runtimeMetrics?: ContainerMetricsSnapshot;
96
103
  metadata?: ComputeJobMetadata;
104
+ outputBucketId?: string;
105
+ outputArchives?: ServiceOutputArchive[];
97
106
  }
98
- export type ServiceJobListed = Omit<ServiceJob, 'dockerCmd' | 'dockerEntrypoint' | 'dockerfile' | 'additionalDockerFiles' | 'runtimeMetrics'>;
107
+ export type ServiceJobListed = Omit<ServiceJob, 'dockerCmd' | 'dockerEntrypoint' | 'dockerfile' | 'additionalDockerFiles' | 'runtimeMetrics' | 'outputArchives'>;
99
108
  export interface ServiceListFilters {
100
109
  status?: ServiceStatusNumber;
101
110
  includeAllStatuses?: boolean;
@@ -251,6 +251,26 @@ export declare class BaseProvider {
251
251
  getServiceStatus(nodeUri: OceanNode, signerOrAuthToken: SignerOrAuthTokenOrSignature, serviceId?: string, signal?: AbortSignal, includeMetrics?: boolean): Promise<ServiceJob[]>;
252
252
  getServices(nodeUri: OceanNode, signerOrAuthToken: SignerOrAuthTokenOrSignature, filters?: ServiceListFilters, signal?: AbortSignal): Promise<ServiceJobListed[]>;
253
253
  serviceGetStreamableLogs(nodeUri: OceanNode, signerOrAuthToken: SignerOrAuthTokenOrSignature, serviceId: string, since?: string, signal?: AbortSignal): Promise<any>;
254
+ /**
255
+ * Downloads a service's /data/outputs as a zip, dispatching to the HTTP or P2P transport based
256
+ * on `nodeUri`. Only for a service started without an output bucket (its results are in the
257
+ * bucket otherwise); owner-only.
258
+ *
259
+ * - `index`: one of the zips the node took whenever a container of the service was removed
260
+ * (stop, expiry, restart, recovery), listed as `outputArchives` by getServiceStatus. Works in
261
+ * any status until the node's storage expiry deletes it; resumable with `offset`.
262
+ * - `'live'`: a zip of the running container's /data/outputs, built as it is read — while the
263
+ * service is Running (or Error before teardown). Not resumable; files being written at that
264
+ * moment may come out partial.
265
+ * @param {OceanNode} nodeUri The provider target (HTTP URL, or peerId / multiaddr for P2P).
266
+ * @param {SignerOrAuthTokenOrSignature} signerOrAuthToken Signer, JWT auth token, or precomputed signature used to authenticate the request.
267
+ * @param {string} serviceId The service.
268
+ * @param {number | 'live'} index An archive index, or `'live'`.
269
+ * @param {number} [offset=0] Byte offset to resume an archive download from.
270
+ * @param {AbortSignal} [signal] Abort signal that cancels the download.
271
+ * @return {Promise<ComputeResultStream>} An async-iterable stream of the zip, starting at `offset`.
272
+ */
273
+ serviceGetResult(nodeUri: OceanNode, signerOrAuthToken: SignerOrAuthTokenOrSignature, serviceId: string, index: number | 'live', offset?: number, signal?: AbortSignal): Promise<ComputeResultStream>;
254
274
  fetchConfig(nodeUri: OceanNode, payload: Record<string, any>): Promise<any>;
255
275
  pushConfig(nodeUri: OceanNode, payload: Record<string, any>): Promise<any>;
256
276
  }
@@ -381,4 +381,16 @@ export declare class HttpProvider {
381
381
  */
382
382
  getServices(nodeUri: string, signerOrAuthToken: SignerOrAuthTokenOrSignature, filters?: ServiceListFilters, signal?: AbortSignal): Promise<ServiceJobListed[]>;
383
383
  serviceGetStreamableLogs(nodeUri: string, signerOrAuthToken: SignerOrAuthTokenOrSignature, serviceId: string, since?: string, signal?: AbortSignal): Promise<any>;
384
+ /**
385
+ * Downloads a service's /data/outputs as a zip over HTTP — for a service started without an
386
+ * output bucket. Owner-only.
387
+ * @param {string} nodeUri The provider URI.
388
+ * @param {SignerOrAuthTokenOrSignature} signerOrAuthToken Signer, JWT auth token, or precomputed signature used to authenticate the request.
389
+ * @param {string} serviceId The service.
390
+ * @param {number | 'live'} index An `index` from the service's `outputArchives` (see getServiceStatus), or `'live'` for a zip of the running container's /data/outputs, built as it is read.
391
+ * @param {number} [offset=0] Byte offset to resume an archive download from, sent as the `offset` query parameter (the node answers 200 with the bytes from there on). Must be a non-negative safe integer; not supported with `'live'`.
392
+ * @param {AbortSignal} [signal] Abort signal that cancels the in-flight request.
393
+ * @return {Promise<ComputeResultStream>} An async-iterable stream of the zip, starting at `offset`.
394
+ */
395
+ serviceGetResult(nodeUri: string, signerOrAuthToken: SignerOrAuthTokenOrSignature, serviceId: string, index: number | 'live', offset?: number, signal?: AbortSignal): Promise<ComputeResultStream>;
384
396
  }
@@ -754,4 +754,21 @@ export declare class P2pProvider {
754
754
  * (Unix seconds, or a relative duration like '30s'/'2h'); omit for the full history then live.
755
755
  */
756
756
  serviceGetStreamableLogs(nodeUri: OceanNode, signerOrAuthToken: SignerOrAuthTokenOrSignature, serviceId: string, since?: string, signal?: AbortSignal): Promise<any>;
757
+ /**
758
+ * Downloads a service's /data/outputs as a zip over libp2p — for a service started without an
759
+ * output bucket. Owner-only.
760
+ *
761
+ * The transfer mirrors `downloadPersistentStorageFile`: `dialAndStream` takes a concurrency
762
+ * slot, the first frame is a status JSON (an `httpStatus >= 400` throws and releases the
763
+ * slot), and the returned generator streams the zip with flow control, resetting the stream
764
+ * and releasing the slot however iteration ends.
765
+ * @param {OceanNode} nodeUri The provider node (peerId / multiaddr).
766
+ * @param {SignerOrAuthTokenOrSignature} signerOrAuthToken Signer, JWT auth token, or precomputed signature used to authenticate the request.
767
+ * @param {string} serviceId The service.
768
+ * @param {number | 'live'} index An `index` from the service's `outputArchives` (see getServiceStatus), or `'live'` for a zip of the running container's /data/outputs, built as it is read.
769
+ * @param {number} [offset=0] Byte offset to resume an archive download from. Must be a non-negative safe integer; not supported with `'live'`.
770
+ * @param {AbortSignal} [signal] Abort signal that cancels the download mid-flight and tears down the stream.
771
+ * @return {Promise<ComputeResultStream>} An async-iterable stream of the zip, starting at `offset`.
772
+ */
773
+ serviceGetResult(nodeUri: OceanNode, signerOrAuthToken: SignerOrAuthTokenOrSignature, serviceId: string, index: number | 'live', offset?: number, signal?: AbortSignal): Promise<ComputeResultStream>;
757
774
  }
@@ -158,6 +158,8 @@ export declare class LpFrameReader {
158
158
  private discarded;
159
159
  /** Set when the stream ends in an error, whether raised locally or by the peer. */
160
160
  private closeError;
161
+ /** Set when the peer closed its writable end, i.e. finished sending the response. */
162
+ private remoteEnded;
161
163
  constructor(lp: ReturnType<typeof lpStream>, stream: Stream, maxBufferSize?: number);
162
164
  /** Bytes delivered by the transport that are not yet part of a complete frame. */
163
165
  get pendingBytes(): number;
@@ -165,9 +167,11 @@ export declare class LpFrameReader {
165
167
  signal: AbortSignal;
166
168
  }): Promise<Uint8Array>;
167
169
  /**
168
- * True when `err` is the graceful end of the stream: an end-of-file thrown with
169
- * every delivered byte already accounted for by a complete frame. A truncated
170
- * frame throws the same error type but leaves bytes pending, and returns false.
170
+ * True when `err` is the graceful end of the stream: an end-of-file thrown after the
171
+ * peer closed its writable end, with every delivered byte already accounted for by a
172
+ * complete frame. A truncated frame throws the same error type but leaves bytes
173
+ * pending, and a stream ended by its connection closing never saw the peer's close;
174
+ * both return false.
171
175
  */
172
176
  isCleanEnd(err: unknown): boolean;
173
177
  }
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Validates the target of a `serviceGetResult` call before anything is signed or dialled: an
3
+ * archive `index` (with an optional resume `offset`), or `'live'` (which cannot be resumed —
4
+ * each live zip is built afresh, so a byte offset into one means nothing in the next).
5
+ */
6
+ export declare function assertServiceResultTarget(index: number | 'live', offset: number): void;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@oceanprotocol/lib",
3
3
  "source": "./src/index.ts",
4
- "version": "9.3.0-next.5",
4
+ "version": "9.3.0-next.6",
5
5
  "description": "JavaScript client library for Ocean Protocol",
6
6
  "module": "./dist/lib.module.mjs",
7
7
  "type": "module",