@kosdev-code/kos-ui-sdk 3.0.24 → 3.0.26

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 (60) hide show
  1. package/.kos.json +1 -1
  2. package/core/core/decorators/kos-logger-aware.d.ts.map +1 -1
  3. package/core/core/decorators/kos-multiple-future-aware.d.ts +10 -46
  4. package/core/core/decorators/kos-multiple-future-aware.d.ts.map +1 -1
  5. package/core/core/decorators/kos-reload-aware.d.ts +6 -4
  6. package/core/core/decorators/kos-reload-aware.d.ts.map +1 -1
  7. package/core/core/decorators/kos-service-request-helpers.d.ts +3 -1
  8. package/core/core/decorators/kos-service-request-helpers.d.ts.map +1 -1
  9. package/core/core/decorators/kos-service-request.d.ts +13 -35
  10. package/core/core/decorators/kos-service-request.d.ts.map +1 -1
  11. package/core/core/decorators/kos-state-machine.d.ts +21 -10
  12. package/core/core/decorators/kos-state-machine.d.ts.map +1 -1
  13. package/core/core/decorators/kos-topic-handler-flow-control.d.ts +28 -28
  14. package/core/core/decorators/kos-topic-handler-flow-control.d.ts.map +1 -1
  15. package/core/core/decorators/kos-view-model.d.ts.map +1 -1
  16. package/core/core/decorators/kosDependency.d.ts +4 -2
  17. package/core/core/decorators/kosDependency.d.ts.map +1 -1
  18. package/core/core/decorators/kosModel.d.ts.map +1 -1
  19. package/core/core/decorators/kosTopicHandler.d.ts +3 -12
  20. package/core/core/decorators/kosTopicHandler.d.ts.map +1 -1
  21. package/core/core/extension/extension-manager.d.ts.map +1 -1
  22. package/core/core/kosCore.d.ts +15 -0
  23. package/core/core/kosCore.d.ts.map +1 -1
  24. package/core/core/kosModel.d.ts +5 -0
  25. package/core/core/kosModel.d.ts.map +1 -1
  26. package/core/core/model/kos-model-component-factory.d.ts +1 -1
  27. package/core/core/model/kos-model-component-factory.d.ts.map +1 -1
  28. package/core/core/model/kos-service-request-manager.d.ts +7 -2
  29. package/core/core/model/kos-service-request-manager.d.ts.map +1 -1
  30. package/core/core/model/kos-subscription-manager.d.ts +2 -2
  31. package/core/core/model/kos-subscription-manager.d.ts.map +1 -1
  32. package/core/core/model/service-response-store.d.ts +2 -1
  33. package/core/core/model/service-response-store.d.ts.map +1 -1
  34. package/core/types/kos-dependency.d.ts +13 -4
  35. package/core/types/kos-dependency.d.ts.map +1 -1
  36. package/core/types/service-response-store.d.ts +0 -4
  37. package/core/types/service-response-store.d.ts.map +1 -1
  38. package/core/util/model-utils.d.ts.map +1 -1
  39. package/{index-YzHb2lnB.js → index-Csq0zQtb.js} +358 -647
  40. package/index-Csq0zQtb.js.map +1 -0
  41. package/{index-CRb8ucfF.cjs → index-D52vEGXT.cjs} +287 -576
  42. package/index-D52vEGXT.cjs.map +1 -0
  43. package/index.cjs +317 -37
  44. package/index.cjs.map +1 -1
  45. package/index.js +382 -102
  46. package/index.js.map +1 -1
  47. package/models/models/kos-time/kos-time-model.d.ts.map +1 -1
  48. package/models/utils/services/kos/daily/service.d.ts +1 -1
  49. package/models/utils/services/kos/daily/service.d.ts.map +1 -1
  50. package/models/utils/services/vfs/daily/service.d.ts +1 -1
  51. package/models/utils/services/vfs/daily/service.d.ts.map +1 -1
  52. package/package.json +2 -2
  53. package/testing/index.d.ts +23 -2
  54. package/testing/index.d.ts.map +1 -1
  55. package/testing.cjs +22 -2
  56. package/testing.cjs.map +1 -1
  57. package/testing.js +22 -2
  58. package/testing.js.map +1 -1
  59. package/index-CRb8ucfF.cjs.map +0 -1
  60. package/index-YzHb2lnB.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"kos-time-model.d.ts","sourceRoot":"","sources":["../../../../../../packages/kos-ui-sdk/src/models/models/kos-time/kos-time-model.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,aAAa,EACb,eAAe,EACf,gBAAgB,EAChB,kBAAkB,EAClB,oBAAoB,EACrB,MAAM,eAAe,CAAC;AAIvB,OAAO,EAAE,KAAK,QAAQ,EAAE,KAAK,cAAc,EAAE,KAAK,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC5E,eAAO,MAAM,UAAU,mBAAmB,CAAC;AAM3C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqDG;AACH,MAAM,MAAM,YAAY,GAAG,oBAAoB,CAAC,gBAAgB,CAAC,CAAC;AAElE;;;GAGG;AACH,qBACa,gBAAiB,YAAW,eAAe,EAAE,aAAa;IACrE,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,gBAAgB,CAAC;IACzB,QAAQ,EAAE,MAAM,CAAC;gBAEf,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,cAAc,EACxB,OAAO,EAAE,kBAAkB;IAO7B;;;;OAIG;IACG,gBAAgB,CAAC,IAAI,EAAE,QAAQ;IAIrC;;;;OAIG;IACG,gBAAgB,CAAC,IAAI,EAAE,QAAQ;IAIrC;;;OAGG;IACG,oBAAoB,CAAC,QAAQ,EAAE,MAAM;IAK3C,gBAAgB,IAAI,IAAI;IAMxB,eAAe,IAAI,IAAI;IAMjB,oBAAoB;IAQ1B;;OAEG;IACG,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;YAIb,gBAAgB;IAI9B,WAAW,CAAC,EAAE,EAAE,MAAM;IAItB;;OAEG;IACG,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CAI5B"}
