@kosdev-code/kos-dispense-sdk 3.0.26 → 3.0.27
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/dispense-registration-manager-Da9CW_cN.js.map +1 -1
- package/dispense-registration-manager-Dtb31fcI.cjs.map +1 -1
- package/{extension-utils-CwctwFhK.cjs → extension-utils-Cfhe358W.cjs} +39 -166
- package/extension-utils-Cfhe358W.cjs.map +1 -0
- package/{extension-utils-C_pwmFbZ.js → extension-utils-D_dnBLH6.js} +39 -166
- package/extension-utils-D_dnBLH6.js.map +1 -0
- package/index.cjs +2 -2
- package/index.js +2 -2
- package/models/constants/constants.d.ts +14 -178
- package/models/constants/constants.d.ts.map +1 -1
- package/models/models/assembly/assembly-registration.d.ts +9 -69
- package/models/models/assembly/assembly-registration.d.ts.map +1 -1
- package/models/models/availability/availability-model.d.ts +10 -76
- package/models/models/availability/availability-model.d.ts.map +1 -1
- package/models/models/availability/types/index.d.ts +3 -12
- package/models/models/board/board-container-registration.d.ts +9 -74
- package/models/models/board/board-container-registration.d.ts.map +1 -1
- package/models/models/board/board-registration.d.ts +9 -72
- package/models/models/board/board-registration.d.ts.map +1 -1
- package/models/models/device-assembly/device-assembly-registration.d.ts +10 -76
- package/models/models/device-assembly/device-assembly-registration.d.ts.map +1 -1
- package/models/models/generic-pour/generic-pour-registration.d.ts +9 -72
- package/models/models/generic-pour/generic-pour-registration.d.ts.map +1 -1
- package/models/models/holder/holder-model.d.ts +9 -73
- package/models/models/holder/holder-model.d.ts.map +1 -1
- package/models/models/holder-container/holder-container-model.d.ts +9 -68
- package/models/models/holder-container/holder-container-model.d.ts.map +1 -1
- package/models/models/ingredient/ingredient-model.d.ts +9 -74
- package/models/models/ingredient/ingredient-model.d.ts.map +1 -1
- package/models/models/ingredient/types/index.d.ts +3 -10
- package/models/models/ingredient-container/ingredient-container-model.d.ts +9 -68
- package/models/models/ingredient-container/ingredient-container-model.d.ts.map +1 -1
- package/models/models/nozzle/nozzle-model.d.ts +10 -72
- package/models/models/nozzle/nozzle-model.d.ts.map +1 -1
- package/models/models/nozzle/services/nozzle-services.d.ts +11 -65
- package/models/models/nozzle/services/nozzle-services.d.ts.map +1 -1
- package/models/models/pump/pump-model.d.ts +9 -79
- package/models/models/pump/pump-model.d.ts.map +1 -1
- package/models/models/pump-container/pump-container-model.d.ts +9 -68
- package/models/models/pump-container/pump-container-model.d.ts.map +1 -1
- package/models/models/types/intent.d.ts +11 -78
- package/models/models/types/intent.d.ts.map +1 -1
- package/models/utils/extension-utils.d.ts +38 -165
- package/models/utils/extension-utils.d.ts.map +1 -1
- package/models.cjs +1 -1
- package/models.js +1 -1
- package/package.json +2 -2
- package/{pump-provider-CAKW652V.js → pump-provider-BQmCKz7S.js} +3 -5
- package/pump-provider-BQmCKz7S.js.map +1 -0
- package/{pump-provider-SXrqGmxO.cjs → pump-provider-uNNMh9uh.cjs} +3 -5
- package/pump-provider-uNNMh9uh.cjs.map +1 -0
- package/ui/hooks/cui-kit/use-default-cui-kit-lifecycle.d.ts +16 -43
- package/ui/hooks/cui-kit/use-default-cui-kit-lifecycle.d.ts.map +1 -1
- package/ui/hooks/ingredient/use-ingredient-pour.d.ts +7 -18
- package/ui/hooks/ingredient/use-ingredient-pour.d.ts.map +1 -1
- package/ui/hooks/nozzle-pour/use-nozzle-pour.d.ts +6 -17
- package/ui/hooks/nozzle-pour/use-nozzle-pour.d.ts.map +1 -1
- package/ui/hooks/pour/use-pour.d.ts +7 -18
- package/ui/hooks/pour/use-pour.d.ts.map +1 -1
- package/ui.cjs +1 -1
- package/ui.js +1 -1
- package/extension-utils-C_pwmFbZ.js.map +0 -1
- package/extension-utils-CwctwFhK.cjs.map +0 -1
- package/pump-provider-CAKW652V.js.map +0 -1
- package/pump-provider-SXrqGmxO.cjs.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extension-utils-D_dnBLH6.js","sources":["../../../packages/kos-dispense-sdk/src/models/models/holder/utils/holder-utils.ts","../../../packages/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 * Registers a data mapper for the {@link IngredientModel}.\n *\n * Ingredient service data often needs properties the base model does not carry. The mapper receives each\n * {@link IngredientResponse} and the data returned by the ingredient loader as context, and its result\n * becomes the model's `data` property.\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 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 * Registers a loader whose result is passed as context to the ingredient data and type mappers.\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 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 * Registers a data mapper for the {@link AvailabilityModel}.\n *\n * The mapper receives each availability node, with its `groupId`, and the data returned by the\n * availability loader as context. Its result becomes the model's `data` property.\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 * ```typescript\n * const beverageDataMapper: AvailabilityDataMapper<BeverageData> = async (\n * data,\n * context?: Record<string, BrandsetIngredient>\n * ) => ({\n * iconUrl: context?.[data.altId]?.icon ?? \"\",\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 * Registers a loader whose result is passed as context to the availability data mapper. A common use is\n * loading UI-specific brandset data that the backend service does not provide.\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 * ```typescript\n * const beverageContextLoader = async () => {\n * const response = await kosFetch(\"kos:/system/brandset/brandset.json\");\n * const json: BrandsetResponse = await response.json();\n * return Object.fromEntries(json.ingredients.map((i) => [i.ingredientId, i]));\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 * Registers a data mapper for the {@link AssemblyModel}, for backends that extend the assembly response\n * with additional properties. The mapper's result is merged into the assembly model.\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 * ```typescript\n * interface IceAgitatorExt {\n * iceAgitator?: { name: string; path: string };\n * }\n *\n * const assemblyDataMapper: AssemblyMapper<\n * { iceAgitatorPath?: string },\n * AssemblyTypes.AssemblyResponse<{ AssemblyExt: IceAgitatorExt }>\n * > = async (data) => ({\n * iceAgitatorPath: data.assemblies.find((a) => a.iceAgitator)?.iceAgitator?.path,\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 DispenseExtensionManager();\n this.core = new CoreExtensionManager();\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIO,MAAM,oBAAoB,CAAC,WAAwB;AACxD,QAAM,CAAC,WAAW,YAAY,IAAI;AAAA,IAChC,QAAQ,OAAO,YAAY;AAAA,EAAA;AAE7B,QAAM,CAAC,iBAAiB,kBAAkB,IAAI;AAAA,IAC5C,QAAQ,OAAO,gBAAgB;AAAA,EAAA;A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O,IAAI,qBAAA;AAAA,EAClB;AACF;"}
|
package/index.cjs
CHANGED
|
@@ -3,8 +3,8 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
3
3
|
const kosApiLevels = require("@kosdev-code/kos-api-levels");
|
|
4
4
|
const utilities = require("@kosdev-code/kos-ui-plugin/utilities");
|
|
5
5
|
const dispenseRegistrationManager = require("./dispense-registration-manager-Dtb31fcI.cjs");
|
|
6
|
-
const extensionUtils = require("./extension-utils-
|
|
7
|
-
const pumpProvider = require("./pump-provider-
|
|
6
|
+
const extensionUtils = require("./extension-utils-Cfhe358W.cjs");
|
|
7
|
+
const pumpProvider = require("./pump-provider-uNNMh9uh.cjs");
|
|
8
8
|
const ControlPourSchema = utilities.createExtensionSchema({}, { rankable: false });
|
|
9
9
|
const EXTENSION_ID = utilities.extensionPointId("cui", "control", "pour");
|
|
10
10
|
const ControlPourExtension = utilities.defineExtensionPoint({
|
package/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { registerApiLevels } from "@kosdev-code/kos-api-levels";
|
|
2
2
|
import { createExtensionSchema, extensionPointId, defineExtensionPoint, createViewAwareTransform, validateWithSchema } from "@kosdev-code/kos-ui-plugin/utilities";
|
|
3
3
|
import { A, a, B, b, c, C, d, D, e, o, E, G, H, f, I, g, K, N, P, h, i, j, T, k, l, m, n, o as o2, r } from "./dispense-registration-manager-Da9CW_cN.js";
|
|
4
|
-
import { i as i2, a as a2, D as D2, b as b2, c as c2, d as d2, K as K2, e as e2, f as f2, g as g2 } from "./extension-utils-
|
|
5
|
-
import { A as A2, a as a3, B as B2, b as b3, C as C2, c as c3, D as D3, d as d3, e as e3, f as f3, H as H2, g as g3, h as h2, i as i3, I as I2, j as j2, N as N2, P as P2, k as k2, T as T2, l as l2, m as m2, n as n2, u, o as o3, p, q, r as r2, s, t, v, w, x, y, z, E as E2, F, G as G2, J, K as K3, L, M, O, Q, R, S, U, V, W, X, Y, Z, _, $, a0, a1, a2 as a22, a3 as a32, a4, a5, a6, a7, a8, a9, aa, ab } from "./pump-provider-
|
|
4
|
+
import { i as i2, a as a2, D as D2, b as b2, c as c2, d as d2, K as K2, e as e2, f as f2, g as g2 } from "./extension-utils-D_dnBLH6.js";
|
|
5
|
+
import { A as A2, a as a3, B as B2, b as b3, C as C2, c as c3, D as D3, d as d3, e as e3, f as f3, H as H2, g as g3, h as h2, i as i3, I as I2, j as j2, N as N2, P as P2, k as k2, T as T2, l as l2, m as m2, n as n2, u, o as o3, p, q, r as r2, s, t, v, w, x, y, z, E as E2, F, G as G2, J, K as K3, L, M, O, Q, R, S, U, V, W, X, Y, Z, _, $, a0, a1, a2 as a22, a3 as a32, a4, a5, a6, a7, a8, a9, aa, ab } from "./pump-provider-BQmCKz7S.js";
|
|
6
6
|
const ControlPourSchema = createExtensionSchema({}, { rankable: false });
|
|
7
7
|
const EXTENSION_ID = extensionPointId("cui", "control", "pour");
|
|
8
8
|
const ControlPourExtension = defineExtensionPoint({
|
|
@@ -3,73 +3,14 @@
|
|
|
3
3
|
* */
|
|
4
4
|
export declare enum ExtensionType {
|
|
5
5
|
/**
|
|
6
|
-
* Loads data that
|
|
7
|
-
*
|
|
8
|
-
|
|
9
|
-
* The following example shows how to load the brandset data, normalize it into a map and then provide it back to the framework
|
|
10
|
-
* where it can be used by the other extension points.
|
|
11
|
-
*
|
|
12
|
-
* In the ingredient container model, the data is provided to the {@link IngredientMapper} extension point in order to augment ingredient data
|
|
13
|
-
* and also loaded into the ingredient container model context in order to make the data available throughout the code.
|
|
14
|
-
*
|
|
15
|
-
* ```typescript
|
|
16
|
-
* export const ingredientContextLoader = async (): Promise<BeverageContext> => {
|
|
17
|
-
* const response = await kosFetch('kos:/system/some/ingredient/endpoint.json');
|
|
18
|
-
*
|
|
19
|
-
* if (response.status !== 200) {
|
|
20
|
-
* KosLog.error('Failed to load ingredient data');
|
|
21
|
-
* return {};
|
|
22
|
-
* }
|
|
23
|
-
* const json = await response.json();
|
|
24
|
-
* return json;
|
|
25
|
-
* };
|
|
26
|
-
* ```
|
|
27
|
-
* */
|
|
6
|
+
* Loads data that is passed as context to the {@link IngredientMapper}. Register with
|
|
7
|
+
* {@link DispenseExtensionManager.registerIngredientLoader}.
|
|
8
|
+
*/
|
|
28
9
|
IngredientLoader = "kos.ingredient.loader",
|
|
29
10
|
/**
|
|
30
|
-
* Maps data into the {@link IngredientModel}
|
|
31
|
-
*
|
|
32
|
-
|
|
33
|
-
* not provided by the base KOS Ingredient model. The {@link IngredientMapper} extension point allows for the data to be mapped
|
|
34
|
-
* into the {@link IngredientModel} and the {@link IngredientModel.data} property to be augmented with additional properties.
|
|
35
|
-
*
|
|
36
|
-
* @example
|
|
37
|
-
* The following example shows how to map the data from the service response into the {@link IngredientModel}.
|
|
38
|
-
* The context is provided by the {@link IngredientLoader} extension point with its data being used to optionally augment the
|
|
39
|
-
* ingredient data.
|
|
40
|
-
*
|
|
41
|
-
* The result of the mapping will be available in the `data` property of the {@link IngredientModel}.
|
|
42
|
-
*
|
|
43
|
-
* In this case the `IngedientReponseData` interface represents the data being returned by the ingredient service and the
|
|
44
|
-
* `IngredientData` interface represents the data that will be available in the {@link IngredientModel.data} property. The `ingredientDataMapper`
|
|
45
|
-
* is responsible for mapping from one format to the other.
|
|
46
|
-
*
|
|
47
|
-
* ```typescript
|
|
48
|
-
*
|
|
49
|
-
* interface IngredientResponseData extends NozzleServices.IngredientResponse {
|
|
50
|
-
* chilled: boolean;
|
|
51
|
-
* carbonated: boolean;
|
|
52
|
-
* highYield: boolean;
|
|
53
|
-
* }
|
|
54
|
-
*
|
|
55
|
-
* interface IngredientData {
|
|
56
|
-
* chilled: boolean;
|
|
57
|
-
* carbonated: boolean;
|
|
58
|
-
* highYield: boolean;
|
|
59
|
-
* }
|
|
60
|
-
*
|
|
61
|
-
* export const ingredientDataMapper = async (
|
|
62
|
-
* data: IngredientResponseData,
|
|
63
|
-
* context: IngredientContext
|
|
64
|
-
* ): Promise<IngredientData> => {
|
|
65
|
-
* return {
|
|
66
|
-
* chilled: data.chilled,
|
|
67
|
-
* carbonated: data.carbonated,
|
|
68
|
-
* highYield: data.highYield,
|
|
69
|
-
* }
|
|
70
|
-
* }
|
|
71
|
-
* ```
|
|
72
|
-
* */
|
|
11
|
+
* Maps ingredient service data into the `data` property of the {@link IngredientModel}, for properties the
|
|
12
|
+
* base model does not carry. Register with {@link DispenseExtensionManager.registerIngredientDataMapper}.
|
|
13
|
+
*/
|
|
73
14
|
IngredientMapper = "kos.ingredient.mapper",
|
|
74
15
|
IngredientIndex = "kos.ingredient.index",
|
|
75
16
|
/**
|
|
@@ -89,127 +30,22 @@ export declare enum ExtensionType {
|
|
|
89
30
|
* */
|
|
90
31
|
HolderIngredientMapper = "kos.holder.ingredient.mapper",
|
|
91
32
|
/**
|
|
92
|
-
* Maps data into the {@link AvailabilityModel}
|
|
93
|
-
*
|
|
94
|
-
|
|
95
|
-
* The following example shows how to map the data from the service response into the {@link AvailabilityModel}.
|
|
96
|
-
* The context is provided by the {@link AvailabilityLoader} extension point with its data being used to augment the
|
|
97
|
-
* availability data.
|
|
98
|
-
*
|
|
99
|
-
* The result of the mapping will be available in the `data` property of the {@link AvailabilityModel}.
|
|
100
|
-
*
|
|
101
|
-
* ```typescript
|
|
102
|
-
* export const beverageDataMapper = async (
|
|
103
|
-
* data: NozzleServices.BeverageResponse,
|
|
104
|
-
* context: BeverageContext
|
|
105
|
-
* ): Promise<BeverageData> => {
|
|
106
|
-
* const id = data.altId;
|
|
107
|
-
* const iconUrl = encodeURI(
|
|
108
|
-
* `http://localhost:8081/system/brandset/${context?.[id]?.icon}`
|
|
109
|
-
* );
|
|
110
|
-
* const cuiColorCode = context?.[id]?.cuiColorCode
|
|
111
|
-
* ? context?.[id]?.cuiColorCode
|
|
112
|
-
* : '';
|
|
113
|
-
* return { iconUrl, cuiColorCode };
|
|
114
|
-
* };
|
|
115
|
-
* ```
|
|
116
|
-
* */
|
|
33
|
+
* Maps availability service data into the `data` property of the {@link AvailabilityModel}. Register with
|
|
34
|
+
* {@link DispenseExtensionManager.registerAvailabilityDataMapper}.
|
|
35
|
+
*/
|
|
117
36
|
AvailabilityMapper = "kos.availability.mapper",
|
|
118
37
|
/**
|
|
119
|
-
* Loads data that
|
|
120
|
-
*
|
|
121
|
-
|
|
122
|
-
* A common use case is to load brandset data that is UI specific and not provided directly by the Java service.
|
|
123
|
-
*
|
|
124
|
-
* The following example shows how to load the brandset data, normalize it into a map and then provide it back to the framework
|
|
125
|
-
* where it can be used by the other extension points.
|
|
126
|
-
*
|
|
127
|
-
* In the nozzle model, the data is provided to the {@link AvailabilityMapper} extension point in order to augment availability data
|
|
128
|
-
* and also loaded into the nozzle model context in order to make the data available throughout the code.
|
|
129
|
-
*
|
|
130
|
-
* ```typescript
|
|
131
|
-
* export const beverageContextLoader = async (): Promise<BeverageContext> => {
|
|
132
|
-
* const response = await kosFetch('kos:/system/brandset/brandset.json');
|
|
133
|
-
*
|
|
134
|
-
* if (response.status !== 200) {
|
|
135
|
-
* KosLog.error('Failed to load beverage data');
|
|
136
|
-
* return {};
|
|
137
|
-
* }
|
|
138
|
-
* const json: BrandsetResponse | null = await response.json();
|
|
139
|
-
* const initialBeverages: Record<string, BrandsetIngredient> = {};
|
|
140
|
-
* const beverages = json?.ingredients?.reduce((acc, beverage) => {
|
|
141
|
-
* acc[beverage.ingredientId] = beverage;
|
|
142
|
-
* return acc;
|
|
143
|
-
* }, initialBeverages);
|
|
144
|
-
* return beverages;
|
|
145
|
-
* };
|
|
146
|
-
* ```
|
|
147
|
-
* */
|
|
38
|
+
* Loads data that is passed as context to the {@link AvailabilityMapper}, such as UI-specific brandset data.
|
|
39
|
+
* Register with {@link DispenseExtensionManager.registerAvailabilityLoader}.
|
|
40
|
+
*/
|
|
148
41
|
AvailabilityLoader = "kos.availability.loader",
|
|
149
42
|
/**
|
|
150
43
|
* Maps the abstract {@link SelectedPourable} data into a format that is specific to the nozzle.
|
|
151
44
|
* */
|
|
152
45
|
SelectedPourableMapper = "kos.selected.pourable.mapper",
|
|
153
46
|
/**
|
|
154
|
-
* Maps
|
|
155
|
-
*
|
|
156
|
-
* point allows for the data to be mapped into the {@link AssemblyModel} and augmented with additional properties.
|
|
157
|
-
*
|
|
158
|
-
* @example
|
|
159
|
-
*
|
|
160
|
-
* In this example of an implementation of a {@link AssemblyMapper}, the {@link AssemblyResponse} data is mapped into
|
|
161
|
-
* a {@link FreestyleAssembly} object.
|
|
162
|
-
*
|
|
163
|
-
* The {@link FreestyleAssemblyResponse} interface represents the additional data being returned by the assembly service and is
|
|
164
|
-
* merged into the {@link AssemblyResponse} interface.
|
|
165
|
-
*
|
|
166
|
-
* The {@link FreestyleAssembly} interface represents the additional data, beyond the base data set, that will be merged into the {@link AssemblyModel}.
|
|
167
|
-
*
|
|
168
|
-
* The mapper is responsible for mapping from the {@link FreestyleAssemblyResponse} format to the {@link FreestyleAssembly} format.
|
|
169
|
-
* ```typescript
|
|
170
|
-
* import { AssemblyTypes } from "@kosdev-code/kos-dispense-sdk";
|
|
171
|
-
* import { DataMapper } from "@kosdev-code/kos-ui-sdk";
|
|
172
|
-
*
|
|
173
|
-
* // define the additional data being returned by the assembly service
|
|
174
|
-
* export interface FreestyleAssemblyResponse {
|
|
175
|
-
* iceAgitator?: {
|
|
176
|
-
* name: "iceAgitator";
|
|
177
|
-
* path: string;
|
|
178
|
-
* };
|
|
179
|
-
* }
|
|
180
|
-
*
|
|
181
|
-
* // define the additional data structure that will be merged into the assembly model
|
|
182
|
-
* export interface FreestyleAssembly {
|
|
183
|
-
* iceAgitator: {
|
|
184
|
-
* path: string;
|
|
185
|
-
* };
|
|
186
|
-
* carbAgitator: {
|
|
187
|
-
* path: string;
|
|
188
|
-
* };
|
|
189
|
-
* }
|
|
190
|
-
*
|
|
191
|
-
*
|
|
192
|
-
* // define the mapper that will map the data from the service response into the additional data structure
|
|
193
|
-
* // that will be merged into the assembly model.
|
|
194
|
-
* // In this case the mapper is responsible for mapping from the {@link FreestyleAssemblyResponse} format to the {@link FreestyleAssembly} format.
|
|
195
|
-
* export const assemblyDataMapper: DataMapper<
|
|
196
|
-
* AssemblyTypes.AssemblyResponse<FreestyleAssemblyResponse>,
|
|
197
|
-
* FreestyleAssembly
|
|
198
|
-
* > = async (data) => {
|
|
199
|
-
* const response = data.assemblies.reduce((acc, assembly) => {
|
|
200
|
-
* const agitatorKeys = ["iceAgitator", "carbAgitator"];
|
|
201
|
-
* agitatorKeys.forEach((key) => {
|
|
202
|
-
* const agitator = assembly[key];
|
|
203
|
-
* if (agitator) {
|
|
204
|
-
* acc[key] = agitator;
|
|
205
|
-
* }
|
|
206
|
-
* });
|
|
207
|
-
*
|
|
208
|
-
* return acc;
|
|
209
|
-
* }, {} as FreestyleAssembly);
|
|
210
|
-
* return response;
|
|
211
|
-
* };
|
|
212
|
-
*```
|
|
47
|
+
* Maps additional assembly response properties into the {@link AssemblyModel}, for backends that extend the
|
|
48
|
+
* base assembly. Register with {@link DispenseExtensionManager.registerAssemblyDataMapper}.
|
|
213
49
|
*/
|
|
214
50
|
AssemblyMapper = "kos.assembly.mapper",
|
|
215
51
|
BoardMapper = "kos.board.mapper",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../../packages/kos-dispense-sdk/src/models/constants/constants.ts"],"names":[],"mappings":"AAAA;;KAEK;AACL,oBAAY,aAAa;IACvB
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../../packages/kos-dispense-sdk/src/models/constants/constants.ts"],"names":[],"mappings":"AAAA;;KAEK;AACL,oBAAY,aAAa;IACvB;;;OAGG;IACH,gBAAgB,0BAA0B;IAE1C;;;OAGG;IACH,gBAAgB,0BAA0B;IAE1C,eAAe,yBAAyB;IACxC;;SAEK;IACL,oBAAoB,+BAA+B;IAEnD;;SAEK;IACL,gBAAgB,2BAA2B;IAE3C,YAAY,sBAAsB;IAElC,WAAW,qBAAqB;IAChC;;;;SAIK;IACL,sBAAsB,iCAAiC;IAEvD;;;OAGG;IACH,kBAAkB,4BAA4B;IAE9C;;;OAGG;IACH,kBAAkB,4BAA4B;IAE9C;;SAEK;IACL,sBAAsB,iCAAiC;IAEvD;;;OAGG;IACH,cAAc,wBAAwB;IACtC,WAAW,qBAAqB;IAChC,UAAU,oBAAoB;IAC9B,SAAS,mBAAmB;IAC5B,oBAAoB,+BAA+B;CACpD;AAED,oBAAY,iBAAiB;IAC3B,MAAM,iBAAiB;IACvB,YAAY,uBAAuB;IACnC,MAAM,iBAAiB;IACvB,eAAe,2BAA2B;IAC1C,mBAAmB,+BAA+B;IAClD,UAAU,qBAAqB;IAC/B,IAAI,eAAe;IACnB,aAAa,yBAAyB;CACvC"}
|
|
@@ -1,80 +1,20 @@
|
|
|
1
1
|
import { SingletonKosModelRegistrationBean } from '@kosdev-code/kos-ui-sdk';
|
|
2
2
|
import { AssemblyModel, AssemblyOptions } from './types';
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* Registration bean for {@link AssemblyModel}.
|
|
5
5
|
*
|
|
6
|
-
*
|
|
6
|
+
* - `type`: the model type, used by the model registry and in `@kosDependency` declarations.
|
|
7
|
+
* - `factory`: `Assembly.factory(options)` returns the single instance, creating it on the first call.
|
|
8
|
+
* - `predicate`: type guard that narrows an `IKosDataModel` to `AssemblyModel`.
|
|
9
|
+
* - `registration`: registry entry that can be spread into an `IKosRegistry["models"]` map.
|
|
7
10
|
*
|
|
8
|
-
*
|
|
9
|
-
* The type property is a string that identifies the model type.
|
|
10
|
-
* The type is used to identify the model type in the model registry and to narrow down the model type in type predicates. It's most frequently
|
|
11
|
-
* used when declaring dependencies on models.
|
|
11
|
+
* Assembly is a singleton. `KosModelRegistry.dispense.models()` registers it.
|
|
12
12
|
*
|
|
13
13
|
* @example
|
|
14
14
|
* ```typescript
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
* private assemblyModel: AssemblyModel;
|
|
18
|
-
* ```
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
* ## factory
|
|
22
|
-
*
|
|
23
|
-
* The factory method creates a factory function that can be used to create new AssemblyModel instances.
|
|
24
|
-
*
|
|
25
|
-
|
|
26
|
-
* The factory function is a curried function that takes the model id as the first argument and the options as the second argument.
|
|
27
|
-
*
|
|
28
|
-
* If a model with the specified id already exists, the factory function will return the existing model. The options will be ignored
|
|
29
|
-
* in this case and the existing model will be returned in its current state.
|
|
30
|
-
*
|
|
31
|
-
* @example
|
|
32
|
-
* ```typescript
|
|
33
|
-
* const model = Assembly.factory("assemblyId")({
|
|
34
|
-
* // Add option data
|
|
35
|
-
* });
|
|
36
|
-
* ```
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
*
|
|
40
|
-
* ## predicate
|
|
41
|
-
*
|
|
42
|
-
* [Typescript type predicate](https://www.typescriptlang.org/docs/handbook/2/narrowing.html#using-type-predicates) function that will identify and narrow down a model to a AssemblyModel.
|
|
43
|
-
*
|
|
44
|
-
* @example
|
|
45
|
-
* ```typescript
|
|
46
|
-
*
|
|
47
|
-
* const model: IKosDataModel = ...; // some model
|
|
48
|
-
*
|
|
49
|
-
* if (Assembly.predicate(model)) {
|
|
50
|
-
* // if the function evaluates to true, the model is narrowed down to AssemblyModel
|
|
51
|
-
* // and the compiler will know that the model has the AssemblyModel interface
|
|
52
|
-
* model.updateAvailability(false);
|
|
53
|
-
* }
|
|
54
|
-
* ```
|
|
55
|
-
*
|
|
56
|
-
* ## registration
|
|
57
|
-
*
|
|
58
|
-
* The registration property is an object that can be used to simplify registration of the model with the model registry. The registration object
|
|
59
|
-
* can be spread into the model registration and provides all of the required information to register the model implementation class against the model type.
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
* @example
|
|
63
|
-
*
|
|
64
|
-
* In an application registration file you can declare the model registration as follows:
|
|
65
|
-
*
|
|
66
|
-
* **registration.ts**
|
|
67
|
-
* ```typescript
|
|
68
|
-
* import { Assembly } from "@kosdev-code/kos-dispense-sdk";
|
|
69
|
-
* ...
|
|
70
|
-
* import { ExtensionManager, IKosRegistry } from "@kosdev-code/kos-ui-sdk";
|
|
71
|
-
* export const kosModels: IKosRegistry["models"] = {
|
|
72
|
-
* ...Assembly.registration,
|
|
73
|
-
* };
|
|
15
|
+
* @kosDependency({ modelType: Assembly.type })
|
|
16
|
+
* private assembly!: AssemblyModel;
|
|
74
17
|
* ```
|
|
75
|
-
|
|
76
|
-
* ## registration.singleton
|
|
77
|
-
* The assembly model is a singleton model. This means that each time the factory function the same instance of the model will be returned.
|
|
78
|
-
* */
|
|
18
|
+
*/
|
|
79
19
|
export declare const Assembly: Readonly<SingletonKosModelRegistrationBean<AssemblyModel, AssemblyOptions>>;
|
|
80
20
|
//# sourceMappingURL=assembly-registration.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assembly-registration.d.ts","sourceRoot":"","sources":["../../../../../../packages/kos-dispense-sdk/src/models/models/assembly/assembly-registration.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iCAAiC,EAAE,MAAM,yBAAyB,CAAC;AAGjF,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE9D
|
|
1
|
+
{"version":3,"file":"assembly-registration.d.ts","sourceRoot":"","sources":["../../../../../../packages/kos-dispense-sdk/src/models/models/assembly/assembly-registration.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iCAAiC,EAAE,MAAM,yBAAyB,CAAC;AAGjF,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE9D;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,QAAQ,EAAE,QAAQ,CAC7B,iCAAiC,CAAC,aAAa,EAAE,eAAe,CAAC,CAWlE,CAAC"}
|
|
@@ -1,88 +1,22 @@
|
|
|
1
1
|
import { KosModelRegistrationBean } from '@kosdev-code/kos-ui-sdk';
|
|
2
2
|
import { AvailabilityModel, AvailabilityOptions } from './types';
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* Registration bean for {@link AvailabilityModel}.
|
|
5
5
|
*
|
|
6
|
-
*
|
|
6
|
+
* - `type`: the model type, used by the model registry and in `@kosDependency` declarations.
|
|
7
|
+
* - `factory`: curried factory, `Availability.factory(id)(options)`. Returns the existing model when the id is already in use and ignores the options.
|
|
8
|
+
* - `predicate`: type guard that narrows an `IKosDataModel` to `AvailabilityModel`.
|
|
9
|
+
* - `registration`: registry entry that can be spread into an `IKosRegistry["models"]` map.
|
|
7
10
|
*
|
|
8
|
-
*
|
|
9
|
-
* The type property is a string that identifies the model type.
|
|
10
|
-
* The type is used to identify the model type in the model registry and to narrow down the model type in type predicates. It's most frequently
|
|
11
|
-
* used when declaring dependencies on models.
|
|
11
|
+
* Availability is not a singleton: each id has its own instance. `KosModelRegistry.dispense.models()` registers it.
|
|
12
12
|
*
|
|
13
13
|
* @example
|
|
14
14
|
* ```typescript
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
* private beverageModel: AvailabilityModel;
|
|
18
|
-
* ```
|
|
19
|
-
*
|
|
20
|
-
* ## factory
|
|
21
|
-
*
|
|
22
|
-
* The factory method creates a factory function that can be used to create new AvailabilityModel instances.
|
|
23
|
-
*
|
|
24
|
-
* The factory function is a curried function that takes the model id as the first argument and the options as the second argument.
|
|
25
|
-
*
|
|
26
|
-
* If a model with the specified id already exists, the factory function will return the existing model. The options will be ignored
|
|
27
|
-
* in this case and the existing model will be returned in its current state.
|
|
28
|
-
*
|
|
29
|
-
* @example
|
|
30
|
-
*
|
|
31
|
-
* ```typescript
|
|
32
|
-
* const cherryFlavor = Availability.factory("beverageId")({
|
|
33
|
-
* groupId: "flavor",
|
|
34
|
-
* rawId: "cherry",
|
|
35
|
-
* altId: "cherry",
|
|
36
|
-
* available: true,
|
|
37
|
-
* visible: true,
|
|
38
|
-
* // this data is added via extension point
|
|
39
|
-
* data: {
|
|
40
|
-
* name: "Cherry",
|
|
41
|
-
* description: "Cherry flavor",
|
|
42
|
-
* },
|
|
43
|
-
* });
|
|
44
|
-
* ```
|
|
45
|
-
*
|
|
46
|
-
* @param predicate
|
|
47
|
-
*
|
|
48
|
-
* [Typescript type predicate](https://www.typescriptlang.org/docs/handbook/2/narrowing.html#using-type-predicates) function that will identify and narrow down a model to a AvailabilityModel.
|
|
49
|
-
*
|
|
50
|
-
* @example
|
|
51
|
-
* ```typescript
|
|
52
|
-
*
|
|
53
|
-
* const model: IKosDataModel = ...; // some model
|
|
54
|
-
*
|
|
55
|
-
* if (Availability.predicate(model)) {
|
|
56
|
-
* // if the function evaluates to true, the model is narrowed down to AvailabilityModel
|
|
57
|
-
* // and the compiler will know that the model has the AvailabilityModel interface
|
|
58
|
-
* model.updateAvailability(false);
|
|
59
|
-
* }
|
|
60
|
-
* ```
|
|
61
|
-
*
|
|
62
|
-
* ## registration
|
|
63
|
-
*
|
|
64
|
-
* The registration property is an object that can be used to simplify registration of the model with the model registry. The registration object
|
|
65
|
-
* can be spread into the model registration and provides all of the required information to register the model implementation class against the model type.
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
* @example
|
|
69
|
-
*
|
|
70
|
-
* In an application registration file you can declare the model registration as follows:
|
|
71
|
-
*
|
|
72
|
-
* **registration.ts**
|
|
73
|
-
* ```typescript
|
|
74
|
-
* import { Availability } from "@kosdev-code/kos-dispense-sdk";
|
|
75
|
-
* ...
|
|
76
|
-
* import { ExtensionManager, IKosRegistry } from "@kosdev-code/kos-ui-sdk";
|
|
77
|
-
* export const kosModels: IKosRegistry["models"] = {
|
|
78
|
-
* ...Availability.registration,
|
|
79
|
-
* };
|
|
15
|
+
* @kosDependency({ modelType: Availability.type, id: "availabilityId" })
|
|
16
|
+
* private availability!: AvailabilityModel;
|
|
80
17
|
* ```
|
|
81
18
|
*
|
|
82
|
-
*
|
|
83
|
-
|
|
84
|
-
* The beverage model is not a singleton model. This means that each time the factory function is called with a unique ID, a new model instance will be created.
|
|
85
|
-
* If the factory function is called with an ID that already exists, the existing model will be returned.
|
|
86
|
-
* */
|
|
19
|
+
* @param predicate Type guard that narrows an `IKosDataModel` to `AvailabilityModel`.
|
|
20
|
+
*/
|
|
87
21
|
export declare const Availability: Readonly<KosModelRegistrationBean<AvailabilityModel, AvailabilityOptions>>;
|
|
88
22
|
//# sourceMappingURL=availability-model.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"availability-model.d.ts","sourceRoot":"","sources":["../../../../../../packages/kos-dispense-sdk/src/models/models/availability/availability-model.ts"],"names":[],"mappings":"AAAA,OAAO,EAOL,KAAK,wBAAwB,EAC9B,MAAM,yBAAyB,CAAC;AAEjC,OAAO,KAAK,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAoEtE
|
|
1
|
+
{"version":3,"file":"availability-model.d.ts","sourceRoot":"","sources":["../../../../../../packages/kos-dispense-sdk/src/models/models/availability/availability-model.ts"],"names":[],"mappings":"AAAA,OAAO,EAOL,KAAK,wBAAwB,EAC9B,MAAM,yBAAyB,CAAC;AAEjC,OAAO,KAAK,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAoEtE;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,YAAY,EAAE,QAAQ,CACjC,wBAAwB,CAAC,iBAAiB,EAAE,mBAAmB,CAAC,CAgBjE,CAAC"}
|
|
@@ -32,20 +32,11 @@ export interface AvailabilityOptions<
|
|
|
32
32
|
properties?: Properties;
|
|
33
33
|
}
|
|
34
34
|
/**
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
35
|
* Represents the nodes of the Beverage Availability graph for a nozzle.
|
|
38
36
|
*
|
|
39
|
-
* @typeParam AdditionalData -
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
* a given implementation might extend the Beverage Graph node to include additional data, such as the beverage name or
|
|
43
|
-
* an image url. This additional data would be added to the node and would be represented by the AdditionalData type parameter.
|
|
44
|
-
* ```typescript
|
|
45
|
-
* const model: AvailabilityModel<{icon: string}> = ...;
|
|
46
|
-
* ```
|
|
47
|
-
* would allow for visibility of all the base properties as well as the additional data (icon) that might be on the message payload from
|
|
48
|
-
* the backend.
|
|
37
|
+
* @typeParam AdditionalData - Application data added to a node by the
|
|
38
|
+
* {@link ExtensionType.AvailabilityMapper} extension point, such as a beverage name or image url.
|
|
39
|
+
* It is exposed on `data`, so `AvailabilityModel<{ icon: string }>` types `model.data.icon`.
|
|
49
40
|
*
|
|
50
41
|
* @category Model
|
|
51
42
|
*/
|
|
@@ -2,85 +2,20 @@ import { SingletonKosModelRegistrationBean } from '@kosdev-code/kos-ui-sdk';
|
|
|
2
2
|
import { BoardContainerModel } from './board-container-model';
|
|
3
3
|
import { BoardContainerOptions } from './types';
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* Registration bean for {@link BoardContainerModel}.
|
|
6
6
|
*
|
|
7
|
-
*
|
|
7
|
+
* - `type`: the model type, used by the model registry and in `@kosDependency` declarations.
|
|
8
|
+
* - `factory`: `BoardContainer.factory(options)` returns the single instance, creating it on the first call.
|
|
9
|
+
* - `predicate`: type guard that narrows an `IKosDataModel` to `BoardContainerModel`.
|
|
10
|
+
* - `registration`: registry entry that can be spread into an `IKosRegistry["models"]` map.
|
|
8
11
|
*
|
|
9
|
-
*
|
|
10
|
-
* The type property is a string that identifies the model type.
|
|
11
|
-
* The type is used to identify the model type in the model registry and to narrow down the model type in type predicates. It's most frequently
|
|
12
|
-
* used when declaring dependencies on models.
|
|
12
|
+
* BoardContainer is a singleton. `KosModelRegistry.dispense.models()` registers it.
|
|
13
13
|
*
|
|
14
14
|
* @example
|
|
15
15
|
* ```typescript
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
* private boardContainerModel: BoardContainerModel;
|
|
16
|
+
* @kosDependency({ modelType: BoardContainer.type })
|
|
17
|
+
* private boardContainer!: BoardContainerModel;
|
|
19
18
|
* ```
|
|
20
|
-
|
|
21
|
-
*
|
|
22
|
-
* ## factory
|
|
23
|
-
*
|
|
24
|
-
* The factory method creates a factory function that can be used to create new BoardContainerModel instances.
|
|
25
|
-
*
|
|
26
|
-
|
|
27
|
-
* As this is a singleton model, the factory function accepts the model options as its argument.
|
|
28
|
-
*
|
|
29
|
-
* If a model with the same model type already exists, the factory function will return the existing model. The options will be ignored
|
|
30
|
-
* in this case and the existing model will be returned in its current state.
|
|
31
|
-
*
|
|
32
|
-
* @example
|
|
33
|
-
* ```typescript
|
|
34
|
-
* const model = BoardContainer.factory({
|
|
35
|
-
* // Add option data
|
|
36
|
-
* });
|
|
37
|
-
* ```
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
*
|
|
41
|
-
* ## predicate
|
|
42
|
-
*
|
|
43
|
-
* [Typescript type predicate](https://www.typescriptlang.org/docs/handbook/2/narrowing.html#using-type-predicates) function that will identify and narrow down a model to a BoardContainerModel.
|
|
44
|
-
*
|
|
45
|
-
* @example
|
|
46
|
-
* ```typescript
|
|
47
|
-
*
|
|
48
|
-
* const model: IKosDataModel = ...; // some model
|
|
49
|
-
*
|
|
50
|
-
* if (BoardContainer.predicate(model)) {
|
|
51
|
-
* // if the function evaluates to true, the model is narrowed down to BoardContainerModel
|
|
52
|
-
* // and the compiler will know that the model has the BoardContainerModel interface
|
|
53
|
-
* model.updateAvailability(false);
|
|
54
|
-
* }
|
|
55
|
-
* ```
|
|
56
|
-
*
|
|
57
|
-
* ## registration
|
|
58
|
-
*
|
|
59
|
-
* The registration property is an object that can be used to simplify registration of the model with the model registry. The registration object
|
|
60
|
-
* can be spread into the model registration and provides all of the required information to register the model implementation class against the model type.
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
* @example
|
|
64
|
-
*
|
|
65
|
-
* In an application registration file you can declare the model registration as follows:
|
|
66
|
-
*
|
|
67
|
-
* **registration.ts**
|
|
68
|
-
* ```typescript
|
|
69
|
-
* import { BoardContainer } from "@kosdev-code/kos-dispense-sdk";
|
|
70
|
-
* ...
|
|
71
|
-
* import { ExtensionManager, IKosRegistry } from "@kosdev-code/kos-ui-sdk";
|
|
72
|
-
* export const kosModels: IKosRegistry["models"] = {
|
|
73
|
-
* ...BoardContainer.registration,
|
|
74
|
-
* };
|
|
75
|
-
* ```
|
|
76
|
-
*
|
|
77
|
-
* ## registration.singleton
|
|
78
|
-
|
|
79
|
-
* The boardContainer model is a singleton model. This means that each time the factory function is called , the same instance will be returned.
|
|
80
|
-
* If the model does not yet exist, it will be created passing in the provided options to initialize it.
|
|
81
|
-
*
|
|
82
|
-
* Singleton models don't require an ID as they will use the model type as their ID to guarantee uniqueness throughout the system.
|
|
83
|
-
|
|
84
|
-
* */
|
|
19
|
+
*/
|
|
85
20
|
export declare const BoardContainer: Readonly<SingletonKosModelRegistrationBean<BoardContainerModel, BoardContainerOptions>>;
|
|
86
21
|
//# sourceMappingURL=board-container-registration.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"board-container-registration.d.ts","sourceRoot":"","sources":["../../../../../../packages/kos-dispense-sdk/src/models/models/board/board-container-registration.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iCAAiC,EAAE,MAAM,yBAAyB,CAAC;AAEjF,OAAO,EAAE,mBAAmB,EAAc,MAAM,yBAAyB,CAAC;AAE1E,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAErD
|
|
1
|
+
{"version":3,"file":"board-container-registration.d.ts","sourceRoot":"","sources":["../../../../../../packages/kos-dispense-sdk/src/models/models/board/board-container-registration.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iCAAiC,EAAE,MAAM,yBAAyB,CAAC;AAEjF,OAAO,EAAE,mBAAmB,EAAc,MAAM,yBAAyB,CAAC;AAE1E,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAErD;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,cAAc,EAAE,QAAQ,CACnC,iCAAiC,CAAC,mBAAmB,EAAE,qBAAqB,CAAC,CAc9E,CAAC"}
|