@gisatcz/ptr-be-core 0.0.1-dev.9 → 0.0.3

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.
@@ -4,6 +4,12 @@
4
4
  * @returns
5
5
  */
6
6
  export declare const nowTimestamp: (regime?: "milisecond" | "second") => number;
7
+ /**
8
+ * Return now local timestamp plus number of seconds to add
9
+ * @param secondsToAdd Seconds to add from now (1 = now + 1 sec.)
10
+ * @returns Timestamp of the future (past) on seconds
11
+ */
12
+ export declare const nowPlusTime: (secondsToAdd: number) => number;
7
13
  /**
8
14
  * Convert epoch time value into ISO format
9
15
  * @param epochValue Epoch value of the timestamp
@@ -1,3 +1,15 @@
1
+ /**
2
+ * Check, if the string is url
3
+ * @param candidate Candidate input, to be checked
4
+ * @returns Is this string url?
5
+ */
6
+ export declare const isUrl: (candidate: string) => boolean;
7
+ /**
8
+ * Check, if the string array contain urls
9
+ * @param candidates Candidate input array, to be checked
10
+ * @returns Is this string array only from url?
11
+ */
12
+ export declare const isArrayOfUrls: (candidates: string[]) => boolean;
1
13
  /**
2
14
  * Check if the value in included in enum posibilities.
3
15
  * @param value Value we need to check
@@ -1,5 +1,5 @@
1
- export { enumCombineValuesToString, enumValuesToArray, enumValuesToString, flattenObject, isInEnum, notEmptyString, randomNumberBetween, removeDuplicitiesFromArray, sortStringArray } from "./globals/coding/code.formating.js";
2
- export { isoIntervalToTimestamps, nowTimestamp, nowTimestampIso, epochToIsoFormat, hasIsoFormat, isoDateToTimestamp } from "./globals/coding/code.dates.js";
1
+ export { enumCombineValuesToString, enumValuesToArray, enumValuesToString, flattenObject, isInEnum, notEmptyString, randomNumberBetween, removeDuplicitiesFromArray, sortStringArray, isUrl, isArrayOfUrls } from "./globals/coding/code.formating.js";
2
+ export { isoIntervalToTimestamps, nowTimestamp, nowTimestampIso, nowPlusTime, epochToIsoFormat, hasIsoFormat, isoDateToTimestamp } from "./globals/coding/code.dates.js";
3
3
  export { csvParseNumbers, csvParseStrings } from "./globals/coding/formats.csv.js";
4
4
  export { filterNodeByLabel, findEdgeByLabel, filterEdgeByLabel, findNodeByLabel } from "./globals/panther/utils.panther.js";
5
5
  export { type Nullable, type Nullish, type Unsure, type UsurePromise } from "./globals/coding/code.types.js";
@@ -1,5 +1,25 @@
1
1
  import { DateTime } from 'luxon';
2
2
 
3
+ /**
4
+ * Check, if the string is url
5
+ * @param candidate Candidate input, to be checked
6
+ * @returns Is this string url?
7
+ */
8
+ const isUrl = (candidate) => {
9
+ try {
10
+ new URL(candidate);
11
+ return true;
12
+ }
13
+ catch {
14
+ return false;
15
+ }
16
+ };
17
+ /**
18
+ * Check, if the string array contain urls
19
+ * @param candidates Candidate input array, to be checked
20
+ * @returns Is this string array only from url?
21
+ */
22
+ const isArrayOfUrls = (candidates) => candidates.every(candidate => isUrl(candidate));
3
23
  /**
4
24
  * Check if the value in included in enum posibilities.
5
25
  * @param value Value we need to check
@@ -118,6 +138,14 @@ const nowTimestamp = (regime = "milisecond") => {
118
138
  const timestamp = DateTime.now().toMillis();
119
139
  return regime === "second" ? Math.round((timestamp / 1000)) : timestamp;
120
140
  };
141
+ /**
142
+ * Return now local timestamp plus number of seconds to add
143
+ * @param secondsToAdd Seconds to add from now (1 = now + 1 sec.)
144
+ * @returns Timestamp of the future (past) on seconds
145
+ */
146
+ const nowPlusTime = (secondsToAdd) => {
147
+ return Math.round(DateTime.now().plus({ seconds: secondsToAdd }).toSeconds());
148
+ };
121
149
  /**
122
150
  * Convert epoch time value into ISO format
123
151
  * @param epochValue Epoch value of the timestamp
@@ -344,5 +372,5 @@ var UsedTimeseriesSteps;
344
372
  UsedTimeseriesSteps["Day"] = "day";
345
373
  })(UsedTimeseriesSteps || (UsedTimeseriesSteps = {}));
346
374
 
347
- export { UsedDatasourceLabels, UsedEdgeLabels, UsedNodeLabels, UsedTimeseriesSteps, csvParseNumbers, csvParseStrings, enumCombineValuesToString, enumValuesToArray, enumValuesToString, epochToIsoFormat, filterEdgeByLabel, filterNodeByLabel, findEdgeByLabel, findNodeByLabel, flattenObject, hasIsoFormat, isInEnum, isoDateToTimestamp, isoIntervalToTimestamps, notEmptyString, nowTimestamp, nowTimestampIso, randomNumberBetween, removeDuplicitiesFromArray, sortStringArray };
375
+ export { UsedDatasourceLabels, UsedEdgeLabels, UsedNodeLabels, UsedTimeseriesSteps, csvParseNumbers, csvParseStrings, enumCombineValuesToString, enumValuesToArray, enumValuesToString, epochToIsoFormat, filterEdgeByLabel, filterNodeByLabel, findEdgeByLabel, findNodeByLabel, flattenObject, hasIsoFormat, isArrayOfUrls, isInEnum, isUrl, isoDateToTimestamp, isoIntervalToTimestamps, notEmptyString, nowPlusTime, nowTimestamp, nowTimestampIso, randomNumberBetween, removeDuplicitiesFromArray, sortStringArray };
348
376
  //# sourceMappingURL=index.browser.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.browser.js","sources":["../src/globals/coding/code.formating.ts","../src/node/api/errors.api.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"],"sourcesContent":["/**\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 * 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\n/**\n * We miss a API parameter needed to process action\n */\nexport class InvalidRequestError extends Error{\n constructor(message: string){\n super(`Invalid Request: ${message}`)\n }\n}\n\n/**\n * Where client has general authorization issue\n */\nexport class AuthorizationError extends Error{\n constructor(){\n super(`Authorization has failed.`)\n }\n}","import { DateTime } from \"luxon\"\nimport { InvalidRequestError } from \"../../node/api/errors.api\"\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 * 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}"],"names":[],"mappings":";;AAAA;;;;;AAKG;MACU,QAAQ,GAAG,CAAC,KAAU,EAAE,UAAe,KAAI;IACpD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A,SAAA,CAAA,GAAA,SAAmB;AACnB,IAAA,oBAAA,CAAA,MAAA,CAAA,GAAA,MAAa;AACb,IAAA,oBAAA,CAAA,KAAA,CAAA,GAAA,KAAW;AACX,IAAA,oBAAA,CAAA,YAAA,CAAA,GAAA,YAAyB;AACzB,IAAA,oBAAA,CAAA,UAAA,CAAA,GAAA,UAAqB;IACrB,oBAAA,CAAA,YAAA,CAAA,GAAA,YAAyB,CAAA;AAC7B,CAAC,EAhBW,oBAAoB,KAApB,oBAAoB,GAAA,EAAA,CAAA,CAAA;AAkBhC;;AAEG;IACS;AAAZ,CAAA,UAAY,cAAc,EAAA;AACtB,IAAA,cAAA,CAAA,WAAA,CAAA,GAAA,SAAqB;AACrB,IAAA,cAAA,CAAA,KAAA,CAAA,GAAA,KAAW;IACX,cAAA,CAAA,mBAAA,CAAA,GAAA,qBAAyC,CAAA;AAC7C,CAAC,EAJW,cAAc,KAAd,cAAc,GAAA,EAAA,CAAA,CAAA;AAM1B;;AAEG;IACS;AAAZ,CAAA,UAAY,mBAAmB,EAAA;AAC3B,IAAA,mBAAA,CAAA,MAAA,CAAA,GAAA,MAAa;AACb,IAAA,mBAAA,CAAA,SAAA,CAAA,GAAA,SAAmB;AACnB,IAAA,mBAAA,CAAA,OAAA,CAAA,GAAA,OAAe;AACf,IAAA,mBAAA,CAAA,MAAA,CAAA,GAAA,MAAa;AACb,IAAA,mBAAA,CAAA,KAAA,CAAA,GAAA,KAAW;AACf,CAAC,EANW,mBAAmB,KAAnB,mBAAmB,GAAA,EAAA,CAAA,CAAA;;;;"}
