@rachelallyson/planning-center-people-ts 2.8.0 → 2.9.1

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 (72) hide show
  1. package/CHANGELOG.md +74 -0
  2. package/LICENSE +1 -1
  3. package/README.md +12 -14
  4. package/dist/client-manager.js +5 -3
  5. package/dist/client.d.ts +8 -8
  6. package/dist/client.js +8 -11
  7. package/dist/core/http.d.ts +1 -1
  8. package/dist/core/http.js +15 -11
  9. package/dist/core.d.ts +3 -3
  10. package/dist/core.js +4 -4
  11. package/dist/error-handling.d.ts +1 -1
  12. package/dist/error-handling.js +3 -3
  13. package/dist/error-scenarios.js +4 -4
  14. package/dist/index.d.ts +8 -8
  15. package/dist/index.js +15 -15
  16. package/dist/matching/matcher.d.ts +22 -0
  17. package/dist/matching/matcher.js +251 -20
  18. package/dist/matching/scoring.d.ts +9 -7
  19. package/dist/matching/scoring.js +49 -20
  20. package/dist/matching/strategies.d.ts +1 -0
  21. package/dist/matching/strategies.js +15 -2
  22. package/dist/modules/campus.d.ts +5 -5
  23. package/dist/modules/campus.js +2 -2
  24. package/dist/modules/contacts.d.ts +1 -1
  25. package/dist/modules/contacts.js +2 -2
  26. package/dist/modules/fields.d.ts +4 -4
  27. package/dist/modules/fields.js +2 -2
  28. package/dist/modules/forms.d.ts +7 -4
  29. package/dist/modules/forms.js +5 -2
  30. package/dist/modules/households.d.ts +2 -2
  31. package/dist/modules/households.js +2 -2
  32. package/dist/modules/lists.d.ts +2 -2
  33. package/dist/modules/lists.js +2 -2
  34. package/dist/modules/notes.d.ts +2 -2
  35. package/dist/modules/notes.js +2 -2
  36. package/dist/modules/people.d.ts +57 -5
  37. package/dist/modules/people.js +38 -8
  38. package/dist/modules/reports.d.ts +5 -5
  39. package/dist/modules/reports.js +2 -2
  40. package/dist/modules/service-time.d.ts +5 -5
  41. package/dist/modules/service-time.js +2 -2
  42. package/dist/modules/workflows.d.ts +2 -2
  43. package/dist/modules/workflows.js +2 -2
  44. package/dist/people/contacts.d.ts +1 -1
  45. package/dist/people/core.d.ts +1 -1
  46. package/dist/people/fields.d.ts +1 -1
  47. package/dist/people/fields.js +4 -4
  48. package/dist/people/households.d.ts +1 -1
  49. package/dist/people/lists.d.ts +1 -1
  50. package/dist/people/notes.d.ts +1 -1
  51. package/dist/people/organization.d.ts +1 -1
  52. package/dist/people/workflows.d.ts +1 -1
  53. package/dist/types/client.d.ts +3 -96
  54. package/dist/types/client.js +2 -0
  55. package/dist/types/index.d.ts +1 -2
  56. package/dist/types/index.js +0 -2
  57. package/dist/types/people.d.ts +15 -15
  58. package/package.json +15 -17
  59. package/dist/api-error.d.ts +0 -10
  60. package/dist/api-error.js +0 -32
  61. package/dist/batch.d.ts +0 -47
  62. package/dist/batch.js +0 -376
  63. package/dist/modules/base.d.ts +0 -46
  64. package/dist/modules/base.js +0 -82
  65. package/dist/monitoring.d.ts +0 -53
  66. package/dist/monitoring.js +0 -142
  67. package/dist/rate-limiter.d.ts +0 -79
  68. package/dist/rate-limiter.js +0 -137
  69. package/dist/types/batch.d.ts +0 -50
  70. package/dist/types/batch.js +0 -5
  71. package/dist/types/events.d.ts +0 -85
  72. package/dist/types/events.js +0 -5
