{"version":3,"file":"index.node.cjs","sources":["../src/globals/coding/code.formating.ts","../src/node/api/models.errors.ts","../src/globals/coding/code.dates.ts","../src/globals/coding/formats.csv.ts","../src/globals/panther/utils.panther.ts","../src/globals/panther/enums.panther.ts","../src/node/api/parsing.errors.ts","../src/node/logging/logger.ts","../src/node/api/validations.shared.ts","../src/node/api/parse.changeNodes.ts","../src/node/api/parse.arrows.json.ts","../src/node/api/parse.changesEdges.ts","../src/node/apps/enums.general.ts","../src/node/apps/utils.environment.ts","../src/node/api/swagger.universal.ts","../src/node/sqlite/enums.sqlite.ts","../src/node/sqlite/defaults.sqlite.ts","../src/node/sqlite/sqlite.connection.ts","../src/node/sqlite/sqlite.commands.ts","../src/node/sqlite/sqlite.queries.ts"],"sourcesContent":["/**\n * Check, if the string is url\n * @param candidate Candidate input, to be checked\n * @returns Is this string url?\n */\nexport const isUrl = (candidate: string) => {\n  try {\n    new URL(candidate)\n    return true\n  } catch {\n    return false\n  }\n}\n\n/**\n * Check, if the string array contain urls\n * @param candidates Candidate input array, to be checked\n * @returns Is this string array only from url?\n */\nexport const isArrayOfUrls = (candidates: string[]) => candidates.every(candidate => isUrl(candidate))\n\n/**\n * Check if the value in included in enum posibilities.\n * @param value Value we need to check\n * @param enumEntity Enum type we check againts the value\n * @returns Is the value in this enum?\n */\nexport const isInEnum = (value: any, enumEntity: any) => {\n    const allEnumValues = Object.values(enumEntity) as string[]\n    return allEnumValues.includes(value)\n  }\n\n/**\n * Sort array of string elements\n * @param rawArray Raw unsorted array of elements\n * @returns Sorted string array\n */\nexport const sortStringArray = (rawArray: string[]) => rawArray.sort()\n\n/**\n * Remove all duplicity string items from an array\n * @param arr Original array with duplicities\n * @returns Array of original values\n */\nexport const removeDuplicitiesFromArray = (arr: any[]) => [...new Set(arr)]\n\n\n/**\n * Check if the string value is not ` \"\" `\n * @param value Value to check\n * @returns Boolean result about the truth\n */\nexport const notEmptyString = (value: string) => value !== \"\"\n\n\n/**\n * Return enum values as array of string\n * @param enumType Type of the enum from code\n * @param separator Optional - separator character\n * @returns Array of enum possible values\n */\nexport const enumValuesToString = (enumType: any, separator = \", \") => Object.values(enumType).join(separator)\n\n/**\n * Return enum values as array of string\n * @param enumTypes Combination of enum types\n * @param separator Optional - separator character\n * @returns Array of enum possible values\n */\nexport const enumCombineValuesToString = (enumTypes: any[], separator = \", \") => enumTypes.map(enumType => enumValuesToString(enumType, separator)).join(separator)\n\n/**\n * Return all enum values as array\n * @param enumType What array we want to work with\n * @returns Array of enum values\n */\nexport const enumValuesToArray = (enumType: any) => Object.values(enumType) as string[]\n\n/**\n * Return random number (integer) between two values\n * @param min \n * @param max \n * @returns \n */\nexport const randomNumberBetween = (min: number, max: number) => {\n  const minAr = Math.ceil(min)\n  const maxAr = Math.floor(max)\n  return Math.floor(Math.random()*(maxAr - minAr + 1) + min)\n}\n\n/**\n * Recursively flattens a nested object. The keys of the resulting object\n * will be the paths to the original values in the nested object, joined by dots.\n *\n * @param obj - The object to flatten.\n * @param prefix - The prefix to use for the keys in the flattened object. Defaults to an empty string.\n * @returns A new object with flattened keys.\n *\n * @example\n * ```typescript\n * const nestedObj = {\n *   a: {\n *     b: {\n *       c: 1\n *     }\n *   },\n *   d: 2\n * };\n * const flatObj = flattenObject(nestedObj);\n * console.log(flatObj);\n * // Output: { 'a.b.c': 1, 'a.b.d': 2 }\n * ```\n */\nexport const flattenObject = (obj: any, prefix = ''): Record<string, any> => {\n    return Object.keys(obj).reduce((acc: Record<string, any>, key: string) => {\n        const propName = prefix ? `${prefix}.${key}` : key\n        if (typeof obj[key] === 'object' && obj[key] !== null && !Array.isArray(obj[key])) {\n            Object.assign(acc, flattenObject(obj[key], propName))\n        } else {\n            acc[propName] = obj[key]\n        }\n        return acc\n    }, {})\n}","/**\n * We miss a API parameter needed to process action\n */\nclass InvalidRequestError extends Error{\n  constructor(message: string){\n    super(`Invalid Request: ${message}`)\n  }\n}\n\n/**\n * Where client has general authorization issue\n */\nclass AuthorizationError extends Error{\n  constructor(){\n    super(`Authorization has failed.`)\n  }\n}\n\n/**\n * General backend server side error\n */\nclass ServerError extends Error{\n  constructor(message: string){\n    super(`Server Error: ${message}`)\n  }\n}\n\n/**\n * Error to indicate that some functionality is SSR only\n */\nclass SSROnlyError extends Error{\n  constructor(message: string){\n    super(`SSR Only Error: ${message}`)\n  }\n}\n\nexport {\n    InvalidRequestError,\n    AuthorizationError,\n    ServerError,\n    SSROnlyError\n} ","import { DateTime } from \"luxon\"\nimport { InvalidRequestError } from \"../../node/api/models.errors\"\n\n/**\n * Return epoch timestamp\n * @param regime Set if you want milisecond format or second format\n * @returns \n */\nexport const nowTimestamp = (regime: \"milisecond\" | \"second\" = \"milisecond\"): number => {\n  const timestamp = DateTime.now().toMillis()\n  return regime === \"second\" ? Math.round((timestamp / 1000)) : timestamp\n}\n\n/**\n * Return now local timestamp plus number of seconds to add\n * @param secondsToAdd Seconds to add from now (1 = now + 1 sec.)\n * @returns Timestamp of the future (past) on seconds\n */\nexport const nowPlusTime = (secondsToAdd: number) => {\n  return Math.round(DateTime.now().plus({seconds: secondsToAdd}).toSeconds())\n}\n\n/**\n * Convert epoch time value into ISO format\n * @param epochValue Epoch value of the timestamp\n * @returns ISO format of the date\n */\nexport const epochToIsoFormat = (epochValue: number) => DateTime.fromMillis(epochValue).toISO() as string\n\n/**\n * Return epoch timestamp\n * @param regime Set if you want milisecond format or second format\n * @returns \n */\nexport const nowTimestampIso = () => {\n  const timestamp = DateTime.now().toISO()\n  return timestamp as string\n}\n\n/**\n * Check if input date is valid for ISO format\n * @param dateToCheck \n * @returns \n */\n export const hasIsoFormat = (dateToCheck: string) => {\n  try{\n    const toDate = new Date(Date.parse(dateToCheck))\n    const isoCheck = toDate.toISOString().includes(dateToCheck) \n    return isoCheck\n  }\n  catch{\n    return false\n  }\n}\n\n/**\n * Convert date in ISO formtat to milisecond timestamp\n * @param isoDate Date in ISO 8601 format\n * @returns Timestamp representing the date in miliseconds\n */\nexport const isoDateToTimestamp = (isoDate: string) => DateTime.fromISO(isoDate).toMillis()\n\n/**\n * Format ISO 8601 interval to from-to values\n * @param interval Defined inteval in ISO format (from/to) of the UTC\n * @returns Tuple - from timestamp and to timestamp\n */\nexport const isoIntervalToTimestamps = (interval: string): [number, number] => {\n\n  // Split the interval into two parts\n  const intervals = interval.split(\"/\")\n\n  // interval as a single year has just one part\n  if (intervals.length == 1) {\n    const newIso = `${interval}-01-01/${interval}-12-31`\n    return isoIntervalToTimestamps(newIso)\n  }\n\n  // interval with two parts or less than one\n  else if (intervals.length > 2 || intervals.length < 1)\n    throw new InvalidRequestError(\"Interval can have only two parameters\")\n\n  // valid interval with two parts\n  else {\n    if (!intervals.every(interval => hasIsoFormat(interval)))\n      throw new InvalidRequestError(\"Parameter utcIntervalIso is not ISO 8601 time interval (date01/date02) or year\");\n\n    const [int1, int2] = intervals.map(intervalIso => {\n      const cleared = intervalIso.replace(\" \", \"\")\n      return isoDateToTimestamp(cleared)\n    })\n\n    return [int1, int2]\n  }\n}\n","// TODO: Cover by tests\n// TODO: mode to ptr-be-core as general CSV methods\n\n\n/**\n * Parses a single line of CSV-formatted strings into an array of trimmed string values.\n *\n * @param csvStingsLine - A string representing a single line of comma-separated values.\n * @returns An array of strings, each representing a trimmed value from the CSV line.\n */\nexport const csvParseStrings = (csvStingsLine: string): string[] => {\n  return csvStingsLine.split(\",\").map((value: string) => value.trim());\n}\n\n/**\n * Parses a comma-separated string of numbers into an array of numbers.\n *\n * @param csvNumbersLine - A string containing numbers separated by commas (e.g., \"1, 2, 3.5\").\n * @returns An array of numbers parsed from the input string.\n */\nexport const csvParseNumbers = (csvNumbersLine: string): number[] => {\n  return csvNumbersLine.split(\",\").map((value: string) => parseFloat(value.trim()));\n}","import { UsedDatasourceLabels, UsedEdgeLabels, UsedNodeLabels } from \"./enums.panther\"\nimport { GraphEdge } from \"./models.edges\"\nimport { FullPantherEntity } from \"./models.nodes\"\n\n/**\n * Finds the first node in the provided list that contains the specified label.\n *\n * Searches the given array of FullPantherEntity objects and returns the first entity\n * whose `labels` array includes the provided label.\n *\n * @param nodes - Array of FullPantherEntity objects to search through.\n * @param label - Label to match; may be a UsedDatasourceLabels or UsedNodeLabels.\n * @returns The first FullPantherEntity whose `labels` includes `label`, or `undefined`\n *          if no such entity is found.\n *\n * @remarks\n * - The search stops at the first match (uses `Array.prototype.find`).\n * - Label comparison is exact (uses `Array.prototype.includes`), so it is case-sensitive\n *   and requires the same string instance/value.\n *\n * @example\n * const result = findNodeByLabel(nodes, 'datasource-main');\n * if (result) {\n *   // found a node that has the 'datasource-main' label\n * }\n */\nexport const findNodeByLabel = (\n  nodes: FullPantherEntity[],\n  label: UsedDatasourceLabels | UsedNodeLabels): FullPantherEntity | undefined => {\n  return nodes.find(n => n.labels.includes(label))\n}\n\n/**\n * Filters an array of FullPantherEntity objects, returning only those that contain the specified label.\n *\n * The function performs a shallow, non-mutating filter: it returns a new array and does not modify the input.\n * Matching is done using Array.prototype.includes on each entity's `labels` array (strict equality).\n *\n * @param nodes - The array of entities to filter.\n * @param label - The label to match; can be a UsedDatasourceLabels or UsedNodeLabels value.\n * @returns A new array containing only the entities whose `labels` array includes the provided label.\n *\n * @remarks\n * Time complexity is O(n * m) where n is the number of entities and m is the average number of labels per entity.\n *\n * @example\n * ```ts\n * const matched = filterNodeByLabel(entities, 'MY_LABEL');\n * ```\n */\nexport const filterNodeByLabel = (\n  nodes: FullPantherEntity[],\n  label: UsedDatasourceLabels | UsedNodeLabels): FullPantherEntity[] => {\n  return nodes.filter(n => n.labels.includes(label))\n}\n\n/**\n * Finds the first edge in the provided array whose label strictly equals the given label.\n *\n * @param edges - Array of GraphEdge objects to search.\n * @param label - The UsedEdgeLabels value to match against each edge's `label` property.\n * @returns The first matching GraphEdge if found; otherwise `undefined`.\n *\n * @example\n * const edge = findEdgeByLabel(edges, 'dependency');\n * if (edge) {\n *   // handle found edge\n * }\n */\nexport const findEdgeByLabel = (\n  edges: GraphEdge[],\n  label: UsedEdgeLabels): GraphEdge | undefined => {\n  return edges.find(e => e.label === label)\n}\n\n/**\n * Filters a list of GraphEdge objects by a specific edge label.\n *\n * Returns a new array containing only those edges whose `label` property\n * strictly equals the provided `label` argument. The original `edges`\n * array is not mutated.\n *\n * @param edges - Array of GraphEdge objects to filter.\n * @param label - The label to match; comparison is performed using strict (`===`) equality.\n * @returns A new array of GraphEdge objects whose `label` matches the provided label. Returns an empty array if no edges match.\n *\n * @remarks\n * Time complexity: O(n), where n is the number of edges.\n *\n * @example\n * // const result = filterEdgeByLabel(edges, 'CONNECTS');\n */\nexport const filterEdgeByLabel = (\n  edges: GraphEdge[],\n  label: UsedEdgeLabels): GraphEdge[] => {\n  return edges.filter(e => e.label === label)\n}","/**\n * What types of graph nodes we use in metadata model\n */\nexport enum UsedNodeLabels {\n    Application = \"application\", // Application node (the root of the FE app)\n    Datasource = \"datasource\", // Datasource node for data including GIS information\n    Place = \"place\", // Place node for geographical information\n    Period = \"period\", // Period node for time information\n    AreaTree = \"areaTree\", // Area tree node for administrative division\n    AreaTreeLevel = \"areaTreeLevel\", // Area tree level node for administrative division\n    Layer = \"layer\", // Layer node for map layer (layer have a style and a datasource)\n    Style = \"style\", // Style node for map layer or a feature\n    Feature = \"feature\", // Feature node for map layer,\n    Attribute = \"attribute\" // Attribute node for properties of entities, like \"temperature\", \"population\", etc.\n}\n\n/**\n * What datasources we use in the system\n */\nexport enum UsedDatasourceLabels {\n    Attribute = \"attributeSource\",   // Column(s) with attribute values\n    Geojson = \"geojson\",      // Geojson for web map\n    WMS = \"wms\",              // WMS online source\n    COG = \"cloudOptimizedGeotiff\", // COG online source\n    MVT = \"mvt\",              // MVT (Mapbox Vector Tiles) source\n    XYZ = \"xyz\",              // XYZ tile source\n    CSV = \"csv\",              // CSV data source\n    GeoTIFF = \"geotiff\",      // GeoTIFF raster data\n    Shapefile = \"shapefile\",   // ESRI Shapefile format\n    PostGIS = \"postgis\",      // PostGIS database source\n    WMTS = \"wmts\",            // Web Map Tile Service\n    WFS = \"wfs\",              // Web Feature Service\n    GeoPackage = \"geopackage\", // OGC GeoPackage format\n    MapStyle = \"mapStyle\", // Map style datasource\n    Timeseries = \"timeseries\" // Timeseries datasource (with from-to and step)\n}\n\n/**\n * What types of edges we use in metadata model\n */\nexport enum UsedEdgeLabels {\n    RelatedTo = \"RELATED\", // Generic edge for any relation\n    Has = \"HAS\", // Edge for ownership relation\n    InPostgisLocation = \"IN_POSTGIS_LOCATION\" // Edge to connect datasource with PostGIS location (schema, table, geometry column)\n}\n\n/**\n * What time steps are used in timeseries data\n */\nexport enum UsedTimeseriesSteps{\n    Year = \"year\",\n    Quarter = \"quarter\",\n    Month = \"month\",\n    Week = \"week\",\n    Day = \"day\"\n}","import { AuthorizationError, InvalidRequestError } from \"./models.errors\"\n\nexport const handleRouteError = (error: unknown) => {\n\t\n    // lets work with the error as an object\n\tconst processedError = error as any;\n\n\t// need to know the type of error to handle it properly\n\tconst errorType = processedError.constructor;\n\n\t// switch on the error type as we know how to handle our errors\n\tswitch (errorType) {\n\t\tcase InvalidRequestError:\n\t\t\treturn { message: processedError.message, status: 400 };\n        case AuthorizationError:\n            return { message: processedError.message, status: 401 };\n\t\tdefault:\n\t\t\treturn { message: processedError.message, status: 500 }; // default status code for server errors\n\t}\n};\n\n\n/**\n * Extract message from exception error (try-catch)\n * @param error error from catch block as any\n * @returns \n */\n export const messageFromError = (error: any) => error[\"message\"] as string\n","import pino from 'pino'\n\n/**\n * Shared pino logger instance used by all logging functions.\n *\n * The logger uses ISO timestamps and a simple level formatter that exposes\n * the textual level as the `level` property on emitted objects.\n */\nconst logger = pino({\n  timestamp: pino.stdTimeFunctions.isoTime,\n  formatters: {\n\n    // eslint-disable-next-line @typescript-eslint/no-unused-vars\n    level(label, number) {\n      return { level: label }\n    }\n  }\n})\n\n\n/**\n * Log an informational message.\n *\n * @param {string} label - Short label or category for the log entry.\n * @param {string} message - Human-readable log message.\n * @param {Record<string, any>} [options={}] - Additional metadata to include.\n */\nexport const loggyInfo = (label: string, message: string, options: Record<string, any> = {}): void => {\n  logger.info({ ...options, label, message })\n}\n\n\n/**\n * Log a debug-level message.\n *\n * @param {string} label - Short label or category for the log entry.\n * @param {string} message - Human-readable debug message.\n * @param {Record<string, any>} [options={}] - Additional metadata to include.\n */\nexport const loggyDebug = (label: string, message: string, options: Record<string, any> = {}): void => {\n  logger.debug({ ...options, label, message })\n}\n\n\n/**\n * Log a warning-level message.\n *\n * @param {string} label - Short label or category for the log entry.\n * @param {string} message - Human-readable warning message.\n * @param {Record<string, any>} [options={}] - Additional metadata to include.\n */\nexport const loggyWarn = (label: string, message: string, options: Record<string, any> = {}): void => {\n  logger.warn({ ...options, label, message })\n}\n\n\n/**\n * Log a trace-level message.\n *\n * @param {string} label - Short label or category for the log entry.\n * @param {string} message - Human-readable trace message.\n * @param {Record<string, any>} [options={}] - Additional metadata to include.\n */\nexport const loggyTrace = (label: string, message: string, options: Record<string, any> = {}): void => {\n  logger.trace({ ...options, label, message })\n}\n\n\n/**\n * Log a fatal message.\n *\n * Use for unrecoverable errors that will abort the process.\n *\n * @param {string} label - Short label or category for the log entry.\n * @param {string} message - Human-readable fatal message.\n * @param {Record<string, any>} [options={}] - Additional metadata to include.\n */\nexport const loggyFatal = (label: string, message: string, options: Record<string, any> = {}): void => {\n  logger.fatal({ ...options, label, message })\n}\n\n\n/**\n * Log an error. When an `Error` instance is provided, its stack is included\n * in the logged metadata.\n *\n * @param {string} label - Short label or category for the log entry.\n * @param {Error|string} err - The error object or an error message string.\n * @param {Record<string, any>} [options={}] - Additional metadata to include.\n */\nexport const loggyError = (label: string, err: Error | string, options: Record<string, any> = {}): void => {\n  const message = typeof err === 'string' ? err : err.message\n  const extra = typeof err === 'string' ? options : { ...options, stack: err.stack }\n  logger.error({ ...extra, label, message })\n}\n\n\n/**\n * Convenience logger for application start information.\n *\n * @param {string} host - Hostname or IP the app is bound to.\n * @param {number} port - Port number the app is listening on.\n * @param {Record<string, any>} [options={}] - Additional metadata to include.\n */\nexport const loggyAppStart = (\n  host: string,\n  port: number,\n  options: Record<string, any> = {}) => {\n  loggyInfo(\"Application started\", `Running on ${host}:${port}`, options)\n}\n\n\n/**\n * Log that an HTTP request was received.\n *\n * @param {string} route - The route or URL path requested.\n * @param {string} method - HTTP method (GET, POST, etc.).\n * @param {Record<string, any>} [options={}] - Additional metadata to include (e.g., headers, id).\n */\nexport const loggyRequestReceived = (\n  route: string,\n  method: string,\n  options: Record<string, any> = {}) => {\n  loggyInfo(\"Request Received\", `${method}: ${route}`, options)\n}\n\n\n/**\n * Log that an HTTP response was sent.\n *\n * @param {string} route - The route or URL path the response corresponds to.\n * @param {string} method - HTTP method (GET, POST, etc.).\n * @param {number} status - HTTP status code returned.\n * @param {Record<string, any>} [options={}] - Additional metadata to include (e.g., timings).\n */\nexport const loggyResponseSent = (\n  route: string,\n  method: string,\n  status: number,\n  options: Record<string, any> = {}) => {\n  loggyInfo(\"Response Sent\", `${status}: ${route}`, { ...options, method })\n}","import _ from \"lodash\"\nimport { enumCombineValuesToString, isInEnum } from \"../../globals/coding/code.formating\"\nimport { InvalidRequestError } from \"./models.errors\"\nimport { UsedDatasourceLabels, UsedEdgeLabels, UsedNodeLabels } from \"../../globals/panther/enums.panther\"\n\n\n/**\n * Validates the provided labels to ensure they are an array of strings and that each label\n * is a valid value within the specified enums (`UsedNodeLabels` or `UsedDatasourceLabels`).\n *\n * @param labels - The input to validate, expected to be an array of strings.\n * @throws {InvalidRequestError} If `labels` is not an array.\n * @throws {InvalidRequestError} If any label in the array is not a valid value in the combined enums.\n */\nexport const validateNodeLabels = (labels: unknown) => {\n\n  if (labels === undefined || labels === null) {\n    throw new InvalidRequestError(\"Graph node labels are required.\")\n  }\n\n  if (!_.isArray(labels))\n    throw new InvalidRequestError(`Graph node labels must be an array of strings.`)\n\n  if (labels.length === 0)\n    throw new InvalidRequestError(\"Graph node labels array must contain at least one label.\")\n\n  for (const label of labels) {\n    if (!isInEnum(label, UsedNodeLabels) && !isInEnum(label, UsedDatasourceLabels))\n      throw new InvalidRequestError(`Label ${label} is not supported. Value must be one of: ${enumCombineValuesToString([UsedNodeLabels, UsedDatasourceLabels])}`)\n  }\n}\n\n/**\n * Validate a graph edge label.\n *\n * The value is first checked for presence (not `undefined`/`null`), then for type (`string`).\n * The string is normalised using `toLocaleLowerCase()` and validated against the `UsedEdgeLabels` enum.\n *\n * @param label - The value to validate; expected to be a string representing an edge label.\n *\n * @throws {InvalidRequestError} If `label` is `undefined` or `null`.\n * @throws {InvalidRequestError} If `label` is not a `string`.\n * @throws {InvalidRequestError} If the normalised label is not one of the supported values in `UsedEdgeLabels`.\n *\n * @example\n * validateEdgeLabel('CONNECTS'); // succeeds if 'connects' exists in UsedEdgeLabels\n *\n * @remarks\n * Membership is determined via `isInEnum` and error messages include the allowed values (via `enumCombineValuesToString`).\n */\nexport const validateEdgeLabel = (label: unknown) => {\n\n  if (label === undefined || label === null) {\n    throw new InvalidRequestError(\"Graph edge label is required.\")\n  }\n\n  if (typeof label !== \"string\") {\n    throw new InvalidRequestError(`Graph edge label must be a string.`)\n  }\n\n  const normalisedLabel = label.toLocaleLowerCase()\n\n  if (!isInEnum(normalisedLabel, UsedEdgeLabels)) {\n    throw new InvalidRequestError(`Graph edge label '${normalisedLabel}' is not supported. Value must be one of: ${enumCombineValuesToString([UsedEdgeLabels])}`)\n  }\n}","import { randomUUID } from \"crypto\"\nimport _ from \"lodash\"\nimport { Unsure } from \"../../globals/coding/code.types\"\nimport { FullPantherEntity, PantherEntity } from \"../../globals/panther/models.nodes\"\nimport { HasConfiguration, HasGeometry, HasInterval, HasLevels, HasUnits } from \"../../globals/panther/models.nodes.properties.general\"\nimport { InvalidRequestError } from \"./models.errors\"\nimport { HasBands, HasColor, HasDocumentId, HasSpecificName, HasTimeseries, HasUrl } from \"../../globals/panther/models.nodes.properties.datasources\"\nimport { UsedDatasourceLabels, UsedNodeLabels } from \"../../globals/panther/enums.panther\"\nimport { validateNodeLabels } from \"./validations.shared\"\nimport { isoIntervalToTimestamps, nowTimestamp } from \"../../globals/coding/code.dates\"\nimport { csvParseNumbers, csvParseStrings } from \"../../globals/coding/formats.csv\"\n\n/**\n * Extract and parse basic entitry from request body\n * This parse function is used in other parsers, becuase basic entity is part of other models\n * @param bodyRaw Body from http request\n * @param key Optional - key value for existing recods in database\n * @returns Parsed entity - all unwanted parameters are gone\n */\nconst parseBasicNodeFromBody = (bodyRaw: unknown): PantherEntity => {\n  const {\n    labels,\n    nameInternal,\n    nameDisplay,\n    description,\n    key\n  } = bodyRaw as any\n\n  validateNodeLabels(labels)\n\n  const basicGraphResult: PantherEntity = {\n    lastUpdatedAt: nowTimestamp(),\n    key: key ?? randomUUID(),\n    nameInternal: nameInternal as string ?? \"\",\n    nameDisplay: nameDisplay as string ?? \"\",\n    description: description as string ?? \"\",\n    labels: labels as string[]\n  }\n\n  return basicGraphResult\n}\n\n/**\n * Parse node of type area tree level \n * @param levelBody Content from request\n * @returns Parsed area tree level\n */\nconst paseHasLevels = (levelBody: unknown): HasLevels => {\n  const { level } = levelBody as any\n\n  const result: HasLevels = {\n    level\n  }\n\n  return result\n}\n\n/**\n * Parse body to period entity\n * @param bodyRaw Request body content - can be anything\n * @returns Parsed entity - all unwanted parameters are gone\n */\nconst parseWithInterval = (bodyRaw: any): HasInterval => {\n  const {\n    intervalISO,\n  } = bodyRaw\n\n  if (!intervalISO)\n    throw new InvalidRequestError(\"Period must have UTC interval in ISO format\")\n\n  const [from, to] = isoIntervalToTimestamps(intervalISO)\n  const intervalResult: HasInterval = {\n    validIntervalIso: intervalISO,\n    validFrom: from,\n    validTo: to\n  }\n\n  return intervalResult\n}\n\nconst parseWithConfiguration = (bodyRaw: any, required = false): Unsure<HasConfiguration> => {\n  const { configuration } = bodyRaw\n\n  if (!configuration && required)\n    throw new InvalidRequestError(\"Configuration is required\")\n\n  if (!configuration)\n    return\n\n  return { configuration: typeof configuration === 'string' ? configuration : JSON.stringify(configuration) }\n}\n\n/**\n * Parse body to place entity\n * @param bodyRaw Request body content - can be anything\n * @returns \n */\nconst parseHasGeometry = (bodyRaw: any) => {\n  const {\n    bbox,\n    geometry,\n  } = bodyRaw\n\n  /**\n   * Convert bbox from CSV string to array of 4 coordinates\n   * @returns Parsed bounding box from CSV string\n   */\n  const bboxFromCSV = () => {\n    const bboxFromCSV = csvParseNumbers(bbox as string)\n\n    if (bboxFromCSV.length !== 4)\n      throw new InvalidRequestError(\"bbox must be an array of 4 numbers\")\n\n    return bboxFromCSV\n  }\n\n  const geometryResult: HasGeometry = {\n    bbox: bbox ? bboxFromCSV() : [],\n    geometry: geometry ?? \"\"\n  }\n\n  return geometryResult\n}\n\n/**\n * Parses the input object and extracts the `url` property.\n * If the `url` property is not present or is undefined, it returns `null` for `url`.\n *\n * @param bodyRaw - The raw input object that may contain a `url` property.\n * @returns An object with a single `url` property, which is either the extracted value or `null`.\n */\nconst parseHasUrl = (bodyRaw: any, isRequired = true): Unsure<HasUrl> => {\n  const { url } = bodyRaw\n\n  if (isRequired && !url)\n    throw new InvalidRequestError(\"Url is required for the node\")\n\n  if (!url) return\n\n  return { url }\n}\n\n/**\n * Parses the `specificName` property from the provided object and returns it wrapped in a `HasSpecificName` type.\n *\n * @param bodyRaw - The raw input object potentially containing the `specificName` property.\n * @param isRequired - If `true`, throws an `InvalidRequestError` when `specificName` is missing. Defaults to `false`.\n * @returns An object with the `specificName` property if present, or `undefined` if not required and missing.\n * @throws {InvalidRequestError} If `isRequired` is `true` and `specificName` is not provided.\n */\nconst parseHasSpecificName = (bodyRaw: any, isRequired = false): Unsure<HasSpecificName> => {\n  const { specificName } = bodyRaw\n\n  if (isRequired && !specificName)\n    throw new InvalidRequestError(\"Property specificName is required for the node\")\n\n  if (!specificName) return\n\n  return { specificName }\n}\n\n\n\n/**\n * Parses the `color` property from the provided `bodyRaw` object and returns it\n * wrapped in an object if it exists. If the `isRequired` flag is set to `true`\n * and the `color` property is missing, an error is thrown.\n *\n * @param bodyRaw - The raw input object containing the `color` property.\n * @param isRequired - A boolean indicating whether the `color` property is required.\n *                      Defaults to `false`.\n * @returns An object containing the `color` property if it exists, or `undefined` if not required.\n * @throws {InvalidRequestError} If `isRequired` is `true` and the `color` property is missing.\n */\nconst parseWithColor = (bodyRaw: any, isRequired = false): Unsure<HasColor> => {\n  const { color } = bodyRaw\n\n  if (isRequired && !color)\n    throw new InvalidRequestError(\"Property color is required for the node\")\n\n  if (!color) return\n\n  return { color }\n}\n\n/**\n * Parses the provided raw body object to extract unit and valueType properties.\n * Ensures that the required properties are present if `isRequired` is set to true.\n *\n * @param bodyRaw - The raw input object containing the properties to parse.\n * @param isRequired - A boolean indicating whether the `unit` and `valueType` properties are mandatory.\n *                      Defaults to `false`.\n * @returns An object containing the `unit` and `valueType` properties, or `null` if they are not provided.\n * @throws {InvalidRequestError} If `isRequired` is true and either `unit` or `valueType` is missing.\n */\nconst parseWithUnits = (bodyRaw: any, isRequired = false): Unsure<HasUnits> => {\n  const { unit, valueType } = bodyRaw\n\n  if (isRequired && (!unit || !valueType))\n    throw new InvalidRequestError(\"Properties unit and valueType are required for the node\")\n\n  return { unit: unit ?? null, valueType: valueType ?? null }\n}\n\n/**\n * Parse and validate the `documentId` property from a raw request body.\n *\n * Extracts `documentId` from `bodyRaw` and returns it as an object matching\n * HasDocumentId, wrapped in the Unsure type. If `documentId` is missing or\n * falsy, the function throws an InvalidRequestError.\n *\n * @param bodyRaw - The raw request body (e.g. parsed JSON) expected to contain `documentId`.\n * @returns Unsure<HasDocumentId> — an object with the `documentId` property.\n * @throws {InvalidRequestError} Thrown when `documentId` is not present on `bodyRaw`.\n */\nconst parseHasDocumentId = (bodyRaw: any): HasDocumentId => {\n  const { documentId } = bodyRaw\n\n  if (!documentId)\n    throw new InvalidRequestError(\"Property documentId is required for the node\")\n\n  return { documentId }\n}\n\n/**\n * Parse timeseries information from a raw request body.\n *\n * Delegates interval parsing to `parseWithInterval(bodyRaw)` and then\n * attaches the `step` value from the provided `bodyRaw` to the resulting\n * timeseries object. The function does not mutate the input object.\n *\n * @param bodyRaw - Raw request payload (unknown/loose shape). Expected to\n *                  contain whatever fields `parseWithInterval` requires and\n *                  optionally a `step` property.\n * @returns A `HasTimeseries` object composed of the interval-related fields\n *          returned by `parseWithInterval` plus the `step` property from\n *          `bodyRaw` (which may be `undefined` if not present).\n * @throws Rethrows any errors produced by `parseWithInterval` when the input\n *         body is invalid for interval parsing.\n */\nconst parseWithTimeseries = (bodyRaw: any): HasTimeseries => {\n  const timeseriesIntervals = parseWithInterval(bodyRaw)\n  const { step } = bodyRaw\n\n  if (!step)\n    throw new InvalidRequestError(\"Property step is required for timeseries datasource\")\n\n  return { ...timeseriesIntervals, step }\n}\n\n/**\n * Parses the `bands`, `bandNames`, and `bandPeriods` properties from the provided raw input object.\n * \n * - If `required` is `true`, throws an `InvalidRequestError` if any of the properties are missing.\n * - Converts CSV strings to arrays:\n *   - `bands` is parsed as an array of numbers.\n *   - `bandNames` and `bandPeriods` are parsed as arrays of trimmed strings.\n * - Returns an object containing any of the parsed properties that were present in the input.\n *\n * @param bodyRaw - The raw input object potentially containing `bands`, `bandNames`, and `bandPeriods` as CSV strings.\n * @param required - If `true`, all three properties are required and an error is thrown if any are missing. Defaults to `false`.\n * @returns An object with the parsed properties, or `undefined` if none are present.\n * @throws {InvalidRequestError} If `required` is `true` and any property is missing.\n */\nconst parseHasBands = (bodyRaw: any, required = false): Unsure<HasBands> => {\n  const { bands, bandNames, bandPeriods } = bodyRaw\n  let result: any\n\n  if (required && (!bands || !bandNames || !bandPeriods))\n    throw new InvalidRequestError(\"Bands, bandNames and bandPeriods are required for the node\")\n\n  if (bands) {\n    result = result ?? {}\n    Object.assign(result, { bands: csvParseNumbers(bands as string) })\n  }\n\n  if (bandNames) {\n    result = result ?? {}\n    Object.assign(result, { bandNames: csvParseStrings(bandNames as string) })\n  }\n\n  if (bandPeriods) {\n    result = result ?? {}\n    Object.assign(result, { bandPeriods: csvParseStrings(bandPeriods as string) })\n  }\n\n  return result as Unsure<HasBands>\n}\n\n/**\n * Parse single graph node from body entity \n * @param bodyNodeEntity Entity from request body\n * @returns Parsed object for specific node\n */\nexport const parseSinglePantherNode = (bodyNodeEntity: unknown): FullPantherEntity => {\n\n  // Parse basic node properties first\n  let node: PantherEntity = parseBasicNodeFromBody(bodyNodeEntity)\n\n  // Parse additional properties for specific node types\n  // single for loop is used to avoid multiple labels array iterations\n  for (const label of node.labels) {\n\n    // If node is a Period, add interval information\n    if (label === UsedNodeLabels.Period)\n      node = { ...node, ...parseWithInterval(bodyNodeEntity) };\n\n    // If node is a Place, add geographic information\n    if (label === UsedNodeLabels.Place)\n      node = { ...node, ...parseHasGeometry(bodyNodeEntity) };\n\n    // If node is a Datasource or Application, add configuration when available\n    if (label === UsedNodeLabels.Datasource || label === UsedNodeLabels.Application) {\n      const parsedConfiguration = parseWithConfiguration(bodyNodeEntity, false);\n      node = parsedConfiguration ? { ...node, ...parsedConfiguration } : node;\n    }\n\n    // If node is a online Datasource, add URL information\n    const datasourcesWithUrl = [\n      UsedDatasourceLabels.COG,\n      UsedDatasourceLabels.WMS,\n      UsedDatasourceLabels.MVT,\n      UsedDatasourceLabels.WFS,\n      UsedDatasourceLabels.WMTS,\n      UsedDatasourceLabels.Geojson\n    ];\n\n    // If node is a Datasource with URL, add URL information\n    if (datasourcesWithUrl.includes(label as UsedDatasourceLabels)) {\n      const parsedUrl = parseHasUrl(bodyNodeEntity, true);\n      node = parsedUrl ? { ...node, ...parsedUrl } : node;\n    }\n\n    // If node is a Datasource with bands, add bands information\n    const datasourcesWithPossibleBands = [\n      UsedDatasourceLabels.COG,\n    ];\n\n    // If node is a Datasource can have bands, add them\n    if (datasourcesWithPossibleBands.includes(label as UsedDatasourceLabels)) {\n      const parsedBands = parseHasBands(bodyNodeEntity, false);\n      node = parsedBands ? { ...node, ...parsedBands } : node;\n    }\n\n    // If node is a Style, add specific name information\n    if (label === UsedNodeLabels.Style || label === UsedDatasourceLabels.MapStyle) {\n      const parsedSpecificName = parseHasSpecificName(bodyNodeEntity, true);\n      node = parsedSpecificName ? { ...node, ...parsedSpecificName } : node;\n    }\n\n    // If node is a Datasource with timeseries, add timeseries information\n    if (label === UsedDatasourceLabels.Timeseries) {\n      const parsedTimeseries = parseWithTimeseries(bodyNodeEntity);\n      node = { ...node, ...parsedTimeseries };\n    }\n\n    // If node is a Datasource with document ID, add document ID information\n    const datasourcesWithDocumentId = [\n      UsedDatasourceLabels.PostGIS,\n      UsedDatasourceLabels.Timeseries\n    ];\n\n    if (datasourcesWithDocumentId.includes(label as UsedDatasourceLabels)) {\n      const parsedDocumentId = parseHasDocumentId(bodyNodeEntity);\n      node = { ...node, ...parsedDocumentId };\n    }\n\n    // If node is an AreaTreeLevel, add level information\n    if (label === UsedNodeLabels.AreaTreeLevel)\n      node = { ...node, ...paseHasLevels(bodyNodeEntity) };\n\n    // If node is an Attribute, add color information and units\n    if (label === UsedNodeLabels.Attribute) {\n      const parsedColor = parseWithColor(bodyNodeEntity, false);\n      const parsedUnit = parseWithUnits(bodyNodeEntity, false);\n      \n      // Add parsed unit if available\n      node = parsedUnit ? { \n        ...node, \n        ...parsedUnit \n      } : node;\n\n      // Add parsed color if available\n      node = parsedColor ? { \n        ...node, \n        ...parsedColor \n      } : node;\n    }\n\n  }\n\n  return node;\n}\n\n/**\n * Parse array of graph nodes from request body\n * @param body Array of graph nodes inside http request body\n * @returns Array of parsed graph nodes in correct form\n */\nexport const parseParsePantherNodes = (body: unknown): FullPantherEntity[] => {\n  const nodeArray = body as any[]\n\n  if (!_.isArray(nodeArray))\n    throw new InvalidRequestError(\"Request: Grah nodes must be an array\")\n\n  return nodeArray.map(PantherEntity => parseSinglePantherNode(PantherEntity))\n}\n\n// TODO: cover by better testing","import { randomUUID } from \"crypto\"\nimport _ from \"lodash\"\nimport { validateNodeLabels } from \"./validations.shared\"\nimport { parseSinglePantherNode } from \"./parse.changeNodes\"\nimport { GraphEdge, GraphRelation } from \"../../globals/panther/models.edges\"\nimport { UsedEdgeLabels } from \"../../globals/panther/enums.panther\"\nimport { isInEnum } from \"../../globals/coding/code.formating\"\nimport { InvalidRequestError } from \"./models.errors\"\nimport { FullPantherEntity, PantherEntity } from \"../../globals/panther/models.nodes\"\n\n/**\n * Parses a node object from the Arrows JSON format and converts it into a `PantherEntity`.\n *\n * Validates that the node's labels are arrays of supported enum values, and constructs\n * a `PantherEntity` object with the appropriate properties. Throws an `InvalidRequestError`\n * if the labels are not valid.\n *\n * @param node - The node object from the Arrows JSON to parse.\n * @returns A `PantherEntity` object representing the parsed node.\n * @throws {InvalidRequestError} If the node's labels are not an array of supported values.\n */\nconst parseNodeFromArrows = (node: any): FullPantherEntity => {\n    const { labels, properties, id, caption } = node\n\n    validateNodeLabels(labels)\n\n    const basicGraphResult: FullPantherEntity = parseSinglePantherNode({\n        labels: labels as string[],\n        key: properties.key as string ?? id ?? randomUUID(),\n        nameDisplay: caption ?? properties.nameDisplay as string ?? \"\",\n        ...properties\n    })\n\n    return basicGraphResult\n}\n\n\n/**\n * Parses an edge object from the Arrows format and converts it into a `GraphEdge`.\n *\n * @param edge - The edge object to parse, containing details about the graph edge.\n * @returns A `GraphEdge` object containing the parsed edge nodes, label, and properties.\n *\n * @throws {InvalidRequestError} If the edge does not have a type (`label`).\n * @throws {InvalidRequestError} If the edge type (`label`) is not supported.\n * @throws {InvalidRequestError} If the edge does not have properties.\n * @throws {InvalidRequestError} If the edge does not have `fromId` or `toId`.\n * @throws {InvalidRequestError} If the `fromId` and `toId` are the same.\n */\nconst parseEdgeFromArrows = (edge: any): GraphEdge => {\n    const {\n        fromId: from,\n        toId: to,\n        type,\n        properties\n    } = edge\n\n    // Determine the label, defaulting to \"RelatedTo\" if the type is invalid or not provided\n    const label = (typeof type === \"string\" && type.trim().length > 0) \n        ? type.trim() as UsedEdgeLabels\n        : UsedEdgeLabels.RelatedTo\n        \n    // validate the edge properties\n    if (!isInEnum(label, UsedEdgeLabels))\n        throw new InvalidRequestError(`Graph edge type '${label}' is not supported`)\n\n    // edge must have a properties\n    if (!properties)\n        throw new InvalidRequestError(`Graph edge must have properties`)\n\n    // edge must have fromId and toId\n    if (!from || !to)\n        throw new InvalidRequestError(`Graph edge must have fromId and toId`)\n\n    if (from === to)\n        throw new InvalidRequestError(`Cannot connect two same keys in graph relation (${from} leads to ${to})`)\n\n    // prepare relation tuple\n    const result: GraphRelation = [from, to]\n\n    // construct the parsed edge object\n    const parsedEdge: GraphEdge = {\n        edgeNodes: result,\n        label,\n        properties\n    }\n\n    // return the parsed edge\n    return parsedEdge\n}\n\n/**\n * Parses a JSON object representing nodes and relationships (edges) from the Arrows JSON.\n *\n * @param body - The input JSON object to parse. Expected to contain `nodes` and `relationships` arrays.\n * @returns An object containing parsed `nodes` and `edges` arrays.\n * @throws {InvalidRequestError} If the input is not a valid object, or if required properties are missing or not arrays.\n */\nexport const parseArrowsJson = (body: unknown): { nodes: FullPantherEntity[]; edges: GraphEdge[] } => {\n\n    // Check if the body is a valid object\n    if (typeof body !== \"object\" || body === null)\n        throw new InvalidRequestError(\"Invalid JSON format\")\n\n    // Check if the body contains the required properties\n    if (!(\"nodes\" in body) || !(\"relationships\" in body))\n        throw new InvalidRequestError(\"Invalid JSON format: Missing nodes or relationships\")\n\n    // Check if nodes and relationships are arrays\n    if (!_.isArray((body as any).nodes) || !_.isArray((body as any).relationships))\n        throw new InvalidRequestError(\"Invalid JSON format: nodes and relationships must be arrays\")\n\n    // Extract nodes and relationships from the body\n    const { nodes: rawNodes, relationships: rawEdges } = body as any\n\n    // Define default values for nodes and edges\n    const nodes: PantherEntity[] = rawNodes ?? []\n    const edges: GraphEdge[] = rawEdges ?? []\n\n    // Parse nodes and edges using the defined functions\n    const parsedNodes = nodes.map((node: any) => parseNodeFromArrows(node))\n    const parsedEdges = edges.map((edge: any) => parseEdgeFromArrows(edge))\n\n    return {\n        nodes: parsedNodes,\n        edges: parsedEdges\n    }\n}","import _ from \"lodash\"\nimport { InvalidRequestError } from \"./models.errors\"\nimport { GraphEdge, GraphRelation } from \"../../globals/panther/models.edges\"\nimport { enumValuesToString, isInEnum } from \"../../globals/coding/code.formating\"\nimport { UsedEdgeLabels } from \"../../globals/panther/enums.panther\"\n\nexport const parseRichEdges = (body: unknown): GraphEdge[] => {\n\n    const parseSingleEdge = (edge: unknown): GraphEdge => {\n\n        const {label, fromKey, toKey, properties } = edge as any\n\n        if (!label || typeof label !== \"string\")\n            throw new InvalidRequestError(\"Every graph edge must have string label\")\n\n        if (!isInEnum(label, UsedEdgeLabels))\n            throw new InvalidRequestError(`Graph edge label is not allowed (${label}). Must be one of: ${enumValuesToString(UsedEdgeLabels)}`)\n\n        if (!fromKey || typeof fromKey !== \"string\")\n            throw new InvalidRequestError(\"Every graph edge must have string fromKey\")\n\n        if (!toKey || typeof toKey !== \"string\")\n            throw new InvalidRequestError(\"Every graph edge must have string toKey\")\n\n        if (fromKey === toKey)\n            throw new InvalidRequestError(`Cannot connect two same keys in graph edge (${fromKey})`)\n\n        const parsedEdge: GraphEdge = {\n            label: label as UsedEdgeLabels,\n            edgeNodes: [fromKey, toKey],\n            properties: properties || {}\n        }\n\n        return parsedEdge\n    }\n    const edgesRaw = body as any[]\n    \n    if (!_.isArray(edgesRaw))\n        throw new InvalidRequestError(\"Graph edges must be an array of edges\")\n\n    if (edgesRaw.length === 0)\n        throw new InvalidRequestError(\"Graph edges array must not be empty\")\n\n    const parsedEdges = edgesRaw.map(edge => parseSingleEdge(edge))\n    return parsedEdges\n}\n\n/**\n * Parse body to graph relation\n * @param body Body from request\n * @returns Graph relation\n */\nexport const parseEqualEdges = (body: unknown): GraphRelation[] => {\n    const relations = body as any[]\n\n    /**\n     * Check single edge relation and parse it\n     * @param edgeRelation \n     * @returns Parsed edge relation\n     */\n    const parseSingleEdgeRelation = (edgeRelation: unknown): GraphRelation => {\n\n        if (!_.isArray(edgeRelation))\n            throw new InvalidRequestError(\"Every graph relation must be two element string tuple [string, string]\")\n\n        if (edgeRelation.length !== 2)\n            throw new InvalidRequestError(\"Every graph relation must be two element string tuple [string, string]\")\n\n        if (edgeRelation[0] === edgeRelation[1])\n            throw new InvalidRequestError(`Cannot connect two same keys in graph relation (${edgeRelation[0]})`)\n\n        return edgeRelation as GraphRelation\n    }\n\n    if (!_.isArray(relations))\n        throw new InvalidRequestError(\"Graph edges must be an array of tuples\")\n\n    const validatedGraphEdges = relations.map(edge => parseSingleEdgeRelation(edge))\n\n    return validatedGraphEdges\n} ","/**\n * What environment setups we use for the BE applications\n */\nexport enum UsedEnvironments {\n  Prod = \"prod\",\n  Dev = \"dev\"\n}","import { join } from 'path'\nimport { readFileSync } from 'fs'\nimport { loggyWarn } from '../logging/logger';\n\n/**\n * Parse package.json metadata from a given working directory.\n *\n * Reads the file at path.join(cwdPath, \"package.json\"), parses it as JSON and returns the\n * package's name, description and version.\n *\n * @param cwdPath - Absolute or relative path to the application's working directory containing package.json.\n * @returns An object with the extracted properties:\n *  - pkgName: string | undefined — value of package.json's \"name\" field\n *  - pkgDescription: string | undefined — value of package.json's \"description\" field\n *  - pkgVersion: string | undefined — value of package.json's \"version\" field\n * @throws {Error} Propagates errors from fs.readFileSync or JSON.parse if the file cannot be read or contains invalid JSON.\n * @remarks\n * - If any of the required fields (name, description, version) are missing the function will still return,\n *   but will call loggyWarn to emit a warning.\n * - This function does not validate the semantics of the values (e.g. semver format for version).\n * @example\n * const { pkgName, pkgDescription, pkgVersion } = parsePackageJsonEnvironments(\"/path/to/app\");\n */\nexport const parsePackageJsonEnvironments = (cwdPath: string) => {\n\n    // Read package.json for application\n    const packageJsonPath = join(cwdPath, \"package.json\");\n    const packageJson = JSON.parse(readFileSync(packageJsonPath, \"utf-8\"));\n    const { name: pkgName, description: pkgDescription, version: pkgVersion } = packageJson\n\n    if (!pkgName || !pkgDescription || !pkgVersion)\n        loggyWarn(\"Environment parse:\", `Package.json is missing some of the required fields: name, description, version`)\n\n    return { pkgName, pkgDescription, pkgVersion }\n}","/**\n * Universal Swagger types and utilities\n * This interface can be extended for more precise typing if needed.\n */\nexport interface AppSchemaTemplate {\n  body?: Record<string, any>;\n  querystring?: Record<string, any>;\n  params?: Record<string, any>;\n  headers?: Record<string, any>;\n  response?: Record<string, any>;\n  description?: string;\n  tags?: string[];\n  summary?: string;\n  [key: string]: any;\n}\n\n/**\n * Shared swagger types used in API documentation\n */\nexport enum SwaggerTypes {\n  String = \"string\",\n  Number = \"number\",\n  Object = \"object\",\n  Array = \"array\",\n  Boolean = \"boolean\"\n}","/**\n * Enumeration of the SQL table names used throughout the application.\n * \n * This enum provides a centralized registry of table names to ensure consistent\n * references across the application's database operations.\n * \n * @enum {string}\n */\nexport enum UsedSqlTables {\n    APP_STATES = \"states\"\n}","/**\n * The default name for the SQLite database file in backend and SSR apps.\n * Default value is \"db.sqlite\".\n */\nexport const DEFAULT_DB_NAME = \"db.sqlite\";\n\n/**\n * The default expiration time for database states, in seconds. For backend and SSR apps.\n * Default value is set to 1 day (86400 seconds).\n */\nexport const DEFAULT_DB_STATE_EXPIRATION_SEC = 60 * 60 * 24; // default to 1 day\n","import type sqlite3 from 'sqlite3';\nimport { Database, open } from 'sqlite';\nimport { UsedSqlTables } from './enums.sqlite';\n\n/**\n * Represents a SQLite database connection for the application.\n * \n * This type is a wrapper around the `Database` type from the SQLite library,\n * specifying the database and statement types as `sqlite3.Database` and\n * `sqlite3.Statement` respectively.\n * \n * @type {Database<sqlite3.Database, sqlite3.Statement>}\n */\nexport type AppDb = Database<sqlite3.Database, sqlite3.Statement>\n\n/**\n * Opens a connection to a SQLite database.\n * \n * @param filename - The path to the SQLite database file. If the file does not exist, it will be created.\n * @returns A Promise that resolves to an AppDb instance representing the opened database connection.\n * \n * @example\n * ```typescript\n * const db = await openDb('./myDatabase.sqlite');\n * ```\n */\nexport async function openDb(filename: string): Promise<AppDb> {\n\tconst { default: sqlite3 } = await import('sqlite3');\n\tconst db = await open({\n\t\tfilename, //database file will be created if it does not exist\n\t\tdriver: sqlite3.Database,\n\t});\n\n\t// create the database structure\n\tawait db.run(`\n\t\t\tCREATE TABLE IF NOT EXISTS ${UsedSqlTables.APP_STATES} (\n\t\t\t\t\t\t\t\t\t\t\t\t  key VARCHAR(50) PRIMARY KEY,\n\t\t\t\t\t\t\t\t\t\t\t\t  state BLOB,\n\t\t\t\t\t\t\t\t\t\t\t\t  expires_at DATETIME\n\t\t\t)`);\n\n\t// return the database connection\n\t// Note: The database connection is automatically closed when the process exits\n\treturn db;\n}\n","import { AppDb } from \"./sqlite.connection\";\nimport { UsedSqlTables } from \"./enums.sqlite\";\n\n/**\n * Saves a state to the database with the specified key.\n * \n * @param db - The application database instance.\n * @param key - The unique identifier for the state.\n * @param state - The state data to be saved as a string.\n * @returns A promise that resolves when the state has been saved.\n */\nexport const dbSaveState = async (db: AppDb, key: string, state: string, expirationSec: number) => {\n\n    // Clean up expired state rows\n    await db.run(\n        `DELETE FROM ${UsedSqlTables.APP_STATES} \n         WHERE expires_at < ?`,\n        [Math.floor(Date.now() / 1000)]\n    );\n\n    // Calculate expiration date by adding seconds to current time\n    const currentTimestamp = Math.floor(Date.now() / 1000); // Current time in seconds\n    const expiresAt = currentTimestamp + expirationSec;\n\n    // Convert JSON to string\n    const jsonString = JSON.stringify(state);\n\n    // Convert string to binary (UTF-8)\n    const encoder = new TextEncoder(); // Available in most modern environments\n    const binaryData = encoder.encode(jsonString); // Uint8Array\n\n    await db.run(\n        `INSERT INTO ${UsedSqlTables.APP_STATES} (key, state, expires_at)\n       VALUES (?, ?, ?)`,\n        [key, binaryData, expiresAt]\n    );\n}","import { AppDb } from \"./sqlite.connection\";\nimport { UsedSqlTables } from \"./enums.sqlite\";\n\n/**\n * Retrieves the application state associated with the specified key from the database.\n * \n * @param db - The application database instance.\n * @param key - The key identifying the state to retrieve.\n * @returns A promise that resolves to the requested state data or undefined if not found.\n */\nexport const dbNeedAppState = async (db: AppDb, key: string): Promise<{\n    key: any;\n    state: any;\n    expiresAt: number;\n} | null> => {\n\n    // read the state from the database\n    const wantedState = await db.get(`SELECT * FROM ${UsedSqlTables.APP_STATES} WHERE key= ?`, key)\n\n    // if the state is not found, return null\n    if (!wantedState)\n        return null\n\n    // convert binary state back to JSON format\n    const decoder = new TextDecoder(\"utf-8\");\n    const decodedString = decoder.decode(wantedState.state);\n    const jsonState = JSON.parse(decodedString);\n\n    // return the state and metadata\n    return {\n        key: wantedState.key,\n        state: jsonState,\n        expiresAt: wantedState.expires_at\n    }\n\n}"],"names":["DateTime","UsedNodeLabels","UsedDatasourceLabels","UsedEdgeLabels","UsedTimeseriesSteps","randomUUID","UsedEnvironments","join","readFileSync","SwaggerTypes","UsedSqlTables","open"],"mappings":";;;;;;;;;;AAAA;;;;AAIG;AACI,MAAM,KAAK,GAAG,CAAC,SAAiB,KAAI;AACzC,IAAA,IAAI;AACF,QAAA,IAAI,GAAG,CAAC,SAAS,CAAC;AAClB,QAAA,OAAO,IAAI;IACb;AAAE,IAAA,MAAM;AACN,QAAA,OAAO,KAAK;IACd;AACF;AAEA;;;;AAIG;MACU,aAAa,GAAG,CAAC,UAAoB,KAAK,UAAU,CAAC,KAAK,CAAC,SAAS,IAAI,KAAK,CAAC,SAAS,CAAC;AAErG;;;;;AAKG;MACU,QAAQ,GAAG,CAAC,KAAU,EAAE,UAAe,KAAI;IACpD,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,CAAC,UAAU,CAAa;AAC3D,IAAA,OAAO,aAAa,CAAC,QAAQ,CAAC,KAAK,CAAC;AACtC;AAEF;;;;AAIG;AACI,MAAM,eAAe,GAAG,CAAC,QAAkB,KAAK,QAAQ,CAAC,IAAI;AAEpE;;;;AAIG;AACI,MAAM,0BAA0B,GAAG,CAAC,GAAU,KAAK,CAAC,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC;AAG1E;;;;AAIG;AACI,MAAM,cAAc,GAAG,CAAC,KAAa,KAAK,KAAK,KAAK;AAG3D;;;;;AAKG;AACI,MAAM,kBAAkB,GAAG,CAAC,QAAa,EAAE,SAAS,GAAG,IAAI,KAAK,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,IAAI,C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