@gisatcz/ptr-be-core 0.0.1-dev.3 → 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/Readme.md +4 -0
- package/dist/{src → globals}/panther/enums.panther.d.ts +3 -2
- package/dist/{src → globals}/panther/models.edges.d.ts +5 -4
- package/dist/globals/panther/models.edges.properties.d.ts +42 -0
- package/dist/{src → globals}/panther/models.nodes.d.ts +3 -3
- package/dist/index.browser.d.ts +7 -0
- package/dist/index.browser.js +142 -0
- package/dist/index.browser.js.map +1 -0
- package/dist/{index.cjs → index.node.cjs} +46 -45
- package/dist/index.node.cjs.map +1 -0
- package/dist/index.node.d.ts +11 -0
- package/dist/{index.mjs → index.node.js} +46 -45
- package/dist/index.node.js.map +1 -0
- package/package.json +14 -10
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.ts +0 -10
- package/dist/index.mjs.map +0 -1
- /package/dist/{src → globals}/coding/code.formating.d.ts +0 -0
- /package/dist/{src → globals}/coding/code.types.d.ts +0 -0
- /package/dist/{src → globals}/panther/models.nodes.properties.d.ts +0 -0
- /package/dist/{src → node}/api/errors.api.d.ts +0 -0
- /package/dist/{src → node}/api/models.api.d.ts +0 -0
- /package/dist/{src → node}/logging/logger.d.ts +0 -0
package/Readme.md
CHANGED
|
@@ -11,6 +11,10 @@ This repository contains source of shared functionalities across Panther backend
|
|
|
11
11
|
- Now you can add this package for local development by opening the target application repository and run `yalc add @gisatcz/ptr-be-core`
|
|
12
12
|
- Run `npm run dev` for development mode with Rollup build watcher and auto yalc publishing.
|
|
13
13
|
|
|
14
|
+
## Usage in Applications
|
|
15
|
+
- FE based apps should use imports from `@gisatcz/ptr-be-core/browser`
|
|
16
|
+
- NodeJS based apps should use imports from `@gisatcz/ptr-be-core/node`
|
|
17
|
+
|
|
14
18
|
## Resources
|
|
15
19
|
- YALC (local NPM): https://github.com/wclr/yalc
|
|
16
20
|
- Vitest (testing): https://vitest.dev
|
|
@@ -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
|
-
import { Nullable } from "../coding/code.types";
|
|
2
|
-
import { UsedEdgeLabels } from "./enums.panther";
|
|
1
|
+
import type { Nullable } from "../coding/code.types.js";
|
|
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;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { HasGeometry, HasInterval, HasLevels, HasConfiguration, HasUrl, HasBands, HasSpecificName, HasColor, HasUnits } from "./models.nodes.properties";
|
|
2
|
-
import { UsedNodeLabels, UsedDatasourceLabels } from "./enums.panther";
|
|
3
|
-
import { Nullable } from "../coding/code.types";
|
|
1
|
+
import { HasGeometry, HasInterval, HasLevels, HasConfiguration, HasUrl, HasBands, HasSpecificName, HasColor, HasUnits } from "./models.nodes.properties.js";
|
|
2
|
+
import { UsedNodeLabels, UsedDatasourceLabels } from "./enums.panther.js";
|
|
3
|
+
import { Nullable } from "../coding/code.types.js";
|
|
4
4
|
/**
|
|
5
5
|
* General graph node - same for all metadatata entities
|
|
6
6
|
*/
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { enumCombineValuesToString, enumValuesToArray, enumValuesToString, flattenObject, isInEnum, notEmptyString, randomNumberBetween, removeDuplicitiesFromArray, sortStringArray } from "./globals/coding/code.formating.js";
|
|
2
|
+
export { type Nullable, type Nullish, type Unsure, type UsurePromise } from "./globals/coding/code.types.js";
|
|
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";
|
|
5
|
+
export { type GraphEdge, type GraphRelation } from "./globals/panther/models.edges.js";
|
|
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";
|
|
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";
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Check if the value in included in enum posibilities.
|
|
3
|
+
* @param value Value we need to check
|
|
4
|
+
* @param enumEntity Enum type we check againts the value
|
|
5
|
+
* @returns Is the value in this enum?
|
|
6
|
+
*/
|
|
7
|
+
const isInEnum = (value, enumEntity) => {
|
|
8
|
+
const allEnumValues = Object.values(enumEntity);
|
|
9
|
+
return allEnumValues.includes(value);
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Sort array of string elements
|
|
13
|
+
* @param rawArray Raw unsorted array of elements
|
|
14
|
+
* @returns Sorted string array
|
|
15
|
+
*/
|
|
16
|
+
const sortStringArray = (rawArray) => rawArray.sort();
|
|
17
|
+
/**
|
|
18
|
+
* Remove all duplicity string items from an array
|
|
19
|
+
* @param arr Original array with duplicities
|
|
20
|
+
* @returns Array of original values
|
|
21
|
+
*/
|
|
22
|
+
const removeDuplicitiesFromArray = (arr) => [...new Set(arr)];
|
|
23
|
+
/**
|
|
24
|
+
* Check if the string value is not ` "" `
|
|
25
|
+
* @param value Value to check
|
|
26
|
+
* @returns Boolean result about the truth
|
|
27
|
+
*/
|
|
28
|
+
const notEmptyString = (value) => value !== "";
|
|
29
|
+
/**
|
|
30
|
+
* Return enum values as array of string
|
|
31
|
+
* @param enumType Type of the enum from code
|
|
32
|
+
* @param separator Optional - separator character
|
|
33
|
+
* @returns Array of enum possible values
|
|
34
|
+
*/
|
|
35
|
+
const enumValuesToString = (enumType, separator = ", ") => Object.values(enumType).join(separator);
|
|
36
|
+
/**
|
|
37
|
+
* Return enum values as array of string
|
|
38
|
+
* @param enumTypes Combination of enum types
|
|
39
|
+
* @param separator Optional - separator character
|
|
40
|
+
* @returns Array of enum possible values
|
|
41
|
+
*/
|
|
42
|
+
const enumCombineValuesToString = (enumTypes, separator = ", ") => enumTypes.map(enumType => enumValuesToString(enumType, separator)).join(separator);
|
|
43
|
+
/**
|
|
44
|
+
* Return all enum values as array
|
|
45
|
+
* @param enumType What array we want to work with
|
|
46
|
+
* @returns Array of enum values
|
|
47
|
+
*/
|
|
48
|
+
const enumValuesToArray = (enumType) => Object.values(enumType);
|
|
49
|
+
/**
|
|
50
|
+
* Return random number (integer) between two values
|
|
51
|
+
* @param min
|
|
52
|
+
* @param max
|
|
53
|
+
* @returns
|
|
54
|
+
*/
|
|
55
|
+
const randomNumberBetween = (min, max) => {
|
|
56
|
+
const minAr = Math.ceil(min);
|
|
57
|
+
const maxAr = Math.floor(max);
|
|
58
|
+
return Math.floor(Math.random() * (maxAr - minAr + 1) + min);
|
|
59
|
+
};
|
|
60
|
+
/**
|
|
61
|
+
* Recursively flattens a nested object. The keys of the resulting object
|
|
62
|
+
* will be the paths to the original values in the nested object, joined by dots.
|
|
63
|
+
*
|
|
64
|
+
* @param obj - The object to flatten.
|
|
65
|
+
* @param prefix - The prefix to use for the keys in the flattened object. Defaults to an empty string.
|
|
66
|
+
* @returns A new object with flattened keys.
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* ```typescript
|
|
70
|
+
* const nestedObj = {
|
|
71
|
+
* a: {
|
|
72
|
+
* b: {
|
|
73
|
+
* c: 1
|
|
74
|
+
* }
|
|
75
|
+
* },
|
|
76
|
+
* d: 2
|
|
77
|
+
* };
|
|
78
|
+
* const flatObj = flattenObject(nestedObj);
|
|
79
|
+
* console.log(flatObj);
|
|
80
|
+
* // Output: { 'a.b.c': 1, 'a.b.d': 2 }
|
|
81
|
+
* ```
|
|
82
|
+
*/
|
|
83
|
+
const flattenObject = (obj, prefix = '') => {
|
|
84
|
+
return Object.keys(obj).reduce((acc, key) => {
|
|
85
|
+
const propName = prefix ? `${prefix}.${key}` : key;
|
|
86
|
+
if (typeof obj[key] === 'object' && obj[key] !== null && !Array.isArray(obj[key])) {
|
|
87
|
+
Object.assign(acc, flattenObject(obj[key], propName));
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
acc[propName] = obj[key];
|
|
91
|
+
}
|
|
92
|
+
return acc;
|
|
93
|
+
}, {});
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* What types of graph nodes we use in metadata model
|
|
98
|
+
*/
|
|
99
|
+
var UsedNodeLabels;
|
|
100
|
+
(function (UsedNodeLabels) {
|
|
101
|
+
UsedNodeLabels["Application"] = "application";
|
|
102
|
+
UsedNodeLabels["Datasource"] = "datasource";
|
|
103
|
+
UsedNodeLabels["Place"] = "place";
|
|
104
|
+
UsedNodeLabels["Period"] = "period";
|
|
105
|
+
UsedNodeLabels["AreaTree"] = "areaTree";
|
|
106
|
+
UsedNodeLabels["AreaTreeLevel"] = "areaTreeLevel";
|
|
107
|
+
UsedNodeLabels["Layer"] = "layer";
|
|
108
|
+
UsedNodeLabels["Style"] = "style";
|
|
109
|
+
UsedNodeLabels["Feature"] = "feature";
|
|
110
|
+
UsedNodeLabels["Attribute"] = "attribute"; // Attribute node for properties of entities, like "temperature", "population", etc.
|
|
111
|
+
})(UsedNodeLabels || (UsedNodeLabels = {}));
|
|
112
|
+
/**
|
|
113
|
+
* What datasources we use in the system
|
|
114
|
+
*/
|
|
115
|
+
var UsedDatasourceLabels;
|
|
116
|
+
(function (UsedDatasourceLabels) {
|
|
117
|
+
UsedDatasourceLabels["Attribute"] = "attributeSource";
|
|
118
|
+
UsedDatasourceLabels["Geojson"] = "geojson";
|
|
119
|
+
UsedDatasourceLabels["WMS"] = "wms";
|
|
120
|
+
UsedDatasourceLabels["COG"] = "cloudOptimizedGeotiff";
|
|
121
|
+
UsedDatasourceLabels["MVT"] = "mvt";
|
|
122
|
+
UsedDatasourceLabels["XYZ"] = "xyz";
|
|
123
|
+
UsedDatasourceLabels["CSV"] = "csv";
|
|
124
|
+
UsedDatasourceLabels["GeoTIFF"] = "geotiff";
|
|
125
|
+
UsedDatasourceLabels["Shapefile"] = "shapefile";
|
|
126
|
+
UsedDatasourceLabels["PostGIS"] = "postgis";
|
|
127
|
+
UsedDatasourceLabels["WMTS"] = "wmts";
|
|
128
|
+
UsedDatasourceLabels["WFS"] = "wfs";
|
|
129
|
+
UsedDatasourceLabels["GeoPackage"] = "geopackage"; // OGC GeoPackage format
|
|
130
|
+
})(UsedDatasourceLabels || (UsedDatasourceLabels = {}));
|
|
131
|
+
/**
|
|
132
|
+
* What types of edges we use in metadata model
|
|
133
|
+
*/
|
|
134
|
+
var UsedEdgeLabels;
|
|
135
|
+
(function (UsedEdgeLabels) {
|
|
136
|
+
UsedEdgeLabels["RelatedTo"] = "RELATED";
|
|
137
|
+
UsedEdgeLabels["Has"] = "HAS";
|
|
138
|
+
UsedEdgeLabels["InPostgisLocation"] = "IN_POSTGIS_LOCATION"; // Edge to connect datasource with PostGIS location (schema, table, geometry column)
|
|
139
|
+
})(UsedEdgeLabels || (UsedEdgeLabels = {}));
|
|
140
|
+
|
|
141
|
+
export { UsedDatasourceLabels, UsedEdgeLabels, UsedNodeLabels, enumCombineValuesToString, enumValuesToArray, enumValuesToString, flattenObject, isInEnum, notEmptyString, randomNumberBetween, removeDuplicitiesFromArray, sortStringArray };
|
|
142
|
+
//# sourceMappingURL=index.browser.js.map
|
|
@@ -0,0 +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 = \"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,GAA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AAA,GAAA,KAAW;AACX,IAAA,oBAAA,CAAA,KAAA,CAAA,GAAA,KAAW;AACX,IAAA,oBAAA,CAAA,SAAA,CAAA,GAAA,SAAmB;AACnB,IAAA,oBAAA,CAAA,WAAA,CAAA,GAAA,WAAuB;AACvB,IAAA,oBAAA,CAAA,SAAA,CAAA,GAAA,SAAmB;AACnB,IAAA,oBAAA,CAAA,MAAA,CAAA,GAAA,MAAa;AACb,IAAA,oBAAA,CAAA,KAAA,CAAA,GAAA,KAAW;IACX,oBAAA,CAAA,YAAA,CAAA,GAAA,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;;;;"}
|
|
@@ -98,6 +98,51 @@ const flattenObject = (obj, prefix = '') => {
|
|
|
98
98
|
}, {});
|
|
99
99
|
};
|
|
100
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
|
+
|
|
101
146
|
/**
|
|
102
147
|
* Extract message from exception error (try-catch)
|
|
103
148
|
* @param error error from catch block as any
|
|
@@ -148,50 +193,6 @@ class AppLogger {
|
|
|
148
193
|
}
|
|
149
194
|
}
|
|
150
195
|
|
|
151
|
-
/**
|
|
152
|
-
* What types of graph nodes we use in metadata model
|
|
153
|
-
*/
|
|
154
|
-
exports.UsedNodeLabels = void 0;
|
|
155
|
-
(function (UsedNodeLabels) {
|
|
156
|
-
UsedNodeLabels["Application"] = "application";
|
|
157
|
-
UsedNodeLabels["Datasource"] = "datasource";
|
|
158
|
-
UsedNodeLabels["Place"] = "place";
|
|
159
|
-
UsedNodeLabels["Period"] = "period";
|
|
160
|
-
UsedNodeLabels["AreaTree"] = "areaTree";
|
|
161
|
-
UsedNodeLabels["AreaTreeLevel"] = "areaTreeLevel";
|
|
162
|
-
UsedNodeLabels["Layer"] = "layer";
|
|
163
|
-
UsedNodeLabels["Style"] = "style";
|
|
164
|
-
UsedNodeLabels["Feature"] = "feature";
|
|
165
|
-
UsedNodeLabels["Attribute"] = "attribute"; // Attribute node for properties of entities, like "temperature", "population", etc.
|
|
166
|
-
})(exports.UsedNodeLabels || (exports.UsedNodeLabels = {}));
|
|
167
|
-
/**
|
|
168
|
-
* What datasources we use in the system
|
|
169
|
-
*/
|
|
170
|
-
exports.UsedDatasourceLabels = void 0;
|
|
171
|
-
(function (UsedDatasourceLabels) {
|
|
172
|
-
UsedDatasourceLabels["Attribute"] = "attribute";
|
|
173
|
-
UsedDatasourceLabels["Geojson"] = "geojson";
|
|
174
|
-
UsedDatasourceLabels["WMS"] = "wms";
|
|
175
|
-
UsedDatasourceLabels["COG"] = "cloudOptimizedGeotiff";
|
|
176
|
-
UsedDatasourceLabels["MVT"] = "mvt";
|
|
177
|
-
UsedDatasourceLabels["XYZ"] = "xyz";
|
|
178
|
-
UsedDatasourceLabels["CSV"] = "csv";
|
|
179
|
-
UsedDatasourceLabels["GeoTIFF"] = "geotiff";
|
|
180
|
-
UsedDatasourceLabels["Shapefile"] = "shapefile";
|
|
181
|
-
UsedDatasourceLabels["PostGIS"] = "postgis";
|
|
182
|
-
UsedDatasourceLabels["WMTS"] = "wmts";
|
|
183
|
-
UsedDatasourceLabels["WFS"] = "wfs";
|
|
184
|
-
UsedDatasourceLabels["GeoPackage"] = "geopackage"; // OGC GeoPackage format
|
|
185
|
-
})(exports.UsedDatasourceLabels || (exports.UsedDatasourceLabels = {}));
|
|
186
|
-
/**
|
|
187
|
-
* What types of edges we use in metadata model
|
|
188
|
-
*/
|
|
189
|
-
exports.UsedEdgeLabels = void 0;
|
|
190
|
-
(function (UsedEdgeLabels) {
|
|
191
|
-
UsedEdgeLabels["RelatedTo"] = "RELATED";
|
|
192
|
-
UsedEdgeLabels["Has"] = "HAS";
|
|
193
|
-
})(exports.UsedEdgeLabels || (exports.UsedEdgeLabels = {}));
|
|
194
|
-
|
|
195
196
|
exports.AppLogger = AppLogger;
|
|
196
197
|
exports.AuthorizationError = AuthorizationError;
|
|
197
198
|
exports.InvalidRequestError = InvalidRequestError;
|
|
@@ -205,4 +206,4 @@ exports.notEmptyString = notEmptyString;
|
|
|
205
206
|
exports.randomNumberBetween = randomNumberBetween;
|
|
206
207
|
exports.removeDuplicitiesFromArray = removeDuplicitiesFromArray;
|
|
207
208
|
exports.sortStringArray = sortStringArray;
|
|
208
|
-
//# sourceMappingURL=index.cjs.map
|
|
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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,KAAK,CAAC,CAAA,yBAAA,CAA2B,CAAC;IACpC;AACD;;ACvBD;AAcA,MAAM,mBAAmB,GAAkB;AACzC,IAAA,KAAK,EAAE;CACR;AAED;AACA,MAAM,YAAY,GAAG,MAAM,CAAC;AAC1B,IAAA,QAAQ,EAAE,IAAI;AACd,IAAA,UAAU,EAAE,IAAI;AAChB,IAAA,aAAa,EAAE;AAChB,CAAA,CAAC;AAEF;AACA,MAAM,UAAU,GAAW,IAAI,CAAC,EAAE,EAAE,YAAY,CAAC;MAEpC,SAAS,CAAA;AACpB,IAAA,OAAO,IAAI,CACT,OAAe,EACf,UAAyB,mBAAmB,EAAA;QAE5C,UAAU,CAAC,IAAI,CAAC,EAAE,GAAG,OAAO,EAAE,OAAO,EAAE,CAAC;IAC1C;AAEA,IAAA,OAAO,IAAI,CACT,OAAe,EACf,UAAyB,mBAAmB,EAAA;QAE5C,UAAU,CAAC,IAAI,CAAC,EAAE,GAAG,OAAO,EAAE,OAAO,EAAE,CAAC;IAC1C;AAEA,IAAA,OAAO,KAAK,CACV,OAAe,EACf,UAAyB,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;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export { enumCombineValuesToString, enumValuesToArray, enumValuesToString, flattenObject, isInEnum, notEmptyString, randomNumberBetween, removeDuplicitiesFromArray, sortStringArray } from "./globals/coding/code.formating.js";
|
|
2
|
+
export { type Nullable, type Nullish, type Unsure, type UsurePromise } from "./globals/coding/code.types.js";
|
|
3
|
+
export { UsedDatasourceLabels, UsedEdgeLabels, UsedNodeLabels } from "./globals/panther/enums.panther.js";
|
|
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";
|
|
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";
|
|
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";
|
|
8
|
+
export { messageFromError, InvalidRequestError, AuthorizationError } from "./node/api/errors.api.js";
|
|
9
|
+
export { type ApiEndpointResponse } from "./node/api/models.api.js";
|
|
10
|
+
export { type AppLogOptions } from "./node/logging/logger.js";
|
|
11
|
+
export { AppLogger } from "./node/logging/logger.js";
|
|
@@ -96,6 +96,51 @@ const flattenObject = (obj, prefix = '') => {
|
|
|
96
96
|
}, {});
|
|
97
97
|
};
|
|
98
98
|
|
|
99
|
+
/**
|
|
100
|
+
* What types of graph nodes we use in metadata model
|
|
101
|
+
*/
|
|
102
|
+
var UsedNodeLabels;
|
|
103
|
+
(function (UsedNodeLabels) {
|
|
104
|
+
UsedNodeLabels["Application"] = "application";
|
|
105
|
+
UsedNodeLabels["Datasource"] = "datasource";
|
|
106
|
+
UsedNodeLabels["Place"] = "place";
|
|
107
|
+
UsedNodeLabels["Period"] = "period";
|
|
108
|
+
UsedNodeLabels["AreaTree"] = "areaTree";
|
|
109
|
+
UsedNodeLabels["AreaTreeLevel"] = "areaTreeLevel";
|
|
110
|
+
UsedNodeLabels["Layer"] = "layer";
|
|
111
|
+
UsedNodeLabels["Style"] = "style";
|
|
112
|
+
UsedNodeLabels["Feature"] = "feature";
|
|
113
|
+
UsedNodeLabels["Attribute"] = "attribute"; // Attribute node for properties of entities, like "temperature", "population", etc.
|
|
114
|
+
})(UsedNodeLabels || (UsedNodeLabels = {}));
|
|
115
|
+
/**
|
|
116
|
+
* What datasources we use in the system
|
|
117
|
+
*/
|
|
118
|
+
var UsedDatasourceLabels;
|
|
119
|
+
(function (UsedDatasourceLabels) {
|
|
120
|
+
UsedDatasourceLabels["Attribute"] = "attributeSource";
|
|
121
|
+
UsedDatasourceLabels["Geojson"] = "geojson";
|
|
122
|
+
UsedDatasourceLabels["WMS"] = "wms";
|
|
123
|
+
UsedDatasourceLabels["COG"] = "cloudOptimizedGeotiff";
|
|
124
|
+
UsedDatasourceLabels["MVT"] = "mvt";
|
|
125
|
+
UsedDatasourceLabels["XYZ"] = "xyz";
|
|
126
|
+
UsedDatasourceLabels["CSV"] = "csv";
|
|
127
|
+
UsedDatasourceLabels["GeoTIFF"] = "geotiff";
|
|
128
|
+
UsedDatasourceLabels["Shapefile"] = "shapefile";
|
|
129
|
+
UsedDatasourceLabels["PostGIS"] = "postgis";
|
|
130
|
+
UsedDatasourceLabels["WMTS"] = "wmts";
|
|
131
|
+
UsedDatasourceLabels["WFS"] = "wfs";
|
|
132
|
+
UsedDatasourceLabels["GeoPackage"] = "geopackage"; // OGC GeoPackage format
|
|
133
|
+
})(UsedDatasourceLabels || (UsedDatasourceLabels = {}));
|
|
134
|
+
/**
|
|
135
|
+
* What types of edges we use in metadata model
|
|
136
|
+
*/
|
|
137
|
+
var UsedEdgeLabels;
|
|
138
|
+
(function (UsedEdgeLabels) {
|
|
139
|
+
UsedEdgeLabels["RelatedTo"] = "RELATED";
|
|
140
|
+
UsedEdgeLabels["Has"] = "HAS";
|
|
141
|
+
UsedEdgeLabels["InPostgisLocation"] = "IN_POSTGIS_LOCATION"; // Edge to connect datasource with PostGIS location (schema, table, geometry column)
|
|
142
|
+
})(UsedEdgeLabels || (UsedEdgeLabels = {}));
|
|
143
|
+
|
|
99
144
|
/**
|
|
100
145
|
* Extract message from exception error (try-catch)
|
|
101
146
|
* @param error error from catch block as any
|
|
@@ -146,49 +191,5 @@ class AppLogger {
|
|
|
146
191
|
}
|
|
147
192
|
}
|
|
148
193
|
|
|
149
|
-
/**
|
|
150
|
-
* What types of graph nodes we use in metadata model
|
|
151
|
-
*/
|
|
152
|
-
var UsedNodeLabels;
|
|
153
|
-
(function (UsedNodeLabels) {
|
|
154
|
-
UsedNodeLabels["Application"] = "application";
|
|
155
|
-
UsedNodeLabels["Datasource"] = "datasource";
|
|
156
|
-
UsedNodeLabels["Place"] = "place";
|
|
157
|
-
UsedNodeLabels["Period"] = "period";
|
|
158
|
-
UsedNodeLabels["AreaTree"] = "areaTree";
|
|
159
|
-
UsedNodeLabels["AreaTreeLevel"] = "areaTreeLevel";
|
|
160
|
-
UsedNodeLabels["Layer"] = "layer";
|
|
161
|
-
UsedNodeLabels["Style"] = "style";
|
|
162
|
-
UsedNodeLabels["Feature"] = "feature";
|
|
163
|
-
UsedNodeLabels["Attribute"] = "attribute"; // Attribute node for properties of entities, like "temperature", "population", etc.
|
|
164
|
-
})(UsedNodeLabels || (UsedNodeLabels = {}));
|
|
165
|
-
/**
|
|
166
|
-
* What datasources we use in the system
|
|
167
|
-
*/
|
|
168
|
-
var UsedDatasourceLabels;
|
|
169
|
-
(function (UsedDatasourceLabels) {
|
|
170
|
-
UsedDatasourceLabels["Attribute"] = "attribute";
|
|
171
|
-
UsedDatasourceLabels["Geojson"] = "geojson";
|
|
172
|
-
UsedDatasourceLabels["WMS"] = "wms";
|
|
173
|
-
UsedDatasourceLabels["COG"] = "cloudOptimizedGeotiff";
|
|
174
|
-
UsedDatasourceLabels["MVT"] = "mvt";
|
|
175
|
-
UsedDatasourceLabels["XYZ"] = "xyz";
|
|
176
|
-
UsedDatasourceLabels["CSV"] = "csv";
|
|
177
|
-
UsedDatasourceLabels["GeoTIFF"] = "geotiff";
|
|
178
|
-
UsedDatasourceLabels["Shapefile"] = "shapefile";
|
|
179
|
-
UsedDatasourceLabels["PostGIS"] = "postgis";
|
|
180
|
-
UsedDatasourceLabels["WMTS"] = "wmts";
|
|
181
|
-
UsedDatasourceLabels["WFS"] = "wfs";
|
|
182
|
-
UsedDatasourceLabels["GeoPackage"] = "geopackage"; // OGC GeoPackage format
|
|
183
|
-
})(UsedDatasourceLabels || (UsedDatasourceLabels = {}));
|
|
184
|
-
/**
|
|
185
|
-
* What types of edges we use in metadata model
|
|
186
|
-
*/
|
|
187
|
-
var UsedEdgeLabels;
|
|
188
|
-
(function (UsedEdgeLabels) {
|
|
189
|
-
UsedEdgeLabels["RelatedTo"] = "RELATED";
|
|
190
|
-
UsedEdgeLabels["Has"] = "HAS";
|
|
191
|
-
})(UsedEdgeLabels || (UsedEdgeLabels = {}));
|
|
192
|
-
|
|
193
194
|
export { AppLogger, AuthorizationError, InvalidRequestError, UsedDatasourceLabels, UsedEdgeLabels, UsedNodeLabels, enumCombineValuesToString, enumValuesToArray, enumValuesToString, flattenObject, isInEnum, messageFromError, notEmptyString, randomNumberBetween, removeDuplicitiesFromArray, sortStringArray };
|
|
194
|
-
//# sourceMappingURL=index.
|
|
195
|
+
//# sourceMappingURL=index.node.js.map
|
|
@@ -0,0 +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 = \"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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,CAAA;AACpB,IAAA,OAAO,IAAI,CACT,OAAe,EACf,UAAyB,mBAAmB,EAAA;QAE5C,UAAU,CAAC,IAAI,CAAC,EAAE,GAAG,OAAO,EAAE,OAAO,EAAE,CAAC;IAC1C;AAEA,IAAA,OAAO,IAAI,CACT,OAAe,EACf,UAAyB,mBAAmB,EAAA;QAE5C,UAAU,CAAC,IAAI,CAAC,EAAE,GAAG,OAAO,EAAE,OAAO,EAAE,CAAC;IAC1C;AAEA,IAAA,OAAO,KAAK,CACV,OAAe,EACf,UAAyB,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/package.json
CHANGED
|
@@ -1,28 +1,32 @@
|
|
|
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
|
-
"main": "./dist/index.cjs",
|
|
7
|
-
"module": "./dist/index.mjs",
|
|
8
|
-
"types": "./dist/index.d.ts",
|
|
9
6
|
"files": [
|
|
10
7
|
"dist/"
|
|
11
8
|
],
|
|
12
9
|
"exports": {
|
|
13
|
-
"
|
|
14
|
-
"types": "./dist/index.d.ts",
|
|
15
|
-
"import": "./dist/index.
|
|
16
|
-
"
|
|
17
|
-
|
|
18
|
-
|
|
10
|
+
"./browser": {
|
|
11
|
+
"types": "./dist/index.browser.d.ts",
|
|
12
|
+
"import": "./dist/index.browser.js",
|
|
13
|
+
"default": "./dist/index.browser.js"
|
|
14
|
+
},
|
|
15
|
+
"./node": {
|
|
16
|
+
"types": "./dist/index.node.d.ts",
|
|
17
|
+
"require": "./dist/index.node.cjs",
|
|
18
|
+
"default": "./dist/index.node.js"
|
|
19
|
+
},
|
|
20
|
+
"./package.json": "./package.json"
|
|
19
21
|
},
|
|
22
|
+
"sideEffects": false,
|
|
20
23
|
"scripts": {
|
|
21
24
|
"yalc:publish": "yalc publish",
|
|
22
25
|
"yalc:publish:push": "yalc publish --push",
|
|
23
26
|
"build:clean": "rm -rf dist .rollup.cache tsconfig.tsbuildinfo",
|
|
24
27
|
"dev": "npm run build:clean && rollup --config --watch",
|
|
25
28
|
"build": "npm run build:clean && rollup --config",
|
|
29
|
+
"build:tsc": "tsc --build tsconfig.prod.json",
|
|
26
30
|
"test": "vitest --config vitest.config.ts",
|
|
27
31
|
"pack:check": "npm pack --dry-run"
|
|
28
32
|
},
|
package/dist/index.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../../src/coding/code.formating.ts","../../src/api/errors.api.ts","../../src/logging/logger.ts","../../src/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}","// 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}","/**\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"],"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,S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AA,SAAmB;AACnB,IAAA,oBAAA,CAAA,MAAA,CAAA,GAAA,MAAa;AACb,IAAA,oBAAA,CAAA,KAAA,CAAA,GAAA,KAAW;IACX,oBAAA,CAAA,YAAA,CAAA,GAAA,YAAyB,CAAA;AAC7B,CAAC,EAdWA,4BAAoB,KAApBA,4BAAoB,GAAA,EAAA,CAAA,CAAA;AAgBhC;;AAEG;AACSC;AAAZ,CAAA,UAAY,cAAc,EAAA;AACtB,IAAA,cAAA,CAAA,WAAA,CAAA,GAAA,SAAqB;AACrB,IAAA,cAAA,CAAA,KAAA,CAAA,GAAA,KAAW;AACf,CAAC,EAHWA,sBAAc,KAAdA,sBAAc,GAAA,EAAA,CAAA,CAAA;;;;;;;;;;;;;;;;"}
|
package/dist/index.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export { enumCombineValuesToString, enumValuesToArray, enumValuesToString, flattenObject, isInEnum, notEmptyString, randomNumberBetween, removeDuplicitiesFromArray, sortStringArray } from "./src/coding/code.formating";
|
|
2
|
-
export { type Nullable, type Nullish, type Unsure, type UsurePromise } from "./src/coding/code.types";
|
|
3
|
-
export { messageFromError, InvalidRequestError, AuthorizationError } from "./src/api/errors.api";
|
|
4
|
-
export { type ApiEndpointResponse } from "./src/api/models.api";
|
|
5
|
-
export { type AppLogOptions } from "./src/logging/logger";
|
|
6
|
-
export { AppLogger } from "./src/logging/logger";
|
|
7
|
-
export { UsedDatasourceLabels, UsedEdgeLabels, UsedNodeLabels } from "./src/panther/enums.panther";
|
|
8
|
-
export { type GraphEdge, type GraphRelation } from "./src/panther/models.edges";
|
|
9
|
-
export { type HasBands, type HasColor, type HasConfiguration, type HasGeometry, type HasInterval, type HasLevels, type HasSpecificName, type HasUrl, type HasUnits } from "./src/panther/models.nodes.properties";
|
|
10
|
-
export { type Place, type Period, type AreaTreeLevel, type Datasource, type ApplicationNode, type Attribute, type FullPantherEntity, type MapStyle, type PantherEntity } from "./src/panther/models.nodes";
|
package/dist/index.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":["../../src/coding/code.formating.ts","../../src/api/errors.api.ts","../../src/logging/logger.ts","../../src/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}","// 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}","/**\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"],"names":[],"mappings":";;;AAAA;;;;;AAKG;MACU,QAAQ,GAAG,CAAC,KAA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AA,WAAuB,CAAA;AAC3B,CAAC,EAXW,cAAc,KAAd,cAAc,GAAA,EAAA,CAAA,CAAA;AAa1B;;AAEG;IACS;AAAZ,CAAA,UAAY,oBAAoB,EAAA;AAC5B,IAAA,oBAAA,CAAA,WAAA,CAAA,GAAA,WAAuB;AACvB,IAAA,oBAAA,CAAA,SAAA,CAAA,GAAA,SAAmB;AACnB,IAAA,oBAAA,CAAA,KAAA,CAAA,GAAA,KAAW;AACX,IAAA,oBAAA,CAAA,KAAA,CAAA,GAAA,uBAA6B;AAC7B,IAAA,oBAAA,CAAA,KAAA,CAAA,GAAA,KAAW;AACX,IAAA,oBAAA,CAAA,KAAA,CAAA,GAAA,KAAW;AACX,IAAA,oBAAA,CAAA,KAAA,CAAA,GAAA,KAAW;AACX,IAAA,oBAAA,CAAA,SAAA,CAAA,GAAA,SAAmB;AACnB,IAAA,oBAAA,CAAA,WAAA,CAAA,GAAA,WAAuB;AACvB,IAAA,oBAAA,CAAA,SAAA,CAAA,GAAA,SAAmB;AACnB,IAAA,oBAAA,CAAA,MAAA,CAAA,GAAA,MAAa;AACb,IAAA,oBAAA,CAAA,KAAA,CAAA,GAAA,KAAW;IACX,oBAAA,CAAA,YAAA,CAAA,GAAA,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;AACf,CAAC,EAHW,cAAc,KAAd,cAAc,GAAA,EAAA,CAAA,CAAA;;;;"}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|