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",
|
||||
"main": "index.ts",
|
||||
"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": {
|
||||
"start": "npm run generate:layeroverview && npm run strt",
|
||||
"strt": "vite --host",
|
||||
|
|
|
@ -4,7 +4,7 @@ import {Store, Stores, UIEventSource} from "../UIEventSource"
|
|||
import {OsmPreferences} from "./OsmPreferences"
|
||||
import {Utils} from "../../Utils"
|
||||
import {LocalStorageSource} from "../Web/LocalStorageSource";
|
||||
|
||||
import * as config from "../../../package.json"
|
||||
export default class UserDetails {
|
||||
public loggedIn = false
|
||||
public name = "Not logged in"
|
||||
|
@ -25,6 +25,7 @@ export default class UserDetails {
|
|||
}
|
||||
|
||||
export interface AuthConfig {
|
||||
"#"?: string // optional comment
|
||||
oauth_client_id: string
|
||||
oauth_secret: string
|
||||
url: string
|
||||
|
@ -33,25 +34,7 @@ export interface AuthConfig {
|
|||
export type OsmServiceState = "online" | "readonly" | "offline" | "unknown" | "unreachable"
|
||||
|
||||
export class OsmConnection {
|
||||
public static readonly oauth_configs: Record<string, AuthConfig> = {
|
||||
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 static readonly oauth_configs: Record<string, AuthConfig> = config.config.oauth_credentials
|
||||
public auth
|
||||
public userDetails: UIEventSource<UserDetails>
|
||||
public isLoggedIn: Store<boolean>
|
||||
|
|
|
@ -6,9 +6,8 @@ export type PriviligedLayerType = (typeof Constants.priviliged_layers)[number]
|
|||
export default class Constants {
|
||||
public static vNumber = meta.version
|
||||
|
||||
public static ImgurApiKey = "7070e7167f0a25a"
|
||||
public static readonly mapillary_client_token_v4 =
|
||||
"MLY|4441509239301885|b40ad2d3ea105435bd40c7e76993ae85"
|
||||
public static ImgurApiKey = meta.config.api_keys.imgur
|
||||
public static readonly mapillary_client_token_v4 =meta.config.api_keys.mapillary_v4
|
||||
|
||||
/**
|
||||
* API key for Maproulette
|
||||
|
@ -19,15 +18,7 @@ export default class Constants {
|
|||
*/
|
||||
public static readonly MaprouletteApiKey = ""
|
||||
|
||||
public static defaultOverpassUrls = [
|
||||
// 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 defaultOverpassUrls = meta.config.default_overpass_urls
|
||||
|
||||
public static readonly added_by_default = [
|
||||
"selected_element",
|
||||
|
@ -100,6 +91,7 @@ export default class Constants {
|
|||
"etymology",
|
||||
"food",
|
||||
"cafes_and_pubs",
|
||||
"shops",
|
||||
"playgrounds",
|
||||
"hailhydrant",
|
||||
"toilets",
|
||||
|
@ -113,9 +105,8 @@ export default class Constants {
|
|||
* In seconds
|
||||
*/
|
||||
static zoomToLocationTimeout = 15
|
||||
static countryCoderEndpoint: string =
|
||||
"https://raw.githubusercontent.com/pietervdvn/MapComplete-data/main/latlon2country"
|
||||
public static readonly OsmPreferenceKeyPicturesLicense = "pictures-license"
|
||||
static countryCoderEndpoint: string = meta.config.country_coder_host
|
||||
|
||||
/**
|
||||
* 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")
|
||||
|
||||
const licenseStore = state?.osmConnection?.GetPreference(
|
||||
Constants.OsmPreferenceKeyPicturesLicense,
|
||||
"pictures-license",
|
||||
"CC0"
|
||||
)
|
||||
|
||||
|
|
Loading…
Reference in a new issue