1
+ {"version":3,"file":"index.browser.js","sources":["../src/globals/coding/code.formating.ts","../src/node/api/errors.api.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"],"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 * 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\n/**\n * We miss a API parameter needed to process action\n */\nexport class InvalidRequestError extends Error{\n constructor(message: string){\n super(`Invalid Request: ${message}`)\n }\n}\n\n/**\n * Where client has general authorization issue\n */\nexport class AuthorizationError extends Error{\n constructor(){\n super(`Authorization has failed.`)\n }\n}","import { DateTime } from \"luxon\"\nimport { InvalidRequestError } from \"../../node/api/errors.api\"\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}"],"names":[],"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,CA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
7
6
  var _ = require('lodash');
8
7
 
8
+ /**
9
+ * Check, if the string is url
10
+ * @param candidate Candidate input, to be checked
11
+ * @returns Is this string url?
12
+ */
13
+ const isUrl = (candidate) => {
14
+ try {
15
+ new URL(candidate);
16
+ return true;
17
+ }
18
+ catch {
19
+ return false;
20
+ }
21
+ };
22
+ /**
23
+ * Check, if the string array contain urls
24
+ * @param candidates Candidate input array, to be checked
25
+ * @returns Is this string array only from url?
26
+ */
27
+ const isArrayOfUrls = (candidates) => candidates.every(candidate => isUrl(candidate));
9
28
  /**
10
29
  * Check if the value in included in enum posibilities.
11
30
  * @param value Value we need to check
@@ -133,6 +152,14 @@ const nowTimestamp = (regime = "milisecond") => {
133
152
  const timestamp = luxon.DateTime.now().toMillis();
134
153
  return regime === "second" ? Math.round((timestamp / 1000)) : timestamp;
135
154
  };
155
+ /**
156
+ * Return now local timestamp plus number of seconds to add
157
+ * @param secondsToAdd Seconds to add from now (1 = now + 1 sec.)
158
+ * @returns Timestamp of the future (past) on seconds
159
+ */
160
+ const nowPlusTime = (secondsToAdd) => {
161
+ return Math.round(luxon.DateTime.now().plus({ seconds: secondsToAdd }).toSeconds());
162
+ };
136
163
  /**
137
164
  * Convert epoch time value into ISO format
138
165
  * @param epochValue Epoch value of the timestamp
@@ -359,32 +386,117 @@ exports.UsedTimeseriesSteps = void 0;
359
386
  UsedTimeseriesSteps["Day"] = "day";
360
387
  })(exports.UsedTimeseriesSteps || (exports.UsedTimeseriesSteps = {}));
361
388
 
362
- // logger.ts
363
- const DEFAULT_LOG_OPTIONS = {
364
- label: 'App'
365
- };
366
- // create the pretty‐printing stream once
367
- const prettyStream = pretty({
368
- colorize: true,
369
- levelFirst: true,
370
- translateTime: 'yyyy-mm-dd HH:MM:ss'
371
- });
372
- // create your logger once and for all
373
- const baseLogger = pino({}, prettyStream);
374
- class AppLogger {
375
- static info(message, options = DEFAULT_LOG_OPTIONS) {
376
- baseLogger.info({ ...options, message });
377
- }
378
- static warn(message, options = DEFAULT_LOG_OPTIONS) {
379
- baseLogger.warn({ ...options, message });
380
- }
381
- static error(message, options = DEFAULT_LOG_OPTIONS) {
382
- baseLogger.error({ ...options, message });
383
- }
384
- static appStart(host, port, options = DEFAULT_LOG_OPTIONS) {
385
- AppLogger.info(`Application started on ${host}:${port}`, options);
389
+ /**
390
+ * Shared pino logger instance used by all logging functions.
391
+ *
392
+ * The logger uses ISO timestamps and a simple level formatter that exposes
393
+ * the textual level as the `level` property on emitted objects.
394
+ */
395
+ const logger = pino({
396
+ timestamp: pino.stdTimeFunctions.isoTime,
397
+ formatters: {
398
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
399
+ level(label, number) {
400
+ return { level: label };
401
+ }
386
402
  }
387
- }
403
+ });
404
+ /**
405
+ * Log an informational message.
406
+ *
407
+ * @param {string} label - Short label or category for the log entry.
408
+ * @param {string} message - Human-readable log message.
409
+ * @param {Record<string, any>} [options={}] - Additional metadata to include.
410
+ */
411
+ const loggyInfo = (label, message, options = {}) => {
412
+ logger.info({ ...options, label, message });
413
+ };
414
+ /**
415
+ * Log a debug-level message.
416
+ *
417
+ * @param {string} label - Short label or category for the log entry.
418
+ * @param {string} message - Human-readable debug message.
419
+ * @param {Record<string, any>} [options={}] - Additional metadata to include.
420
+ */
421
+ const loggyDebug = (label, message, options = {}) => {
422
+ logger.debug({ ...options, label, message });
423
+ };
424
+ /**
425
+ * Log a warning-level message.
426
+ *
427
+ * @param {string} label - Short label or category for the log entry.
428
+ * @param {string} message - Human-readable warning message.
429
+ * @param {Record<string, any>} [options={}] - Additional metadata to include.
430
+ */
431
+ const loggyWarn = (label, message, options = {}) => {
432
+ logger.warn({ ...options, label, message });
433
+ };
434
+ /**
435
+ * Log a trace-level message.
436
+ *
437
+ * @param {string} label - Short label or category for the log entry.
438
+ * @param {string} message - Human-readable trace message.
439
+ * @param {Record<string, any>} [options={}] - Additional metadata to include.
440
+ */
441
+ const loggyTrace = (label, message, options = {}) => {
442
+ logger.trace({ ...options, label, message });
443
+ };
444
+ /**
445
+ * Log a fatal message.
446
+ *
447
+ * Use for unrecoverable errors that will abort the process.
448
+ *
449
+ * @param {string} label - Short label or category for the log entry.
450
+ * @param {string} message - Human-readable fatal message.
451
+ * @param {Record<string, any>} [options={}] - Additional metadata to include.
452
+ */
453
+ const loggyFatal = (label, message, options = {}) => {
454
+ logger.fatal({ ...options, label, message });
455
+ };
456
+ /**
457
+ * Log an error. When an `Error` instance is provided, its stack is included
458
+ * in the logged metadata.
459
+ *
460
+ * @param {string} label - Short label or category for the log entry.
461
+ * @param {Error|string} err - The error object or an error message string.
462
+ * @param {Record<string, any>} [options={}] - Additional metadata to include.
463
+ */
464
+ const loggyError = (label, err, options = {}) => {
465
+ const message = typeof err === 'string' ? err : err.message;
466
+ const extra = typeof err === 'string' ? options : { ...options, stack: err.stack };
467
+ logger.error({ ...extra, label, message });
468
+ };
469
+ /**
470
+ * Convenience logger for application start information.
471
+ *
472
+ * @param {string} host - Hostname or IP the app is bound to.
473
+ * @param {number} port - Port number the app is listening on.
474
+ * @param {Record<string, any>} [options={}] - Additional metadata to include.
475
+ */
476
+ const loggyAppStart = (host, port, options = {}) => {
477
+ loggyInfo("Application started", `Running on ${host}:${port}`, options);
478
+ };
479
+ /**
480
+ * Log that an HTTP request was received.
481
+ *
482
+ * @param {string} route - The route or URL path requested.
483
+ * @param {string} method - HTTP method (GET, POST, etc.).
484
+ * @param {Record<string, any>} [options={}] - Additional metadata to include (e.g., headers, id).
485
+ */
486
+ const loggyRequestReceived = (route, method, options = {}) => {
487
+ loggyInfo("Request Received", `${method}: ${route}`, options);
488
+ };
489
+ /**
490
+ * Log that an HTTP response was sent.
491
+ *
492
+ * @param {string} route - The route or URL path the response corresponds to.
493
+ * @param {string} method - HTTP method (GET, POST, etc.).
494
+ * @param {number} status - HTTP status code returned.
495
+ * @param {Record<string, any>} [options={}] - Additional metadata to include (e.g., timings).
496
+ */
497
+ const loggyResponseSent = (route, method, status, options = {}) => {
498
+ loggyInfo("Response Sent", `${status}: ${route}`, { ...options, method });
499
+ };
388
500
 
