UNPKG

@citrineos/base

Version:

The base module for OCPP v2.0.1 including all interfaces. This module is not intended to be used directly, but rather as a dependency for other modules.

33 lines 1.62 kB
// Copyright (c) 2023 S44, LLC // Copyright Contributors to the CitrineOS Project // // SPDX-License-Identifier: Apache 2.0 import { DEFAULT_TENANT_ID } from '../../config/defineConfig'; /** * Cache namespace, used for grouping cache entries */ export var CacheNamespace; (function (CacheNamespace) { CacheNamespace["CentralSystem"] = "csms"; CacheNamespace["ChargingStation"] = "cs"; CacheNamespace["Transactions"] = "tx"; CacheNamespace["Connections"] = "conn"; CacheNamespace["Protocol"] = "prtcl"; CacheNamespace["Other"] = "other"; })(CacheNamespace || (CacheNamespace = {})); /* * Helper methods to create a unique identifier used in the cache and queues. * This is usually a combination between the tenantId and the stationId. */ export const IDENTIFIER_DELIMITER = ':'; export const createIdentifier = (tenantId, ...args) => [tenantId, ...(args !== null && args !== void 0 ? args : [])].join(IDENTIFIER_DELIMITER); export const getTenantIdFromIdentifier = (identifier) => { const identifierSplit = identifier.split(IDENTIFIER_DELIMITER); return (identifierSplit === null || identifierSplit === void 0 ? void 0 : identifierSplit[0]) ? Number(identifierSplit === null || identifierSplit === void 0 ? void 0 : identifierSplit[0]) : DEFAULT_TENANT_ID; }; export const getStationIdFromIdentifier = (identifier) => { var _a; const identifierSplit = identifier.split(IDENTIFIER_DELIMITER); return (_a = identifierSplit === null || identifierSplit === void 0 ? void 0 : identifierSplit[1]) !== null && _a !== void 0 ? _a : identifier; }; //# sourceMappingURL=types.js.map