Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,25 @@ import { merchantList } from '$lib/merchantListStore';
import type { Place, Report, AreaTags } from '$lib/types';
```

### Generated API types (`$types/btcmap-api`)

- `src/types/btcmap-api/` is generated from btcmap-api's Rust response structs
(ts-rs) — never hand-edit it; it is excluded from biome and must stay
byte-identical to the generator's output
- Refresh with `pnpm types:api` — it fetches the committed `bindings/ts/`
directory from btcmap-api's master on GitHub (no Rust toolchain or checkout
needed; btcmap-api CI guarantees that directory matches its code). Commit
the resulting diff — it documents the API change
- To develop against an unmerged btcmap-api branch:
`npx degit "teambtcmap/btcmap-api/bindings/ts#<branch>" src/types/btcmap-api`
- Import these types (via the `$types` alias) when typing raw v4 API responses,
e.g. `import type { SearchResponse } from "$types/btcmap-api/SearchResponse"`
- **Two `Place` types exist during the migration:** `Place` from `$lib/types`
stays the app-facing type used by stores and components; the generated
`$types/btcmap-api/Place` is the API contract shape for the `fields`-driven
endpoints (all fields optional). Don't autocomplete the wrong one — if a
store or component needs `Place`, it's the `$lib/types` one

### Comments

- **Avoid JSDoc comments** (`/** */` with `@param`, `@returns`, `@description`, etc.)
Expand Down
3 changes: 2 additions & 1 deletion biome.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
"!spritesheet-*.ts",
"!playwright-report",
"!src/error.html",
"!**/*.svg"
"!**/*.svg",
"!src/types/btcmap-api"
]
},
"assist": {
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"preview": "vite preview",
"sync:rtl-plugin": "cp node_modules/@mapbox/mapbox-gl-rtl-text/dist/mapbox-gl-rtl-text.js static/mapbox-gl-rtl-text.js",
"test": "vitest",
"types:api": "rm -rf src/types/btcmap-api && npx degit teambtcmap/btcmap-api/bindings/ts src/types/btcmap-api",
Comment thread
coderabbitai[bot] marked this conversation as resolved.
"typecheck": "tsc --project ./tsconfig.json --noEmit --pretty"
},
"lint-staged": {
Expand Down
12 changes: 6 additions & 6 deletions src/routes/api/search/places/+server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { error } from "@sveltejs/kit";
import { API_BASE } from "$lib/api-base";

import type { RequestHandler } from "./$types";
import type { SearchResponse } from "$types/btcmap-api/SearchResponse";

// Worldwide free-text search. Backed by /v4/search, which matches every OSM tag
// value, so a city name finds the places addressed in that city. Scoped to
Expand Down Expand Up @@ -43,12 +44,11 @@ export const GET: RequestHandler = async ({ url, fetch }) => {
error(res.status, "Search temporarily unavailable");
}

const body = (await res.json()) as {
results?: ({ type: string } & Record<string, unknown>)[];
total_count?: number;
has_more?: boolean;
};
// Drop the discriminator so each row is exactly a Place.
// Partial: the type describes what the current API sends, but this proxy
// deliberately tolerates an upstream that omits fields (see tests).
const body = (await res.json()) as Partial<SearchResponse>;
// Drop the discriminator; `type_filter=place` means every row is a place
// at runtime, though the static type stays the area/place union.
const places = (body.results ?? []).map(({ type: _type, ...place }) => place);

// The API caps `limit`, so a broad query ("str" matches every addr:street)
Expand Down
3 changes: 3 additions & 0 deletions src/types/btcmap-api/ActivityItem.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.

export type ActivityItem = { type: string, place_id: number, place_name?: string, osm_user_id?: number, osm_user_name?: string, osm_user_tip?: string, comment?: string, duration_days?: number, image: string, date: string, };
3 changes: 3 additions & 0 deletions src/types/btcmap-api/Area.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.

export type Area = { id: number, name: string, type: string, url_alias: string, icon: string | null, icon_wide: string | null, website_url: string, description: string, };
3 changes: 3 additions & 0 deletions src/types/btcmap-api/AreaSearchResult.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.

export type AreaSearchResult = { id: number, name: string, type: string, url_alias: string, icon: string | null, website_url: string, };
3 changes: 3 additions & 0 deletions src/types/btcmap-api/AuthNostrResponse.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.

export type AuthNostrResponse = { token: string, username: string, npub: string, };
3 changes: 3 additions & 0 deletions src/types/btcmap-api/ChangePasswordArgs.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.

export type ChangePasswordArgs = { old_password: string, new_password: string, };
3 changes: 3 additions & 0 deletions src/types/btcmap-api/ChartEntry.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.

export type ChartEntry = { date: string, value: number, };
3 changes: 3 additions & 0 deletions src/types/btcmap-api/Community.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.

export type Community = { id: number, alias: string, name: string, icon: string | null, places_total: number, places_verified_1y: number, grade: number, };
3 changes: 3 additions & 0 deletions src/types/btcmap-api/Country.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.

export type Country = { id: number, alias: string, name: string, icon: string | null, places_total: number, places_verified_1y: number, grade: number, };
3 changes: 3 additions & 0 deletions src/types/btcmap-api/CreateTokenArgs.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.

export type CreateTokenArgs = { label: string | null, };
4 changes: 4 additions & 0 deletions src/types/btcmap-api/CreateTokenResponse.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { MeResponse } from "./MeResponse";

export type CreateTokenResponse = { token: string, user: MeResponse, };
3 changes: 3 additions & 0 deletions src/types/btcmap-api/CreateUserArgs.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.

export type CreateUserArgs = { name: string | null, password: string, };
3 changes: 3 additions & 0 deletions src/types/btcmap-api/CreateUserResponse.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.

export type CreateUserResponse = { id: number, name: string, roles: Array<string>, };
4 changes: 4 additions & 0 deletions src/types/btcmap-api/Dashboard.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { ChartEntry } from "./ChartEntry";

export type Dashboard = { total_merchants: number, total_merchants_chart: Array<ChartEntry>, verified_merchants_1y: number, verified_merchants_1y_chart: Array<ChartEntry>, total_exchanges: number, total_exchanges_chart: Array<ChartEntry>, verified_exchanges_1y: number, total_areas: number, verified_areas_1y: number, };
3 changes: 3 additions & 0 deletions src/types/btcmap-api/Invoice.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.

export type Invoice = { id: string, status: string, };
15 changes: 15 additions & 0 deletions src/types/btcmap-api/MeResponse.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { SavedArea } from "./SavedArea";
import type { SavedPlace } from "./SavedPlace";

export type MeResponse = { id: number, name: string, roles: Array<string>, saved_places: Array<SavedPlace>, saved_areas: Array<SavedArea>,
/**
* Area ids the user is restricted to when acting as an event manager.
* Empty means unrestricted.
*/
geofence: Array<number>,
/**
* Bech32 npub (`npub1...`) of the Nostr identity linked to this user,
* or `null` when no pubkey is linked.
*/
npub: string | null, };
7 changes: 7 additions & 0 deletions src/types/btcmap-api/NostrIdentityResponse.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.

export type NostrIdentityResponse = {
/**
* Bech32 npub (`npub1...`) currently linked to the account, or `null`.
*/
npub: string | null, };
3 changes: 3 additions & 0 deletions src/types/btcmap-api/PaginationInfo.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.

export type PaginationInfo = { offset: number, limit: number, total: number, };
11 changes: 11 additions & 0 deletions src/types/btcmap-api/Place.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.

/**
* Type-export-only description of the dynamic place responses.
* `GET /v4/places` and `GET /v4/places/{id}` build their JSON at runtime
* from the `fields` query param, so every field except `id` is optional.
* Fields requested via the `osm:<tag>` passthrough appear as extra keys and
* cannot be typed statically. Kept in sync with `service::element::TAGS` by
* `place_type_covers_all_generate_tags_fields`.
*/
Comment thread
coderabbitai[bot] marked this conversation as resolved.
export type Place = { id: number, osm_id?: string, osm_url?: string, osm_edit_url?: string, lat?: number, lon?: number, name?: string, address?: string, icon?: string, phone?: string, website?: string, twitter?: string, facebook?: string, instagram?: string, line?: string, email?: string, opening_hours?: string, boosted_until?: string, required_app_url?: string, created_at?: string, updated_at?: string, deleted_at?: string, verified_at?: string, comments?: number, description?: string, image?: string, payment_provider?: string, telegram?: string, localized_name?: Record<string, string>, localized_opening_hours?: Record<string, string>, };
3 changes: 3 additions & 0 deletions src/types/btcmap-api/PlaceActivity.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.

export type PlaceActivity = { id: number, type: string, user_id: number | null, user_name?: string, user_tip?: string, created_at: string, updated_at: string, };
3 changes: 3 additions & 0 deletions src/types/btcmap-api/PlaceArea.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.

export type PlaceArea = { id: number, alias: string, tags: Record<string, unknown>, created_at: string, updated_at: string, };
3 changes: 3 additions & 0 deletions src/types/btcmap-api/PlaceBoostQuote.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.

export type PlaceBoostQuote = { quote_30d_sat: number, quote_90d_sat: number, quote_365d_sat: number, };
3 changes: 3 additions & 0 deletions src/types/btcmap-api/PlaceComment.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.

export type PlaceComment = { id: number, text: string, created_at: string, };
3 changes: 3 additions & 0 deletions src/types/btcmap-api/PlaceCommentListItem.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.

export type PlaceCommentListItem = { id: number, place_id: number, text: string, created_at: string, updated_at: string, deleted_at?: string, };
3 changes: 3 additions & 0 deletions src/types/btcmap-api/PlaceCommentQuote.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.

export type PlaceCommentQuote = { quote_sat: number, };
3 changes: 3 additions & 0 deletions src/types/btcmap-api/PlaceIssue.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.

export type PlaceIssue = { id: number, place_id: number, code: string, severity: number, created_at: string, updated_at: string, deleted_at?: string, };
3 changes: 3 additions & 0 deletions src/types/btcmap-api/PlaceIssueSummary.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.

export type PlaceIssueSummary = { element_osm_type: string, element_osm_id: number, element_name: string, issue_code: string, };
4 changes: 4 additions & 0 deletions src/types/btcmap-api/PlaceIssuesRes.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { PlaceIssueSummary } from "./PlaceIssueSummary";

export type PlaceIssuesRes = { total_issues: number, requested_issues: Array<PlaceIssueSummary>, };
3 changes: 3 additions & 0 deletions src/types/btcmap-api/PostPlaceBoostArgs.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.

export type PostPlaceBoostArgs = { place_id: string, days: number, };
3 changes: 3 additions & 0 deletions src/types/btcmap-api/PostPlaceBoostResponse.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.

export type PostPlaceBoostResponse = { invoice_id: string, invoice: string, };
3 changes: 3 additions & 0 deletions src/types/btcmap-api/PostPlaceCommentArgs.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.

export type PostPlaceCommentArgs = { place_id: string, comment: string, };
3 changes: 3 additions & 0 deletions src/types/btcmap-api/PostPlaceCommentResponse.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.

export type PostPlaceCommentResponse = { invoice_id: string, invoice: string, };
3 changes: 3 additions & 0 deletions src/types/btcmap-api/SavedArea.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.

export type SavedArea = { id: number, name: string, };
3 changes: 3 additions & 0 deletions src/types/btcmap-api/SavedPlace.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.

export type SavedPlace = { id: number, name: string, };
5 changes: 5 additions & 0 deletions src/types/btcmap-api/SearchResponse.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { PaginationInfo } from "./PaginationInfo";
import type { SearchResult } from "./SearchResult";

export type SearchResponse = { results: Array<SearchResult>, total_count: number, has_more: boolean, query: string, pagination: PaginationInfo, };
9 changes: 9 additions & 0 deletions src/types/btcmap-api/SearchResult.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { SearchedArea } from "./SearchedArea";
import type { SearchedPlace } from "./SearchedPlace";

/**
* `SearchedPlace` is boxed because it is an order of magnitude larger than
* `SearchedArea`, and clippy's `large_enum_variant` would otherwise fire.
*/
export type SearchResult = { "type": "area" } & SearchedArea | { "type": "place" } & SearchedPlace;
7 changes: 7 additions & 0 deletions src/types/btcmap-api/SearchedArea.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.

export type SearchedArea = { id: number, name: string, alias?: string,
/**
* `[west, south, east, north]`. Absent when the area has no bbox of its own.
*/
bbox?: [number, number, number, number], };
3 changes: 3 additions & 0 deletions src/types/btcmap-api/SearchedPlace.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.

export type SearchedPlace = { id: number, lat: number, lon: number, icon: string, name: string, address?: string, opening_hours?: string, comments?: number, created_at: string, updated_at: string, verified_at: string | null, osm_id?: string, phone?: string, website?: string, twitter?: string, facebook?: string, instagram?: string, line?: string, email?: string, boosted_until?: string, required_app_url?: string, description?: string, image?: string, payment_provider?: string, localized_name?: Record<string, string>, };
3 changes: 3 additions & 0 deletions src/types/btcmap-api/TopEditor.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.

export type TopEditor = { id: number, name: string, avatar_url: string | null, total_edits: number, places_created: number, places_updated: number, places_deleted: number, tip_url: string | null, };
3 changes: 3 additions & 0 deletions src/types/btcmap-api/UpdateUsernameArgs.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.

export type UpdateUsernameArgs = { username: string, };
4 changes: 3 additions & 1 deletion svelte.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ const config = {
adapter: adapter(),
alias: {
$components: 'src/components',
'$components/*': 'src/components/*'
'$components/*': 'src/components/*',
$types: 'src/types',
'$types/*': 'src/types/*'
},
serviceWorker: {
register: true,
Expand Down
Loading