Skip to content

Commit 6c70a80

Browse files
committed
PB-2064: remove all TS enums
expect in @swissgeo/logs, where I find it doesn't really make sense to have something else here (especially with colors).
1 parent 4bbb9d5 commit 6c70a80

103 files changed

Lines changed: 508 additions & 712 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

packages/api/src/features.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import type Feature from 'ol/Feature'
66
import type { LineString, MultiLineString, MultiPolygon, Point, Polygon } from 'ol/geom'
77

88
import { allCoordinateSystems, extentUtils, LV95 } from '@swissgeo/coordinates'
9-
import { ALL_YEARS_TIMESTAMP, CURRENT_YEAR_TIMESTAMP, LayerType } from '@swissgeo/layers'
9+
import { ALL_YEARS_TIMESTAMP, CURRENT_YEAR_TIMESTAMP } from '@swissgeo/layers'
1010
import { geoJsonUtils, layerUtils } from '@swissgeo/layers/utils'
1111
import log from '@swissgeo/log'
1212
import { getApi3BaseUrl } from '@swissgeo/staging-config'
@@ -236,7 +236,7 @@ async function identifyOnExternalLayer(config: IdentifyConfig): Promise<LayerFea
236236
// If we use different projection, we also need to project out initial coordinate
237237
requestedCoordinate = proj4(projection.epsg, requestProjection.epsg, coordinate)
238238
}
239-
if (layer.type === LayerType.WMS) {
239+
if (layer.type === 'WMS') {
240240
return await identifyOnExternalWmsLayer({
241241
...config,
242242
coordinate: requestedCoordinate,
@@ -483,7 +483,7 @@ async function identifyOnExternalWmsLayer(config: IdentifyConfig): Promise<Layer
483483
outputProjection ?? projection,
484484
projection
485485
),
486-
popupDataCanBeTrusted: !layer.isExternal && layer.type !== LayerType.KML,
486+
popupDataCanBeTrusted: !layer.isExternal && layer.type !== 'KML',
487487
}
488488
return layerFeature
489489
})
@@ -657,7 +657,7 @@ function parseGeomAdminFeature(
657657
coordinates: center,
658658
extent: featureExtent,
659659
geometry: featureGeoJSONGeometry,
660-
popupDataCanBeTrusted: !layer.isExternal && layer.type !== LayerType.KML,
660+
popupDataCanBeTrusted: !layer.isExternal && layer.type !== 'KML',
661661
}
662662
return layerFeature
663663
}

packages/api/src/search.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import type { AxiosResponse, CancelToken, CancelTokenSource } from 'axios'
44
import type Feature from 'ol/Feature'
55

