bmlt-query-client 1.0.5 → 1.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +124 -0
- package/dist/app.d.ts +32 -1
- package/dist/app.js +1364 -1923
- package/dist/app.js.map +1 -1
- package/package.json +7 -7
- package/vite.config.ts +3 -1
package/AGENTS.md
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
# AGENTS.md
|
|
2
|
+
|
|
3
|
+
This file provides guidance for AI agents working in this repository.
|
|
4
|
+
|
|
5
|
+
## Project Overview
|
|
6
|
+
|
|
7
|
+
`bmlt-query-client` is a TypeScript/ES module client library for querying [BMLT (Basic Meeting List Tool)](https://bmlt.app) servers. It wraps the BMLT Semantic API with a zero-external-dependency bundle, a fluent query builder, and built-in geocoding via OpenStreetMap Nominatim.
|
|
8
|
+
|
|
9
|
+
Published to NPM as `bmlt-query-client`. Minimum Node.js version: 22.
|
|
10
|
+
|
|
11
|
+
## Repository Layout
|
|
12
|
+
|
|
13
|
+
```
|
|
14
|
+
src/
|
|
15
|
+
client/
|
|
16
|
+
bmlt-client.ts # Main BmltClient class — primary public API
|
|
17
|
+
query-builder.ts # MeetingQueryBuilder (fluent) and QuickSearch helpers
|
|
18
|
+
services/
|
|
19
|
+
geocoding.ts # Nominatim geocoding with rate limiting and retry
|
|
20
|
+
types/
|
|
21
|
+
base.ts # Enums: BmltDataFormat, BmltEndpoint, Weekday, VenueType, etc.
|
|
22
|
+
requests.ts # Request parameter interfaces for each BMLT endpoint
|
|
23
|
+
responses.ts # Response types: Meeting, Format, ServiceBody, etc.
|
|
24
|
+
index.ts # Re-exports all types
|
|
25
|
+
utils/
|
|
26
|
+
errors.ts # BmltQueryError, BmltErrorType enum, ErrorHandler
|
|
27
|
+
url-builder.ts # URL construction and parameter validation
|
|
28
|
+
index.ts # Public package exports
|
|
29
|
+
|
|
30
|
+
test/
|
|
31
|
+
basic.test.ts # Integration tests against the NYC BMLT demo server
|
|
32
|
+
setup.ts # Vitest setup
|
|
33
|
+
|
|
34
|
+
examples/
|
|
35
|
+
basic-usage.ts # Runnable usage examples
|
|
36
|
+
|
|
37
|
+
docs/
|
|
38
|
+
index.html # Browser demo using the ES module directly
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Common Commands
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
npm install # Install dependencies
|
|
45
|
+
npm run build # Compile TypeScript → dist/ (Vite + vite-plugin-dts)
|
|
46
|
+
npm run type-check # Type-check without emitting
|
|
47
|
+
npm run lint # ESLint on src/
|
|
48
|
+
npm run format # Prettier auto-format
|
|
49
|
+
npm run format:check # Check formatting without modifying files
|
|
50
|
+
npm test # Run Vitest integration tests (requires network)
|
|
51
|
+
npm run clean # Delete dist/
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Build Output
|
|
55
|
+
|
|
56
|
+
Vite produces a single ES module bundle:
|
|
57
|
+
|
|
58
|
+
- `dist/app.js` — bundle with p-queue and p-retry inlined (~55 KB, ~15 KB gzipped)
|
|
59
|
+
- `dist/app.d.ts` — TypeScript declarations (generated by vite-plugin-dts)
|
|
60
|
+
- `dist/app.js.map` — source map
|
|
61
|
+
|
|
62
|
+
The package is ESM-only (`"type": "module"` in package.json). Do not add CommonJS output.
|
|
63
|
+
|
|
64
|
+
## Testing
|
|
65
|
+
|
|
66
|
+
Tests in `test/basic.test.ts` are **integration tests** that call the live NYC BMLT demo server (`https://latest.aws.bmlt.app/main_server`). There are no unit tests with mocks.
|
|
67
|
+
|
|
68
|
+
- Run `npm test` to execute all tests.
|
|
69
|
+
- Tests verify real API response shapes and client behaviour including error scenarios.
|
|
70
|
+
- Do not add mock-based tests; keep tests hitting the real demo server.
|
|
71
|
+
- If a test requires network access and CI is offline, mark it with `test.skip`.
|
|
72
|
+
|
|
73
|
+
## Code Style
|
|
74
|
+
|
|
75
|
+
Enforced by Prettier and ESLint — run `npm run format` and `npm run lint` before committing.
|
|
76
|
+
|
|
77
|
+
Key rules:
|
|
78
|
+
|
|
79
|
+
- 2-space indentation, single quotes, semicolons required, trailing commas (ES5), 100-char line width.
|
|
80
|
+
- `const` over `let`; `var` is banned.
|
|
81
|
+
- TypeScript strict mode is on; avoid `any`.
|
|
82
|
+
- Arrow functions: no parentheses for single parameters (`x => x`, not `(x) => x`).
|
|
83
|
+
|
|
84
|
+
## Architecture Constraints
|
|
85
|
+
|
|
86
|
+
- **Zero runtime dependencies in the bundle.** `p-queue` and `p-retry` are bundled via Vite. Do not add new production dependencies without bundling them. Verify with `npm run build` and inspect `dist/app.js`.
|
|
87
|
+
- **No CommonJS.** All source files use ES module syntax (`import`/`export`). `tsconfig.json` targets `ESNext` modules.
|
|
88
|
+
- **Native fetch only.** HTTP requests use the global `fetch` API (Node 22 built-in). Do not introduce axios, node-fetch, or similar.
|
|
89
|
+
- **Enums over magic strings.** Use `Weekday`, `VenueType`, `BmltEndpoint`, etc. when representing BMLT-specific values.
|
|
90
|
+
- **Custom error types.** Throw `BmltQueryError` (from `src/utils/errors.ts`), never plain `Error`, for library errors. Use `BmltErrorType` to classify the error.
|
|
91
|
+
|
|
92
|
+
## Adding or Changing API Surface
|
|
93
|
+
|
|
94
|
+
1. Add or update the relevant type in `src/types/requests.ts` or `src/types/responses.ts`.
|
|
95
|
+
2. Implement or update the method in `src/client/bmlt-client.ts`.
|
|
96
|
+
3. If the feature is chainable, expose it via `MeetingQueryBuilder` in `src/client/query-builder.ts`.
|
|
97
|
+
4. Export any new public types from `src/types/index.ts` and any new public classes/functions from `src/index.ts`.
|
|
98
|
+
5. Add a usage example in `examples/basic-usage.ts`.
|
|
99
|
+
6. Add or extend a test in `test/basic.test.ts`.
|
|
100
|
+
|
|
101
|
+
## Geocoding
|
|
102
|
+
|
|
103
|
+
The geocoding service (`src/services/geocoding.ts`) calls OpenStreetMap Nominatim. Key constraints:
|
|
104
|
+
|
|
105
|
+
- Rate limit: 1 request per second by default (configurable via `GeocodeOptions`).
|
|
106
|
+
- Uses `p-queue` for queuing and `p-retry` for exponential backoff.
|
|
107
|
+
- Respects Nominatim's usage policy — do not remove the rate limiter.
|
|
108
|
+
- Default country bias: `'us'`. Callers can override via `GeocodeOptions`.
|
|
109
|
+
|
|
110
|
+
## CI/CD
|
|
111
|
+
|
|
112
|
+
GitHub Actions (`.github/workflows/ci-cd.yml`):
|
|
113
|
+
|
|
114
|
+
- **test job**: runs on push and PRs; matrix over Node 22 and 24; runs lint → build → test.
|
|
115
|
+
- **publish job**: triggered on version tags (`v*`); publishes to NPM using `NPM_TOKEN` secret and creates a GitHub Release.
|
|
116
|
+
- **security job**: runs `npm audit --audit-level moderate` on every push/PR.
|
|
117
|
+
|
|
118
|
+
Publishing is tag-driven. To release, create and push a semver tag (e.g., `v1.1.0`).
|
|
119
|
+
|
|
120
|
+
## Key Invariants
|
|
121
|
+
|
|
122
|
+
- `dist/` is generated and must not be committed.
|
|
123
|
+
- `package.json` version is updated automatically by the publish CI job from the git tag.
|
|
124
|
+
- The BMLT demo server URL (`https://latest.aws.bmlt.app/main_server`) is used only in tests and examples — it must not be hardcoded in library source.
|
package/dist/app.d.ts
CHANGED
|
@@ -22,6 +22,16 @@ export declare class BmltClient {
|
|
|
22
22
|
* Search for meetings
|
|
23
23
|
*/
|
|
24
24
|
searchMeetings(params?: SearchResultsParams): Promise<Meeting[]>;
|
|
25
|
+
/**
|
|
26
|
+
* Search for meetings and return both meetings and the formats they reference in a
|
|
27
|
+
* single request. Uses get_used_formats=true so the server wraps the response as
|
|
28
|
+
* { meetings: Meeting[], formats: Format[] } instead of a bare Meeting[].
|
|
29
|
+
*
|
|
30
|
+
* This replaces the common pattern of Promise.all([getFormats(), searchMeetings()])
|
|
31
|
+
* with a single round-trip, which matters for large servers where getFormats() can
|
|
32
|
+
* return hundreds of unused format records.
|
|
33
|
+
*/
|
|
34
|
+
searchMeetingsWithFormats(params?: Omit<SearchResultsParams, 'get_used_formats' | 'get_formats_only'>): Promise<MeetingsWithFormats>;
|
|
25
35
|
/**
|
|
26
36
|
* Search for meetings by geographic location using geocoding
|
|
27
37
|
*/
|
|
@@ -364,7 +374,7 @@ export declare interface FieldValuesParams extends BaseSearchParams {
|
|
|
364
374
|
|
|
365
375
|
export declare interface Format {
|
|
366
376
|
/** Format ID */
|
|
367
|
-
|
|
377
|
+
id: string;
|
|
368
378
|
/** Format key string */
|
|
369
379
|
key_string: string;
|
|
370
380
|
/** Format name */
|
|
@@ -373,6 +383,10 @@ export declare interface Format {
|
|
|
373
383
|
description_string: string;
|
|
374
384
|
/** Language */
|
|
375
385
|
lang: string;
|
|
386
|
+
/** World format ID */
|
|
387
|
+
world_id?: string;
|
|
388
|
+
/** Format type enum */
|
|
389
|
+
format_type_enum?: string;
|
|
376
390
|
/** Root server URI (for aggregator mode) */
|
|
377
391
|
root_server_uri?: string;
|
|
378
392
|
}
|
|
@@ -718,12 +732,29 @@ export declare class MeetingQueryBuilder {
|
|
|
718
732
|
* Execute the search and return results
|
|
719
733
|
*/
|
|
720
734
|
execute(): Promise<Meeting[]>;
|
|
735
|
+
/**
|
|
736
|
+
* Execute the search and return both meetings and the formats they reference
|
|
737
|
+
* in a single request. Equivalent to execute() but avoids a separate getFormats() call.
|
|
738
|
+
*/
|
|
739
|
+
executeWithFormats(): Promise<MeetingsWithFormats>;
|
|
721
740
|
/**
|
|
722
741
|
* Execute the search by geocoding an address first
|
|
723
742
|
*/
|
|
724
743
|
executeNearAddress(address: string, radiusMiles?: number, radiusKm?: number, sortByDistance?: boolean): Promise<Meeting[]>;
|
|
725
744
|
}
|
|
726
745
|
|
|
746
|
+
/**
|
|
747
|
+
* Combined response when get_used_formats=true is passed to GetSearchResults.
|
|
748
|
+
* The BMLT API wraps the response in an object with separate meetings and formats arrays
|
|
749
|
+
* instead of returning a bare meetings array.
|
|
750
|
+
*/
|
|
751
|
+
export declare interface MeetingsWithFormats {
|
|
752
|
+
/** Meetings matching the search criteria */
|
|
753
|
+
meetings: Meeting[];
|
|
754
|
+
/** Only the formats actually referenced by the returned meetings */
|
|
755
|
+
formats: Format[];
|
|
756
|
+
}
|
|
757
|
+
|
|
727
758
|
/**
|
|
728
759
|
* Convert miles to kilometers
|
|
729
760
|
*/
|