package/CHANGELOG.md CHANGED
@@ -5,6 +5,80 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [2.9.1] - 2025-01-14
9
+
10
+ ### 🐛 **Bug Fixes**
11
+
12
+ - **Type System Accuracy**: Fixed TypeScript type definitions to match actual API responses
13
+ - Updated nullable fields to properly use `string | null` and `number | null` types
14
+ - Fixed `PersonAttributes`: `given_name`, `middle_name`, `nickname`, `anniversary`, `gender`, `grade`, `graduation_year`, `medical_notes`, `remote_id`, `inactivated_at` now correctly typed as `string | null`
15
+ - Fixed `CampusAttributes`: `latitude`, `longitude` now `string | null`; `phone_number`, `website` now `string | null`; `twenty_four_hour_time` now `boolean | null`; `date_format` now `number | null`
16
+ - Fixed `WorkflowCardAttributes`: `calculated_due_at_in_days_ago`, `snooze_until`, `removed_at`, `flagged_for_notification_at`, `moved_to_step_at` now correctly typed as nullable
17
+ - **Test Suite Fixes**: Fixed integration test expectations to match actual API behavior
18
+ - Relaxed relationship validation tests to make `links` optional (not always present in API responses)
19
+ - Fixed batch test data structure access to use `batchResult.data.data` (batch results wrap API responses)
20
+ - Fixed error handling tests to check error `status` property and use correct event name (`request:error`)
21
+ - Updated v2 service-time test to use `getAll()` instead of `getAllPagesPaginated()`
22
+ - Relaxed batch test expectations to handle API validation behavior
23
+
24
+ ### 🧪 **Testing Improvements**
25
+
26
+ - Comprehensive integration test suite now passes (655+ tests)
27
+ - All type validation tests align with actual API response structures
28
+ - Error handling tests verify correct error structure and event emission
29
+
30
+ ## [2.9.0] - 2025-01-14
31
+
32
+ ### 🎯 **Matching Logic Improvements**
33
+
34
+ This release significantly improves the accuracy of person matching by verifying email/phone matches and preventing incorrect name-only matches.
35
+
36
+ ### 🐛 **Critical Bug Fixes**
37
+
38
+ - **🔍 Email/Phone Verification**: Fixed matching logic that was allowing name-only matches even when email/phone were provided but didn't match
39
+ - Previously, searching with email/phone would match people with different contact info if names matched
40
+ - Now requires actual email/phone verification before considering name matches
41
+ - **✅ Verified Contact Matching**: `scoreEmailMatch()` and `scorePhoneMatch()` now actually fetch and verify contact information instead of assuming matches
42
+ - **🚫 Name-Only Matching Restrictions**: Name-only matching now only occurs when:
43
+ - Multiple people share the same email/phone (name helps distinguish), OR
44
+ - No email/phone was provided in the search
45
+ - **🎯 Exact Match Strategy**: Made "exact" matching strategy stricter, requiring verified email/phone matches unless multiple people share the same contact info
46
+
47
+ ### ✨ **New Features**
48
+
49
+ - **📝 Auto-Update Contact Info**: New `addMissingContactInfo` option in `PersonMatchOptions`
50
+ - When enabled, automatically adds missing email/phone to a person's profile when a match is found
51
+ - Missing contacts are added as non-primary to preserve existing primary contacts
52
+ - Helps keep person profiles up-to-date when new contact information is discovered
53
+
54
+ ### 🔧 **Technical Improvements**
55
+
56
+ - **🔍 Async Verification**: Email and phone matching now uses async methods to fetch and verify actual contact information
57
+ - **📊 Improved Scoring**: MatchScorer now requires PeopleModule dependency to verify matches
58
+ - **🎯 Better Match Prioritization**: Verified email/phone matches are prioritized over name-only matches
59
+ - **📖 Enhanced Documentation**: Comprehensive JSDoc comments and README examples for all new features
60
+
61
+ ### 📚 **Documentation**
62
+
63
+ - **📖 JSDoc Updates**: Added detailed documentation for `PersonMatchOptions` interface and `findOrCreate()` method
64
+ - **📝 README Examples**: Added example showing `addMissingContactInfo` usage
65
+ - **🔍 Method Documentation**: Updated all matching methods with comprehensive parameter descriptions
66
+
67
+ ### 🎯 **Impact**
68
+
69
+ This release fixes the issue where:
70
+
71
+ - ❌ Searching with `rachel@onark.app` + `+11233853584` would incorrectly match someone with `rachel@hangar31.dev` + `+16103017206` based on name alone
72
+ - ❌ Email/phone matches were assumed without verification
73
+ - ❌ Name-only matching occurred even when email/phone were provided
74
+
75
+ Now matching:
76
+
77
+ - ✅ Verifies email/phone actually match before considering a match
78
+ - ✅ Only uses name matching when appropriate (multiple people share contact info or no contact info provided)
79
+ - ✅ Can automatically update profiles with missing contact information
80
+ - ✅ Provides stricter exact matching for high-confidence scenarios
81
+
8
82
  ## [2.8.0] - 2025-01-11
9
83
 
10
84
  ### 🎯 **CRITICAL FINDORCREATE BUG FIX**
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2024 Rachel Higley
3
+ Copyright (c) 2024 Rachel Allyson
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  A modern, type-safe TypeScript library for interacting with the Planning Center Online People API. Built with a class-based architecture, comprehensive error handling, and advanced features like person matching and batch operations.
4
4
 
5
- > **📖 For the latest documentation and examples, see [docs/README.md](docs/README.md)**
5
+ > **📖 For the latest documentation and examples, see the [Monorepo Documentation Site](../../docs/content/index.mdx)**
6
6
 
7
7
  ## Features
8
8
 
@@ -519,19 +519,17 @@ See [TYPE_VALIDATION_SUMMARY.md](./TYPE_VALIDATION_SUMMARY.md) for detailed docu
519
519
 
520
520
  ## 📚 Comprehensive Documentation
521
521
 
