@gisatcz/ptr-be-core 0.0.1-dev.7 → 0.0.1-dev.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/globals/arrows/models.arrows.d.ts +2 -1
- package/dist/globals/coding/code.dates.d.ts +36 -0
- package/dist/globals/coding/formats.csv.d.ts +14 -0
- package/dist/globals/panther/models.edges.d.ts +1 -1
- package/dist/globals/panther/models.edges.properties.d.ts +7 -0
- package/dist/globals/panther/models.nodes.d.ts +27 -3
- package/dist/globals/panther/utils.panther.d.ts +77 -0
- package/dist/index.browser.d.ts +6 -4
- package/dist/index.browser.js +194 -1
- package/dist/index.browser.js.map +1 -1
- package/dist/index.node.cjs +739 -23
- package/dist/index.node.cjs.map +1 -1
- package/dist/index.node.d.ts +4 -0
- package/dist/index.node.js +721 -24
- package/dist/index.node.js.map +1 -1
- package/dist/node/api/parse.arrows.json.d.ts +13 -0
- package/dist/node/api/parse.changeNodes.d.ts +13 -0
- package/dist/node/api/parse.changesEdges.d.ts +8 -0
- package/dist/node/api/validations.shared.d.ts +28 -0
- package/package.json +3 -1
- package/dist/globals/panther/models.groups.d.ts +0 -21
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { UsedDatasourceLabels, UsedEdgeLabels, UsedNodeLabels } from "../panther/enums.panther";
|
|
2
|
-
import { FullEdgeProperties
|
|
2
|
+
import { FullEdgeProperties } from "../panther/models.edges.properties";
|
|
3
|
+
import { FullPantherEntity } from "../panther/models.nodes";
|
|
3
4
|
/**
|
|
4
5
|
* Represents a node in the Arrows diagram/model.
|
|
5
6
|
*
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Return epoch timestamp
|
|
3
|
+
* @param regime Set if you want milisecond format or second format
|
|
4
|
+
* @returns
|
|
5
|
+
*/
|
|
6
|
+
export declare const nowTimestamp: (regime?: "milisecond" | "second") => number;
|
|
7
|
+
/**
|
|
8
|
+
* Convert epoch time value into ISO format
|
|
9
|
+
* @param epochValue Epoch value of the timestamp
|
|
10
|
+
* @returns ISO format of the date
|
|
11
|
+
*/
|
|
12
|
+
export declare const epochToIsoFormat: (epochValue: number) => string;
|
|
13
|
+
/**
|
|
14
|
+
* Return epoch timestamp
|
|
15
|
+
* @param regime Set if you want milisecond format or second format
|
|
16
|
+
* @returns
|
|
17
|
+
*/
|
|
18
|
+
export declare const nowTimestampIso: () => string;
|
|
19
|
+
/**
|
|
20
|
+
* Check if input date is valid for ISO format
|
|
21
|
+
* @param dateToCheck
|
|
22
|
+
* @returns
|
|
23
|
+
*/
|
|
24
|
+
export declare const hasIsoFormat: (dateToCheck: string) => boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Convert date in ISO formtat to milisecond timestamp
|
|
27
|
+
* @param isoDate Date in ISO 8601 format
|
|
28
|
+
* @returns Timestamp representing the date in miliseconds
|
|
29
|
+
*/
|
|
30
|
+
export declare const isoDateToTimestamp: (isoDate: string) => number;
|
|
31
|
+
/**
|
|
32
|
+
* Format ISO 8601 interval to from-to values
|
|
33
|
+
* @param interval Defined inteval in ISO format (from/to) of the UTC
|
|
34
|
+
* @returns Tuple - from timestamp and to timestamp
|
|
35
|
+
*/
|
|
36
|
+
export declare const isoIntervalToTimestamps: (interval: string) => [number, number];
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parses a single line of CSV-formatted strings into an array of trimmed string values.
|
|
3
|
+
*
|
|
4
|
+
* @param csvStingsLine - A string representing a single line of comma-separated values.
|
|
5
|
+
* @returns An array of strings, each representing a trimmed value from the CSV line.
|
|
6
|
+
*/
|
|
7
|
+
export declare const csvParseStrings: (csvStingsLine: string) => string[];
|
|
8
|
+
/**
|
|
9
|
+
* Parses a comma-separated string of numbers into an array of numbers.
|
|
10
|
+
*
|
|
11
|
+
* @param csvNumbersLine - A string containing numbers separated by commas (e.g., "1, 2, 3.5").
|
|
12
|
+
* @returns An array of numbers parsed from the input string.
|
|
13
|
+
*/
|
|
14
|
+
export declare const csvParseNumbers: (csvNumbersLine: string) => number[];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Nullable } from "../coding/code.types.js";
|
|
2
2
|
import { UsedEdgeLabels } from "./enums.panther.js";
|
|
3
|
-
import { FullEdgeProperties } from "./models.
|
|
3
|
+
import { FullEdgeProperties } from "./models.edges.properties.js";
|
|
4
4
|
/**
|
|
5
5
|
* Tuple for relation between two graph nodes
|
|
6
6
|
* It is point to point definition of graph edge
|
|
@@ -33,3 +33,10 @@ export interface EdgeForPostgisLocationProperties extends EdgePropertiesBasic {
|
|
|
33
33
|
featureIdColumn: string | null;
|
|
34
34
|
periodIso: string | null;
|
|
35
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 FullEdgeProperties = EdgeForPostgisLocationProperties | EdgePropertiesBasic;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { HasGeometry, HasInterval, HasLevels, HasConfiguration, HasUnits } from "./models.nodes.properties.general.js";
|
|
2
2
|
import { UsedNodeLabels, UsedDatasourceLabels } from "./enums.panther.js";
|
|
3
|
-
import { HasColor } from "./models.nodes.properties.datasources.js";
|
|
3
|
+
import { HasBands, HasColor, HasDocumentId, HasSpecificName, HasTimeseries, HasUrl } from "./models.nodes.properties.datasources.js";
|
|
4
4
|
import { Nullable } from "../coding/code.types.js";
|
|
5
|
-
import { FullDatasourceProperties } from "./models.groups.js";
|
|
6
5
|
/**
|
|
7
6
|
* General graph node - same for all metadatata entities
|
|
8
7
|
*/
|
|
@@ -32,7 +31,7 @@ export interface AreaTreeLevel extends PantherEntity, HasLevels {
|
|
|
32
31
|
/**
|
|
33
32
|
* Datasource with source configuration
|
|
34
33
|
*/
|
|
35
|
-
export interface Datasource extends PantherEntity, Partial<
|
|
34
|
+
export interface Datasource extends PantherEntity, Partial<HasConfiguration & HasUrl & HasBands & HasTimeseries & HasSpecificName & HasColor & HasDocumentId> {
|
|
36
35
|
}
|
|
37
36
|
/**
|
|
38
37
|
* Application node - main entity in metadata model
|
|
@@ -45,3 +44,28 @@ export interface ApplicationNode extends PantherEntity, Partial<HasConfiguration
|
|
|
45
44
|
*/
|
|
46
45
|
export interface Attribute extends PantherEntity, Partial<HasColor & HasUnits> {
|
|
47
46
|
}
|
|
47
|
+
/**
|
|
48
|
+
* Represents a comprehensive Panther entity composed of the required core
|
|
49
|
+
* PantherEntity shape plus a collection of optional feature mixins.
|
|
50
|
+
*
|
|
51
|
+
* The base PantherEntity provides the mandatory identity and core fields.
|
|
52
|
+
* The additional capabilities are included via Partial<...>, so they may be
|
|
53
|
+
* absent at runtime:
|
|
54
|
+
* - HasGeometry: spatial geometry (e.g. GeoJSON) for spatial features.
|
|
55
|
+
* - HasInterval: temporal interval or validity range for the entity.
|
|
56
|
+
* - HasLevels: hierarchical or zoom/detail levels.
|
|
57
|
+
* - HasConfiguration: rendering or domain-specific configuration data.
|
|
58
|
+
* - HasUrl: an external URL or resource locator.
|
|
59
|
+
* - HasBands: spectral band information (useful for raster/multiband data).
|
|
60
|
+
* - HasSpecificName: alternate or more specific naming fields.
|
|
61
|
+
* - HasColor: color or styling metadata.
|
|
62
|
+
* - HasUnits: measurement units for numeric values.
|
|
63
|
+
* - HasDocumentId: backend/document database identifier.
|
|
64
|
+
* - HasTimeseries: timeseries metadata or embedded series data.
|
|
65
|
+
*
|
|
66
|
+
* Use this interface when you need a single type that can represent a fully
|
|
67
|
+
* featured Panther entity. Consumers should always check for the presence of
|
|
68
|
+
* optional properties before accessing them.
|
|
69
|
+
*/
|
|
70
|
+
export interface FullPantherEntity extends PantherEntity, Partial<HasGeometry & HasInterval & HasLevels & HasConfiguration & HasUrl & HasBands & HasSpecificName & HasColor & HasUnits & HasDocumentId & HasTimeseries> {
|
|
71
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { UsedDatasourceLabels, UsedEdgeLabels, UsedNodeLabels } from "./enums.panther";
|
|
2
|
+
import { GraphEdge } from "./models.edges";
|
|
3
|
+
import { FullPantherEntity } from "./models.nodes";
|
|
4
|
+
/**
|
|
5
|
+
* Finds the first node in the provided list that contains the specified label.
|
|
6
|
+
*
|
|
7
|
+
* Searches the given array of FullPantherEntity objects and returns the first entity
|
|
8
|
+
* whose `labels` array includes the provided label.
|
|
9
|
+
*
|
|
10
|
+
* @param nodes - Array of FullPantherEntity objects to search through.
|
|
11
|
+
* @param label - Label to match; may be a UsedDatasourceLabels or UsedNodeLabels.
|
|
12
|
+
* @returns The first FullPantherEntity whose `labels` includes `label`, or `undefined`
|
|
13
|
+
* if no such entity is found.
|
|
14
|
+
*
|
|
15
|
+
* @remarks
|
|
16
|
+
* - The search stops at the first match (uses `Array.prototype.find`).
|
|
17
|
+
* - Label comparison is exact (uses `Array.prototype.includes`), so it is case-sensitive
|
|
18
|
+
* and requires the same string instance/value.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* const result = findNodeByLabel(nodes, 'datasource-main');
|
|
22
|
+
* if (result) {
|
|
23
|
+
* // found a node that has the 'datasource-main' label
|
|
24
|
+
* }
|
|
25
|
+
*/
|
|
26
|
+
export declare const findNodeByLabel: (nodes: FullPantherEntity[], label: UsedDatasourceLabels | UsedNodeLabels) => FullPantherEntity | undefined;
|
|
27
|
+
/**
|
|
28
|
+
* Filters an array of FullPantherEntity objects, returning only those that contain the specified label.
|
|
29
|
+
*
|
|
30
|
+
* The function performs a shallow, non-mutating filter: it returns a new array and does not modify the input.
|
|
31
|
+
* Matching is done using Array.prototype.includes on each entity's `labels` array (strict equality).
|
|
32
|
+
*
|
|
33
|
+
* @param nodes - The array of entities to filter.
|
|
34
|
+
* @param label - The label to match; can be a UsedDatasourceLabels or UsedNodeLabels value.
|
|
35
|
+
* @returns A new array containing only the entities whose `labels` array includes the provided label.
|
|
36
|
+
*
|
|
37
|
+
* @remarks
|
|
38
|
+
* Time complexity is O(n * m) where n is the number of entities and m is the average number of labels per entity.
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```ts
|
|
42
|
+
* const matched = filterNodeByLabel(entities, 'MY_LABEL');
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
export declare const filterNodeByLabel: (nodes: FullPantherEntity[], label: UsedDatasourceLabels | UsedNodeLabels) => FullPantherEntity[];
|
|
46
|
+
/**
|
|
47
|
+
* Finds the first edge in the provided array whose label strictly equals the given label.
|
|
48
|
+
*
|
|
49
|
+
* @param edges - Array of GraphEdge objects to search.
|
|
50
|
+
* @param label - The UsedEdgeLabels value to match against each edge's `label` property.
|
|
51
|
+
* @returns The first matching GraphEdge if found; otherwise `undefined`.
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
* const edge = findEdgeByLabel(edges, 'dependency');
|
|
55
|
+
* if (edge) {
|
|
56
|
+
* // handle found edge
|
|
57
|
+
* }
|
|
58
|
+
*/
|
|
59
|
+
export declare const findEdgeByLabel: (edges: GraphEdge[], label: UsedEdgeLabels) => GraphEdge | undefined;
|
|
60
|
+
/**
|
|
61
|
+
* Filters a list of GraphEdge objects by a specific edge label.
|
|
62
|
+
*
|
|
63
|
+
* Returns a new array containing only those edges whose `label` property
|
|
64
|
+
* strictly equals the provided `label` argument. The original `edges`
|
|
65
|
+
* array is not mutated.
|
|
66
|
+
*
|
|
67
|
+
* @param edges - Array of GraphEdge objects to filter.
|
|
68
|
+
* @param label - The label to match; comparison is performed using strict (`===`) equality.
|
|
69
|
+
* @returns A new array of GraphEdge objects whose `label` matches the provided label. Returns an empty array if no edges match.
|
|
70
|
+
*
|
|
71
|
+
* @remarks
|
|
72
|
+
* Time complexity: O(n), where n is the number of edges.
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
* // const result = filterEdgeByLabel(edges, 'CONNECTS');
|
|
76
|
+
*/
|
|
77
|
+
export declare const filterEdgeByLabel: (edges: GraphEdge[], label: UsedEdgeLabels) => GraphEdge[];
|
package/dist/index.browser.d.ts
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
export { enumCombineValuesToString, enumValuesToArray, enumValuesToString, flattenObject, isInEnum, notEmptyString, randomNumberBetween, removeDuplicitiesFromArray, sortStringArray } from "./globals/coding/code.formating.js";
|
|
2
|
+
export { isoIntervalToTimestamps, nowTimestamp, nowTimestampIso, epochToIsoFormat, hasIsoFormat, isoDateToTimestamp } from "./globals/coding/code.dates.js";
|
|
3
|
+
export { csvParseNumbers, csvParseStrings } from "./globals/coding/formats.csv.js";
|
|
4
|
+
export { filterNodeByLabel, findEdgeByLabel, filterEdgeByLabel, findNodeByLabel } from "./globals/panther/utils.panther.js";
|
|
2
5
|
export { type Nullable, type Nullish, type Unsure, type UsurePromise } from "./globals/coding/code.types.js";
|
|
3
6
|
export { UsedDatasourceLabels, UsedEdgeLabels, UsedNodeLabels, UsedTimeseriesSteps } from "./globals/panther/enums.panther.js";
|
|
4
|
-
export { type EdgeForPostgisLocationProperties, type EdgePropertiesBasic } from "./globals/panther/models.edges.properties.js";
|
|
7
|
+
export { type EdgeForPostgisLocationProperties, type EdgePropertiesBasic, type FullEdgeProperties } from "./globals/panther/models.edges.properties.js";
|
|
5
8
|
export { type GraphEdge, type GraphRelation } from "./globals/panther/models.edges.js";
|
|
6
9
|
export { type HasEdges, type HasNeighbours, type NodeWithNeighbours } from "./globals/panther/models.nodes.structure.js";
|
|
7
10
|
export { type HasConfiguration, type HasGeometry, type HasInterval, type HasLevels, type HasUnits } from "./globals/panther/models.nodes.properties.general.js";
|
|
8
|
-
export { type HasBands, type HasDocumentId, type HasTimeseries, type HasUrl, type HasSpecificName, type HasColor } from "./globals/panther/models.nodes.properties.datasources.js";
|
|
9
|
-
export { type Place, type Period, type AreaTreeLevel, type Datasource, type ApplicationNode, type Attribute, type PantherEntity } from "./globals/panther/models.nodes.js";
|
|
10
|
-
export { type FullDatasourceProperties, type FullPantherEntity, type FullEdgeProperties } from "./globals/panther/models.groups.js";
|
|
11
|
+
export { type HasBands, type HasDocumentId, type HasTimeseries, type HasUrl, type HasSpecificName, type HasColor, } from "./globals/panther/models.nodes.properties.datasources.js";
|
|
12
|
+
export { type Place, type Period, type AreaTreeLevel, type Datasource, type ApplicationNode, type Attribute, type PantherEntity, type FullPantherEntity } from "./globals/panther/models.nodes.js";
|
|
11
13
|
export { type ArrowsNode, type ArrowsEdge } from "./globals/arrows/models.arrows.js";
|
package/dist/index.browser.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { DateTime } from 'luxon';
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* Check if the value in included in enum posibilities.
|
|
3
5
|
* @param value Value we need to check
|
|
@@ -93,6 +95,197 @@ const flattenObject = (obj, prefix = '') => {
|
|
|
93
95
|
}, {});
|
|
94
96
|
};
|
|
95
97
|
|
|
98
|
+
/**
|
|
99
|
+
* Extract message from exception error (try-catch)
|
|
100
|
+
* @param error error from catch block as any
|
|
101
|
+
* @returns
|
|
102
|
+
*/
|
|
103
|
+
/**
|
|
104
|
+
* We miss a API parameter needed to process action
|
|
105
|
+
*/
|
|
106
|
+
class InvalidRequestError extends Error {
|
|
107
|
+
constructor(message) {
|
|
108
|
+
super(`Invalid Request: ${message}`);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Return epoch timestamp
|
|
114
|
+
* @param regime Set if you want milisecond format or second format
|
|
115
|
+
* @returns
|
|
116
|
+
*/
|
|
117
|
+
const nowTimestamp = (regime = "milisecond") => {
|
|
118
|
+
const timestamp = DateTime.now().toMillis();
|
|
119
|
+
return regime === "second" ? Math.round((timestamp / 1000)) : timestamp;
|
|
120
|
+
};
|
|
121
|
+
/**
|
|
122
|
+
* Convert epoch time value into ISO format
|
|
123
|
+
* @param epochValue Epoch value of the timestamp
|
|
124
|
+
* @returns ISO format of the date
|
|
125
|
+
*/
|
|
126
|
+
const epochToIsoFormat = (epochValue) => DateTime.fromMillis(epochValue).toISO();
|
|
127
|
+
/**
|
|
128
|
+
* Return epoch timestamp
|
|
129
|
+
* @param regime Set if you want milisecond format or second format
|
|
130
|
+
* @returns
|
|
131
|
+
*/
|
|
132
|
+
const nowTimestampIso = () => {
|
|
133
|
+
const timestamp = DateTime.now().toISO();
|
|
134
|
+
return timestamp;
|
|
135
|
+
};
|
|
136
|
+
/**
|
|
137
|
+
* Check if input date is valid for ISO format
|
|
138
|
+
* @param dateToCheck
|
|
139
|
+
* @returns
|
|
140
|
+
*/
|
|
141
|
+
const hasIsoFormat = (dateToCheck) => {
|
|
142
|
+
try {
|
|
143
|
+
const toDate = new Date(Date.parse(dateToCheck));
|
|
144
|
+
const isoCheck = toDate.toISOString().includes(dateToCheck);
|
|
145
|
+
return isoCheck;
|
|
146
|
+
}
|
|
147
|
+
catch {
|
|
148
|
+
return false;
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
/**
|
|
152
|
+
* Convert date in ISO formtat to milisecond timestamp
|
|
153
|
+
* @param isoDate Date in ISO 8601 format
|
|
154
|
+
* @returns Timestamp representing the date in miliseconds
|
|
155
|
+
*/
|
|
156
|
+
const isoDateToTimestamp = (isoDate) => DateTime.fromISO(isoDate).toMillis();
|
|
157
|
+
/**
|
|
158
|
+
* Format ISO 8601 interval to from-to values
|
|
159
|
+
* @param interval Defined inteval in ISO format (from/to) of the UTC
|
|
160
|
+
* @returns Tuple - from timestamp and to timestamp
|
|
161
|
+
*/
|
|
162
|
+
const isoIntervalToTimestamps = (interval) => {
|
|
163
|
+
// Split the interval into two parts
|
|
164
|
+
const intervals = interval.split("/");
|
|
165
|
+
// interval as a single year has just one part
|
|
166
|
+
if (intervals.length == 1) {
|
|
167
|
+
const newIso = `${interval}-01-01/${interval}-12-31`;
|
|
168
|
+
return isoIntervalToTimestamps(newIso);
|
|
169
|
+
}
|
|
170
|
+
// interval with two parts or less than one
|
|
171
|
+
else if (intervals.length > 2 || intervals.length < 1)
|
|
172
|
+
throw new InvalidRequestError("Interval can have only two parameters");
|
|
173
|
+
// valid interval with two parts
|
|
174
|
+
else {
|
|
175
|
+
if (!intervals.every(interval => hasIsoFormat(interval)))
|
|
176
|
+
throw new InvalidRequestError("Parameter utcIntervalIso is not ISO 8601 time interval (date01/date02) or year");
|
|
177
|
+
const [int1, int2] = intervals.map(intervalIso => {
|
|
178
|
+
const cleared = intervalIso.replace(" ", "");
|
|
179
|
+
return isoDateToTimestamp(cleared);
|
|
180
|
+
});
|
|
181
|
+
return [int1, int2];
|
|
182
|
+
}
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
// TODO: Cover by tests
|
|
186
|
+
// TODO: mode to ptr-be-core as general CSV methods
|
|
187
|
+
/**
|
|
188
|
+
* Parses a single line of CSV-formatted strings into an array of trimmed string values.
|
|
189
|
+
*
|
|
190
|
+
* @param csvStingsLine - A string representing a single line of comma-separated values.
|
|
191
|
+
* @returns An array of strings, each representing a trimmed value from the CSV line.
|
|
192
|
+
*/
|
|
193
|
+
const csvParseStrings = (csvStingsLine) => {
|
|
194
|
+
return csvStingsLine.split(",").map((value) => value.trim());
|
|
195
|
+
};
|
|
196
|
+
/**
|
|
197
|
+
* Parses a comma-separated string of numbers into an array of numbers.
|
|
198
|
+
*
|
|
199
|
+
* @param csvNumbersLine - A string containing numbers separated by commas (e.g., "1, 2, 3.5").
|
|
200
|
+
* @returns An array of numbers parsed from the input string.
|
|
201
|
+
*/
|
|
202
|
+
const csvParseNumbers = (csvNumbersLine) => {
|
|
203
|
+
return csvNumbersLine.split(",").map((value) => parseFloat(value.trim()));
|
|
204
|
+
};
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* Finds the first node in the provided list that contains the specified label.
|
|
208
|
+
*
|
|
209
|
+
* Searches the given array of FullPantherEntity objects and returns the first entity
|
|
210
|
+
* whose `labels` array includes the provided label.
|
|
211
|
+
*
|
|
212
|
+
* @param nodes - Array of FullPantherEntity objects to search through.
|
|
213
|
+
* @param label - Label to match; may be a UsedDatasourceLabels or UsedNodeLabels.
|
|
214
|
+
* @returns The first FullPantherEntity whose `labels` includes `label`, or `undefined`
|
|
215
|
+
* if no such entity is found.
|
|
216
|
+
*
|
|
217
|
+
* @remarks
|
|
218
|
+
* - The search stops at the first match (uses `Array.prototype.find`).
|
|
219
|
+
* - Label comparison is exact (uses `Array.prototype.includes`), so it is case-sensitive
|
|
220
|
+
* and requires the same string instance/value.
|
|
221
|
+
*
|
|
222
|
+
* @example
|
|
223
|
+
* const result = findNodeByLabel(nodes, 'datasource-main');
|
|
224
|
+
* if (result) {
|
|
225
|
+
* // found a node that has the 'datasource-main' label
|
|
226
|
+
* }
|
|
227
|
+
*/
|
|
228
|
+
const findNodeByLabel = (nodes, label) => {
|
|
229
|
+
return nodes.find(n => n.labels.includes(label));
|
|
230
|
+
};
|
|
231
|
+
/**
|
|
232
|
+
* Filters an array of FullPantherEntity objects, returning only those that contain the specified label.
|
|
233
|
+
*
|
|
234
|
+
* The function performs a shallow, non-mutating filter: it returns a new array and does not modify the input.
|
|
235
|
+
* Matching is done using Array.prototype.includes on each entity's `labels` array (strict equality).
|
|
236
|
+
*
|
|
237
|
+
* @param nodes - The array of entities to filter.
|
|
238
|
+
* @param label - The label to match; can be a UsedDatasourceLabels or UsedNodeLabels value.
|
|
239
|
+
* @returns A new array containing only the entities whose `labels` array includes the provided label.
|
|
240
|
+
*
|
|
241
|
+
* @remarks
|
|
242
|
+
* Time complexity is O(n * m) where n is the number of entities and m is the average number of labels per entity.
|
|
243
|
+
*
|
|
244
|
+
* @example
|
|
245
|
+
* ```ts
|
|
246
|
+
* const matched = filterNodeByLabel(entities, 'MY_LABEL');
|
|
247
|
+
* ```
|
|
248
|
+
*/
|
|
249
|
+
const filterNodeByLabel = (nodes, label) => {
|
|
250
|
+
return nodes.filter(n => n.labels.includes(label));
|
|
251
|
+
};
|
|
252
|
+
/**
|
|
253
|
+
* Finds the first edge in the provided array whose label strictly equals the given label.
|
|
254
|
+
*
|
|
255
|
+
* @param edges - Array of GraphEdge objects to search.
|
|
256
|
+
* @param label - The UsedEdgeLabels value to match against each edge's `label` property.
|
|
257
|
+
* @returns The first matching GraphEdge if found; otherwise `undefined`.
|
|
258
|
+
*
|
|
259
|
+
* @example
|
|
260
|
+
* const edge = findEdgeByLabel(edges, 'dependency');
|
|
261
|
+
* if (edge) {
|
|
262
|
+
* // handle found edge
|
|
263
|
+
* }
|
|
264
|
+
*/
|
|
265
|
+
const findEdgeByLabel = (edges, label) => {
|
|
266
|
+
return edges.find(e => e.label === label);
|
|
267
|
+
};
|
|
268
|
+
/**
|
|
269
|
+
* Filters a list of GraphEdge objects by a specific edge label.
|
|
270
|
+
*
|
|
271
|
+
* Returns a new array containing only those edges whose `label` property
|
|
272
|
+
* strictly equals the provided `label` argument. The original `edges`
|
|
273
|
+
* array is not mutated.
|
|
274
|
+
*
|
|
275
|
+
* @param edges - Array of GraphEdge objects to filter.
|
|
276
|
+
* @param label - The label to match; comparison is performed using strict (`===`) equality.
|
|
277
|
+
* @returns A new array of GraphEdge objects whose `label` matches the provided label. Returns an empty array if no edges match.
|
|
278
|
+
*
|
|
279
|
+
* @remarks
|
|
280
|
+
* Time complexity: O(n), where n is the number of edges.
|
|
281
|
+
*
|
|
282
|
+
* @example
|
|
283
|
+
* // const result = filterEdgeByLabel(edges, 'CONNECTS');
|
|
284
|
+
*/
|
|
285
|
+
const filterEdgeByLabel = (edges, label) => {
|
|
286
|
+
return edges.filter(e => e.label === label);
|
|
287
|
+
};
|
|
288
|
+
|
|
96
289
|
/**
|
|
97
290
|
* What types of graph nodes we use in metadata model
|
|
98
291
|
*/
|
|
@@ -151,5 +344,5 @@ var UsedTimeseriesSteps;
|
|
|
151
344
|
UsedTimeseriesSteps["Day"] = "day";
|
|
152
345
|
})(UsedTimeseriesSteps || (UsedTimeseriesSteps = {}));
|
|
153
346
|
|
|
154
|
-
export { UsedDatasourceLabels, UsedEdgeLabels, UsedNodeLabels, UsedTimeseriesSteps, enumCombineValuesToString, enumValuesToArray, enumValuesToString, flattenObject, isInEnum, notEmptyString, randomNumberBetween, removeDuplicitiesFromArray, sortStringArray };
|
|
347
|
+
export { UsedDatasourceLabels, UsedEdgeLabels, UsedNodeLabels, UsedTimeseriesSteps, csvParseNumbers, csvParseStrings, enumCombineValuesToString, enumValuesToArray, enumValuesToString, epochToIsoFormat, filterEdgeByLabel, filterNodeByLabel, findEdgeByLabel, findNodeByLabel, flattenObject, hasIsoFormat, isInEnum, isoDateToTimestamp, isoIntervalToTimestamps, notEmptyString, nowTimestamp, nowTimestampIso, randomNumberBetween, removeDuplicitiesFromArray, sortStringArray };
|
|
155
348
|
//# sourceMappingURL=index.browser.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.browser.js","sources":["../src/globals/coding/code.formating.ts","../src/globals/panther/enums.panther.ts"],"sourcesContent":["/**\n * Check if the value in included in enum posibilities.\n * @param value Value we need to check\n * @param enumEntity Enum type we check againts the value\n * @returns Is the value in this enum?\n */\nexport const isInEnum = (value: any, enumEntity: any) => {\n const allEnumValues = Object.values(enumEntity) as string[]\n return allEnumValues.includes(value)\n }\n\n/**\n * Sort array of string elements\n * @param rawArray Raw unsorted array of elements\n * @returns Sorted string array\n */\nexport const sortStringArray = (rawArray: string[]) => rawArray.sort()\n\n/**\n * Remove all duplicity string items from an array\n * @param arr Original array with duplicities\n * @returns Array of original values\n */\nexport const removeDuplicitiesFromArray = (arr: any[]) => [...new Set(arr)]\n\n\n/**\n * Check if the string value is not ` \"\" `\n * @param value Value to check\n * @returns Boolean result about the truth\n */\nexport const notEmptyString = (value: string) => value !== \"\"\n\n\n/**\n * Return enum values as array of string\n * @param enumType Type of the enum from code\n * @param separator Optional - separator character\n * @returns Array of enum possible values\n */\nexport const enumValuesToString = (enumType: any, separator = \", \") => Object.values(enumType).join(separator)\n\n/**\n * Return enum values as array of string\n * @param enumTypes Combination of enum types\n * @param separator Optional - separator character\n * @returns Array of enum possible values\n */\nexport const enumCombineValuesToString = (enumTypes: any[], separator = \", \") => enumTypes.map(enumType => enumValuesToString(enumType, separator)).join(separator)\n\n/**\n * Return all enum values as array\n * @param enumType What array we want to work with\n * @returns Array of enum values\n */\nexport const enumValuesToArray = (enumType: any) => Object.values(enumType) as string[]\n\n/**\n * Return random number (integer) between two values\n * @param min \n * @param max \n * @returns \n */\nexport const randomNumberBetween = (min: number, max: number) => {\n const minAr = Math.ceil(min)\n const maxAr = Math.floor(max)\n return Math.floor(Math.random()*(maxAr - minAr + 1) + min)\n}\n\n/**\n * Recursively flattens a nested object. The keys of the resulting object\n * will be the paths to the original values in the nested object, joined by dots.\n *\n * @param obj - The object to flatten.\n * @param prefix - The prefix to use for the keys in the flattened object. Defaults to an empty string.\n * @returns A new object with flattened keys.\n *\n * @example\n * ```typescript\n * const nestedObj = {\n * a: {\n * b: {\n * c: 1\n * }\n * },\n * d: 2\n * };\n * const flatObj = flattenObject(nestedObj);\n * console.log(flatObj);\n * // Output: { 'a.b.c': 1, 'a.b.d': 2 }\n * ```\n */\nexport const flattenObject = (obj: any, prefix = ''): Record<string, any> => {\n return Object.keys(obj).reduce((acc: Record<string, any>, key: string) => {\n const propName = prefix ? `${prefix}.${key}` : key\n if (typeof obj[key] === 'object' && obj[key] !== null && !Array.isArray(obj[key])) {\n Object.assign(acc, flattenObject(obj[key], propName))\n } else {\n acc[propName] = obj[key]\n }\n return acc\n }, {})\n}","/**\n * What types of graph nodes we use in metadata model\n */\nexport enum UsedNodeLabels {\n Application = \"application\", // Application node (the root of the FE app)\n Datasource = \"datasource\", // Datasource node for data including GIS information\n Place = \"place\", // Place node for geographical information\n Period = \"period\", // Period node for time information\n AreaTree = \"areaTree\", // Area tree node for administrative division\n AreaTreeLevel = \"areaTreeLevel\", // Area tree level node for administrative division\n Layer = \"layer\", // Layer node for map layer (layer have a style and a datasource)\n Style = \"style\", // Style node for map layer or a feature\n Feature = \"feature\", // Feature node for map layer,\n Attribute = \"attribute\" // Attribute node for properties of entities, like \"temperature\", \"population\", etc.\n}\n\n/**\n * What datasources we use in the system\n */\nexport enum UsedDatasourceLabels {\n Attribute = \"attributeSource\", // Column(s) with attribute values\n Geojson = \"geojson\", // Geojson for web map\n WMS = \"wms\", // WMS online source\n COG = \"cloudOptimizedGeotiff\", // COG online source\n MVT = \"mvt\", // MVT (Mapbox Vector Tiles) source\n XYZ = \"xyz\", // XYZ tile source\n CSV = \"csv\", // CSV data source\n GeoTIFF = \"geotiff\", // GeoTIFF raster data\n Shapefile = \"shapefile\", // ESRI Shapefile format\n PostGIS = \"postgis\", // PostGIS database source\n WMTS = \"wmts\", // Web Map Tile Service\n WFS = \"wfs\", // Web Feature Service\n GeoPackage = \"geopackage\", // OGC GeoPackage format\n MapStyle = \"mapStyle\", // Map style datasource\n Timeseries = \"timeseries\" // Timeseries datasource (with from-to and step)\n}\n\n/**\n * What types of edges we use in metadata model\n */\nexport enum UsedEdgeLabels {\n RelatedTo = \"RELATED\", // Generic edge for any relation\n Has = \"HAS\", // Edge for ownership relation\n InPostgisLocation = \"IN_POSTGIS_LOCATION\" // Edge to connect datasource with PostGIS location (schema, table, geometry column)\n}\n\n/**\n * What time steps are used in timeseries data\n */\nexport enum UsedTimeseriesSteps{\n Year = \"year\",\n Quarter = \"quarter\",\n Month = \"month\",\n Week = \"week\",\n Day = \"day\"\n}"],"names":[],"mappings":"AAAA;;;;;AAKG;MACU,QAAQ,GAAG,CAAC,KAAU,EAAE,UAAe,KAAI;IACpD,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,KAA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AA;;;;"}
|
|
1
|
+
{"version":3,"file":"index.browser.js","sources":["../src/globals/coding/code.formating.ts","../src/node/api/errors.api.ts","../src/globals/coding/code.dates.ts","../src/globals/coding/formats.csv.ts","../src/globals/panther/utils.panther.ts","../src/globals/panther/enums.panther.ts"],"sourcesContent":["/**\n * Check if the value in included in enum posibilities.\n * @param value Value we need to check\n * @param enumEntity Enum type we check againts the value\n * @returns Is the value in this enum?\n */\nexport const isInEnum = (value: any, enumEntity: any) => {\n const allEnumValues = Object.values(enumEntity) as string[]\n return allEnumValues.includes(value)\n }\n\n/**\n * Sort array of string elements\n * @param rawArray Raw unsorted array of elements\n * @returns Sorted string array\n */\nexport const sortStringArray = (rawArray: string[]) => rawArray.sort()\n\n/**\n * Remove all duplicity string items from an array\n * @param arr Original array with duplicities\n * @returns Array of original values\n */\nexport const removeDuplicitiesFromArray = (arr: any[]) => [...new Set(arr)]\n\n\n/**\n * Check if the string value is not ` \"\" `\n * @param value Value to check\n * @returns Boolean result about the truth\n */\nexport const notEmptyString = (value: string) => value !== \"\"\n\n\n/**\n * Return enum values as array of string\n * @param enumType Type of the enum from code\n * @param separator Optional - separator character\n * @returns Array of enum possible values\n */\nexport const enumValuesToString = (enumType: any, separator = \", \") => Object.values(enumType).join(separator)\n\n/**\n * Return enum values as array of string\n * @param enumTypes Combination of enum types\n * @param separator Optional - separator character\n * @returns Array of enum possible values\n */\nexport const enumCombineValuesToString = (enumTypes: any[], separator = \", \") => enumTypes.map(enumType => enumValuesToString(enumType, separator)).join(separator)\n\n/**\n * Return all enum values as array\n * @param enumType What array we want to work with\n * @returns Array of enum values\n */\nexport const enumValuesToArray = (enumType: any) => Object.values(enumType) as string[]\n\n/**\n * Return random number (integer) between two values\n * @param min \n * @param max \n * @returns \n */\nexport const randomNumberBetween = (min: number, max: number) => {\n const minAr = Math.ceil(min)\n const maxAr = Math.floor(max)\n return Math.floor(Math.random()*(maxAr - minAr + 1) + min)\n}\n\n/**\n * Recursively flattens a nested object. The keys of the resulting object\n * will be the paths to the original values in the nested object, joined by dots.\n *\n * @param obj - The object to flatten.\n * @param prefix - The prefix to use for the keys in the flattened object. Defaults to an empty string.\n * @returns A new object with flattened keys.\n *\n * @example\n * ```typescript\n * const nestedObj = {\n * a: {\n * b: {\n * c: 1\n * }\n * },\n * d: 2\n * };\n * const flatObj = flattenObject(nestedObj);\n * console.log(flatObj);\n * // Output: { 'a.b.c': 1, 'a.b.d': 2 }\n * ```\n */\nexport const flattenObject = (obj: any, prefix = ''): Record<string, any> => {\n return Object.keys(obj).reduce((acc: Record<string, any>, key: string) => {\n const propName = prefix ? `${prefix}.${key}` : key\n if (typeof obj[key] === 'object' && obj[key] !== null && !Array.isArray(obj[key])) {\n Object.assign(acc, flattenObject(obj[key], propName))\n } else {\n acc[propName] = obj[key]\n }\n return acc\n }, {})\n}","/**\n * Extract message from exception error (try-catch)\n * @param error error from catch block as any\n * @returns \n */\n export const messageFromError = (error: any) => error[\"message\"] as string\n\n/**\n * We miss a API parameter needed to process action\n */\nexport class InvalidRequestError extends Error{\n constructor(message: string){\n super(`Invalid Request: ${message}`)\n }\n}\n\n/**\n * Where client has general authorization issue\n */\nexport class AuthorizationError extends Error{\n constructor(){\n super(`Authorization has failed.`)\n }\n}","import { DateTime } from \"luxon\"\nimport { InvalidRequestError } from \"../../node/api/errors.api\"\n\n/**\n * Return epoch timestamp\n * @param regime Set if you want milisecond format or second format\n * @returns \n */\nexport const nowTimestamp = (regime: \"milisecond\" | \"second\" = \"milisecond\"): number => {\n const timestamp = DateTime.now().toMillis()\n return regime === \"second\" ? Math.round((timestamp / 1000)) : timestamp\n}\n\n/**\n * Convert epoch time value into ISO format\n * @param epochValue Epoch value of the timestamp\n * @returns ISO format of the date\n */\nexport const epochToIsoFormat = (epochValue: number) => DateTime.fromMillis(epochValue).toISO() as string\n\n/**\n * Return epoch timestamp\n * @param regime Set if you want milisecond format or second format\n * @returns \n */\nexport const nowTimestampIso = () => {\n const timestamp = DateTime.now().toISO()\n return timestamp as string\n}\n\n/**\n * Check if input date is valid for ISO format\n * @param dateToCheck \n * @returns \n */\n export const hasIsoFormat = (dateToCheck: string) => {\n try{\n const toDate = new Date(Date.parse(dateToCheck))\n const isoCheck = toDate.toISOString().includes(dateToCheck) \n return isoCheck\n }\n catch{\n return false\n }\n}\n\n/**\n * Convert date in ISO formtat to milisecond timestamp\n * @param isoDate Date in ISO 8601 format\n * @returns Timestamp representing the date in miliseconds\n */\nexport const isoDateToTimestamp = (isoDate: string) => DateTime.fromISO(isoDate).toMillis()\n\n/**\n * Format ISO 8601 interval to from-to values\n * @param interval Defined inteval in ISO format (from/to) of the UTC\n * @returns Tuple - from timestamp and to timestamp\n */\nexport const isoIntervalToTimestamps = (interval: string): [number, number] => {\n\n // Split the interval into two parts\n const intervals = interval.split(\"/\")\n\n // interval as a single year has just one part\n if (intervals.length == 1) {\n const newIso = `${interval}-01-01/${interval}-12-31`\n return isoIntervalToTimestamps(newIso)\n }\n\n // interval with two parts or less than one\n else if (intervals.length > 2 || intervals.length < 1)\n throw new InvalidRequestError(\"Interval can have only two parameters\")\n\n // valid interval with two parts\n else {\n if (!intervals.every(interval => hasIsoFormat(interval)))\n throw new InvalidRequestError(\"Parameter utcIntervalIso is not ISO 8601 time interval (date01/date02) or year\");\n\n const [int1, int2] = intervals.map(intervalIso => {\n const cleared = intervalIso.replace(\" \", \"\")\n return isoDateToTimestamp(cleared)\n })\n\n return [int1, int2]\n }\n}\n","// TODO: Cover by tests\n// TODO: mode to ptr-be-core as general CSV methods\n\n\n/**\n * Parses a single line of CSV-formatted strings into an array of trimmed string values.\n *\n * @param csvStingsLine - A string representing a single line of comma-separated values.\n * @returns An array of strings, each representing a trimmed value from the CSV line.\n */\nexport const csvParseStrings = (csvStingsLine: string): string[] => {\n return csvStingsLine.split(\",\").map((value: string) => value.trim());\n}\n\n/**\n * Parses a comma-separated string of numbers into an array of numbers.\n *\n * @param csvNumbersLine - A string containing numbers separated by commas (e.g., \"1, 2, 3.5\").\n * @returns An array of numbers parsed from the input string.\n */\nexport const csvParseNumbers = (csvNumbersLine: string): number[] => {\n return csvNumbersLine.split(\",\").map((value: string) => parseFloat(value.trim()));\n}","import { UsedDatasourceLabels, UsedEdgeLabels, UsedNodeLabels } from \"./enums.panther\"\nimport { GraphEdge } from \"./models.edges\"\nimport { FullPantherEntity } from \"./models.nodes\"\n\n/**\n * Finds the first node in the provided list that contains the specified label.\n *\n * Searches the given array of FullPantherEntity objects and returns the first entity\n * whose `labels` array includes the provided label.\n *\n * @param nodes - Array of FullPantherEntity objects to search through.\n * @param label - Label to match; may be a UsedDatasourceLabels or UsedNodeLabels.\n * @returns The first FullPantherEntity whose `labels` includes `label`, or `undefined`\n * if no such entity is found.\n *\n * @remarks\n * - The search stops at the first match (uses `Array.prototype.find`).\n * - Label comparison is exact (uses `Array.prototype.includes`), so it is case-sensitive\n * and requires the same string instance/value.\n *\n * @example\n * const result = findNodeByLabel(nodes, 'datasource-main');\n * if (result) {\n * // found a node that has the 'datasource-main' label\n * }\n */\nexport const findNodeByLabel = (\n nodes: FullPantherEntity[],\n label: UsedDatasourceLabels | UsedNodeLabels): FullPantherEntity | undefined => {\n return nodes.find(n => n.labels.includes(label))\n}\n\n/**\n * Filters an array of FullPantherEntity objects, returning only those that contain the specified label.\n *\n * The function performs a shallow, non-mutating filter: it returns a new array and does not modify the input.\n * Matching is done using Array.prototype.includes on each entity's `labels` array (strict equality).\n *\n * @param nodes - The array of entities to filter.\n * @param label - The label to match; can be a UsedDatasourceLabels or UsedNodeLabels value.\n * @returns A new array containing only the entities whose `labels` array includes the provided label.\n *\n * @remarks\n * Time complexity is O(n * m) where n is the number of entities and m is the average number of labels per entity.\n *\n * @example\n * ```ts\n * const matched = filterNodeByLabel(entities, 'MY_LABEL');\n * ```\n */\nexport const filterNodeByLabel = (\n nodes: FullPantherEntity[],\n label: UsedDatasourceLabels | UsedNodeLabels): FullPantherEntity[] => {\n return nodes.filter(n => n.labels.includes(label))\n}\n\n/**\n * Finds the first edge in the provided array whose label strictly equals the given label.\n *\n * @param edges - Array of GraphEdge objects to search.\n * @param label - The UsedEdgeLabels value to match against each edge's `label` property.\n * @returns The first matching GraphEdge if found; otherwise `undefined`.\n *\n * @example\n * const edge = findEdgeByLabel(edges, 'dependency');\n * if (edge) {\n * // handle found edge\n * }\n */\nexport const findEdgeByLabel = (\n edges: GraphEdge[],\n label: UsedEdgeLabels): GraphEdge | undefined => {\n return edges.find(e => e.label === label)\n}\n\n/**\n * Filters a list of GraphEdge objects by a specific edge label.\n *\n * Returns a new array containing only those edges whose `label` property\n * strictly equals the provided `label` argument. The original `edges`\n * array is not mutated.\n *\n * @param edges - Array of GraphEdge objects to filter.\n * @param label - The label to match; comparison is performed using strict (`===`) equality.\n * @returns A new array of GraphEdge objects whose `label` matches the provided label. Returns an empty array if no edges match.\n *\n * @remarks\n * Time complexity: O(n), where n is the number of edges.\n *\n * @example\n * // const result = filterEdgeByLabel(edges, 'CONNECTS');\n */\nexport const filterEdgeByLabel = (\n edges: GraphEdge[],\n label: UsedEdgeLabels): GraphEdge[] => {\n return edges.filter(e => e.label === label)\n}","/**\n * What types of graph nodes we use in metadata model\n */\nexport enum UsedNodeLabels {\n Application = \"application\", // Application node (the root of the FE app)\n Datasource = \"datasource\", // Datasource node for data including GIS information\n Place = \"place\", // Place node for geographical information\n Period = \"period\", // Period node for time information\n AreaTree = \"areaTree\", // Area tree node for administrative division\n AreaTreeLevel = \"areaTreeLevel\", // Area tree level node for administrative division\n Layer = \"layer\", // Layer node for map layer (layer have a style and a datasource)\n Style = \"style\", // Style node for map layer or a feature\n Feature = \"feature\", // Feature node for map layer,\n Attribute = \"attribute\" // Attribute node for properties of entities, like \"temperature\", \"population\", etc.\n}\n\n/**\n * What datasources we use in the system\n */\nexport enum UsedDatasourceLabels {\n Attribute = \"attributeSource\", // Column(s) with attribute values\n Geojson = \"geojson\", // Geojson for web map\n WMS = \"wms\", // WMS online source\n COG = \"cloudOptimizedGeotiff\", // COG online source\n MVT = \"mvt\", // MVT (Mapbox Vector Tiles) source\n XYZ = \"xyz\", // XYZ tile source\n CSV = \"csv\", // CSV data source\n GeoTIFF = \"geotiff\", // GeoTIFF raster data\n Shapefile = \"shapefile\", // ESRI Shapefile format\n PostGIS = \"postgis\", // PostGIS database source\n WMTS = \"wmts\", // Web Map Tile Service\n WFS = \"wfs\", // Web Feature Service\n GeoPackage = \"geopackage\", // OGC GeoPackage format\n MapStyle = \"mapStyle\", // Map style datasource\n Timeseries = \"timeseries\" // Timeseries datasource (with from-to and step)\n}\n\n/**\n * What types of edges we use in metadata model\n */\nexport enum UsedEdgeLabels {\n RelatedTo = \"RELATED\", // Generic edge for any relation\n Has = \"HAS\", // Edge for ownership relation\n InPostgisLocation = \"IN_POSTGIS_LOCATION\" // Edge to connect datasource with PostGIS location (schema, table, geometry column)\n}\n\n/**\n * What time steps are used in timeseries data\n */\nexport enum UsedTimeseriesSteps{\n Year = \"year\",\n Quarter = \"quarter\",\n Month = \"month\",\n Week = \"week\",\n Day = \"day\"\n}"],"names":[],"mappings":";;AAAA;;;;;AAKG;MACU,QAAQ,GAAG,CAAC,KAAU,EAAE,UAAe,KAAI;IACpD,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,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