@kosdev-code/kos-ui-sdk 3.0.20 → 3.0.22

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 (98) 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 +10 -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 +5 -5
  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/kosCore.d.ts +1 -0
  11. package/core/core/kosCore.d.ts.map +1 -1
  12. package/core/core/kosModel.d.ts +11 -0
  13. package/core/core/kosModel.d.ts.map +1 -1
  14. package/core/core/kosModelManager.d.ts +8 -0
  15. package/core/core/kosModelManager.d.ts.map +1 -1
  16. package/core/core/lifecycle/constants.d.ts +1 -1
  17. package/core/core/lifecycle/constants.d.ts.map +1 -1
  18. package/core/core/model/kos-service-request-manager.d.ts.map +1 -1
  19. package/core/core/model/kos-subscription-manager.d.ts +1 -0
  20. package/core/core/model/kos-subscription-manager.d.ts.map +1 -1
  21. package/core/core/registration/index.d.ts +1 -1
  22. package/core/core/registration/index.d.ts.map +1 -1
  23. package/core/core/registration/model-registration.d.ts +11 -0
  24. package/core/core/registration/model-registration.d.ts.map +1 -1
  25. package/core/core/services/browser-router.d.ts +1 -0
  26. package/core/core/services/browser-router.d.ts.map +1 -1
  27. package/core/index.d.ts +1 -1
  28. package/core/index.d.ts.map +1 -1
  29. package/core/util/kos-model-utils.d.ts +13 -0
  30. package/core/util/kos-model-utils.d.ts.map +1 -1
  31. package/core/util/kos-service-request.d.ts +6 -1
  32. package/core/util/kos-service-request.d.ts.map +1 -1
  33. package/core/util/service-factory.d.ts +2 -0
  34. package/core/util/service-factory.d.ts.map +1 -1
  35. package/index-CRb8ucfF.cjs +13604 -0
  36. package/index-CRb8ucfF.cjs.map +1 -0
  37. package/index-YzHb2lnB.js +13607 -0
  38. package/index-YzHb2lnB.js.map +1 -0
  39. package/index.cjs +1345 -14523
  40. package/index.cjs.map +1 -1
  41. package/index.js +799 -13984
  42. package/index.js.map +1 -1
  43. package/models/decorators/future-service.d.ts.map +1 -1
  44. package/models/decorators/kos-config-bean-prop.d.ts +5 -0
  45. package/models/decorators/kos-config-bean-prop.d.ts.map +1 -1
  46. package/models/decorators/kos-config-bean.d.ts +7 -1
  47. package/models/decorators/kos-config-bean.d.ts.map +1 -1
  48. package/models/models/browser-router/browser-router-model.d.ts.map +1 -1
  49. package/models/models/config-bean/config-bean-model.d.ts +9 -0
  50. package/models/models/config-bean/config-bean-model.d.ts.map +1 -1
  51. package/models/models/config-bean/config-bean-types.d.ts +2 -0
  52. package/models/models/config-bean/config-bean-types.d.ts.map +1 -1
  53. package/models/models/config-bean-prop/config-bean-prop-model.d.ts +3 -0
  54. package/models/models/config-bean-prop/config-bean-prop-model.d.ts.map +1 -1
  55. package/models/models/config-bean-prop/types/index.d.ts +10 -0
  56. package/models/models/log-stream/services/log-stream-services.d.ts +0 -1
  57. package/models/models/log-stream/services/log-stream-services.d.ts.map +1 -1
  58. package/models/models/network-interface/services/network-interface-services.d.ts.map +1 -1
  59. package/models/models/region-info/region-info-model.d.ts +12 -1
  60. package/models/models/region-info/region-info-model.d.ts.map +1 -1
  61. package/models/models/region-info/services/region-info-services.d.ts +2 -2
  62. package/models/models/region-info/services/region-info-services.d.ts.map +1 -1
  63. package/models/models/region-info/types/index.d.ts +7 -0
  64. package/models/models/region-info/types/index.d.ts.map +1 -1
  65. package/models/models/software-info/services/software-info-services.d.ts.map +1 -1
  66. package/models/models/translation/descriptor-merge.d.ts +38 -0
  67. package/models/models/translation/descriptor-merge.d.ts.map +1 -0
  68. package/models/models/translation/index.d.ts +2 -0
  69. package/models/models/translation/index.d.ts.map +1 -1
  70. package/models/models/translation/test-harness.d.ts +36 -0
  71. package/models/models/translation/test-harness.d.ts.map +1 -0
  72. package/models/models/translation/translation-container-model.d.ts +2 -0
  73. package/models/models/translation/translation-container-model.d.ts.map +1 -1
  74. package/models/models/translation/translation-model.d.ts.map +1 -1
  75. package/models/models/translation/types/index.d.ts +26 -0
  76. package/models/models/trouble/services/trouble-services.d.ts +0 -1
  77. package/models/models/trouble/services/trouble-services.d.ts.map +1 -1
  78. package/models/services/config-bean/index.d.ts +2 -2
  79. package/models/services/config-bean/index.d.ts.map +1 -1
  80. package/models/utils/openapi-index.d.ts +2 -2
  81. package/models/utils/services/kos/daily/openapi.d.ts +5514 -4341
  82. package/models/utils/services/kos/daily/service.d.ts +64 -5
  83. package/models/utils/services/kos/daily/service.d.ts.map +1 -1
  84. package/models/utils/services/vfs/daily/openapi.d.ts +42 -42
  85. package/models/utils/services/vfs/daily/service.d.ts +61 -2
  86. package/models/utils/services/vfs/daily/service.d.ts.map +1 -1
  87. package/models/utils/services-index.d.ts +2 -2
  88. package/models/utils/services-index.d.ts.map +1 -1
  89. package/package.json +12 -2
  90. package/testing/index.d.ts +75 -0
  91. package/testing/index.d.ts.map +1 -0
  92. package/testing.cjs +80 -0
  93. package/testing.cjs.map +1 -0
  94. package/testing.d.cts +2 -0
  95. package/testing.d.ts +2 -0
  96. package/testing.js +80 -0
  97. package/testing.js.map +1 -0
  98. 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,MA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M,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":[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/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.20",
