@rachelallyson/planning-center-people-ts 1.1.0 → 2.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 (56) hide show
  1. package/CHANGELOG.md +116 -0
  2. package/README.md +16 -0
  3. package/dist/batch.d.ts +47 -0
  4. package/dist/batch.js +376 -0
  5. package/dist/client-manager.d.ts +66 -0
  6. package/dist/client-manager.js +150 -0
  7. package/dist/client.d.ts +71 -0
  8. package/dist/client.js +123 -0
  9. package/dist/core/http.d.ts +47 -0
  10. package/dist/core/http.js +242 -0
  11. package/dist/core/pagination.d.ts +34 -0
  12. package/dist/core/pagination.js +164 -0
  13. package/dist/index.d.ts +13 -3
  14. package/dist/index.js +23 -5
  15. package/dist/matching/matcher.d.ts +41 -0
  16. package/dist/matching/matcher.js +161 -0
  17. package/dist/matching/scoring.d.ts +35 -0
  18. package/dist/matching/scoring.js +141 -0
  19. package/dist/matching/strategies.d.ts +35 -0
  20. package/dist/matching/strategies.js +79 -0
  21. package/dist/modules/base.d.ts +46 -0
  22. package/dist/modules/base.js +82 -0
  23. package/dist/modules/contacts.d.ts +103 -0
  24. package/dist/modules/contacts.js +130 -0
  25. package/dist/modules/fields.d.ts +157 -0
  26. package/dist/modules/fields.js +294 -0
  27. package/dist/modules/households.d.ts +42 -0
  28. package/dist/modules/households.js +74 -0
  29. package/dist/modules/lists.d.ts +62 -0
  30. package/dist/modules/lists.js +92 -0
  31. package/dist/modules/notes.d.ts +74 -0
  32. package/dist/modules/notes.js +125 -0
  33. package/dist/modules/people.d.ts +196 -0
  34. package/dist/modules/people.js +221 -0
  35. package/dist/modules/workflows.d.ts +131 -0
  36. package/dist/modules/workflows.js +221 -0
  37. package/dist/monitoring.d.ts +53 -0
  38. package/dist/monitoring.js +142 -0
  39. package/dist/testing/index.d.ts +9 -0
  40. package/dist/testing/index.js +24 -0
  41. package/dist/testing/recorder.d.ts +58 -0
  42. package/dist/testing/recorder.js +195 -0
  43. package/dist/testing/simple-builders.d.ts +33 -0
  44. package/dist/testing/simple-builders.js +124 -0
  45. package/dist/testing/simple-factories.d.ts +91 -0
  46. package/dist/testing/simple-factories.js +279 -0
  47. package/dist/testing/types.d.ts +160 -0
  48. package/dist/testing/types.js +5 -0
  49. package/dist/types/batch.d.ts +50 -0
  50. package/dist/types/batch.js +5 -0
  51. package/dist/types/client.d.ts +81 -0
  52. package/dist/types/client.js +5 -0
  53. package/dist/types/events.d.ts +85 -0
  54. package/dist/types/events.js +5 -0
  55. package/dist/types/people.d.ts +20 -1
  56. package/package.json +9 -3
