@rachelallyson/planning-center-people-ts 2.6.0 โ†’ 2.6.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 CHANGED
@@ -5,12 +5,56 @@ 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.6.1] - 2025-01-10
9
+
10
+ ### ๐Ÿ› **CRITICAL BUG FIXES**
11
+
12
+ This patch release fixes critical bugs in the `findOrCreate` method that would cause runtime errors and API failures.
13
+
14
+ ### Fixed
15
+
16
+ - **๐Ÿ› Critical Bug in findOrCreate**: Fixed broken contact creation in `findOrCreate` method
17
+ - **Issue**: `createWithContacts` method didn't exist, causing runtime errors
18
+ - **Issue**: Email/phone passed to person creation caused 422 API errors
19
+ - **Fix**: Now properly creates person first, then adds contacts separately
20
+ - **Enhancement**: Added campus assignment support with `campusId` option
21
+ - **Enhancement**: Added proper error handling for contact creation failures
22
+
23
+ ### Changed
24
+
25
+ - **๐Ÿงน Cleaned up PersonMatchOptions interface**: Removed unused `campus` field, kept only functional `campusId` field
26
+ - **๐Ÿ“ Better error handling**: Contact creation failures now log warnings instead of crashing
27
+
28
+ ### Migration
29
+
30
+ No breaking changes - this is a bug fix release:
31
+
32
+ ```typescript
33
+ // This now works correctly (was broken in 2.6.0)
34
+ const person = await client.people.findOrCreate({
35
+ firstName: 'John',
36
+ lastName: 'Doe',
37
+ email: 'john@example.com',
38
+ phone: '555-1234',
39
+ campusId: 'campus-123' // NEW: Campus assignment support
40
+ });
41
+ ```
42
+
8
43
  ## [2.6.0] - 2025-01-10
9
44
 
10
45
  ### ๐ŸŽฏ **PERFORMANCE & DEPENDENCY OPTIMIZATION**
11
46
 
12
47
  This release focuses on performance improvements and dependency optimization, making the library lighter, faster, and more efficient.
13
48
 
49
+ ### Fixed
50
+
51
+ - **๐Ÿ› Critical Bug in findOrCreate**: Fixed broken contact creation in `findOrCreate` method
52
+ - **Issue**: `createWithContacts` method didn't exist, causing runtime errors
53
+ - **Issue**: Email/phone passed to person creation caused 422 API errors
54
+ - **Fix**: Now properly creates person first, then adds contacts separately
55
+ - **Enhancement**: Added campus assignment support with `campusId` option
56
+ - **Enhancement**: Added proper error handling for contact creation failures
57
+
14
58
  ### Removed
15
59
 
16
60
  - **๐Ÿ“ฆ Axios Dependency**: Completely removed axios dependency by replacing it with native fetch API
@@ -132,26 +132,46 @@ class PersonMatcher {
132
132
  * Create a new person
133
133
  */
134
134
  async createPerson(options) {
135
+ // Create basic person data (only name fields)
135
136
  const personData = {};
136
137
  if (options.firstName)
137
138
  personData.first_name = options.firstName;
138
139
  if (options.lastName)
139
140
  personData.last_name = options.lastName;
140
- if (options.email)
141
- personData.email = options.email;
142
- if (options.phone)
143
- personData.phone = options.phone;
141
+ // Create the person first
144
142
  const person = await this.peopleModule.create(personData);
145
- // Add contact information if provided
146
- const contacts = {};
143
+ // Add email contact if provided
147
144
  if (options.email) {
148
- contacts.email = { address: options.email, primary: true };
145
+ try {
146
+ await this.peopleModule.addEmail(person.id, {
147
+ address: options.email,
148
+ primary: true
149
+ });
150
+ }
151
+ catch (error) {
152
+ console.warn('Failed to create email contact:', error);
153
+ }
149
154
  }
155
+ // Add phone contact if provided
150
156
  if (options.phone) {
151
- contacts.phone = { number: options.phone, primary: true };
157
+ try {
158
+ await this.peopleModule.addPhoneNumber(person.id, {
159
+ number: options.phone,
160
+ primary: true
161
+ });
162
+ }
163
+ catch (error) {
164
+ console.warn('Failed to create phone contact:', error);
165
+ }
152
166
  }
153
- if (Object.keys(contacts).length > 0) {
154
- await this.peopleModule.createWithContacts(personData, contacts);
167
+ // Set campus if provided
168
+ if (options.campusId) {
169
+ try {
170
+ await this.peopleModule.setPrimaryCampus(person.id, options.campusId);
171
+ }
172
+ catch (error) {
173
+ console.warn('Failed to set campus:', error);
174
+ }
155
175
  }
156
176
  return person;
157
177
  }
@@ -48,7 +48,7 @@ export interface PersonMatchOptions {
48
48
  email?: string;
49
49
  phone?: string;
50
50
  matchStrategy?: 'exact' | 'fuzzy' | 'aggressive';
51
- campus?: string;
51
+ campusId?: string;
52
52
  createIfNotFound?: boolean;
53
53
  agePreference?: 'adults' | 'children' | 'any';
54
54
  minAge?: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rachelallyson/planning-center-people-ts",
3
- "version": "2.6.0",
3
+ "version": "2.6.1",
4
4
  "description": "A strictly typed TypeScript client for Planning Center Online People API with smart matching, batch operations, and enhanced developer experience",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",