@kosdev-code/kos-ui-sdk 3.0.19 → 3.0.21

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.
Files changed (61) hide show
  1. package/core/core/decorators/kos-execute-service-request.d.ts +1 -1
  2. package/core/core/decorators/kos-execute-service-request.d.ts.map +1 -1
  3. package/core/core/decorators/kos-execution-context.d.ts +11 -1
  4. package/core/core/decorators/kos-execution-context.d.ts.map +1 -1
  5. package/core/core/decorators/kos-service-request-model-factory.test-d.d.ts +2 -0
  6. package/core/core/decorators/kos-service-request-model-factory.test-d.d.ts.map +1 -0
  7. package/core/core/decorators/kos-service-request.d.ts +1 -1
  8. package/core/core/decorators/kos-service-request.d.ts.map +1 -1
  9. package/core/core/decorators/kosTopicHandler.d.ts.map +1 -1
  10. package/core/core/model/kos-service-request-manager.d.ts.map +1 -1
  11. package/core/core/services/browser-router.d.ts +1 -0
  12. package/core/core/services/browser-router.d.ts.map +1 -1
  13. package/core/util/kos-service-request.d.ts +6 -1
  14. package/core/util/kos-service-request.d.ts.map +1 -1
  15. package/core/util/service-factory.d.ts +2 -0
  16. package/core/util/service-factory.d.ts.map +1 -1
  17. package/index-BUwbSjst.js +13540 -0
  18. package/index-BUwbSjst.js.map +1 -0
  19. package/index-DUoSahlA.cjs +13537 -0
  20. package/index-DUoSahlA.cjs.map +1 -0
  21. package/index.cjs +1141 -14406
  22. package/index.cjs.map +1 -1
  23. package/index.js +712 -13984
  24. package/index.js.map +1 -1
  25. package/models/decorators/future-service.d.ts.map +1 -1
  26. package/models/models/browser-router/browser-router-model.d.ts.map +1 -1
  27. package/models/models/log-stream/services/log-stream-services.d.ts +0 -1
  28. package/models/models/log-stream/services/log-stream-services.d.ts.map +1 -1
  29. package/models/models/network-interface/services/network-interface-services.d.ts.map +1 -1
  30. package/models/models/software-info/services/software-info-services.d.ts.map +1 -1
  31. package/models/models/translation/descriptor-merge.d.ts +38 -0
  32. package/models/models/translation/descriptor-merge.d.ts.map +1 -0
  33. package/models/models/translation/index.d.ts +2 -0
  34. package/models/models/translation/index.d.ts.map +1 -1
  35. package/models/models/translation/test-harness.d.ts +36 -0
  36. package/models/models/translation/test-harness.d.ts.map +1 -0
  37. package/models/models/translation/translation-container-model.d.ts +2 -0
  38. package/models/models/translation/translation-container-model.d.ts.map +1 -1
  39. package/models/models/translation/translation-model.d.ts.map +1 -1
  40. package/models/models/translation/types/index.d.ts +26 -0
  41. package/models/models/trouble/services/trouble-services.d.ts +0 -1
  42. package/models/models/trouble/services/trouble-services.d.ts.map +1 -1
  43. package/models/utils/openapi-index.d.ts +2 -2
  44. package/models/utils/services/kos/daily/openapi.d.ts +5514 -4341
  45. package/models/utils/services/kos/daily/service.d.ts +64 -5
  46. package/models/utils/services/kos/daily/service.d.ts.map +1 -1
  47. package/models/utils/services/vfs/daily/openapi.d.ts +42 -42
  48. package/models/utils/services/vfs/daily/service.d.ts +61 -2
  49. package/models/utils/services/vfs/daily/service.d.ts.map +1 -1
  50. package/models/utils/services-index.d.ts +2 -2
  51. package/models/utils/services-index.d.ts.map +1 -1
  52. package/package.json +12 -2
  53. package/testing/index.d.ts +33 -0
  54. package/testing/index.d.ts.map +1 -0
  55. package/testing.cjs +26 -0
  56. package/testing.cjs.map +1 -0
  57. package/testing.d.cts +2 -0
  58. package/testing.d.ts +2 -0
  59. package/testing.js +26 -0
  60. package/testing.js.map +1 -0
  61. package/ui/contexts/translation-container/kos-translations-provider.d.ts.map +1 -1
@@ -8,14 +8,20 @@ import { paths } from './openapi';
8
8
  export type Api = paths;
9
9
  export type ApiPath = keyof paths;
10
10
  export type ValidPaths = PathsByMethod<paths>;
11
+ /**
12
+ * Methods a response type can be derived for — the lowercase subset of
13
+ * HttpMethod. The uppercase spellings HttpMethod also permits do not match the
14
+ * keys of an OpenAPI `paths` object, so they would silently yield `unknown`.
15
+ */
16
+ export type SupportedMethod = "get" | "post" | "put" | "delete" | "patch";
11
17
  /**
12
18
  * Get client response type for kos API
13
19
  */
14
- export type ApiResponse<Path extends ApiPath, Method extends "get" | "post" | "put" | "delete" = "get"> = ClientResponse<paths, Path, Method>;
20
+ export type ApiResponse<Path extends ApiPath, Method extends SupportedMethod = "get"> = ClientResponse<paths, Path, Method>;
15
21
  /**
16
22
  * Get execution context type for kos API
17
23
  */
18
- export type ExecutionContext<Path extends ApiPath = ApiPath, Method extends HttpMethod = "get"> = KosExecutionContext<paths, Path, Method>;
24
+ export type ExecutionContext<Path extends ApiPath = ApiPath, Method extends HttpMethod = "get", Transformed = ApiResponse<Path, SupportedMethod & Method>> = KosExecutionContext<paths, Path, Method, Transformed>;
19
25
  /**
20
26
  * Typed decorator factory for @kosServiceRequest with kos API types
21
27
  *
@@ -38,11 +44,64 @@ export type ExecutionContext<Path extends ApiPath = ApiPath, Method extends Http
38
44
  * ```
39
45
  */
