@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.
Files changed (82) hide show
  1. package/CHANGELOG.md +248 -1
  2. package/README.md +28 -0
  3. package/dist/auth.d.ts +64 -0
  4. package/dist/auth.js +98 -0
  5. package/dist/batch.d.ts +47 -0
  6. package/dist/batch.js +376 -0
  7. package/dist/client-manager.d.ts +66 -0
  8. package/dist/client-manager.js +150 -0
  9. package/dist/client.d.ts +71 -0
  10. package/dist/client.js +123 -0
  11. package/dist/core/http.d.ts +47 -0
  12. package/dist/core/http.js +242 -0
  13. package/dist/core/pagination.d.ts +34 -0
  14. package/dist/core/pagination.js +164 -0
  15. package/dist/core.d.ts +5 -0
  16. package/dist/core.js +12 -0
  17. package/dist/helpers.d.ts +125 -100
  18. package/dist/helpers.js +315 -275
  19. package/dist/index.d.ts +17 -5
  20. package/dist/index.js +39 -5
  21. package/dist/matching/matcher.d.ts +41 -0
  22. package/dist/matching/matcher.js +161 -0
  23. package/dist/matching/scoring.d.ts +35 -0
  24. package/dist/matching/scoring.js +141 -0
  25. package/dist/matching/strategies.d.ts +35 -0
  26. package/dist/matching/strategies.js +79 -0
  27. package/dist/modules/base.d.ts +46 -0
  28. package/dist/modules/base.js +82 -0
  29. package/dist/modules/contacts.d.ts +103 -0
  30. package/dist/modules/contacts.js +130 -0
  31. package/dist/modules/fields.d.ts +157 -0
  32. package/dist/modules/fields.js +294 -0
  33. package/dist/modules/households.d.ts +42 -0
  34. package/dist/modules/households.js +74 -0
  35. package/dist/modules/lists.d.ts +62 -0
  36. package/dist/modules/lists.js +92 -0
  37. package/dist/modules/notes.d.ts +74 -0
  38. package/dist/modules/notes.js +125 -0
  39. package/dist/modules/people.d.ts +196 -0
  40. package/dist/modules/people.js +221 -0
  41. package/dist/modules/workflows.d.ts +131 -0
  42. package/dist/modules/workflows.js +221 -0
  43. package/dist/monitoring.d.ts +53 -0
  44. package/dist/monitoring.js +142 -0
  45. package/dist/people/contacts.d.ts +43 -0
  46. package/dist/people/contacts.js +122 -0
  47. package/dist/people/core.d.ts +28 -0
  48. package/dist/people/core.js +69 -0
  49. package/dist/people/fields.d.ts +62 -0
  50. package/dist/people/fields.js +293 -0
  51. package/dist/people/households.d.ts +15 -0
  52. package/dist/people/households.js +31 -0
  53. package/dist/people/index.d.ts +8 -0
  54. package/dist/people/index.js +25 -0
  55. package/dist/people/lists.d.ts +30 -0
  56. package/dist/people/lists.js +37 -0
  57. package/dist/people/notes.d.ts +30 -0
  58. package/dist/people/notes.js +37 -0
  59. package/dist/people/organization.d.ts +12 -0
  60. package/dist/people/organization.js +15 -0
  61. package/dist/people/workflows.d.ts +37 -0
  62. package/dist/people/workflows.js +75 -0
  63. package/dist/testing/index.d.ts +9 -0
  64. package/dist/testing/index.js +24 -0
  65. package/dist/testing/recorder.d.ts +58 -0
  66. package/dist/testing/recorder.js +195 -0
  67. package/dist/testing/simple-builders.d.ts +33 -0
  68. package/dist/testing/simple-builders.js +124 -0
  69. package/dist/testing/simple-factories.d.ts +91 -0
  70. package/dist/testing/simple-factories.js +279 -0
  71. package/dist/testing/types.d.ts +160 -0
  72. package/dist/testing/types.js +5 -0
  73. package/dist/types/batch.d.ts +50 -0
  74. package/dist/types/batch.js +5 -0
  75. package/dist/types/client.d.ts +81 -0
  76. package/dist/types/client.js +5 -0
  77. package/dist/types/events.d.ts +85 -0
  78. package/dist/types/events.js +5 -0
  79. package/dist/types/people.d.ts +73 -79
  80. package/package.json +14 -3
  81. package/dist/people.d.ts +0 -205
  82. 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
