@kosdev-code/kos-ui-sdk 3.0.7 → 3.0.8

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.
@@ -35,7 +35,7 @@ export declare const getSoftwareInfos: (signal?: AbortSignal) => Promise<DeviceS
35
35
  * }
36
36
  * ```
37
37
  */
38
- export declare const getSoftwareInfosWithCancel: import('../../../utils/cancellable-service').CancellableFunction<() => Promise<{
38
+ export declare const getSoftwareInfosWithCancel: import('../../../utils').CancellableFunction<() => Promise<{
39
39
  nodes?: import('../../../utils/types').components["schemas"]["a7a680dc-5c50-468d-8063-704a7bf4e167"];
40
40
  }>>;
41
41
  //# sourceMappingURL=software-info-services.d.ts.map
@@ -1,37 +1,61 @@
1
1
  /**
2
- * A Promise that can be cancelled and provides progress/state tracking
2
+ * A long-running operation whose progress can be observed imperatively.
3
+ *
4
+ * This is the consumer-facing contract for progress surfaces (progress
5
+ * notifications, status indicators, modals): they depend on this interface,
6
+ * never on the producer. Producers adapt their source to it — e.g.
7
+ * `awaitFutureCall` adapts a KOS Future, but an XHR upload or an aggregate
8
+ * over several operations can implement it just as well.
3
9
  */
4
- export interface CancellablePromise<T> extends Promise<T> {
10
+ export interface ProgressOperation<T = unknown> extends Promise<T> {
5
11
  /**
6
- * Cancel this specific operation
12
+ * Percent complete, 0-100. Values <= 0 mean the operation has not reported
13
+ * real progress yet — consumers should render an indeterminate state.
7
14
  */
8
- cancel(): Promise<void>;
15
+ readonly progress: number;
9
16
  /**
10
- * Get the underlying AbortController for this operation
17
+ * Current status of the operation.
18
+ * Common values: "NOT_ACTIVE", "IN_PROGRESS", a terminal end state
19
+ * ("SUCCESS" | "FAIL" | "ABORT" | "CANCEL"), or consumer-defined.
11
20
  */
12
- getController(): AbortController | undefined;
21
+ readonly status: string;
13
22
  /**
14
- * Check if this operation is cancelled
23
+ * Whether the operation is currently running
15
24
  */
16
- isCancelled(): boolean;
25
+ readonly isRunning: boolean;
17
26
  /**
18
- * Current progress of the operation (0-1)
27
+ * Human-readable time remaining (e.g. "2 minutes"), when the source can
28
+ * estimate it. Empty/undefined when unknown.
19
29
  */
20
- readonly progress: number;
30
+ readonly timeRemaining?: string;
21
31
  /**
22
- * Current status of the operation
32
+ * Cancel this specific operation
23
33
  */
24
- readonly status: string;
34
+ cancel(): Promise<void>;
25
35
  /**
26
- * Whether the operation is currently running
36
+ * Check if this operation was cancelled. Optional — consumers must treat
37
+ * a missing implementation as "unknown".
27
38
  */
28
- readonly isRunning: boolean;
39
+ isCancelled?(): boolean;
29
40
  /**
30
41
  * Subscribe to progress updates
31
42
  * Returns a dispose function to clean up the subscription
32
43
  */
33
44
  onProgressUpdate(callback: (progress: number, status: string) => void): () => void;
34
45
  }
46
+ /**
47
+ * A Promise that can be cancelled and provides progress/state tracking
48
+ */
49
+ export interface CancellablePromise<T> extends ProgressOperation<T> {
50
+ /**
51
+ * Get the underlying AbortController for this operation
52
+ */
53
+ getController(): AbortController | undefined;
54
+ /**
55
+ * Check if this operation is cancelled
56
+ */
57
+ isCancelled(): boolean;
58
+ }
35
59
  /**
36
60
  * Options for creating a cancellable promise with progress tracking
37
61
  */
@@ -1 +1 @@
1
- {"version":3,"file":"cancellable-promise.d.ts","sourceRoot":"","sources":["../../../../../packages/kos-ui-sdk/src/models/types/cancellable-promise.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,WAAW,kBAAkB,CAAC,CAAC,CAAE,SAAQ,OAAO,CAAC,CAAC,CAAC;IACvD;;OAEG;IACH,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAExB;;OAEG;IACH,aAAa,IAAI,eAAe,GAAG,SAAS,CAAC;IAE7C;;OAEG;IACH,WAAW,IAAI,OAAO,CAAC;IAEvB;;OAEG;IACH,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAE1B;;OAEG;IACH,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAExB;;OAEG;IACH,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;IAE5B;;;OAGG;IACH,gBAAgB,CACd,QAAQ,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,IAAI,GACnD,MAAM,IAAI,CAAC;CACf;AAED;;GAEG;AACH,MAAM,WAAW,yBAAyB,CAAC,CAAC;IAC1C,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;IACpB,eAAe,CAAC,EAAE,eAAe,CAAC;IAClC,YAAY,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IACnC,MAAM,CAAC,EAAE,GAAG,CAAC;CACd;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CAAC,CAAC,EACxC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,EACnB,eAAe,CAAC,EAAE,eAAe,EACjC,YAAY,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,EAClC,MAAM,CAAC,EAAE,GAAG,GACX,kBAAkB,CAAC,CAAC,CAAC,CAAC;AACzB,wBAAgB,wBAAwB,CAAC,CAAC,EACxC,OAAO,EAAE,yBAAyB,CAAC,CAAC,CAAC,GACpC,kBAAkB,CAAC,CAAC,CAAC,CAAC"}
1
+ {"version":3,"file":"cancellable-promise.d.ts","sourceRoot":"","sources":["../../../../../packages/kos-ui-sdk/src/models/types/cancellable-promise.ts"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AACH,MAAM,WAAW,iBAAiB,CAAC,CAAC,GAAG,OAAO,CAAE,SAAQ,OAAO,CAAC,CAAC,CAAC;IAChE;;;OAGG;IACH,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAE1B;;;;OAIG;IACH,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAExB;;OAEG;IACH,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;IAE5B;;;OAGG;IACH,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;IAEhC;;OAEG;IACH,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAExB;;;OAGG;IACH,WAAW,CAAC,IAAI,OAAO,CAAC;IAExB;;;OAGG;IACH,gBAAgB,CACd,QAAQ,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,IAAI,GACnD,MAAM,IAAI,CAAC;CACf;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB,CAAC,CAAC,CAAE,SAAQ,iBAAiB,CAAC,CAAC,CAAC;IACjE;;OAEG;IACH,aAAa,IAAI,eAAe,GAAG,SAAS,CAAC;IAE7C;;OAEG;IACH,WAAW,IAAI,OAAO,CAAC;CACxB;AAED;;GAEG;AACH,MAAM,WAAW,yBAAyB,CAAC,CAAC;IAC1C,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;IACpB,eAAe,CAAC,EAAE,eAAe,CAAC;IAClC,YAAY,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IACnC,MAAM,CAAC,EAAE,GAAG,CAAC;CACd;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CAAC,CAAC,EACxC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,EACnB,eAAe,CAAC,EAAE,eAAe,EACjC,YAAY,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,EAClC,MAAM,CAAC,EAAE,GAAG,GACX,kBAAkB,CAAC,CAAC,CAAC,CAAC;AACzB,wBAAgB,wBAAwB,CAAC,CAAC,EACxC,OAAO,EAAE,yBAAyB,CAAC,CAAC,CAAC,GACpC,kBAAkB,CAAC,CAAC,CAAC,CAAC"}
@@ -0,0 +1,62 @@
1
+ import { FutureContainer } from '../models/future/future-types';
2
+ import { FutureEndState } from '../services/future';
3
+ import { CancellablePromise } from '../types/cancellable-promise';
4
+ /**
5
+ * Rejection raised when the awaited future ends in FAIL / ABORT / CANCEL.
6
+ * `reason` carries the backend's reason code (e.g. a ReasonException id),
7
+ * so callers can map it to user-facing messages.
8
+ */
9
+ export declare class FutureCallError extends Error {
10
+ readonly endState: FutureEndState;
11
+ readonly reason?: string;
12
+ readonly futureId?: string;
13
+ constructor(endState: FutureEndState, reason?: string, futureId?: string);
14
+ get isCancelled(): boolean;
15
+ }
16
+ export interface AwaitFutureCallOptions {
17
+ /** Alias the wrapped method registers its future under (@kosFuture alias). */
18
+ alias?: string;
19
+ /**
20
+ * Reject with a timeout error if the future has not reached an end state
21
+ * within this window. Unset = wait indefinitely.
22
+ */
23
+ timeoutMs?: number;
24
+ }
25
+ /**
26
+ * Invoke a @kosFuture method on a future-aware model and return a
27
+ * CancellablePromise that settles from the future's end state:
28
+ *
29
+ * - resolves with the method's response once the future ends in SUCCESS
30
+ * - rejects with {@link FutureCallError} on FAIL / ABORT / CANCEL
31
+ * - rejects with the service error if the call itself throws
32
+ * - resolves with the response when the call turns out not to be
33
+ * future-tracked (no future was produced)
34
+ *
35
+ * The future created by the call is captured reactively (the @kosFuture
36
+ * wrapper registers it on the model's futureHandler before the request is
37
+ * sent), so no timing hacks are needed and concurrent operations on other
38
+ * aliases are unaffected.
39
+ *
40
+ * @example Awaiting real completion from a command
41
+ * ```typescript
42
+ * try {
43
+ * await awaitFutureCall(artifact, (a) =>
44
+ * a.publishImportedKab(path, version, qualifier)
45
+ * );
46
+ * studio.notifications.success("Published");
47
+ * } catch (e) {
48
+ * if (e instanceof FutureCallError && !e.isCancelled) {
49
+ * studio.notifications.error(mapReason(e.reason));
50
+ * }
51
+ * }
52
+ * ```
53
+ *
54
+ * @example Cancellation and progress
55
+ * ```typescript
56
+ * const call = awaitFutureCall(model, (m) => m.performOperation());
57
+ * const stop = call.onProgressUpdate((p, status) => render(p, status));
58
+ * // later: await call.cancel();
59
+ * ```
60
+ */
61
+ export declare function awaitFutureCall<T extends FutureContainer, R>(model: T, methodCall: (model: T) => Promise<R>, options?: AwaitFutureCallOptions): CancellablePromise<R>;
62
+ //# sourceMappingURL=await-future-call.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"await-future-call.d.ts","sourceRoot":"","sources":["../../../../../packages/kos-ui-sdk/src/models/utils/await-future-call.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAIH,OAAO,KAAK,EACV,eAAe,EAEhB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAIvE;;;;GAIG;AACH,qBAAa,eAAgB,SAAQ,KAAK;IACxC,QAAQ,CAAC,QAAQ,EAAE,cAAc,CAAC;IAClC,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;gBAEf,QAAQ,EAAE,cAAc,EAAE,MAAM,CAAC,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM;IAQxE,IAAI,WAAW,YAKd;CACF;AAED,MAAM,WAAW,sBAAsB;IACrC,8EAA8E;IAC9E,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,wBAAgB,eAAe,CAAC,CAAC,SAAS,eAAe,EAAE,CAAC,EAC1D,KAAK,EAAE,CAAC,EACR,UAAU,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC,EACpC,OAAO,GAAE,sBAA2B,GACnC,kBAAkB,CAAC,CAAC,CAAC,CAuKvB"}
@@ -1,3 +1,6 @@
1
+ export * from './await-future-call';
2
+ export * from './cancellable-future-call';
3
+ export * from './cancellable-service';
1
4
  export * from './client';
2
5
  export * from './conversion-utils';
3
6
  export * from './core-registration-manager';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../packages/kos-ui-sdk/src/models/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,oBAAoB,CAAC;AACnC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC;AACjC,cAAc,yBAAyB,CAAC;AACxC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../packages/kos-ui-sdk/src/models/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,uBAAuB,CAAC;AACtC,cAAc,UAAU,CAAC;AACzB,cAAc,oBAAoB,CAAC;AACnC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC;AACjC,cAAc,yBAAyB,CAAC;AACxC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kosdev-code/kos-ui-sdk",
3
- "version": "3.0.7",
3
+ "version": "3.0.8",
4
4
  "type": "module",
5
5
  "main": "./index.cjs",
6
6
  "module": "./index.js",
@@ -49,7 +49,7 @@
49
49
  },
50
50
  "kos": {
51
51
  "build": {
52
- "gitHash": "65e37c8c2fa31716451cc469c9d23f1e4871b818"
52
+ "gitHash": "29a870c61fdd44a1dbbef550f682c9d991e98146"
53
53
  }
54
54
  }
55
55
  }