40
46
  export declare function kosServiceRequest<Path extends ApiPath, Method extends HttpMethod = "get", Response = any, TransformedResponse = Response>(params: IKosServiceRequestParams<paths, Path, Method, Response, TransformedResponse>): (target: any, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
47
+ /**
48
+ * One endpoint of the kos API: a path and the method it is called with.
49
+ */
50
+ export interface Endpoint {
51
+ path: ApiPath;
52
+ method: SupportedMethod;
53
+ }
54
+ /**
55
+ * Declare an endpoint once. The decorator config, the execution context type
56
+ * and the response type are all derived from the result, so a path string is
57
+ * never restated — and never drifts between the three.
58
+ *
59
+ * @example
60
+ * ```typescript
61
+ * export const BoardApi = {
62
+ * list: endpoint("/api/board", "get"),
63
+ * update: endpoint("/api/board/{id}", "put"),
64
+ * } as const;
65
+ * ```
66
+ */
67
+ export declare function endpoint<Path extends ApiPath, Method extends SupportedMethod>(path: Path, method: Method): {
68
+ readonly path: Path;
69
+ readonly method: Method;
70
+ };
71
+ /**
72
+ * Execution context for an endpoint — the method-driven `$ctx` parameter type.
73
+ * Pass `Transformed` when the decorator declares a `transform`, so what the
74
+ * method receives is typed as the mapper's output rather than the raw response.
75
+ */
76
+ export type EndpointCtx<E extends Endpoint, Transformed = EndpointResponse<E>> = ExecutionContext<E["path"], E["method"], Transformed>;
77
+ /** Response body type for an endpoint. */
78
+ export type EndpointResponse<E extends Endpoint> = ApiResponse<E["path"], E["method"]>;
79
+ /**
80
+ * @kosServiceRequest preconfigured from an endpoint descriptor, defaulting to
81
+ * log-and-continue error handling. Pass overrides (lifecycle, errorHandler,
82
+ * cache, …) as the second argument.
83
+ *
84
+ * A `transform` narrows what the model receives: its return type becomes the
85
+ * handler's data type, so the raw response shape stops at the mapper.
86
+ *
87
+ * @example
88
+ * ```typescript
89
+ * @serviceRequest(BoardApi.update)
90
+ * async renameBoard(name: string, $ctx?: EndpointCtx<typeof BoardApi.update>) {
91
+ * const data = await executeServiceRequest(this, $ctx, {
92
+ * pathParams: { id: this.id },
93
+ * body: { name },
94
+ * });
95
+ * if (!data) return;
96
+ * }
97
+ * ```
98
+ */
99
+ export declare function serviceRequest<E extends Endpoint, Transformed = EndpointResponse<E>>(ep: E, opts?: Partial<IKosServiceRequestParams<paths, E["path"], E["method"], EndpointResponse<E>, Transformed>>): (target: any, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
41
100
  /**
42
101
  * Create an API client for kos
43
102
  */
44
103
  export declare const api: {
45
- get: <K extends "/api/kos/network/interfaces" | "/api/kos/ui/plugins/context/{*name}" | "/api/kos/ui/plugins/contexts" | "/api/kos/localization/context/{*path}" | "/api/kos/localization/contexts" | "/api/kos/browser" | "/api/kos/browser/redirect" | "/api/kos/future/traces" | "/api/kos/future/traces/{traceId}/events" | "/api/kos/ota/paused" | "/api/kos/ota/artifacts" | "/api/kos/state/paths" | "/api/kos/state/{path}" | "/api/kos/hardware/resolver/identityMappings" | "/api/kos/config/schema" | "/api/kos/config/schema/{path}" | "/api/kos/config/{path}" | "/api/kos/config/details/{options}" | "/api/kos/config/details/{path}/{options}" | "/api/kos/config/value/merged/{scopedPath}/{attr}" | "/api/kos/config/value/{scopedPath}/{attr}" | "/api/kos/config/bean/defaults/{scopedPath}" | "/api/kos/config/bean/merged/{path}" | "/api/kos/config/bean/overrides/{scopedPath}" | "/api/kos/storage/devices" | "/api/kos/update/available" | "/api/kos/troubles" | "/api/kos/troubles/{troubleId}" | "/api/kos/handles" | "/api/kos/handles/{path}" | "/api/kos/handles/{path}/{view}" | "/api/kos/handles/views" | "/api/kos/openapi/{*baseUrl}" | "/api/kos/manifest/node" | "/api/kos/manifest/device" | "/api/kos/manifest/info" | "/api/kos/apps" | "/api/kos/apps/started" | "/api/kos/time/timezone" | "/api/kos/regions" | "/api/kos/regions/info" | "/api/kos/descriptor/{path}" | "/api/kos/descriptor/{path}/{dotted}" | "/api/kos/logs/rotateAll" | "/api/kos/logs/node/{nodeId}/streams" | "/api/kos/logs/node/{nodeId}/{stream}/blocks" | "/api/kos/logs/node/{nodeId}/{stream}/blocks/{blockId}" | "/api/kos/logs/rotate/{stream}" | "/api/kos/logs/overrides" | "/api/kos/nodeMgr/node/{nodeId}/blockedManifests" | "/api/kos/nodeMgr/blockedManifests" | "/api/kos/logs/groups" | "/api/kos/logs/overrides/{nodeType}" | "/api/kos/logs/overrides/{nodeType}/{typePrefix}" | "/api/kos/studio/properties" | "/api/kos/criticalData/sources" | "/api/kos/criticalData/data" | "/api/kos/criticalData/data/{name}" | "/api/kos/device" | "/api/kos/device/assemblies" | "/api/kos/device/serialNumber">(endpoint: K, params?: (paths[K]["get"] extends {
104
+ get: <K extends "/api/kos/network/interfaces" | "/api/kos/ui/plugins/context/{*name}" | "/api/kos/ui/plugins/contexts" | "/api/kos/localization/context/{*path}" | "/api/kos/localization/contexts" | "/api/kos/browser" | "/api/kos/browser/redirect" | "/api/kos/future/traces" | "/api/kos/future/traces/{traceId}/events" | "/api/kos/ota/paused" | "/api/kos/ota/artifacts" | "/api/kos/state/paths" | "/api/kos/state/{path}" | "/api/kos/hardware/resolver/identityMappings" | "/api/kos/config/schema" | "/api/kos/config/schema/{path}" | "/api/kos/config/{path}" | "/api/kos/config/details/{options}" | "/api/kos/config/details/{path}/{options}" | "/api/kos/config/value/merged/{scopedPath}/{attr}" | "/api/kos/config/value/{scopedPath}/{attr}" | "/api/kos/config/bean/defaults/{scopedPath}" | "/api/kos/config/bean/merged/{path}" | "/api/kos/config/bean/overrides/{scopedPath}" | "/api/kos/storage/devices" | "/api/kos/update/available" | "/api/kos/troubles" | "/api/kos/troubles/{troubleId}" | "/api/kos/handles" | "/api/kos/handles/{path}" | "/api/kos/handles/{path}/{view}" | "/api/kos/handles/views" | "/api/kos/openapi/{*baseUrl}" | "/api/kos/manifest/node" | "/api/kos/manifest/device" | "/api/kos/manifest/info" | "/api/kos/apps" | "/api/kos/apps/started" | "/api/kos/time/timezone" | "/api/kos/regions" | "/api/kos/regions/info" | "/api/kos/descriptor/{path}" | "/api/kos/descriptor/{path}/{dotted}" | "/api/kos/logs/rotateAll" | "/api/kos/logs/node/{nodeId}/streams" | "/api/kos/logs/node/{nodeId}/{stream}/blocks" | "/api/kos/logs/node/{nodeId}/{stream}/blocks/{blockId}" | "/api/kos/logs/rotate/{stream}" | "/api/kos/logs/overrides" | "/api/kos/nodeMgr/node/{nodeId}/blockedManifests" | "/api/kos/nodeMgr/blockedManifests" | "/api/kos/logs/groups" | "/api/kos/logs/overrides/{nodeType}" | "/api/kos/logs/overrides/{nodeType}/{typePrefix}" | "/api/kos/studio/properties" | "/api/kos/criticalData/sources" | "/api/kos/criticalData/data" | "/api/kos/criticalData/data/{name}" | "/api/kos/device" | "/api/kos/device/assemblies" | "/api/kos/device/serialNumber" | "/api/kos/future/active" | "/api/kos/udev/devices" | "/api/kos/udev/monitors" | "/api/kos/nodeMgr/node/{nodeId}/fallbacks" | "/api/kos/nodeMgr/node/{nodeId}/queues" | "/api/kos/nodeMgr/node/{nodeId}/queues/meta/activeQueue" | "/api/kos/nodeMgr/node/{nodeId}/queues/meta/effectiveQueueAtBoot" | "/api/kos/nodeMgr/node/{nodeId}/queues/meta/activeQueueAtBoot" | "/api/kos/nodeMgr/node/{nodeId}/queues/{name}" | "/api/kos/nodeMgr/node/{nodeId}/manifests/{queue}/{manifestId}/props" | "/api/kos/nodeMgr/node/{nodeId}/manifests/{queue}/{manifestId}/props/{key}" | "/api/kos/nodeMgr/node/{nodeId}/fallback/{queue}" | "/api/kos/context" | "/api/kos/gpio/chips" | "/api/kos/gpio/pins">(endpoint: K, params?: (paths[K]["get"] extends {
46
105
  parameters: infer P;
47
106
  } ? P : never) | undefined, options?: {
48
107
  ordered?: boolean | undefined;
@@ -58,7 +117,7 @@ export declare const api: {
58
117
  responseType?: "text" | "json" | "arraybuffer" | "blob" | undefined;
59
118
  retry?: (boolean | import('../../../../..').RetryConfig) | undefined;
60
119
  }) => Promise<import('../../../../../core/util/kos-service-request').ServiceResponse<ClientResponse<paths, K, "get">>>;
61
- post: <K extends "/api/kos/network/set-connection/{nodeId}" | "/api/kos/network/connect-node-to-wifi" | "/api/kos/browser/{nodeId}" | "/api/kos/browser/{nodeId}/{name}" | "/api/kos/browser/intent" | "/api/kos/browser/url" | "/api/kos/future/{futureId}/cancel" | "/api/kos/ota/resume/{name}" | "/api/kos/ota/cancel" | "/api/kos/ota/cancel/{name}" | "/api/kos/ota/pause/{name}" | "/api/kos/hardware/resolver/identityMappings/{boardPath}" | "/api/kos/config/{path}" | "/api/kos/config/bulk" | "/api/kos/update/install" | "/api/kos/troubles/resolve" | "/api/kos/troubles/resolve/{troubleId}" | "/api/kos/time/date" | "/api/kos/time/timezone" | "/api/kos/time/time" | "/api/kos/logs/node/{nodeId}/{stream}/subscribe" | "/api/kos/logs/node/{nodeId}/{stream}/unsubscribe" | "/api/kos/logs/overrides" | "/api/kos/nodeMgr/reboot" | "/api/kos/nodeMgr/node/{nodeId}/reboot" | "/api/kos/nodeMgr/node/{nodeId}/blockedManifests/{manifestId}" | "/api/kos/nodeMgr/blockedManifests/{manifestId}" | "/api/kos/criticalData/data" | "/api/kos/criticalData/data/{name}" | "/api/kos/device/serialNumber/{serialNum}">(endpoint: K, params?: (paths[K]["post"] extends {
120
+ post: <K extends "/api/kos/network/set-connection/{nodeId}" | "/api/kos/network/connect-node-to-wifi" | "/api/kos/browser/{nodeId}" | "/api/kos/browser/{nodeId}/{name}" | "/api/kos/browser/intent" | "/api/kos/browser/url" | "/api/kos/future/{futureId}/cancel" | "/api/kos/ota/resume/{name}" | "/api/kos/ota/cancel" | "/api/kos/ota/cancel/{name}" | "/api/kos/ota/pause/{name}" | "/api/kos/hardware/resolver/identityMappings/{boardPath}" | "/api/kos/config/{path}" | "/api/kos/config/bulk" | "/api/kos/update/install" | "/api/kos/troubles/resolve" | "/api/kos/troubles/resolve/{troubleId}" | "/api/kos/time/date" | "/api/kos/time/timezone" | "/api/kos/time/time" | "/api/kos/logs/node/{nodeId}/{stream}/subscribe" | "/api/kos/logs/node/{nodeId}/{stream}/unsubscribe" | "/api/kos/logs/overrides" | "/api/kos/nodeMgr/reboot" | "/api/kos/nodeMgr/node/{nodeId}/reboot" | "/api/kos/nodeMgr/node/{nodeId}/blockedManifests/{manifestId}" | "/api/kos/nodeMgr/blockedManifests/{manifestId}" | "/api/kos/criticalData/data" | "/api/kos/criticalData/data/{name}" | "/api/kos/device/serialNumber/{serialNum}" | "/api/kos/nodeMgr/node/{nodeId}/queues/meta/activeQueue/{name}" | "/api/kos/nodeMgr/node/{nodeId}/queues/{name}" | "/api/kos/nodeMgr/node/{nodeId}/queues/{queue}/{newName}" | "/api/kos/nodeMgr/node/{nodeId}/manifests/{queue}/{manifestId}/active" | "/api/kos/nodeMgr/node/{nodeId}/manifests/{queue}/{manifestId}/props" | "/api/kos/nodeMgr/node/{nodeId}/fallback/{queue}/{fallbackQueue}" | "/api/kos/update/internalUpdate" | "/api/kos/update/internalUpdateAndReboot">(endpoint: K, params?: (paths[K]["post"] extends {
62
121
  parameters: infer P;
63
122
  } ? P : never) | undefined, body?: (paths[K]["post"] extends {
64
123
  requestBody: {
@@ -98,7 +157,7 @@ export declare const api: {
98
157
  responseType?: "text" | "json" | "arraybuffer" | "blob" | undefined;
99
158
  retry?: (boolean | import('../../../../..').RetryConfig) | undefined;
100
159
  }) => Promise<import('../../../../../core/util/kos-service-request').ServiceResponse<ClientResponse<paths, K, "put">>>;
101
- delete: <K extends "/api/kos/hardware/resolver/identityMappings/{boardPath}" | "/api/kos/logs/overrides" | "/api/kos/nodeMgr/node/{nodeId}/blockedManifests" | "/api/kos/nodeMgr/node/{nodeId}/blockedManifests/{manifestId}" | "/api/kos/nodeMgr/blockedManifests/{manifestId}" | "/api/kos/criticalData/data/{name}">(endpoint: K, params?: (paths[K]["delete"] extends {
160
+ delete: <K extends "/api/kos/hardware/resolver/identityMappings/{boardPath}" | "/api/kos/logs/overrides" | "/api/kos/nodeMgr/node/{nodeId}/blockedManifests" | "/api/kos/nodeMgr/node/{nodeId}/blockedManifests/{manifestId}" | "/api/kos/nodeMgr/blockedManifests/{manifestId}" | "/api/kos/criticalData/data/{name}" | "/api/kos/nodeMgr/node/{nodeId}/queues/{name}" | "/api/kos/nodeMgr/node/{nodeId}/manifests/{queue}/{manifestId}" | "/api/kos/nodeMgr/node/{nodeId}/manifests/{queue}/{manifestId}/active" | "/api/kos/nodeMgr/node/{nodeId}/manifests/{queue}/{manifestId}/props/{key}">(endpoint: K, params?: (paths[K]["delete"] extends {
102
161
  parameters: infer P;
103
162
  } ? P : never) | undefined, body?: (paths[K]["put"] extends {
104
163
  requestBody: {
@@ -1 +1 @@
1
- {"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../../../../../../../packages/kos-ui-sdk/src/models/utils/services/kos/daily/service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,2DAA2D,CAAC;AACrG,OAAO,KAAK,EACV,UAAU,EACV,wBAAwB,EACzB,MAAM,yDAAyD,CAAC;AAEjE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8CAA8C,CAAC;AAGnF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8CAA8C,CAAC;AAClF,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAEvC;;GAEG;AACH,MAAM,MAAM,GAAG,GAAG,KAAK,CAAC;AACxB,MAAM,MAAM,OAAO,GAAG,MAAM,KAAK,CAAC;AAClC,MAAM,MAAM,UAAU,GAAG,aAAa,CAAC,KAAK,CAAC,CAAC;AAE9C;;GAEG;AACH,MAAM,MAAM,WAAW,CACrB,IAAI,SAAS,OAAO,EACpB,MAAM,SAAS,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,QAAQ,GAAG,KAAK,IACtD,cAAc,CAAC,KAAK,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;AAExC;;GAEG;AACH,MAAM,MAAM,gBAAgB,CAC1B,IAAI,SAAS,OAAO,GAAG,OAAO,EAC9B,MAAM,SAAS,UAAU,GAAG,KAAK,IAC/B,mBAAmB,CAAC,KAAK,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;AAE7C;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,iBAAiB,CAC/B,IAAI,SAAS,OAAO,EACpB,MAAM,SAAS,UAAU,GAAG,KAAK,EACjC,QAAQ,GAAG,GAAG,EACd,mBAAmB,GAAG,QAAQ,EAE9B,MAAM,EAAE,wBAAwB,CAC9B,KAAK,EACL,IAAI,EACJ,MAAM,EACN,QAAQ,EACR,mBAAmB,CACpB,4FASF;AAED;;GAEG;AACH,eAAO,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAAwB,CAAC;AAEzC,eAAe,GAAG,CAAC"}
1
+ {"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../../../../../../../packages/kos-ui-sdk/src/models/utils/services/kos/daily/service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,2DAA2D,CAAC;AACrG,OAAO,KAAK,EACV,UAAU,EACV,wBAAwB,EACzB,MAAM,yDAAyD,CAAC;AAEjE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8CAA8C,CAAC;AAGnF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8CAA8C,CAAC;AAClF,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAEvC;;GAEG;AACH,MAAM,MAAM,GAAG,GAAG,KAAK,CAAC;AACxB,MAAM,MAAM,OAAO,GAAG,MAAM,KAAK,CAAC;AAClC,MAAM,MAAM,UAAU,GAAG,aAAa,CAAC,KAAK,CAAC,CAAC;AAE9C;;;;GAIG;AACH,MAAM,MAAM,eAAe,GAAG,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,QAAQ,GAAG,OAAO,CAAC;AAE1E;;GAEG;AACH,MAAM,MAAM,WAAW,CACrB,IAAI,SAAS,OAAO,EACpB,MAAM,SAAS,eAAe,GAAG,KAAK,IACpC,cAAc,CAAC,KAAK,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;AAExC;;GAEG;AACH,MAAM,MAAM,gBAAgB,CAC1B,IAAI,SAAS,OAAO,GAAG,OAAO,EAC9B,MAAM,SAAS,UAAU,GAAG,KAAK,EACjC,WAAW,GAAG,WAAW,CAAC,IAAI,EAAE,eAAe,GAAG,MAAM,CAAC,IACvD,mBAAmB,CAAC,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,WAAW,CAAC,CAAC;AAE1D;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,iBAAiB,CAC/B,IAAI,SAAS,OAAO,EACpB,MAAM,SAAS,UAAU,GAAG,KAAK,EACjC,QAAQ,GAAG,GAAG,EACd,mBAAmB,GAAG,QAAQ,EAE9B,MAAM,EAAE,wBAAwB,CAC9B,KAAK,EACL,IAAI,EACJ,MAAM,EACN,QAAQ,EACR,mBAAmB,CACpB,4FASF;AAED;;GAEG;AACH,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,OAAO,CAAC;IACd,MAAM,EAAE,eAAe,CAAC;CACzB;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,QAAQ,CAAC,IAAI,SAAS,OAAO,EAAE,MAAM,SAAS,eAAe,EAC3E,IAAI,EAAE,IAAI,EACV,MAAM,EAAE,MAAM;;;EAGf;AAED;;;;GAIG;AACH,MAAM,MAAM,WAAW,CACrB,CAAC,SAAS,QAAQ,EAClB,WAAW,GAAG,gBAAgB,CAAC,CAAC,CAAC,IAC/B,gBAAgB,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,EAAE,WAAW,CAAC,CAAC;AAE1D,0CAA0C;AAC1C,MAAM,MAAM,gBAAgB,CAAC,CAAC,SAAS,QAAQ,IAAI,WAAW,CAC5D,CAAC,CAAC,MAAM,CAAC,EACT,CAAC,CAAC,QAAQ,CAAC,CACZ,CAAC;AAEF;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,cAAc,CAC5B,CAAC,SAAS,QAAQ,EAClB,WAAW,GAAG,gBAAgB,CAAC,CAAC,CAAC,EAEjC,EAAE,EAAE,CAAC,EACL,IAAI,CAAC,EAAE,OAAO,CACZ,wBAAwB,CACtB,KAAK,EACL,CAAC,CAAC,MAAM,CAAC,EACT,CAAC,CAAC,QAAQ,CAAC,EACX,gBAAgB,CAAC,CAAC,CAAC,EACnB,WAAW,CACZ,CACF,4FAaF;AAED;;GAEG;AACH,eAAO,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAAwB,CAAC;AAEzC,eAAe,GAAG,CAAC"}
@@ -1,51 +1,51 @@
1
1
  export interface paths {
2
- "/api/vfs": {
3
- parameters: {
4
- query?: never;
5
- header?: never;
6
- path?: never;
7
- cookie?: never;
8
- };
9
- /** Return the structure of the VFS. (v1.0) */
10
- get: {
11
- parameters: {
12
- query?: never;
13
- header?: never;
14
- path?: never;
15
- cookie?: never;
16
- };
17
- requestBody?: never;
18
- responses: {
19
- /** @description OK */
20
- 200: {
21
- headers: {
22
- [name: string]: unknown;
23
- };
24
- content: {
25
- "application/json": components["schemas"]["7482934b-52af-489c-ba46-d05c45c33100"];
26
- };
2
+ "/api/vfs": {
3
+ parameters: {
4
+ query?: never;
5
+ header?: never;
6
+ path?: never;
7
+ cookie?: never;
8
+ };
9
+ /** Return the structure of the VFS. (v1.0) */
10
+ get: {
11
+ parameters: {
12
+ query?: never;
13
+ header?: never;
14
+ path?: never;
15
+ cookie?: never;
16
+ };
17
+ requestBody?: never;
18
+ responses: {
19
+ /** @description OK */
20
+ 200: {
21
+ headers: {
22
+ [name: string]: unknown;
23
+ };
24
+ content: {
25
+ "application/json": components["schemas"]["7377fe1a-07be-4d53-a475-50b722868d11"];
26
+ };
27
+ };
28
+ };
27
29
  };
28
- };
30
+ put?: never;
31
+ post?: never;
32
+ delete?: never;
33
+ options?: never;
34
+ head?: never;
35
+ patch?: never;
36
+ trace?: never;
29
37
  };
30
- put?: never;
31
- post?: never;
32
- delete?: never;
33
- options?: never;
34
- head?: never;
35
- patch?: never;
36
- trace?: never;
37
- };
38
38
  }
39
39
  export type webhooks = Record<string, never>;
40
40
  export interface components {
41
- schemas: {
42
- "7482934b-52af-489c-ba46-d05c45c33100": unknown;
43
- };
44
- responses: never;
45
- parameters: never;
46
- requestBodies: never;
47
- headers: never;
48
- pathItems: never;
41
+ schemas: {
42
+ "7377fe1a-07be-4d53-a475-50b722868d11": unknown;
43
+ };
44
+ responses: never;
45
+ parameters: never;
46
+ requestBodies: never;
47
+ headers: never;
48
+ pathItems: never;
49
49
  }
50
50
  export type $defs = Record<string, never>;
51
51
  export type operations = Record<string, never>;
@@ -8,14 +8,20 @@ import { paths } from './openapi';
8
8
  export type Api = paths;
9
9
  export type ApiPath = keyof paths;
10
10
  export type ValidPaths = PathsByMethod<paths>;
11
+ /**
12
+ * Methods a response type can be derived for — the lowercase subset of
13
+ * HttpMethod. The uppercase spellings HttpMethod also permits do not match the
14
+ * keys of an OpenAPI `paths` object, so they would silently yield `unknown`.
15
+ */
16
+ export type SupportedMethod = "get" | "post" | "put" | "delete" | "patch";
11
17
  /**
12
18
  * Get client response type for vfs API
13
19
  */
14
- export type ApiResponse<Path extends ApiPath, Method extends "get" | "post" | "put" | "delete" = "get"> = ClientResponse<paths, Path, Method>;
20
+ export type ApiResponse<Path extends ApiPath, Method extends SupportedMethod = "get"> = ClientResponse<paths, Path, Method>;
15
21
  /**
16
22
  * Get execution context type for vfs API
17
23
  */
18
- export type ExecutionContext<Path extends ApiPath = ApiPath, Method extends HttpMethod = "get"> = KosExecutionContext<paths, Path, Method>;
24
+ export type ExecutionContext<Path extends ApiPath = ApiPath, Method extends HttpMethod = "get", Transformed = ApiResponse<Path, SupportedMethod & Method>> = KosExecutionContext<paths, Path, Method, Transformed>;
19
25
  /**
20
26
  * Typed decorator factory for @kosServiceRequest with vfs API types
21
27
  *
@@ -38,6 +44,59 @@ export type ExecutionContext<Path extends ApiPath = ApiPath, Method extends Http
38
44
  * ```
39
45
  */
40
46
  export declare function kosServiceRequest<Path extends ApiPath, Method extends HttpMethod = "get", Response = any, TransformedResponse = Response>(params: IKosServiceRequestParams<paths, Path, Method, Response, TransformedResponse>): (target: any, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
47
+ /**
48
+ * One endpoint of the vfs API: a path and the method it is called with.
49
+ */
50
+ export interface Endpoint {
51
+ path: ApiPath;
52
+ method: SupportedMethod;
53
+ }
54
+ /**
55
+ * Declare an endpoint once. The decorator config, the execution context type
56
+ * and the response type are all derived from the result, so a path string is
57
+ * never restated — and never drifts between the three.
58
+ *
59
+ * @example
60
+ * ```typescript
61
+ * export const BoardApi = {
62
+ * list: endpoint("/api/board", "get"),
63
+ * update: endpoint("/api/board/{id}", "put"),
64
+ * } as const;
65
+ * ```
66
+ */
67
+ export declare function endpoint<Path extends ApiPath, Method extends SupportedMethod>(path: Path, method: Method): {
68
+ readonly path: Path;
69
+ readonly method: Method;
70
+ };
71
+ /**
72
+ * Execution context for an endpoint — the method-driven `$ctx` parameter type.
73
+ * Pass `Transformed` when the decorator declares a `transform`, so what the
74
+ * method receives is typed as the mapper's output rather than the raw response.
75
+ */
76
+ export type EndpointCtx<E extends Endpoint, Transformed = EndpointResponse<E>> = ExecutionContext<E["path"], E["method"], Transformed>;
77
+ /** Response body type for an endpoint. */
78
+ export type EndpointResponse<E extends Endpoint> = ApiResponse<E["path"], E["method"]>;
79
+ /**
80
+ * @kosServiceRequest preconfigured from an endpoint descriptor, defaulting to
81
+ * log-and-continue error handling. Pass overrides (lifecycle, errorHandler,
82
+ * cache, …) as the second argument.
83
+ *
84
+ * A `transform` narrows what the model receives: its return type becomes the
85
+ * handler's data type, so the raw response shape stops at the mapper.
86
+ *
87
+ * @example
88
+ * ```typescript
89
+ * @serviceRequest(BoardApi.update)
90
+ * async renameBoard(name: string, $ctx?: EndpointCtx<typeof BoardApi.update>) {
91
+ * const data = await executeServiceRequest(this, $ctx, {
92
+ * pathParams: { id: this.id },
93
+ * body: { name },
94
+ * });
95
+ * if (!data) return;
96
+ * }
97
+ * ```
98
+ */
99
+ export declare function serviceRequest<E extends Endpoint, Transformed = EndpointResponse<E>>(ep: E, opts?: Partial<IKosServiceRequestParams<paths, E["path"], E["method"], EndpointResponse<E>, Transformed>>): (target: any, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
41
100
  /**
42
101
  * Create an API client for vfs
43
102
  */
@@ -1 +1 @@
1
- {"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../../../../../../../packages/kos-ui-sdk/src/models/utils/services/vfs/daily/service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,2DAA2D,CAAC;AACrG,OAAO,KAAK,EACV,UAAU,EACV,wBAAwB,EACzB,MAAM,yDAAyD,CAAC;AAEjE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8CAA8C,CAAC;AAGnF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8CAA8C,CAAC;AAClF,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAEvC;;GAEG;AACH,MAAM,MAAM,GAAG,GAAG,KAAK,CAAC;AACxB,MAAM,MAAM,OAAO,GAAG,MAAM,KAAK,CAAC;AAClC,MAAM,MAAM,UAAU,GAAG,aAAa,CAAC,KAAK,CAAC,CAAC;AAE9C;;GAEG;AACH,MAAM,MAAM,WAAW,CACrB,IAAI,SAAS,OAAO,EACpB,MAAM,SAAS,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,QAAQ,GAAG,KAAK,IACtD,cAAc,CAAC,KAAK,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;AAExC;;GAEG;AACH,MAAM,MAAM,gBAAgB,CAC1B,IAAI,SAAS,OAAO,GAAG,OAAO,EAC9B,MAAM,SAAS,UAAU,GAAG,KAAK,IAC/B,mBAAmB,CAAC,KAAK,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;AAE7C;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,iBAAiB,CAC/B,IAAI,SAAS,OAAO,EACpB,MAAM,SAAS,UAAU,GAAG,KAAK,EACjC,QAAQ,GAAG,GAAG,EACd,mBAAmB,GAAG,QAAQ,EAE9B,MAAM,EAAE,wBAAwB,CAC9B,KAAK,EACL,IAAI,EACJ,MAAM,EACN,QAAQ,EACR,mBAAmB,CACpB,4FASF;AAED;;GAEG;AACH,eAAO,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAAwB,CAAC;AAEzC,eAAe,GAAG,CAAC"}
1
+ {"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../../../../../../../packages/kos-ui-sdk/src/models/utils/services/vfs/daily/service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,2DAA2D,CAAC;AACrG,OAAO,KAAK,EACV,UAAU,EACV,wBAAwB,EACzB,MAAM,yDAAyD,CAAC;AAEjE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8CAA8C,CAAC;AAGnF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8CAA8C,CAAC;AAClF,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAEvC;;GAEG;AACH,MAAM,MAAM,GAAG,GAAG,KAAK,CAAC;AACxB,MAAM,MAAM,OAAO,GAAG,MAAM,KAAK,CAAC;AAClC,MAAM,MAAM,UAAU,GAAG,aAAa,CAAC,KAAK,CAAC,CAAC;AAE9C;;;;GAIG;AACH,MAAM,MAAM,eAAe,GAAG,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,QAAQ,GAAG,OAAO,CAAC;AAE1E;;GAEG;AACH,MAAM,MAAM,WAAW,CACrB,IAAI,SAAS,OAAO,EACpB,MAAM,SAAS,eAAe,GAAG,KAAK,IACpC,cAAc,CAAC,KAAK,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;AAExC;;GAEG;AACH,MAAM,MAAM,gBAAgB,CAC1B,IAAI,SAAS,OAAO,GAAG,OAAO,EAC9B,MAAM,SAAS,UAAU,GAAG,KAAK,EACjC,WAAW,GAAG,WAAW,CAAC,IAAI,EAAE,eAAe,GAAG,MAAM,CAAC,IACvD,mBAAmB,CAAC,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,WAAW,CAAC,CAAC;AAE1D;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,iBAAiB,CAC/B,IAAI,SAAS,OAAO,EACpB,MAAM,SAAS,UAAU,GAAG,KAAK,EACjC,QAAQ,GAAG,GAAG,EACd,mBAAmB,GAAG,QAAQ,EAE9B,MAAM,EAAE,wBAAwB,CAC9B,KAAK,EACL,IAAI,EACJ,MAAM,EACN,QAAQ,EACR,mBAAmB,CACpB,4FASF;AAED;;GAEG;AACH,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,OAAO,CAAC;IACd,MAAM,EAAE,eAAe,CAAC;CACzB;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,QAAQ,CAAC,IAAI,SAAS,OAAO,EAAE,MAAM,SAAS,eAAe,EAC3E,IAAI,EAAE,IAAI,EACV,MAAM,EAAE,MAAM;;;EAGf;AAED;;;;GAIG;AACH,MAAM,MAAM,WAAW,CACrB,CAAC,SAAS,QAAQ,EAClB,WAAW,GAAG,gBAAgB,CAAC,CAAC,CAAC,IAC/B,gBAAgB,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,EAAE,WAAW,CAAC,CAAC;AAE1D,0CAA0C;AAC1C,MAAM,MAAM,gBAAgB,CAAC,CAAC,SAAS,QAAQ,IAAI,WAAW,CAC5D,CAAC,CAAC,MAAM,CAAC,EACT,CAAC,CAAC,QAAQ,CAAC,CACZ,CAAC;AAEF;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,cAAc,CAC5B,CAAC,SAAS,QAAQ,EAClB,WAAW,GAAG,gBAAgB,CAAC,CAAC,CAAC,EAEjC,EAAE,EAAE,CAAC,EACL,IAAI,CAAC,EAAE,OAAO,CACZ,wBAAwB,CACtB,KAAK,EACL,CAAC,CAAC,MAAM,CAAC,EACT,CAAC,CAAC,QAAQ,CAAC,EACX,gBAAgB,CAAC,CAAC,CAAC,EACnB,WAAW,CACZ,CACF,4FAaF;AAED;;GAEG;AACH,eAAO,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAAwB,CAAC;AAEzC,eAAe,GAAG,CAAC"}
@@ -1,9 +1,9 @@
1
+ export * as KOS_SERVICE from './services/kos/daily/service';
1
2
  export * as KOS_SERVICE_1_6_5 from './services/kos/1.6.5/service';
2
3
  export * as KOS_SERVICE_1_8_1 from './services/kos/1.8.1/service';
3
4
  export * as KOS_SERVICE_1_9_X from './services/kos/1.9.x/service';
4
- export * as KOS_SERVICE from './services/kos/daily/service';
5
+ export * as VFS_SERVICE from './services/vfs/daily/service';
5
6
  export * as VFS_SERVICE_1_6_5 from './services/vfs/1.6.5/service';
6
7
  export * as VFS_SERVICE_1_8_1 from './services/vfs/1.8.1/service';
7
8
  export * as VFS_SERVICE_1_9_X from './services/vfs/1.9.x/service';
8
- export * as VFS_SERVICE from './services/vfs/daily/service';
9
9
  //# sourceMappingURL=services-index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"services-index.d.ts","sourceRoot":"","sources":["../../../../../packages/kos-ui-sdk/src/models/utils/services-index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,iBAAiB,MAAM,8BAA8B,CAAC;AAClE,OAAO,KAAK,iBAAiB,MAAM,8BAA8B,CAAC;AAClE,OAAO,KAAK,iBAAiB,MAAM,8BAA8B,CAAC;AAClE,OAAO,KAAK,WAAW,MAAM,8BAA8B,CAAC;AAC5D,OAAO,KAAK,iBAAiB,MAAM,8BAA8B,CAAC;AAClE,OAAO,KAAK,iBAAiB,MAAM,8BAA8B,CAAC;AAClE,OAAO,KAAK,iBAAiB,MAAM,8BAA8B,CAAC;AAClE,OAAO,KAAK,WAAW,MAAM,8BAA8B,CAAC"}
1
+ {"version":3,"file":"services-index.d.ts","sourceRoot":"","sources":["../../../../../packages/kos-ui-sdk/src/models/utils/services-index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,WAAW,MAAM,8BAA8B,CAAC;AAC5D,OAAO,KAAK,iBAAiB,MAAM,8BAA8B,CAAC;AAClE,OAAO,KAAK,iBAAiB,MAAM,8BAA8B,CAAC;AAClE,OAAO,KAAK,iBAAiB,MAAM,8BAA8B,CAAC;AAClE,OAAO,KAAK,WAAW,MAAM,8BAA8B,CAAC;AAC5D,OAAO,KAAK,iBAAiB,MAAM,8BAA8B,CAAC;AAClE,OAAO,KAAK,iBAAiB,MAAM,8BAA8B,CAAC;AAClE,OAAO,KAAK,iBAAiB,MAAM,8BAA8B,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kosdev-code/kos-ui-sdk",
3
- "version": "3.0.19",
3
+ "version": "3.0.21",
4
4
  "type": "module",
5
5
  "main": "./index.cjs",
6
6
  "module": "./index.js",
@@ -30,6 +30,16 @@
30
30
  "default": "./index.cjs"
31
31
  }
32
32
  },
33
+ "./testing": {
34
+ "import": {
35
+ "types": "./testing.d.ts",
36
+ "default": "./testing.js"
37
+ },
38
+ "require": {
39
+ "types": "./testing.d.cts",
40
+ "default": "./testing.cjs"
41
+ }
42
+ },
33
43
  "./package.json": "./package.json"
34
44
  },
35
45
  "peerDependencies": {
@@ -49,7 +59,7 @@
49
59
  },
50
60
  "kos": {
51
61
  "build": {
52
- "gitHash": "442efeac4f5ebe09b50bc6dfa13190bc3799fbbe"
62
+ "gitHash": "a5481c29ff5f1e4f0c89ed967aea9b0f0b9ee171"
53
63
  }
54
64
  }
55
65
  }
@@ -0,0 +1,33 @@
1
+ import { IKosCoreManager, IKosRegistry } from '../core';
2
+ export interface BootKosCoreOptions {
3
+ /** Connection alias, when the model under test cares about one. */
4
+ alias?: string;
5
+ }
6
+ /**
7
+ * Boot KosCore on the standalone mock transport and resolve once it is ready.
8
+ *
9
+ * Idempotent per module instance: the first call boots, later calls return the
10
+ * same core. KosCore and the model manager are process-global, so a test file
11
+ * gets one core and one set of singletons — which is the isolation boundary,
12
+ * and the reason a differently-configured singleton needs its own file.
13
+ *
14
+ * Register any routes the models need BEFORE calling this, so nothing races the
15
+ * boot requests.
16
+ *
17
+ * @param registration Models under test, e.g. `{ models: {...Board.registration}, preloadModels: [] }`.
18
+ */
19
+ export declare function bootKosCore(registration: IKosRegistry, options?: BootKosCoreOptions): Promise<IKosCoreManager>;
20
+ /**
21
+ * Wait until `predicate` holds, then resolve — or reject naming what never
22
+ * happened.
23
+ *
24
+ * Model reactions are asynchronous, so a test that changes an input and asserts
25
+ * immediately reads the old value. Polling for the OUTCOME beats sleeping for an
26
+ * arbitrary interval: it is faster when the reaction is quick, and it fails with
27
+ * a usable message instead of a bare assertion diff when the reaction never
28
+ * fires at all.
29
+ *
30
+ * @param label What is being waited for, quoted back in the timeout message.
31
+ */
32
+ export declare function until(predicate: () => boolean, label: string, timeoutMs?: number): Promise<void>;
33
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../packages/kos-ui-sdk/src/testing/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AACH,OAAO,KAAK,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAK7D,MAAM,WAAW,kBAAkB;IACjC,mEAAmE;IACnE,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,WAAW,CACzB,YAAY,EAAE,YAAY,EAC1B,OAAO,GAAE,kBAAuB,GAC/B,OAAO,CAAC,eAAe,CAAC,CAQ1B;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,KAAK,CACzB,SAAS,EAAE,MAAM,OAAO,EACxB,KAAK,EAAE,MAAM,EACb,SAAS,SAAO,GACf,OAAO,CAAC,IAAI,CAAC,CAQf"}
package/testing.cjs ADDED
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ require("mobx");
4
+ const service = require("./index-DUoSahlA.cjs");
5
+ require("loglevel");
6
+ let booted;
7
+ function bootKosCore(registration, options = {}) {
8
+ if (!booted) {
9
+ service.KosMock.configure({ standalone: true });
10
+ const core = service.KosCore.create(registration, false, options.alias);
11
+ booted = core.whenReady().then(() => core);
12
+ }
13
+ return booted;
14
+ }
15
+ async function until(predicate, label, timeoutMs = 2e3) {
16
+ const deadline = Date.now() + timeoutMs;
17
+ while (!predicate()) {
18
+ if (Date.now() > deadline) {
19
+ throw new Error(`timed out waiting for ${label}`);
20
+ }
21
+ await new Promise((resolve) => setTimeout(resolve, 5));
22
+ }
23
+ }
24
+ exports.bootKosCore = bootKosCore;
25
+ exports.until = until;
26
+ //# sourceMappingURL=testing.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"testing.cjs","sources":["../../../packages/kos-ui-sdk/src/testing/index.ts"],"sourcesContent":["/**\n * Test support for KOS models — boot the framework in a unit test, with no\n * device, no WebSocket server and no browser.\n *\n * KOS models cannot be built in isolation: they need a live KosCore, and\n * KosCore opens a WebSocket the moment it is created. `bootKosCore` boots it on\n * KosMock's standalone loopback transport instead, which authorizes itself so\n * `whenReady()` resolves with no device and no `KOS_ALLOW_ANONYMOUS` build flag.\n *\n * Backend traffic is mocked the same way an app would mock it — `KosMock.get`,\n * `KosMock.post`, fixtures, config injection — so a test exercises the real\n * request path rather than a stubbed service function.\n *\n * ```ts\n * import { bootKosCore, until } from \"@kosdev-code/kos-ui-sdk/testing\";\n * import { KosMock } from \"@kosdev-code/kos-ui-sdk\";\n *\n * beforeAll(async () => {\n * KosMock.get(\"/api/board/:id\", { data: { id: \"b1\", state: \"READY\" } });\n * await bootKosCore({ models: { ...Board.registration }, preloadModels: [] });\n * });\n *\n * it(\"loads the board\", async () => {\n * const board = Board.factory(\"b1\")({});\n * await whenReady(board);\n * expect(board.state).toBe(\"READY\");\n * });\n * ```\n *\n * ## Two things that bite\n *\n * **Singleton models take one configuration per test file.** A second\n * `factory(options)` call returns the FIRST instance and discards the new\n * options in silence, so assertions written against them pass for the wrong\n * reason. A case needing different options belongs in its own file, which the\n * test runner gives its own module state.\n *\n * **The standalone socket authorizes by publishing Studio's\n * `/studioServer/auth/LOGGED_IN` on every open.** A device never sends that, so\n * a test shaped around disconnect/reconnect here is exercising Studio's\n * sequence, not a device's. It makes no difference to tests that never\n * reconnect.\n */\nimport type { IKosCoreManager, IKosRegistry } from \"../core\";\nimport { KosCore, KosMock } from \"../core\";\n\nlet booted: Promise<IKosCoreManager> | undefined;\n\nexport interface BootKosCoreOptions {\n /** Connection alias, when the model under test cares about one. */\n alias?: string;\n}\n\n/**\n * Boot KosCore on the standalone mock transport and resolve once it is ready.\n *\n * Idempotent per module instance: the first call boots, later calls return the\n * same core. KosCore and the model manager are process-global, so a test file\n * gets one core and one set of singletons — which is the isolation boundary,\n * and the reason a differently-configured singleton needs its own file.\n *\n * Register any routes the models need BEFORE calling this, so nothing races the\n * boot requests.\n *\n * @param registration Models under test, e.g. `{ models: {...Board.registration}, preloadModels: [] }`.\n */\nexport function bootKosCore(\n registration: IKosRegistry,\n options: BootKosCoreOptions = {}\n): Promise<IKosCoreManager> {\n if (!booted) {\n // Must precede KosCore.create: TransportFactory picks the transport once.\n KosMock.configure({ standalone: true });\n const core = KosCore.create(registration, false, options.alias);\n booted = core.whenReady().then(() => core);\n }\n return booted;\n}\n\n/**\n * Wait until `predicate` holds, then resolve — or reject naming what never\n * happened.\n *\n * Model reactions are asynchronous, so a test that changes an input and asserts\n * immediately reads the old value. Polling for the OUTCOME beats sleeping for an\n * arbitrary interval: it is faster when the reaction is quick, and it fails with\n * a usable message instead of a bare assertion diff when the reaction never\n * fires at all.\n *\n * @param label What is being waited for, quoted back in the timeout message.\n */\nexport async function until(\n predicate: () => boolean,\n label: string,\n timeoutMs = 2000\n): Promise<void> {\n const deadline = Date.now() + timeoutMs;\n while (!predicate()) {\n if (Date.now() > deadline) {\n throw new Error(`timed out waiting for ${label}`);\n }\n await new Promise((resolve) => setTimeout(resolve, 5));\n }\n}\n"],"names":["KosMock","KosCore"],"mappings":";;;;;AA8CA,IAAI;AAoBG,SAAS,YACd,cACA,UAA8B,IACJ;AAC1B,MAAI,CAAC,QAAQ;AAEXA,YAAAA,QAAQ,UAAU,EAAE,YAAY,KAAA,CAAM;AACtC,UAAM,OAAOC,QAAAA,QAAQ,OAAO,cAAc,OAAO,QAAQ,KAAK;AAC9D,aAAS,KAAK,UAAA,EAAY,KAAK,MAAM,IAAI;AAAA,EAC3C;AACA,SAAO;AACT;AAcA,eAAsB,MACpB,WACA,OACA,YAAY,KACG;AACf,QAAM,WAAW,KAAK,IAAA,IAAQ;AAC9B,SAAO,CAAC,aAAa;AACnB,QAAI,KAAK,IAAA,IAAQ,UAAU;AACzB,YAAM,IAAI,MAAM,yBAAyB,KAAK,EAAE;AAAA,IAClD;AACA,UAAM,IAAI,QAAQ,CAAC,YAAY,WAAW,SAAS,CAAC,CAAC;AAAA,EACvD;AACF;;;"}
package/testing.d.cts ADDED
@@ -0,0 +1,2 @@
1
+ export * from './testing/index'
2
+ export {}
package/testing.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export * from './testing/index'
2
+ export {}
package/testing.js ADDED
@@ -0,0 +1,26 @@
1
+ import "mobx";
2
+ import { b0 as KosMock, l as KosCore } from "./index-BUwbSjst.js";
3
+ import "loglevel";
4
+ let booted;
5
+ function bootKosCore(registration, options = {}) {
6
+ if (!booted) {
7
+ KosMock.configure({ standalone: true });
8
+ const core = KosCore.create(registration, false, options.alias);
9
+ booted = core.whenReady().then(() => core);
10
+ }
11
+ return booted;
12
+ }
13
+ async function until(predicate, label, timeoutMs = 2e3) {
14
+ const deadline = Date.now() + timeoutMs;
15
+ while (!predicate()) {
16
+ if (Date.now() > deadline) {
17
+ throw new Error(`timed out waiting for ${label}`);
18
+ }
19
+ await new Promise((resolve) => setTimeout(resolve, 5));
20
+ }
21
+ }
22
+ export {
23
+ bootKosCore,
24
+ until
25
+ };
26
+ //# sourceMappingURL=testing.js.map
package/testing.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"testing.js","sources":["../../../packages/kos-ui-sdk/src/testing/index.ts"],"sourcesContent":["/**\n * Test support for KOS models — boot the framework in a unit test, with no\n * device, no WebSocket server and no browser.\n *\n * KOS models cannot be built in isolation: they need a live KosCore, and\n * KosCore opens a WebSocket the moment it is created. `bootKosCore` boots it on\n * KosMock's standalone loopback transport instead, which authorizes itself so\n * `whenReady()` resolves with no device and no `KOS_ALLOW_ANONYMOUS` build flag.\n *\n * Backend traffic is mocked the same way an app would mock it — `KosMock.get`,\n * `KosMock.post`, fixtures, config injection — so a test exercises the real\n * request path rather than a stubbed service function.\n *\n * ```ts\n * import { bootKosCore, until } from \"@kosdev-code/kos-ui-sdk/testing\";\n * import { KosMock } from \"@kosdev-code/kos-ui-sdk\";\n *\n * beforeAll(async () => {\n * KosMock.get(\"/api/board/:id\", { data: { id: \"b1\", state: \"READY\" } });\n * await bootKosCore({ models: { ...Board.registration }, preloadModels: [] });\n * });\n *\n * it(\"loads the board\", async () => {\n * const board = Board.factory(\"b1\")({});\n * await whenReady(board);\n * expect(board.state).toBe(\"READY\");\n * });\n * ```\n *\n * ## Two things that bite\n *\n * **Singleton models take one configuration per test file.** A second\n * `factory(options)` call returns the FIRST instance and discards the new\n * options in silence, so assertions written against them pass for the wrong\n * reason. A case needing different options belongs in its own file, which the\n * test runner gives its own module state.\n *\n * **The standalone socket authorizes by publishing Studio's\n * `/studioServer/auth/LOGGED_IN` on every open.** A device never sends that, so\n * a test shaped around disconnect/reconnect here is exercising Studio's\n * sequence, not a device's. It makes no difference to tests that never\n * reconnect.\n */\nimport type { IKosCoreManager, IKosRegistry } from \"../core\";\nimport { KosCore, KosMock } from \"../core\";\n\nlet booted: Promise<IKosCoreManager> | undefined;\n\nexport interface BootKosCoreOptions {\n /** Connection alias, when the model under test cares about one. */\n alias?: string;\n}\n\n/**\n * Boot KosCore on the standalone mock transport and resolve once it is ready.\n *\n * Idempotent per module instance: the first call boots, later calls return the\n * same core. KosCore and the model manager are process-global, so a test file\n * gets one core and one set of singletons — which is the isolation boundary,\n * and the reason a differently-configured singleton needs its own file.\n *\n * Register any routes the models need BEFORE calling this, so nothing races the\n * boot requests.\n *\n * @param registration Models under test, e.g. `{ models: {...Board.registration}, preloadModels: [] }`.\n */\nexport function bootKosCore(\n registration: IKosRegistry,\n options: BootKosCoreOptions = {}\n): Promise<IKosCoreManager> {\n if (!booted) {\n // Must precede KosCore.create: TransportFactory picks the transport once.\n KosMock.configure({ standalone: true });\n const core = KosCore.create(registration, false, options.alias);\n booted = core.whenReady().then(() => core);\n }\n return booted;\n}\n\n/**\n * Wait until `predicate` holds, then resolve — or reject naming what never\n * happened.\n *\n * Model reactions are asynchronous, so a test that changes an input and asserts\n * immediately reads the old value. Polling for the OUTCOME beats sleeping for an\n * arbitrary interval: it is faster when the reaction is quick, and it fails with\n * a usable message instead of a bare assertion diff when the reaction never\n * fires at all.\n *\n * @param label What is being waited for, quoted back in the timeout message.\n */\nexport async function until(\n predicate: () => boolean,\n label: string,\n timeoutMs = 2000\n): Promise<void> {\n const deadline = Date.now() + timeoutMs;\n while (!predicate()) {\n if (Date.now() > deadline) {\n throw new Error(`timed out waiting for ${label}`);\n }\n await new Promise((resolve) => setTimeout(resolve, 5));\n }\n}\n"],"names":[],"mappings":";;;AA8CA,IAAI;AAoBG,SAAS,YACd,cACA,UAA8B,IACJ;AAC1B,MAAI,CAAC,QAAQ;AAEX,YAAQ,UAAU,EAAE,YAAY,KAAA,CAAM;AACtC,UAAM,OAAO,QAAQ,OAAO,cAAc,OAAO,QAAQ,KAAK;AAC9D,aAAS,KAAK,UAAA,EAAY,KAAK,MAAM,IAAI;AAAA,EAC3C;AACA,SAAO;AACT;AAcA,eAAsB,MACpB,WACA,OACA,YAAY,KACG;AACf,QAAM,WAAW,KAAK,IAAA,IAAQ;AAC9B,SAAO,CAAC,aAAa;AACnB,QAAI,KAAK,IAAA,IAAQ,UAAU;AACzB,YAAM,IAAI,MAAM,yBAAyB,KAAK,EAAE;AAAA,IAClD;AACA,UAAM,IAAI,QAAQ,CAAC,YAAY,WAAW,SAAS,CAAC,CAAC;AAAA,EACvD;AACF;"}
@@ -1 +1 @@
1
- {"version":3,"file":"kos-translations-provider.d.ts","sourceRoot":"","sources":["../../../../../../packages/kos-ui-sdk/src/ui/contexts/translation-container/kos-translations-provider.tsx"],"names":[],"mappings":"AACA,OAAO,EAEL,YAAY,EACZ,yBAAyB,EAE1B,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EACL,iBAAiB,EAMlB,MAAM,OAAO,CAAC;AAEf,UAAU,wBAAwB;IAChC,SAAS,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IACpC,UAAU,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;CACjD;AACD,eAAO,MAAM,2BAA2B,+DAE5B,CAAC;AAEb,UAAU,iCAAiC;IACzC,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAC/B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,kBAAkB,CAAC,EAAE,MAAM,OAAO,CAAC,YAAY,CAAC,CAAC;IACjD,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC7B,QAAQ,CAAC,EAAE,CACT,IAAI,EAAE,yBAAyB,EAC/B,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,MAAM,KACX,MAAM,CAAC;CACb;AAUD,eAAO,MAAM,sBAAsB,EAAE,KAAK,CAAC,iBAAiB,CAC1D,iBAAiB,CAAC,iCAAiC,CAAC,CA2HrD,CAAC;AACF,eAAO,MAAM,wBAAwB,gCAQpC,CAAC"}
1
+ {"version":3,"file":"kos-translations-provider.d.ts","sourceRoot":"","sources":["../../../../../../packages/kos-ui-sdk/src/ui/contexts/translation-container/kos-translations-provider.tsx"],"names":[],"mappings":"AACA,OAAO,EAEL,YAAY,EACZ,yBAAyB,EAI1B,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EACL,iBAAiB,EAMlB,MAAM,OAAO,CAAC;AAEf,UAAU,wBAAwB;IAChC,SAAS,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IACpC,UAAU,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;CACjD;AACD,eAAO,MAAM,2BAA2B,+DAE5B,CAAC;AAEb,UAAU,iCAAiC;IACzC,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAC/B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,kBAAkB,CAAC,EAAE,MAAM,OAAO,CAAC,YAAY,CAAC,CAAC;IACjD,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC7B,QAAQ,CAAC,EAAE,CACT,IAAI,EAAE,yBAAyB,EAC/B,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,MAAM,KACX,MAAM,CAAC;CACb;AAUD,eAAO,MAAM,sBAAsB,EAAE,KAAK,CAAC,iBAAiB,CAC1D,iBAAiB,CAAC,iCAAiC,CAAC,CAyFrD,CAAC;AACF,eAAO,MAAM,wBAAwB,gCAQpC,CAAC"}