@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
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Simplified Testing Factory Functions
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.SimpleMockPcoClient = void 0;
|
|
7
|
+
exports.createSimpleMockClient = createSimpleMockClient;
|
|
8
|
+
exports.createTestClient = createTestClient;
|
|
9
|
+
exports.createErrorMockClient = createErrorMockClient;
|
|
10
|
+
exports.createSlowMockClient = createSlowMockClient;
|
|
11
|
+
const simple_builders_1 = require("./simple-builders");
|
|
12
|
+
class SimpleMockPcoClient {
|
|
13
|
+
constructor(config, mockConfig = {}) {
|
|
14
|
+
this.config = config;
|
|
15
|
+
this.mockConfig = mockConfig;
|
|
16
|
+
// Initialize modules with mock implementations
|
|
17
|
+
this.people = this.createPeopleModule();
|
|
18
|
+
this.fields = this.createFieldsModule();
|
|
19
|
+
this.workflows = this.createWorkflowsModule();
|
|
20
|
+
this.contacts = this.createContactsModule();
|
|
21
|
+
this.households = this.createHouseholdsModule();
|
|
22
|
+
this.notes = this.createNotesModule();
|
|
23
|
+
this.lists = this.createListsModule();
|
|
24
|
+
this.batch = this.createBatchModule();
|
|
25
|
+
}
|
|
26
|
+
createPeopleModule() {
|
|
27
|
+
return {
|
|
28
|
+
getAll: this.mockConfig.people?.getAll || (() => Promise.resolve(simple_builders_1.SimpleMockResponseBuilder.paginated([simple_builders_1.SimpleMockResponseBuilder.person()]))),
|
|
29
|
+
getById: this.mockConfig.people?.getById || ((id) => Promise.resolve(simple_builders_1.SimpleMockResponseBuilder.person({ id }))),
|
|
30
|
+
create: this.mockConfig.people?.create || ((data) => Promise.resolve(simple_builders_1.SimpleMockResponseBuilder.person(data))),
|
|
31
|
+
update: this.mockConfig.people?.update || ((id, data) => Promise.resolve(simple_builders_1.SimpleMockResponseBuilder.person({ id, ...data }))),
|
|
32
|
+
delete: this.mockConfig.people?.delete || (() => Promise.resolve()),
|
|
33
|
+
findOrCreate: this.mockConfig.people?.findOrCreate || ((options) => Promise.resolve(simple_builders_1.SimpleMockResponseBuilder.person({
|
|
34
|
+
first_name: options.firstName,
|
|
35
|
+
last_name: options.lastName,
|
|
36
|
+
}))),
|
|
37
|
+
createWithContacts: this.mockConfig.people?.createWithContacts || ((personData, contacts) => Promise.resolve(simple_builders_1.SimpleMockResponseBuilder.person({
|
|
38
|
+
first_name: personData.firstName,
|
|
39
|
+
last_name: personData.lastName,
|
|
40
|
+
}))),
|
|
41
|
+
search: this.mockConfig.people?.search || ((criteria) => Promise.resolve(simple_builders_1.SimpleMockResponseBuilder.paginated([simple_builders_1.SimpleMockResponseBuilder.person()]))),
|
|
42
|
+
getAllPages: this.mockConfig.people?.getAllPages || (() => Promise.resolve({
|
|
43
|
+
data: [simple_builders_1.SimpleMockResponseBuilder.person()],
|
|
44
|
+
totalCount: 1,
|
|
45
|
+
pagesFetched: 1,
|
|
46
|
+
duration: 100,
|
|
47
|
+
})),
|
|
48
|
+
addEmail: this.mockConfig.people?.addEmail || ((personId, data) => Promise.resolve(simple_builders_1.SimpleMockResponseBuilder.email(data))),
|
|
49
|
+
addPhoneNumber: this.mockConfig.people?.addPhoneNumber || ((personId, data) => Promise.resolve({ type: 'PhoneNumber', id: 'phone_123', attributes: data })),
|
|
50
|
+
addAddress: this.mockConfig.people?.addAddress || ((personId, data) => Promise.resolve({ type: 'Address', id: 'address_123', attributes: data })),
|
|
51
|
+
addSocialProfile: this.mockConfig.people?.addSocialProfile || ((personId, data) => Promise.resolve({ type: 'SocialProfile', id: 'social_123', attributes: data })),
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
createFieldsModule() {
|
|
55
|
+
return {
|
|
56
|
+
getAllFieldDefinitions: this.mockConfig.fields?.getAllFieldDefinitions || (() => Promise.resolve([{ type: 'FieldDefinition', id: 'field_1', attributes: { name: 'Birthdate', slug: 'birthdate' } }])),
|
|
57
|
+
getFieldDefinition: this.mockConfig.fields?.getFieldDefinition || ((id) => Promise.resolve({ type: 'FieldDefinition', id, attributes: { name: 'Test Field' } })),
|
|
58
|
+
getFieldDefinitionBySlug: this.mockConfig.fields?.getFieldDefinitionBySlug || ((slug) => Promise.resolve({ type: 'FieldDefinition', id: 'field_1', attributes: { slug } })),
|
|
59
|
+
getFieldDefinitionByName: this.mockConfig.fields?.getFieldDefinitionByName || ((name) => Promise.resolve({ type: 'FieldDefinition', id: 'field_1', attributes: { name } })),
|
|
60
|
+
setPersonField: this.mockConfig.fields?.setPersonField || (() => Promise.resolve({ id: 'field_data_123', value: 'test' })),
|
|
61
|
+
setPersonFieldById: this.mockConfig.fields?.setPersonFieldById || (() => Promise.resolve({ id: 'field_data_123', value: 'test' })),
|
|
62
|
+
setPersonFieldBySlug: this.mockConfig.fields?.setPersonFieldBySlug || ((personId, slug, value) => Promise.resolve({ id: 'field_data_123', value })),
|
|
63
|
+
setPersonFieldByName: this.mockConfig.fields?.setPersonFieldByName || (() => Promise.resolve({ id: 'field_data_123', value: 'test' })),
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
createWorkflowsModule() {
|
|
67
|
+
return {
|
|
68
|
+
getAll: this.mockConfig.workflows?.getAll || (() => Promise.resolve(simple_builders_1.SimpleMockResponseBuilder.paginated([simple_builders_1.SimpleMockResponseBuilder.workflow()]))),
|
|
69
|
+
getById: this.mockConfig.workflows?.getById || ((id) => Promise.resolve(simple_builders_1.SimpleMockResponseBuilder.workflow({ id }))),
|
|
70
|
+
create: this.mockConfig.workflows?.create || ((data) => Promise.resolve(simple_builders_1.SimpleMockResponseBuilder.workflow(data))),
|
|
71
|
+
update: this.mockConfig.workflows?.update || ((id, data) => Promise.resolve(simple_builders_1.SimpleMockResponseBuilder.workflow({ id, ...data }))),
|
|
72
|
+
delete: this.mockConfig.workflows?.delete || (() => Promise.resolve()),
|
|
73
|
+
getAllPages: this.mockConfig.workflows?.getAllPages || (() => Promise.resolve({
|
|
74
|
+
data: [simple_builders_1.SimpleMockResponseBuilder.workflow()],
|
|
75
|
+
totalCount: 1,
|
|
76
|
+
pagesFetched: 1,
|
|
77
|
+
duration: 100,
|
|
78
|
+
})),
|
|
79
|
+
addPersonToWorkflow: this.mockConfig.workflows?.addPersonToWorkflow || (() => Promise.resolve({ type: 'WorkflowCard', id: 'workflow_card_123', attributes: {} })),
|
|
80
|
+
createWorkflowCard: this.mockConfig.workflows?.createWorkflowCard || (() => Promise.resolve({ type: 'WorkflowCard', id: 'workflow_card_123', attributes: {} })),
|
|
81
|
+
createWorkflowCardNote: this.mockConfig.workflows?.createWorkflowCardNote || (() => Promise.resolve({ type: 'WorkflowCardNote', id: 'workflow_card_note_123', attributes: {} })),
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
createContactsModule() {
|
|
85
|
+
return {
|
|
86
|
+
getAllEmails: () => Promise.resolve(simple_builders_1.SimpleMockResponseBuilder.paginated([simple_builders_1.SimpleMockResponseBuilder.email()])),
|
|
87
|
+
createEmail: (data) => Promise.resolve(simple_builders_1.SimpleMockResponseBuilder.email(data)),
|
|
88
|
+
getAllPhoneNumbers: () => Promise.resolve(simple_builders_1.SimpleMockResponseBuilder.paginated([])),
|
|
89
|
+
createPhoneNumber: (data) => Promise.resolve({ type: 'PhoneNumber', id: 'phone_123', attributes: data }),
|
|
90
|
+
getAllAddresses: () => Promise.resolve(simple_builders_1.SimpleMockResponseBuilder.paginated([])),
|
|
91
|
+
createAddress: (data) => Promise.resolve({ type: 'Address', id: 'address_123', attributes: data }),
|
|
92
|
+
getAllSocialProfiles: () => Promise.resolve(simple_builders_1.SimpleMockResponseBuilder.paginated([])),
|
|
93
|
+
createSocialProfile: (data) => Promise.resolve({ type: 'SocialProfile', id: 'social_123', attributes: data }),
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
createHouseholdsModule() {
|
|
97
|
+
return {
|
|
98
|
+
getAll: () => Promise.resolve(simple_builders_1.SimpleMockResponseBuilder.paginated([])),
|
|
99
|
+
getById: (id) => Promise.resolve({ type: 'Household', id, attributes: {} }),
|
|
100
|
+
create: (data) => Promise.resolve({ type: 'Household', id: 'household_123', attributes: data }),
|
|
101
|
+
update: (id, data) => Promise.resolve({ type: 'Household', id, attributes: data }),
|
|
102
|
+
delete: () => Promise.resolve(),
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
createNotesModule() {
|
|
106
|
+
return {
|
|
107
|
+
getAll: () => Promise.resolve(simple_builders_1.SimpleMockResponseBuilder.paginated([])),
|
|
108
|
+
getById: (id) => Promise.resolve({ type: 'Note', id, attributes: {} }),
|
|
109
|
+
create: (data) => Promise.resolve({ type: 'Note', id: 'note_123', attributes: data }),
|
|
110
|
+
update: (id, data) => Promise.resolve({ type: 'Note', id, attributes: data }),
|
|
111
|
+
delete: () => Promise.resolve(),
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
createListsModule() {
|
|
115
|
+
return {
|
|
116
|
+
getAll: () => Promise.resolve(simple_builders_1.SimpleMockResponseBuilder.paginated([])),
|
|
117
|
+
getById: (id) => Promise.resolve({ type: 'List', id, attributes: {} }),
|
|
118
|
+
create: (data) => Promise.resolve({ type: 'List', id: 'list_123', attributes: data }),
|
|
119
|
+
update: (id, data) => Promise.resolve({ type: 'List', id, attributes: data }),
|
|
120
|
+
delete: () => Promise.resolve(),
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
createBatchModule() {
|
|
124
|
+
return {
|
|
125
|
+
execute: this.mockConfig.batch?.execute || ((operations) => Promise.resolve({
|
|
126
|
+
total: operations.length,
|
|
127
|
+
successful: operations.length,
|
|
128
|
+
failed: 0,
|
|
129
|
+
successRate: 1.0,
|
|
130
|
+
duration: 100,
|
|
131
|
+
results: operations.map((op, index) => ({
|
|
132
|
+
index,
|
|
133
|
+
operation: op,
|
|
134
|
+
success: true,
|
|
135
|
+
data: { id: `result_${index}` },
|
|
136
|
+
})),
|
|
137
|
+
})),
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
// Event system methods (mock implementations)
|
|
141
|
+
on(eventType, handler) {
|
|
142
|
+
// Mock implementation - does nothing
|
|
143
|
+
}
|
|
144
|
+
off(eventType, handler) {
|
|
145
|
+
// Mock implementation - does nothing
|
|
146
|
+
}
|
|
147
|
+
emit(event) {
|
|
148
|
+
// Mock implementation - does nothing
|
|
149
|
+
}
|
|
150
|
+
getConfig() {
|
|
151
|
+
return this.config;
|
|
152
|
+
}
|
|
153
|
+
getPerformanceMetrics() {
|
|
154
|
+
return {};
|
|
155
|
+
}
|
|
156
|
+
getRateLimitInfo() {
|
|
157
|
+
return {};
|
|
158
|
+
}
|
|
159
|
+
removeAllListeners(eventType) {
|
|
160
|
+
// Mock implementation - does nothing
|
|
161
|
+
}
|
|
162
|
+
listenerCount(eventType) {
|
|
163
|
+
return 0;
|
|
164
|
+
}
|
|
165
|
+
eventTypes() {
|
|
166
|
+
return [];
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
exports.SimpleMockPcoClient = SimpleMockPcoClient;
|
|
170
|
+
/**
|
|
171
|
+
* Create a simple mock client for testing
|
|
172
|
+
*/
|
|
173
|
+
function createSimpleMockClient(config, mockConfig = {}) {
|
|
174
|
+
return new SimpleMockPcoClient(config, mockConfig);
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Create a test client with common mock responses
|
|
178
|
+
*/
|
|
179
|
+
function createTestClient(overrides = {}) {
|
|
180
|
+
const defaultConfig = {
|
|
181
|
+
auth: {
|
|
182
|
+
type: 'oauth',
|
|
183
|
+
accessToken: 'test-token',
|
|
184
|
+
},
|
|
185
|
+
};
|
|
186
|
+
const defaultMockConfig = {
|
|
187
|
+
people: {
|
|
188
|
+
getAll: () => Promise.resolve({
|
|
189
|
+
data: [
|
|
190
|
+
simple_builders_1.SimpleMockResponseBuilder.person({ id: 'person_1', first_name: 'John', last_name: 'Doe' })
|
|
191
|
+
],
|
|
192
|
+
meta: { total_count: 1 },
|
|
193
|
+
links: { self: '/people', next: null, prev: null },
|
|
194
|
+
}),
|
|
195
|
+
create: (data) => Promise.resolve(simple_builders_1.SimpleMockResponseBuilder.person({
|
|
196
|
+
id: 'person_new',
|
|
197
|
+
first_name: data.firstName || data.first_name || 'New',
|
|
198
|
+
last_name: data.lastName || data.last_name || 'Person',
|
|
199
|
+
})),
|
|
200
|
+
},
|
|
201
|
+
fields: {
|
|
202
|
+
getAllFieldDefinitions: () => Promise.resolve([
|
|
203
|
+
simple_builders_1.SimpleMockResponseBuilder.person({ type: 'FieldDefinition', id: 'field_1', attributes: { name: 'Birthdate', slug: 'birthdate' } })
|
|
204
|
+
]),
|
|
205
|
+
setPersonFieldBySlug: (personId, slug, value) => Promise.resolve({ id: 'field_data_123', value }),
|
|
206
|
+
},
|
|
207
|
+
workflows: {
|
|
208
|
+
getAll: () => Promise.resolve({
|
|
209
|
+
data: [simple_builders_1.SimpleMockResponseBuilder.workflow({ id: 'workflow_1', name: 'New Member Workflow' })],
|
|
210
|
+
meta: { total_count: 1 },
|
|
211
|
+
links: { self: '/workflows', next: null, prev: null },
|
|
212
|
+
}),
|
|
213
|
+
},
|
|
214
|
+
batch: {
|
|
215
|
+
execute: (operations) => Promise.resolve({
|
|
216
|
+
total: operations.length,
|
|
217
|
+
successful: operations.length,
|
|
218
|
+
failed: 0,
|
|
219
|
+
successRate: 1.0,
|
|
220
|
+
duration: 100,
|
|
221
|
+
results: operations.map((op, index) => ({
|
|
222
|
+
index,
|
|
223
|
+
operation: op,
|
|
224
|
+
success: true,
|
|
225
|
+
data: { id: `result_${index}` },
|
|
226
|
+
})),
|
|
227
|
+
}),
|
|
228
|
+
},
|
|
229
|
+
};
|
|
230
|
+
// Merge with overrides
|
|
231
|
+
const mergedMockConfig = { ...defaultMockConfig, ...overrides };
|
|
232
|
+
return createSimpleMockClient(defaultConfig, mergedMockConfig);
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* Create a mock client that simulates errors
|
|
236
|
+
*/
|
|
237
|
+
function createErrorMockClient(errorType = 'network') {
|
|
238
|
+
const config = {
|
|
239
|
+
auth: {
|
|
240
|
+
type: 'oauth',
|
|
241
|
+
accessToken: 'test-token',
|
|
242
|
+
},
|
|
243
|
+
};
|
|
244
|
+
const errorMockConfig = {
|
|
245
|
+
people: {
|
|
246
|
+
getAll: () => {
|
|
247
|
+
const error = new Error(`Mock ${errorType} error`);
|
|
248
|
+
error.status = errorType === 'auth' ? 401 : errorType === 'rate_limit' ? 429 : 500;
|
|
249
|
+
return Promise.reject(error);
|
|
250
|
+
},
|
|
251
|
+
},
|
|
252
|
+
};
|
|
253
|
+
return createSimpleMockClient(config, errorMockConfig);
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* Create a mock client with specific response delays
|
|
257
|
+
*/
|
|
258
|
+
function createSlowMockClient(delayMs = 1000) {
|
|
259
|
+
const config = {
|
|
260
|
+
auth: {
|
|
261
|
+
type: 'oauth',
|
|
262
|
+
accessToken: 'test-token',
|
|
263
|
+
},
|
|
264
|
+
};
|
|
265
|
+
const slowMockConfig = {
|
|
266
|
+
people: {
|
|
267
|
+
getAll: () => new Promise(resolve => {
|
|
268
|
+
setTimeout(() => {
|
|
269
|
+
resolve({
|
|
270
|
+
data: [],
|
|
271
|
+
meta: { total_count: 0 },
|
|
272
|
+
links: { self: '/people', next: null, prev: null },
|
|
273
|
+
});
|
|
274
|
+
}, delayMs);
|
|
275
|
+
}),
|
|
276
|
+
},
|
|
277
|
+
};
|
|
278
|
+
return createSimpleMockClient(config, slowMockConfig);
|
|
279
|
+
}
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* v2.0.0 Testing Types
|
|
3
|
+
*/
|
|
4
|
+
import type { PcoClientConfig } from '../types/client';
|
|
5
|
+
import type { PersonResource, EmailResource, PhoneNumberResource, AddressResource, SocialProfileResource, FieldDefinitionResource, WorkflowResource, WorkflowCardResource, WorkflowCardNoteResource, HouseholdResource, NoteResource, ListResource } from '../types';
|
|
6
|
+
export interface MockClientConfig {
|
|
7
|
+
/** Mock responses for people operations */
|
|
8
|
+
people?: {
|
|
9
|
+
getAll?: () => Promise<{
|
|
10
|
+
data: PersonResource[];
|
|
11
|
+
meta?: any;
|
|
12
|
+
links?: any;
|
|
13
|
+
}>;
|
|
14
|
+
getById?: (id: string) => Promise<PersonResource>;
|
|
15
|
+
create?: (data: any) => Promise<PersonResource>;
|
|
16
|
+
update?: (id: string, data: any) => Promise<PersonResource>;
|
|
17
|
+
delete?: (id: string) => Promise<void>;
|
|
18
|
+
findOrCreate?: (options: any) => Promise<PersonResource>;
|
|
19
|
+
search?: (criteria: any) => Promise<{
|
|
20
|
+
data: PersonResource[];
|
|
21
|
+
meta?: any;
|
|
22
|
+
links?: any;
|
|
23
|
+
}>;
|
|
24
|
+
getAllPages?: (options?: any) => Promise<{
|
|
25
|
+
data: PersonResource[];
|
|
26
|
+
totalCount: number;
|
|
27
|
+
pagesFetched: number;
|
|
28
|
+
duration: number;
|
|
29
|
+
}>;
|
|
30
|
+
addEmail?: (personId: string, data: any) => Promise<EmailResource>;
|
|
31
|
+
addPhoneNumber?: (personId: string, data: any) => Promise<PhoneNumberResource>;
|
|
32
|
+
addAddress?: (personId: string, data: any) => Promise<AddressResource>;
|
|
33
|
+
addSocialProfile?: (personId: string, data: any) => Promise<SocialProfileResource>;
|
|
34
|
+
};
|
|
35
|
+
/** Mock responses for fields operations */
|
|
36
|
+
fields?: {
|
|
37
|
+
getAllFieldDefinitions?: () => Promise<FieldDefinitionResource[]>;
|
|
38
|
+
getFieldDefinition?: (id: string) => Promise<FieldDefinitionResource>;
|
|
39
|
+
getFieldDefinitionBySlug?: (slug: string) => Promise<FieldDefinitionResource | null>;
|
|
40
|
+
getFieldDefinitionByName?: (name: string) => Promise<FieldDefinitionResource | null>;
|
|
41
|
+
setPersonField?: (personId: string, options: any) => Promise<any>;
|
|
42
|
+
setPersonFieldById?: (personId: string, fieldId: string, value: string) => Promise<any>;
|
|
43
|
+
setPersonFieldBySlug?: (personId: string, slug: string, value: string) => Promise<any>;
|
|
44
|
+
setPersonFieldByName?: (personId: string, name: string, value: string) => Promise<any>;
|
|
45
|
+
};
|
|
46
|
+
/** Mock responses for workflows operations */
|
|
47
|
+
workflows?: {
|
|
48
|
+
getAll?: (options?: any) => Promise<{
|
|
49
|
+
data: WorkflowResource[];
|
|
50
|
+
meta?: any;
|
|
51
|
+
links?: any;
|
|
52
|
+
}>;
|
|
53
|
+
getById?: (id: string) => Promise<WorkflowResource>;
|
|
54
|
+
create?: (data: any) => Promise<WorkflowResource>;
|
|
55
|
+
update?: (id: string, data: any) => Promise<WorkflowResource>;
|
|
56
|
+
delete?: (id: string) => Promise<void>;
|
|
57
|
+
getAllPages?: (options?: any) => Promise<{
|
|
58
|
+
data: WorkflowResource[];
|
|
59
|
+
totalCount: number;
|
|
60
|
+
pagesFetched: number;
|
|
61
|
+
duration: number;
|
|
62
|
+
}>;
|
|
63
|
+
addPersonToWorkflow?: (personId: string, workflowId: string, options?: any) => Promise<WorkflowCardResource>;
|
|
64
|
+
createWorkflowCard?: (workflowId: string, personId: string) => Promise<WorkflowCardResource>;
|
|
65
|
+
createWorkflowCardNote?: (personId: string, workflowCardId: string, data: any) => Promise<WorkflowCardNoteResource>;
|
|
66
|
+
};
|
|
67
|
+
/** Mock responses for contacts operations */
|
|
68
|
+
contacts?: {
|
|
69
|
+
getAllEmails?: () => Promise<{
|
|
70
|
+
data: EmailResource[];
|
|
71
|
+
meta?: any;
|
|
72
|
+
links?: any;
|
|
73
|
+
}>;
|
|
74
|
+
createEmail?: (data: any) => Promise<EmailResource>;
|
|
75
|
+
getAllPhoneNumbers?: () => Promise<{
|
|
76
|
+
data: PhoneNumberResource[];
|
|
77
|
+
meta?: any;
|
|
78
|
+
links?: any;
|
|
79
|
+
}>;
|
|
80
|
+
createPhoneNumber?: (data: any) => Promise<PhoneNumberResource>;
|
|
81
|
+
getAllAddresses?: () => Promise<{
|
|
82
|
+
data: AddressResource[];
|
|
83
|
+
meta?: any;
|
|
84
|
+
links?: any;
|
|
85
|
+
}>;
|
|
86
|
+
createAddress?: (data: any) => Promise<AddressResource>;
|
|
87
|
+
getAllSocialProfiles?: () => Promise<{
|
|
88
|
+
data: SocialProfileResource[];
|
|
89
|
+
meta?: any;
|
|
90
|
+
links?: any;
|
|
91
|
+
}>;
|
|
92
|
+
createSocialProfile?: (data: any) => Promise<SocialProfileResource>;
|
|
93
|
+
};
|
|
94
|
+
/** Mock responses for households operations */
|
|
95
|
+
households?: {
|
|
96
|
+
getAll?: (options?: any) => Promise<{
|
|
97
|
+
data: HouseholdResource[];
|
|
98
|
+
meta?: any;
|
|
99
|
+
links?: any;
|
|
100
|
+
}>;
|
|
101
|
+
getById?: (id: string) => Promise<HouseholdResource>;
|
|
102
|
+
create?: (data: any) => Promise<HouseholdResource>;
|
|
103
|
+
update?: (id: string, data: any) => Promise<HouseholdResource>;
|
|
104
|
+
delete?: (id: string) => Promise<void>;
|
|
105
|
+
};
|
|
106
|
+
/** Mock responses for notes operations */
|
|
107
|
+
notes?: {
|
|
108
|
+
getAll?: (options?: any) => Promise<{
|
|
109
|
+
data: NoteResource[];
|
|
110
|
+
meta?: any;
|
|
111
|
+
links?: any;
|
|
112
|
+
}>;
|
|
113
|
+
getById?: (id: string) => Promise<NoteResource>;
|
|
114
|
+
create?: (data: any) => Promise<NoteResource>;
|
|
115
|
+
update?: (id: string, data: any) => Promise<NoteResource>;
|
|
116
|
+
delete?: (id: string) => Promise<void>;
|
|
117
|
+
};
|
|
118
|
+
/** Mock responses for lists operations */
|
|
119
|
+
lists?: {
|
|
120
|
+
getAll?: (options?: any) => Promise<{
|
|
121
|
+
data: ListResource[];
|
|
122
|
+
meta?: any;
|
|
123
|
+
links?: any;
|
|
124
|
+
}>;
|
|
125
|
+
getById?: (id: string) => Promise<ListResource>;
|
|
126
|
+
create?: (data: any) => Promise<ListResource>;
|
|
127
|
+
update?: (id: string, data: any) => Promise<ListResource>;
|
|
128
|
+
delete?: (id: string) => Promise<void>;
|
|
129
|
+
};
|
|
130
|
+
/** Mock responses for batch operations */
|
|
131
|
+
batch?: {
|
|
132
|
+
execute?: (operations: any[]) => Promise<any>;
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
export interface RecordingConfig {
|
|
136
|
+
/** Path to save recorded requests/responses */
|
|
137
|
+
recordPath: string;
|
|
138
|
+
/** Whether to record new requests or replay existing ones */
|
|
139
|
+
mode: 'record' | 'replay' | 'auto';
|
|
140
|
+
/** Filter which requests to record */
|
|
141
|
+
filter?: (endpoint: string, method: string) => boolean;
|
|
142
|
+
/** Transform recorded responses */
|
|
143
|
+
transform?: (response: any) => any;
|
|
144
|
+
}
|
|
145
|
+
export interface RecordedRequest {
|
|
146
|
+
endpoint: string;
|
|
147
|
+
method: string;
|
|
148
|
+
params?: Record<string, any>;
|
|
149
|
+
data?: any;
|
|
150
|
+
response: any;
|
|
151
|
+
timestamp: string;
|
|
152
|
+
}
|
|
153
|
+
export interface RecordedSession {
|
|
154
|
+
requests: RecordedRequest[];
|
|
155
|
+
metadata: {
|
|
156
|
+
recordedAt: string;
|
|
157
|
+
version: string;
|
|
158
|
+
config: PcoClientConfig;
|
|
159
|
+
};
|
|
160
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* v2.0.0 Batch Operations Types
|
|
3
|
+
*/
|
|
4
|
+
export interface BatchOperation {
|
|
5
|
+
type: string;
|
|
6
|
+
data?: any;
|
|
7
|
+
dependencies?: string[];
|
|
8
|
+
[key: string]: any;
|
|
9
|
+
}
|
|
10
|
+
export interface BatchResult<T = any> {
|
|
11
|
+
index: number;
|
|
12
|
+
operation: BatchOperation;
|
|
13
|
+
success: boolean;
|
|
14
|
+
data?: T;
|
|
15
|
+
error?: Error;
|
|
16
|
+
}
|
|
17
|
+
export interface BatchOptions {
|
|
18
|
+
/** Continue processing other operations if one fails */
|
|
19
|
+
continueOnError?: boolean;
|
|
20
|
+
/** Maximum number of operations to run in parallel */
|
|
21
|
+
maxConcurrency?: number;
|
|
22
|
+
/** Enable automatic rollback on failure */
|
|
23
|
+
enableRollback?: boolean;
|
|
24
|
+
/** Callback for each completed operation */
|
|
25
|
+
onOperationComplete?: (result: BatchResult) => void;
|
|
26
|
+
/** Callback for batch completion */
|
|
27
|
+
onBatchComplete?: (results: BatchResult[]) => void;
|
|
28
|
+
}
|
|
29
|
+
export interface BatchSummary {
|
|
30
|
+
total: number;
|
|
31
|
+
successful: number;
|
|
32
|
+
failed: number;
|
|
33
|
+
successRate: number;
|
|
34
|
+
duration: number;
|
|
35
|
+
results: BatchResult[];
|
|
36
|
+
}
|
|
37
|
+
export interface OperationReference {
|
|
38
|
+
/** Reference to a previous operation result using $index.path syntax */
|
|
39
|
+
reference: string;
|
|
40
|
+
/** The operation index being referenced */
|
|
41
|
+
index: number;
|
|
42
|
+
/** The path within the result object */
|
|
43
|
+
path: string;
|
|
44
|
+
}
|
|
45
|
+
export interface ResolvedBatchOperation extends BatchOperation {
|
|
46
|
+
/** Resolved data with references replaced */
|
|
47
|
+
resolvedData?: any;
|
|
48
|
+
/** Dependencies on other operations */
|
|
49
|
+
dependencies?: string[];
|
|
50
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* v2.0.0 Client Configuration Types
|
|
3
|
+
*/
|
|
4
|
+
export interface PcoClientConfig {
|
|
5
|
+
/** Authentication configuration */
|
|
6
|
+
auth: {
|
|
7
|
+
type: 'oauth' | 'personal_access_token';
|
|
8
|
+
accessToken?: string;
|
|
9
|
+
refreshToken?: string;
|
|
10
|
+
personalAccessToken?: string;
|
|
11
|
+
onRefresh?: (tokens: {
|
|
12
|
+
accessToken: string;
|
|
13
|
+
refreshToken?: string;
|
|
14
|
+
}) => void | Promise<void>;
|
|
15
|
+
onRefreshFailure?: (error: Error) => void | Promise<void>;
|
|
16
|
+
};
|
|
17
|
+
/** Caching configuration */
|
|
18
|
+
caching?: {
|
|
19
|
+
fieldDefinitions?: boolean;
|
|
20
|
+
ttl?: number;
|
|
21
|
+
maxSize?: number;
|
|
22
|
+
};
|
|
23
|
+
/** Retry configuration */
|
|
24
|
+
retry?: {
|
|
25
|
+
enabled?: boolean;
|
|
26
|
+
maxRetries?: number;
|
|
27
|
+
baseDelay?: number;
|
|
28
|
+
maxDelay?: number;
|
|
29
|
+
backoff?: 'linear' | 'exponential';
|
|
30
|
+
};
|
|
31
|
+
/** Event handlers */
|
|
32
|
+
events?: {
|
|
33
|
+
onError?: (event: ErrorEvent) => void | Promise<void>;
|
|
34
|
+
onAuthFailure?: (event: AuthFailureEvent) => void | Promise<void>;
|
|
35
|
+
onRequestStart?: (event: RequestStartEvent) => void | Promise<void>;
|
|
36
|
+
onRequestComplete?: (event: RequestCompleteEvent) => void | Promise<void>;
|
|
37
|
+
onRateLimit?: (event: RateLimitEvent) => void | Promise<void>;
|
|
38
|
+
};
|
|
39
|
+
/** Base URL override */
|
|
40
|
+
baseURL?: string;
|
|
41
|
+
/** Request timeout in milliseconds */
|
|
42
|
+
timeout?: number;
|
|
43
|
+
/** Custom headers */
|
|
44
|
+
headers?: Record<string, string>;
|
|
45
|
+
}
|
|
46
|
+
export interface ErrorEvent {
|
|
47
|
+
error: Error;
|
|
48
|
+
operation: string;
|
|
49
|
+
timestamp: string;
|
|
50
|
+
context?: Record<string, any>;
|
|
51
|
+
}
|
|
52
|
+
export interface AuthFailureEvent {
|
|
53
|
+
error: Error;
|
|
54
|
+
timestamp: string;
|
|
55
|
+
authType: 'oauth' | 'basic';
|
|
56
|
+
}
|
|
57
|
+
export interface RequestStartEvent {
|
|
58
|
+
endpoint: string;
|
|
59
|
+
method: string;
|
|
60
|
+
timestamp: string;
|
|
61
|
+
requestId: string;
|
|
62
|
+
}
|
|
63
|
+
export interface RequestCompleteEvent {
|
|
64
|
+
endpoint: string;
|
|
65
|
+
method: string;
|
|
66
|
+
status: number;
|
|
67
|
+
duration: number;
|
|
68
|
+
timestamp: string;
|
|
69
|
+
requestId: string;
|
|
70
|
+
}
|
|
71
|
+
export interface RateLimitEvent {
|
|
72
|
+
limit: number;
|
|
73
|
+
remaining: number;
|
|
74
|
+
resetTime: string;
|
|
75
|
+
timestamp: string;
|
|
76
|
+
}
|
|
77
|
+
export interface CacheEvent {
|
|
78
|
+
key: string;
|
|
79
|
+
operation: 'hit' | 'miss' | 'set' | 'invalidate';
|
|
80
|
+
timestamp: string;
|
|
81
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* v2.0.0 Event System Types
|
|
3
|
+
*/
|
|
4
|
+
export type EventType = 'request:start' | 'request:complete' | 'request:error' | 'auth:success' | 'auth:failure' | 'auth:refresh' | 'rate:limit' | 'rate:available' | 'cache:hit' | 'cache:miss' | 'cache:set' | 'cache:invalidate' | 'error';
|
|
5
|
+
export interface BaseEvent {
|
|
6
|
+
type: EventType;
|
|
7
|
+
timestamp: string;
|
|
8
|
+
requestId?: string;
|
|
9
|
+
}
|
|
10
|
+
export interface RequestStartEvent extends BaseEvent {
|
|
11
|
+
type: 'request:start';
|
|
12
|
+
endpoint: string;
|
|
13
|
+
method: string;
|
|
14
|
+
requestId: string;
|
|
15
|
+
}
|
|
16
|
+
export interface RequestCompleteEvent extends BaseEvent {
|
|
17
|
+
type: 'request:complete';
|
|
18
|
+
endpoint: string;
|
|
19
|
+
method: string;
|
|
20
|
+
status: number;
|
|
21
|
+
duration: number;
|
|
22
|
+
requestId: string;
|
|
23
|
+
}
|
|
24
|
+
export interface RequestErrorEvent extends BaseEvent {
|
|
25
|
+
type: 'request:error';
|
|
26
|
+
endpoint: string;
|
|
27
|
+
method: string;
|
|
28
|
+
error: Error;
|
|
29
|
+
requestId: string;
|
|
30
|
+
}
|
|
31
|
+
export interface AuthSuccessEvent extends BaseEvent {
|
|
32
|
+
type: 'auth:success';
|
|
33
|
+
authType: 'oauth' | 'basic';
|
|
34
|
+
}
|
|
35
|
+
export interface AuthFailureEvent extends BaseEvent {
|
|
36
|
+
type: 'auth:failure';
|
|
37
|
+
authType: 'oauth' | 'basic';
|
|
38
|
+
error: Error;
|
|
39
|
+
}
|
|
40
|
+
export interface AuthRefreshEvent extends BaseEvent {
|
|
41
|
+
type: 'auth:refresh';
|
|
42
|
+
authType: 'oauth';
|
|
43
|
+
success: boolean;
|
|
44
|
+
}
|
|
45
|
+
export interface RateLimitEvent extends BaseEvent {
|
|
46
|
+
type: 'rate:limit';
|
|
47
|
+
limit: number;
|
|
48
|
+
remaining: number;
|
|
49
|
+
resetTime: string;
|
|
50
|
+
}
|
|
51
|
+
export interface RateAvailableEvent extends BaseEvent {
|
|
52
|
+
type: 'rate:available';
|
|
53
|
+
limit: number;
|
|
54
|
+
remaining: number;
|
|
55
|
+
}
|
|
56
|
+
export interface CacheHitEvent extends BaseEvent {
|
|
57
|
+
type: 'cache:hit';
|
|
58
|
+
key: string;
|
|
59
|
+
}
|
|
60
|
+
export interface CacheMissEvent extends BaseEvent {
|
|
61
|
+
type: 'cache:miss';
|
|
62
|
+
key: string;
|
|
63
|
+
}
|
|
64
|
+
export interface CacheSetEvent extends BaseEvent {
|
|
65
|
+
type: 'cache:set';
|
|
66
|
+
key: string;
|
|
67
|
+
ttl?: number;
|
|
68
|
+
}
|
|
69
|
+
export interface CacheInvalidateEvent extends BaseEvent {
|
|
70
|
+
type: 'cache:invalidate';
|
|
71
|
+
key: string;
|
|
72
|
+
}
|
|
73
|
+
export interface ErrorEvent extends BaseEvent {
|
|
74
|
+
type: 'error';
|
|
75
|
+
error: Error;
|
|
76
|
+
operation: string;
|
|
77
|
+
context?: Record<string, any>;
|
|
78
|
+
}
|
|
79
|
+
export type PcoEvent = RequestStartEvent | RequestCompleteEvent | RequestErrorEvent | AuthSuccessEvent | AuthFailureEvent | AuthRefreshEvent | RateLimitEvent | RateAvailableEvent | CacheHitEvent | CacheMissEvent | CacheSetEvent | CacheInvalidateEvent | ErrorEvent;
|
|
80
|
+
export type EventHandler<T extends PcoEvent = PcoEvent> = (event: T) => void | Promise<void>;
|
|
81
|
+
export interface EventEmitter {
|
|
82
|
+
on<T extends PcoEvent>(eventType: T['type'], handler: EventHandler<T>): void;
|
|
83
|
+
off<T extends PcoEvent>(eventType: T['type'], handler: EventHandler<T>): void;
|
|
84
|
+
emit<T extends PcoEvent>(event: T): void;
|
|
85
|
+
}
|