- * Helper Functions for Common PCO People API Operations
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
- import type { PcoClientState } from './core';
8
- import type { AddressResource, EmailResource, FieldDatumResource, ListResource, NoteResource, OrganizationResource, PersonResource, PhoneNumberResource, SocialProfileResource, WorkflowCardNoteResource, WorkflowCardResource } from './types';
9
- /**
10
- * Get a complete person profile with all related data
11
- */
12
- export declare function getCompletePersonProfile(client: PcoClientState, personId: string): Promise<{
13
- person: PersonResource;
14
- emails: EmailResource[];
15
- phoneNumbers: PhoneNumberResource[];
16
- addresses: AddressResource[];
17
- socialProfiles: SocialProfileResource[];
18
- fieldData: FieldDatumResource[];
19
- workflowCards: WorkflowCardResource[];
20
- notes: NoteResource[];
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
- * Create a person with initial contact information
35
+ * Format date string in various formats
24
36
  */
25
- export declare function createPersonWithContact(client: PcoClientState, personData: {
26
- first_name: string;
27
- last_name: string;
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
- * Search for people by multiple criteria
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
- phone?: string;
49
- status?: string;
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<PersonResource[]>;
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
- * Create a workflow card with an initial note
80
+ * Get complete person profile with all related data
64
81
  */
65
- export declare function createWorkflowCardWithNote(client: PcoClientState, personId: string, workflowId: string, cardData: {
66
- title: string;
67
- description?: string;
68
- initialNote?: string;
69
- }): Promise<{
70
- card: WorkflowCardResource;
71
- note?: WorkflowCardNoteResource;
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 all lists with their categories
91
+ * Get organization info with statistics
75
92
  */
76
- export declare function getListsWithCategories(client: PcoClientState): Promise<(ListResource & {
77
- category?: any;
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
- * Export all people data to a structured format
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
- batchSize?: number;
99
- }): Promise<{
100
- person: PersonResource;
101
- emails: EmailResource[];
102
- phoneNumbers: PhoneNumberResource[];
103
- addresses: AddressResource[];
104
- socialProfiles: SocialProfileResource[];
105
- fieldData?: FieldDatumResource[];
106
- workflowCards?: WorkflowCardResource[];
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
- * Validate email format
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 isValidEmail(email: string): boolean;
144
+ export declare function extractFileUrl(value: string): string;
119
145
  /**
120
- * Validate phone format (basic validation)
146
+ * Determines if a value contains a file URL
121
147
  */
122
- export declare function isValidPhone(phone: string): boolean;
148
+ export declare function isFileUrl(value: string): boolean;
123
149
  /**
124
- * Format person name for display
150
+ * Gets file extension from URL
125
151
  */
126
- export declare function formatPersonName(person: PersonResource): string;
152
+ export declare function getFileExtension(url: string): string;
127
153
  /**
128
- * Get primary contact information for a person
154
+ * Gets filename from URL
129
155
  */
130
- export declare function getPrimaryContact(person: PersonResource, relatedData: {
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
- * Calculate age from birthdate
158
+ * Determines if a field value represents a file upload
139
159
  */
140
- export declare function calculateAge(birthdate: string): number | null;
160
+ export declare function isFileUpload(value: string): boolean;
141
161
  /**
142
- * Format date for display
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 formatDate(dateString: string, format?: 'short' | 'long' | 'iso'): string;
165
+ export declare function processFileValue(value: string, fieldType?: 'text' | 'file'): string | {
166
+ url: string;
167
+ filename: string;
168
+ contentType: string;
169
+ };