@gisatcz/ptr-be-core 0.0.1-dev.1

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.
Files changed (37) hide show
  1. package/.github/workflows/release-dev.yml +34 -0
  2. package/.github/workflows/release.yml +28 -0
  3. package/.github/workflows/version-bump.yml +68 -0
  4. package/Readme.md +26 -0
  5. package/barrelsby.json +9 -0
  6. package/dist/index.cjs +26340 -0
  7. package/dist/index.cjs.map +1 -0
  8. package/dist/index.d.ts +11 -0
  9. package/dist/index.d.ts.map +1 -0
  10. package/dist/index.mjs +26329 -0
  11. package/dist/index.mjs.map +1 -0
  12. package/dist/src/coding/code.formating.d.ts +77 -0
  13. package/dist/src/coding/code.formating.d.ts.map +1 -0
  14. package/dist/src/coding/code.types.d.ts +6 -0
  15. package/dist/src/coding/code.types.d.ts.map +1 -0
  16. package/dist/src/logging/logger.d.ts +16 -0
  17. package/dist/src/logging/logger.d.ts.map +1 -0
  18. package/dist/src/panther/enums.panther.d.ts +40 -0
  19. package/dist/src/panther/enums.panther.d.ts.map +1 -0
  20. package/dist/src/panther/models.edges.d.ts +18 -0
  21. package/dist/src/panther/models.edges.d.ts.map +1 -0
  22. package/dist/src/panther/models.nodes.d.ts +53 -0
  23. package/dist/src/panther/models.nodes.d.ts.map +1 -0
  24. package/dist/src/panther/models.nodes.properties.d.ts +29 -0
  25. package/dist/src/panther/models.nodes.properties.d.ts.map +1 -0
  26. package/doc/npm-refresh.md +4 -0
  27. package/package.json +46 -0
  28. package/rollup.config.js +30 -0
  29. package/src/coding/code.formating.ts +104 -0
  30. package/src/coding/code.types.ts +11 -0
  31. package/src/logging/logger.ts +58 -0
  32. package/src/panther/SharedFeature.md +43 -0
  33. package/src/panther/enums.panther.ts +41 -0
  34. package/src/panther/models.edges.ts +20 -0
  35. package/src/panther/models.nodes.properties.ts +31 -0
  36. package/src/panther/models.nodes.ts +55 -0
  37. package/tsconfig.json +51 -0
