@kosdev-code/kos-dispense-sdk 2.0.44 → 2.0.45

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 (121) hide show
  1. package/dispense-registration-manager-C7GGaZ47.js +2673 -0
  2. package/dispense-registration-manager-C7GGaZ47.js.map +1 -0
  3. package/dispense-registration-manager-lQhkTFKW.cjs +2671 -0
  4. package/dispense-registration-manager-lQhkTFKW.cjs.map +1 -0
  5. package/extension-utils-50g2ril2.cjs +500 -0
  6. package/extension-utils-50g2ril2.cjs.map +1 -0
  7. package/extension-utils-Dt00FOJq.js +501 -0
  8. package/extension-utils-Dt00FOJq.js.map +1 -0
  9. package/extensions/control-pour-extension.d.ts +70 -0
  10. package/extensions/control-pour-extension.d.ts.map +1 -0
  11. package/extensions/index.d.ts +2 -0
  12. package/extensions/index.d.ts.map +1 -0
  13. package/index.cjs +142 -1
  14. package/index.cjs.map +1 -1
  15. package/index.d.ts +2 -1
  16. package/index.d.ts.map +1 -1
  17. package/index.js +133 -103
  18. package/index.js.map +1 -1
  19. package/kos-models.json +180 -0
  20. package/models/models/assembly/assembly-model.d.ts +4 -0
  21. package/models/models/assembly/assembly-model.d.ts.map +1 -1
  22. package/models/models/assembly/pump-utils.d.ts.map +1 -1
  23. package/models/models/availability/availability-model.d.ts.map +1 -1
  24. package/models/models/board/board-container-model.d.ts +4 -0
  25. package/models/models/board/board-container-model.d.ts.map +1 -1
  26. package/models/models/board/board-model.d.ts +4 -0
  27. package/models/models/board/board-model.d.ts.map +1 -1
  28. package/models/models/device-assembly/device-assembly-model.d.ts +4 -0
  29. package/models/models/device-assembly/device-assembly-model.d.ts.map +1 -1
  30. package/models/models/generic-pour/generic-pour-model.d.ts +54 -13
  31. package/models/models/generic-pour/generic-pour-model.d.ts.map +1 -1
  32. package/models/models/generic-pour/index.d.ts +2 -2
  33. package/models/models/generic-pour/index.d.ts.map +1 -1
  34. package/models/models/generic-pour/types/index.d.ts +1 -0
  35. package/models/models/holder/holder-model.d.ts.map +1 -1
  36. package/models/models/holder-container/holder-container-model.d.ts.map +1 -1
  37. package/models/models/ingredient/ingredient-model.d.ts.map +1 -1
  38. package/models/models/ingredient-container/ingredient-container-model.d.ts.map +1 -1
  39. package/models/models/nozzle/index.d.ts +1 -1
  40. package/models/models/nozzle/index.d.ts.map +1 -1
  41. package/models/models/nozzle/nozzle-model.d.ts +28 -9
  42. package/models/models/nozzle/nozzle-model.d.ts.map +1 -1
  43. package/models/models/nozzle/types/index.d.ts +8 -0
  44. package/models/models/pump/pump-model.d.ts.map +1 -1
  45. package/models/models/pump/types/index.d.ts +7 -2
  46. package/models/models/pump-container/pump-container-model.d.ts.map +1 -1
  47. package/models/models/types/assembly.d.ts +4 -0
  48. package/models/models/types/assembly.d.ts.map +1 -1
  49. package/models/models/types/intent.d.ts +98 -0
  50. package/models/models/types/intent.d.ts.map +1 -1
  51. package/models/models/types/pouring.d.ts +1 -3
  52. package/models/models/types/pouring.d.ts.map +1 -1
  53. package/models/utils/dispense-registration-manager.d.ts +2 -2
  54. package/models/utils/extension-utils.d.ts +90 -18
  55. package/models/utils/extension-utils.d.ts.map +1 -1
  56. package/models/utils/openapi-index.d.ts +2 -0
  57. package/models/utils/openapi-index.d.ts.map +1 -0
  58. package/models/utils/service.d.ts +16 -12
  59. package/models/utils/service.d.ts.map +1 -1
  60. package/models/utils/services/dispense/1.6.5/openapi.d.ts +845 -0
  61. package/models/utils/services/dispense/1.6.5/service.d.ts +122 -0
  62. package/models/utils/services/dispense/1.6.5/service.d.ts.map +1 -0
  63. package/models/utils/services/dispense/1.8.1/openapi.d.ts +1653 -0
  64. package/models/utils/services/dispense/1.8.1/service.d.ts +122 -0
  65. package/models/utils/services/dispense/1.8.1/service.d.ts.map +1 -0
  66. package/models/utils/services/dispense/daily/openapi.d.ts +1820 -0
  67. package/models/utils/services/dispense/daily/service.d.ts +122 -0
  68. package/models/utils/services/dispense/daily/service.d.ts.map +1 -0
  69. package/models/utils/services-index.d.ts +4 -0
  70. package/models/utils/services-index.d.ts.map +1 -0
  71. package/models.cjs +47 -1
  72. package/models.cjs.map +1 -1
  73. package/models.js +40 -37
  74. package/package.json +19 -2
  75. package/pump-provider-CBFev3qg.cjs +1824 -0
  76. package/pump-provider-CBFev3qg.cjs.map +1 -0
  77. package/pump-provider-DyxEmFRT.js +1825 -0
  78. package/pump-provider-DyxEmFRT.js.map +1 -0
  79. package/ui/contexts/cui-kit/cui-kit.d.ts +4 -4
  80. package/ui/contexts/cui-kit/cui-kit.d.ts.map +1 -1
  81. package/ui/hooks/cui-kit/dispense-topics.d.ts +47 -0
  82. package/ui/hooks/cui-kit/dispense-topics.d.ts.map +1 -0
  83. package/ui/hooks/cui-kit/use-beverages.d.ts +3 -2
  84. package/ui/hooks/cui-kit/use-beverages.d.ts.map +1 -1
  85. package/ui/hooks/cui-kit/use-brands.d.ts +1 -1
  86. package/ui/hooks/cui-kit/use-brands.d.ts.map +1 -1
  87. package/ui/hooks/cui-kit/use-cui-kit.d.ts +3 -2
  88. package/ui/hooks/cui-kit/use-cui-kit.d.ts.map +1 -1
  89. package/ui/hooks/cui-kit/use-dispense-lifecycle.d.ts +2 -1
  90. package/ui/hooks/cui-kit/use-dispense-lifecycle.d.ts.map +1 -1
  91. package/ui/hooks/cui-kit/use-flavors.d.ts +1 -1
  92. package/ui/hooks/cui-kit/use-flavors.d.ts.map +1 -1
  93. package/ui/hooks/generic-pour/use-generic-pour.d.ts +3 -2
  94. package/ui/hooks/generic-pour/use-generic-pour.d.ts.map +1 -1
  95. package/ui/hooks/nozzle-pour/use-nozzle-pour.d.ts +6 -2
  96. package/ui/hooks/nozzle-pour/use-nozzle-pour.d.ts.map +1 -1
  97. package/ui/hooks/pour/use-pour.d.ts +8 -3
  98. package/ui/hooks/pour/use-pour.d.ts.map +1 -1
  99. package/ui/hooks/utils/pour-strategy/hold-to-pour-strategy.d.ts.map +1 -1
  100. package/ui/hooks/utils/pour-strategy/pour-strategy.d.ts +2 -9
  101. package/ui/hooks/utils/pour-strategy/pour-strategy.d.ts.map +1 -1
  102. package/ui/hooks/utils/pour-strategy/tap-to-pour-strategy.d.ts.map +1 -1
  103. package/ui/index.d.ts +1 -0
  104. package/ui/index.d.ts.map +1 -1
  105. package/ui/utils/pour-context.d.ts +8 -0
  106. package/ui/utils/pour-context.d.ts.map +1 -0
  107. package/ui.cjs +73 -1
  108. package/ui.cjs.map +1 -1
  109. package/ui.js +66 -65
  110. package/dispense-registration-manager-B6nEgoFC.js +0 -1960
  111. package/dispense-registration-manager-B6nEgoFC.js.map +0 -1
  112. package/dispense-registration-manager-CFnZNxso.cjs +0 -2
  113. package/dispense-registration-manager-CFnZNxso.cjs.map +0 -1
  114. package/extension-utils-CtCTSFBg.js +0 -381
  115. package/extension-utils-CtCTSFBg.js.map +0 -1
  116. package/extension-utils-DupW7Vca.cjs +0 -2
  117. package/extension-utils-DupW7Vca.cjs.map +0 -1
  118. package/pump-provider-BWzCQ8mL.js +0 -1238
  119. package/pump-provider-BWzCQ8mL.js.map +0 -1
  120. package/pump-provider-vk4pL4O3.cjs +0 -2
  121. package/pump-provider-vk4pL4O3.cjs.map +0 -1
