@quantum-hub/qhub-service 1.7.0 → 1.8.1

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/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  export * from './client.js';
2
2
  export * from './datapool.js';
3
+ export * from './result.js';
3
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;AAC3B,cAAc,eAAe,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;AAC3B,cAAc,eAAe,CAAA;AAC7B,cAAc,aAAa,CAAA"}
package/dist/index.js CHANGED
@@ -1,2 +1,3 @@
1
1
  export * from './client.js';
2
2
  export * from './datapool.js';
3
+ export * from './result.js';
@@ -0,0 +1,28 @@
1
+ import type { HubService } from '@quantum-hub/qhub-api/service';
2
+ /**
3
+ * A service execution result that separates the service-computed values
4
+ * (Result data) from the Execution metadata and Result files.
5
+ *
6
+ * Construct with {@link ExecutionResult.from}. The service output is never
7
+ * spread onto the wrapper, so a service field named `data`/`metadata`/`files`
8
+ * cannot shadow a view method; reach such a field via `result.raw.<field>`.
9
+ */
10
+ export declare class ExecutionResult {
11
+ readonly raw: HubService.ResultResponse;
12
+ private constructor();
13
+ /** Wrap a raw ResultResponse, e.g. from `client.api().getResult(id)`. */
14
+ static from(raw: HubService.ResultResponse): ExecutionResult;
15
+ /**
16
+ * The service-computed values: every top-level field except the HAL
17
+ * envelope keys `_links`/`_embedded`. Empty object when none.
18
+ */
19
+ data<T = Record<string, unknown>>(): T;
20
+ /** The embedded execution resource (`_embedded.status`), or `undefined`. */
21
+ metadata(): HubService.ServiceExecution | undefined;
22
+ /**
23
+ * Downloadable result file names, excluding the navigational `status` and
24
+ * `self` links. Empty array when there are no links.
25
+ */
26
+ files(): string[];
27
+ }
28
+ //# sourceMappingURL=result.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"result.d.ts","sourceRoot":"","sources":["../src/result.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,+BAA+B,CAAA;AAM7D;;;;;;;GAOG;AACH,qBAAa,eAAe;aACY,GAAG,EAAE,UAAU,CAAC,cAAc;IAAlE,OAAO;IAEP,yEAAyE;IACzE,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,UAAU,CAAC,cAAc,GAAG,eAAe;IAI5D;;;OAGG;IACH,IAAI,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,CAAC;IAMtC,4EAA4E;IAC5E,QAAQ,IAAI,UAAU,CAAC,gBAAgB,GAAG,SAAS;IAInD;;;OAGG;IACH,KAAK,IAAI,MAAM,EAAE;CAGpB"}
package/dist/result.js ADDED
@@ -0,0 +1,41 @@
1
+ // HAL navigational links to exclude from result files. `self` is present at
2
+ // runtime but is not declared in the Fern `ResultResponse.Links` type.
3
+ const NAVIGATIONAL_LINKS = ['status', 'self'];
4
+ /**
5
+ * A service execution result that separates the service-computed values
6
+ * (Result data) from the Execution metadata and Result files.
7
+ *
8
+ * Construct with {@link ExecutionResult.from}. The service output is never
9
+ * spread onto the wrapper, so a service field named `data`/`metadata`/`files`
10
+ * cannot shadow a view method; reach such a field via `result.raw.<field>`.
11
+ */
12
+ export class ExecutionResult {
13
+ raw;
14
+ constructor(raw) {
15
+ this.raw = raw;
16
+ }
17
+ /** Wrap a raw ResultResponse, e.g. from `client.api().getResult(id)`. */
18
+ static from(raw) {
19
+ return new ExecutionResult(raw);
20
+ }
21
+ /**
22
+ * The service-computed values: every top-level field except the HAL
23
+ * envelope keys `_links`/`_embedded`. Empty object when none.
24
+ */
25
+ data() {
26
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
27
+ const { _links, _embedded, ...rest } = this.raw;
28
+ return rest;
29
+ }
30
+ /** The embedded execution resource (`_embedded.status`), or `undefined`. */
31
+ metadata() {
32
+ return this.raw._embedded?.status;
33
+ }
34
+ /**
35
+ * Downloadable result file names, excluding the navigational `status` and
36
+ * `self` links. Empty array when there are no links.
37
+ */
38
+ files() {
39
+ return Object.keys(this.raw._links ?? {}).filter((rel) => !NAVIGATIONAL_LINKS.includes(rel));
40
+ }
41
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quantum-hub/qhub-service",
3
- "version": "1.7.0",
3
+ "version": "1.8.1",
4
4
  "description": "SDK to interact with managed services on the Kipu Quantum Hub.",
5
5
  "author": "Kipu Quantum GmbH",
6
6
  "contributors": [
@@ -31,6 +31,10 @@
31
31
  "@quantum-hub/qhub-api": "^1",
32
32
  "simple-oauth2": "^5"
33
33
  },
34
+ "overrides": {
35
+ "form-data": ">=4.0.6",
36
+ "joi": ">=17.13.4"
37
+ },
34
38
  "devDependencies": {
35
39
  "@types/node": "^22",
36
40
  "@types/simple-oauth2": "^5",