@gisatcz/ptr-be-core 0.0.1-dev.4 → 0.0.1-dev.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/globals/panther/enums.panther.d.ts +3 -2
- package/dist/globals/panther/models.edges.d.ts +3 -2
- package/dist/globals/panther/models.edges.properties.d.ts +42 -0
- package/dist/index.browser.d.ts +1 -0
- package/dist/index.browser.js +2 -1
- package/dist/index.browser.js.map +1 -1
- package/dist/index.node.cjs +209 -0
- package/dist/index.node.cjs.map +1 -0
- package/dist/index.node.d.ts +1 -0
- package/dist/index.node.js +2 -1
- package/dist/index.node.js.map +1 -1
- package/package.json +5 -3
|
@@ -17,7 +17,7 @@ export declare enum UsedNodeLabels {
|
|
|
17
17
|
* What datasources we use in the system
|
|
18
18
|
*/
|
|
19
19
|
export declare enum UsedDatasourceLabels {
|
|
20
|
-
Attribute = "
|
|
20
|
+
Attribute = "attributeSource",// Column(s) with attribute values
|
|
21
21
|
Geojson = "geojson",// Geojson for web map
|
|
22
22
|
WMS = "wms",// WMS online source
|
|
23
23
|
COG = "cloudOptimizedGeotiff",// COG online source
|
|
@@ -36,5 +36,6 @@ export declare enum UsedDatasourceLabels {
|
|
|
36
36
|
*/
|
|
37
37
|
export declare enum UsedEdgeLabels {
|
|
38
38
|
RelatedTo = "RELATED",// Generic edge for any relation
|
|
39
|
-
Has = "HAS"
|
|
39
|
+
Has = "HAS",// Edge for ownership relation
|
|
40
|
+
InPostgisLocation = "IN_POSTGIS_LOCATION"
|
|
40
41
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Nullable } from "../coding/code.types.js";
|
|
2
2
|
import { UsedEdgeLabels } from "./enums.panther.js";
|
|
3
|
+
import { OneOfEdgeProperties } from "./models.edges.properties.js";
|
|
3
4
|
/**
|
|
4
5
|
* Tuple for relation between two graph nodes
|
|
5
6
|
* It is point to point definition of graph edge
|
|
@@ -11,7 +12,7 @@ export type GraphRelation = [string, string];
|
|
|
11
12
|
* Have "key" witch is composed from node keys.
|
|
12
13
|
*/
|
|
13
14
|
export interface GraphEdge {
|
|
14
|
-
|
|
15
|
+
label: UsedEdgeLabels;
|
|
15
16
|
edgeNodes: GraphRelation;
|
|
16
|
-
properties: Nullable<
|
|
17
|
+
properties: Nullable<OneOfEdgeProperties>;
|
|
17
18
|
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Represents the basic shared properties of all edges in the system.
|
|
3
|
+
* This interface allows for dynamic key-value pairs where the keys are strings
|
|
4
|
+
* and the values can be of type string, number, boolean, or null.
|
|
5
|
+
*
|
|
6
|
+
* @remarks
|
|
7
|
+
* - This interface is designed to be a flexible structure for edge properties.
|
|
8
|
+
* - It is intended to be extended or used as a base for more specific edge property definitions.
|
|
9
|
+
* @property [key: string] - A dynamic key-value pair where the key is a string
|
|
10
|
+
* and the value can be a string, number, boolean, or null.
|
|
11
|
+
*/
|
|
12
|
+
export interface EdgePropertiesBasic {
|
|
13
|
+
[key: string]: string | number | boolean | null;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Represents the properties of an edge for a PostGIS location.
|
|
17
|
+
* This interface extends the basic edge properties and includes
|
|
18
|
+
* additional details specific to PostGIS integration.
|
|
19
|
+
*
|
|
20
|
+
* @interface EdgeForPostgisLocationProperties
|
|
21
|
+
* @extends EdgePropertiesBasic
|
|
22
|
+
*
|
|
23
|
+
* @property {string} tableName - The name of the PostGIS table.
|
|
24
|
+
* @property {string} column - The name of the column in the specified PostGIS table.
|
|
25
|
+
* @property {string | number | null} featureId - The ID of the PostGIS feature.
|
|
26
|
+
* @property {string | null} featureIdColumn - The name of the column in the specified PostGIS table that contains the feature ID.
|
|
27
|
+
* @property {string | null} periodIso - The ISO 8601 period, e.g., "2025", "2025-01-01", or "2020-01-01/2020-12-31".
|
|
28
|
+
*/
|
|
29
|
+
export interface EdgeForPostgisLocationProperties extends EdgePropertiesBasic {
|
|
30
|
+
tableName: string;
|
|
31
|
+
column: string;
|
|
32
|
+
featureId: string | number | null;
|
|
33
|
+
featureIdColumn: string | null;
|
|
34
|
+
periodIso: string | null;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Represents a union type for edge properties, which can be either
|
|
38
|
+
* `EdgeForPostgisLocationProperties` or `EdgePropertiesBasic`.
|
|
39
|
+
* This type is used to define the possible properties of an edge
|
|
40
|
+
* in the application.
|
|
41
|
+
*/
|
|
42
|
+
export type OneOfEdgeProperties = EdgeForPostgisLocationProperties | EdgePropertiesBasic;
|
package/dist/index.browser.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { enumCombineValuesToString, enumValuesToArray, enumValuesToString, flattenObject, isInEnum, notEmptyString, randomNumberBetween, removeDuplicitiesFromArray, sortStringArray } from "./globals/coding/code.formating.js";
|
|
2
2
|
export { type Nullable, type Nullish, type Unsure, type UsurePromise } from "./globals/coding/code.types.js";
|
|
3
3
|
export { UsedDatasourceLabels, UsedEdgeLabels, UsedNodeLabels } from "./globals/panther/enums.panther.js";
|
|
4
|
+
export { type EdgeForPostgisLocationProperties, type EdgePropertiesBasic, type OneOfEdgeProperties } from "./globals/panther/models.edges.properties.js";
|
|
4
5
|
export { type GraphEdge, type GraphRelation } from "./globals/panther/models.edges.js";
|
|
5
6
|
export { type HasBands, type HasColor, type HasConfiguration, type HasGeometry, type HasInterval, type HasLevels, type HasSpecificName, type HasUrl, type HasUnits } from "./globals/panther/models.nodes.properties.js";
|
|
6
7
|
export { type Place, type Period, type AreaTreeLevel, type Datasource, type ApplicationNode, type Attribute, type FullPantherEntity, type MapStyle, type PantherEntity } from "./globals/panther/models.nodes.js";
|
package/dist/index.browser.js
CHANGED
|
@@ -114,7 +114,7 @@ var UsedNodeLabels;
|
|
|
114
114
|
*/
|
|
115
115
|
var UsedDatasourceLabels;
|
|
116
116
|
(function (UsedDatasourceLabels) {
|
|
117
|
-
UsedDatasourceLabels["Attribute"] = "
|
|
117
|
+
UsedDatasourceLabels["Attribute"] = "attributeSource";
|
|
118
118
|
UsedDatasourceLabels["Geojson"] = "geojson";
|
|
119
119
|
UsedDatasourceLabels["WMS"] = "wms";
|
|
120
120
|
UsedDatasourceLabels["COG"] = "cloudOptimizedGeotiff";
|
|
@@ -135,6 +135,7 @@ var UsedEdgeLabels;
|
|
|
135
135
|
(function (UsedEdgeLabels) {
|
|
136
136
|
UsedEdgeLabels["RelatedTo"] = "RELATED";
|
|
137
137
|
UsedEdgeLabels["Has"] = "HAS";
|
|
138
|
+
UsedEdgeLabels["InPostgisLocation"] = "IN_POSTGIS_LOCATION"; // Edge to connect datasource with PostGIS location (schema, table, geometry column)
|
|
138
139
|
})(UsedEdgeLabels || (UsedEdgeLabels = {}));
|
|
139
140
|
|
|
140
141
|
export { UsedDatasourceLabels, UsedEdgeLabels, UsedNodeLabels, enumCombineValuesToString, enumValuesToArray, enumValuesToString, flattenObject, isInEnum, notEmptyString, randomNumberBetween, removeDuplicitiesFromArray, sortStringArray };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.browser.js","sources":["../src/globals/coding/code.formating.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 * 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 = \"
|
|
1
|
+
{"version":3,"file":"index.browser.js","sources":["../src/globals/coding/code.formating.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 * 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}\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"],"names":[],"mappings":"AAAA;;;;;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,CAAC,SAAS;AAE7G;;;;;AAKG;AACI,MAAM,yBAAyB,GAAG,CAAC,SAAgB,EAAE,SAAS,GAAG,IAAI,KAAK,SAAS,CAAC,GAAG,CAAC,QAAQ,IAAI,kBAAkB,CAAC,QAAQ,EAAE,SAAS,CAAC,C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AAA,YAAyB,CAAA;AAC7B,CAAC,EAdW,oBAAoB,KAApB,oBAAoB,GAAA,EAAA,CAAA,CAAA;AAgBhC;;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;;;;"}
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var pino = require('pino');
|
|
4
|
+
var pretty = require('pino-pretty');
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Check if the value in included in enum posibilities.
|
|
8
|
+
* @param value Value we need to check
|
|
9
|
+
* @param enumEntity Enum type we check againts the value
|
|
10
|
+
* @returns Is the value in this enum?
|
|
11
|
+
*/
|
|
12
|
+
const isInEnum = (value, enumEntity) => {
|
|
13
|
+
const allEnumValues = Object.values(enumEntity);
|
|
14
|
+
return allEnumValues.includes(value);
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Sort array of string elements
|
|
18
|
+
* @param rawArray Raw unsorted array of elements
|
|
19
|
+
* @returns Sorted string array
|
|
20
|
+
*/
|
|
21
|
+
const sortStringArray = (rawArray) => rawArray.sort();
|
|
22
|
+
/**
|
|
23
|
+
* Remove all duplicity string items from an array
|
|
24
|
+
* @param arr Original array with duplicities
|
|
25
|
+
* @returns Array of original values
|
|
26
|
+
*/
|
|
27
|
+
const removeDuplicitiesFromArray = (arr) => [...new Set(arr)];
|
|
28
|
+
/**
|
|
29
|
+
* Check if the string value is not ` "" `
|
|
30
|
+
* @param value Value to check
|
|
31
|
+
* @returns Boolean result about the truth
|
|
32
|
+
*/
|
|
33
|
+
const notEmptyString = (value) => value !== "";
|
|
34
|
+
/**
|
|
35
|
+
* Return enum values as array of string
|
|
36
|
+
* @param enumType Type of the enum from code
|
|
37
|
+
* @param separator Optional - separator character
|
|
38
|
+
* @returns Array of enum possible values
|
|
39
|
+
*/
|
|
40
|
+
const enumValuesToString = (enumType, separator = ", ") => Object.values(enumType).join(separator);
|
|
41
|
+
/**
|
|
42
|
+
* Return enum values as array of string
|
|
43
|
+
* @param enumTypes Combination of enum types
|
|
44
|
+
* @param separator Optional - separator character
|
|
45
|
+
* @returns Array of enum possible values
|
|
46
|
+
*/
|
|
47
|
+
const enumCombineValuesToString = (enumTypes, separator = ", ") => enumTypes.map(enumType => enumValuesToString(enumType, separator)).join(separator);
|
|
48
|
+
/**
|
|
49
|
+
* Return all enum values as array
|
|
50
|
+
* @param enumType What array we want to work with
|
|
51
|
+
* @returns Array of enum values
|
|
52
|
+
*/
|
|
53
|
+
const enumValuesToArray = (enumType) => Object.values(enumType);
|
|
54
|
+
/**
|
|
55
|
+
* Return random number (integer) between two values
|
|
56
|
+
* @param min
|
|
57
|
+
* @param max
|
|
58
|
+
* @returns
|
|
59
|
+
*/
|
|
60
|
+
const randomNumberBetween = (min, max) => {
|
|
61
|
+
const minAr = Math.ceil(min);
|
|
62
|
+
const maxAr = Math.floor(max);
|
|
63
|
+
return Math.floor(Math.random() * (maxAr - minAr + 1) + min);
|
|
64
|
+
};
|
|
65
|
+
/**
|
|
66
|
+
* Recursively flattens a nested object. The keys of the resulting object
|
|
67
|
+
* will be the paths to the original values in the nested object, joined by dots.
|
|
68
|
+
*
|
|
69
|
+
* @param obj - The object to flatten.
|
|
70
|
+
* @param prefix - The prefix to use for the keys in the flattened object. Defaults to an empty string.
|
|
71
|
+
* @returns A new object with flattened keys.
|
|
72
|
+
*
|
|
73
|
+
* @example
|
|
74
|
+
* ```typescript
|
|
75
|
+
* const nestedObj = {
|
|
76
|
+
* a: {
|
|
77
|
+
* b: {
|
|
78
|
+
* c: 1
|
|
79
|
+
* }
|
|
80
|
+
* },
|
|
81
|
+
* d: 2
|
|
82
|
+
* };
|
|
83
|
+
* const flatObj = flattenObject(nestedObj);
|
|
84
|
+
* console.log(flatObj);
|
|
85
|
+
* // Output: { 'a.b.c': 1, 'a.b.d': 2 }
|
|
86
|
+
* ```
|
|
87
|
+
*/
|
|
88
|
+
const flattenObject = (obj, prefix = '') => {
|
|
89
|
+
return Object.keys(obj).reduce((acc, key) => {
|
|
90
|
+
const propName = prefix ? `${prefix}.${key}` : key;
|
|
91
|
+
if (typeof obj[key] === 'object' && obj[key] !== null && !Array.isArray(obj[key])) {
|
|
92
|
+
Object.assign(acc, flattenObject(obj[key], propName));
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
acc[propName] = obj[key];
|
|
96
|
+
}
|
|
97
|
+
return acc;
|
|
98
|
+
}, {});
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* What types of graph nodes we use in metadata model
|
|
103
|
+
*/
|
|
104
|
+
exports.UsedNodeLabels = void 0;
|
|
105
|
+
(function (UsedNodeLabels) {
|
|
106
|
+
UsedNodeLabels["Application"] = "application";
|
|
107
|
+
UsedNodeLabels["Datasource"] = "datasource";
|
|
108
|
+
UsedNodeLabels["Place"] = "place";
|
|
109
|
+
UsedNodeLabels["Period"] = "period";
|
|
110
|
+
UsedNodeLabels["AreaTree"] = "areaTree";
|
|
111
|
+
UsedNodeLabels["AreaTreeLevel"] = "areaTreeLevel";
|
|
112
|
+
UsedNodeLabels["Layer"] = "layer";
|
|
113
|
+
UsedNodeLabels["Style"] = "style";
|
|
114
|
+
UsedNodeLabels["Feature"] = "feature";
|
|
115
|
+
UsedNodeLabels["Attribute"] = "attribute"; // Attribute node for properties of entities, like "temperature", "population", etc.
|
|
116
|
+
})(exports.UsedNodeLabels || (exports.UsedNodeLabels = {}));
|
|
117
|
+
/**
|
|
118
|
+
* What datasources we use in the system
|
|
119
|
+
*/
|
|
120
|
+
exports.UsedDatasourceLabels = void 0;
|
|
121
|
+
(function (UsedDatasourceLabels) {
|
|
122
|
+
UsedDatasourceLabels["Attribute"] = "attributeSource";
|
|
123
|
+
UsedDatasourceLabels["Geojson"] = "geojson";
|
|
124
|
+
UsedDatasourceLabels["WMS"] = "wms";
|
|
125
|
+
UsedDatasourceLabels["COG"] = "cloudOptimizedGeotiff";
|
|
126
|
+
UsedDatasourceLabels["MVT"] = "mvt";
|
|
127
|
+
UsedDatasourceLabels["XYZ"] = "xyz";
|
|
128
|
+
UsedDatasourceLabels["CSV"] = "csv";
|
|
129
|
+
UsedDatasourceLabels["GeoTIFF"] = "geotiff";
|
|
130
|
+
UsedDatasourceLabels["Shapefile"] = "shapefile";
|
|
131
|
+
UsedDatasourceLabels["PostGIS"] = "postgis";
|
|
132
|
+
UsedDatasourceLabels["WMTS"] = "wmts";
|
|
133
|
+
UsedDatasourceLabels["WFS"] = "wfs";
|
|
134
|
+
UsedDatasourceLabels["GeoPackage"] = "geopackage"; // OGC GeoPackage format
|
|
135
|
+
})(exports.UsedDatasourceLabels || (exports.UsedDatasourceLabels = {}));
|
|
136
|
+
/**
|
|
137
|
+
* What types of edges we use in metadata model
|
|
138
|
+
*/
|
|
139
|
+
exports.UsedEdgeLabels = void 0;
|
|
140
|
+
(function (UsedEdgeLabels) {
|
|
141
|
+
UsedEdgeLabels["RelatedTo"] = "RELATED";
|
|
142
|
+
UsedEdgeLabels["Has"] = "HAS";
|
|
143
|
+
UsedEdgeLabels["InPostgisLocation"] = "IN_POSTGIS_LOCATION"; // Edge to connect datasource with PostGIS location (schema, table, geometry column)
|
|
144
|
+
})(exports.UsedEdgeLabels || (exports.UsedEdgeLabels = {}));
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Extract message from exception error (try-catch)
|
|
148
|
+
* @param error error from catch block as any
|
|
149
|
+
* @returns
|
|
150
|
+
*/
|
|
151
|
+
const messageFromError = (error) => error["message"];
|
|
152
|
+
/**
|
|
153
|
+
* We miss a API parameter needed to process action
|
|
154
|
+
*/
|
|
155
|
+
class InvalidRequestError extends Error {
|
|
156
|
+
constructor(message) {
|
|
157
|
+
super(`Invalid Request: ${message}`);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Where client has general authorization issue
|
|
162
|
+
*/
|
|
163
|
+
class AuthorizationError extends Error {
|
|
164
|
+
constructor() {
|
|
165
|
+
super(`Authorization has failed.`);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
// logger.ts
|
|
170
|
+
const DEFAULT_LOG_OPTIONS = {
|
|
171
|
+
label: 'App'
|
|
172
|
+
};
|
|
173
|
+
// create the pretty‐printing stream once
|
|
174
|
+
const prettyStream = pretty({
|
|
175
|
+
colorize: true,
|
|
176
|
+
levelFirst: true,
|
|
177
|
+
translateTime: 'yyyy-mm-dd HH:MM:ss'
|
|
178
|
+
});
|
|
179
|
+
// create your logger once and for all
|
|
180
|
+
const baseLogger = pino({}, prettyStream);
|
|
181
|
+
class AppLogger {
|
|
182
|
+
static info(message, options = DEFAULT_LOG_OPTIONS) {
|
|
183
|
+
baseLogger.info({ ...options, message });
|
|
184
|
+
}
|
|
185
|
+
static warn(message, options = DEFAULT_LOG_OPTIONS) {
|
|
186
|
+
baseLogger.warn({ ...options, message });
|
|
187
|
+
}
|
|
188
|
+
static error(message, options = DEFAULT_LOG_OPTIONS) {
|
|
189
|
+
baseLogger.error({ ...options, message });
|
|
190
|
+
}
|
|
191
|
+
static appStart(host, port, options = DEFAULT_LOG_OPTIONS) {
|
|
192
|
+
AppLogger.info(`Application started on ${host}:${port}`, options);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
exports.AppLogger = AppLogger;
|
|
197
|
+
exports.AuthorizationError = AuthorizationError;
|
|
198
|
+
exports.InvalidRequestError = InvalidRequestError;
|
|
199
|
+
exports.enumCombineValuesToString = enumCombineValuesToString;
|
|
200
|
+
exports.enumValuesToArray = enumValuesToArray;
|
|
201
|
+
exports.enumValuesToString = enumValuesToString;
|
|
202
|
+
exports.flattenObject = flattenObject;
|
|
203
|
+
exports.isInEnum = isInEnum;
|
|
204
|
+
exports.messageFromError = messageFromError;
|
|
205
|
+
exports.notEmptyString = notEmptyString;
|
|
206
|
+
exports.randomNumberBetween = randomNumberBetween;
|
|
207
|
+
exports.removeDuplicitiesFromArray = removeDuplicitiesFromArray;
|
|
208
|
+
exports.sortStringArray = sortStringArray;
|
|
209
|
+
//# sourceMappingURL=index.node.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.node.cjs","sources":["../src/globals/coding/code.formating.ts","../src/globals/panther/enums.panther.ts","../src/node/api/errors.api.ts","../src/node/logging/logger.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 * 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}\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 * 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}","// logger.ts\nimport pino, { Logger } from 'pino'\nimport pretty from 'pino-pretty'\n\n/**\n * @typedef {Object} AppLogOptions\n * @property {string} label - The label for the log entry.\n * @property {string|number|boolean} [key] - Any extra fields.\n */\nexport type AppLogOptions = {\n label: string\n [key: string]: string|number|boolean\n}\n\nconst DEFAULT_LOG_OPTIONS: AppLogOptions = {\n label: 'App'\n}\n\n// create the pretty‐printing stream once\nconst prettyStream = pretty({\n colorize: true,\n levelFirst: true,\n translateTime: 'yyyy-mm-dd HH:MM:ss'\n})\n\n// create your logger once and for all\nconst baseLogger: Logger = pino({}, prettyStream)\n\nexport class AppLogger {\n static info(\n message: string,\n options: AppLogOptions = DEFAULT_LOG_OPTIONS,\n ) {\n baseLogger.info({ ...options, message })\n }\n\n static warn(\n message: string,\n options: AppLogOptions = DEFAULT_LOG_OPTIONS,\n ) {\n baseLogger.warn({ ...options, message })\n }\n\n static error(\n message: string,\n options: AppLogOptions = DEFAULT_LOG_OPTIONS,\n ) {\n baseLogger.error({ ...options, message })\n }\n\n static appStart(\n host: string,\n port: number,\n options: AppLogOptions = DEFAULT_LOG_OPTIONS,\n ) {\n AppLogger.info(`Application started on ${host}:${port}`, options)\n }\n}"],"names":["UsedNodeLabels","UsedDatasourceLabels","UsedEdgeLabels"],"mappings":";;;;;AAAA;;;;;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,CAAC,SAAS;AAE7G;;;;;AAKG;AACI,MAAM,yBAAyB,GAAG,CAAC,SAAgB,EAAE,SAAS,GAAG,IAAI,KAAK,SAAS,CAAC,GAAG,CAAC,QAAQ,IAAI,kBAAkB,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS;AAElK;;;;AAIG;AACI,MAAM,iBAAiB,GAAG,CAAC,QAAa,KAAK,MAAM,CAAC,MAAM,CAAC,QAAQ;AAE1E;;;;;A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mBAAmB,EAAA;QAE5C,UAAU,CAAC,KAAK,CAAC,EAAE,GAAG,OAAO,EAAE,OAAO,EAAE,CAAC;IAC3C;IAEA,OAAO,QAAQ,CACb,IAAY,EACZ,IAAY,EACZ,UAAyB,mBAAmB,EAAA;QAE5C,SAAS,CAAC,IAAI,CAAC,CAAA,uBAAA,EAA0B,IAAI,CAAA,CAAA,EAAI,IAAI,CAAA,CAAE,EAAE,OAAO,CAAC;IACnE;AACD;;;;;;;;;;;;;;;;"}
|
package/dist/index.node.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ export { enumCombineValuesToString, enumValuesToArray, enumValuesToString, flatt
|
|
|
2
2
|
export { type Nullable, type Nullish, type Unsure, type UsurePromise } from "./globals/coding/code.types.js";
|
|
3
3
|
export { UsedDatasourceLabels, UsedEdgeLabels, UsedNodeLabels } from "./globals/panther/enums.panther.js";
|
|
4
4
|
export { type GraphEdge, type GraphRelation } from "./globals/panther/models.edges.js";
|
|
5
|
+
export { type EdgeForPostgisLocationProperties, type EdgePropertiesBasic, type OneOfEdgeProperties } from "./globals/panther/models.edges.properties.js";
|
|
5
6
|
export { type HasBands, type HasColor, type HasConfiguration, type HasGeometry, type HasInterval, type HasLevels, type HasSpecificName, type HasUrl, type HasUnits } from "./globals/panther/models.nodes.properties.js";
|
|
6
7
|
export { type Place, type Period, type AreaTreeLevel, type Datasource, type ApplicationNode, type Attribute, type FullPantherEntity, type MapStyle, type PantherEntity } from "./globals/panther/models.nodes.js";
|
|
7
8
|
export { messageFromError, InvalidRequestError, AuthorizationError } from "./node/api/errors.api.js";
|
package/dist/index.node.js
CHANGED
|
@@ -117,7 +117,7 @@ var UsedNodeLabels;
|
|
|
117
117
|
*/
|
|
118
118
|
var UsedDatasourceLabels;
|
|
119
119
|
(function (UsedDatasourceLabels) {
|
|
120
|
-
UsedDatasourceLabels["Attribute"] = "
|
|
120
|
+
UsedDatasourceLabels["Attribute"] = "attributeSource";
|
|
121
121
|
UsedDatasourceLabels["Geojson"] = "geojson";
|
|
122
122
|
UsedDatasourceLabels["WMS"] = "wms";
|
|
123
123
|
UsedDatasourceLabels["COG"] = "cloudOptimizedGeotiff";
|
|
@@ -138,6 +138,7 @@ var UsedEdgeLabels;
|
|
|
138
138
|
(function (UsedEdgeLabels) {
|
|
139
139
|
UsedEdgeLabels["RelatedTo"] = "RELATED";
|
|
140
140
|
UsedEdgeLabels["Has"] = "HAS";
|
|
141
|
+
UsedEdgeLabels["InPostgisLocation"] = "IN_POSTGIS_LOCATION"; // Edge to connect datasource with PostGIS location (schema, table, geometry column)
|
|
141
142
|
})(UsedEdgeLabels || (UsedEdgeLabels = {}));
|
|
142
143
|
|
|
143
144
|
/**
|
package/dist/index.node.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.node.js","sources":["../src/globals/coding/code.formating.ts","../src/globals/panther/enums.panther.ts","../src/node/api/errors.api.ts","../src/node/logging/logger.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 * 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 = \"attribute\", // 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}\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}\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}","// logger.ts\nimport pino, { Logger } from 'pino'\nimport pretty from 'pino-pretty'\n\n/**\n * @typedef {Object} AppLogOptions\n * @property {string} label - The label for the log entry.\n * @property {string|number|boolean} [key] - Any extra fields.\n */\nexport type AppLogOptions = {\n label: string\n [key: string]: string|number|boolean\n}\n\nconst DEFAULT_LOG_OPTIONS: AppLogOptions = {\n label: 'App'\n}\n\n// create the pretty‐printing stream once\nconst prettyStream = pretty({\n colorize: true,\n levelFirst: true,\n translateTime: 'yyyy-mm-dd HH:MM:ss'\n})\n\n// create your logger once and for all\nconst baseLogger: Logger = pino({}, prettyStream)\n\nexport class AppLogger {\n static info(\n message: string,\n options: AppLogOptions = DEFAULT_LOG_OPTIONS,\n ) {\n baseLogger.info({ ...options, message })\n }\n\n static warn(\n message: string,\n options: AppLogOptions = DEFAULT_LOG_OPTIONS,\n ) {\n baseLogger.warn({ ...options, message })\n }\n\n static error(\n message: string,\n options: AppLogOptions = DEFAULT_LOG_OPTIONS,\n ) {\n baseLogger.error({ ...options, message })\n }\n\n static appStart(\n host: string,\n port: number,\n options: AppLogOptions = DEFAULT_LOG_OPTIONS,\n ) {\n AppLogger.info(`Application started on ${host}:${port}`, options)\n }\n}"],"names":[],"mappings":";;;AAAA;;;;;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,CAAC,SAAS;AAE7G;;;;;AAKG;AACI,MAAM,yBAAyB,GAAG,CAAC,SAAgB,EAAE,SAAS,GAAG,IAAI,KAAK,SAAS,CAAC,GAAG,CAAC,QAAQ,IAAI,kBAAkB,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS;AAElK;;;;AAIG;AACI,MAAM,iBAAiB,GAAG,CAAC,QAAa,K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UAAU,CAAC,KAAK,CAAC,EAAE,GAAG,OAAO,EAAE,OAAO,EAAE,CAAC;IAC3C;IAEA,OAAO,QAAQ,CACb,IAAY,EACZ,IAAY,EACZ,UAAyB,mBAAmB,EAAA;QAE5C,SAAS,CAAC,IAAI,CAAC,CAAA,uBAAA,EAA0B,IAAI,CAAA,CAAA,EAAI,IAAI,CAAA,CAAE,EAAE,OAAO,CAAC;IACnE;AACD;;;;"}
|
|
1
|
+
{"version":3,"file":"index.node.js","sources":["../src/globals/coding/code.formating.ts","../src/globals/panther/enums.panther.ts","../src/node/api/errors.api.ts","../src/node/logging/logger.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 * 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}\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 * 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}","// logger.ts\nimport pino, { Logger } from 'pino'\nimport pretty from 'pino-pretty'\n\n/**\n * @typedef {Object} AppLogOptions\n * @property {string} label - The label for the log entry.\n * @property {string|number|boolean} [key] - Any extra fields.\n */\nexport type AppLogOptions = {\n label: string\n [key: string]: string|number|boolean\n}\n\nconst DEFAULT_LOG_OPTIONS: AppLogOptions = {\n label: 'App'\n}\n\n// create the pretty‐printing stream once\nconst prettyStream = pretty({\n colorize: true,\n levelFirst: true,\n translateTime: 'yyyy-mm-dd HH:MM:ss'\n})\n\n// create your logger once and for all\nconst baseLogger: Logger = pino({}, prettyStream)\n\nexport class AppLogger {\n static info(\n message: string,\n options: AppLogOptions = DEFAULT_LOG_OPTIONS,\n ) {\n baseLogger.info({ ...options, message })\n }\n\n static warn(\n message: string,\n options: AppLogOptions = DEFAULT_LOG_OPTIONS,\n ) {\n baseLogger.warn({ ...options, message })\n }\n\n static error(\n message: string,\n options: AppLogOptions = DEFAULT_LOG_OPTIONS,\n ) {\n baseLogger.error({ ...options, message })\n }\n\n static appStart(\n host: string,\n port: number,\n options: AppLogOptions = DEFAULT_LOG_OPTIONS,\n ) {\n AppLogger.info(`Application started on ${host}:${port}`, options)\n }\n}"],"names":[],"mappings":";;;AAAA;;;;;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,CAAC,SAAS;AAE7G;;;;;AAKG;AACI,MAAM,yBAAyB,GAAG,CAAC,SAAgB,EAAE,SAAS,GAAG,IAAI,KAAK,SAAS,CAAC,GAAG,CAAC,QAAQ,IAAI,kBAAkB,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS;AAElK;;;;AAIG;AACI,MAAM,iBAAiB,GAAG,CAAC,QAAa,KAAK,MAAM,CAAC,MAAM,CAAC,QAAQ;AAE1E;;;;;AAKG;MACU,mBAAmB,GAAG,CAAC,GAAW,EAAE,GAAW,KAAI;IAC9D,MAAM,KAAK,GAA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C;IAEA,OAAO,QAAQ,CACb,IAAY,EACZ,IAAY,EACZ,UAAyB,mBAAmB,EAAA;QAE5C,SAAS,CAAC,IAAI,CAAC,CAAA,uBAAA,EAA0B,IAAI,CAAA,CAAA,EAAI,IAAI,CAAA,CAAE,EAAE,OAAO,CAAC;IACnE;AACD;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gisatcz/ptr-be-core",
|
|
3
|
-
"version": "0.0.1-dev.
|
|
3
|
+
"version": "0.0.1-dev.5",
|
|
4
4
|
"description": "Shared core library for PTR BE services",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
@@ -9,11 +9,13 @@
|
|
|
9
9
|
"exports": {
|
|
10
10
|
"./browser": {
|
|
11
11
|
"types": "./dist/index.browser.d.ts",
|
|
12
|
-
"import": "./dist/index.browser.js"
|
|
12
|
+
"import": "./dist/index.browser.js",
|
|
13
|
+
"default": "./dist/index.browser.js"
|
|
13
14
|
},
|
|
14
15
|
"./node": {
|
|
15
16
|
"types": "./dist/index.node.d.ts",
|
|
16
|
-
"
|
|
17
|
+
"require": "./dist/index.node.cjs",
|
|
18
|
+
"default": "./dist/index.node.js"
|
|
17
19
|
},
|
|
18
20
|
"./package.json": "./package.json"
|
|
19
21
|
},
|