522
- This library includes extensive documentation covering all aspects of usage:
523
-
524
- - **[📖 Complete Documentation](./docs/README.md)** - Comprehensive guide covering all features
525
- - **[🚀 Getting Started](./docs/OVERVIEW.md)** - What this library does and why you should use it
526
- - **[⚙️ Installation Guide](./docs/INSTALLATION.md)** - Complete setup instructions for all environments
527
- - **[🔐 Authentication Guide](./docs/AUTHENTICATION.md)** - All authentication methods and token management
528
- - **[📋 API Reference](./docs/API_REFERENCE.md)** - Complete reference for all 40+ functions
529
- - **[💡 Examples & Patterns](./docs/EXAMPLES.md)** - Real-world examples and common patterns
530
- - **[🛠️ Error Handling](./docs/ERROR_HANDLING.md)** - Advanced error management and recovery
531
- - **[ Performance Guide](./docs/PERFORMANCE.md)** - Optimization techniques and bulk operations
532
- - **[🔧 Troubleshooting](./docs/TROUBLESHOOTING.md)** - Common issues and solutions
533
- - **[🔄 Migration Guide](./docs/MIGRATION.md)** - Switching from other libraries
534
- - **[⭐ Best Practices](./docs/BEST_PRACTICES.md)** - Production-ready patterns and security
522
+ Complete documentation is available in the monorepo documentation site:
523
+
524
+ - **[📖 Documentation Index](../../docs/content/index.mdx)** - Complete documentation entry point
525
+ - **[🚀 Quick Start Guide](../../docs/content/guides/quickstart.mdx)** - Get started in 5 minutes
526
+ - **[📋 API Reference](../../docs/content/api/)** - Complete TypeScript API documentation
527
+ - **[⚙️ Configuration Reference](../../docs/content/reference/config.mdx)** - All configuration options
528
+ - **[💡 Examples & Recipes](../../docs/content/recipes/examples.mdx)** - Copy-paste code snippets
529
+ - **[🛠️ Error Handling Guide](../../docs/content/guides/error-handling.mdx)** - Comprehensive error handling
530
+ - **[📄 Pagination Guide](../../docs/content/guides/pagination.mdx)** - Handling paginated responses
531
+ - **[🔧 Troubleshooting](../../docs/content/troubleshooting.mdx)** - Common issues and solutions
532
+ - **[🏗️ Core Concepts](../../docs/content/concepts.mdx)** - Architecture and mental models
535
533
 
536
534
  ## License
537
535
 
