@rachelallyson/planning-center-people-ts 1.0.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.
- package/CHANGELOG.md +248 -1
- package/README.md +28 -0
- package/dist/auth.d.ts +64 -0
- package/dist/auth.js +98 -0
- package/dist/batch.d.ts +47 -0
- package/dist/batch.js +376 -0
- package/dist/client-manager.d.ts +66 -0
- package/dist/client-manager.js +150 -0
- package/dist/client.d.ts +71 -0
- package/dist/client.js +123 -0
- package/dist/core/http.d.ts +47 -0
- package/dist/core/http.js +242 -0
- package/dist/core/pagination.d.ts +34 -0
- package/dist/core/pagination.js +164 -0
- package/dist/core.d.ts +5 -0
- package/dist/core.js +12 -0
- package/dist/helpers.d.ts +125 -100
- package/dist/helpers.js +315 -275
- package/dist/index.d.ts +17 -5
- package/dist/index.js +39 -5
- package/dist/matching/matcher.d.ts +41 -0
- package/dist/matching/matcher.js +161 -0
- package/dist/matching/scoring.d.ts +35 -0
- package/dist/matching/scoring.js +141 -0
- package/dist/matching/strategies.d.ts +35 -0
- package/dist/matching/strategies.js +79 -0
- package/dist/modules/base.d.ts +46 -0
- package/dist/modules/base.js +82 -0
- package/dist/modules/contacts.d.ts +103 -0
- package/dist/modules/contacts.js +130 -0
- package/dist/modules/fields.d.ts +157 -0
- package/dist/modules/fields.js +294 -0
- package/dist/modules/households.d.ts +42 -0
- package/dist/modules/households.js +74 -0
- package/dist/modules/lists.d.ts +62 -0
- package/dist/modules/lists.js +92 -0
- package/dist/modules/notes.d.ts +74 -0
- package/dist/modules/notes.js +125 -0
- package/dist/modules/people.d.ts +196 -0
- package/dist/modules/people.js +221 -0
- package/dist/modules/workflows.d.ts +131 -0
- package/dist/modules/workflows.js +221 -0
- package/dist/monitoring.d.ts +53 -0
- package/dist/monitoring.js +142 -0
- package/dist/people/contacts.d.ts +43 -0
- package/dist/people/contacts.js +122 -0
- package/dist/people/core.d.ts +28 -0
- package/dist/people/core.js +69 -0
- package/dist/people/fields.d.ts +62 -0
- package/dist/people/fields.js +293 -0
- package/dist/people/households.d.ts +15 -0
- package/dist/people/households.js +31 -0
- package/dist/people/index.d.ts +8 -0
- package/dist/people/index.js +25 -0
- package/dist/people/lists.d.ts +30 -0
- package/dist/people/lists.js +37 -0
- package/dist/people/notes.d.ts +30 -0
- package/dist/people/notes.js +37 -0
- package/dist/people/organization.d.ts +12 -0
- package/dist/people/organization.js +15 -0
- package/dist/people/workflows.d.ts +37 -0
- package/dist/people/workflows.js +75 -0
- package/dist/testing/index.d.ts +9 -0
- package/dist/testing/index.js +24 -0
- package/dist/testing/recorder.d.ts +58 -0
- package/dist/testing/recorder.js +195 -0
- package/dist/testing/simple-builders.d.ts +33 -0
- package/dist/testing/simple-builders.js +124 -0
- package/dist/testing/simple-factories.d.ts +91 -0
- package/dist/testing/simple-factories.js +279 -0
- package/dist/testing/types.d.ts +160 -0
- package/dist/testing/types.js +5 -0
- package/dist/types/batch.d.ts +50 -0
- package/dist/types/batch.js +5 -0
- package/dist/types/client.d.ts +81 -0
- package/dist/types/client.js +5 -0
- package/dist/types/events.d.ts +85 -0
- package/dist/types/events.js +5 -0
- package/dist/types/people.d.ts +73 -79
- package/package.json +14 -3
- package/dist/people.d.ts +0 -205
- package/dist/people.js +0 -598
package/dist/helpers.d.ts
CHANGED
|
@@ -1,144 +1,169 @@
|
|
|
1
|
+
import type { PcoClientState } from './core';
|
|
2
|
+
import type { ErrorContext } from './error-handling';
|
|
3
|
+
import type { PersonAttributes, EmailAttributes, PhoneNumberAttributes, AddressAttributes, WorkflowCardNoteAttributes, PeopleList, PersonSingle, EmailSingle, PhoneNumberSingle, AddressSingle, WorkflowCardSingle, WorkflowCardNoteSingle, ListsList, ListCategoriesList, OrganizationSingle } from './types';
|
|
1
4
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
* This module provides convenient helper functions for common operations
|
|
5
|
-
* that combine multiple API calls or provide higher-level abstractions.
|
|
5
|
+
* Transform complex params object into flat query params for API calls
|
|
6
6
|
*/
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
7
|
+
export declare function buildQueryParams(params?: {
|
|
8
|
+
where?: Record<string, any>;
|
|
9
|
+
include?: string[];
|
|
10
|
+
per_page?: number;
|
|
11
|
+
page?: number;
|
|
12
|
+
filter?: string;
|
|
13
|
+
}): Record<string, any>;
|
|
14
|
+
/**
|
|
15
|
+
* Calculate age from birthdate string
|
|
16
|
+
*/
|
|
17
|
+
export declare function calculateAge(birthdate: string): number;
|
|
18
|
+
/**
|
|
19
|
+
* Validate email format
|
|
20
|
+
*/
|
|
21
|
+
export declare function isValidEmail(email: string): boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Validate phone number format (basic validation)
|
|
24
|
+
*/
|
|
25
|
+
export declare function isValidPhone(phone: string): boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Format person name from attributes
|
|
28
|
+
*/
|
|
29
|
+
export declare function formatPersonName(person: {
|
|
30
|
+
first_name?: string;
|
|
31
|
+
last_name?: string;
|
|
32
|
+
nickname?: string;
|
|
33
|
+
}): string;
|
|
22
34
|
/**
|
|
23
|
-
*
|
|
35
|
+
* Format date string in various formats
|
|
24
36
|
*/
|
|
25
|
-
export declare function
|
|
26
|
-
|
|
27
|
-
|
|
37
|
+
export declare function formatDate(dateString: string, format?: 'short' | 'long' | 'iso'): string;
|
|
38
|
+
/**
|
|
39
|
+
* Validate person data
|
|
40
|
+
*/
|
|
41
|
+
export declare function validatePersonData(data: Partial<PersonAttributes>): {
|
|
42
|
+
isValid: boolean;
|
|
43
|
+
errors: string[];
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* Get primary contact information for a person
|
|
47
|
+
*/
|
|
48
|
+
export declare function getPrimaryContact(client: PcoClientState, personId: string, context?: Partial<ErrorContext>): Promise<{
|
|
28
49
|
email?: string;
|
|
29
50
|
phone?: string;
|
|
30
|
-
address?:
|
|
31
|
-
address1: string;
|
|
32
|
-
city: string;
|
|
33
|
-
state: string;
|
|
34
|
-
zip: string;
|
|
35
|
-
};
|
|
36
|
-
}): Promise<{
|
|
37
|
-
person: PersonResource;
|
|
38
|
-
email?: EmailResource;
|
|
39
|
-
phone?: PhoneNumberResource;
|
|
40
|
-
address?: AddressResource;
|
|
51
|
+
address?: string;
|
|
41
52
|
}>;
|
|
42
53
|
/**
|
|
43
|
-
*
|
|
54
|
+
* Create a person with contact information
|
|
55
|
+
*/
|
|
56
|
+
export declare function createPersonWithContact(client: PcoClientState, personData: Partial<PersonAttributes>, contactData?: {
|
|
57
|
+
email?: Partial<EmailAttributes>;
|
|
58
|
+
phone?: Partial<PhoneNumberAttributes>;
|
|
59
|
+
address?: Partial<AddressAttributes>;
|
|
60
|
+
}, context?: Partial<ErrorContext>): Promise<{
|
|
61
|
+
person: PersonSingle;
|
|
62
|
+
email?: EmailSingle;
|
|
63
|
+
phone?: PhoneNumberSingle;
|
|
64
|
+
address?: AddressSingle;
|
|
65
|
+
}>;
|
|
66
|
+
/**
|
|
67
|
+
* Search people by multiple criteria
|
|
44
68
|
*/
|
|
45
69
|
export declare function searchPeople(client: PcoClientState, criteria: {
|
|
70
|
+
status?: string;
|
|
46
71
|
name?: string;
|
|
47
72
|
email?: string;
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
household?: string;
|
|
51
|
-
}): Promise<PersonResource[]>;
|
|
73
|
+
per_page?: number;
|
|
74
|
+
}, context?: Partial<ErrorContext>): Promise<PeopleList>;
|
|
52
75
|
/**
|
|
53
76
|
* Get people by household
|
|
54
77
|
*/
|
|
55
|
-
export declare function getPeopleByHousehold(client: PcoClientState, householdId: string): Promise<
|
|
56
|
-
/**
|
|
57
|
-
* Get all workflow cards for a person with their notes
|
|
58
|
-
*/
|
|
59
|
-
export declare function getPersonWorkflowCardsWithNotes(client: PcoClientState, personId: string): Promise<(WorkflowCardResource & {
|
|
60
|
-
notes: WorkflowCardNoteResource[];
|
|
61
|
-
})[]>;
|
|
78
|
+
export declare function getPeopleByHousehold(client: PcoClientState, householdId: string, context?: Partial<ErrorContext>): Promise<PeopleList>;
|
|
62
79
|
/**
|
|
63
|
-
*
|
|
80
|
+
* Get complete person profile with all related data
|
|
64
81
|
*/
|
|
65
|
-
export declare function
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
82
|
+
export declare function getCompletePersonProfile(client: PcoClientState, personId: string, context?: Partial<ErrorContext>): Promise<{
|
|
83
|
+
person: PersonSingle;
|
|
84
|
+
emails: any;
|
|
85
|
+
phones: any;
|
|
86
|
+
addresses: any;
|
|
87
|
+
fieldData: any;
|
|
88
|
+
workflowCards: any;
|
|
72
89
|
}>;
|
|
73
90
|
/**
|
|
74
|
-
* Get
|
|
91
|
+
* Get organization info with statistics
|
|
75
92
|
*/
|
|
76
|
-
export declare function
|
|
77
|
-
|
|
78
|
-
})[]>;
|
|
79
|
-
/**
|
|
80
|
-
* Get organization information with statistics
|
|
81
|
-
*/
|
|
82
|
-
export declare function getOrganizationInfo(client: PcoClientState): Promise<{
|
|
83
|
-
organization: OrganizationResource;
|
|
93
|
+
export declare function getOrganizationInfo(client: PcoClientState, context?: Partial<ErrorContext>): Promise<{
|
|
94
|
+
organization: OrganizationSingle;
|
|
84
95
|
stats: {
|
|
85
96
|
totalPeople: number;
|
|
86
97
|
totalHouseholds: number;
|
|
87
98
|
totalLists: number;
|
|
88
|
-
totalWorkflows: number;
|
|
89
99
|
};
|
|
90
100
|
}>;
|
|
91
101
|
/**
|
|
92
|
-
*
|
|
102
|
+
* Get lists with their categories
|
|
103
|
+
*/
|
|
104
|
+
export declare function getListsWithCategories(client: PcoClientState, context?: Partial<ErrorContext>): Promise<{
|
|
105
|
+
lists: ListsList;
|
|
106
|
+
categories: ListCategoriesList;
|
|
107
|
+
}>;
|
|
108
|
+
/**
|
|
109
|
+
* Get workflow cards with notes for a person
|
|
110
|
+
*/
|
|
111
|
+
export declare function getPersonWorkflowCardsWithNotes(client: PcoClientState, personId: string, context?: Partial<ErrorContext>): Promise<{
|
|
112
|
+
workflowCards: any;
|
|
113
|
+
notes: {
|
|
114
|
+
[cardId: string]: any;
|
|
115
|
+
};
|
|
116
|
+
}>;
|
|
117
|
+
/**
|
|
118
|
+
* Create a workflow card with a note
|
|
119
|
+
*/
|
|
120
|
+
export declare function createWorkflowCardWithNote(client: PcoClientState, workflowId: string, personId: string, noteData: Partial<WorkflowCardNoteAttributes>, context?: Partial<ErrorContext>): Promise<{
|
|
121
|
+
workflowCard: WorkflowCardSingle;
|
|
122
|
+
note: WorkflowCardNoteSingle;
|
|
123
|
+
}>;
|
|
124
|
+
/**
|
|
125
|
+
* Export all people data in a structured format
|
|
93
126
|
*/
|
|
94
127
|
export declare function exportAllPeopleData(client: PcoClientState, options?: {
|
|
95
128
|
includeInactive?: boolean;
|
|
96
129
|
includeFieldData?: boolean;
|
|
97
130
|
includeWorkflowCards?: boolean;
|
|
98
|
-
|
|
99
|
-
}): Promise<{
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
}[]>;
|
|
108
|
-
/**
|
|
109
|
-
* Validate person data before creation/update
|
|
110
|
-
*/
|
|
111
|
-
export declare function validatePersonData(data: any): {
|
|
112
|
-
isValid: boolean;
|
|
113
|
-
errors: string[];
|
|
114
|
-
};
|
|
131
|
+
perPage?: number;
|
|
132
|
+
}, context?: Partial<ErrorContext>): Promise<{
|
|
133
|
+
people: any[];
|
|
134
|
+
households: any[];
|
|
135
|
+
lists: any[];
|
|
136
|
+
organization: any;
|
|
137
|
+
exportDate: string;
|
|
138
|
+
totalCount: number;
|
|
139
|
+
}>;
|
|
115
140
|
/**
|
|
116
|
-
*
|
|
141
|
+
* Extracts clean URL from HTML markup that contains file links
|
|
142
|
+
* Handles cases like: <a href="https://onark.s3.us-east-1.amazonaws.com/file.pdf" download>View File: https://onark.s3.us-east-1.amazonaws.com/file.pdf</a>
|
|
117
143
|
*/
|
|
118
|
-
export declare function
|
|
144
|
+
export declare function extractFileUrl(value: string): string;
|
|
119
145
|
/**
|
|
120
|
-
*
|
|
146
|
+
* Determines if a value contains a file URL
|
|
121
147
|
*/
|
|
122
|
-
export declare function
|
|
148
|
+
export declare function isFileUrl(value: string): boolean;
|
|
123
149
|
/**
|
|
124
|
-
*
|
|
150
|
+
* Gets file extension from URL
|
|
125
151
|
*/
|
|
126
|
-
export declare function
|
|
152
|
+
export declare function getFileExtension(url: string): string;
|
|
127
153
|
/**
|
|
128
|
-
*
|
|
154
|
+
* Gets filename from URL
|
|
129
155
|
*/
|
|
130
|
-
export declare function
|
|
131
|
-
emails?: EmailResource[];
|
|
132
|
-
phoneNumbers?: PhoneNumberResource[];
|
|
133
|
-
}): {
|
|
134
|
-
email?: string;
|
|
135
|
-
phone?: string;
|
|
136
|
-
};
|
|
156
|
+
export declare function getFilename(url: string): string;
|
|
137
157
|
/**
|
|
138
|
-
*
|
|
158
|
+
* Determines if a field value represents a file upload
|
|
139
159
|
*/
|
|
140
|
-
export declare function
|
|
160
|
+
export declare function isFileUpload(value: string): boolean;
|
|
141
161
|
/**
|
|
142
|
-
*
|
|
162
|
+
* Processes file upload value for PCO field
|
|
163
|
+
* Returns clean URL for text fields, or file data for file fields
|
|
143
164
|
*/
|
|
144
|
-
export declare function
|
|
165
|
+
export declare function processFileValue(value: string, fieldType?: 'text' | 'file'): string | {
|
|
166
|
+
url: string;
|
|
167
|
+
filename: string;
|
|
168
|
+
contentType: string;
|
|
169
|
+
};
|