@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
@@ -0,0 +1,221 @@
1
+ "use strict";
2
+ /**
3
+ * v2.0.0 Workflows Module
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.WorkflowsModule = void 0;
7
+ const base_1 = require("./base");
8
+ class WorkflowsModule extends base_1.BaseModule {
9
+ /**
10
+ * Get all workflows
11
+ */
12
+ async getAll(options = {}) {
13
+ const params = {};
14
+ if (options.where) {
15
+ Object.entries(options.where).forEach(([key, value]) => {
16
+ params[`where[${key}]`] = value;
17
+ });
18
+ }
19
+ if (options.include) {
20
+ params.include = options.include.join(',');
21
+ }
22
+ if (options.perPage) {
23
+ params.per_page = options.perPage;
24
+ }
25
+ if (options.page) {
26
+ params.page = options.page;
27
+ }
28
+ return this.getList('/workflows', params);
29
+ }
30
+ /**
31
+ * Get all workflows across all pages
32
+ */
33
+ async getAllPagesPaginated(options = {}, paginationOptions) {
34
+ const params = {};
35
+ if (options.where) {
36
+ Object.entries(options.where).forEach(([key, value]) => {
37
+ params[`where[${key}]`] = value;
38
+ });
39
+ }
40
+ if (options.include) {
41
+ params.include = options.include.join(',');
42
+ }
43
+ return this.getAllPages('/workflows', params, paginationOptions);
44
+ }
45
+ /**
46
+ * Get a single workflow by ID
47
+ */
48
+ async getById(id, include) {
49
+ const params = {};
50
+ if (include) {
51
+ params.include = include.join(',');
52
+ }
53
+ return this.getSingle(`/workflows/${id}`, params);
54
+ }
55
+ /**
56
+ * Create a workflow
57
+ */
58
+ async create(data) {
59
+ return this.createResource('/workflows', data);
60
+ }
61
+ /**
62
+ * Update a workflow
63
+ */
64
+ async update(id, data) {
65
+ return this.updateResource(`/workflows/${id}`, data);
66
+ }
67
+ /**
68
+ * Delete a workflow
69
+ */
70
+ async delete(id) {
71
+ return this.deleteResource(`/workflows/${id}`);
72
+ }
73
+ /**
74
+ * Get workflow cards for a person
75
+ */
76
+ async getPersonWorkflowCards(personId) {
77
+ return this.getList(`/people/${personId}/workflow_cards`);
78
+ }
79
+ /**
80
+ * Add a person to a workflow with smart duplicate detection
81
+ */
82
+ async addPersonToWorkflow(personId, workflowId, options = {}) {
83
+ const { skipIfExists = true, skipIfActive = true } = options;
84
+ // Check for existing workflow cards if requested
85
+ if (skipIfExists || skipIfActive) {
86
+ const existingCards = await this.getPersonWorkflowCards(personId);
87
+ const existingCard = existingCards.data.find(card => {
88
+ const workflowData = card.relationships?.workflow?.data;
89
+ return workflowData && !Array.isArray(workflowData) && workflowData.id === workflowId;
90
+ });
91
+ if (existingCard && existingCard.attributes) {
92
+ // Check if card is completed or removed
93
+ if (skipIfExists && (existingCard.attributes.completed_at || existingCard.attributes.removed_at)) {
94
+ throw new Error(`Person already has a completed/removed card in this workflow`);
95
+ }
96
+ // Check if card is active
97
+ if (skipIfActive && !existingCard.attributes.completed_at && !existingCard.attributes.removed_at) {
98
+ throw new Error(`Person already has an active card in this workflow`);
99
+ }
100
+ }
101
+ }
102
+ // Create the workflow card
103
+ const workflowCard = await this.createResource(`/workflows/${workflowId}/cards`, {
104
+ person_id: personId,
105
+ });
106
+ // Add note if provided
107
+ if (options.note || options.noteTemplate) {
108
+ const noteText = options.note || this.formatNoteTemplate(options.noteTemplate, { personId, workflowId });
109
+ await this.createWorkflowCardNote(personId, workflowCard.id, { note: noteText });
110
+ }
111
+ return workflowCard;
112
+ }
113
+ /**
114
+ * Create a workflow card
115
+ */
116
+ async createWorkflowCard(workflowId, personId) {
117
+ return this.createResource(`/workflows/${workflowId}/cards`, {
118
+ person_id: personId,
119
+ });
120
+ }
121
+ /**
122
+ * Update a workflow card
123
+ */
124
+ async updateWorkflowCard(workflowCardId, data, personId) {
125
+ // If personId is provided, use the person-specific endpoint
126
+ if (personId) {
127
+ return this.updateResource(`/people/${personId}/workflow_cards/${workflowCardId}`, data);
128
+ }
129
+ // Fallback to the generic endpoint (may not work for all operations)
130
+ return this.updateResource(`/workflow_cards/${workflowCardId}`, data);
131
+ }
132
+ /**
133
+ * Get workflow card notes
134
+ */
135
+ async getWorkflowCardNotes(personId, workflowCardId) {
136
+ return this.getList(`/people/${personId}/workflow_cards/${workflowCardId}/notes`);
137
+ }
138
+ /**
139
+ * Create a workflow card note
140
+ */
141
+ async createWorkflowCardNote(personId, workflowCardId, data) {
142
+ return this.createResource(`/people/${personId}/workflow_cards/${workflowCardId}/notes`, data);
143
+ }
144
+ /**
145
+ * Update a workflow card note
146
+ */
147
+ async updateWorkflowCardNote(personId, workflowCardId, noteId, data) {
148
+ return this.updateResource(`/people/${personId}/workflow_cards/${workflowCardId}/notes/${noteId}`, data);
149
+ }
150
+ /**
151
+ * Delete a workflow card note
152
+ */
153
+ async deleteWorkflowCardNote(personId, workflowCardId, noteId) {
154
+ return this.deleteResource(`/people/${personId}/workflow_cards/${workflowCardId}/notes/${noteId}`);
155
+ }
156
+ /**
157
+ * Create a workflow card with a note
158
+ */
159
+ async createWorkflowCardWithNote(workflowId, personId, noteData) {
160
+ const workflowCard = await this.createWorkflowCard(workflowId, personId);
161
+ const note = await this.createWorkflowCardNote(personId, workflowCard.id, noteData);
162
+ return { workflowCard, note };
163
+ }
164
+ /**
165
+ * Move a workflow card back to the previous step
166
+ */
167
+ async goBackWorkflowCard(personId, workflowCardId) {
168
+ return this.createResource(`/people/${personId}/workflow_cards/${workflowCardId}/go_back`, {});
169
+ }
170
+ /**
171
+ * Move a workflow card to the next step
172
+ */
173
+ async promoteWorkflowCard(personId, workflowCardId) {
174
+ return this.createResource(`/people/${personId}/workflow_cards/${workflowCardId}/promote`, {});
175
+ }
176
+ /**
177
+ * Remove a workflow card
178
+ */
179
+ async removeWorkflowCard(personId, workflowCardId) {
180
+ return this.createResource(`/people/${personId}/workflow_cards/${workflowCardId}/remove`, {});
181
+ }
182
+ /**
183
+ * Restore a workflow card
184
+ */
185
+ async restoreWorkflowCard(personId, workflowCardId) {
186
+ return this.createResource(`/people/${personId}/workflow_cards/${workflowCardId}/restore`, {});
187
+ }
188
+ /**
189
+ * Send an email to the subject of the workflow card
190
+ */
191
+ async sendEmailWorkflowCard(personId, workflowCardId, data) {
192
+ return this.createResource(`/people/${personId}/workflow_cards/${workflowCardId}/send_email`, data);
193
+ }
194
+ /**
195
+ * Move a workflow card to the next step without completing the current step
196
+ */
197
+ async skipStepWorkflowCard(personId, workflowCardId) {
198
+ return this.createResource(`/people/${personId}/workflow_cards/${workflowCardId}/skip_step`, {});
199
+ }
200
+ /**
201
+ * Snooze a workflow card for a specific duration
202
+ */
203
+ async snoozeWorkflowCard(personId, workflowCardId, data) {
204
+ return this.createResource(`/people/${personId}/workflow_cards/${workflowCardId}/snooze`, data);
205
+ }
206
+ /**
207
+ * Unsnooze a workflow card
208
+ */
209
+ async unsnoozeWorkflowCard(personId, workflowCardId) {
210
+ return this.createResource(`/people/${personId}/workflow_cards/${workflowCardId}/unsnooze`, {});
211
+ }
212
+ /**
213
+ * Format note template with variables
214
+ */
215
+ formatNoteTemplate(template, variables) {
216
+ return template.replace(/\{\{(\w+)\}\}/g, (match, key) => {
217
+ return variables[key] || match;
218
+ });
219
+ }
220
+ }
221
+ exports.WorkflowsModule = WorkflowsModule;
@@ -0,0 +1,53 @@
1
+ /**
2
+ * v2.0.0 Event System and Monitoring
3
+ */
4
+ import type { PcoEvent, EventHandler, EventType, EventEmitter } from './types/events';
5
+ export declare class PcoEventEmitter implements EventEmitter {
6
+ private handlers;
7
+ on<T extends PcoEvent>(eventType: T['type'], handler: EventHandler<T>): void;
8
+ off<T extends PcoEvent>(eventType: T['type'], handler: EventHandler<T>): void;
9
+ emit<T extends PcoEvent>(event: T): void;
10
+ /** Remove all event handlers */
11
+ removeAllListeners(eventType?: EventType): void;
12
+ /** Get the number of listeners for an event type */
13
+ listenerCount(eventType: EventType): number;
14
+ /** Get all registered event types */
15
+ eventTypes(): EventType[];
16
+ }
17
+ /**
18
+ * Request ID generator for tracking requests
19
+ */
20
+ export declare class RequestIdGenerator {
21
+ private counter;
22
+ generate(): string;
23
+ }
24
+ /**
25
+ * Performance metrics collector
26
+ */
27
+ export declare class PerformanceMetrics {
28
+ private metrics;
29
+ record(operation: string, duration: number, success?: boolean): void;
30
+ getMetrics(): Record<string, {
31
+ count: number;
32
+ averageTime: number;
33
+ minTime: number;
34
+ maxTime: number;
35
+ errorRate: number;
36
+ }>;
37
+ reset(): void;
38
+ }
39
+ /**
40
+ * Rate limit tracker
41
+ */
42
+ export declare class RateLimitTracker {
43
+ private limits;
44
+ update(endpoint: string, limit: number, remaining: number, resetTime: number): void;
45
+ getRemaining(endpoint: string): number;
46
+ getResetTime(endpoint: string): number;
47
+ isRateLimited(endpoint: string): boolean;
48
+ getAllLimits(): Record<string, {
49
+ limit: number;
50
+ remaining: number;
51
+ resetTime: number;
52
+ }>;
53
+ }
@@ -0,0 +1,142 @@
1
+ "use strict";
2
+ /**
3
+ * v2.0.0 Event System and Monitoring
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.RateLimitTracker = exports.PerformanceMetrics = exports.RequestIdGenerator = exports.PcoEventEmitter = void 0;
7
+ class PcoEventEmitter {
8
+ constructor() {
9
+ this.handlers = new Map();
10
+ }
11
+ on(eventType, handler) {
12
+ if (!this.handlers.has(eventType)) {
13
+ this.handlers.set(eventType, new Set());
14
+ }
15
+ this.handlers.get(eventType).add(handler);
16
+ }
17
+ off(eventType, handler) {
18
+ const eventHandlers = this.handlers.get(eventType);
19
+ if (eventHandlers) {
20
+ eventHandlers.delete(handler);
21
+ if (eventHandlers.size === 0) {
22
+ this.handlers.delete(eventType);
23
+ }
24
+ }
25
+ }
26
+ emit(event) {
27
+ const eventHandlers = this.handlers.get(event.type);
28
+ if (eventHandlers) {
29
+ for (const handler of eventHandlers) {
30
+ try {
31
+ handler(event);
32
+ }
33
+ catch (error) {
34
+ console.error(`Error in event handler for ${event.type}:`, error);
35
+ }
36
+ }
37
+ }
38
+ }
39
+ /** Remove all event handlers */
40
+ removeAllListeners(eventType) {
41
+ if (eventType) {
42
+ this.handlers.delete(eventType);
43
+ }
44
+ else {
45
+ this.handlers.clear();
46
+ }
47
+ }
48
+ /** Get the number of listeners for an event type */
49
+ listenerCount(eventType) {
50
+ return this.handlers.get(eventType)?.size || 0;
51
+ }
52
+ /** Get all registered event types */
53
+ eventTypes() {
54
+ return Array.from(this.handlers.keys());
55
+ }
56
+ }
57
+ exports.PcoEventEmitter = PcoEventEmitter;
58
+ /**
59
+ * Request ID generator for tracking requests
60
+ */
61
+ class RequestIdGenerator {
62
+ constructor() {
63
+ this.counter = 0;
64
+ }
65
+ generate() {
66
+ return `req_${Date.now()}_${++this.counter}`;
67
+ }
68
+ }
69
+ exports.RequestIdGenerator = RequestIdGenerator;
70
+ /**
71
+ * Performance metrics collector
72
+ */
73
+ class PerformanceMetrics {
74
+ constructor() {
75
+ this.metrics = new Map();
76
+ }
77
+ record(operation, duration, success = true) {
78
+ const existing = this.metrics.get(operation) || {
79
+ count: 0,
80
+ totalTime: 0,
81
+ minTime: Infinity,
82
+ maxTime: 0,
83
+ errors: 0,
84
+ };
85
+ existing.count++;
86
+ existing.totalTime += duration;
87
+ existing.minTime = Math.min(existing.minTime, duration);
88
+ existing.maxTime = Math.max(existing.maxTime, duration);
89
+ if (!success) {
90
+ existing.errors++;
91
+ }
92
+ this.metrics.set(operation, existing);
93
+ }
94
+ getMetrics() {
95
+ const result = {};
96
+ for (const [operation, metrics] of this.metrics) {
97
+ result[operation] = {
98
+ count: metrics.count,
99
+ averageTime: metrics.totalTime / metrics.count,
100
+ minTime: metrics.minTime === Infinity ? 0 : metrics.minTime,
101
+ maxTime: metrics.maxTime,
102
+ errorRate: metrics.errors / metrics.count,
103
+ };
104
+ }
105
+ return result;
106
+ }
107
+ reset() {
108
+ this.metrics.clear();
109
+ }
110
+ }
111
+ exports.PerformanceMetrics = PerformanceMetrics;
112
+ /**
113
+ * Rate limit tracker
114
+ */
115
+ class RateLimitTracker {
116
+ constructor() {
117
+ this.limits = new Map();
118
+ }
119
+ update(endpoint, limit, remaining, resetTime) {
120
+ this.limits.set(endpoint, { limit, remaining, resetTime });
121
+ }
122
+ getRemaining(endpoint) {
123
+ const limit = this.limits.get(endpoint);
124
+ return limit?.remaining || 0;
125
+ }
126
+ getResetTime(endpoint) {
127
+ const limit = this.limits.get(endpoint);
128
+ return limit?.resetTime || 0;
129
+ }
130
+ isRateLimited(endpoint) {
131
+ const limit = this.limits.get(endpoint);
132
+ return limit ? limit.remaining <= 0 : false;
133
+ }
134
+ getAllLimits() {
135
+ const result = {};
136
+ for (const [endpoint, limit] of this.limits) {
137
+ result[endpoint] = limit;
138
+ }
139
+ return result;
140
+ }
141
+ }
142
+ exports.RateLimitTracker = RateLimitTracker;
@@ -0,0 +1,43 @@
1
+ import { PcoClientState } from '../core';
2
+ import type { ErrorContext } from '../error-handling';
3
+ import { AddressAttributes, AddressesList, AddressSingle, EmailAttributes, EmailSingle, EmailsList, PhoneNumberAttributes, PhoneNumberSingle, PhoneNumbersList, SocialProfileAttributes, SocialProfileSingle, SocialProfilesList } from '../types';
4
+ /**
5
+ * Get all emails for a person
6
+ */
7
+ export declare function getPersonEmails(client: PcoClientState, personId: string, context?: Partial<ErrorContext>): Promise<EmailsList>;
8
+ /**
9
+ * Create an email for a person
10
+ */
11
+ export declare function createPersonEmail(client: PcoClientState, personId: string, data: Partial<EmailAttributes>, context?: Partial<ErrorContext>): Promise<EmailSingle>;
12
+ /**
13
+ * Get all phone numbers for a person
14
+ */
15
+ export declare function getPersonPhoneNumbers(client: PcoClientState, personId: string, context?: Partial<ErrorContext>): Promise<PhoneNumbersList>;
16
+ /**
17
+ * Create a phone number for a person
18
+ */
19
+ export declare function createPersonPhoneNumber(client: PcoClientState, personId: string, data: Partial<PhoneNumberAttributes>, context?: Partial<ErrorContext>): Promise<PhoneNumberSingle>;
20
+ /**
21
+ * Get all addresses for a person
22
+ */
23
+ export declare function getPersonAddresses(client: PcoClientState, personId: string, context?: Partial<ErrorContext>): Promise<AddressesList>;
24
+ /**
25
+ * Create an address for a person
26
+ */
27
+ export declare function createPersonAddress(client: PcoClientState, personId: string, data: Partial<AddressAttributes>, context?: Partial<ErrorContext>): Promise<AddressSingle>;
28
+ /**
29
+ * Update an address for a person
30
+ */
31
+ export declare function updatePersonAddress(client: PcoClientState, personId: string, addressId: string, data: Partial<AddressAttributes>, context?: Partial<ErrorContext>): Promise<AddressSingle>;
32
+ /**
33
+ * Get social profiles for a person
34
+ */
35
+ export declare function getPersonSocialProfiles(client: PcoClientState, personId: string, context?: Partial<ErrorContext>): Promise<SocialProfilesList>;
36
+ /**
37
+ * Create a social profile for a person
38
+ */
39
+ export declare function createPersonSocialProfile(client: PcoClientState, personId: string, data: Partial<SocialProfileAttributes>, context?: Partial<ErrorContext>): Promise<SocialProfileSingle>;
40
+ /**
41
+ * Delete a social profile
42
+ */
43
+ export declare function deleteSocialProfile(client: PcoClientState, socialProfileId: string, context?: Partial<ErrorContext>): Promise<void>;
@@ -0,0 +1,122 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getPersonEmails = getPersonEmails;
4
+ exports.createPersonEmail = createPersonEmail;
5
+ exports.getPersonPhoneNumbers = getPersonPhoneNumbers;
6
+ exports.createPersonPhoneNumber = createPersonPhoneNumber;
7
+ exports.getPersonAddresses = getPersonAddresses;
8
+ exports.createPersonAddress = createPersonAddress;
9
+ exports.updatePersonAddress = updatePersonAddress;
10
+ exports.getPersonSocialProfiles = getPersonSocialProfiles;
11
+ exports.createPersonSocialProfile = createPersonSocialProfile;
12
+ exports.deleteSocialProfile = deleteSocialProfile;
13
+ const core_1 = require("../core");
14
+ /**
15
+ * Get all emails for a person
16
+ */
17
+ async function getPersonEmails(client, personId, context) {
18
+ return (0, core_1.getList)(client, `/people/${personId}/emails`, undefined, {
19
+ ...context,
20
+ endpoint: `/people/${personId}/emails`,
21
+ method: 'GET',
22
+ personId,
23
+ });
24
+ }
25
+ /**
26
+ * Create an email for a person
27
+ */
28
+ async function createPersonEmail(client, personId, data, context) {
29
+ return (0, core_1.post)(client, `/people/${personId}/emails`, data, undefined, {
30
+ ...context,
31
+ endpoint: `/people/${personId}/emails`,
32
+ method: 'POST',
33
+ personId,
34
+ });
35
+ }
36
+ /**
37
+ * Get all phone numbers for a person
38
+ */
39
+ async function getPersonPhoneNumbers(client, personId, context) {
40
+ return (0, core_1.getList)(client, `/people/${personId}/phone_numbers`, undefined, {
41
+ ...context,
42
+ endpoint: `/people/${personId}/phone_numbers`,
43
+ method: 'GET',
44
+ personId,
45
+ });
46
+ }
47
+ /**
48
+ * Create a phone number for a person
49
+ */
50
+ async function createPersonPhoneNumber(client, personId, data, context) {
51
+ return (0, core_1.post)(client, `/people/${personId}/phone_numbers`, data, undefined, {
52
+ ...context,
53
+ endpoint: `/people/${personId}/phone_numbers`,
54
+ method: 'POST',
55
+ personId,
56
+ });
57
+ }
58
+ /**
59
+ * Get all addresses for a person
60
+ */
61
+ async function getPersonAddresses(client, personId, context) {
62
+ return (0, core_1.getList)(client, `/people/${personId}/addresses`, undefined, {
63
+ ...context,
64
+ endpoint: `/people/${personId}/addresses`,
65
+ method: 'GET',
66
+ personId,
67
+ });
68
+ }
69
+ /**
70
+ * Create an address for a person
71
+ */
72
+ async function createPersonAddress(client, personId, data, context) {
73
+ return (0, core_1.post)(client, `/people/${personId}/addresses`, data, undefined, {
74
+ ...context,
75
+ endpoint: `/people/${personId}/addresses`,
76
+ method: 'POST',
77
+ personId,
78
+ });
79
+ }
80
+ /**
81
+ * Update an address for a person
82
+ */
83
+ async function updatePersonAddress(client, personId, addressId, data, context) {
84
+ return (0, core_1.patch)(client, `/people/${personId}/addresses/${addressId}`, data, undefined, {
85
+ ...context,
86
+ endpoint: `/people/${personId}/addresses/${addressId}`,
87
+ method: 'PATCH',
88
+ personId,
89
+ });
90
+ }
91
+ /**
92
+ * Get social profiles for a person
93
+ */
94
+ async function getPersonSocialProfiles(client, personId, context) {
95
+ return (0, core_1.getList)(client, `/people/${personId}/social_profiles`, undefined, {
96
+ ...context,
97
+ endpoint: `/people/${personId}/social_profiles`,
98
+ method: 'GET',
99
+ personId,
100
+ });
101
+ }
102
+ /**
103
+ * Create a social profile for a person
104
+ */
105
+ async function createPersonSocialProfile(client, personId, data, context) {
106
+ return (0, core_1.post)(client, `/people/${personId}/social_profiles`, data, undefined, {
107
+ ...context,
108
+ endpoint: `/people/${personId}/social_profiles`,
109
+ method: 'POST',
110
+ personId,
111
+ });
112
+ }
113
+ /**
114
+ * Delete a social profile
115
+ */
116
+ async function deleteSocialProfile(client, socialProfileId, context) {
117
+ return (0, core_1.del)(client, `/social_profiles/${socialProfileId}`, {
118
+ ...context,
119
+ endpoint: `/social_profiles/${socialProfileId}`,
120
+ method: 'DELETE',
121
+ });
122
+ }
@@ -0,0 +1,28 @@
1
+ import { PcoClientState } from '../core';
2
+ import type { ErrorContext } from '../error-handling';
3
+ import { PeopleList, PersonAttributes, PersonSingle } from '../types';
4
+ /**
5
+ * Get all people with optional filtering and pagination
6
+ */
7
+ export declare function getPeople(client: PcoClientState, params?: {
8
+ where?: Record<string, any>;
9
+ include?: string[];
10
+ per_page?: number;
11
+ page?: number;
12
+ }, context?: Partial<ErrorContext>): Promise<PeopleList>;
13
+ /**
14
+ * Get a single person by ID
15
+ */
16
+ export declare function getPerson(client: PcoClientState, id: string, include?: string[], context?: Partial<ErrorContext>): Promise<PersonSingle>;
17
+ /**
18
+ * Create a new person
19
+ */
20
+ export declare function createPerson(client: PcoClientState, data: Partial<PersonAttributes>, context?: Partial<ErrorContext>): Promise<PersonSingle>;
21
+ /**
22
+ * Update a person
23
+ */
24
+ export declare function updatePerson(client: PcoClientState, id: string, data: Partial<PersonAttributes>, context?: Partial<ErrorContext>): Promise<PersonSingle>;
25
+ /**
26
+ * Delete a person
27
+ */
28
+ export declare function deletePerson(client: PcoClientState, id: string, context?: Partial<ErrorContext>): Promise<void>;
@@ -0,0 +1,69 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getPeople = getPeople;
4
+ exports.getPerson = getPerson;
5
+ exports.createPerson = createPerson;
6
+ exports.updatePerson = updatePerson;
7
+ exports.deletePerson = deletePerson;
8
+ const core_1 = require("../core");
9
+ const helpers_1 = require("../helpers");
10
+ /**
11
+ * Get all people with optional filtering and pagination
12
+ */
13
+ async function getPeople(client, params, context) {
14
+ const result = await (0, core_1.getList)(client, '/people', (0, helpers_1.buildQueryParams)(params), {
15
+ ...context,
16
+ endpoint: '/people',
17
+ method: 'GET',
18
+ });
19
+ return result;
20
+ }
21
+ /**
22
+ * Get a single person by ID
23
+ */
24
+ async function getPerson(client, id, include, context) {
25
+ const params = {};
26
+ if (include) {
27
+ params.include = include.join(',');
28
+ }
29
+ return (await (0, core_1.getSingle)(client, `/people/${id}`, params, {
30
+ ...context,
31
+ endpoint: `/people/${id}`,
32
+ method: 'GET',
33
+ personId: id,
34
+ }));
35
+ }
36
+ /**
37
+ * Create a new person
38
+ */
39
+ async function createPerson(client, data, context) {
40
+ return (0, core_1.post)(client, '/people', data, undefined, {
41
+ ...context,
42
+ endpoint: '/people',
43
+ method: 'POST',
44
+ });
45
+ }
46
+ /**
47
+ * Update a person
48
+ */
49
+ async function updatePerson(client, id, data, context) {
50
+ return (0, core_1.patch)(client, `/people/${id}`, data, undefined, {
51
+ ...context,
52
+ endpoint: `/people/${id}`,
53
+ method: 'PATCH',
54
+ personId: id,
55
+ });
56
+ }
57
+ /**
58
+ * Delete a person
59
+ */
60
+ async function deletePerson(client, id, context) {
61
+ return (0, core_1.del)(client, `/people/${id}`, undefined, {
62
+ ...context,
63
+ endpoint: `/people/${id}`,
64
+ method: 'DELETE',
65
+ personId: id,
66
+ metadata: { operation: 'delete_person' },
67
+ timestamp: new Date().toISOString(),
68
+ });
69
+ }