Skip to content

Commit 8418cba

Browse files
authored
Merge pull request #1542 from geoadmin/feat-PB-1387-api-as-module
PB-1387: all API files as a package
2 parents 995c86e + 3976129 commit 8418cba

File tree

202 files changed

+5265
-4784
lines changed

Some content is hidden

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

202 files changed

+5265
-4784
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
"prettier-plugin-packagejson": "catalog:",
4141
"prettier-plugin-tailwindcss": "catalog:",
4242
"tsx": "catalog:",
43+
"vitest": "catalog:",
4344
"yaml": "catalog:"
4445
},
4546
"engines": {

packages/api/eslint.config.mts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import defaultConfig from '@swissgeo/config-eslint'
2+
3+
export default [
4+
...defaultConfig,
5+
{
6+
languageOptions: {
7+
parserOptions: {
8+
tsconfigRootDir: import.meta.dirname,
9+
},
10+
},
11+
},
12+
]

packages/api/package.json

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
{
2+
"name": "@swissgeo/api",
3+
"version": "0.0.1",
4+
"description": "API utilities to interact with SWISSGEO's backend services",
5+
"type": "module",
6+
"exports": {
7+
".": {
8+
"types": "./dist/index.d.ts",
9+
"import": "./dist/index.js",
10+
"require": "./dist/index.umd.cjs"
11+
},
12+
"./utils": {
13+
"types": "./dist/utils.d.ts",
14+
"import": "./dist/utils.js",
15+
"require": "./dist/utils.umd.cjs"
16+
}
17+
},
18+
"scripts": {
19+
"build": "pnpm run type-check && pnpm run generate-types && vite build",
20+
"generate-types": "vue-tsc --declaration",
21+
"lint": "eslint --fix",
22+
"lint:no-fix": "eslint",
23+
"prepare": "pnpm run build",
24+
"test:unit": "vitest run",
25+
"test:unit:watch": "vitest watch",
26+
"type-check": "vue-tsc --build"
27+
},
28+
"dependencies": {
29+
"@geoblocks/mapfishprint": "catalog:",
30+
"@swissgeo/coordinates": "workspace:*",
31+
"@swissgeo/layers": "workspace:*",
32+
"@swissgeo/log": "workspace:*",
33+
"@swissgeo/numbers": "workspace:*",
34+
"@swissgeo/staging-config": "workspace:*",
35+
"@swissgeo/theme": "workspace:*",
36+
"@tmcw/togeojson": "catalog:",
37+
"@turf/turf": "catalog:",
38+
"form-data": "catalog:",
39+
"jszip": "catalog:",
40+
"lodash": "catalog:",
41+
"luxon": "catalog:",
42+
"pako": "catalog:"
43+
},
44+
"devDependencies": {
45+
"@intlify/core-base": "catalog:",
46+
"@microsoft/api-extractor": "catalog:",
47+
"@swissgeo/config-eslint": "workspace:*",
48+
"@swissgeo/config-prettier": "workspace:*",
49+
"@swissgeo/config-typescript": "workspace:*",
50+
"@tsconfig/node22": "catalog:",
51+
"@types/chai": "catalog:",
52+
"@types/geojson": "catalog:",
53+
"@types/jsdom": "catalog:",
54+
"@types/lodash": "catalog:",
55+
"@types/pako": "catalog:",
56+
"chai": "catalog:",
57+
"eslint": "catalog:",
58+
"typescript": "catalog:",
59+
"unplugin-dts": "catalog:",
60+
"vite": "catalog:",
61+
"vite-plugin-vue-devtools": "catalog:",
62+
"vite-tsconfig-paths": "catalog:",
63+
"vitest": "catalog:",
64+
"vue-tsc": "catalog:"
65+
},
66+
"peerDependencies": {
67+
"axios": "catalog:",
68+
"ol": "catalog:",
69+
"proj4": "catalog:"
70+
}
71+
}

packages/viewer/src/api/__tests__/file-proxy.api.spec.ts renamed to packages/api/src/__tests__/fileProxy.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import { describe, expect, it } from 'vitest'
22

3-
import { transformFileUrl } from '@/api/file-proxy.api'
3+
import fileProxyAPI from '@/fileProxy'
44

55
describe('Serice-proxy tests', () => {
66
describe('transformFileUrl', () => {
77
it('returns undefined when the input is invalid', () => {
8-
expect(transformFileUrl('some non URL string')).to.be.undefined
8+
expect(fileProxyAPI.transformFileUrl('some non URL string')).to.be.undefined
99
})
1010
it('returns the URL transformed', () => {
11-
expect(transformFileUrl('http://some-file.kml?one=1&foo=bar')).to.eq(
11+
expect(fileProxyAPI.transformFileUrl('http://some-file.kml?one=1&foo=bar')).to.eq(
1212
`http/some-file.kml${encodeURIComponent('?one=1&foo=bar')}`
1313
)
1414
})
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
import { describe, expect, it } from 'vitest'
22

3-
import { sanitizeTitle } from '@/api/search.api'
3+
import searchAPI from '@/search'
44

55
describe('Builds object by extracting all relevant attributes from the backend', () => {
66
describe('FeatureSearchResult.getSimpleTitle', () => {
77
it('Returns title removing HTML', () => {
88
const expectedResult = 'Some irrelevant stuff 123 Test'
99
const expectedResultWrappedInHtml = '<i>Some irrelevant stuff</i> <b>123 Test</b>'
10-
expect(sanitizeTitle(expectedResultWrappedInHtml)).to.eq(expectedResult)
10+
expect(searchAPI.sanitizeTitle(expectedResultWrappedInHtml)).to.eq(expectedResult)
1111
})
1212

1313
it('Returns title as is if no HTML is present', () => {
1414
const expectedResult = 'Test 123 Test'
15-
expect(sanitizeTitle(expectedResult)).to.eq(expectedResult)
15+
expect(searchAPI.sanitizeTitle(expectedResult)).to.eq(expectedResult)
1616
})
1717
})
1818
})

packages/api/src/config/log.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { LogPreDefinedColor } from '@swissgeo/log'
2+
3+
const LogColorPerService = {
4+
feedback: LogPreDefinedColor.Amber,
5+
fileProxy: LogPreDefinedColor.Green,
6+
files: LogPreDefinedColor.Indigo,
7+
height: LogPreDefinedColor.Orange,
8+
icons: LogPreDefinedColor.Lime,
9+
lv03Reframe: LogPreDefinedColor.Zinc,
10+
print: LogPreDefinedColor.Emerald,
11+
qrCode: LogPreDefinedColor.Purple,
12+
}
13+
export default LogColorPerService

0 commit comments

Comments
 (0)