@quantum-hub/qhub-service 1.6.2 → 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/client.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { type HubService, HubServiceClient as BaseHubServiceClient } from '@quantum-hub/qhub-api/service';
2
1
  import { HubPlatformClient as BaseHubPlatformClient } from '@quantum-hub/qhub-api/platform';
2
+ import { type HubService, HubServiceClient as BaseHubServiceClient } from '@quantum-hub/qhub-api/service';
3
3
  import { type DataPoolGrant } from './datapool.js';
4
4
  type ServiceApiClient = InstanceType<typeof BaseHubServiceClient>['serviceApi'];
5
5
  type DataPoolGrantsClient = InstanceType<typeof BaseHubPlatformClient>['dataPoolGrants'];
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,KAAK,UAAU,EAAE,gBAAgB,IAAI,oBAAoB,EAAC,MAAM,+BAA+B,CAAA;AACvG,OAAO,EAAC,iBAAiB,IAAI,qBAAqB,EAAC,MAAM,gCAAgC,CAAA;AACzF,OAAO,EAAC,KAAK,aAAa,EAAgB,MAAM,eAAe,CAAA;AAE/D,KAAK,gBAAgB,GAAG,YAAY,CAAC,OAAO,oBAAoB,CAAC,CAAC,YAAY,CAAC,CAAA;AAC/E,KAAK,oBAAoB,GAAG,YAAY,CAAC,OAAO,qBAAqB,CAAC,CAAC,gBAAgB,CAAC,CAAA;AAExF,eAAO,MAAM,sBAAsB,+CAA+C,CAAA;AAIlF,MAAM,WAAW,wBAAwB;IACvC,MAAM,EAAE,MAAM,CAAA;IACd,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,cAAc,CAAC,EAAE,MAAM,CAAA;CACxB;AAED,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,OAAO,CAAuB;IACtC,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAoB;gBAExC,OAAO,EAAE,wBAA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,eAAe,EAAE,MAAM,EACvB,WAAW,CAAC,EAAE,MAAM,EACpB,eAAe,CAAC,EAAE,MAAM,EACxB,aAAa,GAAE,MAA+B,EAC9C,cAAc,CAAC,EAAE,iBAAiB;IAsB/B,GAAG,IAAI,gBAAgB;IAIjB,GAAG,CACZ,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACjC,IAAI,CAAC,EAAE,MAAM,EAAE,EACf,OAAO,CAAC,EAAE,UAAU,GACrB,OAAO,CAAC,UAAU,CAAC,gBAAgB,CAAC;YAwBzB,aAAa;CAkB5B"}
package/dist/client.js CHANGED
@@ -1,9 +1,11 @@
1
- import { ClientCredentials } from 'simple-oauth2';
2
- import { HubServiceClient as BaseHubServiceClient } from '@quantum-hub/qhub-api/service';
3
1
  import { HubPlatformClient as BaseHubPlatformClient } from '@quantum-hub/qhub-api/platform';
2
+ import { HubServiceClient as BaseHubServiceClient } from '@quantum-hub/qhub-api/service';
3
+ import { ClientCredentials } from 'simple-oauth2';
4
4
  import { ReferenceType } from './datapool.js';
5
5
  export const DEFAULT_TOKEN_ENDPOINT = 'https://gateway.hub.kipu-quantum.com/token';
6
6
  const GRANT_CACHE_BUFFER_SECONDS = 30;
7
+ const PARENT_EXECUTION_TOKEN_ENV = 'KQH_SERVICE_EXECUTION_TOKEN';
8
+ const PARENT_EXECUTION_TOKEN_HEADER = 'X-Parent-Execution-Token';
7
9
  export class HubPlatformClient {
8
10
  _client;
9
11
  _organizationId;
@@ -63,17 +65,20 @@ export class HubServiceClient {
63
65
  _platform;
64
66
  _grantCache = new Map();
65
67
  constructor(serviceEndpoint, accessKeyId, secretAccessKey, tokenEndpoint = DEFAULT_TOKEN_ENDPOINT, platformClient) {
68
+ const headers = resolveParentExecutionTokenHeader();
66
69
  if (accessKeyId && secretAccessKey) {
67
70
  const auth = new HubServiceAuth(accessKeyId, secretAccessKey, tokenEndpoint);
68
71
  this._api = new BaseHubServiceClient({
69
72
  environment: () => serviceEndpoint,
70
73
  token: async () => auth.getAccessToken(),
74
+ ...(headers ? { headers } : {}),
71
75
  });
72
76
  }
73
77
  else {
74
78
  this._api = new BaseHubServiceClient({
75
79
  environment: () => serviceEndpoint,
76
80
  token: async () => Math.random().toString(36).slice(2),
81
+ ...(headers ? { headers } : {}),
77
82
  });
78
83
  }
79
84
  this._platform = platformClient;
@@ -105,7 +110,7 @@ export class HubServiceClient {
105
110
  if (cached && Date.now() / 1000 < cached.expiry - GRANT_CACHE_BUFFER_SECONDS) {
106
111
  return cached.token;
107
112
  }
108
- const grant = await this._platform.dataPoolGrants.createGrant(datapoolId, {
113
+ const grant = await this._platform.dataPoolGrants.createDataPoolGrant(datapoolId, {
109
114
  applicationId,
110
115
  permission,
111
116
  'X-OrganizationId': this._platform.organizationId,
@@ -116,6 +121,13 @@ export class HubServiceClient {
116
121
  return token;
117
122
  }
118
123
  }
124
+ function resolveParentExecutionTokenHeader() {
125
+ const token = process.env[PARENT_EXECUTION_TOKEN_ENV];
126
+ if (!token) {
127
+ return undefined;
128
+ }
129
+ return { [PARENT_EXECUTION_TOKEN_HEADER]: token };
130
+ }
119
131
  function parseJwtExpiry(token) {
120
132
  const payload = token.split('.')[1];
121
133
  const decoded = JSON.parse(atob(payload));
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.6.2",
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",