1
+ {"version":3,"file":"kos-time-model.d.ts","sourceRoot":"","sources":["../../../../../../packages/kos-ui-sdk/src/models/models/kos-time/kos-time-model.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,aAAa,EACb,eAAe,EACf,gBAAgB,EAChB,kBAAkB,EAClB,oBAAoB,EACrB,MAAM,eAAe,CAAC;AAIvB,OAAO,EAAE,KAAK,QAAQ,EAAE,KAAK,cAAc,EAAE,KAAK,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC5E,eAAO,MAAM,UAAU,mBAAmB,CAAC;AAM3C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqDG;AACH,MAAM,MAAM,YAAY,GAAG,oBAAoB,CAAC,gBAAgB,CAAC,CAAC;AAElE;;;GAGG;AACH,qBACa,gBAAiB,YAAW,eAAe,EAAE,aAAa;IACrE,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,gBAAgB,CAAC;IACzB,QAAQ,EAAE,MAAM,CAAC;gBAEf,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,cAAc,EACxB,OAAO,EAAE,kBAAkB;IAO7B;;;;OAIG;IACG,gBAAgB,CAAC,IAAI,EAAE,QAAQ;IAIrC;;;;OAIG;IACG,gBAAgB,CAAC,IAAI,EAAE,QAAQ;IAIrC;;;OAGG;IACG,oBAAoB,CAAC,QAAQ,EAAE,MAAM;IAK3C,gBAAgB,IAAI,IAAI;IAMxB,eAAe,IAAI,IAAI;IAMjB,oBAAoB;IAQ1B;;OAEG;IACG,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;YAIb,gBAAgB;IAY9B,WAAW,CAAC,EAAE,EAAE,MAAM;IAItB;;OAEG;IACG,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CAI5B"}
@@ -13,7 +13,7 @@ export type ValidPaths = PathsByMethod<paths>;
13
13
  * HttpMethod. The uppercase spellings HttpMethod also permits do not match the
14
14
  * keys of an OpenAPI `paths` object, so they would silently yield `unknown`.
15
15
  */
16
- export type SupportedMethod = "get" | "post" | "put" | "delete" | "patch";
16
+ export type SupportedMethod = "get" | "post" | "put" | "delete";
17
17
  /**
18
18
  * Get client response type for kos API
19
19
  */
@@ -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,O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;;;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
+ {"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,OA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,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"}
@@ -13,7 +13,7 @@ export type ValidPaths = PathsByMethod<paths>;
13
13
  * HttpMethod. The uppercase spellings HttpMethod also permits do not match the
14
14
  * keys of an OpenAPI `paths` object, so they would silently yield `unknown`.
15
15
  */
16
- export type SupportedMethod = "get" | "post" | "put" | "delete" | "patch";
16
+ export type SupportedMethod = "get" | "post" | "put" | "delete";
17
17
  /**
18
18
  * Get client response type for vfs API
19
19
  */
@@ -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;;;;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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,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,CAAC;AAEhE;;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,GAA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"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kosdev-code/kos-ui-sdk",
3
- "version": "3.0.24",
3
+ "version": "3.0.26",
4
4
  "type": "module",
5
5
  "main": "./index.cjs",
6
6
  "module": "./index.js",
@@ -59,7 +59,7 @@
59
59
  },