389
501
  /**
390
502
  * Validates the provided labels to ensure they are an array of strings and that each label
@@ -903,7 +1015,6 @@ const parseEqualEdges = (body) => {
903
1015
  return validatedGraphEdges;
904
1016
  };
905
1017
 
906
- exports.AppLogger = AppLogger;
907
1018
  exports.AuthorizationError = AuthorizationError;
908
1019
  exports.InvalidRequestError = InvalidRequestError;
909
1020
  exports.csvParseNumbers = csvParseNumbers;
@@ -918,11 +1029,23 @@ exports.findEdgeByLabel = findEdgeByLabel;
918
1029
  exports.findNodeByLabel = findNodeByLabel;
919
1030
  exports.flattenObject = flattenObject;
920
1031
  exports.hasIsoFormat = hasIsoFormat;
1032
+ exports.isArrayOfUrls = isArrayOfUrls;
921
1033
  exports.isInEnum = isInEnum;
1034
+ exports.isUrl = isUrl;
922
1035
  exports.isoDateToTimestamp = isoDateToTimestamp;
923
1036
  exports.isoIntervalToTimestamps = isoIntervalToTimestamps;
1037
+ exports.loggyAppStart = loggyAppStart;
1038
+ exports.loggyDebug = loggyDebug;
1039
+ exports.loggyError = loggyError;
1040
+ exports.loggyFatal = loggyFatal;
1041
+ exports.loggyInfo = loggyInfo;
1042
+ exports.loggyRequestReceived = loggyRequestReceived;
1043
+ exports.loggyResponseSent = loggyResponseSent;
1044
+ exports.loggyTrace = loggyTrace;
1045
+ exports.loggyWarn = loggyWarn;
924
1046
  exports.messageFromError = messageFromError;
925
1047
  exports.notEmptyString = notEmptyString;
1048
+ exports.nowPlusTime = nowPlusTime;
926
1049
  exports.nowTimestamp = nowTimestamp;
927
1050
  exports.nowTimestampIso = nowTimestampIso;
928
1051
  exports.parseArrowsJson = parseArrowsJson;