mcp-grampsweb 1.0.0

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.
Files changed (67) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +133 -0
  3. package/dist/auth.d.ts +37 -0
  4. package/dist/auth.d.ts.map +1 -0
  5. package/dist/auth.js +119 -0
  6. package/dist/auth.js.map +1 -0
  7. package/dist/client.d.ts +44 -0
  8. package/dist/client.d.ts.map +1 -0
  9. package/dist/client.js +153 -0
  10. package/dist/client.js.map +1 -0
  11. package/dist/config.d.ts +11 -0
  12. package/dist/config.d.ts.map +1 -0
  13. package/dist/config.js +32 -0
  14. package/dist/config.js.map +1 -0
  15. package/dist/constants.d.ts +24 -0
  16. package/dist/constants.d.ts.map +1 -0
  17. package/dist/constants.js +50 -0
  18. package/dist/constants.js.map +1 -0
  19. package/dist/index.d.ts +9 -0
  20. package/dist/index.d.ts.map +1 -0
  21. package/dist/index.js +132 -0
  22. package/dist/index.js.map +1 -0
  23. package/dist/schemas/common.d.ts +308 -0
  24. package/dist/schemas/common.d.ts.map +1 -0
  25. package/dist/schemas/common.js +120 -0
  26. package/dist/schemas/common.js.map +1 -0
  27. package/dist/schemas/entities.d.ts +1165 -0
  28. package/dist/schemas/entities.d.ts.map +1 -0
  29. package/dist/schemas/entities.js +125 -0
  30. package/dist/schemas/entities.js.map +1 -0
  31. package/dist/schemas/index.d.ts +7 -0
  32. package/dist/schemas/index.d.ts.map +1 -0
  33. package/dist/schemas/index.js +7 -0
  34. package/dist/schemas/index.js.map +1 -0
  35. package/dist/schemas/search.d.ts +47 -0
  36. package/dist/schemas/search.d.ts.map +1 -0
  37. package/dist/schemas/search.js +24 -0
  38. package/dist/schemas/search.js.map +1 -0
  39. package/dist/tools/analysis.d.ts +115 -0
  40. package/dist/tools/analysis.d.ts.map +1 -0
  41. package/dist/tools/analysis.js +387 -0
  42. package/dist/tools/analysis.js.map +1 -0
  43. package/dist/tools/create.d.ts +355 -0
  44. package/dist/tools/create.d.ts.map +1 -0
  45. package/dist/tools/create.js +547 -0
  46. package/dist/tools/create.js.map +1 -0
  47. package/dist/tools/index.d.ts +468 -0
  48. package/dist/tools/index.d.ts.map +1 -0
  49. package/dist/tools/index.js +17 -0
  50. package/dist/tools/index.js.map +1 -0
  51. package/dist/tools/search.d.ts +95 -0
  52. package/dist/tools/search.d.ts.map +1 -0
  53. package/dist/tools/search.js +161 -0
  54. package/dist/tools/search.js.map +1 -0
  55. package/dist/types.d.ts +210 -0
  56. package/dist/types.d.ts.map +1 -0
  57. package/dist/types.js +5 -0
  58. package/dist/types.js.map +1 -0
  59. package/dist/utils/errors.d.ts +19 -0
  60. package/dist/utils/errors.d.ts.map +1 -0
  61. package/dist/utils/errors.js +48 -0
  62. package/dist/utils/errors.js.map +1 -0
  63. package/dist/utils/formatting.d.ts +60 -0
  64. package/dist/utils/formatting.d.ts.map +1 -0
  65. package/dist/utils/formatting.js +256 -0
  66. package/dist/utils/formatting.js.map +1 -0
  67. package/package.json +48 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,133 @@
