@gisatcz/ptr-be-core 0.0.1-dev.2 → 0.0.1-dev.4

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 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
@@ -1,5 +1,5 @@
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
3
  /**
4
4
  * Tuple for relation between two graph nodes
5
5
  * It is point to point definition of graph edge
@@ -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,6 @@
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 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
+ 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";
@@ -1,52 +1,3 @@
1
- 'use strict';
2
-
3
- var pino = require('pino');
4
- var pretty = require('pino-pretty');
5
-
6
- /**
7
- * What types of graph nodes we use in metadata model
8
- */
9
- exports.UsedNodeLabels = void 0;
10
- (function (UsedNodeLabels) {
11
- UsedNodeLabels["Application"] = "application";
12
- UsedNodeLabels["Datasource"] = "datasource";
13
- UsedNodeLabels["Place"] = "place";
14
- UsedNodeLabels["Period"] = "period";
15
- UsedNodeLabels["AreaTree"] = "areaTree";
16
- UsedNodeLabels["AreaTreeLevel"] = "areaTreeLevel";
17
- UsedNodeLabels["Layer"] = "layer";
18
- UsedNodeLabels["Style"] = "style";
19
- UsedNodeLabels["Feature"] = "feature";
20
- UsedNodeLabels["Attribute"] = "attribute"; // Attribute node for properties of entities, like "temperature", "population", etc.
21
- })(exports.UsedNodeLabels || (exports.UsedNodeLabels = {}));
22
- /**
23
- * What datasources we use in the system
24
- */
25
- exports.UsedDatasourceLabels = void 0;
26
- (function (UsedDatasourceLabels) {
27
- UsedDatasourceLabels["Attribute"] = "attribute";
28
- UsedDatasourceLabels["Geojson"] = "geojson";
29
- UsedDatasourceLabels["WMS"] = "wms";
30
- UsedDatasourceLabels["COG"] = "cloudOptimizedGeotiff";
31
- UsedDatasourceLabels["MVT"] = "mvt";
32
- UsedDatasourceLabels["XYZ"] = "xyz";
33
- UsedDatasourceLabels["CSV"] = "csv";
34
- UsedDatasourceLabels["GeoTIFF"] = "geotiff";
35
- UsedDatasourceLabels["Shapefile"] = "shapefile";
36
- UsedDatasourceLabels["PostGIS"] = "postgis";
37
- UsedDatasourceLabels["WMTS"] = "wmts";
38
- UsedDatasourceLabels["WFS"] = "wfs";
39
- UsedDatasourceLabels["GeoPackage"] = "geopackage"; // OGC GeoPackage format
40
- })(exports.UsedDatasourceLabels || (exports.UsedDatasourceLabels = {}));
41
- /**
42
- * What types of edges we use in metadata model
43
- */
44
- exports.UsedEdgeLabels = void 0;
45
- (function (UsedEdgeLabels) {
46
- UsedEdgeLabels["RelatedTo"] = "RELATED";
47
- UsedEdgeLabels["Has"] = "HAS";
48
- })(exports.UsedEdgeLabels || (exports.UsedEdgeLabels = {}));
49
-
50
1
  /**
51
2
  * Check if the value in included in enum posibilities.
52
3
  * @param value Value we need to check
@@ -143,66 +94,48 @@ const flattenObject = (obj, prefix = '') => {
143
94
  };
144
95
 
145
96
  /**
146
- * Extract message from exception error (try-catch)
147
- * @param error error from catch block as any
148
- * @returns
97
+ * What types of graph nodes we use in metadata model
149
98
  */
150
- const messageFromError = (error) => error["message"];
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 = {}));
151
112
  /**
152
- * We miss a API parameter needed to process action
113
+ * What datasources we use in the system
153
114
  */
154
- class InvalidRequestError extends Error {
155
- constructor(message) {
156
- super(`Invalid Request: ${message}`);
157
- }
158
- }
115
+ var UsedDatasourceLabels;
116
+ (function (UsedDatasourceLabels) {
117
+ UsedDatasourceLabels["Attribute"] = "attribute";
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 = {}));
159
131
  /**
160
- * Where client has general authorization issue
132
+ * What types of edges we use in metadata model
161
133
  */