@@ -0,0 +1,77 @@
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
+ export declare const isInEnum: (value: any, enumEntity: any) => boolean;
8
+ /**
9
+ * Sort array of string elements
10
+ * @param rawArray Raw unsorted array of elements
11
+ * @returns Sorted string array
12
+ */
13
+ export declare const sortStringArray: (rawArray: string[]) => string[];
14
+ /**
15
+ * Remove all duplicity string items from an array
16
+ * @param arr Original array with duplicities
17
+ * @returns Array of original values
18
+ */
19
+ export declare const removeDuplicitiesFromArray: (arr: any[]) => any[];
20
+ /**
21
+ * Check if the string value is not ` "" `
22
+ * @param value Value to check
23
+ * @returns Boolean result about the truth
24
+ */
25
+ export declare const notEmptyString: (value: string) => boolean;
26
+ /**
27
+ * Return enum values as array of string
28
+ * @param enumType Type of the enum from code
29
+ * @param separator Optional - separator character
30
+ * @returns Array of enum possible values
31
+ */
32
+ export declare const enumValuesToString: (enumType: any, separator?: string) => string;
33
+ /**
34
+ * Return enum values as array of string
35
+ * @param enumTypes Combination of enum types
36
+ * @param separator Optional - separator character
37
+ * @returns Array of enum possible values
38
+ */
39
+ export declare const enumCombineValuesToString: (enumTypes: any[], separator?: string) => string;
40
+ /**
41
+ * Return all enum values as array
42
+ * @param enumType What array we want to work with
43
+ * @returns Array of enum values
44
+ */
45
+ export declare const enumValuesToArray: (enumType: any) => string[];
46
+ /**
47
+ * Return random number (integer) between two values
48
+ * @param min
49
+ * @param max
50
+ * @returns
51
+ */
52
+ export declare const randomNumberBetween: (min: number, max: number) => number;
53
+ /**
54
+ * Recursively flattens a nested object. The keys of the resulting object
55
+ * will be the paths to the original values in the nested object, joined by dots.
56
+ *
57
+ * @param obj - The object to flatten.
58
+ * @param prefix - The prefix to use for the keys in the flattened object. Defaults to an empty string.
59
+ * @returns A new object with flattened keys.
60
+ *
61
+ * @example
62
+ * ```typescript
63
+ * const nestedObj = {
64
+ * a: {
65
+ * b: {
66
+ * c: 1
67
+ * }
68
+ * },
69
+ * d: 2
70
+ * };
71
+ * const flatObj = flattenObject(nestedObj);
72
+ * console.log(flatObj);
73
+ * // Output: { 'a.b.c': 1, 'a.b.d': 2 }
74
+ * ```
75
+ */
76
+ export declare const flattenObject: (obj: any, prefix?: string) => Record<string, any>;
77
+ //# sourceMappingURL=code.formating.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"code.formating.d.ts","sourceRoot":"","sources":["../../../src/coding/code.formating.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,eAAO,MAAM,QAAQ,GAAI,OAAO,GAAG,EAAE,YAAY,GAAG,YAGjD,CAAA;AAEH;;;;GAIG;AACH,eAAO,MAAM,eAAe,GAAI,UAAU,MAAM,EAAE,aAAqB,CAAA;AAEvE;;;;GAIG;AACH,eAAO,MAAM,0BAA0B,GAAI,KAAK,GAAG,EAAE,UAAsB,CAAA;AAE3E;;;;GAIG;AACH,eAAO,MAAM,cAAc,GAAI,OAAO,MAAM,YAAiB,CAAA;AAG7D;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,GAAI,UAAU,GAAG,EAAE,kBAAgB,WAA4C,CAAA;AAE9G;;;;;GAKG;AACH,eAAO,MAAM,yBAAyB,GAAI,WAAW,GAAG,EAAE,EAAE,kBAAgB,WAAuF,CAAA;AAEnK;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,GAAI,UAAU,GAAG,KAAgC,MAAM,EAAE,CAAA;AAEvF;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,GAAI,KAAK,MAAM,EAAE,KAAK,MAAM,WAI3D,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,eAAO,MAAM,aAAa,GAAI,KAAK,GAAG,EAAE,eAAW,KAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAUvE,CAAA"}
@@ -0,0 +1,6 @@
1
+ type Nullable<T> = T | null;
2
+ type Unsure<T> = T | undefined;
3
+ type Nullish<T> = T | undefined | null;
4
+ type UsurePromise<T> = Unsure<Promise<T>>;
5
+ export { Nullable, Nullish, Unsure, UsurePromise };
6
+ //# sourceMappingURL=code.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"code.types.d.ts","sourceRoot":"","sources":["../../../src/coding/code.types.ts"],"names":[],"mappings":"AAAA,KAAK,QAAQ,CAAC,CAAC,IAAI,CAAC,GAAG,IAAI,CAAA;AAC3B,KAAK,MAAM,CAAC,CAAC,IAAI,CAAC,GAAG,SAAS,CAAA;AAC9B,KAAK,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,SAAS,GAAG,IAAI,CAAA;AACtC,KAAK,YAAY,CAAC,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAA;AAEzC,OAAO,EACH,QAAQ,EACR,OAAO,EACP,MAAM,EACN,YAAY,EACf,CAAA"}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * @typedef {Object} AppLogOptions
3
+ * @property {string} label - The label for the log entry.
4
+ * @property {string|number|boolean} [key] - Any extra fields.
5
+ */
6
+ export type AppLogOptions = {
7
+ label: string;
8
+ [key: string]: string | number | boolean;
9
+ };
10
+ export declare class AppLogger {
11
+ static info(message: string, options?: AppLogOptions): void;
12
+ static warn(message: string, options?: AppLogOptions): void;
13
+ static error(message: string, options?: AppLogOptions): void;
14
+ static appStart(host: string, port: number, options?: AppLogOptions): void;
15
+ }
16
+ //# sourceMappingURL=logger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../../src/logging/logger.ts"],"names":[],"mappings":"AAIA;;;;GAIG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B,KAAK,EAAE,MAAM,CAAA;IACb,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAC,MAAM,GAAC,OAAO,CAAA;CACrC,CAAA;AAgBD,qBAAa,SAAS;IACpB,MAAM,CAAC,IAAI,CACT,OAAO,EAAE,MAAM,EACf,OAAO,GAAE,aAAmC;IAK9C,MAAM,CAAC,IAAI,CACT,OAAO,EAAE,MAAM,EACf,OAAO,GAAE,aAAmC;IAK9C,MAAM,CAAC,KAAK,CACV,OAAO,EAAE,MAAM,EACf,OAAO,GAAE,aAAmC;IAK9C,MAAM,CAAC,QAAQ,CACb,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE,aAAmC;CAI/C"}
@@ -0,0 +1,40 @@
1
+ /**
2
+ * What types of graph nodes we use in metadata model
3
+ */
4
+ export declare enum UsedNodeLabels {
5
+ Application = "application",// Application node (the root of the FE app)
6
+ Datasource = "datasource",// Datasource node for data including GIS information
7
+ Place = "place",// Place node for geographical information
8
+ Period = "period",// Period node for time information
9
+ AreaTree = "areaTree",// Area tree node for administrative division
10
+ AreaTreeLevel = "areaTreeLevel",// Area tree level node for administrative division
11
+ Layer = "layer",// Layer node for map layer (layer have a style and a datasource)
12
+ Style = "style",// Style node for map layer or a feature
13
+ Feature = "feature"
14
+ }
15
+ /**
16
+ * What datasources we use in the system
17
+ */
18
+ export declare enum UsedDatasourceLabels {
19
+ Attribute = "attribute",// Column(s) with attribute values
20
+ Geojson = "geojson",// Geojson for web map
21
+ WMS = "wms",// WMS online source
22
+ COG = "cogBitmap",// COG online source
23
+ MVT = "mvt",// MVT (Mapbox Vector Tiles) source
24
+ XYZ = "xyz",// XYZ tile source
25
+ CSV = "csv",// CSV data source
26
+ GeoTIFF = "geotiff",// GeoTIFF raster data
27
+ Shapefile = "shapefile",// ESRI Shapefile format
28
+ PostGIS = "postgis",// PostGIS database source
29
+ WMTS = "wmts",// Web Map Tile Service
30
+ WFS = "wfs",// Web Feature Service
31
+ GeoPackage = "geopackage"
32
+ }
33
+ /**
34
+ * What types of edges we use in metadata model
35
+ */
36
+ export declare enum UsedEdgeLabels {
37
+ RelatedTo = "RELATED",// Generic edge for any relation
38
+ Has = "HAS"
39
+ }
40
+ //# sourceMappingURL=enums.panther.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"enums.panther.d.ts","sourceRoot":"","sources":["../../../src/panther/enums.panther.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,oBAAY,cAAc;IACtB,WAAW,gBAAgB,CAAE,4CAA4C;IACzE,UAAU,eAAe,CAAE,qDAAqD;IAChF,KAAK,UAAU,CAAE,0CAA0C;IAC3D,MAAM,WAAW,CAAE,mCAAmC;IACtD,QAAQ,aAAa,CAAE,6CAA6C;IACpE,aAAa,kBAAkB,CAAE,mDAAmD;IACpF,KAAK,UAAU,CAAE,iEAAiE;IAClF,KAAK,UAAU,CAAE,wCAAwC;IACzD,OAAO,YAAY;CACtB;AAED;;GAEG;AACH,oBAAY,oBAAoB;IAC5B,SAAS,cAAc,CAAI,kCAAkC;IAC7D,OAAO,YAAY,CAAO,sBAAsB;IAChD,GAAG,QAAQ,CAAe,oBAAoB;IAC9C,GAAG,cAAc,CAAS,oBAAoB;IAC9C,GAAG,QAAQ,CAAe,mCAAmC;IAC7D,GAAG,QAAQ,CAAe,kBAAkB;IAC5C,GAAG,QAAQ,CAAe,kBAAkB;IAC5C,OAAO,YAAY,CAAO,sBAAsB;IAChD,SAAS,cAAc,CAAI,wBAAwB;IACnD,OAAO,YAAY,CAAO,0BAA0B;IACpD,IAAI,SAAS,CAAa,uBAAuB;IACjD,GAAG,QAAQ,CAAe,sBAAsB;IAChD,UAAU,eAAe;CAC5B;AAED;;GAEG;AACH,oBAAY,cAAc;IACtB,SAAS,YAAY,CAAE,gCAAgC;IACvD,GAAG,QAAQ;CACd"}
@@ -0,0 +1,18 @@
1
+ import { Nullable } from "../coding/code.types";
2
+ import { UsedEdgeLabels } from "./enums.panther";
3
+ /**
4
+ * Tuple for relation between two graph nodes
5
+ * It is point to point definition of graph edge
6
+ */
7
+ export type GraphRelation = [string, string];
8
+ /**
9
+ * Edge of the graph model.
10
+ * It connects two graph nodes and have some properties.
11
+ * Have "key" witch is composed from node keys.
12
+ */
13
+ export interface GraphEdge {
14
+ labels: string[] | UsedEdgeLabels[];
15
+ edgeNodes: GraphRelation;
16
+ properties: Nullable<object>;
17
+ }
18
+ //# sourceMappingURL=models.edges.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"models.edges.d.ts","sourceRoot":"","sources":["../../../src/panther/models.edges.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AAC/C,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAEhD;;;GAGG;AACH,MAAM,MAAM,aAAa,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;AAG5C;;;;GAIG;AACH,MAAM,WAAW,SAAS;IACtB,MAAM,EAAE,MAAM,EAAE,GAAG,cAAc,EAAE,CAAC;IACpC,SAAS,EAAE,aAAa,CAAA;IACxB,UAAU,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAA;CAC/B"}
@@ -0,0 +1,53 @@
1
+ import { Nullable } from "../coding/code.types";
2
+ import { HasGeometry, HasInterval, HasLevels, HasConfiguration } from "./models.nodes.properties";
3
+ import { UsedNodeLabels, UsedDatasourceLabels } from "./enums.panther";
4
+ /**
5
+ * General graph node - same for all metadatata entities
6
+ */
7
+ export interface PantherEntity {
8
+ labels: Array<string | UsedNodeLabels | UsedDatasourceLabels>;
9
+ key: string;
10
+ nameDisplay: string;
11
+ nameInternal: string;
12
+ description: Nullable<string>;
13
+ lastUpdatedAt: number;
14
+ }
15
+ /**
16
+ * Place node - somewhere in the world
17
+ */
18
+ export interface Place extends PantherEntity, HasGeometry {
19
+ }
20
+ /**
21
+ * Period node - selected time in timeline
22
+ */
23
+ export interface Period extends PantherEntity, HasInterval {
24
+ }
25
+ /**
26
+ * Area tree node - tree of areas
27
+ */
28
+ export interface AreaTreeLevel extends PantherEntity, HasLevels {
29
+ }
30
+ /**
31
+ * Datasource with source configuration
32
+ */
33
+ export interface Datasource extends PantherEntity, HasConfiguration {
34
+ }
35
+ /**
36
+ * Application node - main entity in metadata model
37
+ */
38
+ export interface ApplicationNode extends PantherEntity, HasConfiguration {
39
+ }
40
+ export { UsedNodeLabels, HasInterval, UsedDatasourceLabels };
41
+ /**
42
+ * Represents a full panther entity which extends the basic PantherEntity
43
+ * and optionally includes geometry, interval, levels, and configuration properties.
44
+ *
45
+ * @extends PantherEntity
46
+ * @extends Partial<HasGeometry>
47
+ * @extends Partial<HasInterval>
48
+ * @extends Partial<HasLevels>
49
+ * @extends Partial<HasConfiguration>
50
+ */
51
+ export interface FullPantherEntity extends PantherEntity, Partial<HasGeometry & HasInterval & HasLevels & HasConfiguration> {
52
+ }
53
+ //# sourceMappingURL=models.nodes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"models.nodes.d.ts","sourceRoot":"","sources":["../../../src/panther/models.nodes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AAC/C,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAA;AACjG,OAAO,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAA;AAEtE;;GAEG;AACH,MAAM,WAAW,aAAa;IAC1B,MAAM,EAAE,KAAK,CAAC,MAAM,GAAG,cAAc,GAAG,oBAAoB,CAAC,CAAC;IAC9D,GAAG,EAAE,MAAM,CAAA;IACX,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;IAC9B,aAAa,EAAE,MAAM,CAAC;CACzB;AAED;;GAEG;AACH,MAAM,WAAW,KAAM,SAAQ,aAAa,EAAE,WAAW;CAAI;AAE7D;;GAEG;AACH,MAAM,WAAW,MAAO,SAAQ,aAAa,EAAE,WAAW;CAAI;AAE9D;;GAEG;AACH,MAAM,WAAW,aAAc,SAAQ,aAAa,EAAE,SAAS;CAAG;AAElE;;GAEG;AACH,MAAM,WAAW,UAAW,SAAQ,aAAa,EAAE,gBAAgB;CAAG;AAEtE;;GAEG;AACH,MAAM,WAAW,eAAgB,SAAQ,aAAa,EAAE,gBAAgB;CAAG;AAE3E,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,oBAAoB,EAAE,CAAA;AAG5D;;;;;;;;;GASG;AACH,MAAM,WAAW,iBAAkB,SAAQ,aAAa,EAAE,OAAO,CAAC,WAAW,GAAG,WAAW,GAAG,SAAS,GAAG,gBAAgB,CAAC;CAAI"}
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Entity that has relevant time interval.
3
+ * Example: Period is connected to some time range.
4
+ */
5
+ export interface HasInterval {
6
+ validUtcIntervalIso: string;
7
+ validFrom: number;
8
+ validTo: number;
9
+ }
10
+ /**
11
+ * Entity with custom configuration
12
+ */
13
+ export interface HasConfiguration {
14
+ configuration: string;
15
+ }
16
+ /**
17
+ * Place node - somewhere in the world
18
+ */
19
+ export interface HasGeometry {
20
+ geometry: any;
21
+ bbox: any;
22
+ }
23
+ /**
24
+ * Place node - somewhere in the world
25
+ */
26
+ export interface HasLevels {
27
+ level: number;
28
+ }
29
+ //# sourceMappingURL=models.nodes.properties.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"models.nodes.properties.d.ts","sourceRoot":"","sources":["../../../src/panther/models.nodes.properties.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,WAAW,WAAW;IACxB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAA;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC7B,aAAa,EAAE,MAAM,CAAA;CACxB;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IACxB,QAAQ,EAAE,GAAG,CAAC;IACd,IAAI,EAAE,GAAG,CAAC;CACb;AAED;;GAEG;AACH,MAAM,WAAW,SAAS;IACtB,KAAK,EAAE,MAAM,CAAC;CACjB"}
@@ -0,0 +1,4 @@
1
+
2
+
3
+ npm install lodash luxon pino pino-pretty
4
+ npm install --save-dev @types/lodash @types/luxon @types/node barrelsby ts-node tsc-alias tsconfig-paths tsx typescript
package/package.json ADDED
@@ -0,0 +1,46 @@
1
+ {
2
+ "name": "@gisatcz/ptr-be-core",
3
+ "version": "0.0.1-dev.1",
4
+ "description": "Testing the core",
5
+ "main": "dist/index.cjs",
6
+ "module": "dist/index.mjs",
7
+ "types": "dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "import": "./dist/index.mjs",
11
+ "require": "./dist/index.cjs",
12
+ "types": "./dist/index.d.ts"
13
+ }
14
+ },
15
+ "scripts": {
16
+ "build:clean": "rm -rf dist .rollup.cache tsconfig.tsbuildinfo",
17
+ "build:barrels": "barrelsby -c barrelsby.json",
18
+ "build:rollup": "rollup -c",
19
+ "build": "npm run build:clean && npm run build:barrels && npm run build:rollup"
20
+ },
21
+ "author": "",
22
+ "license": "ISC",
23
+ "peerDependencies": {
24
+ "lodash": "^4.17.21",
25
+ "luxon": "^3.6.1",
26
+ "pino": "^9.6.0",
27
+ "pino-pretty": "^13.0.0"
28
+ },
29
+ "devDependencies": {
30
+ "@rollup/plugin-commonjs": "^28.0.3",
31
+ "@rollup/plugin-json": "^6.1.0",
32
+ "@rollup/plugin-node-resolve": "^16.0.1",
33
+ "@rollup/plugin-typescript": "^12.1.2",
34
+ "@types/lodash": "^4.17.16",
35
+ "@types/luxon": "^3.6.2",
36
+ "@types/node": "^22.15.12",
37
+ "barrelsby": "^2.8.1",
38
+ "rollup": "^4.40.2",
39
+ "ts-node": "^10.9.2",
40
+ "tsc-alias": "^1.8.16",
41
+ "tsconfig-paths": "^4.2.0",
42
+ "tslib": "^2.8.1",
43
+ "tsx": "^4.19.4",
44
+ "typescript": "^5.8.3"
45
+ }
46
+ }
@@ -0,0 +1,30 @@
1
+ import json from '@rollup/plugin-json';
2
+ import resolve from '@rollup/plugin-node-resolve';
3
+ import commonjs from '@rollup/plugin-commonjs';
4
+ import typescript from '@rollup/plugin-typescript';
5
+ import { createRequire } from 'module';
6
+
7
+ const require = createRequire(import.meta.url); // Creates a require function
8
+ const pkg = require('./package.json'); // Loads package.json for configuration
9
+ const extensions = ['.js', '.jsx', '.ts', '.tsx'];
10
+
11
+ export default [
12
+ {
13
+ input: 'index.ts',
14
+ output: [
15
+ {
16
+ file: pkg.main,
17
+ format: 'cjs',
18
+ sourcemap: true,
19
+ },
20
+ {
21
+ file: pkg.module,
22
+ format: 'es',
23
+ sourcemap: true,
24
+ }
25
+ ],
26
+ plugins: [json(), resolve({ extensions }), commonjs(), typescript({
27
+ tsconfig: './tsconfig.json',
28
+ })]
29
+ }
30
+ ];
@@ -0,0 +1,104 @@
1
+ import { sortBy } from "lodash"
2
+
3
+ /**
4
+ * Check if the value in included in enum posibilities.
5
+ * @param value Value we need to check
6
+ * @param enumEntity Enum type we check againts the value
7
+ * @returns Is the value in this enum?
8
+ */
9
+ export const isInEnum = (value: any, enumEntity: any) => {
10
+ const allEnumValues = Object.values(enumEntity) as string[]
11
+ return allEnumValues.includes(value)
12
+ }
13
+
14
+ /**
15
+ * Sort array of string elements
16
+ * @param rawArray Raw unsorted array of elements
17
+ * @returns Sorted string array
18
+ */
19
+ export const sortStringArray = (rawArray: string[]) => sortBy(rawArray)
20
+
21
+ /**
22
+ * Remove all duplicity string items from an array
23
+ * @param arr Original array with duplicities
24
+ * @returns Array of original values
25
+ */
26
+ export const removeDuplicitiesFromArray = (arr: any[]) => [...new Set(arr)]
27
+
28
+ /**
29
+ * Check if the string value is not ` "" `
30
+ * @param value Value to check
31
+ * @returns Boolean result about the truth
32
+ */
33
+ export const notEmptyString = (value: string) => value !== ""
34
+
35
+
36
+ /**
37
+ * Return enum values as array of string
38
+ * @param enumType Type of the enum from code
39
+ * @param separator Optional - separator character
40
+ * @returns Array of enum possible values
41
+ */
42
+ export const enumValuesToString = (enumType: any, separator = ", ") => Object.values(enumType).join(separator)
43
+
44
+ /**
45
+ * Return enum values as array of string
46
+ * @param enumTypes Combination of enum types
47
+ * @param separator Optional - separator character
48
+ * @returns Array of enum possible values
49
+ */
50
+ export const enumCombineValuesToString = (enumTypes: any[], separator = ", ") => enumTypes.map(enumType => enumValuesToString(enumType, separator)).join(separator)
51
+
52
+ /**
53
+ * Return all enum values as array
54
+ * @param enumType What array we want to work with
55
+ * @returns Array of enum values
56
+ */
57
+ export const enumValuesToArray = (enumType: any) => Object.values(enumType) as string[]
58
+
59
+ /**
60
+ * Return random number (integer) between two values
61
+ * @param min
62
+ * @param max
63
+ * @returns
64
+ */
65
+ export const randomNumberBetween = (min: number, max: number) => {
66
+ const minAr = Math.ceil(min)
67
+ const maxAr = Math.floor(max)
68
+ return Math.floor(Math.random()*(maxAr - minAr + 1) + min)
69
+ }
70
+
71
+ /**
72
+ * Recursively flattens a nested object. The keys of the resulting object
73
+ * will be the paths to the original values in the nested object, joined by dots.
74
+ *
75
+ * @param obj - The object to flatten.
76
+ * @param prefix - The prefix to use for the keys in the flattened object. Defaults to an empty string.
77
+ * @returns A new object with flattened keys.
78
+ *
79
+ * @example
80
+ * ```typescript
81
+ * const nestedObj = {
82
+ * a: {
83
+ * b: {
84
+ * c: 1
85
+ * }
86
+ * },
87
+ * d: 2
88
+ * };
89
+ * const flatObj = flattenObject(nestedObj);
90
+ * console.log(flatObj);
91
+ * // Output: { 'a.b.c': 1, 'a.b.d': 2 }
92
+ * ```
93
+ */
94
+ export const flattenObject = (obj: any, prefix = ''): Record<string, any> => {
95
+ return Object.keys(obj).reduce((acc: Record<string, any>, key: string) => {
96
+ const propName = prefix ? `${prefix}.${key}` : key
97
+ if (typeof obj[key] === 'object' && obj[key] !== null && !Array.isArray(obj[key])) {
98
+ Object.assign(acc, flattenObject(obj[key], propName))
99
+ } else {
100
+ acc[propName] = obj[key]
101
+ }
102
+ return acc
103
+ }, {})
104
+ }
@@ -0,0 +1,11 @@
1
+ type Nullable<T> = T | null
2
+ type Unsure<T> = T | undefined
3
+ type Nullish<T> = T | undefined | null
4
+ type UsurePromise<T> = Unsure<Promise<T>>
5
+
6
+ export {
7
+ Nullable,
8
+ Nullish,
9
+ Unsure,
10
+ UsurePromise
11
+ }
@@ -0,0 +1,58 @@
1
+ // logger.ts
2
+ import pino, { Logger } from 'pino'
3
+ import pretty from 'pino-pretty'
4
+
5
+ /**
6
+ * @typedef {Object} AppLogOptions
7
+ * @property {string} label - The label for the log entry.
8
+ * @property {string|number|boolean} [key] - Any extra fields.
9
+ */
10
+ export type AppLogOptions = {
11
+ label: string
12
+ [key: string]: string|number|boolean
13
+ }
14
+
15
+ const DEFAULT_LOG_OPTIONS: AppLogOptions = {
16
+ label: 'App'
17
+ }
18
+
19
+ // create the pretty‐printing stream once
20
+ const prettyStream = pretty({
21
+ colorize: true,
22
+ levelFirst: true,
23
+ translateTime: 'yyyy-mm-dd HH:MM:ss'
24
+ })
25
+
26
+ // create your logger once and for all
27
+ const baseLogger: Logger = pino({}, prettyStream)
28
+
29
+ export class AppLogger {
30
+ static info(
31
+ message: string,
32
+ options: AppLogOptions = DEFAULT_LOG_OPTIONS,
33
+ ) {
34
+ baseLogger.info({ ...options, message })
35
+ }
36
+
37
+ static warn(
38
+ message: string,
39
+ options: AppLogOptions = DEFAULT_LOG_OPTIONS,
40
+ ) {
41
+ baseLogger.warn({ ...options, message })
42
+ }
43
+
44
+ static error(
45
+ message: string,
46
+ options: AppLogOptions = DEFAULT_LOG_OPTIONS,
47
+ ) {
48
+ baseLogger.error({ ...options, message })
49
+ }
50
+
51
+ static appStart(
52
+ host: string,
53
+ port: number,
54
+ options: AppLogOptions = DEFAULT_LOG_OPTIONS,
55
+ ) {
56
+ AppLogger.info(`Application started on ${host}:${port}`, options)
57
+ }
58
+ }
@@ -0,0 +1,43 @@
1
+ # Panther Models and Logic
2
+ Panther models are based on graph data structure. Graph structure is flat and very flexible.
3
+
4
+ ## What are Graphs
5
+ Graph can be visualiset as dots connected by lines.
6
+
7
+ Graphs have two parts:
8
+ - node (dot)
9
+ - edge (line)
10
+
11
+ Nodes are connected by Edges into a graph.
12
+
13
+ ## Node Structure
14
+ Node has two main parts:
15
+ - Label(s)
16
+ - Properties
17
+
18
+ ### Labels
19
+ Label is one or more Tags that define a "category" saing "What this Node is".
20
+ Examples are Place, Period, Datasource etc.
21
+
22
+ Combination of multiple nodes can be used as multiple-level labeling. Like `[Datasource, WMS]` is combination of two labels for single node.
23
+
24
+ ### Properties
25
+ Can be anything inside the node. Can be `key`, `name` or any general property we need.
26
+
27
+ ## Edge Structure
28
+ Edge is connection betwee two nodes. Can be directed (from-to).
29
+
30
+ Same as Nodes, Edge also can have:
31
+ - Label(s)
32
+ - Properties
33
+
34
+ Works the same as in the node case.
35
+
36
+ Example of Edge Labels: `IS_RELATED`, `WAITING_FOR`, `CONTAINS`
37
+ Example of Edge properties: `expiration`, `length`, `priority`, `created`
38
+
39
+ ## Resources
40
+ Please check resorces for visual explanation and many other examples.
41
+
42
+ - https://neo4j.com/docs/getting-started/graph-database/
43
+ - https://www.mongodb.com/resources/basics/databases/mongodb-graph-database
@@ -0,0 +1,41 @@
1
+ /**
2
+ * What types of graph nodes we use in metadata model
3
+ */
4
+ export enum UsedNodeLabels {
5
+ Application = "application", // Application node (the root of the FE app)
6
+ Datasource = "datasource", // Datasource node for data including GIS information
7
+ Place = "place", // Place node for geographical information
8
+ Period = "period", // Period node for time information
9
+ AreaTree = "areaTree", // Area tree node for administrative division
10
+ AreaTreeLevel = "areaTreeLevel", // Area tree level node for administrative division
11
+ Layer = "layer", // Layer node for map layer (layer have a style and a datasource)
12
+ Style = "style", // Style node for map layer or a feature
13
+ Feature = "feature" // Feature node for map layer
14
+ }
15
+
16
+ /**
17
+ * What datasources we use in the system
18
+ */
19
+ export enum UsedDatasourceLabels {
20
+ Attribute = "attribute", // Column(s) with attribute values
21
+ Geojson = "geojson", // Geojson for web map
22
+ WMS = "wms", // WMS online source
23
+ COG = "cogBitmap", // COG online source
24
+ MVT = "mvt", // MVT (Mapbox Vector Tiles) source
25
+ XYZ = "xyz", // XYZ tile source
26
+ CSV = "csv", // CSV data source
27
+ GeoTIFF = "geotiff", // GeoTIFF raster data
28
+ Shapefile = "shapefile", // ESRI Shapefile format
29
+ PostGIS = "postgis", // PostGIS database source
30
+ WMTS = "wmts", // Web Map Tile Service
31
+ WFS = "wfs", // Web Feature Service
32
+ GeoPackage = "geopackage" // OGC GeoPackage format
33
+ }
34
+
35
+ /**
36
+ * What types of edges we use in metadata model
37
+ */
38
+ export enum UsedEdgeLabels {
39
+ RelatedTo = "RELATED", // Generic edge for any relation
40
+ Has = "HAS", // Edge for ownership relation
41
+ }
@@ -0,0 +1,20 @@
1
+ import { Nullable } from "../coding/code.types"
2
+ import { UsedEdgeLabels } from "./enums.panther"
3
+
4
+ /**
5
+ * Tuple for relation between two graph nodes
6
+ * It is point to point definition of graph edge
7
+ */
8
+ export type GraphRelation = [string, string]
9
+
10
+
11
+ /**
12
+ * Edge of the graph model.
13
+ * It connects two graph nodes and have some properties.
14
+ * Have "key" witch is composed from node keys.
15
+ */
16
+ export interface GraphEdge{
17
+ labels: string[] | UsedEdgeLabels[],
18
+ edgeNodes: GraphRelation
19
+ properties: Nullable<object>
20
+ }
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Entity that has relevant time interval.
3
+ * Example: Period is connected to some time range.
4
+ */
5
+ export interface HasInterval {
6
+ validUtcIntervalIso: string,
7
+ validFrom: number,
8
+ validTo: number
9
+ }
10
+
11
+ /**
12
+ * Entity with custom configuration
13
+ */
14
+ export interface HasConfiguration {
15
+ configuration: string // JSON string
16
+ }
17
+
18
+ /**
19
+ * Place node - somewhere in the world
20
+ */
21
+ export interface HasGeometry {
22
+ geometry: any,
23
+ bbox: any,
24
+ }
25
+
26
+ /**
27
+ * Place node - somewhere in the world
28
+ */
29
+ export interface HasLevels {
30
+ level: number,
31
+ }