60
60
  "kos": {
61
61
  "build": {
62
- "gitHash": "ffff83a8bc286119fd7fa0acda2d1d3bcaa0e7f2"
62
+ "gitHash": "81591542fbf659141e885941c2469ef83f879c2e"
63
63
  }
64
64
  }
65
65
  }
@@ -1,4 +1,4 @@
1
- import { BaseKosModelRegistrationBean, IKosCoreManager, IKosModelRegistration, IKosRegistry, KosCompanionModelType, KosModelRegistrationType, Preloaded } from '../core';
1
+ import { BaseKosModelRegistrationBean, IKosCoreManager, IKosModelRegistration, IKosRegistry, KosCompanionModelType, KosMockFixture, KosMockPlaybackOptions, KosMockSetupModule, KosModelRegistrationType, Preloaded } from '../core';
2
2
  export interface BootKosCoreOptions {
3
3
  /** Connection alias, when the model under test cares about one. */
4
4
  alias?: string;
@@ -28,6 +28,20 @@ export interface KosCoreBootBuilder {
28
28
  legacy: (type: string, registration: IKosModelRegistration) => KosCoreBootBuilder;
29
29
  /** Connection alias, when the model under test cares about one. */
30
30
  alias: (alias: string) => KosCoreBootBuilder;
31
+ /**
32
+ * Install a KosMock setup module before boot — the same default export the
33
+ * fixture server serves from `fixtures/setups/*.mjs`, imported directly. It
34
+ * runs before the transport exists, so it registers routes, transformers,
35
+ * config injections and observers; anything it pushes belongs after boot.
36
+ */
37
+ setup: (module: KosMockSetupModule) => KosCoreBootBuilder;
38
+ /**
39
+ * Load a recorded fixture before boot — the JSON the fixture server serves,
40
+ * imported directly. Test defaults: `ignoreLatency: true` (full speed) and
41
+ * `pushes: "manual"` (the capture's topic and future timeline stays inert; a
42
+ * test pushes what it asserts on). Pass options to override either.
43
+ */
44
+ fixture: (fixture: KosMockFixture, options?: KosMockPlaybackOptions) => KosCoreBootBuilder;
31
45
  /** Boot KosCore with everything registered on this chain. */
32
46
  boot: () => Promise<IKosCoreManager>;
33
47
  }
@@ -41,11 +55,18 @@ export interface KosCoreBootBuilder {
41
55
  * file.
42
56
  *
43
57
  * Register any routes the models need BEFORE calling `boot()`, so nothing races
44
- * the boot requests.
58
+ * the boot requests — `KosMock.get(...)` above the chain, or `.setup()` /
59
+ * `.fixture()` on it.
45
60
  *
46
61
  * @example
47
62
  * ```ts
48
63
  * await bootKosCore().model(AssetManager).model(AssetEntry).boot();
64
+ *
65
+ * await bootKosCore()
66
+ * .setup(boardBaseline) // fixtures/setups/board-baseline.mjs
67
+ * .fixture(pourOk) // fixtures/pour-ok.json
68
+ * .model(Board)
69
+ * .boot();
49
70
  * ```
50
71
  */
51
72
  export declare function bootKosCore(): KosCoreBootBuilder;
@@ -1 +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"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../packages/kos-ui-sdk/src/testing/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoDG;AACH,OAAO,KAAK,EACV,4BAA4B,EAC5B,eAAe,EACf,qBAAqB,EACrB,YAAY,EACZ,qBAAqB,EACrB,cAAc,EACd,sBAAsB,EACtB,kBAAkB,EAClB,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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I,CAAC,CAQf"}
package/testing.cjs CHANGED
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  require("mobx");
4
- const service = require("./index-CRb8ucfF.cjs");
4
+ const service = require("./index-D52vEGXT.cjs");
5
5
  require("loglevel");
6
6
  let booted;
7
7
  let prepared = false;
@@ -21,8 +21,13 @@ function bootCore(registration, options) {
21
21
  }
22
22
  return booted;
23
23
  }
