@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.
- package/CHANGELOG.md +74 -0
- package/LICENSE +1 -1
- package/README.md +12 -14
- package/dist/client-manager.js +5 -3
- package/dist/client.d.ts +8 -8
- package/dist/client.js +8 -11
- package/dist/core/http.d.ts +1 -1
- package/dist/core/http.js +15 -11
- package/dist/core.d.ts +3 -3
- package/dist/core.js +4 -4
- package/dist/error-handling.d.ts +1 -1
- package/dist/error-handling.js +3 -3
- package/dist/error-scenarios.js +4 -4
- package/dist/index.d.ts +8 -8
- package/dist/index.js +15 -15
- package/dist/matching/matcher.d.ts +22 -0
- package/dist/matching/matcher.js +251 -20
- package/dist/matching/scoring.d.ts +9 -7
- package/dist/matching/scoring.js +49 -20
- package/dist/matching/strategies.d.ts +1 -0
- package/dist/matching/strategies.js +15 -2
- package/dist/modules/campus.d.ts +5 -5
- package/dist/modules/campus.js +2 -2
- package/dist/modules/contacts.d.ts +1 -1
- package/dist/modules/contacts.js +2 -2
- package/dist/modules/fields.d.ts +4 -4
- package/dist/modules/fields.js +2 -2
- package/dist/modules/forms.d.ts +7 -4
- package/dist/modules/forms.js +5 -2
- package/dist/modules/households.d.ts +2 -2
- package/dist/modules/households.js +2 -2
- package/dist/modules/lists.d.ts +2 -2
- package/dist/modules/lists.js +2 -2
- package/dist/modules/notes.d.ts +2 -2
- package/dist/modules/notes.js +2 -2
- package/dist/modules/people.d.ts +57 -5
- package/dist/modules/people.js +38 -8
- package/dist/modules/reports.d.ts +5 -5
- package/dist/modules/reports.js +2 -2
- package/dist/modules/service-time.d.ts +5 -5
- package/dist/modules/service-time.js +2 -2
- package/dist/modules/workflows.d.ts +2 -2
- package/dist/modules/workflows.js +2 -2
- package/dist/people/contacts.d.ts +1 -1
- package/dist/people/core.d.ts +1 -1
- package/dist/people/fields.d.ts +1 -1
- package/dist/people/fields.js +4 -4
- package/dist/people/households.d.ts +1 -1
- package/dist/people/lists.d.ts +1 -1
- package/dist/people/notes.d.ts +1 -1
- package/dist/people/organization.d.ts +1 -1
- package/dist/people/workflows.d.ts +1 -1
- package/dist/types/client.d.ts +3 -96
- package/dist/types/client.js +2 -0
- package/dist/types/index.d.ts +1 -2
- package/dist/types/index.js +0 -2
- package/dist/types/people.d.ts +15 -15
- package/package.json +15 -17
- package/dist/api-error.d.ts +0 -10
- package/dist/api-error.js +0 -32
- package/dist/batch.d.ts +0 -47
- package/dist/batch.js +0 -376
- package/dist/modules/base.d.ts +0 -46
- package/dist/modules/base.js +0 -82
- package/dist/monitoring.d.ts +0 -53
- package/dist/monitoring.js +0 -142
- package/dist/rate-limiter.d.ts +0 -79
- package/dist/rate-limiter.js +0 -137
- package/dist/types/batch.d.ts +0 -50
- package/dist/types/batch.js +0 -5
- package/dist/types/events.d.ts +0 -85
- 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
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 [
|
|
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
|
-
|
|
523
|
-
|
|
524
|
-
- **[📖
|
|
525
|
-
- **[🚀
|
|
526
|
-
- **[
|
|
527
|
-
- **[
|
|
528
|
-
- **[
|
|
529
|
-
- **[
|
|
530
|
-
- **[
|
|
531
|
-
- **[
|
|
532
|
-
- **[
|
|
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
|
|
package/dist/client-manager.js
CHANGED
|
@@ -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
|
-
|
|
123
|
-
|
|
124
|
-
|
|
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 '
|
|
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
|
|
37
|
-
off<T extends
|
|
38
|
-
emit<T extends
|
|
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?:
|
|
68
|
+
removeAllListeners(eventType?: EventType): void;
|
|
69
69
|
/**
|
|
70
70
|
* Get the number of listeners for an event type
|
|
71
71
|
*/
|
|
72
|
-
listenerCount(eventType:
|
|
72
|
+
listenerCount(eventType: EventType): number;
|
|
73
73
|
/**
|
|
74
74
|
* Get all registered event types
|
|
75
75
|
*/
|
|
76
|
-
eventTypes():
|
|
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
|
|
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
|
|
26
|
-
this.httpClient = new
|
|
27
|
-
this.paginationHelper = new
|
|
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
|
|
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
|
|
67
|
-
this.paginationHelper = new
|
|
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
|
|
125
|
+
this.batch = new planning_center_base_ts_1.BatchExecutor(this, this.eventEmitter);
|
|
129
126
|
}
|
|
130
127
|
}
|
|
131
128
|
exports.PcoClient = PcoClient;
|
package/dist/core/http.d.ts
CHANGED
|
@@ -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 '
|
|
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
|
|
8
|
-
const
|
|
9
|
-
const
|
|
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
|
|
15
|
-
this.performanceMetrics = new
|
|
16
|
-
this.rateLimitTracker = new
|
|
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
|
|
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
|
|
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 '
|
|
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 '
|
|
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("
|
|
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
|
|
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
|
|
17
|
-
Object.defineProperty(exports, "PcoApiError", { enumerable: true, get: function () { return
|
|
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
|
|
28
|
+
const rateLimiter = new planning_center_base_ts_1.PcoRateLimiter(rateLimitConfig.maxRequests, rateLimitConfig.perMilliseconds);
|
|
29
29
|
return {
|
|
30
30
|
config,
|
|
31
31
|
rateLimiter,
|
package/dist/error-handling.d.ts
CHANGED
package/dist/error-handling.js
CHANGED
|
@@ -7,7 +7,7 @@ exports.withErrorBoundary = withErrorBoundary;
|
|
|
7
7
|
exports.handleValidationError = handleValidationError;
|
|
8
8
|
exports.handleTimeoutError = handleTimeoutError;
|
|
9
9
|
exports.handleNetworkError = handleNetworkError;
|
|
10
|
-
const
|
|
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
|
|
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
|
|
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 ||
|
package/dist/error-scenarios.js
CHANGED
|
@@ -13,7 +13,7 @@ exports.withTimeout = withTimeout;
|
|
|
13
13
|
exports.classifyError = classifyError;
|
|
14
14
|
exports.attemptRecovery = attemptRecovery;
|
|
15
15
|
exports.createErrorReport = createErrorReport;
|
|
16
|
-
const
|
|
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
|
|
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
|
|
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
|
|
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 '
|
|
5
|
-
export type { BatchOperation, BatchResult, BatchOptions, BatchSummary } from '
|
|
6
|
-
export type { Paginated, Relationship, ResourceIdentifier, ResourceObject, } from '
|
|
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 '
|
|
17
|
-
export type { RateLimitHeaders, RateLimitInfo } from '
|
|
18
|
-
export { PcoRateLimiter } from '
|
|
19
|
-
export type { ErrorContext } from '
|
|
20
|
-
export { ErrorCategory, ErrorSeverity, handleNetworkError, handleTimeoutError, handleValidationError, PcoError, retryWithBackoff, shouldNotRetry, withErrorBoundary, } from '
|
|
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
|
|
46
|
-
Object.defineProperty(exports, "PcoApiError", { enumerable: true, get: function () { return
|
|
47
|
-
var
|
|
48
|
-
Object.defineProperty(exports, "PcoRateLimiter", { enumerable: true, get: function () { return
|
|
49
|
-
var
|
|
50
|
-
Object.defineProperty(exports, "ErrorCategory", { enumerable: true, get: function () { return
|
|
51
|
-
Object.defineProperty(exports, "ErrorSeverity", { enumerable: true, get: function () { return
|
|
52
|
-
Object.defineProperty(exports, "handleNetworkError", { enumerable: true, get: function () { return
|
|
53
|
-
Object.defineProperty(exports, "handleTimeoutError", { enumerable: true, get: function () { return
|
|
54
|
-
Object.defineProperty(exports, "handleValidationError", { enumerable: true, get: function () { return
|
|
55
|
-
Object.defineProperty(exports, "PcoError", { enumerable: true, get: function () { return
|
|
56
|
-
Object.defineProperty(exports, "retryWithBackoff", { enumerable: true, get: function () { return
|
|
57
|
-
Object.defineProperty(exports, "shouldNotRetry", { enumerable: true, get: function () { return
|
|
58
|
-
Object.defineProperty(exports, "withErrorBoundary", { enumerable: true, get: function () { return
|
|
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
|
*/
|