162
- class AuthorizationError extends Error {
163
- constructor() {
164
- super(`Authorization has failed.`);
165
- }
166
- }
167
-
168
- // logger.ts
169
- const DEFAULT_LOG_OPTIONS = {
170
- label: 'App'
171
- };
172
- // create the pretty‐printing stream once
173
- const prettyStream = pretty({
174
- colorize: true,
175
- levelFirst: true,
176
- translateTime: 'yyyy-mm-dd HH:MM:ss'
177
- });
178
- // create your logger once and for all
179
- const baseLogger = pino({}, prettyStream);
180
- class AppLogger {
181
- static info(message, options = DEFAULT_LOG_OPTIONS) {
182
- baseLogger.info({ ...options, message });
183
- }
184
- static warn(message, options = DEFAULT_LOG_OPTIONS) {
185
- baseLogger.warn({ ...options, message });
186
- }
187
- static error(message, options = DEFAULT_LOG_OPTIONS) {
188
- baseLogger.error({ ...options, message });
189
- }
190
- static appStart(host, port, options = DEFAULT_LOG_OPTIONS) {
191
- AppLogger.info(`Application started on ${host}:${port}`, options);
192
- }
193
- }
134
+ var UsedEdgeLabels;
135
+ (function (UsedEdgeLabels) {
136
+ UsedEdgeLabels["RelatedTo"] = "RELATED";
137
+ UsedEdgeLabels["Has"] = "HAS";
138
+ })(UsedEdgeLabels || (UsedEdgeLabels = {}));
194
139
 
195
- exports.AppLogger = AppLogger;
196
- exports.AuthorizationError = AuthorizationError;
197
- exports.InvalidRequestError = InvalidRequestError;
198
- exports.enumCombineValuesToString = enumCombineValuesToString;
199
- exports.enumValuesToArray = enumValuesToArray;
200
- exports.enumValuesToString = enumValuesToString;
201
- exports.flattenObject = flattenObject;
202
- exports.isInEnum = isInEnum;
203
- exports.messageFromError = messageFromError;
204
- exports.notEmptyString = notEmptyString;
205
- exports.randomNumberBetween = randomNumberBetween;
206
- exports.removeDuplicitiesFromArray = removeDuplicitiesFromArray;
207
- exports.sortStringArray = sortStringArray;
208
- //# sourceMappingURL=index.cjs.map
140
+ export { UsedDatasourceLabels, UsedEdgeLabels, UsedNodeLabels, enumCombineValuesToString, enumValuesToArray, enumValuesToString, flattenObject, isInEnum, notEmptyString, randomNumberBetween, removeDuplicitiesFromArray, sortStringArray };
141
+ //# 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 = \"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,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;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AW;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;;;;"}
@@ -0,0 +1,10 @@
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 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
+ 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
+ export { messageFromError, InvalidRequestError, AuthorizationError } from "./node/api/errors.api.js";
8
+ export { type ApiEndpointResponse } from "./node/api/models.api.js";
9
+ export { type AppLogOptions } from "./node/logging/logger.js";
10
+ export { AppLogger } from "./node/logging/logger.js";
@@ -1,50 +1,6 @@
1
1
  import pino from 'pino';
2
2
  import pretty from 'pino-pretty';
3
3
 
