forked from MapComplete/MapComplete
Refactoring: move constants into package.json
This commit is contained in:
parent
4d01d81e1e
commit
f207736e40
4 changed files with 49 additions and 36 deletions
39
package.json
39
package.json
|
@ -7,6 +7,45 @@
|
||||||
"homepage": "https://mapcomplete.org",
|
"homepage": "https://mapcomplete.org",
|
||||||
"main": "index.ts",
|
"main": "index.ts",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
|
"config": {
|
||||||
|
"#": "Various endpoints that are instance-specific",
|
||||||
|
"#oauth_credentials:comment": [
|
||||||
|
"`oauth_credentials` are the OAuth-2 credentials for the production-OSM server and the test-server.",
|
||||||
|
"Are you deploying your own instance? Register your application too.",
|
||||||
|
"See https://wiki.openstreetmap.org/wiki/OAuth#Registering_your_application_as_OAuth_2.0_consumer for instructions",
|
||||||
|
"Use `https://<your domain name>/<path to mapcomplete>/land.html` as redirect URIs. You can add `http://127.0.0.1:1234/land.html` too for local development."
|
||||||
|
],
|
||||||
|
"oauth_credentials": {
|
||||||
|
"osm_pietervdvn": {
|
||||||
|
"#": "This client_id is registered by 'Pieter Vander Vennet' on OSM.org",
|
||||||
|
"oauth_client_id": "sa1ngLJBJ8McmzHElN8NYtIDm5TZTYEYhq3-0snO4Qc",
|
||||||
|
"oauth_secret": "XU_cD5Mvw9VKk9T0t_gO8V7cbRC4Hmw2Tb4Rv0Zmz-U",
|
||||||
|
"url": "https://www.openstreetmap.org"
|
||||||
|
},
|
||||||
|
"osm": {
|
||||||
|
"#": "This client-id is registered by 'MapComplete' on osm.org",
|
||||||
|
"oauth_client_id": "K93H1d8ve7p-tVLE1ZwsQ4lAFLQk8INx5vfTLMu5DWk",
|
||||||
|
"oauth_secret": "NBWGhWDrD3QDB35xtVuxv4aExnmIt4FA_WgeLtwxasg",
|
||||||
|
"url": "https://www.openstreetmap.org"
|
||||||
|
},
|
||||||
|
"osm-test": {
|
||||||
|
"oauth_client_id": "HwUn6GPxGm1m9WwMarxTglhy6dBTM4YkaV1I9h6pDGU",
|
||||||
|
"oauth_secret": "luFZtPJg7j96K6WM6RpcZ_3M-r6muuDq6fG1ygk0I_4",
|
||||||
|
"url": "https://master.apis.dev.openstreetmap.org"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"api_keys": {
|
||||||
|
"#": "Various API-keys for various services. Feel free to reuse those in another MapComplete-hosted version",
|
||||||
|
"imgur": "7070e7167f0a25a",
|
||||||
|
"mapillary_v4": "MLY|4441509239301885|b40ad2d3ea105435bd40c7e76993ae85"
|
||||||
|
},
|
||||||
|
"default_overpass_urls": [
|
||||||
|
"https://overpass-api.de/api/interpreter",
|
||||||
|
"https://overpass.kumi.systems/api/interpreter",
|
||||||
|
"https://overpass.openstreetmap.ru/cgi/interpreter"
|
||||||
|
],
|
||||||
|
"country_coder_host": "https://raw.githubusercontent.com/pietervdvn/MapComplete-data/main/latlon2country"
|
||||||
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "npm run generate:layeroverview && npm run strt",
|
"start": "npm run generate:layeroverview && npm run strt",
|
||||||
"strt": "vite --host",
|
"strt": "vite --host",
|
||||||
|
|
|
@ -4,7 +4,7 @@ import {Store, Stores, UIEventSource} from "../UIEventSource"
|
||||||
import {OsmPreferences} from "./OsmPreferences"
|
import {OsmPreferences} from "./OsmPreferences"
|
||||||
import {Utils} from "../../Utils"
|
import {Utils} from "../../Utils"
|
||||||
import {LocalStorageSource} from "../Web/LocalStorageSource";
|
import {LocalStorageSource} from "../Web/LocalStorageSource";
|
||||||
|
import * as config from "../../../package.json"
|
||||||
export default class UserDetails {
|
export default class UserDetails {
|
||||||
public loggedIn = false
|
public loggedIn = false
|
||||||
public name = "Not logged in"
|
public name = "Not logged in"
|
||||||
|
@ -25,6 +25,7 @@ export default class UserDetails {
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface AuthConfig {
|
export interface AuthConfig {
|
||||||
|
"#"?: string // optional comment
|
||||||
oauth_client_id: string
|
oauth_client_id: string
|
||||||
oauth_secret: string
|
oauth_secret: string
|
||||||
url: string
|
url: string
|
||||||
|
@ -33,25 +34,7 @@ export interface AuthConfig {
|
||||||
export type OsmServiceState = "online" | "readonly" | "offline" | "unknown" | "unreachable"
|
export type OsmServiceState = "online" | "readonly" | "offline" | "unknown" | "unreachable"
|
||||||
|
|
||||||
export class OsmConnection {
|
export class OsmConnection {
|
||||||
public static readonly oauth_configs: Record<string, AuthConfig> = {
|
public static readonly oauth_configs: Record<string, AuthConfig> = config.config.oauth_credentials
|
||||||
osm_pietervdvn: {
|
|
||||||
// This client_id is registered by "Pieter Vander Vennet" on OSM.org
|
|
||||||
oauth_client_id: 'sa1ngLJBJ8McmzHElN8NYtIDm5TZTYEYhq3-0snO4Qc',
|
|
||||||
oauth_secret: 'XU_cD5Mvw9VKk9T0t_gO8V7cbRC4Hmw2Tb4Rv0Zmz-U',
|
|
||||||
url: "https://www.openstreetmap.org",
|
|
||||||
},
|
|
||||||
osm: {
|
|
||||||
// This client-id is registered by "MapComplete" on osm.org
|
|
||||||
oauth_client_id: "K93H1d8ve7p-tVLE1ZwsQ4lAFLQk8INx5vfTLMu5DWk",
|
|
||||||
oauth_secret: "NBWGhWDrD3QDB35xtVuxv4aExnmIt4FA_WgeLtwxasg",
|
|
||||||
url: "https://www.openstreetmap.org",
|
|
||||||
},
|
|
||||||
"osm-test": {
|
|
||||||
oauth_client_id: "HwUn6GPxGm1m9WwMarxTglhy6dBTM4YkaV1I9h6pDGU",
|
|
||||||
oauth_secret: "luFZtPJg7j96K6WM6RpcZ_3M-r6muuDq6fG1ygk0I_4",
|
|
||||||
url: "https://master.apis.dev.openstreetmap.org",
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public auth
|
public auth
|
||||||
public userDetails: UIEventSource<UserDetails>
|
public userDetails: UIEventSource<UserDetails>
|
||||||
public isLoggedIn: Store<boolean>
|
public isLoggedIn: Store<boolean>
|
||||||
|
|
|
@ -6,9 +6,8 @@ export type PriviligedLayerType = (typeof Constants.priviliged_layers)[number]
|
||||||
export default class Constants {
|
export default class Constants {
|
||||||
public static vNumber = meta.version
|
public static vNumber = meta.version
|
||||||
|
|
||||||
public static ImgurApiKey = "7070e7167f0a25a"
|
public static ImgurApiKey = meta.config.api_keys.imgur
|
||||||
public static readonly mapillary_client_token_v4 =
|
public static readonly mapillary_client_token_v4 =meta.config.api_keys.mapillary_v4
|
||||||
"MLY|4441509239301885|b40ad2d3ea105435bd40c7e76993ae85"
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* API key for Maproulette
|
* API key for Maproulette
|
||||||
|
@ -19,15 +18,7 @@ export default class Constants {
|
||||||
*/
|
*/
|
||||||
public static readonly MaprouletteApiKey = ""
|
public static readonly MaprouletteApiKey = ""
|
||||||
|
|
||||||
public static defaultOverpassUrls = [
|
public static defaultOverpassUrls = meta.config.default_overpass_urls
|
||||||
// The official instance, 10000 queries per day per project allowed
|
|
||||||
"https://overpass-api.de/api/interpreter",
|
|
||||||
// 'Fair usage'
|
|
||||||
"https://overpass.kumi.systems/api/interpreter",
|
|
||||||
// Offline: "https://overpass.nchc.org.tw/api/interpreter",
|
|
||||||
"https://overpass.openstreetmap.ru/cgi/interpreter",
|
|
||||||
// Doesn't support nwr: "https://overpass.openstreetmap.fr/api/interpreter"
|
|
||||||
]
|
|
||||||
|
|
||||||
public static readonly added_by_default = [
|
public static readonly added_by_default = [
|
||||||
"selected_element",
|
"selected_element",
|
||||||
|
@ -100,6 +91,7 @@ export default class Constants {
|
||||||
"etymology",
|
"etymology",
|
||||||
"food",
|
"food",
|
||||||
"cafes_and_pubs",
|
"cafes_and_pubs",
|
||||||
|
"shops",
|
||||||
"playgrounds",
|
"playgrounds",
|
||||||
"hailhydrant",
|
"hailhydrant",
|
||||||
"toilets",
|
"toilets",
|
||||||
|
@ -113,9 +105,8 @@ export default class Constants {
|
||||||
* In seconds
|
* In seconds
|
||||||
*/
|
*/
|
||||||
static zoomToLocationTimeout = 15
|
static zoomToLocationTimeout = 15
|
||||||
static countryCoderEndpoint: string =
|
static countryCoderEndpoint: string = meta.config.country_coder_host
|
||||||
"https://raw.githubusercontent.com/pietervdvn/MapComplete-data/main/latlon2country"
|
|
||||||
public static readonly OsmPreferenceKeyPicturesLicense = "pictures-license"
|
|
||||||
/**
|
/**
|
||||||
* These are the values that are allowed to use as 'backdrop' icon for a map pin
|
* These are the values that are allowed to use as 'backdrop' icon for a map pin
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -73,7 +73,7 @@ export class ImageUploadFlow extends Toggle {
|
||||||
]).SetClass("w-full flex justify-center items-center")
|
]).SetClass("w-full flex justify-center items-center")
|
||||||
|
|
||||||
const licenseStore = state?.osmConnection?.GetPreference(
|
const licenseStore = state?.osmConnection?.GetPreference(
|
||||||
Constants.OsmPreferenceKeyPicturesLicense,
|
"pictures-license",
|
||||||
"CC0"
|
"CC0"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue