@kosdev-code/kos-ui-sdk 0.1.0-dev.5053 → 0.1.0-dev.5072
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/core/core/decorators/index.d.ts +2 -0
- package/core/core/decorators/index.d.ts.map +1 -1
- package/core/core/decorators/kos-execution-context.d.ts +60 -0
- package/core/core/decorators/kos-execution-context.d.ts.map +1 -0
- package/core/core/decorators/kos-service-request.d.ts +381 -0
- package/core/core/decorators/kos-service-request.d.ts.map +1 -0
- package/core/core/decorators/kosTopicHandler.d.ts +33 -5
- package/core/core/decorators/kosTopicHandler.d.ts.map +1 -1
- package/core/core/kosModel.d.ts +2 -0
- package/core/core/kosModel.d.ts.map +1 -1
- package/core/core/model/kos-model-component-factory.d.ts +4 -0
- package/core/core/model/kos-model-component-factory.d.ts.map +1 -1
- package/core/core/model/kos-offline-queue.d.ts +78 -1
- package/core/core/model/kos-offline-queue.d.ts.map +1 -1
- package/core/core/model/kos-service-request-manager.d.ts +102 -0
- package/core/core/model/kos-service-request-manager.d.ts.map +1 -0
- package/core/core/model/kos-subscription-manager.d.ts +18 -0
- package/core/core/model/kos-subscription-manager.d.ts.map +1 -1
- package/core/core/model/model-introspection-utils.d.ts +1 -0
- package/core/core/model/model-introspection-utils.d.ts.map +1 -1
- package/core/core/model/service-response-store.d.ts +164 -0
- package/core/core/model/service-response-store.d.ts.map +1 -0
- package/core/types/index.d.ts +1 -0
- package/core/types/index.d.ts.map +1 -1
- package/core/types/service-response-store.d.ts +152 -0
- package/core/types/service-response-store.d.ts.map +1 -0
- package/core/util/index.d.ts +1 -0
- package/core/util/index.d.ts.map +1 -1
- package/core/util/kos-service-request.d.ts +8 -0
- package/core/util/kos-service-request.d.ts.map +1 -1
- package/core/util/service-response.d.ts +110 -0
- package/core/util/service-response.d.ts.map +1 -0
- package/index.cjs +77 -77
- package/index.cjs.map +1 -1
- package/index.js +7721 -6766
- package/index.js.map +1 -1
- package/models/decorators/future-service.d.ts +7 -0
- package/models/decorators/future-service.d.ts.map +1 -1
- package/models/utils/service.d.ts +58 -2
- package/models/utils/service.d.ts.map +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { IKosDataModel } from '../core/kosModel';
|
|
2
|
+
import { ApiPath, HttpMethod } from '../core/decorators/kos-service-request';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Utility functions for accessing cached service responses from ServiceResponseStore
|
|
6
|
+
*
|
|
7
|
+
* These functions provide type-safe access to responses stored by @kosServiceRequest
|
|
8
|
+
* decorated methods, eliminating the need for "magic last parameter" patterns.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* @kosServiceRequest({
|
|
13
|
+
* path: PATH_INGREDIENTS,
|
|
14
|
+
* method: 'get',
|
|
15
|
+
* lifecycle: DependencyLifecycle.LOAD
|
|
16
|
+
* })
|
|
17
|
+
* private onIngredientsLoaded(): void {
|
|
18
|
+
* const response = getServiceResponse(this, PATH_INGREDIENTS, 'get');
|
|
19
|
+
* this.processIngredients(response.data.ingredients);
|
|
20
|
+
* }
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
/**
|
|
24
|
+
* Get cached service response by path and method
|
|
25
|
+
*
|
|
26
|
+
* Returns the response data cached by @kosServiceRequest decorated methods.
|
|
27
|
+
* TypeScript will infer types from your OpenAPI schema when using typed path constants.
|
|
28
|
+
*
|
|
29
|
+
* For cross-package scenarios where OpenAPI specs differ, you can optionally
|
|
30
|
+
* provide an explicit type parameter.
|
|
31
|
+
*
|
|
32
|
+
* @param model - The KOS model instance
|
|
33
|
+
* @param path - The API path constant
|
|
34
|
+
* @param method - The HTTP method (defaults to 'get')
|
|
35
|
+
* @returns The cached response data, or undefined if not found/expired
|
|
36
|
+
*
|
|
37
|
+
* @example Standard usage (types inferred from OpenAPI)
|
|
38
|
+
* ```typescript
|
|
39
|
+
* const status = getServiceResponse(this, PATH_DEVICE_STATUS, 'get');
|
|
40
|
+
* // TypeScript infers the type from PATH_DEVICE_STATUS
|
|
41
|
+
* ```
|
|
42
|
+
*
|
|
43
|
+
* @example Cross-package usage with explicit type (when OpenAPI schemas differ)
|
|
44
|
+
* ```typescript
|
|
45
|
+
* // Studio models using different OpenAPI than main SDK
|
|
46
|
+
* const vms = getServiceResponse<StudioVMResponse>(this, PATH_VMS, 'get');
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
export declare function getServiceResponse<T = any>(model: IKosDataModel, path: ApiPath, method?: HttpMethod): T | undefined;
|
|
50
|
+
/**
|
|
51
|
+
* Check if a cached response exists for the given path and method
|
|
52
|
+
*
|
|
53
|
+
* @param model - The KOS model instance
|
|
54
|
+
* @param path - The API path constant
|
|
55
|
+
* @param method - The HTTP method (defaults to 'get')
|
|
56
|
+
* @returns true if a valid cached response exists
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* ```typescript
|
|
60
|
+
* if (hasCachedResponse(this, PATH_DEVICE_STATUS, 'get')) {
|
|
61
|
+
* // Use cached data
|
|
62
|
+
* const status = getServiceResponse(this, PATH_DEVICE_STATUS, 'get');
|
|
63
|
+
* } else {
|
|
64
|
+
* // Fetch fresh data
|
|
65
|
+
* await this.refreshStatus();
|
|
66
|
+
* }
|
|
67
|
+
* ```
|
|
68
|
+
*/
|
|
69
|
+
export declare function hasCachedResponse(model: IKosDataModel, path: ApiPath, method?: HttpMethod): boolean;
|
|
70
|
+
/**
|
|
71
|
+
* Manually clear a cached service response
|
|
72
|
+
*
|
|
73
|
+
* @param model - The KOS model instance
|
|
74
|
+
* @param path - The API path constant
|
|
75
|
+
* @param method - The HTTP method (defaults to 'get')
|
|
76
|
+
*
|
|
77
|
+
* @example
|
|
78
|
+
* ```typescript
|
|
79
|
+
* // Clear cached response to force refresh on next request
|
|
80
|
+
* clearServiceResponse(this, PATH_TEMP_DATA, 'post');
|
|
81
|
+
* ```
|
|
82
|
+
*/
|
|
83
|
+
export declare function clearServiceResponse(model: IKosDataModel, path: ApiPath, method?: HttpMethod): void;
|
|
84
|
+
/**
|
|
85
|
+
* Clear all cached responses for a specific path (all methods)
|
|
86
|
+
*
|
|
87
|
+
* @param model - The KOS model instance
|
|
88
|
+
* @param path - The API path constant
|
|
89
|
+
*
|
|
90
|
+
* @example
|
|
91
|
+
* ```typescript
|
|
92
|
+
* // Clear all cached responses for this endpoint
|
|
93
|
+
* clearPath(this, PATH_INGREDIENTS);
|
|
94
|
+
* // Clears GET, POST, PUT, DELETE responses for this path
|
|
95
|
+
* ```
|
|
96
|
+
*/
|
|
97
|
+
export declare function clearPath(model: IKosDataModel, path: ApiPath): void;
|
|
98
|
+
/**
|
|
99
|
+
* Clear all cached service responses in the model
|
|
100
|
+
*
|
|
101
|
+
* @param model - The KOS model instance
|
|
102
|
+
*
|
|
103
|
+
* @example
|
|
104
|
+
* ```typescript
|
|
105
|
+
* // Clear all cached responses (typically during model cleanup)
|
|
106
|
+
* clearAllServiceResponses(this);
|
|
107
|
+
* ```
|
|
108
|
+
*/
|
|
109
|
+
export declare function clearAllServiceResponses(model: IKosDataModel): void;
|
|
110
|
+
//# sourceMappingURL=service-response.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service-response.d.ts","sourceRoot":"","sources":["../../../../../../packages/sdk/kos-ui-sdk/src/core/util/service-response.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,OAAO,EACP,UAAU,EACX,MAAM,wCAAwC,CAAC;AAChD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEtD;;;;;;;;;;;;;;;;;;GAkBG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,GAAG,GAAG,EACxC,KAAK,EAAE,aAAa,EACpB,IAAI,EAAE,OAAO,EACb,MAAM,GAAE,UAAkB,GACzB,CAAC,GAAG,SAAS,CAOf;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,aAAa,EACpB,IAAI,EAAE,OAAO,EACb,MAAM,GAAE,UAAkB,GACzB,OAAO,CAOT;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,aAAa,EACpB,IAAI,EAAE,OAAO,EACb,MAAM,GAAE,UAAkB,GACzB,IAAI,CAON;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,aAAa,EAAE,IAAI,EAAE,OAAO,GAAG,IAAI,CAOnE;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,aAAa,GAAG,IAAI,CAOnE"}
|