@@ -0,0 +1,79 @@
1
+ "use strict";
2
+ /**
3
+ * v2.0.0 Person Matching Strategies
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.MatchStrategies = void 0;
7
+ class MatchStrategies {
8
+ /**
9
+ * Select the best match based on strategy
10
+ */
11
+ selectBestMatch(candidates, strategy) {
12
+ if (candidates.length === 0) {
13
+ return null;
14
+ }
15
+ switch (strategy) {
16
+ case 'exact':
17
+ return this.selectExactMatch(candidates);
18
+ case 'fuzzy':
19
+ return this.selectFuzzyMatch(candidates);
20
+ case 'aggressive':
21
+ return this.selectAggressiveMatch(candidates);
22
+ default:
23
+ return this.selectFuzzyMatch(candidates);
24
+ }
25
+ }
26
+ /**
27
+ * Exact matching strategy - only return matches with very high confidence
28
+ */
29
+ selectExactMatch(candidates) {
30
+ // Only return matches with score >= 0.9
31
+ const exactMatches = candidates.filter(c => c.score >= 0.9);
32
+ return exactMatches.length > 0 ? exactMatches[0] : null;
33
+ }
34
+ /**
35
+ * Fuzzy matching strategy - return best match above threshold
36
+ */
37
+ selectFuzzyMatch(candidates) {
38
+ // Return best match with score >= 0.7
39
+ const fuzzyMatches = candidates.filter(c => c.score >= 0.7);
40
+ return fuzzyMatches.length > 0 ? fuzzyMatches[0] : null;
41
+ }
42
+ /**
43
+ * Aggressive matching strategy - return best match with lower threshold
44
+ */
45
+ selectAggressiveMatch(candidates) {
46
+ // Return best match with score >= 0.5
47
+ const aggressiveMatches = candidates.filter(c => c.score >= 0.5);
48
+ return aggressiveMatches.length > 0 ? aggressiveMatches[0] : null;
49
+ }
50
+ /**
51
+ * Get all matches above threshold for a strategy
52
+ */
53
+ getAllMatchesAboveThreshold(candidates, strategy) {
54
+ const threshold = this.getThreshold(strategy);
55
+ return candidates.filter(c => c.score >= threshold);
56
+ }
57
+ /**
58
+ * Get the threshold for a strategy
59
+ */
60
+ getThreshold(strategy) {
61
+ switch (strategy) {
62
+ case 'exact':
63
+ return 0.9;
64
+ case 'fuzzy':
65
+ return 0.7;
66
+ case 'aggressive':
67
+ return 0.5;
68
+ default:
69
+ return 0.7;
70
+ }
71
+ }
72
+ /**
73
+ * Check if a score meets the strategy threshold
74
+ */
75
+ meetsThreshold(score, strategy) {
76
+ return score >= this.getThreshold(strategy);
77
+ }
78
+ }
79
+ exports.MatchStrategies = MatchStrategies;
@@ -0,0 +1,46 @@
1
+ /**
2
+ * v2.0.0 Base Module Class
3
+ */
4
+ import type { PcoHttpClient } from '../core/http';
5
+ import type { PaginationHelper } from '../core/pagination';
6
+ import type { PcoEventEmitter } from '../monitoring';
7
+ import type { PaginationOptions, PaginationResult } from '../core/pagination';
8
+ import type { ResourceObject } from '../types';
9
+ export declare abstract class BaseModule {
10
+ protected httpClient: PcoHttpClient;
11
+ protected paginationHelper: PaginationHelper;
12
+ protected eventEmitter: PcoEventEmitter;
13
+ constructor(httpClient: PcoHttpClient, paginationHelper: PaginationHelper, eventEmitter: PcoEventEmitter);
14
+ /**
15
+ * Get a single resource
16
+ */
17
+ protected getSingle<T extends ResourceObject<string, any, any>>(endpoint: string, params?: Record<string, any>): Promise<T>;
18
+ /**
19
+ * Get a list of resources
20
+ */
21
+ protected getList<T extends ResourceObject<string, any, any>>(endpoint: string, params?: Record<string, any>): Promise<{
22
+ data: T[];
23
+ meta?: any;
24
+ links?: any;
25
+ }>;
26
+ /**
27
+ * Create a resource
28
+ */
29
+ protected createResource<T extends ResourceObject<string, any, any>>(endpoint: string, data: any, params?: Record<string, any>): Promise<T>;
30
+ /**
31
+ * Update a resource
32
+ */
33
+ protected updateResource<T extends ResourceObject<string, any, any>>(endpoint: string, data: any, params?: Record<string, any>): Promise<T>;
34
+ /**
35
+ * Delete a resource
36
+ */
37
+ protected deleteResource(endpoint: string, params?: Record<string, any>): Promise<void>;
38
+ /**
39
+ * Get all pages of a resource
40
+ */
41
+ protected getAllPages<T extends ResourceObject<string, any, any>>(endpoint: string, params?: Record<string, any>, options?: PaginationOptions): Promise<PaginationResult<T>>;
42
+ /**
43
+ * Stream pages of a resource
44
+ */
45
+ protected streamPages<T extends ResourceObject<string, any, any>>(endpoint: string, params?: Record<string, any>, options?: PaginationOptions): AsyncGenerator<T[], void, unknown>;
46
+ }
@@ -0,0 +1,82 @@
1
+ "use strict";
2
+ /**
3
+ * v2.0.0 Base Module Class
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.BaseModule = void 0;
7
+ class BaseModule {
8
+ constructor(httpClient, paginationHelper, eventEmitter) {
9
+ this.httpClient = httpClient;
10
+ this.paginationHelper = paginationHelper;
11
+ this.eventEmitter = eventEmitter;
12
+ }
13
+ /**
14
+ * Get a single resource
15
+ */
16
+ async getSingle(endpoint, params) {
17
+ const response = await this.httpClient.request({
18
+ method: 'GET',
19
+ endpoint,
20
+ params,
21
+ });
22
+ return response.data.data;
23
+ }
24
+ /**
25
+ * Get a list of resources
26
+ */
27
+ async getList(endpoint, params) {
28
+ const response = await this.httpClient.request({
29
+ method: 'GET',
30
+ endpoint,
31
+ params,
32
+ });
33
+ return response.data;
34
+ }
35
+ /**
36
+ * Create a resource
37
+ */
38
+ async createResource(endpoint, data, params) {
39
+ const response = await this.httpClient.request({
40
+ method: 'POST',
41
+ endpoint,
42
+ data,
43
+ params,
44
+ });
45
+ return response.data.data;
46
+ }
47
+ /**
48
+ * Update a resource
49
+ */
50
+ async updateResource(endpoint, data, params) {
51
+ const response = await this.httpClient.request({
52
+ method: 'PATCH',
53
+ endpoint,
54
+ data,
55
+ params,
56
+ });
57
+ return response.data.data;
58
+ }
59
+ /**
60
+ * Delete a resource
61
+ */
62
+ async deleteResource(endpoint, params) {
63
+ await this.httpClient.request({
64
+ method: 'DELETE',
65
+ endpoint,
66
+ params,
67
+ });
68
+ }
69
+ /**
70
+ * Get all pages of a resource
71
+ */
72
+ async getAllPages(endpoint, params, options) {
73
+ return this.paginationHelper.getAllPages(endpoint, params, options);
74
+ }
75
+ /**
76
+ * Stream pages of a resource
77
+ */
78
+ async *streamPages(endpoint, params, options) {
79
+ yield* this.paginationHelper.streamPages(endpoint, params, options);
80
+ }
81
+ }
82
+ exports.BaseModule = BaseModule;
@@ -0,0 +1,103 @@
1
+ /**
2
+ * v2.0.0 Contacts Module
3
+ */
4
+ import { BaseModule } from './base';
5
+ import type { EmailResource, EmailAttributes, PhoneNumberResource, PhoneNumberAttributes, AddressResource, AddressAttributes, SocialProfileResource, SocialProfileAttributes } from '../types';
6
+ export declare class ContactsModule extends BaseModule {
7
+ /**
8
+ * Get all emails
9
+ */
10
+ getAllEmails(): Promise<{
11
+ data: EmailResource[];
12
+ meta?: any;
13
+ links?: any;
14
+ }>;
15
+ /**
16
+ * Get a single email by ID
17
+ */
18
+ getEmailById(id: string): Promise<EmailResource>;
19
+ /**
20
+ * Create an email
21
+ */
22
+ createEmail(data: EmailAttributes): Promise<EmailResource>;
23
+ /**
24
+ * Update an email
25
+ */
26
+ updateEmail(id: string, data: Partial<EmailAttributes>): Promise<EmailResource>;
27
+ /**
28
+ * Delete an email
29
+ */
30
+ deleteEmail(id: string): Promise<void>;
31
+ /**
32
+ * Get all phone numbers
33
+ */
34
+ getAllPhoneNumbers(): Promise<{
35
+ data: PhoneNumberResource[];
36
+ meta?: any;
37
+ links?: any;
38
+ }>;
39
+ /**
40
+ * Get a single phone number by ID
41
+ */
42
+ getPhoneNumberById(id: string): Promise<PhoneNumberResource>;
43
+ /**
44
+ * Create a phone number
45
+ */
46
+ createPhoneNumber(data: PhoneNumberAttributes): Promise<PhoneNumberResource>;
47
+ /**
48
+ * Update a phone number
49
+ */
50
+ updatePhoneNumber(id: string, data: Partial<PhoneNumberAttributes>): Promise<PhoneNumberResource>;
51
+ /**
52
+ * Delete a phone number
53
+ */
54
+ deletePhoneNumber(id: string): Promise<void>;
55
+ /**
56
+ * Get all addresses
57
+ */
58
+ getAllAddresses(): Promise<{
59
+ data: AddressResource[];
60
+ meta?: any;
61
+ links?: any;
62
+ }>;
63
+ /**
64
+ * Get a single address by ID
65
+ */
66
+ getAddressById(id: string): Promise<AddressResource>;
67
+ /**
68
+ * Create an address
69
+ */
70
+ createAddress(data: AddressAttributes): Promise<AddressResource>;
71
+ /**
72
+ * Update an address
73
+ */
74
+ updateAddress(id: string, data: Partial<AddressAttributes>): Promise<AddressResource>;
75
+ /**
76
+ * Delete an address
77
+ */
78
+ deleteAddress(id: string): Promise<void>;
79
+ /**
80
+ * Get all social profiles
81
+ */
82
+ getAllSocialProfiles(): Promise<{
83
+ data: SocialProfileResource[];
84
+ meta?: any;
85
+ links?: any;
86
+ }>;
87
+ /**
88
+ * Get a single social profile by ID
89
+ */
90
+ getSocialProfileById(id: string): Promise<SocialProfileResource>;
91
+ /**
92
+ * Create a social profile
93
+ */
94
+ createSocialProfile(data: SocialProfileAttributes): Promise<SocialProfileResource>;
95
+ /**
96
+ * Update a social profile
97
+ */
98
+ updateSocialProfile(id: string, data: Partial<SocialProfileAttributes>): Promise<SocialProfileResource>;
99
+ /**
100
+ * Delete a social profile
101
+ */
102
+ deleteSocialProfile(id: string): Promise<void>;
103
+ }
@@ -0,0 +1,130 @@
1
+ "use strict";
2
+ /**
3
+ * v2.0.0 Contacts Module
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.ContactsModule = void 0;
7
+ const base_1 = require("./base");
8
+ class ContactsModule extends base_1.BaseModule {
9
+ /**
10
+ * Get all emails
11
+ */
12
+ async getAllEmails() {
13
+ return this.getList('/emails');
14
+ }
15
+ /**
16
+ * Get a single email by ID
17
+ */
18
+ async getEmailById(id) {
19
+ return this.getSingle(`/emails/${id}`);
20
+ }
21
+ /**
22
+ * Create an email
23
+ */
24
+ async createEmail(data) {
25
+ return this.createResource('/emails', data);
26
+ }
27
+ /**
28
+ * Update an email
29
+ */
30
+ async updateEmail(id, data) {
31
+ return this.updateResource(`/emails/${id}`, data);
32
+ }
33
+ /**
34
+ * Delete an email
35
+ */
36
+ async deleteEmail(id) {
37
+ return this.deleteResource(`/emails/${id}`);
38
+ }
39
+ /**
40
+ * Get all phone numbers
41
+ */
42
+ async getAllPhoneNumbers() {
43
+ return this.getList('/phone_numbers');
44
+ }
45
+ /**
46
+ * Get a single phone number by ID
47
+ */
48
+ async getPhoneNumberById(id) {
49
+ return this.getSingle(`/phone_numbers/${id}`);
50
+ }
51
+ /**
52
+ * Create a phone number
53
+ */
54
+ async createPhoneNumber(data) {
55
+ return this.createResource('/phone_numbers', data);
56
+ }
57
+ /**
58
+ * Update a phone number
59
+ */
60
+ async updatePhoneNumber(id, data) {
61
+ return this.updateResource(`/phone_numbers/${id}`, data);
62
+ }
63
+ /**
64
+ * Delete a phone number
65
+ */
66
+ async deletePhoneNumber(id) {
67
+ return this.deleteResource(`/phone_numbers/${id}`);
68
+ }
69
+ /**
70
+ * Get all addresses
71
+ */
72
+ async getAllAddresses() {
73
+ return this.getList('/addresses');
74
+ }
75
+ /**
76
+ * Get a single address by ID
77
+ */
78
+ async getAddressById(id) {
79
+ return this.getSingle(`/addresses/${id}`);
80
+ }
81
+ /**
82
+ * Create an address
83
+ */
84
+ async createAddress(data) {
85
+ return this.createResource('/addresses', data);
86
+ }
87
+ /**
88
+ * Update an address
89
+ */
90
+ async updateAddress(id, data) {
91
+ return this.updateResource(`/addresses/${id}`, data);
92
+ }
93
+ /**
94
+ * Delete an address
95
+ */
96
+ async deleteAddress(id) {
97
+ return this.deleteResource(`/addresses/${id}`);
98
+ }
99
+ /**
100
+ * Get all social profiles
101
+ */
102
+ async getAllSocialProfiles() {
103
+ return this.getList('/social_profiles');
104
+ }
105
+ /**
106
+ * Get a single social profile by ID
107
+ */
108
+ async getSocialProfileById(id) {
109
+ return this.getSingle(`/social_profiles/${id}`);
110
+ }
111
+ /**
112
+ * Create a social profile
113
+ */
114
+ async createSocialProfile(data) {
115
+ return this.createResource('/social_profiles', data);
116
+ }
117
+ /**
118
+ * Update a social profile
119
+ */
120
+ async updateSocialProfile(id, data) {
121
+ return this.updateResource(`/social_profiles/${id}`, data);
122
+ }
123
+ /**
124
+ * Delete a social profile
125
+ */
126
+ async deleteSocialProfile(id) {
127
+ return this.deleteResource(`/social_profiles/${id}`);
128
+ }
129
+ }
130
+ exports.ContactsModule = ContactsModule;
@@ -0,0 +1,157 @@
1
+ /**
2
+ * v2.0.0 Fields Module
3
+ */
4
+ import { BaseModule } from './base';
5
+ import type { PcoHttpClient } from '../core/http';
6
+ import type { PaginationHelper } from '../core/pagination';
7
+ import type { PcoEventEmitter } from '../monitoring';
8
+ import type { FieldDefinitionResource, FieldDefinitionAttributes, FieldDatumResource, FieldOptionResource, FieldOptionAttributes, TabResource, TabAttributes } from '../types';
9
+ export interface FieldDefinitionCache {
10
+ byId: Map<string, FieldDefinitionResource>;
11
+ bySlug: Map<string, FieldDefinitionResource>;
12
+ byName: Map<string, FieldDefinitionResource>;
13
+ lastUpdated: number;
14
+ }
15
+ export interface FieldSetOptions {
16
+ /** Field definition ID */
17
+ fieldId?: string;
18
+ /** Field definition slug */
19
+ fieldSlug?: string;
20
+ /** Field definition name */
21
+ fieldName?: string;
22
+ /** Value to set */
23
+ value: string;
24
+ /** Whether to handle file uploads automatically */
25
+ handleFileUploads?: boolean;
26
+ }
27
+ export declare class FieldsModule extends BaseModule {
28
+ private fieldDefinitionCache;
29
+ private cacheTtl;
30
+ constructor(httpClient: PcoHttpClient, paginationHelper: PaginationHelper, eventEmitter: PcoEventEmitter);
31
+ /**
32
+ * Get all field definitions with caching
33
+ */
34
+ getAllFieldDefinitions(useCache?: boolean): Promise<FieldDefinitionResource[]>;
35
+ /**
36
+ * Get a single field definition by ID
37
+ */
38
+ getFieldDefinition(id: string): Promise<FieldDefinitionResource>;
39
+ /**
40
+ * Get field definition by slug
41
+ */
42
+ getFieldDefinitionBySlug(slug: string): Promise<FieldDefinitionResource | null>;
43
+ /**
44
+ * Get field definition by name
45
+ */
46
+ getFieldDefinitionByName(name: string): Promise<FieldDefinitionResource | null>;
47
+ /**
48
+ * Create a field definition
49
+ */
50
+ createFieldDefinition(tabId: string, data: FieldDefinitionAttributes): Promise<FieldDefinitionResource>;
51
+ /**
52
+ * Update a field definition
53
+ */
54
+ updateFieldDefinition(id: string, data: Partial<FieldDefinitionAttributes>): Promise<FieldDefinitionResource>;
55
+ /**
56
+ * Delete a field definition
57
+ */
58
+ deleteFieldDefinition(id: string): Promise<void>;
59
+ /**
60
+ * Get field options for a field definition
61
+ */
62
+ getFieldOptions(fieldDefinitionId: string): Promise<{
63
+ data: FieldOptionResource[];
64
+ meta?: any;
65
+ links?: any;
66
+ }>;
67
+ /**
68
+ * Create a field option
69
+ */
70
+ createFieldOption(fieldDefinitionId: string, data: FieldOptionAttributes): Promise<FieldOptionResource>;
71
+ /**
72
+ * Get person's field data
73
+ */
74
+ getPersonFieldData(personId: string): Promise<{
75
+ data: FieldDatumResource[];
76
+ meta?: any;
77
+ links?: any;
78
+ }>;
79
+ /**
80
+ * Set a person's field value with automatic field lookup
81
+ */
82
+ setPersonField(personId: string, options: FieldSetOptions): Promise<FieldDatumResource>;
83
+ /**
84
+ * Set a person's field value by field definition ID
85
+ */
86
+ setPersonFieldById(personId: string, fieldId: string, value: string): Promise<FieldDatumResource>;
87
+ /**
88
+ * Set a person's field value by field slug
89
+ */
90
+ setPersonFieldBySlug(personId: string, fieldSlug: string, value: string): Promise<FieldDatumResource>;
91
+ /**
92
+ * Set a person's field value by field name
93
+ */
94
+ setPersonFieldByName(personId: string, fieldName: string, value: string): Promise<FieldDatumResource>;
95
+ /**
96
+ * Create field data for a person
97
+ */
98
+ createPersonFieldData(personId: string, fieldDefinitionId: string, value: string, options?: {
99
+ handleFileUploads?: boolean;
100
+ }): Promise<FieldDatumResource>;
101
+ /**
102
+ * Delete person's field data
103
+ */
104
+ deletePersonFieldData(personId: string, fieldDataId: string): Promise<void>;
105
+ /**
106
+ * Get all tabs
107
+ */
108
+ getTabs(): Promise<{
109
+ data: TabResource[];
110
+ meta?: any;
111
+ links?: any;
112
+ }>;
113
+ /**
114
+ * Create a tab
115
+ */
116
+ createTab(data: TabAttributes): Promise<TabResource>;
117
+ /**
118
+ * Update a tab
119
+ */
120
+ updateTab(id: string, data: Partial<TabAttributes>): Promise<TabResource>;
121
+ /**
122
+ * Delete a tab
123
+ */
124
+ deleteTab(id: string): Promise<void>;
125
+ /**
126
+ * Resolve field definition from options
127
+ */
128
+ private resolveFieldDefinition;
129
+ /**
130
+ * Create field data for file uploads
131
+ */
132
+ private createPersonFileFieldData;
133
+ /**
134
+ * Check if cache is valid
135
+ */
136
+ private isCacheValid;
137
+ /**
138
+ * Ensure cache is loaded
139
+ */
140
+ private ensureCacheLoaded;
141
+ /**
142
+ * Update field definition cache
143
+ */
144
+ private updateFieldDefinitionCache;
145
+ /**
146
+ * Invalidate cache
147
+ */
148
+ private invalidateCache;
149
+ /**
150
+ * Check if a value is a file URL
151
+ */
152
+ private isFileUrl;
153
+ /**
154
+ * Extract file URL from HTML markup
155
+ */
156
+ private extractFileUrl;
157
+ }