24
+ const FIXTURE_TEST_DEFAULTS = {
25
+ ignoreLatency: true,
26
+ pushes: "manual"
27
+ };
24
28
  function buildBootBuilder() {
25
29
  const registrations = [];
30
+ const mockInstalls = [];
26
31
  const preloadModels = [];
27
32
  let alias;
28
33
  const builder = {
@@ -55,7 +60,22 @@ function buildBootBuilder() {
55
60
  alias = value;
56
61
  return builder;
57
62
  },
58
- boot: () => {
63
+ setup: (module2) => {
64
+ mockInstalls.push(async () => {
65
+ await module2(service.KosMock);
66
+ });
67
+ return builder;
68
+ },
69
+ fixture: (fixture, options) => {
70
+ mockInstalls.push(() => {
71
+ service.KosMock.loadFixture(fixture, { ...FIXTURE_TEST_DEFAULTS, ...options });
72
+ });
73
+ return builder;
74
+ },
75
+ boot: async () => {
76
+ for (const install of mockInstalls.splice(0)) {
77
+ await install();
78
+ }
59
79
  prepareTransport(alias);
60
80
  registrations.splice(0).forEach((register) => register());
61
81
  return bootCore({ models: {}, preloadModels }, { alias });
package/testing.cjs.map CHANGED
@@ -1 +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,iBAAiB,MAAA,CAAO;AAChD;AAEA,SAAS,SACP,cACA,SAC0B;AAC1B,MAAI,CAAC,QAAQ;AACX,qBAAiB,QAAQ,KAAK;AAC9B,UAAM,OAAOA,QAAAA,QAAQ,OAAO,cAAc,OAAO,QAAQ,KAAK;AAC9D,aAAS,KAAK,UAAA,EAAY,KAAK,MAAM,IAAI;AAAA,EAC3C;AACA,SAAO;AACT;AAEA,SAAS,mBAAuC;AAC9C,QAAM,gBAAgC,CAAA;AACtC,QAAM,gBAA6B,CAAA;AACnC,MAAI;AAEJ,QAAM,UAA8B;AAAA,IAClC,OAAO,CAAC,cAAc,YAAY;AAChC,oBAAc;AAAA,QAAK,MACjBC,QAAAA,oBAAoB,MAAM,SAAS,OAAO,EAAE,cAAc,OAAO;AAAA,MAAA;AAEnE,aAAO;AAAA,IACT;AAAA,IACA,SAAS,CAAC,UAAU;AAClB,oBAAc,KAAK,KAAK;AACxB,aAAO;AAAA,IACT;AAAA,IACA,WAAW,CAAC,YAAY,cAAc;AACpC,oBAAc;AAAA,QAAK,MACjBA,QAAAA,oBAAoB,UAAU,SAAS,OAAO,EAAE,YAAY,SAAS;AAAA,MAAA;AAEvE,aAAO;AAAA,IACT;AAAA,IACA,QAAQ,CAAC,MAAM,iBAAiB;AAC9B,oBAAc;AAAA,QAAK,MACjBA,4BAAoB,MAAM,oBAAoB,OAAO;AAAA,UACnD;AAAA,UACA;AAAA,QAAA;AAAA,MACF;AAEF,aAAO;AAAA,IACT;AAAA,IACA,OAAO,CAAC,UAAU;AAChB,cAAQ;AACR,aAAO;AAAA,IACT;AAAA,IACA,MAAM,MAAM;AACV,uBAAiB,KAAK;AACtB,oBAAc,OAAO,CAAC,EAAE,QAAQ,CAAC,aAAa,UAAU;AACxD,aAAO,SAAS,EAAE,QAAQ,CAAA,GAAI,cAAA,GAAiB,EAAE,OAAO;AAAA,IAC1D;AAAA,EAAA;AAGF,SAAO;AACT;AAiCO,SAAS,YACd,cACA,UAA8B,IACiB;AAC/C,SAAO,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;;;"}
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. The chain's `.setup()`\n * and `.fixture()` install the project's committed setup modules and recorded\n * fixtures before boot, so the declarations the browser dev loop runs are the\n * ones the test runs.\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 KosMockFixture,\n KosMockPlaybackOptions,\n KosMockSetupModule,\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 /**\n * Install a KosMock setup module before boot — the same default export the\n * fixture server serves from `fixtures/setups/*.mjs`, imported directly. It\n * runs before the transport exists, so it registers routes, transformers,\n * config injections and observers; anything it pushes belongs after boot.\n */\n setup: (module: KosMockSetupModule) => KosCoreBootBuilder;\n /**\n * Load a recorded fixture before boot — the JSON the fixture server serves,\n * imported directly. Test defaults: `ignoreLatency: true` (full speed) and\n * `pushes: \"manual\"` (the capture's topic and future timeline stays inert; a\n * test pushes what it asserts on). Pass options to override either.\n */\n fixture: (\n fixture: KosMockFixture,\n options?: KosMockPlaybackOptions\n ) => 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\nconst FIXTURE_TEST_DEFAULTS: KosMockPlaybackOptions = {\n ignoreLatency: true,\n pushes: \"manual\",\n};\n\nfunction buildBootBuilder(): KosCoreBootBuilder {\n const registrations: (() => void)[] = [];\n const mockInstalls: (() => Promise<void> | 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 setup: (module) => {\n mockInstalls.push(async () => {\n await module(KosMock);\n });\n return builder;\n },\n fixture: (fixture, options) => {\n mockInstalls.push(() => {\n KosMock.loadFixture(fixture, { ...FIXTURE_TEST_DEFAULTS, ...options });\n });\n return builder;\n },\n boot: async () => {\n // Mocks first, in call order, before the transport exists — the same\n // \"routes before boot\" rule a test follows when it calls KosMock.get.\n for (const install of mockInstalls.splice(0)) {\n await install();\n }\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 — `KosMock.get(...)` above the chain, or `.setup()` /\n * `.fixture()` on it.\n *\n * @example\n * ```ts\n * await bootKosCore().model(AssetManager).model(AssetEntry).boot();\n *\n * await bootKosCore()\n * .setup(boardBaseline) // fixtures/setups/board-baseline.mjs\n * .fixture(pourOk) // fixtures/pour-ok.json\n * .model(Board)\n * .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","module"],"mappings":";;;;;AAmEA,IAAI;AACJ,IAAI,WAAW;AAyEf,SAAS,iBAAiB,OAAsB;AAC9C,MAAI,UAAU;AACZ;AAAA,EACF;AACA,aAAW;AACXA,UAAAA,QAAQ,UAAU,EAAE,YAAY,KAAA,CAAM;AACtCC,UAAAA,QAAQ,YAAY,EAAE,iBAAiB,MAAA,CAAO;AAChD;AAEA,SAAS,SACP,cACA,SAC0B;AAC1B,MAAI,CAAC,QAAQ;AACX,qBAAiB,QAAQ,KAAK;AAC9B,UAAM,OAAOA,QAAAA,QAAQ,OAAO,c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YAAY;AAGhB,iBAAW,WAAW,aAAa,OAAO,CAAC,GAAG;AAC5C,cAAM,QAAA;AAAA,MACR;AACA,uBAAiB,KAAK;AACtB,oBAAc,OAAO,CAAC,EAAE,QAAQ,CAAC,aAAa,UAAU;AACxD,aAAO,SAAS,EAAE,QAAQ,CAAA,GAAI,cAAA,GAAiB,EAAE,OAAO;AAAA,IAC1D;AAAA,EAAA;AAGF,SAAO;AACT;AAwCO,SAAS,YACd,cACA,UAA8B,IACiB;AAC/C,SAAO,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.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import "mobx";
2
- import { l as KosCore, b0 as KosMock, al as RegistrationManager } from "./index-YzHb2lnB.js";
2
+ import { l as KosCore, a$ as KosMock, al as RegistrationManager } from "./index-Csq0zQtb.js";
3
3
  import "loglevel";
4
4
  let booted;
5
5
  let prepared = false;
@@ -19,8 +19,13 @@ function bootCore(registration, options) {
19
19
  }
20
20
  return booted;
21
21
  }
22
+ const FIXTURE_TEST_DEFAULTS = {
23
+ ignoreLatency: true,
24
+ pushes: "manual"
25
+ };
22
26
  function buildBootBuilder() {
23
27
  const registrations = [];
28
+ const mockInstalls = [];
24
29
  const preloadModels = [];
25
30
  let alias;
26
31
  const builder = {
@@ -53,7 +58,22 @@ function buildBootBuilder() {
53
58
  alias = value;
54
59
  return builder;
55
60
  },
56
- boot: () => {
61
+ setup: (module) => {
62
+ mockInstalls.push(async () => {
63
+ await module(KosMock);
64
+ });
65
+ return builder;
66
+ },
67
+ fixture: (fixture, options) => {
68
+ mockInstalls.push(() => {
69
+ KosMock.loadFixture(fixture, { ...FIXTURE_TEST_DEFAULTS, ...options });
70
+ });
71
+ return builder;
72
+ },
73
+ boot: async () => {
74
+ for (const install of mockInstalls.splice(0)) {
75
+ await install();
76
+ }
57
77
  prepareTransport(alias);
58
78
  registrations.splice(0).forEach((register) => register());
59
79
  return bootCore({ models: {}, preloadModels }, { alias });
package/testing.js.map CHANGED
@@ -1 +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 * 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":[],"mappings":";;;AA6DA,IAAI;AACJ,IAAI,WAAW;AAwDf,SAAS,iBAAiB,OAAsB;AAC9C,MAAI,UAAU;AACZ;AAAA,EACF;AACA,aAAW;AACX,UAAQ,UAAU,EAAE,YAAY,KAAA,CAAM;AACtC,UAAQ,YAAY,EAAE,iBAAiB,MAAA,CAAO;AAChD;AAEA,SAAS,SACP,cACA,SAC0B;AAC1B,MAAI,CAAC,QAAQ;AACX,qBAAiB,QAAQ,KAAK;AAC9B,UAAM,OAAO,QAAQ,OAAO,cAAc,OAAO,QAAQ,KAAK;AAC9D,aAAS,KAAK,UAAA,EAAY,KAAK,MAAM,IAAI;AAAA,EAC3C;AACA,SAAO;AACT;AAEA,SAAS,mBAAuC;AAC9C,QAAM,gBAAgC,CAAA;AACtC,QAAM,gBAA6B,CAAA;AACnC,MAAI;AAEJ,QAAM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-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. The chain's `.setup()`\n * and `.fixture()` install the project's committed setup modules and recorded\n * fixtures before boot, so the declarations the browser dev loop runs are the\n * ones the test runs.\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 KosMockFixture,\n KosMockPlaybackOptions,\n KosMockSetupModule,\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 /**\n * Install a KosMock setup module before boot — the same default export the\n * fixture server serves from `fixtures/setups/*.mjs`, imported directly. It\n * runs before the transport exists, so it registers routes, transformers,\n * config injections and observers; anything it pushes belongs after boot.\n */\n setup: (module: KosMockSetupModule) => KosCoreBootBuilder;\n /**\n * Load a recorded fixture before boot — the JSON the fixture server serves,\n * imported directly. Test defaults: `ignoreLatency: true` (full speed) and\n * `pushes: \"manual\"` (the capture's topic and future timeline stays inert; a\n * test pushes what it asserts on). Pass options to override either.\n */\n fixture: (\n fixture: KosMockFixture,\n options?: KosMockPlaybackOptions\n ) => 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\nconst FIXTURE_TEST_DEFAULTS: KosMockPlaybackOptions = {\n ignoreLatency: true,\n pushes: \"manual\",\n};\n\nfunction buildBootBuilder(): KosCoreBootBuilder {\n const registrations: (() => void)[] = [];\n const mockInstalls: (() => Promise<void> | 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 setup: (module) => {\n mockInstalls.push(async () => {\n await module(KosMock);\n });\n return builder;\n },\n fixture: (fixture, options) => {\n mockInstalls.push(() => {\n KosMock.loadFixture(fixture, { ...FIXTURE_TEST_DEFAULTS, ...options });\n });\n return builder;\n },\n boot: async () => {\n // Mocks first, in call order, before the transport exists — the same\n // \"routes before boot\" rule a test follows when it calls KosMock.get.\n for (const install of mockInstalls.splice(0)) {\n await install();\n }\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 — `KosMock.get(...)` above the chain, or `.setup()` /\n * `.fixture()` on it.\n *\n * @example\n * ```ts\n * await bootKosCore().model(AssetManager).model(AssetEntry).boot();\n *\n * await bootKosCore()\n * .setup(boardBaseline) // fixtures/setups/board-baseline.mjs\n * .fixture(pourOk) // fixtures/pour-ok.json\n * .model(Board)\n * .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":[],"mappings":";;;AAmEA,IAAI;AACJ,IAAI,WAAW;AAyEf,SAAS,iBAAiB,OAAsB;AAC9C,MAAI,UAAU;AACZ;AAAA,EACF;AACA,aAAW;AACX,UAAQ,UAAU,EAAE,YAAY,KAAA,CAAM;AACtC,UAAQ,YAAY,EAAE,iBAAiB,MAAA,CAAO;AAChD;AAEA,SAAS,SACP,cACA,SAC0B;AAC1B,MAAI,CAAC,QAAQ;AACX,qBAAiB,QAAQ,KAAK;AAC9B,UAAM,OAAO,QAAQ,OAAO,cAAc,OAAO,QAAQ,KAAK;AAC9D,aAAS,KAAK,UAAA,EAAY,KAAK,MAAM,IAAI;AAAA,EAC3C;AACA,SAAO;AACT;AAEA,MAAM,wBAAgD;AAAA,EACpD,eAAe;AAAA,EACf,QAAQ;AACV;AAEA,SAAS,mBAAuC;AAC9C,QAAM,gBAAgC,CAAA;AACtC,QAAM,eAA+C,CAAA;AACrD,QAAM,gBAA6B,CAAA;AACnC,MAAI;AAEJ,QAAM,UAA8B;AAAA,IAClC,OAAO,CAAC,cAAc,YAAY;AAChC,oBAAc;AAAA,QAAK,MACjB,oBAAoB,MAAM,SAAS,OAAO,EAAE,cAAc,OAAO;AAAA,MAAA;AAEnE,aAAO;AAAA,IACT;AAAA,IACA,SAAS,CAAC,UAAU;AAClB,oBAAc,KAAK,KAAK;AACxB,aAAO;AAAA,IACT;AAAA,IACA,WAAW,CAAC,YAAY,cAAc;AACpC,oBAAc;AAAA,QAAK,MACjB,oBAAoB,UAAU,SAAS,OAAO,EAAE,YAAY,SAAS;AAAA,MAAA;AAEvE,aAAO;AAAA,IACT;AAAA,IACA,QAAQ,CAAC,MAAM,iBAAiB;AAC9B,oBAAc;AAAA,QAAK,MACjB,oBAAoB,MA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