1
+ # mcp-grampsweb
2
+
3
+ An MCP (Model Context Protocol) server for interacting with [Gramps Web](https://www.grampsweb.org/) genealogy API. This allows AI assistants like Claude to search, retrieve, and create genealogical records in your Gramps Web instance.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npx mcp-grampsweb
9
+ ```
10
+
11
+ Or install globally:
12
+
13
+ ```bash
14
+ npm install -g mcp-grampsweb
15
+ ```
16
+
17
+ ## Configuration
18
+
19
+ The server requires the following environment variables:
20
+
21
+ | Variable | Description | Required |
22
+ |----------|-------------|----------|
23
+ | `GRAMPS_API_URL` | Base URL of your Gramps Web instance (e.g., `https://gramps.example.com`) | Yes |
24
+ | `GRAMPS_USERNAME` | Your Gramps Web username | Yes |
25
+ | `GRAMPS_PASSWORD` | Your Gramps Web password | Yes |
26
+ | `GRAMPS_TREE_ID` | Tree ID for multi-tree instances (requests use `/api/trees/{id}/...`) | No |
27
+
28
+ ## Usage with Claude Desktop
29
+
30
+ Add the following to your Claude Desktop configuration file:
31
+
32
+ **macOS**: `~/Library/Application Support/Claude/claude_desktop_config.json`
33
+ **Windows**: `%APPDATA%\Claude\claude_desktop_config.json`
34
+
35
+ ```json
36
+ {
37
+ "mcpServers": {
38
+ "grampsweb": {
39
+ "command": "npx",
40
+ "args": ["mcp-grampsweb"],
41
+ "env": {
42
+ "GRAMPS_API_URL": "https://your-gramps-web.com",
43
+ "GRAMPS_USERNAME": "your-username",
44
+ "GRAMPS_PASSWORD": "your-password",
45
+ "GRAMPS_TREE_ID": "optional-tree-id"
46
+ }
47
+ }
48
+ }
49
+ }
50
+ ```
51
+
52
+ ## Available Tools
53
+
54
+ ### Search & Retrieval
55
+
56
+ | Tool | Description |
57
+ |------|-------------|
58
+ | `gramps_search` | GQL-based search for any entity type (people, families, events, places, etc.) |
59
+ | `gramps_find` | Full-text search across all records |
60
+ | `gramps_get` | Get full entity details by handle or Gramps ID |
61
+
62
+ ### Data Management
63
+
64
+ | Tool | Description |
65
+ |------|-------------|
66
+ | `gramps_create_person` | Create a new person record |
67
+ | `gramps_create_family` | Create a new family unit |
68
+ | `gramps_create_event` | Create a new life event (birth, death, marriage, etc.) |
69
+ | `gramps_create_place` | Create a new geographic location |
70
+ | `gramps_create_source` | Create a new source document |
71
+ | `gramps_create_citation` | Create a new citation |
72
+ | `gramps_create_note` | Create a new textual note |
73
+ | `gramps_create_media` | Create a new media object |
74
+ | `gramps_create_repository` | Create a new repository |
75
+
76
+ ### Analysis
77
+
78
+ | Tool | Description |
79
+ |------|-------------|
80
+ | `gramps_tree_stats` | Get tree statistics (counts of all entity types) |
81
+ | `gramps_get_ancestors` | Find ancestors of a person (up to 10 generations) |
82
+ | `gramps_get_descendants` | Find descendants of a person (up to 10 generations) |
83
+ | `gramps_recent_changes` | Get recently modified records |
84
+
85
+ ## Examples
86
+
87
+ ### Search for people with a specific surname
88
+
89
+ ```
90
+ Use gramps_search to find people with surname "Smith"
91
+ ```
92
+
93
+ ### Get ancestors of a person
94
+
95
+ ```
96
+ Find the ancestors of person with handle "abc123" going back 4 generations
97
+ ```
98
+
99
+ ### Create a new person
100
+
101
+ ```
102
+ Create a person named John Smith, male gender
103
+ ```
104
+
105
+ ## Development
106
+
107
+ ```bash
108
+ # Clone the repository
109
+ git clone https://github.com/nikkoxgonzales/mcp-grampsweb.git
110
+ cd mcp-grampsweb
111
+
112
+ # Install dependencies
113
+ npm install
114
+
115
+ # Build
116
+ npm run build
117
+
118
+ # Run tests
119
+ npm test
120
+
121
+ # Run in development mode
122
+ npm run dev
123
+ ```
124
+
125
+ ### Testing with MCP Inspector
126
+
127
+ ```bash
128
+ npx @modelcontextprotocol/inspector node dist/index.js
129
+ ```
130
+
131
+ ## License
132
+
133
+ MIT
package/dist/auth.d.ts ADDED
@@ -0,0 +1,37 @@
1
+ /**
2
+ * JWT Authentication singleton for Gramps Web API
3
+ */
4
+ import type { Config } from "./config.js";
5
+ declare class AuthManager {
6
+ private token;
7
+ private tokenExpiry;
8
+ private config;
9
+ private refreshPromise;
10
+ /**
11
+ * Initialize the auth manager with configuration
12
+ */
13
+ initialize(config: Config): void;
14
+ /**
15
+ * Get a valid access token, refreshing if necessary
16
+ */
17
+ getToken(): Promise<string>;
18
+ /**
19
+ * Force a token refresh
20
+ */
21
+ refreshToken(): Promise<string>;
22
+ /**
23
+ * Extract expiry time from JWT token
24
+ */
25
+ private extractExpiry;
26
+ /**
27
+ * Clear the cached token
28
+ */
29
+ clearToken(): void;
30
+ /**
31
+ * Check if we have a valid token
32
+ */
33
+ hasValidToken(): boolean;
34
+ }
35
+ export declare const authManager: AuthManager;
36
+ export {};
37
+ //# sourceMappingURL=auth.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAG1C,cAAM,WAAW;IACf,OAAO,CAAC,KAAK,CAAuB;IACpC,OAAO,CAAC,WAAW,CAAa;IAChC,OAAO,CAAC,MAAM,CAAuB;IACrC,OAAO,CAAC,cAAc,CAAgC;IAEtD;;OAEG;IACH,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAMhC;;OAEG;IACG,QAAQ,IAAI,OAAO,CAAC,MAAM,CAAC;IA0BjC;;OAEG;IACG,YAAY,IAAI,OAAO,CAAC,MAAM,CAAC;IAwCrC;;OAEG;IACH,OAAO,CAAC,aAAa;IA2BrB;;OAEG;IACH,UAAU,IAAI,IAAI;IAKlB;;OAEG;IACH,aAAa,IAAI,OAAO;CAGzB;AAGD,eAAO,MAAM,WAAW,aAAoB,CAAC"}
package/dist/auth.js ADDED
@@ -0,0 +1,119 @@
1
+ /**
2
+ * JWT Authentication singleton for Gramps Web API
3
+ */
4
+ import { API_ENDPOINTS, TOKEN_EXPIRY_BUFFER_MS } from "./constants.js";
5
+ import { AuthenticationError } from "./utils/errors.js";
6
+ class AuthManager {
7
+ token = null;
8
+ tokenExpiry = 0;
9
+ config = null;
10
+ refreshPromise = null;
11
+ /**
12
+ * Initialize the auth manager with configuration
13
+ */
14
+ initialize(config) {
15
+ this.config = config;
16
+ this.token = null;
17
+ this.tokenExpiry = 0;
18
+ }
19
+ /**
20
+ * Get a valid access token, refreshing if necessary
21
+ */
22
+ async getToken() {
23
+ if (!this.config) {
24
+ throw new AuthenticationError("Auth manager not initialized");
25
+ }
26
+ // Return cached token if still valid
27
+ if (this.token && Date.now() < this.tokenExpiry) {
28
+ return this.token;
29
+ }
30
+ // If already refreshing, wait for that promise
31
+ if (this.refreshPromise) {
32
+ return this.refreshPromise;
33
+ }
34
+ // Refresh the token
35
+ this.refreshPromise = this.refreshToken();
36
+ try {
37
+ const token = await this.refreshPromise;
38
+ return token;
39
+ }
40
+ finally {
41
+ this.refreshPromise = null;
42
+ }
43
+ }
44
+ /**
45
+ * Force a token refresh
46
+ */
47
+ async refreshToken() {
48
+ if (!this.config) {
49
+ throw new AuthenticationError("Auth manager not initialized");
50
+ }
51
+ const url = `${this.config.apiUrl}/api${API_ENDPOINTS.TOKEN}`;
52
+ // Gramps Web expects form-urlencoded data for token endpoint
53
+ const body = new URLSearchParams({
54
+ username: this.config.username,
55
+ password: this.config.password,
56
+ });
57
+ const response = await fetch(url, {
58
+ method: "POST",
59
+ headers: {
60
+ "Content-Type": "application/x-www-form-urlencoded",
61
+ },
62
+ body: body.toString(),
63
+ });
64
+ if (!response.ok) {
65
+ const errorText = await response.text();
66
+ throw new AuthenticationError(`Failed to authenticate: ${response.status} ${response.statusText}. ${errorText}`);
67
+ }
68
+ const data = (await response.json());
69
+ if (!data.access_token) {
70
+ throw new AuthenticationError("No access token in response");
71
+ }
72
+ this.token = data.access_token;
73
+ this.tokenExpiry = this.extractExpiry(data.access_token);
74
+ return this.token;
75
+ }
76
+ /**
77
+ * Extract expiry time from JWT token
78
+ */
79
+ extractExpiry(token) {
80
+ try {
81
+ // JWT format: header.payload.signature
82
+ const parts = token.split(".");
83
+ if (parts.length !== 3) {
84
+ // Can't decode, use default expiry (1 hour)
85
+ return Date.now() + 60 * 60 * 1000 - TOKEN_EXPIRY_BUFFER_MS;
86
+ }
87
+ // Decode the payload (base64url)
88
+ const payload = parts[1];
89
+ const decoded = Buffer.from(payload, "base64url").toString("utf-8");
90
+ const parsed = JSON.parse(decoded);
91
+ if (parsed.exp) {
92
+ // exp is in seconds, convert to ms and subtract buffer
93
+ return parsed.exp * 1000 - TOKEN_EXPIRY_BUFFER_MS;
94
+ }
95
+ // No exp claim, use default
96
+ return Date.now() + 60 * 60 * 1000 - TOKEN_EXPIRY_BUFFER_MS;
97
+ }
98
+ catch {
99
+ // Failed to parse, use default expiry
100
+ return Date.now() + 60 * 60 * 1000 - TOKEN_EXPIRY_BUFFER_MS;
101
+ }
102
+ }
103
+ /**
104
+ * Clear the cached token
105
+ */
106
+ clearToken() {
107
+ this.token = null;
108
+ this.tokenExpiry = 0;
109
+ }
110
+ /**
111
+ * Check if we have a valid token
112
+ */
113
+ hasValidToken() {
114
+ return this.token !== null && Date.now() < this.tokenExpiry;
115
+ }
116
+ }
117
+ // Export singleton instance
118
+ export const authManager = new AuthManager();
119
+ //# sourceMappingURL=auth.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth.js","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,aAAa,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AACvE,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAIxD,MAAM,WAAW;IACP,KAAK,GAAkB,IAAI,CAAC;IAC5B,WAAW,GAAW,CAAC,CAAC;IACxB,MAAM,GAAkB,IA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AG,KAAK,CAAC,CAAC,CAAC,CAAC;YACzB,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;YACpE,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAe,CAAC;YAEjD,IAAI,MAAM,CAAC,GAAG,EAAE,CAAC;gBACf,uDAAuD;gBACvD,OAAO,MAAM,CAAC,GAAG,GAAG,IAAI,GAAG,sBAAsB,CAAC;YACpD,CAAC;YAED,4BAA4B;YAC5B,OAAO,IAAI,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,GAAG,sBAAsB,CAAC;QAC9D,CAAC;QAAC,MAAM,CAAC;YACP,sCAAsC;YACtC,OAAO,IAAI,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,GAAG,sBAAsB,CAAC;QAC9D,CAAC;IACH,CAAC;IAED;;OAEG;IACH,UAAU;QACR,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,IAAI,CAAC,WAAW,GAAG,CAAC,CAAC;IACvB,CAAC;IAED;;OAEG;IACH,aAAa;QACX,OAAO,IAAI,CAAC,KAAK,KAAK,IAAI,IAAI,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,WAAW,CAAC;IAC9D,CAAC;CACF;AAED,4BAA4B;AAC5B,MAAM,CAAC,MAAM,WAAW,GAAG,IAAI,WAAW,EAAE,CAAC"}
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Gramps Web API Client
3
+ */
4
+ import type { Config } from "./config.js";
5
+ export interface RequestOptions {
6
+ method?: "GET" | "POST" | "PUT" | "DELETE";
7
+ body?: unknown;
8
+ params?: Record<string, string | number | boolean | undefined>;
9
+ timeout?: number;
10
+ }
11
+ declare class GrampsClient {
12
+ private baseUrl;
13
+ /**
14
+ * Initialize the client with configuration
15
+ */
16
+ initialize(config: Config): void;
17
+ /**
18
+ * Make an authenticated request to the Gramps API
19
+ */
20
+ request<T>(endpoint: string, options?: RequestOptions): Promise<T>;
21
+ /**
22
+ * Handle error responses
23
+ */
24
+ private handleErrorResponse;
25
+ /**
26
+ * GET request helper
27
+ */
28
+ get<T>(endpoint: string, params?: Record<string, string | number | boolean | undefined>): Promise<T>;
29
+ /**
30
+ * POST request helper
31
+ */
32
+ post<T>(endpoint: string, body?: unknown): Promise<T>;
33
+ /**
34
+ * PUT request helper
35
+ */
36
+ put<T>(endpoint: string, body?: unknown): Promise<T>;
37
+ /**
38
+ * DELETE request helper
39
+ */
40
+ delete<T>(endpoint: string): Promise<T>;
41
+ }
42
+ export declare const grampsClient: GrampsClient;
43
+ export {};
44
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;GAEG;AAKH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAE1C,MAAM,WAAW,cAAc;IAC7B,MAAM,CAAC,EAAE,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,QAAQ,CAAC;IAC3C,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC,CAAC;IAC/D,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,cAAM,YAAY;IAChB,OAAO,CAAC,OAAO,CAAc;IAE7B;;OAEG;IACH,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAQhC;;OAEG;IACG,OAAO,CAAC,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,GAAE,cAAmB,GAAG,OAAO,CAAC,CAAC,CAAC;IA6F5E;;OAEG;YACW,mBAAmB;IAwBjC;;OAEG;IACG,GAAG,CAAC,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;IAI1G;;OAEG;IACG,IAAI,CAAC,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,CAAC,CAAC;IAI3D;;OAEG;IACG,GAAG,CAAC,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,CAAC,CAAC;IAI1D;;OAEG;IACG,MAAM,CAAC,CAAC,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC;CAG9C;AAGD,eAAO,MAAM,YAAY,cAAqB,CAAC"}
package/dist/client.js ADDED
@@ -0,0 +1,153 @@
1
+ /**
2
+ * Gramps Web API Client
3
+ */
4
+ import { authManager } from "./auth.js";
5
+ import { GrampsAPIError, NotFoundError } from "./utils/errors.js";
6
+ import { DEFAULT_TIMEOUT_MS } from "./constants.js";
7
+ class GrampsClient {
8
+ baseUrl = "";
9
+ /**
10
+ * Initialize the client with configuration
11
+ */
12
+ initialize(config) {
13
+ if (config.treeId) {
14
+ this.baseUrl = `${config.apiUrl}/api/trees/${config.treeId}`;
15
+ }
16
+ else {
17
+ this.baseUrl = `${config.apiUrl}/api`;
18
+ }
19
+ }
20
+ /**
21
+ * Make an authenticated request to the Gramps API
22
+ */
23
+ async request(endpoint, options = {}) {
24
+ const { method = "GET", body, params, timeout = DEFAULT_TIMEOUT_MS } = options;
25
+ // Build URL with query params
26
+ let url = `${this.baseUrl}${endpoint}`;
27
+ if (params) {
28
+ const searchParams = new URLSearchParams();
29
+ for (const [key, value] of Object.entries(params)) {
30
+ if (value !== undefined) {
31
+ searchParams.append(key, String(value));
32
+ }
33
+ }
34
+ const queryString = searchParams.toString();
35
+ if (queryString) {
36
+ url += `?${queryString}`;
37
+ }
38
+ }
39
+ // Get auth token
40
+ const token = await authManager.getToken();
41
+ // Prepare headers
42
+ const headers = {
43
+ Authorization: `Bearer ${token}`,
44
+ Accept: "application/json",
45
+ };
46
+ if (body) {
47
+ headers["Content-Type"] = "application/json";
48
+ }
49
+ // Create abort controller for timeout
50
+ const controller = new AbortController();
51
+ const timeoutId = setTimeout(() => controller.abort(), timeout);
52
+ try {
53
+ const response = await fetch(url, {
54
+ method,
55
+ headers,
56
+ body: body ? JSON.stringify(body) : undefined,
57
+ signal: controller.signal,
58
+ });
59
+ // Handle 401 - try refreshing token once
60
+ if (response.status === 401) {
61
+ authManager.clearToken();
62
+ const newToken = await authManager.refreshToken();
63
+ headers.Authorization = `Bearer ${newToken}`;
64
+ const retryResponse = await fetch(url, {
65
+ method,
66
+ headers,
67
+ body: body ? JSON.stringify(body) : undefined,
68
+ signal: controller.signal,
69
+ });
70
+ if (!retryResponse.ok) {
71
+ await this.handleErrorResponse(retryResponse, endpoint);
72
+ }
73
+ return (await retryResponse.json());
74
+ }
75
+ if (!response.ok) {
76
+ await this.handleErrorResponse(response, endpoint);
77
+ }
78
+ // Handle empty responses
79
+ const text = await response.text();
80
+ if (!text) {
81
+ return {};
82
+ }
83
+ return JSON.parse(text);
84
+ }
85
+ catch (error) {
86
+ if (error instanceof GrampsAPIError) {
87
+ throw error;
88
+ }
89
+ if (error instanceof Error) {
90
+ if (error.name === "AbortError") {
91
+ throw new GrampsAPIError(`Request timeout after ${timeout}ms`, undefined, endpoint);
92
+ }
93
+ throw new GrampsAPIError(error.message, undefined, endpoint);
94
+ }
95
+ throw new GrampsAPIError(String(error), undefined, endpoint);
96
+ }
97
+ finally {
98
+ clearTimeout(timeoutId);
99
+ }
100
+ }
101
+ /**
102
+ * Handle error responses
103
+ */
104
+ async handleErrorResponse(response, endpoint) {
105
+ let message = `${response.status} ${response.statusText}`;
106
+ try {
107
+ const errorBody = await response.text();
108
+ if (errorBody) {
109
+ const parsed = JSON.parse(errorBody);
110
+ if (parsed.detail) {
111
+ message = parsed.detail;
112
+ }
113
+ else if (parsed.message) {
114
+ message = parsed.message;
115
+ }
116
+ }
117
+ }
118
+ catch {
119
+ // Ignore JSON parse errors
120
+ }
121
+ if (response.status === 404) {
122
+ throw new NotFoundError("Resource", endpoint);
123
+ }
124
+ throw new GrampsAPIError(message, response.status, endpoint);
125
+ }
126
+ /**
127
+ * GET request helper
128
+ */
129
+ async get(endpoint, params) {
130
+ return this.request(endpoint, { method: "GET", params });
131
+ }
132
+ /**
133
+ * POST request helper
134
+ */
135
+ async post(endpoint, body) {
136
+ return this.request(endpoint, { method: "POST", body });
137
+ }
138
+ /**
139
+ * PUT request helper
140
+ */
141
+ async put(endpoint, body) {
142
+ return this.request(endpoint, { method: "PUT", body });
143
+ }
144
+ /**
145
+ * DELETE request helper
146
+ */
147
+ async delete(endpoint) {
148
+ return this.request(endpoint, { method: "DELETE" });
149
+ }
150
+ }
151
+ // Export singleton instance
152
+ export const grampsClient = new GrampsClient();
153
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClE,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAUpD,MAAM,YAAY;IACR,OAAO,GAAW,EAAE,CAAC;IAE7B;;OAEG;IACH,UAAU,CAAC,MAAc;QACvB,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;YAClB,IAAI,CAAC,OAAO,GAAG,GAAG,MAAM,CAAC,MAAM,cAAc,MAAM,CAAC,MAAM,EAAE,CAAC;QAC/D,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,OAAO,GAAG,GAAG,MAAM,CAAC,MAAM,MAAM,CAAC;QACxC,CAAC;IACH,CAAC;IAED;;OAEG;IAC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;YAC5B,MAAM,IAAI,aAAa,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;QAChD,CAAC;QAED,MAAM,IAAI,cAAc,CAAC,OAAO,EAAE,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IAC/D,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,GAAG,CAAI,QAAgB,EAAE,MAA8D;QAC3F,OAAO,IAAI,CAAC,OAAO,CAAI,QAAQ,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC;IAC9D,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,IAAI,CAAI,QAAgB,EAAE,IAAc;QAC5C,OAAO,IAAI,CAAC,OAAO,CAAI,QAAQ,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;IAC7D,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,GAAG,CAAI,QAAgB,EAAE,IAAc;QAC3C,OAAO,IAAI,CAAC,OAAO,CAAI,QAAQ,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IAC5D,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,MAAM,CAAI,QAAgB;QAC9B,OAAO,IAAI,CAAC,OAAO,CAAI,QAAQ,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,CAAC;IACzD,CAAC;CACF;AAED,4BAA4B;AAC5B,MAAM,CAAC,MAAM,YAAY,GAAG,IAAI,YAAY,EAAE,CAAC"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Environment configuration with validation
3
+ */
4
+ export interface Config {
5
+ apiUrl: string;
6
+ username: string;
7
+ password: string;
8
+ treeId?: string;
9
+ }
10
+ export declare function loadConfig(): Config;
11
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,WAAW,MAAM;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,wBAAgB,UAAU,IAAI,MAAM,CA+BnC"}
package/dist/config.js ADDED
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Environment configuration with validation
3
+ */
4
+ export function loadConfig() {
5
+ const apiUrl = process.env.GRAMPS_API_URL;
6
+ const username = process.env.GRAMPS_USERNAME;
7
+ const password = process.env.GRAMPS_PASSWORD;
8
+ const treeId = process.env.GRAMPS_TREE_ID;
9
+ const missing = [];
10
+ if (!apiUrl)
11
+ missing.push("GRAMPS_API_URL");
12
+ if (!username)
13
+ missing.push("GRAMPS_USERNAME");
14
+ if (!password)
15
+ missing.push("GRAMPS_PASSWORD");
16
+ if (missing.length > 0 || !apiUrl || !username || !password) {
17
+ throw new Error(`Missing required environment variables: ${missing.join(", ")}\n\n` +
18
+ "Please configure the following environment variables:\n" +
19
+ " GRAMPS_API_URL - Base URL of your Gramps Web instance (e.g., https://gramps.example.com)\n" +
20
+ " GRAMPS_USERNAME - Your Gramps Web username\n" +
21
+ " GRAMPS_PASSWORD - Your Gramps Web password");
22
+ }
23
+ // Normalize the API URL (remove trailing slash)
24
+ const normalizedUrl = apiUrl.replace(/\/+$/, "");
25
+ return {
26
+ apiUrl: normalizedUrl,
27
+ username,
28
+ password,
29
+ treeId,
30
+ };
31
+ }
32
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;GAEG;AASH,MAAM,UAAU,UAAU;IACxB,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC;IAC1C,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC;IAC7C,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC;IAC7C,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC;IAE1C,MAAM,OAAO,GAAa,EAAE,CAAC;IAE7B,IAAI,CAAC,MAAM;QAAE,OAAO,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;IAC5C,IAAI,CAAC,QAAQ;QAAE,OAAO,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;IAC/C,IAAI,CAAC,QAAQ;QAAE,OAAO,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;IAE/C,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,MAAM,IAAI,CAAC,QAAQ,IAAI,CAAC,QAAQ,EAAE,CAAC;QAC5D,MAAM,IAAI,KAAK,CACb,2CAA2C,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM;YACjE,yDAAyD;YACzD,+FAA+F;YAC/F,gDAAgD;YAChD,8CAA8C,CACjD,CAAC;IACJ,CAAC;IAED,gDAAgD;IAChD,MAAM,aAAa,GAAG,MAAM,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;IAEjD,OAAO;QACL,MAAM,EAAE,aAAa;QACrB,QAAQ;QACR,QAAQ;QACR,MAAM;KACP,CAAC;AACJ,CAAC"}
@@ -0,0 +1,24 @@
1
+ /**
2
+ * API endpoint definitions for Gramps Web
3
+ */
4
+ export declare const API_ENDPOINTS: {
5
+ readonly TOKEN: "/token/";
6
+ readonly PEOPLE: "/people/";
7
+ readonly FAMILIES: "/families/";
8
+ readonly EVENTS: "/events/";
9
+ readonly PLACES: "/places/";
10
+ readonly SOURCES: "/sources/";
11
+ readonly CITATIONS: "/citations/";
12
+ readonly REPOSITORIES: "/repositories/";
13
+ readonly MEDIA: "/media/";
14
+ readonly NOTES: "/notes/";
15
+ readonly SEARCH: "/search/";
16
+ readonly METADATA: "/metadata/";
17
+ readonly TREES: "/trees/";
18
+ readonly RECENT: "/recent/";
19
+ };
20
+ export type APIEndpoint = (typeof API_ENDPOINTS)[keyof typeof API_ENDPOINTS];
21
+ export declare const ENTITY_ENDPOINT_MAP: Record<string, string>;
22
+ export declare const TOKEN_EXPIRY_BUFFER_MS: number;
23
+ export declare const DEFAULT_TIMEOUT_MS: number;
24
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;CA0BhB,CAAC;AAEX,MAAM,MAAM,WAAW,GAAG,CAAC,OAAO,aAAa,CAAC,CAAC,MAAM,OAAO,aAAa,CAAC,CAAC;AAG7E,eAAO,MAAM,mBAAmB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAkBtD,CAAC;AAGF,eAAO,MAAM,sBAAsB,QAAY,CAAC;AAGhD,eAAO,MAAM,kBAAkB,QAAY,CAAC"}
@@ -0,0 +1,50 @@
1
+ /**
2
+ * API endpoint definitions for Gramps Web
3
+ */
4
+ export const API_ENDPOINTS = {
5
+ // Authentication
6
+ TOKEN: "/token/",
7
+ // Entity endpoints (append handle for specific entity)
8
+ PEOPLE: "/people/",
9
+ FAMILIES: "/families/",
10
+ EVENTS: "/events/",
11
+ PLACES: "/places/",
12
+ SOURCES: "/sources/",
13
+ CITATIONS: "/citations/",
14
+ REPOSITORIES: "/repositories/",
15
+ MEDIA: "/media/",
16
+ NOTES: "/notes/",
17
+ // Search
18
+ SEARCH: "/search/",
19
+ // Metadata
20
+ METADATA: "/metadata/",
21
+ // Trees (for multi-tree setups)
22
+ TREES: "/trees/",
23
+ // Recent changes
24
+ RECENT: "/recent/",
25
+ };
26
+ // Map entity type to endpoint
27
+ export const ENTITY_ENDPOINT_MAP = {
28
+ people: API_ENDPOINTS.PEOPLE,
29
+ person: API_ENDPOINTS.PEOPLE,
30
+ families: API_ENDPOINTS.FAMILIES,
31
+ family: API_ENDPOINTS.FAMILIES,
32
+ events: API_ENDPOINTS.EVENTS,
33
+ event: API_ENDPOINTS.EVENTS,
34
+ places: API_ENDPOINTS.PLACES,
35
+ place: API_ENDPOINTS.PLACES,
36
+ sources: API_ENDPOINTS.SOURCES,
37
+ source: API_ENDPOINTS.SOURCES,
38
+ citations: API_ENDPOINTS.CITATIONS,
39
+ citation: API_ENDPOINTS.CITATIONS,
40
+ repositories: API_ENDPOINTS.REPOSITORIES,
41
+ repository: API_ENDPOINTS.REPOSITORIES,
42
+ media: API_ENDPOINTS.MEDIA,
43
+ notes: API_ENDPOINTS.NOTES,
44
+ note: API_ENDPOINTS.NOTES,
45
+ };
46
+ // Token expiration buffer (30 seconds before actual expiry)
47
+ export const TOKEN_EXPIRY_BUFFER_MS = 30 * 1000;
48
+ // Default request timeout
49
+ export const DEFAULT_TIMEOUT_MS = 30 * 1000;
50
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,iBAAiB;IACjB,KAAK,EAAE,SAAS;IAEhB,uDAAuD;IACvD,MAAM,EAAE,UAAU;IAClB,QAAQ,EAAE,YAAY;IACtB,MAAM,EAAE,UAAU;IAClB,MAAM,EAAE,UAAU;IAClB,OAAO,EAAE,WAAW;IACpB,SAAS,EAAE,aAAa;IACxB,YAAY,EAAE,gBAAgB;IAC9B,KAAK,EAAE,SAAS;IAChB,KAAK,EAAE,SAAS;IAEhB,SAAS;IACT,MAAM,EAAE,UAAU;IAElB,WAAW;IACX,QAAQ,EAAE,YAAY;IAEtB,gCAAgC;IAChC,KAAK,EAAE,SAAS;IAEhB,iBAAiB;IACjB,MAAM,EAAE,UAAU;CACV,CAAC;AAIX,8BAA8B;AAC9B,MAAM,CAAC,MAAM,mBAAmB,GAA2B;IACzD,MAAM,EAAE,aAAa,CAAC,MAAM;I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