66
import { CustomCoordinateSystem, LV95, WGS84 } from '@swissgeo/coordinates'
7-
import { LayerType } from '@swissgeo/layers'
87
import { geoJsonUtils } from '@swissgeo/layers/utils'
98
import log, { LogPreDefinedColor } from '@swissgeo/log'
109
import { getApi3BaseUrl } from '@swissgeo/staging-config'
@@ -327,7 +326,7 @@ function searchLayerFeaturesKMLGPX(
327326
iconSets: DrawingIconSet[]
328327
): SearchResult[] {
329328
return layersToSearch.reduce((returnLayers: SearchResult[], currentLayer: Layer) => {
330-
if (currentLayer.type === LayerType.KML) {
329+
if (currentLayer.type === 'KML') {
331330
const kmlLayer = currentLayer as KMLLayer
332331
return returnLayers.concat(
333332
searchFeatures(
@@ -338,7 +337,7 @@ function searchLayerFeaturesKMLGPX(
338337
)
339338
)
340339
}
341-
if (currentLayer.type === LayerType.GPX) {
340+
if (currentLayer.type === 'GPX') {
342341
const gpxLayer = currentLayer as GPXLayer
343342
const gpxData = gpxLayer.gpxData
344343
if (!gpxData) {

packages/api/src/utils/__tests__/legacyLayerParamUtils.spec.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import type { ExternalWMSLayer, GeoAdminLayer, Layer } from '@swissgeo/layers'
22

3-
import { LayerType } from '@swissgeo/layers'
43
import { layerUtils, timeConfigUtils } from '@swissgeo/layers/utils'
54
import { describe, expect, it } from 'vitest'
65

@@ -162,7 +161,7 @@ describe('Test parsing of legacy URL param into new params', () => {
162161
expect(result).to.be.an('Array').length(1)
163162
const [kmlLayer] = result
164163
expect(kmlLayer!.id).to.eq(`KML|${kmlFileUrl}`)
165-
expect(kmlLayer!.type).to.eq(LayerType.KML)
164+
expect(kmlLayer!.type).to.eq('KML')
166165
expect(kmlLayer!.baseUrl).to.eq(kmlFileUrl)
167166
})
168167
it('Handles opacity/visibility correctly with external layers', () => {
@@ -194,7 +193,7 @@ describe('Test parsing of legacy URL param into new params', () => {
194193
)
195194
expect(result).to.be.an('Array').length(1)
196195
const [externalWmsLayer] = result
197-
expect(externalWmsLayer!.type).to.eq(LayerType.WMS)
196+
expect(externalWmsLayer!.type).to.eq('WMS')
198197
expect(externalWmsLayer!.opacity).to.eq(0.45)
199198
expect((externalWmsLayer as ExternalWMSLayer).wmsVersion).to.eq(wmsVersion)
200199
expect(externalWmsLayer!.id).to.eq(wmsLayerId)
@@ -216,7 +215,7 @@ describe('Test parsing of legacy URL param into new params', () => {
216215
)
217216
expect(result).to.be.an('Array').length(1)
218217
const [externalWmtsLayer] = result
219-
expect(externalWmtsLayer!.type).to.eq(LayerType.WMTS)
218+
expect(externalWmtsLayer!.type).to.eq('WMTS')
220219
expect(externalWmtsLayer!.opacity).to.eq(0.77)
221220
expect(externalWmtsLayer!.isVisible).to.be.false
222221
expect(externalWmtsLayer!.id).to.eq(wmtsLayerId)

packages/api/src/utils/kmlUtils.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import type { Size } from 'ol/size'
99
import type Style from 'ol/style/Style'
1010

1111
import { registerProj4, WGS84 } from '@swissgeo/coordinates'
12-
import { KMLStyle } from '@swissgeo/layers'
1312
import log, { LogPreDefinedColor } from '@swissgeo/log'
1413
import {
1514
DEFAULT_TITLE_OFFSET,
@@ -776,7 +775,7 @@ function parseKml(
776775
featureProjection: projection.epsg,
777776
})
778777

779-
if (kmlLayer.style === KMLStyle.GEOADMIN) {
778+
if (kmlLayer.style === 'GEOADMIN') {
780779
features.forEach((olFeature) => {
781780
const editableFeature = getEditableFeatureFromKmlFeature(
782781
olFeature,

packages/api/src/utils/legacyLayerParamUtils.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import type { GeoAdminLayer, KMLLayer, Layer } from '@swissgeo/layers'
22
import type { Staging } from '@swissgeo/staging-config'
33

4-
import { KMLStyle } from '@swissgeo/layers'
54
import { layerUtils, timeConfigUtils } from '@swissgeo/layers/utils'
65
import log from '@swissgeo/log'
76

@@ -114,7 +113,7 @@ function getLayersFromLegacyUrlParams(
114113
layer = layerUtils.makeKMLLayer({
115114
kmlFileUrl: url,
116115
isVisible: true,
117-
style: KMLStyle.GEOADMIN,
116+
style: 'GEOADMIN',
118117
})
119118
}
120119
if (layerId.startsWith('GPX||')) {
@@ -219,7 +218,10 @@ function getBackgroundLayerFromLegacyUrlParams(
219218
* @param adminId KML admin ID
220219
* @returns KML Layer
221220
*/
222-
async function getKmlLayerFromLegacyAdminIdParam(adminId: string, staging: Staging = 'production'): Promise<KMLLayer> {
221+
async function getKmlLayerFromLegacyAdminIdParam(
222+
adminId: string,
223+
staging: Staging = 'production'
224+
): Promise<KMLLayer> {
223225
const kmlMetadata = await filesAPI.getKmlMetadataByAdminId(adminId, staging)
224226
return layerUtils.makeKMLLayer({
225227
kmlFileUrl: kmlMetadata.links.kml,

packages/config/staging/src/constants/print.config.ts

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,7 @@ export const PRINT_DPI_COMPENSATION: number = 144
66
//So when there is a non 0 scale, we set its minimum to 0.0001
77
export const MIN_PRINT_SCALE_SIZE: number = 0.0001
88

9-
export enum PrintLayout {
10-
A0 = 'A0',
11-
A1 = 'A1',
12-
A2 = 'A2',
13-
A3 = 'A3',
14-
A4 = 'A4',
15-
A5 = 'A5',
16-
A6 = 'A6',
17-
}
9+
export type PrintLayout = 'A0' | 'A1' | 'A2' | 'A3' | 'A4' | 'A5' | 'A6'
1810

1911
/** Dimensions in mm of the viewport for each print format */
2012
export const PRINT_DIMENSIONS: Record<PrintLayout, [number, number]> = {

packages/layers/src/api/__test__/internal.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import type {
99
} from '@/types'
1010

1111
import { generateLayerObject } from '@/api'
12-
import { LayerType, YEAR_TO_DESCRIBE_ALL_OR_CURRENT_DATA } from '@/types'
12+
import { YEAR_TO_DESCRIBE_ALL_OR_CURRENT_DATA } from '@/types'
1313

1414
import rawLayerConfig from './rawLayerConfig.json'
1515

@@ -251,7 +251,7 @@ describe('Test layer config parsing', () => {
251251
const layer = parseLayer(layerId)
252252

253253
expect(layer).to.not.be.undefined
254-
expect(layer!.type).to.eq(LayerType.GEOJSON)
254+
expect(layer!.type).to.eq('GEOJSON')
255255
const geoJsonLayer = layer as GeoAdminGeoJSONLayer
256256

257257
expect(geoJsonLayer.geoJsonUrl).to.eq(

packages/layers/src/api/internal.ts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import type {
1414
} from '@/index'
1515

1616
import { DEFAULT_GEOADMIN_MAX_WMTS_RESOLUTION } from '@/config'
17-
import { LayerType } from '@/index'
1817
import { layerUtils, timeConfigUtils } from '@/utils'
1918

2019
export interface LayerConfigResponse {
@@ -150,7 +149,7 @@ export function generateLayerObject(
150149
break
151150
case 'wmts': {
152151
return layerUtils.makeGeoAdminWMTSLayer({
153-
type: LayerType.WMTS,
152+
type: 'WMTS',
154153
name,
155154
id,
156155
baseUrl: _urlWithTrailingSlash(getWmtsBaseUrl(staging)),
@@ -173,7 +172,7 @@ export function generateLayerObject(
173172
}
174173
case 'wms': {
175174
return layerUtils.makeGeoAdminWMSLayer({
176-
type: LayerType.WMS,
175+
type: 'WMS',
177176
name,
178177
id: id,
179178
idIn3d: layerConfig.config3d,
@@ -197,7 +196,7 @@ export function generateLayerObject(
197196
}
198197
case 'geojson': {
199198
return layerUtils.makeGeoAdminGeoJSONLayer({
200-
type: LayerType.GEOJSON,
199+
type: 'GEOJSON',
201200
name,
202201
id,
203202
opacity,
@@ -250,10 +249,7 @@ export function generateLayerObject(
250249
lang,
251250
staging
252251
)
253-
if (
254-
subLayer &&
255-
(subLayer.type === LayerType.WMS || subLayer.type === LayerType.WMTS)
256-
) {
252+
if (subLayer && (subLayer.type === 'WMS' || subLayer.type === 'WMTS')) {
257253
subLayers.push(
258254
layerUtils.makeAggregateSubLayer({
259255
subLayerId,

packages/layers/src/parsers/WMTSCapabilitiesParser.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ import type {
2323
WMTSLegendURL,
2424
WMTSOnlineResource,
2525
WMTSTileMatrixSetLink,
26+
WMTSEncodingType,
2627
} from '@/types'
2728
import type { TileMatrix } from '@/types/layers'
2829

29-
import { LayerType, WMTSEncodingType } from '@/types'
3030
import layerUtils from '@/utils/layerUtils'
3131
import timeConfigUtils from '@/utils/timeConfigUtils'
3232
import { CapabilitiesError } from '@/validation'
@@ -331,7 +331,7 @@ function getLayerAttributes(
331331
getCapUrl = capabilities.originUrl.toString()
332332
}
333333

334-
let getTileEncoding: WMTSEncodingType = WMTSEncodingType.REST
334+
let getTileEncoding: WMTSEncodingType = 'REST'
335335
if (
336336
capabilities.OperationsMetadata &&
337337
'GetTile' in capabilities.OperationsMetadata &&
@@ -471,7 +471,7 @@ function getExternalLayer(
471471
}
472472

473473
return layerUtils.makeExternalWMTSLayer({
474-
type: LayerType.WMTS,
474+
type: 'WMTS',
475475
...attributes,
476476
opacity,
477477
isVisible,

0 commit comments

Comments
 (0)