@@ -0,0 +1,501 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
+ var __publicField = (obj, key, value) => {
4
+ __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
5
+ return value;
6
+ };
7
+ import { p as getIngredients, q as addAssignment, s as assignHolderIngredient, t as deleteAssignment, u as getAssignments, v as getHolders, w as replaceLine, x as sendRfidOverride, y as unassignHolderIngredient, z as getAssembly, F as getIntentVolume, J as sendIntent, L as clearPourable, M as getAvailability, O as pourNamedPourable, Q as pourPourable, R as selectPourable, S as pourOnTarget, E as ExtensionType } from "./dispense-registration-manager-C7GGaZ47.js";
8
+ import { kosAutoEffect, CoreExtensionManager, ExtensionManager, EXTENSION_FEATURE_FLAG_RESOLVER } from "@kosdev-code/kos-ui-sdk";
9
+ import { useState, useEffect } from "react";
10
+ const index$5 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
11
+ __proto__: null,
12
+ getIngredients
13
+ }, Symbol.toStringTag, { value: "Module" }));
14
+ const index$4 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
15
+ __proto__: null,
16
+ addAssignment,
17
+ assignHolderIngredient,
18
+ deleteAssignment,
19
+ getAssignments,
20
+ getHolders,
21
+ replaceLine,
22
+ sendRfidOverride,
23
+ unassignHolderIngredient
24
+ }, Symbol.toStringTag, { value: "Module" }));
25
+ const index$3 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
26
+ __proto__: null,
27
+ getAssembly
28
+ }, Symbol.toStringTag, { value: "Module" }));
29
+ const index$2 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
30
+ __proto__: null,
31
+ getIntentVolume,
32
+ sendIntent
33
+ }, Symbol.toStringTag, { value: "Module" }));
34
+ const index$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
35
+ __proto__: null,
36
+ clearPourable,
37
+ getAvailability,
38
+ pourNamedPourable,
39
+ pourPourable,
40
+ selectPourable
41
+ }, Symbol.toStringTag, { value: "Module" }));
42
+ const assembly = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
43
+ __proto__: null
44
+ }, Symbol.toStringTag, { value: "Module" }));
45
+ const index = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
46
+ __proto__: null,
47
+ pourOnTarget
48
+ }, Symbol.toStringTag, { value: "Module" }));
49
+ const getFuelGaugeValue = (holder) => {
50
+ var _a, _b, _c, _d;
51
+ const [maxVolume, setMaxVolume] = useState(
52
+ ((_a = holder == null ? void 0 : holder.slice) == null ? void 0 : _a.maxVolMl) ?? 0
53
+ );
54
+ const [remainingVolume, setRemainingVolume] = useState(
55
+ ((_b = holder == null ? void 0 : holder.slice) == null ? void 0 : _b.currentVolMl) ?? 0
56
+ );
57
+ const [hasMaxVolume, setHasMaxVolume] = useState(
58
+ ((_c = holder == null ? void 0 : holder.slice) == null ? void 0 : _c.maxVolMl) !== void 0
59
+ );
60
+ const [hasRemainingVolume, setHasRemainingVolume] = useState(
61
+ ((_d = holder == null ? void 0 : holder.slice) == null ? void 0 : _d.currentVolMl) !== void 0
62
+ );
63
+ const [fillPercent, setFillPercent] = useState(
64
+ remainingVolume <= 0 ? 0 : Math.floor((remainingVolume || 1) / (maxVolume || 1) * 100)
65
+ );
66
+ const [hasFuelGuage, setHasFuelGuage] = useState(
67
+ hasMaxVolume && hasRemainingVolume
68
+ );
69
+ useEffect(() => {
70
+ const disposer = kosAutoEffect(() => {
71
+ var _a2, _b2, _c2, _d2;
72
+ setMaxVolume(((_a2 = holder == null ? void 0 : holder.slice) == null ? void 0 : _a2.maxVolMl) ?? 0);
73
+ setRemainingVolume(((_b2 = holder == null ? void 0 : holder.slice) == null ? void 0 : _b2.currentVolMl) ?? 0);
74
+ setHasMaxVolume(((_c2 = holder == null ? void 0 : holder.slice) == null ? void 0 : _c2.maxVolMl) !== void 0);
75
+ setHasRemainingVolume(((_d2 = holder == null ? void 0 : holder.slice) == null ? void 0 : _d2.currentVolMl) !== void 0);
76
+ setFillPercent(
77
+ remainingVolume <= 0 ? 0 : Math.floor((remainingVolume || 1) / (maxVolume || 1) * 100)
78
+ );
79
+ setHasFuelGuage(hasMaxVolume && hasRemainingVolume);
80
+ });
81
+ return () => {
82
+ disposer();
83
+ };
84
+ }, [holder]);
85
+ return { maxVolume, remainingVolume, fillPercent, hasFuelGuage };
86
+ };
87
+ class DispenseExtensionManager {
88
+ constructor() {
89
+ __publicField(this, "core", new CoreExtensionManager());
90
+ }
91
+ /**
92
+ * Maps data into the {@link IngredientModel}
93
+ *
94
+ * It is common for the ingredient data provided by the ingredient service to be augmented with additional properties that are
95
+ * not provided by the base KOS Ingredient model. The {@link IngredientMapper} extension point allows for the data to be mapped
96
+ * into the {@link IngredientModel} and the {@link IngredientModel.data} property to be augmented with additional properties.
97
+ *
98
+ * @param ingredientDataMapper - Mapping function that maps an {@link IngredientResponse} into additional model data
99
+ * @param options - Optional {@link ExtensionOptions} to control failure behavior.
100
+ * Defaults to `failurePolicy: "throw"`, which throws an {@link ExtensionException} on mapper failure.
101
+ * Set to `"continue"` to log the error and continue processing remaining mappers.
102
+ * @returns this instance for chaining
103
+ *
104
+ * @example
105
+ * The following example shows how to map the data from the service response into the {@link IngredientModel}.
106
+ * The context is provided by the {@link IngredientLoader} extension point with its data being used to optionally augment the
107
+ * ingredient data.
108
+ *
109
+ * The result of the mapping will be available in the `data` property of the {@link IngredientModel}.
110
+ *
111
+ * In this case the `IngedientReponseData` interface represents the data being returned by the ingredient service and the
112
+ * `IngredientData` interface represents the data that will be available in the {@link IngredientModel.data} property. The `ingredientDataMapper`
113
+ * is responsible for mapping from one format to the other.
114
+ *
115
+ * ```typescript
116
+ *
117
+ * interface IngredientResponseData extends NozzleServices.IngredientResponse {
118
+ * chilled: boolean;
119
+ * carbonated: boolean;
120
+ * highYield: boolean;
121
+ * }
122
+ *
123
+ * interface IngredientData {
124
+ * chilled: boolean;
125
+ * carbonated: boolean;
126
+ * highYield: boolean;
127
+ * }
128
+ *
129
+ * export const ingredientDataMapper = async (
130
+ * data: IngredientResponseData,
131
+ * context: IngredientContext
132
+ * ): Promise<IngredientData> => {
133
+ * return {
134
+ * chilled: data.chilled,
135
+ * carbonated: data.carbonated,
136
+ * highYield: data.highYield,
137
+ * }
138
+ * }
139
+ * ```
140
+ * */
141
+ registerIngredientDataMapper(ingredientDataMapper, options) {
142
+ ExtensionManager.dataMapper.registerDataMapper(
143
+ ExtensionType.IngredientMapper,
144
+ ingredientDataMapper,
145
+ options
146
+ );
147
+ return this;
148
+ }
149
+ /**
150
+ * Loads data that will be provided as context into the {@link IngredientMapper}.
151
+ *
152
+ * @param ingredientLoader - Async function that loads and returns ingredient context data
153
+ * @param options - Optional {@link ExtensionOptions} to control failure behavior.
154
+ * Defaults to `failurePolicy: "throw"`, which throws an {@link ExtensionException} on loader failure.
155
+ * Set to `"continue"` to log the error and return `undefined` instead.
156
+ * @returns this instance for chaining
157
+ *
158
+ * @example
159
+ * The following example shows how to load the brandset data, normalize it into a map and then provide it back to the framework
160
+ * where it can be used by the other extension points.
161
+ *
162
+ * In the ingredient container model, the data is provided to the {@link IngredientMapper} extension point in order to augment ingredient data
163
+ * and also loaded into the ingredient container model context in order to make the data available throughout the code.
164
+ *
165
+ * ```typescript
166
+ * export const ingredientContextLoader = async (): Promise<BeverageContext> => {
167
+ * const response = await kosFetch('kos:/system/some/ingredient/endpoint.json');
168
+ *
169
+ * if (response.status !== 200) {
170
+ * KosLog.error('Failed to load ingredient data');
171
+ * return {};
172
+ * }
173
+ * const json = await response.json();
174
+ * return json;
175
+ * };
176
+ * ```
177
+ * */
178
+ registerIngredientLoader(ingredientLoader, options) {
179
+ ExtensionManager.loader.registerLoader(
180
+ ExtensionType.IngredientLoader,
181
+ ingredientLoader,
182
+ options
183
+ );
184
+ return this;
185
+ }
186
+ registerIngredientIndex(ingredientIndex) {
187
+ ExtensionManager.indexExtension.registerIndexExtension(
188
+ ExtensionType.IngredientIndex,
189
+ ingredientIndex
190
+ );
191
+ return this;
192
+ }
193
+ /**
194
+ * Registers a property mapper that derives the `type` property of the {@link IngredientModel}
195
+ * from an {@link IngredientResponse}.
196
+ *
197
+ * @param ingredientTypeMapper - Mapping function that extracts a type string from an {@link IngredientResponse}
198
+ * @param options - Optional {@link ExtensionOptions} to control failure behavior.
199
+ * Defaults to `failurePolicy: "throw"`, which throws an {@link ExtensionException} on mapper failure.
200
+ * Set to `"continue"` to log the error and return a fallback value instead.
201
+ * @returns this instance for chaining
202
+ * */
203
+ registerIngredientTypeMapper(ingredientTypeMapper, options) {
204
+ ExtensionManager.propertyMapper.registerPropertyMapper(
205
+ ExtensionType.IngredientTypeMapper,
206
+ ingredientTypeMapper,
207
+ options
208
+ );
209
+ return this;
210
+ }
211
+ /**
212
+ * Registers a data mapper for the {@link HolderModel} model.
213
+ *
214
+ * @param holderDataMapper - Mapping function that maps additional data from a {@link HolderResponse}
215
+ * @param options - Optional {@link ExtensionOptions} to control failure behavior.
216
+ * Defaults to `failurePolicy: "throw"`, which throws an {@link ExtensionException} on mapper failure.
217
+ * Set to `"continue"` to log the error and continue processing remaining mappers.
218
+ * @returns this instance for chaining
219
+ */
220
+ registerHolderDataMapper(holderDataMapper, options) {
221
+ ExtensionManager.dataMapper.registerDataMapper(
222
+ ExtensionType.HolderMapper,
223
+ holderDataMapper,
224
+ options
225
+ );
226
+ return this;
227
+ }
228
+ /**
229
+ * Registers a property mapper that derives the `type` property of the {@link HolderModel}
230
+ * from a {@link HolderResponse}.
231
+ *
232
+ * @param holderTypeMapper - Mapping function that extracts a type string from a {@link HolderResponse}
233
+ * @param options - Optional {@link ExtensionOptions} to control failure behavior.
234
+ * Defaults to `failurePolicy: "throw"`, which throws an {@link ExtensionException} on mapper failure.
235
+ * Set to `"continue"` to log the error and return a fallback value instead.
236
+ * @returns this instance for chaining
237
+ */
238
+ registerHolderTypeMapper(holderTypeMapper, options) {
239
+ ExtensionManager.propertyMapper.registerPropertyMapper(
240
+ ExtensionType.HolderTypeMapper,
241
+ holderTypeMapper,
242
+ options
243
+ );
244
+ return this;
245
+ }
246
+ /**
247
+ * Maps the ingredientId property of the holder into the {@link HolderModel}.
248
+ * If not provided, the ingredientId will assume that the value is mapped from the
249
+ * ingredientId property of the service response.
250
+ *
251
+ * @param holderTypeMapper - Mapping function that extracts the ingredientId from a {@link HolderResponse}
252
+ * @param options - Optional {@link ExtensionOptions} to control failure behavior.
253
+ * Defaults to `failurePolicy: "throw"`, which throws an {@link ExtensionException} on mapper failure.
254
+ * Set to `"continue"` to log the error and return a fallback value instead.
255
+ * @returns this instance for chaining
256
+ * */
257
+ registerHolderIngredientMapper(holderTypeMapper, options) {
258
+ ExtensionManager.propertyMapper.registerPropertyMapper(
259
+ ExtensionType.HolderTypeMapper,
260
+ holderTypeMapper,
261
+ options
262
+ );
263
+ return this;
264
+ }
265
+ registerHolderIndex(holderIndex) {
266
+ ExtensionManager.indexExtension.registerIndexExtension(
267
+ ExtensionType.HolderIndex,
268
+ holderIndex
269
+ );
270
+ return this;
271
+ }
272
+ /**
273
+ * Maps data into the {@link AvailabilityModel}.
274
+ *
275
+ * @param availabilityMapper - Mapping function that maps a {@link GroupBeverageResponse} into additional availability data
276
+ * @param options - Optional {@link ExtensionOptions} to control failure behavior.
277
+ * Defaults to `failurePolicy: "throw"`, which throws an {@link ExtensionException} on mapper failure.
278
+ * Set to `"continue"` to log the error and continue processing remaining mappers.
279
+ * @returns this instance for chaining
280
+ *
281
+ * @example
282
+ * The following example shows how to map the data from the service response into the {@link AvailabilityModel}.
283
+ * The context is provided by the {@link AvailabilityLoader} extension point with its data being used to augment the
284
+ * availability data.
285
+ *
286
+ * The result of the mapping will be available in the `data` property of the {@link AvailabilityModel}.
287
+ *
288
+ * ```typescript
289
+ * export const beverageDataMapper = async (
290
+ * data: NozzleServices.BeverageResponse,
291
+ * context: BeverageContext
292
+ * ): Promise<BeverageData> => {
293
+ * const id = data.altId;
294
+ * const iconUrl = encodeURI(
295
+ * `http://localhost:8081/system/brandset/${context?.[id]?.icon}`
296
+ * );
297
+ * const cuiColorCode = context?.[id]?.cuiColorCode
298
+ * ? context?.[id]?.cuiColorCode
299
+ * : '';
300
+ * return { iconUrl, cuiColorCode };
301
+ * };
302
+ * ```
303
+ * */
304
+ registerAvailabilityDataMapper(availabilityMapper, options) {
305
+ ExtensionManager.dataMapper.registerDataMapper(
306
+ ExtensionType.AvailabilityMapper,
307
+ availabilityMapper,
308
+ options
309
+ );
310
+ return this;
311
+ }
312
+ /**
313
+ * Loads data that will be provided as context into the {@link AvailabilityMapper}.
314
+ *
315
+ * @param availabilityLoader - Async function that loads and returns availability context data
316
+ * @param options - Optional {@link ExtensionOptions} to control failure behavior.
317
+ * Defaults to `failurePolicy: "throw"`, which throws an {@link ExtensionException} on loader failure.
318
+ * Set to `"continue"` to log the error and return `undefined` instead.
319
+ * @returns this instance for chaining
320
+ *
321
+ * @example
322
+ * A common use case is to load brandset data that is UI specific and not provided directly by the Java service.
323
+ *
324
+ * The following example shows how to load the brandset data, normalize it into a map and then provide it back to the framework
325
+ * where it can be used by the other extension points.
326
+ *
327
+ * In the nozzle model, the data is provided to the {@link AvailabilityMapper} extension point in order to augment availability data
328
+ * and also loaded into the nozzle model context in order to make the data available throughout the code.
329
+ *
330
+ * ```typescript
331
+ * export const beverageContextLoader = async (): Promise<BeverageContext> => {
332
+ * const response = await kosFetch('kos:/system/brandset/brandset.json');
333
+ *
334
+ * if (response.status !== 200) {
335
+ * KosLog.error('Failed to load beverage data');
336
+ * return {};
337
+ * }
338
+ * const json: BrandsetResponse | null = await response.json();
339
+ * const initialBeverages: Record<string, BrandsetIngredient> = {};
340
+ * const beverages = json?.ingredients?.reduce((acc, beverage) => {
341
+ * acc[beverage.ingredientId] = beverage;
342
+ * return acc;
343
+ * }, initialBeverages);
344
+ * return beverages;
345
+ * };
346
+ * ```
347
+ * */
348
+ registerAvailabilityLoader(availabilityLoader, options) {
349
+ ExtensionManager.loader.registerLoader(
350
+ ExtensionType.AvailabilityLoader,
351
+ availabilityLoader,
352
+ options
353
+ );
354
+ return this;
355
+ }
356
+ /**
357
+ * Maps the abstract {@link SelectedPourable} data into a format that is specific to the nozzle.
358
+ *
359
+ * @param selectedPourableMapper - Mapping function that transforms {@link SelectedPourable} data
360
+ * @param options - Optional {@link ExtensionOptions} to control failure behavior.
361
+ * Defaults to `failurePolicy: "throw"`, which throws an {@link ExtensionException} on mapper failure.
362
+ * Set to `"continue"` to log the error and continue processing remaining mappers.
363
+ * @returns this instance for chaining
364
+ * */
365
+ registerSelectedPourableDataMapper(selectedPourableMapper, options) {
366
+ ExtensionManager.dataMapper.registerDataMapper(
367
+ ExtensionType.SelectedPourableMapper,
368
+ selectedPourableMapper,
369
+ options
370
+ );
371
+ return this;
372
+ }
373
+ /**
374
+ * Maps data into the {@link AssemblyModel} data.
375
+ * Used in cases where the base assembly has been extended with additional properties in the backend. This extension
376
+ * point allows for the data to be mapped into the {@link AssemblyModel} and augmented with additional properties.
377
+ *
378
+ * @param assemblyDataMapper - Mapping function that maps an {@link AssemblyTypes.AssemblyResponse} into additional assembly data
379
+ * @param options - Optional {@link ExtensionOptions} to control failure behavior.
380
+ * Defaults to `failurePolicy: "throw"`, which throws an {@link ExtensionException} on mapper failure.
381
+ * Set to `"continue"` to log the error and continue processing remaining mappers.
382
+ * @returns this instance for chaining
383
+ *
384
+ * @example
385
+ *
386
+ * In this example of an implementation of a {@link AssemblyMapper}, the {@link AssemblyResponse} data is mapped into
387
+ * a {@link FreestyleAssembly} object.
388
+ *
389
+ * The {@link FreestyleAssemblyResponse} interface represents the additional data being returned by the assembly service and is
390
+ * merged into the {@link AssemblyResponse} interface.
391
+ *
392
+ * The {@link FreestyleAssembly} interface represents the additional data, beyond the base data set, that will be merged into the {@link AssemblyModel}.
393
+ *
394
+ * The mapper is responsible for mapping from the {@link FreestyleAssemblyResponse} format to the {@link FreestyleAssembly} format.
395
+ * ```typescript
396
+ * import { AssemblyTypes } from "@kosdev-code/kos-dispense-sdk";
397
+ * import { DataMapper } from "@kosdev-code/kos-ui-sdk";
398
+ *
399
+ * // define the additional data being returned by the assembly service
400
+ * export interface FreestyleAssemblyResponse {
401
+ * iceAgitator?: {
402
+ * name: "iceAgitator";
403
+ * path: string;
404
+ * };
405
+ * }
406
+ *
407
+ * // define the additional data structure that will be merged into the assembly model
408
+ * export interface FreestyleAssembly {
409
+ * iceAgitator: {
410
+ * path: string;
411
+ * };
412
+ * carbAgitator: {
413
+ * path: string;
414
+ * };
415
+ * }
416
+ *
417
+ *
418
+ * // define the mapper that will map the data from the service response into the additional data structure
419
+ * // that will be merged into the assembly model.
420
+ * // In this case the mapper is responsible for mapping from the {@link FreestyleAssemblyResponse} format to the {@link FreestyleAssembly} format.
421
+ * export const assemblyDataMapper: DataMapper<
422
+ * AssemblyTypes.AssemblyResponse<FreestyleAssemblyResponse>,
423
+ * FreestyleAssembly
424
+ * > = async (data) => {
425
+ * const response = data.assemblies.reduce((acc, assembly) => {
426
+ * const agitatorKeys = ["iceAgitator", "carbAgitator"];
427
+ * agitatorKeys.forEach((key) => {
428
+ * const agitator = assembly[key];
429
+ * if (agitator) {
430
+ * acc[key] = agitator;
431
+ * }
432
+ * });
433
+ *
434
+ * return acc;
435
+ * }, {} as FreestyleAssembly);
436
+ * return response;
437
+ * };
438
+ *```
439
+ */
440
+ registerAssemblyDataMapper(assemblyDataMapper, options) {
441
+ ExtensionManager.dataMapper.registerDataMapper(
442
+ ExtensionType.AssemblyMapper,
443
+ assemblyDataMapper,
444
+ options
445
+ );
446
+ return this;
447
+ }
448
+ registerBoardIndex(boardIndex) {
449
+ ExtensionManager.indexExtension.registerIndexExtension(
450
+ ExtensionType.BoardIndex,
451
+ boardIndex
452
+ );
453
+ return this;
454
+ }
455
+ /**
456
+ * Registers a data mapper for the board model within an assembly.
457
+ *
458
+ * @param boardDataMapper - Mapping function that maps an {@link AssemblyTypes.AssemblyBoard} into additional board data
459
+ * @param options - Optional {@link ExtensionOptions} to control failure behavior.
460
+ * Defaults to `failurePolicy: "throw"`, which throws an {@link ExtensionException} on mapper failure.
461
+ * Set to `"continue"` to log the error and continue processing remaining mappers.
462
+ * @returns this instance for chaining
463
+ */
464
+ registerBoardDataMapper(boardDataMapper, options) {
465
+ ExtensionManager.dataMapper.registerDataMapper(
466
+ ExtensionType.BoardMapper,
467
+ boardDataMapper,
468
+ options
469
+ );
470
+ return this;
471
+ }
472
+ registerAssemblyFeatureFlagResolver(assemblyFeatureFlagResolver) {
473
+ var _a;
474
+ (_a = ExtensionManager[EXTENSION_FEATURE_FLAG_RESOLVER]) == null ? void 0 : _a.register(
475
+ ExtensionType.AssemblyFeatureFlags,
476
+ assemblyFeatureFlagResolver
477
+ );
478
+ return this;
479
+ }
480
+ }
481
+ class KosExtensionManager {
482
+ constructor() {
483
+ __publicField(this, "dispense");
484
+ __publicField(this, "core");
485
+ this.dispense = new DispenseExtensionManager();
486
+ this.core = new CoreExtensionManager();
487
+ }
488
+ }
489
+ export {
490
+ DispenseExtensionManager as D,
491
+ KosExtensionManager as K,
492
+ index as a,
493
+ index$4 as b,
494
+ index$5 as c,
495
+ index$1 as d,
496
+ index$2 as e,
497
+ assembly as f,
498
+ getFuelGaugeValue as g,
499
+ index$3 as i
500
+ };
501
+ //# sourceMappingURL=extension-utils-Dt00FOJq.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"extension-utils-Dt00FOJq.js","sources":["../../../../packages/sdk/kos-dispense-sdk/src/models/models/holder/utils/holder-utils.ts","../../../../packages/sdk/kos-dispense-sdk/src/models/utils/extension-utils.ts"],"sourcesContent":["import { kosAutoEffect } from \"@kosdev-code/kos-ui-sdk\";\nimport { useEffect, useState } from \"react\";\nimport type { HolderModel } from \"../types\";\n\nexport const getFuelGaugeValue = (holder: HolderModel) => {\n const [maxVolume, setMaxVolume] = useState<number>(\n holder?.slice?.maxVolMl ?? 0\n );\n const [remainingVolume, setRemainingVolume] = useState<number>(\n holder?.slice?.currentVolMl ?? 0\n );\n\n const [hasMaxVolume, setHasMaxVolume] = useState<boolean>(\n holder?.slice?.maxVolMl !== undefined\n );\n\n const [hasRemainingVolume, setHasRemainingVolume] = useState<boolean>(\n holder?.slice?.currentVolMl !== undefined\n );\n\n const [fillPercent, setFillPercent] = useState<number>(\n remainingVolume <= 0\n ? 0\n : Math.floor(((remainingVolume || 1) / (maxVolume || 1)) * 100)\n );\n\n const [hasFuelGuage, setHasFuelGuage] = useState<boolean>(\n hasMaxVolume && hasRemainingVolume\n );\n\n useEffect(() => {\n const disposer = kosAutoEffect(() => {\n setMaxVolume(holder?.slice?.maxVolMl ?? 0);\n setRemainingVolume(holder?.slice?.currentVolMl ?? 0);\n setHasMaxVolume(holder?.slice?.maxVolMl !== undefined);\n setHasRemainingVolume(holder?.slice?.currentVolMl !== undefined);\n setFillPercent(\n remainingVolume <= 0\n ? 0\n : Math.floor(((remainingVolume || 1) / (maxVolume || 1)) * 100)\n );\n setHasFuelGuage(hasMaxVolume && hasRemainingVolume);\n });\n\n return () => {\n disposer();\n };\n }, [holder]);\n\n return { maxVolume, remainingVolume, fillPercent, hasFuelGuage };\n};\n","/* eslint-disable @typescript-eslint/no-explicit-any */\nimport {\n CoreExtensionManager,\n DataLoader,\n DataMapper,\n EXTENSION_FEATURE_FLAG_RESOLVER,\n ExtensionManager,\n ExtensionOptions,\n IndexExtension,\n PropertyMapper,\n type FlagResolver,\n} from \"@kosdev-code/kos-ui-sdk\";\nimport { ExtensionType } from \"../constants\";\nimport { AssemblyTypes, type AssemblyModel } from \"../models\";\nimport type { HolderResponse } from \"../models/holder/services\";\nimport type { HolderModel } from \"../models/holder/types\";\nimport type { IngredientResponse } from \"../models/ingredient/services\";\nimport type { BeverageResponse } from \"../models/nozzle/services\";\nimport type { SelectedPourable } from \"../models/nozzle/types\";\n\nexport type IngredientDataMapper<\n AdditionalData extends object = Record<string, any>\n> = DataMapper<IngredientResponse, AdditionalData, any>;\n\n/**\n * Mapping function that maps an ingredient response into the type property of\n * the {@link IngredientModel}.\n */\nexport type IngredientTypeMapper<\n T extends IngredientResponse = IngredientResponse\n> = PropertyMapper<T, string>;\n\n/**\n * Mapping function that maps additional data from holder service response\n * into the {@link HolderModel} data.\n */\nexport type HolderTypeMapper<T extends HolderResponse = HolderResponse> =\n PropertyMapper<T, string>;\n\n/**\n * Mapping function that maps additional data from holder service response\n * into the {@link HolderModel} data.\n */\nexport type HolderDataMapper<\n AdditionalData extends object = Record<string, any>,\n HolderData extends HolderResponse = HolderResponse\n> = DataMapper<HolderData, AdditionalData, any>;\n\nexport type GroupBeverageResponse = BeverageResponse & { groupId: string };\nexport type AvailabilityDataMapper<\n AdditionalData extends object = Record<string, any>,\n AvailabilityData extends GroupBeverageResponse = GroupBeverageResponse\n> = DataMapper<AvailabilityData, AdditionalData, any>;\n\nexport type SelectedPourableMapper = DataMapper<SelectedPourable, any>;\n\nexport type BoardDataMapper<\n AdditionalData extends object = Record<string, any>,\n BoardData extends AssemblyTypes.AssemblyBoard<any> = AssemblyTypes.AssemblyBoard<any>\n> = DataMapper<BoardData, AdditionalData, any>;\n\nexport type AssemblyMapper<\n AdditionalData extends object = Record<string, any>,\n AssemblyResponseData extends AssemblyTypes.AssemblyResponse<any> = AssemblyTypes.AssemblyResponse<any>\n> = DataMapper<AssemblyResponseData, AdditionalData, any>;\n/**\n * The DispenseExtensionManager is responsible for managing the extension points that are specific to the Dispense application.\n */\nexport class DispenseExtensionManager {\n core: CoreExtensionManager = new CoreExtensionManager();\n /**\n * Maps data into the {@link IngredientModel}\n *\n * It is common for the ingredient data provided by the ingredient service to be augmented with additional properties that are\n * not provided by the base KOS Ingredient model. The {@link IngredientMapper} extension point allows for the data to be mapped\n * into the {@link IngredientModel} and the {@link IngredientModel.data} property to be augmented with additional properties.\n *\n * @param ingredientDataMapper - Mapping function that maps an {@link IngredientResponse} into additional model data\n * @param options - Optional {@link ExtensionOptions} to control failure behavior.\n * Defaults to `failurePolicy: \"throw\"`, which throws an {@link ExtensionException} on mapper failure.\n * Set to `\"continue\"` to log the error and continue processing remaining mappers.\n * @returns this instance for chaining\n *\n * @example\n * The following example shows how to map the data from the service response into the {@link IngredientModel}.\n * The context is provided by the {@link IngredientLoader} extension point with its data being used to optionally augment the\n * ingredient data.\n *\n * The result of the mapping will be available in the `data` property of the {@link IngredientModel}.\n *\n * In this case the `IngedientReponseData` interface represents the data being returned by the ingredient service and the\n * `IngredientData` interface represents the data that will be available in the {@link IngredientModel.data} property. The `ingredientDataMapper`\n * is responsible for mapping from one format to the other.\n *\n * ```typescript\n *\n * interface IngredientResponseData extends NozzleServices.IngredientResponse {\n * chilled: boolean;\n * carbonated: boolean;\n * highYield: boolean;\n * }\n *\n * interface IngredientData {\n * chilled: boolean;\n * carbonated: boolean;\n * highYield: boolean;\n * }\n *\n * export const ingredientDataMapper = async (\n * data: IngredientResponseData,\n * context: IngredientContext\n * ): Promise<IngredientData> => {\n * return {\n * chilled: data.chilled,\n * carbonated: data.carbonated,\n * highYield: data.highYield,\n * }\n * }\n * ```\n * */\n registerIngredientDataMapper(\n ingredientDataMapper: IngredientDataMapper,\n options?: ExtensionOptions\n ) {\n ExtensionManager.dataMapper.registerDataMapper(\n ExtensionType.IngredientMapper,\n ingredientDataMapper,\n options\n );\n\n return this;\n }\n\n /**\n * Loads data that will be provided as context into the {@link IngredientMapper}.\n *\n * @param ingredientLoader - Async function that loads and returns ingredient context data\n * @param options - Optional {@link ExtensionOptions} to control failure behavior.\n * Defaults to `failurePolicy: \"throw\"`, which throws an {@link ExtensionException} on loader failure.\n * Set to `\"continue\"` to log the error and return `undefined` instead.\n * @returns this instance for chaining\n *\n * @example\n * The following example shows how to load the brandset data, normalize it into a map and then provide it back to the framework\n * where it can be used by the other extension points.\n *\n * In the ingredient container model, the data is provided to the {@link IngredientMapper} extension point in order to augment ingredient data\n * and also loaded into the ingredient container model context in order to make the data available throughout the code.\n *\n * ```typescript\n * export const ingredientContextLoader = async (): Promise<BeverageContext> => {\n * const response = await kosFetch('kos:/system/some/ingredient/endpoint.json');\n *\n * if (response.status !== 200) {\n * KosLog.error('Failed to load ingredient data');\n * return {};\n * }\n * const json = await response.json();\n * return json;\n * };\n * ```\n * */\n registerIngredientLoader(\n ingredientLoader: DataLoader,\n options?: ExtensionOptions\n ) {\n ExtensionManager.loader.registerLoader(\n ExtensionType.IngredientLoader,\n ingredientLoader,\n options\n );\n return this;\n }\n\n registerIngredientIndex(ingredientIndex: IndexExtension) {\n ExtensionManager.indexExtension.registerIndexExtension(\n ExtensionType.IngredientIndex,\n ingredientIndex\n );\n return this;\n }\n\n /**\n * Registers a property mapper that derives the `type` property of the {@link IngredientModel}\n * from an {@link IngredientResponse}.\n *\n * @param ingredientTypeMapper - Mapping function that extracts a type string from an {@link IngredientResponse}\n * @param options - Optional {@link ExtensionOptions} to control failure behavior.\n * Defaults to `failurePolicy: \"throw\"`, which throws an {@link ExtensionException} on mapper failure.\n * Set to `\"continue\"` to log the error and return a fallback value instead.\n * @returns this instance for chaining\n * */\n registerIngredientTypeMapper(\n ingredientTypeMapper: IngredientTypeMapper,\n options?: ExtensionOptions\n ) {\n ExtensionManager.propertyMapper.registerPropertyMapper(\n ExtensionType.IngredientTypeMapper,\n ingredientTypeMapper,\n options\n );\n return this;\n }\n\n /**\n * Registers a data mapper for the {@link HolderModel} model.\n *\n * @param holderDataMapper - Mapping function that maps additional data from a {@link HolderResponse}\n * @param options - Optional {@link ExtensionOptions} to control failure behavior.\n * Defaults to `failurePolicy: \"throw\"`, which throws an {@link ExtensionException} on mapper failure.\n * Set to `\"continue\"` to log the error and continue processing remaining mappers.\n * @returns this instance for chaining\n */\n registerHolderDataMapper(\n holderDataMapper: HolderDataMapper,\n options?: ExtensionOptions\n ) {\n ExtensionManager.dataMapper.registerDataMapper(\n ExtensionType.HolderMapper,\n holderDataMapper,\n options\n );\n return this;\n }\n\n /**\n * Registers a property mapper that derives the `type` property of the {@link HolderModel}\n * from a {@link HolderResponse}.\n *\n * @param holderTypeMapper - Mapping function that extracts a type string from a {@link HolderResponse}\n * @param options - Optional {@link ExtensionOptions} to control failure behavior.\n * Defaults to `failurePolicy: \"throw\"`, which throws an {@link ExtensionException} on mapper failure.\n * Set to `\"continue\"` to log the error and return a fallback value instead.\n * @returns this instance for chaining\n */\n registerHolderTypeMapper(\n holderTypeMapper: HolderTypeMapper,\n options?: ExtensionOptions\n ) {\n ExtensionManager.propertyMapper.registerPropertyMapper(\n ExtensionType.HolderTypeMapper,\n holderTypeMapper,\n options\n );\n return this;\n }\n\n /**\n * Maps the ingredientId property of the holder into the {@link HolderModel}.\n * If not provided, the ingredientId will assume that the value is mapped from the\n * ingredientId property of the service response.\n *\n * @param holderTypeMapper - Mapping function that extracts the ingredientId from a {@link HolderResponse}\n * @param options - Optional {@link ExtensionOptions} to control failure behavior.\n * Defaults to `failurePolicy: \"throw\"`, which throws an {@link ExtensionException} on mapper failure.\n * Set to `\"continue\"` to log the error and return a fallback value instead.\n * @returns this instance for chaining\n * */\n registerHolderIngredientMapper(\n holderTypeMapper: HolderTypeMapper,\n options?: ExtensionOptions\n ) {\n ExtensionManager.propertyMapper.registerPropertyMapper(\n ExtensionType.HolderTypeMapper,\n holderTypeMapper,\n options\n );\n return this;\n }\n\n registerHolderIndex<T extends HolderModel = HolderModel>(\n holderIndex: IndexExtension<T>\n ) {\n ExtensionManager.indexExtension.registerIndexExtension(\n ExtensionType.HolderIndex,\n holderIndex\n );\n return this;\n }\n\n /**\n * Maps data into the {@link AvailabilityModel}.\n *\n * @param availabilityMapper - Mapping function that maps a {@link GroupBeverageResponse} into additional availability data\n * @param options - Optional {@link ExtensionOptions} to control failure behavior.\n * Defaults to `failurePolicy: \"throw\"`, which throws an {@link ExtensionException} on mapper failure.\n * Set to `\"continue\"` to log the error and continue processing remaining mappers.\n * @returns this instance for chaining\n *\n * @example\n * The following example shows how to map the data from the service response into the {@link AvailabilityModel}.\n * The context is provided by the {@link AvailabilityLoader} extension point with its data being used to augment the\n * availability data.\n *\n * The result of the mapping will be available in the `data` property of the {@link AvailabilityModel}.\n *\n * ```typescript\n * export const beverageDataMapper = async (\n * data: NozzleServices.BeverageResponse,\n * context: BeverageContext\n * ): Promise<BeverageData> => {\n * const id = data.altId;\n * const iconUrl = encodeURI(\n * `http://localhost:8081/system/brandset/${context?.[id]?.icon}`\n * );\n * const cuiColorCode = context?.[id]?.cuiColorCode\n * ? context?.[id]?.cuiColorCode\n * : '';\n * return { iconUrl, cuiColorCode };\n * };\n * ```\n * */\n registerAvailabilityDataMapper(\n availabilityMapper: AvailabilityDataMapper,\n options?: ExtensionOptions\n ) {\n ExtensionManager.dataMapper.registerDataMapper(\n ExtensionType.AvailabilityMapper,\n availabilityMapper,\n options\n );\n return this;\n }\n\n /**\n * Loads data that will be provided as context into the {@link AvailabilityMapper}.\n *\n * @param availabilityLoader - Async function that loads and returns availability context data\n * @param options - Optional {@link ExtensionOptions} to control failure behavior.\n * Defaults to `failurePolicy: \"throw\"`, which throws an {@link ExtensionException} on loader failure.\n * Set to `\"continue\"` to log the error and return `undefined` instead.\n * @returns this instance for chaining\n *\n * @example\n * A common use case is to load brandset data that is UI specific and not provided directly by the Java service.\n *\n * The following example shows how to load the brandset data, normalize it into a map and then provide it back to the framework\n * where it can be used by the other extension points.\n *\n * In the nozzle model, the data is provided to the {@link AvailabilityMapper} extension point in order to augment availability data\n * and also loaded into the nozzle model context in order to make the data available throughout the code.\n *\n * ```typescript\n * export const beverageContextLoader = async (): Promise<BeverageContext> => {\n * const response = await kosFetch('kos:/system/brandset/brandset.json');\n *\n * if (response.status !== 200) {\n * KosLog.error('Failed to load beverage data');\n * return {};\n * }\n * const json: BrandsetResponse | null = await response.json();\n * const initialBeverages: Record<string, BrandsetIngredient> = {};\n * const beverages = json?.ingredients?.reduce((acc, beverage) => {\n * acc[beverage.ingredientId] = beverage;\n * return acc;\n * }, initialBeverages);\n * return beverages;\n * };\n * ```\n * */\n registerAvailabilityLoader(\n availabilityLoader: DataLoader,\n options?: ExtensionOptions\n ) {\n ExtensionManager.loader.registerLoader(\n ExtensionType.AvailabilityLoader,\n availabilityLoader,\n options\n );\n return this;\n }\n\n /**\n * Maps the abstract {@link SelectedPourable} data into a format that is specific to the nozzle.\n *\n * @param selectedPourableMapper - Mapping function that transforms {@link SelectedPourable} data\n * @param options - Optional {@link ExtensionOptions} to control failure behavior.\n * Defaults to `failurePolicy: \"throw\"`, which throws an {@link ExtensionException} on mapper failure.\n * Set to `\"continue\"` to log the error and continue processing remaining mappers.\n * @returns this instance for chaining\n * */\n registerSelectedPourableDataMapper(\n selectedPourableMapper: SelectedPourableMapper,\n options?: ExtensionOptions\n ) {\n ExtensionManager.dataMapper.registerDataMapper(\n ExtensionType.SelectedPourableMapper,\n selectedPourableMapper,\n options\n );\n return this;\n }\n\n /**\n * Maps data into the {@link AssemblyModel} data.\n * Used in cases where the base assembly has been extended with additional properties in the backend. This extension\n * point allows for the data to be mapped into the {@link AssemblyModel} and augmented with additional properties.\n *\n * @param assemblyDataMapper - Mapping function that maps an {@link AssemblyTypes.AssemblyResponse} into additional assembly data\n * @param options - Optional {@link ExtensionOptions} to control failure behavior.\n * Defaults to `failurePolicy: \"throw\"`, which throws an {@link ExtensionException} on mapper failure.\n * Set to `\"continue\"` to log the error and continue processing remaining mappers.\n * @returns this instance for chaining\n *\n * @example\n *\n * In this example of an implementation of a {@link AssemblyMapper}, the {@link AssemblyResponse} data is mapped into\n * a {@link FreestyleAssembly} object.\n *\n * The {@link FreestyleAssemblyResponse} interface represents the additional data being returned by the assembly service and is\n * merged into the {@link AssemblyResponse} interface.\n *\n * The {@link FreestyleAssembly} interface represents the additional data, beyond the base data set, that will be merged into the {@link AssemblyModel}.\n *\n * The mapper is responsible for mapping from the {@link FreestyleAssemblyResponse} format to the {@link FreestyleAssembly} format.\n * ```typescript\n * import { AssemblyTypes } from \"@kosdev-code/kos-dispense-sdk\";\n * import { DataMapper } from \"@kosdev-code/kos-ui-sdk\";\n *\n * // define the additional data being returned by the assembly service\n * export interface FreestyleAssemblyResponse {\n * iceAgitator?: {\n * name: \"iceAgitator\";\n * path: string;\n * };\n * }\n *\n * // define the additional data structure that will be merged into the assembly model\n * export interface FreestyleAssembly {\n * iceAgitator: {\n * path: string;\n * };\n * carbAgitator: {\n * path: string;\n * };\n * }\n *\n *\n * // define the mapper that will map the data from the service response into the additional data structure\n * // that will be merged into the assembly model.\n * // In this case the mapper is responsible for mapping from the {@link FreestyleAssemblyResponse} format to the {@link FreestyleAssembly} format.\n * export const assemblyDataMapper: DataMapper<\n * AssemblyTypes.AssemblyResponse<FreestyleAssemblyResponse>,\n * FreestyleAssembly\n * > = async (data) => {\n * const response = data.assemblies.reduce((acc, assembly) => {\n * const agitatorKeys = [\"iceAgitator\", \"carbAgitator\"];\n * agitatorKeys.forEach((key) => {\n * const agitator = assembly[key];\n * if (agitator) {\n * acc[key] = agitator;\n * }\n * });\n *\n * return acc;\n * }, {} as FreestyleAssembly);\n * return response;\n * };\n *```\n */\n registerAssemblyDataMapper(\n assemblyDataMapper: AssemblyMapper,\n options?: ExtensionOptions\n ) {\n ExtensionManager.dataMapper.registerDataMapper(\n ExtensionType.AssemblyMapper,\n assemblyDataMapper,\n options\n );\n return this;\n }\n\n registerBoardIndex(boardIndex: IndexExtension) {\n ExtensionManager.indexExtension.registerIndexExtension(\n ExtensionType.BoardIndex,\n boardIndex\n );\n return this;\n }\n\n /**\n * Registers a data mapper for the board model within an assembly.\n *\n * @param boardDataMapper - Mapping function that maps an {@link AssemblyTypes.AssemblyBoard} into additional board data\n * @param options - Optional {@link ExtensionOptions} to control failure behavior.\n * Defaults to `failurePolicy: \"throw\"`, which throws an {@link ExtensionException} on mapper failure.\n * Set to `\"continue\"` to log the error and continue processing remaining mappers.\n * @returns this instance for chaining\n */\n registerBoardDataMapper(\n boardDataMapper: BoardDataMapper<any, any>,\n options?: ExtensionOptions\n ) {\n ExtensionManager.dataMapper.registerDataMapper(\n ExtensionType.BoardMapper,\n boardDataMapper,\n options\n );\n return this;\n }\n\n registerAssemblyFeatureFlagResolver(\n assemblyFeatureFlagResolver: FlagResolver<AssemblyModel>\n ) {\n ExtensionManager[EXTENSION_FEATURE_FLAG_RESOLVER]?.register(\n ExtensionType.AssemblyFeatureFlags,\n assemblyFeatureFlagResolver\n );\n return this;\n }\n}\n\n/**\n * The KosExtensionManager provides access to the extension points that are provided in the SDK for Dispense applications.\n *\n * The extension points are divided into two categories:\n *\n * @param core - The core extension {@link CoreExtensionManager} points are used to extend the base models that are provided by the SDK.\n * @param dispense - The dispense extension {@link DispenseExtensionManager} points are used to extend the models that are specific to the Dispense SDK.\n */\nexport class KosExtensionManager {\n dispense: DispenseExtensionManager;\n core: CoreExtensionManager;\n constructor() {\n this.dispense = new DispenseExtensionMan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qBAAA;AAAA,EAClB;AACF;"}
@@ -0,0 +1,70 @@
1
+ import { z } from 'zod';
2
+
3
+ declare const ControlPourSchema: z.ZodObject<{
4
+ id: z.ZodString;
5
+ title: z.ZodString;
6
+ namespace: z.ZodString;
7
+ experienceId: z.ZodString;
8
+ } | ({
9
+ id: z.ZodString;
10
+ title: z.ZodString;
11
+ namespace: z.ZodString;
12
+ experienceId: z.ZodString;
13
+ } & {
14
+ rank: z.ZodOptional<z.ZodNumber>;
15
+ }), z.UnknownKeysParam, z.ZodTypeAny, {
16
+ id: string;
17
+ experienceId: string;
18
+ title: string;
19
+ namespace: string;
20
+ } | {
21
+ id: string;
22
+ experienceId: string;
23
+ title: string;
24
+ namespace: string;
25
+ rank?: unknown;
26
+ }, {
27
+ id: string;
28
+ experienceId: string;
29
+ title: string;
30
+ namespace: string;
31
+ } | {
32
+ id: string;
33
+ experienceId: string;
34
+ title: string;
35
+ namespace: string;
36
+ rank?: unknown;
37
+ }>;
38
+ type ControlPourDefinition = z.infer<typeof ControlPourSchema>;
39
+ /**
40
+ * Control Pour extension point for beverage dispensing interfaces
41
+ *
42
+ * Allows plugin developers to contribute controlled pour functionality
43
+ * to CUI applications that register this extension point.
44
+ */
45
+ export declare const ControlPourExtension: import('@kosdev-code/kos-ui-plugin/utilities').ViewExtensionPointDefinition<{
46
+ id: string;
47
+ experienceId: string;
48
+ title: string;
49
+ namespace: string;
50
+ } | {
51
+ id: string;
52
+ experienceId: string;
53
+ title: string;
54
+ namespace: string;
55
+ rank?: unknown;
56
+ }, {
57
+ id: string;
58
+ experienceId: string;
59
+ title: string;
60
+ namespace: string;
61
+ } | {
62
+ id: string;
63
+ experienceId: string;
64
+ title: string;
65
+ namespace: string;
66
+ rank?: unknown;
67
+ }, any>;
68
+ export declare const EXTENSION_POINT_CONTROL_POUR: string;
69
+ export type { ControlPourDefinition };
70
+ //# sourceMappingURL=control-pour-extension.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"control-pour-extension.d.ts","sourceRoot":"","sources":["../../../../../packages/sdk/kos-dispense-sdk/src/extensions/control-pour-extension.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,QAAA,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAAiD,CAAC;AAGzE,KAAK,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAI/D;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;OAyB/B,CAAC;AAGH,eAAO,MAAM,4BAA4B,QAAe,CAAC;AACzD,YAAY,EAAE,qBAAqB,EAAE,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from './control-pour-extension';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../packages/sdk/kos-dispense-sdk/src/extensions/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC"}