4
- /**
5
- * What types of graph nodes we use in metadata model
6
- */
7
- var UsedNodeLabels;
8
- (function (UsedNodeLabels) {
9
- UsedNodeLabels["Application"] = "application";
10
- UsedNodeLabels["Datasource"] = "datasource";
11
- UsedNodeLabels["Place"] = "place";
12
- UsedNodeLabels["Period"] = "period";
13
- UsedNodeLabels["AreaTree"] = "areaTree";
14
- UsedNodeLabels["AreaTreeLevel"] = "areaTreeLevel";
15
- UsedNodeLabels["Layer"] = "layer";
16
- UsedNodeLabels["Style"] = "style";
17
- UsedNodeLabels["Feature"] = "feature";
18
- UsedNodeLabels["Attribute"] = "attribute"; // Attribute node for properties of entities, like "temperature", "population", etc.
19
- })(UsedNodeLabels || (UsedNodeLabels = {}));
20
- /**
21
- * What datasources we use in the system
22
- */
23
- var UsedDatasourceLabels;
24
- (function (UsedDatasourceLabels) {
25
- UsedDatasourceLabels["Attribute"] = "attribute";
26
- UsedDatasourceLabels["Geojson"] = "geojson";
27
- UsedDatasourceLabels["WMS"] = "wms";
28
- UsedDatasourceLabels["COG"] = "cloudOptimizedGeotiff";
29
- UsedDatasourceLabels["MVT"] = "mvt";
30
- UsedDatasourceLabels["XYZ"] = "xyz";
31
- UsedDatasourceLabels["CSV"] = "csv";
32
- UsedDatasourceLabels["GeoTIFF"] = "geotiff";
33
- UsedDatasourceLabels["Shapefile"] = "shapefile";
34
- UsedDatasourceLabels["PostGIS"] = "postgis";
35
- UsedDatasourceLabels["WMTS"] = "wmts";
36
- UsedDatasourceLabels["WFS"] = "wfs";
37
- UsedDatasourceLabels["GeoPackage"] = "geopackage"; // OGC GeoPackage format
38
- })(UsedDatasourceLabels || (UsedDatasourceLabels = {}));
39
- /**
40
- * What types of edges we use in metadata model
41
- */
42
- var UsedEdgeLabels;
43
- (function (UsedEdgeLabels) {
44
- UsedEdgeLabels["RelatedTo"] = "RELATED";
45
- UsedEdgeLabels["Has"] = "HAS";
46
- })(UsedEdgeLabels || (UsedEdgeLabels = {}));
47
-
48
4
  /**
49
5
  * Check if the value in included in enum posibilities.
50
6
  * @param value Value we need to check
@@ -140,6 +96,50 @@ const flattenObject = (obj, prefix = '') => {
140
96
  }, {});
141
97
  };
142
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"] = "attribute";
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 || (UsedEdgeLabels = {}));
142
+
143
143
  /**
144
144
  * Extract message from exception error (try-catch)
145
145
  * @param error error from catch block as any
@@ -191,4 +191,4 @@ class AppLogger {
191
191
  }
192
192
 
193
193
  export { AppLogger, AuthorizationError, InvalidRequestError, UsedDatasourceLabels, UsedEdgeLabels, UsedNodeLabels, enumCombineValuesToString, enumValuesToArray, enumValuesToString, flattenObject, isInEnum, messageFromError, notEmptyString, randomNumberBetween, removeDuplicitiesFromArray, sortStringArray };
194
- //# sourceMappingURL=index.mjs.map
194
+ //# 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 = \"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,y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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,30 +1,32 @@
1
1
  {
2
2
  "name": "@gisatcz/ptr-be-core",
3
- "version": "0.0.1-dev.2",
3
+ "version": "0.0.1-dev.4",
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
- "dist"
7
+ "dist/"
11
8
  ],
12
9
  "exports": {
13
- ".": {
14
- "import": "./dist/index.mjs",
15
- "require": "./dist/index.cjs",
16
- "types": "./dist/index.d.ts"
17
- }
10
+ "./browser": {
11
+ "types": "./dist/index.browser.d.ts",
12
+ "import": "./dist/index.browser.js"
13
+ },
14
+ "./node": {
15
+ "types": "./dist/index.node.d.ts",
16
+ "import": "./dist/index.node.js"
17
+ },
18
+ "./package.json": "./package.json"
18
19
  },
20
+ "sideEffects": false,
19
21
  "scripts": {
20
- "build:clean": "rm -rf dist .rollup.cache tsconfig.tsbuildinfo",
21
- "build:barrels": "barrelsby -c barrelsby.json",
22
22
  "yalc:publish": "yalc publish",
23
23
  "yalc:publish:push": "yalc publish --push",
24
+ "build:clean": "rm -rf dist .rollup.cache tsconfig.tsbuildinfo",
25
+ "dev": "npm run build:clean && rollup --config --watch",
26
+ "build": "npm run build:clean && rollup --config",
24
27
  "build:tsc": "tsc --build tsconfig.prod.json",
25
- "dev": "rollup --config --watch",
26
- "build": "rollup --config",
27
- "test": "vitest --config vitest.config.ts"
28
+ "test": "vitest --config vitest.config.ts",
29
+ "pack:check": "npm pack --dry-run"
28
30
  },
29
31
  "author": "",
30
32
  "license": "ISC",
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.cjs","sources":["../../src/panther/enums.panther.ts","../../src/coding/code.formating.ts","../../src/api/errors.api.ts","../../src/logging/logger.ts"],"sourcesContent":["/**\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 * 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}"],"names":["UsedNodeLabels","UsedDatasourceLabels","UsedEdgeLabels"],"mappings":";;;;;AAAA;;AAEG;AACSA;AAAZ,CAAA,UAAY,cAAc,EAAA;AACtB,IAAA,cAAA,CAAA,aAAA,CAAA,GAAA,aAA2B;AAC3B,IAAA,cAAA,CAAA,YAAA,CAAA,GAAA,YAAyB;AACzB,IAAA,cAAA,CAAA,OAAA,CAAA,GAAA,OAAe;AACf,IAAA,cAAA,CAAA,QAAA,CAAA,GAAA,QAAiB;AACjB,IAAA,cAAA,CAAA,UAAA,CAAA,GAAA,UAAqB;AACrB,IAAA,cAAA,CAAA,eAAA,CAAA,GAAA,eAA+B;AAC/B,IAAA,cAAA,CAAA,OAAA,CAAA,GAAA,OAAe;AACf,IAAA,cAAA,CAAA,OAAA,CAAA,GAAA,OAAe;AACf,IAAA,cAAA,CAAA,SAAA,CAAA,GAAA,SAAmB;IACnB,cAAA,CAAA,WAAA,CAAA,GAAA,WAAuB,CAAA;AAC3B,CAAC,EAXWA,sBAAc,KAAdA,sBAAc,GAAA,EAAA,CAAA,CAAA;AAa1B;;AAEG;AACSC;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,GAA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AS,CAAC,IAAI,CAAC,CAAA,uBAAA,EAA0B,IAAI,CAAA,CAAA,EAAI,IAAI,CAAA,CAAE,EAAE,OAAO,CAAC;IACnE;AACD;;;;;;;;;;;;;;;;"}
package/dist/index.d.ts DELETED
@@ -1,11 +0,0 @@
1
- import { UsedDatasourceLabels, UsedEdgeLabels, UsedNodeLabels } from "./src/panther/enums.panther";
2
- export { enumCombineValuesToString, enumValuesToArray, enumValuesToString, flattenObject, isInEnum, notEmptyString, randomNumberBetween, removeDuplicitiesFromArray, sortStringArray } from "./src/coding/code.formating";
3
- export type { Nullable, Nullish, Unsure, UsurePromise } from "./src/coding/code.types";
4
- export { messageFromError, InvalidRequestError, AuthorizationError } from "./src/api/errors.api";
5
- export type { ApiEndpointResponse } from "./src/api/models.api";
6
- export type { AppLogOptions } from "./src/logging/logger";
7
- export { AppLogger } from "./src/logging/logger";
8
- export { UsedDatasourceLabels, UsedEdgeLabels, UsedNodeLabels };
9
- export type { GraphEdge, GraphRelation } from "./src/panther/models.edges";
10
- export type { HasBands, HasColor, HasConfiguration, HasGeometry, HasInterval, HasLevels, HasSpecificName, HasUrl, HasUnits } from "./src/panther/models.nodes.properties";
11
- export type { Place, Period, AreaTreeLevel, Datasource, ApplicationNode, Attribute, FullPantherEntity } from "./src/panther/models.nodes";
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.mjs","sources":["../../src/panther/enums.panther.ts","../../src/coding/code.formating.ts","../../src/api/errors.api.ts","../../src/logging/logger.ts"],"sourcesContent":["/**\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 * 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}"],"names":[],"mappings":";;;AAAA;;AAEG;IACS;AAAZ,CAAA,UAAY,cAAc,EAAA;AACtB,IAAA,cAAA,CAAA,aAAA,CAAA,GAAA,aAA2B;AAC3B,IAAA,cAAA,CAAA,YAAA,CAAA,GAAA,YAAyB;AACzB,IAAA,cAAA,CAAA,OAAA,CAAA,GAAA,OAAe;AACf,IAAA,cAAA,CAAA,QAAA,CAAA,GAAA,QAAiB;AACjB,IAAA,cAAA,CAAA,UAAA,CAAA,GAAA,UAAqB;AACrB,IAAA,cAAA,CAAA,eAAA,CAAA,GAAA,eAA+B;AAC/B,IAAA,cAAA,CAAA,OAAA,CAAA,GAAA,OAAe;AACf,IAAA,cAAA,CAAA,OAAA,CAAA,GAAA,OAAe;AACf,IAAA,cAAA,CAAA,SAAA,CAAA,GAAA,SAAmB;IACnB,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