@@ -119,9 +119,11 @@ class PcoClientManager {
119
119
  // Create a hash of the configuration
120
120
  const configStr = JSON.stringify({
121
121
  authType: config.auth.type,
122
- hasAccessToken: config.auth.type === 'oauth' ? !!config.auth.accessToken : false,
123
- hasRefreshToken: config.auth.type === 'oauth' ? !!config.auth.refreshToken : false,
124
- hasPersonalAccessToken: config.auth.type === 'personal_access_token' ? !!config.auth.personalAccessToken : false,
122
+ accessToken: config.auth.type === 'oauth' ? config.auth.accessToken : undefined,
123
+ refreshToken: config.auth.type === 'oauth' ? config.auth.refreshToken : undefined,
124
+ personalAccessToken: config.auth.type === 'personal_access_token' ? config.auth.personalAccessToken : undefined,
125
+ appId: config.auth.type === 'basic' ? config.auth.appId : undefined,
126
+ appSecret: config.auth.type === 'basic' ? config.auth.appSecret : undefined,
125
127
  baseURL: config.baseURL,
126
128
  timeout: config.timeout,
127
129
  });
package/dist/client.d.ts CHANGED
@@ -2,7 +2,8 @@
2
2
  * v2.0.0 Main PcoClient Class
3
3
  */
4
4
  import type { PcoClientConfig } from './types/client';
5
- import type { EventEmitter } from './types/events';
5
+ import type { EventEmitter, PcoEvent, EventHandler, EventType } from '@rachelallyson/planning-center-base-ts';
6
+ import { BatchExecutor } from '@rachelallyson/planning-center-base-ts';
6
7
  import { PeopleModule } from './modules/people';
7
8
  import { FieldsModule } from './modules/fields';
8
9
  import { WorkflowsModule } from './modules/workflows';
@@ -14,7 +15,6 @@ import { CampusModule } from './modules/campus';
14
15
  import { ServiceTimeModule } from './modules/service-time';
15
16
  import { FormsModule } from './modules/forms';
16
17
  import { ReportsModule } from './modules/reports';
17
- import { BatchExecutor } from './batch';
18
18
  export declare class PcoClient implements EventEmitter {
19
19
  people: PeopleModule;
20
20
  fields: FieldsModule;
@@ -33,9 +33,9 @@ export declare class PcoClient implements EventEmitter {
33
33
  private eventEmitter;
34
34
  private config;
35
35
  constructor(config: PcoClientConfig);
36
- on<T extends import('./types/events').PcoEvent>(eventType: T['type'], handler: import('./types/events').EventHandler<T>): void;
37
- off<T extends import('./types/events').PcoEvent>(eventType: T['type'], handler: import('./types/events').EventHandler<T>): void;
38
- emit<T extends import('./types/events').PcoEvent>(event: T): void;
36
+ on<T extends PcoEvent>(eventType: T['type'], handler: EventHandler<T>): void;
37
+ off<T extends PcoEvent>(eventType: T['type'], handler: EventHandler<T>): void;
38
+ emit<T extends PcoEvent>(event: T): void;
39
39
  /**
40
40
  * Get the current configuration
41
41
  */
@@ -65,15 +65,15 @@ export declare class PcoClient implements EventEmitter {
65
65
  /**
66
66
  * Clear all event listeners
67
67
  */
68
- removeAllListeners(eventType?: import('./types/events').EventType): void;
68
+ removeAllListeners(eventType?: EventType): void;
69
69
  /**
70
70
  * Get the number of listeners for an event type
71
71
  */
72
- listenerCount(eventType: import('./types/events').EventType): number;
72
+ listenerCount(eventType: EventType): number;
73
73
  /**
74
74
  * Get all registered event types
75
75
  */
76
- eventTypes(): import('./types/events').EventType[];
76
+ eventTypes(): EventType[];
77
77
  private setupEventHandlers;
78
78
  private updateModules;
79
79
  }
package/dist/client.js CHANGED
@@ -4,9 +4,7 @@
4
4
  */
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.PcoClient = void 0;
7
- const monitoring_1 = require("./monitoring");
8
- const http_1 = require("./core/http");
9
- const pagination_1 = require("./core/pagination");
7
+ const planning_center_base_ts_1 = require("@rachelallyson/planning-center-base-ts");
10
8
  const people_1 = require("./modules/people");
11
9
  const fields_1 = require("./modules/fields");
12
10
  const workflows_1 = require("./modules/workflows");
@@ -18,13 +16,12 @@ const campus_1 = require("./modules/campus");
18
16
  const service_time_1 = require("./modules/service-time");
19
17
  const forms_1 = require("./modules/forms");
20
18
  const reports_1 = require("./modules/reports");
21
- const batch_1 = require("./batch");
22
19
  class PcoClient {
23
20
  constructor(config) {
24
21
  this.config = config;
25
- this.eventEmitter = new monitoring_1.PcoEventEmitter();
26
- this.httpClient = new http_1.PcoHttpClient(config, this.eventEmitter);
27
- this.paginationHelper = new pagination_1.PaginationHelper(this.httpClient);
22
+ this.eventEmitter = new planning_center_base_ts_1.PcoEventEmitter();
23
+ this.httpClient = new planning_center_base_ts_1.PcoHttpClient(config, this.eventEmitter);
24
+ this.paginationHelper = new planning_center_base_ts_1.PaginationHelper(this.httpClient);
28
25
  // Initialize modules
29
26
  this.people = new people_1.PeopleModule(this.httpClient, this.paginationHelper, this.eventEmitter);
30
27
  this.fields = new fields_1.FieldsModule(this.httpClient, this.paginationHelper, this.eventEmitter);
@@ -37,7 +34,7 @@ class PcoClient {
37
34
  this.serviceTime = new service_time_1.ServiceTimeModule(this.httpClient, this.paginationHelper, this.eventEmitter);
38
35
  this.forms = new forms_1.FormsModule(this.httpClient, this.paginationHelper, this.eventEmitter);
39
36
  this.reports = new reports_1.ReportsModule(this.httpClient, this.paginationHelper, this.eventEmitter);
40
- this.batch = new batch_1.BatchExecutor(this, this.eventEmitter);
37
+ this.batch = new planning_center_base_ts_1.BatchExecutor(this, this.eventEmitter);
41
38
  // Set up event handlers from config
42
39
  this.setupEventHandlers();
43
40
  }
@@ -63,8 +60,8 @@ class PcoClient {
63
60
  updateConfig(updates) {
64
61
  this.config = { ...this.config, ...updates };
65
62
  // Recreate HTTP client with new config
66
- this.httpClient = new http_1.PcoHttpClient(this.config, this.eventEmitter);
67
- this.paginationHelper = new pagination_1.PaginationHelper(this.httpClient);
63
+ this.httpClient = new planning_center_base_ts_1.PcoHttpClient(this.config, this.eventEmitter);
64
+ this.paginationHelper = new planning_center_base_ts_1.PaginationHelper(this.httpClient);
68
65
  // Update modules with new HTTP client
69
66
  this.updateModules();
70
67
  }
@@ -125,7 +122,7 @@ class PcoClient {
125
122
  this.households = new households_1.HouseholdsModule(this.httpClient, this.paginationHelper, this.eventEmitter);
126
123
  this.notes = new notes_1.NotesModule(this.httpClient, this.paginationHelper, this.eventEmitter);
127
124
  this.lists = new lists_1.ListsModule(this.httpClient, this.paginationHelper, this.eventEmitter);
128
- this.batch = new batch_1.BatchExecutor(this, this.eventEmitter);
125
+ this.batch = new planning_center_base_ts_1.BatchExecutor(this, this.eventEmitter);
129
126
  }
130
127
  }
131
128
  exports.PcoClient = PcoClient;
@@ -2,7 +2,7 @@
2
2
  * v2.0.0 HTTP Client
3
3
  */
4
4
  import type { PcoClientConfig } from '../types/client';
5
- import { PcoEventEmitter } from '../monitoring';
5
+ import { PcoEventEmitter } from '@rachelallyson/planning-center-base-ts';
6
6
  export interface HttpRequestOptions {
7
7
  method: string;
8
8
  endpoint: string;
package/dist/core/http.js CHANGED
@@ -4,18 +4,18 @@
4
4
  */
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.PcoHttpClient = void 0;
7
- const monitoring_1 = require("../monitoring");
8
- const rate_limiter_1 = require("../rate-limiter");
9
- const api_error_1 = require("../api-error");
7
+ const planning_center_base_ts_1 = require("@rachelallyson/planning-center-base-ts");
8
+ const planning_center_base_ts_2 = require("@rachelallyson/planning-center-base-ts");
9
+ const planning_center_base_ts_3 = require("@rachelallyson/planning-center-base-ts");
10
10
  class PcoHttpClient {
11
11
  constructor(config, eventEmitter) {
12
12
  this.config = config;
13
13
  this.eventEmitter = eventEmitter;
14
- this.requestIdGenerator = new monitoring_1.RequestIdGenerator();
15
- this.performanceMetrics = new monitoring_1.PerformanceMetrics();
16
- this.rateLimitTracker = new monitoring_1.RateLimitTracker();
14
+ this.requestIdGenerator = new planning_center_base_ts_1.RequestIdGenerator();
15
+ this.performanceMetrics = new planning_center_base_ts_1.PerformanceMetrics();
16
+ this.rateLimitTracker = new planning_center_base_ts_1.RateLimitTracker();
17
17
  // Initialize rate limiter
18
- this.rateLimiter = new rate_limiter_1.PcoRateLimiter(100, 20000); // 100 requests per 20 seconds
18
+ this.rateLimiter = new planning_center_base_ts_2.PcoRateLimiter(100, 20000); // 100 requests per 20 seconds
19
19
  }
20
20
  async request(options) {
21
21
  const requestId = this.requestIdGenerator.generate();
@@ -163,7 +163,7 @@ class PcoHttpClient {
163
163
  catch {
164
164
  errorData = {};
165
165
  }
166
- throw api_error_1.PcoApiError.fromFetchError(response, errorData);
166
+ throw planning_center_base_ts_3.PcoApiError.fromFetchError(response, errorData);
167
167
  }
168
168
  // Parse response
169
169
  if (options.method === 'DELETE') {
@@ -186,6 +186,10 @@ class PcoHttpClient {
186
186
  }
187
187
  catch (error) {
188
188
  clearTimeout(timeoutId);
189
+ // Handle timeout/abort errors
190
+ if (error instanceof Error && error.name === 'AbortError') {
191
+ throw new Error(`Request timeout after ${timeout}ms`);
192
+ }
189
193
  throw error;
190
194
  }
191
195
  }
@@ -263,11 +267,11 @@ class PcoHttpClient {
263
267
  const tokens = await response.json();
264
268
  // Update the config with new tokens
265
269
  this.config.auth.accessToken = tokens.access_token;
266
- this.config.auth.refreshToken = tokens.refresh_token;
267
- // Call the onRefresh callback
270
+ this.config.auth.refreshToken = tokens.refresh_token || this.config.auth.refreshToken;
271
+ // Call the onRefresh callback with the expected format
268
272
  await this.config.auth.onRefresh({
269
273
  accessToken: tokens.access_token,
270
- refreshToken: tokens.refresh_token,
274
+ refreshToken: tokens.refresh_token || this.config.auth.refreshToken,
271
275
  });
272
276
  }
273
277
  updateRateLimitTracking(endpoint, headers) {
package/dist/core.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { type ErrorContext, PcoError } from './error-handling';
2
- import { PcoRateLimiter } from './rate-limiter';
2
+ import { PcoRateLimiter } from '@rachelallyson/planning-center-base-ts';
3
3
  import { Paginated, ResourceObject, Response as JsonApiResponse } from './types';
4
4
  import { type TokenRefreshCallback, type TokenRefreshFailureCallback } from './auth';
5
5
  export interface PcoClientConfig {
@@ -36,7 +36,7 @@ export interface PcoClientConfig {
36
36
  onRetry?: (error: PcoError, attempt: number) => void;
37
37
  };
38
38
  }
39
- export { PcoApiError } from './api-error';
39
+ export { PcoApiError } from '@rachelallyson/planning-center-base-ts';
40
40
  export interface PcoClientState {
41
41
  config: PcoClientConfig;
42
42
  rateLimiter: PcoRateLimiter;
@@ -72,4 +72,4 @@ export declare function getAllPages<T extends ResourceObject<string, any, any>>(
72
72
  /**
73
73
  * Get rate limit information
74
74
  */
75
- export declare function getRateLimitInfo(client: PcoClientState): import("./rate-limiter").RateLimitInfo;
75
+ export declare function getRateLimitInfo(client: PcoClientState): import("@rachelallyson/planning-center-base-ts").RateLimitInfo;
package/dist/core.js CHANGED
@@ -10,11 +10,11 @@ exports.del = del;
10
10
  exports.getAllPages = getAllPages;
11
11
  exports.getRateLimitInfo = getRateLimitInfo;
12
12
  const error_handling_1 = require("./error-handling");
13
- const rate_limiter_1 = require("./rate-limiter");
13
+ const planning_center_base_ts_1 = require("@rachelallyson/planning-center-base-ts");
14
14
  const auth_1 = require("./auth");
15
15
  // Re-export PcoApiError for convenience
16
- var api_error_1 = require("./api-error");
17
- Object.defineProperty(exports, "PcoApiError", { enumerable: true, get: function () { return api_error_1.PcoApiError; } });
16
+ var planning_center_base_ts_2 = require("@rachelallyson/planning-center-base-ts");
17
+ Object.defineProperty(exports, "PcoApiError", { enumerable: true, get: function () { return planning_center_base_ts_2.PcoApiError; } });
18
18
  // ===== Core PCO Client Functions =====
19
19
  /**
20
20
  * Create a PCO client state
@@ -25,7 +25,7 @@ function createPcoClient(config) {
25
25
  maxRequests: 100,
26
26
  perMilliseconds: 20000, // 20 seconds
27
27
  };
28
- const rateLimiter = new rate_limiter_1.PcoRateLimiter(rateLimitConfig.maxRequests, rateLimitConfig.perMilliseconds);
28
+ const rateLimiter = new planning_center_base_ts_1.PcoRateLimiter(rateLimitConfig.maxRequests, rateLimitConfig.perMilliseconds);
29
29
  return {
30
30
  config,
31
31
  rateLimiter,
@@ -1,4 +1,4 @@
1
- import { PcoApiError } from './api-error';
1
+ import { PcoApiError } from '@rachelallyson/planning-center-base-ts';
2
2
  import type { ErrorObject as JsonApiError } from './types';
3
3
  export declare enum ErrorCategory {
4
4
  EXTERNAL_API = "external_api",
@@ -7,7 +7,7 @@ exports.withErrorBoundary = withErrorBoundary;
7
7
  exports.handleValidationError = handleValidationError;
8
8
  exports.handleTimeoutError = handleTimeoutError;
9
9
  exports.handleNetworkError = handleNetworkError;
10
- const api_error_1 = require("./api-error");
10
+ const planning_center_base_ts_1 = require("@rachelallyson/planning-center-base-ts");
11
11
  // Error categories for better monitoring
12
12
  var ErrorCategory;
13
13
  (function (ErrorCategory) {
@@ -29,7 +29,7 @@ var ErrorSeverity;
29
29
  ErrorSeverity["CRITICAL"] = "critical";
30
30
  })(ErrorSeverity || (exports.ErrorSeverity = ErrorSeverity = {}));
31
31
  // Enhanced PCO API Error with additional context
32
- class PcoError extends api_error_1.PcoApiError {
32
+ class PcoError extends planning_center_base_ts_1.PcoApiError {
33
33
  constructor(message, status, statusText, errors, rateLimitHeaders, context = {}) {
34
34
  super(message, status, statusText, errors, rateLimitHeaders);
35
35
  this.name = 'PcoError';
@@ -170,7 +170,7 @@ function shouldNotRetry(error) {
170
170
  if (error instanceof PcoError) {
171
171
  return !error.shouldRetry();
172
172
  }
173
- if (error instanceof api_error_1.PcoApiError) {
173
+ if (error instanceof planning_center_base_ts_1.PcoApiError) {
174
174
  // Don't retry authentication, authorization, or validation errors
175
175
  return (error.status === 401 ||
176
176
  error.status === 403 ||
@@ -13,7 +13,7 @@ exports.withTimeout = withTimeout;
13
13
  exports.classifyError = classifyError;
14
14
  exports.attemptRecovery = attemptRecovery;
15
15
  exports.createErrorReport = createErrorReport;
16
- const api_error_1 = require("./api-error");
16
+ const planning_center_base_ts_1 = require("@rachelallyson/planning-center-base-ts");
17
17
  exports.DEFAULT_RETRY_CONFIG = {
18
18
  backoffFactor: 2,
19
19
  baseDelay: 1000,
@@ -52,7 +52,7 @@ async function retryWithExponentialBackoff(operation, config = {}) {
52
52
  * Check if an error is retryable
53
53
  */
54
54
  function isRetryableError(error, retryableStatuses) {
55
- if (error instanceof api_error_1.PcoApiError) {
55
+ if (error instanceof planning_center_base_ts_1.PcoApiError) {
56
56
  return retryableStatuses.includes(error.status);
57
57
  }
58
58
  // Network errors are generally retryable
@@ -195,7 +195,7 @@ exports.TIMEOUT_CONFIG = {
195
195
  * Classify errors for appropriate handling
196
196
  */
197
197
  function classifyError(error) {
198
- if (error instanceof api_error_1.PcoApiError) {
198
+ if (error instanceof planning_center_base_ts_1.PcoApiError) {
199
199
  return classifyPcoError(error);
200
200
  }
201
201
  if (error.name === 'TypeError' && error.message.includes('fetch')) {
@@ -300,7 +300,7 @@ async function attemptRecovery(operation, error, context) {
300
300
  }
301
301
  // Rate limit recovery
302
302
  if (classification.category === 'rate_limit' &&
303
- error instanceof api_error_1.PcoApiError) {
303
+ error instanceof planning_center_base_ts_1.PcoApiError) {
304
304
  const retryAfter = error.rateLimitHeaders?.['Retry-After'];
305
305
  if (retryAfter) {
306
306
  const delay = parseInt(retryAfter) * 1000;
package/dist/index.d.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  export { PcoClient } from './client';
2
2
  export { PcoClientManager } from './client-manager';
3
3
  export type { PcoClientConfig, PcoAuthConfig, PersonalAccessTokenAuth, OAuthAuth } from './types/client';
4
- export type { PcoEvent, EventHandler, EventType } from './types/events';
5
- export type { BatchOperation, BatchResult, BatchOptions, BatchSummary } from './types/batch';
6
- export type { Paginated, Relationship, ResourceIdentifier, ResourceObject, } from './types';
4
+ export type { PcoEvent, EventHandler, EventType } from '@rachelallyson/planning-center-base-ts';
5
+ export type { BatchOperation, BatchResult, BatchOptions, BatchSummary } from '@rachelallyson/planning-center-base-ts';
6
+ export type { Paginated, Relationship, ResourceIdentifier, ResourceObject, } from '@rachelallyson/planning-center-base-ts';
7
7
  export type { PersonResource, PersonAttributes, PersonSingle, PeopleList, EmailResource, EmailAttributes, PhoneNumberResource, PhoneNumberAttributes, AddressResource, AddressAttributes, SocialProfileResource, SocialProfileAttributes, } from './types';
8
8
  export type { FieldDefinitionResource, FieldDefinitionAttributes, FieldDatumResource, FieldDatumAttributes, FieldOptionResource, FieldOptionAttributes, TabResource, TabAttributes, } from './types';
9
9
  export type { WorkflowResource, WorkflowAttributes, WorkflowCardResource, WorkflowCardAttributes, WorkflowCardNoteResource, WorkflowCardNoteAttributes, } from './types';
@@ -13,11 +13,11 @@ export type { PcoClientConfig as PcoClientConfigV1, PcoClientState } from './cor
13
13
  export { createPcoClient, del, getAllPages, getList, getRateLimitInfo, getSingle, patch, post, } from './core';
14
14
  export type { TokenResponse, TokenRefreshCallback, TokenRefreshFailureCallback } from './auth';
15
15
  export { attemptTokenRefresh, hasRefreshTokenCapability, refreshAccessToken, updateClientTokens, } from './auth';
16
- export { PcoApiError } from './api-error';
17
- export type { RateLimitHeaders, RateLimitInfo } from './rate-limiter';
18
- export { PcoRateLimiter } from './rate-limiter';
19
- export type { ErrorContext } from './error-handling';
20
- export { ErrorCategory, ErrorSeverity, handleNetworkError, handleTimeoutError, handleValidationError, PcoError, retryWithBackoff, shouldNotRetry, withErrorBoundary, } from './error-handling';
16
+ export { PcoApiError } from '@rachelallyson/planning-center-base-ts';
17
+ export type { RateLimitHeaders, RateLimitInfo } from '@rachelallyson/planning-center-base-ts';
18
+ export { PcoRateLimiter } from '@rachelallyson/planning-center-base-ts';
19
+ export type { ErrorContext } from '@rachelallyson/planning-center-base-ts';
20
+ export { ErrorCategory, ErrorSeverity, handleNetworkError, handleTimeoutError, handleValidationError, PcoError, retryWithBackoff, shouldNotRetry, withErrorBoundary, } from '@rachelallyson/planning-center-base-ts';
21
21
  export { createFieldDefinition, createFieldOption, createPerson, createPersonAddress, createPersonEmail, createPersonFieldData, createPersonPhoneNumber, createPersonSocialProfile, createWorkflowCard, createWorkflowCardNote, deleteFieldDefinition, deletePerson, deletePersonFieldData, deleteSocialProfile, getFieldDefinitions, getFieldOptions, getHousehold, getHouseholds, getTabs, getListById, getListCategories, getLists, getNote, getNoteCategories, getNotes, getOrganization, getPeople, getPerson, getPersonAddresses, getPersonEmails, getPersonFieldData, getPersonPhoneNumbers, getPersonSocialProfiles, getWorkflow, getWorkflowCardNotes, getWorkflowCards, getWorkflows, updatePerson, updatePersonAddress, } from './people';
22
22
  export { attemptRecovery, CircuitBreaker, classifyError, createErrorReport, DEFAULT_RETRY_CONFIG, executeBulkOperation, retryWithExponentialBackoff, TIMEOUT_CONFIG, withTimeout, } from './error-scenarios';
23
23
  export { buildQueryParams, calculateAge, createPersonWithContact, createWorkflowCardWithNote, exportAllPeopleData, extractFileUrl, formatDate, formatPersonName, getCompletePersonProfile, getFileExtension, getFilename, getListsWithCategories, getOrganizationInfo, getPeopleByHousehold, getPersonWorkflowCardsWithNotes, getPrimaryContact, isFileUpload, isFileUrl, isValidEmail, isValidPhone, processFileValue, searchPeople, validatePersonData, } from './helpers';
package/dist/index.js CHANGED
@@ -41,21 +41,21 @@ Object.defineProperty(exports, "attemptTokenRefresh", { enumerable: true, get: f
41
41
  Object.defineProperty(exports, "hasRefreshTokenCapability", { enumerable: true, get: function () { return auth_1.hasRefreshTokenCapability; } });
42
42
  Object.defineProperty(exports, "refreshAccessToken", { enumerable: true, get: function () { return auth_1.refreshAccessToken; } });
43
43
  Object.defineProperty(exports, "updateClientTokens", { enumerable: true, get: function () { return auth_1.updateClientTokens; } });
44
- // Export API error
45
- var api_error_1 = require("./api-error");
46
- Object.defineProperty(exports, "PcoApiError", { enumerable: true, get: function () { return api_error_1.PcoApiError; } });
47
- var rate_limiter_1 = require("./rate-limiter");
48
- Object.defineProperty(exports, "PcoRateLimiter", { enumerable: true, get: function () { return rate_limiter_1.PcoRateLimiter; } });
49
- var error_handling_1 = require("./error-handling");
50
- Object.defineProperty(exports, "ErrorCategory", { enumerable: true, get: function () { return error_handling_1.ErrorCategory; } });
51
- Object.defineProperty(exports, "ErrorSeverity", { enumerable: true, get: function () { return error_handling_1.ErrorSeverity; } });
52
- Object.defineProperty(exports, "handleNetworkError", { enumerable: true, get: function () { return error_handling_1.handleNetworkError; } });
53
- Object.defineProperty(exports, "handleTimeoutError", { enumerable: true, get: function () { return error_handling_1.handleTimeoutError; } });
54
- Object.defineProperty(exports, "handleValidationError", { enumerable: true, get: function () { return error_handling_1.handleValidationError; } });
55
- Object.defineProperty(exports, "PcoError", { enumerable: true, get: function () { return error_handling_1.PcoError; } });
56
- Object.defineProperty(exports, "retryWithBackoff", { enumerable: true, get: function () { return error_handling_1.retryWithBackoff; } });
57
- Object.defineProperty(exports, "shouldNotRetry", { enumerable: true, get: function () { return error_handling_1.shouldNotRetry; } });
58
- Object.defineProperty(exports, "withErrorBoundary", { enumerable: true, get: function () { return error_handling_1.withErrorBoundary; } });
44
+ // Export API error (re-exported from base)
45
+ var planning_center_base_ts_1 = require("@rachelallyson/planning-center-base-ts");
46
+ Object.defineProperty(exports, "PcoApiError", { enumerable: true, get: function () { return planning_center_base_ts_1.PcoApiError; } });
47
+ var planning_center_base_ts_2 = require("@rachelallyson/planning-center-base-ts");
48
+ Object.defineProperty(exports, "PcoRateLimiter", { enumerable: true, get: function () { return planning_center_base_ts_2.PcoRateLimiter; } });
49
+ var planning_center_base_ts_3 = require("@rachelallyson/planning-center-base-ts");
50
+ Object.defineProperty(exports, "ErrorCategory", { enumerable: true, get: function () { return planning_center_base_ts_3.ErrorCategory; } });
51
+ Object.defineProperty(exports, "ErrorSeverity", { enumerable: true, get: function () { return planning_center_base_ts_3.ErrorSeverity; } });
52
+ Object.defineProperty(exports, "handleNetworkError", { enumerable: true, get: function () { return planning_center_base_ts_3.handleNetworkError; } });
53
+ Object.defineProperty(exports, "handleTimeoutError", { enumerable: true, get: function () { return planning_center_base_ts_3.handleTimeoutError; } });
54
+ Object.defineProperty(exports, "handleValidationError", { enumerable: true, get: function () { return planning_center_base_ts_3.handleValidationError; } });
55
+ Object.defineProperty(exports, "PcoError", { enumerable: true, get: function () { return planning_center_base_ts_3.PcoError; } });
56
+ Object.defineProperty(exports, "retryWithBackoff", { enumerable: true, get: function () { return planning_center_base_ts_3.retryWithBackoff; } });
57
+ Object.defineProperty(exports, "shouldNotRetry", { enumerable: true, get: function () { return planning_center_base_ts_3.shouldNotRetry; } });
58
+ Object.defineProperty(exports, "withErrorBoundary", { enumerable: true, get: function () { return planning_center_base_ts_3.withErrorBoundary; } });
59
59
  // Export People-specific functions (deprecated)
60
60
  var people_1 = require("./people");
61
61
  Object.defineProperty(exports, "createFieldDefinition", { enumerable: true, get: function () { return people_1.createFieldDefinition; } });
@@ -8,6 +8,7 @@ export interface MatchResult {
8
8
  person: PersonResource;
9
9
  score: number;
10
10
  reason: string;
11
+ isVerifiedContactMatch?: boolean;
11
12
  }
12
13
  export declare class PersonMatcher {
13
14
  private peopleModule;
@@ -16,6 +17,14 @@ export declare class PersonMatcher {
16
17
  constructor(peopleModule: PeopleModule);
17
18
  /**
18
19
  * Find or create a person with smart matching
20
+ *
21
+ * Uses intelligent matching logic that:
22
+ * - Verifies email/phone matches by checking actual contact information
23
+ * - Only uses name matching when appropriate (multiple people share contact info, or no contact info provided)
24
+ * - Can automatically add missing contact information when a match is found (if addMissingContactInfo is true)
25
+ *
26
+ * @param options - Matching options
27
+ * @param options.addMissingContactInfo - If true, automatically adds missing email/phone to matched person's profile
19
28
  */
20
29
  findOrCreate(options: PersonMatchOptions): Promise<PersonResource>;
21
30
  /**
@@ -24,8 +33,21 @@ export declare class PersonMatcher {
24
33
  findMatch(options: PersonMatchOptions): Promise<MatchResult | null>;
25
34
  /**
26
35
  * Get potential matching candidates
36
+ * @deprecated Use findMatch which has improved logic for separating verified matches from name-only matches
27
37
  */
28
38
  private getCandidates;
39
+ /**
40
+ * Verify if a person's email actually matches the search email
41
+ */
42
+ private verifyEmailMatch;
43
+ /**
44
+ * Verify if a person's phone actually matches the search phone
45
+ */
46
+ private verifyPhoneMatch;
47
+ /**
48
+ * Add missing contact information to a person's profile
49
+ */
50
+ private addMissingContactInfo;
29
51
  /**
30
52
  * Filter candidates by age preferences
31
53
  */