3
+ "version": "3.0.22",
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": "3dbe0f1e25c641a7273ef1a86408a9c35081a534"
62
+ "gitHash": "b64d9a0431aa83daea7eba6b84d7b39db7d47ea9"
53
63
  }
54
64
  }
55
65
  }
@@ -0,0 +1,75 @@
1
+ import { BaseKosModelRegistrationBean, IKosCoreManager, IKosModelRegistration, IKosRegistry, KosCompanionModelType, KosModelRegistrationType, Preloaded } from '../core';
2
+ export interface BootKosCoreOptions {
3
+ /** Connection alias, when the model under test cares about one. */
4
+ alias?: string;
5
+ }
6
+ /**
7
+ * A model's registration bean — the value `@kosModel` generates beside the
8
+ * model, and the one an application passes to `KosModelRegistry...model()`.
9
+ *
10
+ * The bean itself, not its `registration` property: handing over the property
11
+ * registers nothing, and the model only fails later, on the first build.
12
+ */
13
+ export type KosTestRegistration = BaseKosModelRegistrationBean<any, any> | KosModelRegistrationType<any, any>;
14
+ /**
15
+ * The registration chain an application uses, terminated by `boot()`.
16
+ *
17
+ * Every call is deferred until `boot()`, so ordering within the chain does not
18
+ * matter and `alias()` may come after the models it applies to.
19
+ */
20
+ export interface KosCoreBootBuilder {
21
+ /** Register a model under test, optionally preloading it. */
22
+ model: (registration: KosTestRegistration, preload?: boolean) => KosCoreBootBuilder;
23
+ /** Preload a model type, or a specific instance of one, at boot. */
24
+ preload: (model: Preloaded) => KosCoreBootBuilder;
25
+ /** Attach a companion model type to a parent type. */
26
+ companion: (parentType: string, companion: KosCompanionModelType<any>) => KosCoreBootBuilder;
27
+ /** Register a hand-written registration record against a type. */
28
+ legacy: (type: string, registration: IKosModelRegistration) => KosCoreBootBuilder;
29
+ /** Connection alias, when the model under test cares about one. */
30
+ alias: (alias: string) => KosCoreBootBuilder;
31
+ /** Boot KosCore with everything registered on this chain. */
32
+ boot: () => Promise<IKosCoreManager>;
33
+ }
34
+ /**
35
+ * Open a registration chain, then `boot()` it.
36
+ *
37
+ * Idempotent per module instance: the first `boot()` boots, later ones return
38
+ * the same core. KosCore and the model manager are process-global, so a test
39
+ * file gets one core and one set of singletons — which is the isolation
40
+ * boundary, and the reason a differently-configured singleton needs its own
41
+ * file.
42
+ *
43
+ * Register any routes the models need BEFORE calling `boot()`, so nothing races
44
+ * the boot requests.
45
+ *
46
+ * @example
47
+ * ```ts
48
+ * await bootKosCore().model(AssetManager).model(AssetEntry).boot();
49
+ * ```
50
+ */
51
+ export declare function bootKosCore(): KosCoreBootBuilder;
52
+ /**
53
+ * Boot KosCore from an assembled registry.
54
+ *
55
+ * Kept for callers that already hold an `IKosRegistry`. A test registering its
56
+ * own models should use the no-argument chain instead, which takes the
57
+ * registration beans directly.
58
+ *
59
+ * @param registration Models under test, e.g. `{ models: {...}, preloadModels: [] }`.
60
+ */
61
+ export declare function bootKosCore(registration: IKosRegistry, options?: BootKosCoreOptions): Promise<IKosCoreManager>;
62
+ /**
63
+ * Wait until `predicate` holds, then resolve — or reject naming what never
64
+ * happened.
65
+ *
66
+ * Model reactions are asynchronous, so a test that changes an input and asserts
67
+ * immediately reads the old value. Polling for the OUTCOME beats sleeping for an
68
+ * arbitrary interval: it is faster when the reaction is quick, and it fails with
69
+ * a usable message instead of a bare assertion diff when the reaction never
70
+ * fires at all.
71
+ *
72
+ * @param label What is being waited for, quoted back in the timeout message.
73
+ */
74
+ export declare function until(predicate: () => boolean, label: string, timeoutMs?: number): Promise<void>;
75
+ //# 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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;AACH,OAAO,KAAK,EACV,4BAA4B,EAC5B,eAAe,EACf,qBAAqB,EACrB,YAAY,EACZ,qBAAqB,EACrB,wBAAwB,EACxB,SAAS,EACV,MAAM,SAAS,CAAC;AAMjB,MAAM,WAAW,kBAAkB;IACjC,mEAAmE;IACnE,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;GAMG;AACH,MAAM,MAAM,mBAAmB,GAC3B,4BAA4B,CAAC,GAAG,EAAE,GAAG,CAAC,GACtC,wBAAwB,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;AAEvC;;;;;GAKG;AACH,MAAM,WAAW,kBAAkB;IACjC,6DAA6D;IAC7D,KAAK,EAAE,CACL,YAAY,EAAE,mBAAmB,EACjC,OAAO,CAAC,EAAE,OAAO,KACd,kBAAkB,CAAC;IACxB,oEAAoE;IACpE,OAAO,EAAE,CAAC,KAAK,EAAE,SAAS,KAAK,kBAAkB,CAAC;IAClD,sDAAsD;IACtD,SAAS,EAAE,CACT,UAAU,EAAE,MAAM,EAClB,SAAS,EAAE,qBAAqB,CAAC,GAAG,CAAC,KAClC,kBAAkB,CAAC;IACxB,kEAAkE;IAClE,MAAM,EAAE,CACN,IAAI,EAAE,MAAM,EACZ,YAAY,EAAE,qBAAqB,KAChC,kBAAkB,CAAC;IACxB,mEAAmE;IACnE,KAAK,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,kBAAkB,CAAC;IAC7C,6DAA6D;IAC7D,IAAI,EAAE,MAAM,OAAO,CAAC,eAAe,CAAC,CAAC;CACtC;AA4ED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,WAAW,IAAI,kBAAkB,CAAC;AAClD;;;;;;;;GAQG;AACH,wBAAgB,WAAW,CACzB,YAAY,EAAE,YAAY,EAC1B,OAAO,CAAC,EAAE,kBAAkB,GAC3B,OAAO,CAAC,eAAe,CAAC,CAAC;AAQ5B;;;;;;;;;;;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,80 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ require("mobx");
4
+ const service = require("./index-CRb8ucfF.cjs");
5
+ require("loglevel");
6
+ let booted;
7
+ let prepared = false;
8
+ function prepareTransport(alias) {
9
+ if (prepared) {
10
+ return;
11
+ }
12
+ prepared = true;
13
+ service.KosMock.configure({ standalone: true });
14
+ service.KosCore.getInstance({ connectionAlias: alias });
15
+ }
16
+ function bootCore(registration, options) {
17
+ if (!booted) {
18
+ prepareTransport(options.alias);
19
+ const core = service.KosCore.create(registration, false, options.alias);
20
+ booted = core.whenReady().then(() => core);
21
+ }
22
+ return booted;
23
+ }
24
+ function buildBootBuilder() {
25
+ const registrations = [];
26
+ const preloadModels = [];
27
+ let alias;
28
+ const builder = {
29
+ model: (registration, preload) => {
30
+ registrations.push(
31
+ () => service.RegistrationManager.model.register(builder)(registration, preload)
32
+ );
33
+ return builder;
34
+ },
35
+ preload: (model) => {
36
+ preloadModels.push(model);
37
+ return builder;
38
+ },
39
+ companion: (parentType, companion) => {
40
+ registrations.push(
41
+ () => service.RegistrationManager.companion.register(builder)(parentType, companion)
42
+ );
43
+ return builder;
44
+ },
45
+ legacy: (type, registration) => {
46
+ registrations.push(
47
+ () => service.RegistrationManager.model.registerLegacyModel(builder)(
48
+ type,
49
+ registration
50
+ )
51
+ );
52
+ return builder;
53
+ },
54
+ alias: (value) => {
55
+ alias = value;
56
+ return builder;
57
+ },
58
+ boot: () => {
59
+ prepareTransport(alias);
60
+ registrations.splice(0).forEach((register) => register());
61
+ return bootCore({ models: {}, preloadModels }, { alias });
62
+ }
63
+ };
64
+ return builder;
65
+ }
66
+ function bootKosCore(registration, options = {}) {
67
+ return registration ? bootCore(registration, options) : buildBootBuilder();
68
+ }
69
+ async function until(predicate, label, timeoutMs = 2e3) {
70
+ const deadline = Date.now() + timeoutMs;
71
+ while (!predicate()) {
72
+ if (Date.now() > deadline) {
73
+ throw new Error(`timed out waiting for ${label}`);
74
+ }
75
+ await new Promise((resolve) => setTimeout(resolve, 5));
76
+ }
77
+ }
78
+ exports.bootKosCore = bootKosCore;
79
+ exports.until = until;
80
+ //# 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 * Models register the way an application registers them. `bootKosCore()` with\n * no arguments returns a builder carrying the same chain an app's\n * `KosModelRegistry` gives — `.model()`, `.preload()`, `.companion()`,\n * `.legacy()` — so a test hands over the registration bean itself rather than\n * assembling a registry by hand.\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 * import { Board } from \"./models/board\";\n *\n * beforeAll(async () => {\n * KosMock.get(\"/api/board/:id\", { data: { id: \"b1\", state: \"READY\" } });\n * await bootKosCore().model(Board).boot();\n * });\n *\n * it(\"loads the board\", async () => {\n * const board = Board.instance(\"b1\").options({}).build();\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 * `options(...)` call returns the FIRST instance and discards the new options in\n * silence, so assertions written against them pass for the wrong reason. A case\n * needing different options belongs in its own file, which the test runner\n * 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 {\n BaseKosModelRegistrationBean,\n IKosCoreManager,\n IKosModelRegistration,\n IKosRegistry,\n KosCompanionModelType,\n KosModelRegistrationType,\n Preloaded,\n} from \"../core\";\nimport { KosCore, KosMock, RegistrationManager } from \"../core\";\n\nlet booted: Promise<IKosCoreManager> | undefined;\nlet prepared = false;\n\nexport interface BootKosCoreOptions {\n /** Connection alias, when the model under test cares about one. */\n alias?: string;\n}\n\n/**\n * A model's registration bean — the value `@kosModel` generates beside the\n * model, and the one an application passes to `KosModelRegistry...model()`.\n *\n * The bean itself, not its `registration` property: handing over the property\n * registers nothing, and the model only fails later, on the first build.\n */\nexport type KosTestRegistration =\n | BaseKosModelRegistrationBean<any, any>\n | KosModelRegistrationType<any, any>;\n\n/**\n * The registration chain an application uses, terminated by `boot()`.\n *\n * Every call is deferred until `boot()`, so ordering within the chain does not\n * matter and `alias()` may come after the models it applies to.\n */\nexport interface KosCoreBootBuilder {\n /** Register a model under test, optionally preloading it. */\n model: (\n registration: KosTestRegistration,\n preload?: boolean\n ) => KosCoreBootBuilder;\n /** Preload a model type, or a specific instance of one, at boot. */\n preload: (model: Preloaded) => KosCoreBootBuilder;\n /** Attach a companion model type to a parent type. */\n companion: (\n parentType: string,\n companion: KosCompanionModelType<any>\n ) => KosCoreBootBuilder;\n /** Register a hand-written registration record against a type. */\n legacy: (\n type: string,\n registration: IKosModelRegistration\n ) => KosCoreBootBuilder;\n /** Connection alias, when the model under test cares about one. */\n alias: (alias: string) => KosCoreBootBuilder;\n /** Boot KosCore with everything registered on this chain. */\n boot: () => Promise<IKosCoreManager>;\n}\n\n/**\n * Put the mock transport and the connection alias in place before anything\n * constructs KosCore.\n *\n * KosCore picks its transport and reads its alias in the constructor, and\n * registering a model reaches `KosCore.getInstance()` — so registration cannot\n * come first.\n */\nfunction prepareTransport(alias?: string): void {\n if (prepared) {\n return;\n }\n prepared = true;\n KosMock.configure({ standalone: true });\n KosCore.getInstance({ connectionAlias: alias });\n}\n\nfunction bootCore(\n registration: IKosRegistry,\n options: BootKosCoreOptions\n): Promise<IKosCoreManager> {\n if (!booted) {\n prepareTransport(options.alias);\n const core = KosCore.create(registration, false, options.alias);\n booted = core.whenReady().then(() => core);\n }\n return booted;\n}\n\nfunction buildBootBuilder(): KosCoreBootBuilder {\n const registrations: (() => void)[] = [];\n const preloadModels: Preloaded[] = [];\n let alias: string | undefined;\n\n const builder: KosCoreBootBuilder = {\n model: (registration, preload) => {\n registrations.push(() =>\n RegistrationManager.model.register(builder)(registration, preload)\n );\n return builder;\n },\n preload: (model) => {\n preloadModels.push(model);\n return builder;\n },\n companion: (parentType, companion) => {\n registrations.push(() =>\n RegistrationManager.companion.register(builder)(parentType, companion)\n );\n return builder;\n },\n legacy: (type, registration) => {\n registrations.push(() =>\n RegistrationManager.model.registerLegacyModel(builder)(\n type,\n registration\n )\n );\n return builder;\n },\n alias: (value) => {\n alias = value;\n return builder;\n },\n boot: () => {\n prepareTransport(alias);\n registrations.splice(0).forEach((register) => register());\n return bootCore({ models: {}, preloadModels }, { alias });\n },\n };\n\n return builder;\n}\n\n/**\n * Open a registration chain, then `boot()` it.\n *\n * Idempotent per module instance: the first `boot()` boots, later ones return\n * the same core. KosCore and the model manager are process-global, so a test\n * file gets one core and one set of singletons — which is the isolation\n * boundary, and the reason a differently-configured singleton needs its own\n * file.\n *\n * Register any routes the models need BEFORE calling `boot()`, so nothing races\n * the boot requests.\n *\n * @example\n * ```ts\n * await bootKosCore().model(AssetManager).model(AssetEntry).boot();\n * ```\n */\nexport function bootKosCore(): KosCoreBootBuilder;\n/**\n * Boot KosCore from an assembled registry.\n *\n * Kept for callers that already hold an `IKosRegistry`. A test registering its\n * own models should use the no-argument chain instead, which takes the\n * registration beans directly.\n *\n * @param registration Models under test, e.g. `{ models: {...}, preloadModels: [] }`.\n */\nexport function bootKosCore(\n registration: IKosRegistry,\n options?: BootKosCoreOptions\n): Promise<IKosCoreManager>;\nexport function bootKosCore(\n registration?: IKosRegistry,\n options: BootKosCoreOptions = {}\n): KosCoreBootBuilder | Promise<IKosCoreManager> {\n return registration ? bootCore(registration, options) : buildBootBuilder();\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","RegistrationManager"],"mappings":";;;;;AA6DA,IAAI;AACJ,IAAI,WAAW;AAwDf,SAAS,iBAAiB,OAAsB;AAC9C,MAAI,UAAU;AACZ;AAAA,EACF;AACA,aAAW;AACXA,UAAAA,QAAQ,UAAU,EAAE,YAAY,KAAA,CAAM;AACtCC,UAAAA,QAAQ,YAAY,EAAE,iBAAi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O,eAAe,SAAS,cAAc,OAAO,IAAI,iBAAA;AAC1D;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 {}