@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,62 @@
|
|
|
1
|
+
import { PcoClientState } from '../core';
|
|
2
|
+
import type { ErrorContext } from '../error-handling';
|
|
3
|
+
import { FieldDataList, FieldDataSingle, FieldDefinitionsList, FieldDefinitionSingle, FieldOptionAttributes, FieldOptionSingle, FieldOptionsList, TabsList } from '../types';
|
|
4
|
+
/**
|
|
5
|
+
* Delete field data for a person
|
|
6
|
+
*/
|
|
7
|
+
export declare function deletePersonFieldData(client: PcoClientState, personId: string, fieldDataId: string, context?: Partial<ErrorContext>): Promise<void>;
|
|
8
|
+
/**
|
|
9
|
+
* Get field data for a person (custom fields)
|
|
10
|
+
*/
|
|
11
|
+
export declare function getPersonFieldData(client: PcoClientState, personId: string, context?: Partial<ErrorContext>): Promise<FieldDataList>;
|
|
12
|
+
/**
|
|
13
|
+
* Get field definitions
|
|
14
|
+
*/
|
|
15
|
+
export declare function getFieldDefinitions(client: PcoClientState, params?: {
|
|
16
|
+
include?: string[];
|
|
17
|
+
per_page?: number;
|
|
18
|
+
page?: number;
|
|
19
|
+
filter?: string;
|
|
20
|
+
order?: string;
|
|
21
|
+
}, context?: Partial<ErrorContext>): Promise<FieldDefinitionsList>;
|
|
22
|
+
/**
|
|
23
|
+
* Get a single field definition by ID
|
|
24
|
+
*/
|
|
25
|
+
export declare function getFieldDefinition(client: PcoClientState, fieldId: string, params?: {
|
|
26
|
+
include?: string[];
|
|
27
|
+
}, context?: Partial<ErrorContext>): Promise<FieldDefinitionSingle>;
|
|
28
|
+
/**
|
|
29
|
+
* Get field options for a field definition
|
|
30
|
+
*/
|
|
31
|
+
export declare function getFieldOptions(client: PcoClientState, fieldDefinitionId: string, context?: Partial<ErrorContext>): Promise<FieldOptionsList>;
|
|
32
|
+
/**
|
|
33
|
+
* Create a field option for a field definition
|
|
34
|
+
*/
|
|
35
|
+
export declare function createFieldOption(client: PcoClientState, fieldDefinitionId: string, data: Partial<FieldOptionAttributes>, context?: Partial<ErrorContext>): Promise<FieldOptionSingle>;
|
|
36
|
+
/**
|
|
37
|
+
* Get tabs
|
|
38
|
+
*/
|
|
39
|
+
export declare function getTabs(client: PcoClientState, params?: {
|
|
40
|
+
include?: string[];
|
|
41
|
+
per_page?: number;
|
|
42
|
+
page?: number;
|
|
43
|
+
}, context?: Partial<ErrorContext>): Promise<TabsList>;
|
|
44
|
+
/**
|
|
45
|
+
* Create a field definition
|
|
46
|
+
*/
|
|
47
|
+
export declare function createFieldDefinition(client: PcoClientState, tabId: string, data: {
|
|
48
|
+
name: string;
|
|
49
|
+
data_type: string;
|
|
50
|
+
sequence?: number;
|
|
51
|
+
slug?: string;
|
|
52
|
+
config?: string | Record<string, any>;
|
|
53
|
+
}, context?: Partial<ErrorContext>): Promise<FieldDefinitionSingle>;
|
|
54
|
+
/**
|
|
55
|
+
* Delete a field definition
|
|
56
|
+
*/
|
|
57
|
+
export declare function deleteFieldDefinition(client: PcoClientState, fieldDefinitionId: string, context?: Partial<ErrorContext>): Promise<void>;
|
|
58
|
+
/**
|
|
59
|
+
* Create field data for a person with automatic file upload handling
|
|
60
|
+
* Determines field type and uses appropriate creation method
|
|
61
|
+
*/
|
|
62
|
+
export declare function createPersonFieldData(client: PcoClientState, personId: string, fieldId: string, value: string, context?: Partial<ErrorContext>): Promise<FieldDataSingle>;
|
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.deletePersonFieldData = deletePersonFieldData;
|
|
4
|
+
exports.getPersonFieldData = getPersonFieldData;
|
|
5
|
+
exports.getFieldDefinitions = getFieldDefinitions;
|
|
6
|
+
exports.getFieldDefinition = getFieldDefinition;
|
|
7
|
+
exports.getFieldOptions = getFieldOptions;
|
|
8
|
+
exports.createFieldOption = createFieldOption;
|
|
9
|
+
exports.getTabs = getTabs;
|
|
10
|
+
exports.createFieldDefinition = createFieldDefinition;
|
|
11
|
+
exports.deleteFieldDefinition = deleteFieldDefinition;
|
|
12
|
+
exports.createPersonFieldData = createPersonFieldData;
|
|
13
|
+
const core_1 = require("../core");
|
|
14
|
+
const error_handling_1 = require("../error-handling");
|
|
15
|
+
const helpers_1 = require("../helpers");
|
|
16
|
+
/**
|
|
17
|
+
* Create field data for a person (internal)
|
|
18
|
+
*/
|
|
19
|
+
async function createPersonFieldDataInternal(client, personId, fieldDefinitionId, value, context) {
|
|
20
|
+
return (0, core_1.post)(client, `/people/${personId}/field_data`, {
|
|
21
|
+
field_definition_id: fieldDefinitionId,
|
|
22
|
+
value,
|
|
23
|
+
}, undefined, {
|
|
24
|
+
...context,
|
|
25
|
+
endpoint: `/people/${personId}/field_data`,
|
|
26
|
+
method: 'POST',
|
|
27
|
+
personId,
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Delete field data for a person
|
|
32
|
+
*/
|
|
33
|
+
async function deletePersonFieldData(client, personId, fieldDataId, context) {
|
|
34
|
+
return (0, core_1.del)(client, `/people/${personId}/field_data/${fieldDataId}`, undefined, {
|
|
35
|
+
...context,
|
|
36
|
+
endpoint: `/people/${personId}/field_data/${fieldDataId}`,
|
|
37
|
+
method: 'DELETE',
|
|
38
|
+
personId,
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Get field data for a person (custom fields)
|
|
43
|
+
*/
|
|
44
|
+
async function getPersonFieldData(client, personId, context) {
|
|
45
|
+
return (0, core_1.getList)(client, `/people/${personId}/field_data`, undefined, {
|
|
46
|
+
...context,
|
|
47
|
+
endpoint: `/people/${personId}/field_data`,
|
|
48
|
+
method: 'GET',
|
|
49
|
+
personId,
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Upload a file to PCO and create field data (internal)
|
|
54
|
+
*/
|
|
55
|
+
async function createPersonFileFieldDataInternal(client, personId, fieldDefinitionId, fileUrl, context) {
|
|
56
|
+
return (0, error_handling_1.withErrorBoundary)(async () => {
|
|
57
|
+
// Dynamic import with error handling for optional dependencies
|
|
58
|
+
let axios;
|
|
59
|
+
try {
|
|
60
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
61
|
+
axios = require('axios');
|
|
62
|
+
}
|
|
63
|
+
catch (error) {
|
|
64
|
+
throw new Error('axios package is required for file uploads. Please install it: npm install axios');
|
|
65
|
+
}
|
|
66
|
+
// Extract filename from URL
|
|
67
|
+
const urlParts = fileUrl.split('/');
|
|
68
|
+
const filename = urlParts[urlParts.length - 1] ?? 'file';
|
|
69
|
+
// Extract file extension
|
|
70
|
+
const extension = filename.includes('.')
|
|
71
|
+
? (filename.split('.').pop() ?? '')
|
|
72
|
+
: '';
|
|
73
|
+
// Get MIME type from file extension
|
|
74
|
+
const getMimeType = (ext) => {
|
|
75
|
+
const mimeTypes = {
|
|
76
|
+
csv: 'text/csv',
|
|
77
|
+
doc: 'application/msword',
|
|
78
|
+
docx: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
|
|
79
|
+
gif: 'image/gif',
|
|
80
|
+
jpeg: 'image/jpeg',
|
|
81
|
+
jpg: 'image/jpeg',
|
|
82
|
+
pdf: 'application/pdf',
|
|
83
|
+
png: 'image/png',
|
|
84
|
+
txt: 'text/plain',
|
|
85
|
+
xls: 'application/vnd.ms-excel',
|
|
86
|
+
xlsx: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
|
87
|
+
};
|
|
88
|
+
return mimeTypes[ext.toLowerCase()] || 'application/octet-stream';
|
|
89
|
+
};
|
|
90
|
+
// Download the file from the provided URL
|
|
91
|
+
const fileResponse = await axios.default.get(fileUrl, {
|
|
92
|
+
responseType: 'arraybuffer',
|
|
93
|
+
timeout: 30000, // 30 second timeout
|
|
94
|
+
});
|
|
95
|
+
// Step 1: Upload to PCO's upload service first
|
|
96
|
+
let FormDataConstructor;
|
|
97
|
+
try {
|
|
98
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
99
|
+
const FormDataModule = require('form-data');
|
|
100
|
+
// Handle different export patterns
|
|
101
|
+
FormDataConstructor = FormDataModule.default || FormDataModule;
|
|
102
|
+
}
|
|
103
|
+
catch (error) {
|
|
104
|
+
throw new Error('form-data package is required for file uploads. Please install it: npm install form-data');
|
|
105
|
+
}
|
|
106
|
+
const uploadFormData = new FormDataConstructor();
|
|
107
|
+
uploadFormData.append('file', fileResponse.data, {
|
|
108
|
+
contentType: getMimeType(extension),
|
|
109
|
+
filename,
|
|
110
|
+
});
|
|
111
|
+
// Create a separate axios instance for the upload service with the same auth
|
|
112
|
+
const uploadAxios = axios.default.create({
|
|
113
|
+
headers: {
|
|
114
|
+
Authorization: client.config.accessToken
|
|
115
|
+
? `Bearer ${client.config.accessToken}`
|
|
116
|
+
: `Basic ${Buffer.from(`${client.config.appId}:${client.config.appSecret}`).toString('base64')}`,
|
|
117
|
+
},
|
|
118
|
+
});
|
|
119
|
+
const uploadResponse = await uploadAxios.post('https://upload.planningcenteronline.com/v2/files', uploadFormData, {
|
|
120
|
+
headers: uploadFormData.getHeaders(),
|
|
121
|
+
timeout: 60000,
|
|
122
|
+
});
|
|
123
|
+
// Step 2: Get the file UUID from the response
|
|
124
|
+
const fileUUID = uploadResponse.data?.data?.[0]?.id;
|
|
125
|
+
if (!fileUUID) {
|
|
126
|
+
throw new Error('Failed to get file UUID from upload response');
|
|
127
|
+
}
|
|
128
|
+
// Step 3: Use the UUID to assign the file to the field
|
|
129
|
+
return createPersonFieldDataInternal(client, personId, fieldDefinitionId, fileUUID, {
|
|
130
|
+
...context,
|
|
131
|
+
endpoint: `/people/${personId}/field_data`,
|
|
132
|
+
metadata: {
|
|
133
|
+
...context?.metadata,
|
|
134
|
+
operation: 'create_file_field_data',
|
|
135
|
+
originalFileUrl: fileUrl,
|
|
136
|
+
uploadedFileUUID: fileUUID,
|
|
137
|
+
},
|
|
138
|
+
method: 'POST',
|
|
139
|
+
});
|
|
140
|
+
}, {
|
|
141
|
+
...context,
|
|
142
|
+
category: error_handling_1.ErrorCategory.EXTERNAL_API,
|
|
143
|
+
severity: error_handling_1.ErrorSeverity.HIGH,
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Get field definitions
|
|
148
|
+
*/
|
|
149
|
+
async function getFieldDefinitions(client, params, context) {
|
|
150
|
+
return (0, core_1.getList)(client, '/field_definitions', (0, helpers_1.buildQueryParams)(params), {
|
|
151
|
+
...context,
|
|
152
|
+
endpoint: '/field_definitions',
|
|
153
|
+
method: 'GET',
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Get a single field definition by ID
|
|
158
|
+
*/
|
|
159
|
+
async function getFieldDefinition(client, fieldId, params, context) {
|
|
160
|
+
return (0, core_1.getSingle)(client, `/field_definitions/${fieldId}`, (0, helpers_1.buildQueryParams)(params), {
|
|
161
|
+
...context,
|
|
162
|
+
endpoint: `/field_definitions/${fieldId}`,
|
|
163
|
+
method: 'GET',
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Get field options for a field definition
|
|
168
|
+
*/
|
|
169
|
+
async function getFieldOptions(client, fieldDefinitionId, context) {
|
|
170
|
+
return (0, core_1.getList)(client, `/field_definitions/${fieldDefinitionId}/field_options`, undefined, {
|
|
171
|
+
...context,
|
|
172
|
+
endpoint: `/field_definitions/${fieldDefinitionId}/field_options`,
|
|
173
|
+
fieldDefinitionId,
|
|
174
|
+
method: 'GET',
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Create a field option for a field definition
|
|
179
|
+
*/
|
|
180
|
+
async function createFieldOption(client, fieldDefinitionId, data, context) {
|
|
181
|
+
return (0, core_1.post)(client, `/field_definitions/${fieldDefinitionId}/field_options`, data, undefined, {
|
|
182
|
+
...context,
|
|
183
|
+
endpoint: `/field_definitions/${fieldDefinitionId}/field_options`,
|
|
184
|
+
fieldDefinitionId,
|
|
185
|
+
method: 'POST',
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Get tabs
|
|
190
|
+
*/
|
|
191
|
+
async function getTabs(client, params, context) {
|
|
192
|
+
return (0, core_1.getList)(client, '/tabs', (0, helpers_1.buildQueryParams)(params), {
|
|
193
|
+
...context,
|
|
194
|
+
endpoint: '/tabs',
|
|
195
|
+
method: 'GET',
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Create a field definition
|
|
200
|
+
*/
|
|
201
|
+
async function createFieldDefinition(client, tabId, data, context) {
|
|
202
|
+
return (0, core_1.post)(client, `/tabs/${tabId}/field_definitions`, data, undefined, {
|
|
203
|
+
...context,
|
|
204
|
+
endpoint: `/tabs/${tabId}/field_definitions`,
|
|
205
|
+
method: 'POST',
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Delete a field definition
|
|
210
|
+
*/
|
|
211
|
+
async function deleteFieldDefinition(client, fieldDefinitionId, context) {
|
|
212
|
+
return (0, core_1.del)(client, `/field_definitions/${fieldDefinitionId}`, undefined, {
|
|
213
|
+
...context,
|
|
214
|
+
endpoint: `/field_definitions/${fieldDefinitionId}`,
|
|
215
|
+
method: 'DELETE',
|
|
216
|
+
fieldDefinitionId,
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Helper function to check if a field definition has a data_type attribute
|
|
221
|
+
*/
|
|
222
|
+
function hasDataType(fieldDef) {
|
|
223
|
+
return fieldDef && typeof fieldDef.data_type === 'string';
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Create field data for a person with automatic file upload handling
|
|
227
|
+
* Determines field type and uses appropriate creation method
|
|
228
|
+
*/
|
|
229
|
+
async function createPersonFieldData(client, personId, fieldId, value, context) {
|
|
230
|
+
// Get field definition to determine type
|
|
231
|
+
// Get field definition by ID - try direct fetch first, then search in ordered list
|
|
232
|
+
let fieldDef;
|
|
233
|
+
// First try direct fetch
|
|
234
|
+
const singleFieldDef = await getFieldDefinition(client, fieldId, { include: [] }, {
|
|
235
|
+
...context,
|
|
236
|
+
metadata: {
|
|
237
|
+
...context?.metadata,
|
|
238
|
+
operation: 'get_field_definition_direct',
|
|
239
|
+
},
|
|
240
|
+
});
|
|
241
|
+
fieldDef = singleFieldDef.data || undefined;
|
|
242
|
+
// If direct fetch fails, search through the list ordered by creation date (newest first)
|
|
243
|
+
if (!fieldDef) {
|
|
244
|
+
const fieldDefinition = await getFieldDefinitions(client, {
|
|
245
|
+
include: [],
|
|
246
|
+
// Include deleted fields in case the field was soft-deleted
|
|
247
|
+
filter: 'include_deleted',
|
|
248
|
+
per_page: 200, // Get more fields to ensure we find the one we need
|
|
249
|
+
order: '-created_at', // Order by creation date, newest first
|
|
250
|
+
}, {
|
|
251
|
+
...context,
|
|
252
|
+
metadata: {
|
|
253
|
+
...context?.metadata,
|
|
254
|
+
operation: 'get_field_definition_list',
|
|
255
|
+
},
|
|
256
|
+
});
|
|
257
|
+
// Find the specific field definition
|
|
258
|
+
fieldDef = fieldDefinition.data?.find(f => f.id === fieldId);
|
|
259
|
+
if (!fieldDef) {
|
|
260
|
+
// Debug: log available field IDs to help troubleshoot
|
|
261
|
+
const availableIds = fieldDefinition.data?.map(f => f.id) || [];
|
|
262
|
+
console.log(`Field definition not found for field ID: ${fieldId}`);
|
|
263
|
+
console.log(`Available field definition IDs: ${availableIds.slice(0, 10).join(', ')}${availableIds.length > 10 ? '...' : ''}`);
|
|
264
|
+
console.log(`Total field definitions found: ${fieldDefinition.data?.length || 0}`);
|
|
265
|
+
throw new Error(`Field definition not found for field ID: ${fieldId}`);
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
// Check if this is a file field
|
|
269
|
+
if (hasDataType(fieldDef.attributes) && fieldDef.attributes.data_type === 'file') {
|
|
270
|
+
// This is a file field - always use file upload
|
|
271
|
+
const fileUrl = (0, helpers_1.isFileUpload)(value) ? (0, helpers_1.extractFileUrl)(value) : value;
|
|
272
|
+
return createPersonFileFieldDataInternal(client, personId, fieldId, fileUrl, {
|
|
273
|
+
...context,
|
|
274
|
+
endpoint: `/people/${personId}/field_data`,
|
|
275
|
+
metadata: {
|
|
276
|
+
...context?.metadata,
|
|
277
|
+
operation: 'create_file_field_data',
|
|
278
|
+
},
|
|
279
|
+
method: 'POST',
|
|
280
|
+
});
|
|
281
|
+
}
|
|
282
|
+
// This is a text field - clean the value if it's a file URL
|
|
283
|
+
const cleanValue = (0, helpers_1.isFileUpload)(value) ? (0, helpers_1.extractFileUrl)(value) : value;
|
|
284
|
+
return createPersonFieldDataInternal(client, personId, fieldId, cleanValue, {
|
|
285
|
+
...context,
|
|
286
|
+
endpoint: `/people/${personId}/field_data`,
|
|
287
|
+
metadata: {
|
|
288
|
+
...context?.metadata,
|
|
289
|
+
operation: 'create_text_field_data',
|
|
290
|
+
},
|
|
291
|
+
method: 'POST',
|
|
292
|
+
});
|
|
293
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { PcoClientState } from '../core';
|
|
2
|
+
import type { ErrorContext } from '../error-handling';
|
|
3
|
+
import { HouseholdSingle, HouseholdsList } from '../types';
|
|
4
|
+
/**
|
|
5
|
+
* Get all households
|
|
6
|
+
*/
|
|
7
|
+
export declare function getHouseholds(client: PcoClientState, params?: {
|
|
8
|
+
include?: string[];
|
|
9
|
+
per_page?: number;
|
|
10
|
+
page?: number;
|
|
11
|
+
}, context?: Partial<ErrorContext>): Promise<HouseholdsList>;
|
|
12
|
+
/**
|
|
13
|
+
* Get a single household by ID
|
|
14
|
+
*/
|
|
15
|
+
export declare function getHousehold(client: PcoClientState, id: string, include?: string[], context?: Partial<ErrorContext>): Promise<HouseholdSingle>;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getHouseholds = getHouseholds;
|
|
4
|
+
exports.getHousehold = getHousehold;
|
|
5
|
+
const core_1 = require("../core");
|
|
6
|
+
const helpers_1 = require("../helpers");
|
|
7
|
+
/**
|
|
8
|
+
* Get all households
|
|
9
|
+
*/
|
|
10
|
+
async function getHouseholds(client, params, context) {
|
|
11
|
+
return (0, core_1.getList)(client, '/households', (0, helpers_1.buildQueryParams)(params), {
|
|
12
|
+
...context,
|
|
13
|
+
endpoint: '/households',
|
|
14
|
+
method: 'GET',
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Get a single household by ID
|
|
19
|
+
*/
|
|
20
|
+
async function getHousehold(client, id, include, context) {
|
|
21
|
+
const params = {};
|
|
22
|
+
if (include) {
|
|
23
|
+
params.include = include.join(',');
|
|
24
|
+
}
|
|
25
|
+
return (0, core_1.getSingle)(client, `/households/${id}`, params, {
|
|
26
|
+
...context,
|
|
27
|
+
endpoint: `/households/${id}`,
|
|
28
|
+
householdId: id,
|
|
29
|
+
method: 'GET',
|
|
30
|
+
});
|
|
31
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
// Re-export all people-related functions from their respective modules
|
|
18
|
+
__exportStar(require("./core"), exports);
|
|
19
|
+
__exportStar(require("./contacts"), exports);
|
|
20
|
+
__exportStar(require("./fields"), exports);
|
|
21
|
+
__exportStar(require("./households"), exports);
|
|
22
|
+
__exportStar(require("./lists"), exports);
|
|
23
|
+
__exportStar(require("./notes"), exports);
|
|
24
|
+
__exportStar(require("./workflows"), exports);
|
|
25
|
+
__exportStar(require("./organization"), exports);
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { PcoClientState } from '../core';
|
|
2
|
+
import type { ErrorContext } from '../error-handling';
|
|
3
|
+
import { ListCategoriesList, ListSingle, ListsList } from '../types';
|
|
4
|
+
/**
|
|
5
|
+
* Get all lists
|
|
6
|
+
*/
|
|
7
|
+
export declare function getLists(client: PcoClientState, params?: {
|
|
8
|
+
where?: Record<string, any>;
|
|
9
|
+
include?: string[];
|
|
10
|
+
per_page?: number;
|
|
11
|
+
page?: number;
|
|
12
|
+
}, context?: Partial<ErrorContext>): Promise<ListsList>;
|
|
13
|
+
/**
|
|
14
|
+
* Get a single list
|
|
15
|
+
*/
|
|
16
|
+
export declare function getListById(client: PcoClientState, listId: string, params?: {
|
|
17
|
+
where?: Record<string, any>;
|
|
18
|
+
include?: string[];
|
|
19
|
+
per_page?: number;
|
|
20
|
+
page?: number;
|
|
21
|
+
}, context?: Partial<ErrorContext>): Promise<ListSingle>;
|
|
22
|
+
/**
|
|
23
|
+
* Get all list categories
|
|
24
|
+
*/
|
|
25
|
+
export declare function getListCategories(client: PcoClientState, params?: {
|
|
26
|
+
where?: Record<string, any>;
|
|
27
|
+
include?: string[];
|
|
28
|
+
per_page?: number;
|
|
29
|
+
page?: number;
|
|
30
|
+
}, context?: Partial<ErrorContext>): Promise<ListCategoriesList>;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getLists = getLists;
|
|
4
|
+
exports.getListById = getListById;
|
|
5
|
+
exports.getListCategories = getListCategories;
|
|
6
|
+
const core_1 = require("../core");
|
|
7
|
+
const helpers_1 = require("../helpers");
|
|
8
|
+
/**
|
|
9
|
+
* Get all lists
|
|
10
|
+
*/
|
|
11
|
+
async function getLists(client, params, context) {
|
|
12
|
+
return (0, core_1.getList)(client, '/lists', (0, helpers_1.buildQueryParams)(params), {
|
|
13
|
+
...context,
|
|
14
|
+
endpoint: '/lists',
|
|
15
|
+
method: 'GET',
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Get a single list
|
|
20
|
+
*/
|
|
21
|
+
async function getListById(client, listId, params, context) {
|
|
22
|
+
return (0, core_1.getSingle)(client, `/lists/${listId}`, (0, helpers_1.buildQueryParams)(params), {
|
|
23
|
+
...context,
|
|
24
|
+
endpoint: `/lists/${listId}`,
|
|
25
|
+
method: 'GET',
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Get all list categories
|
|
30
|
+
*/
|
|
31
|
+
async function getListCategories(client, params, context) {
|
|
32
|
+
return (0, core_1.getList)(client, '/list_categories', (0, helpers_1.buildQueryParams)(params), {
|
|
33
|
+
...context,
|
|
34
|
+
endpoint: '/list_categories',
|
|
35
|
+
method: 'GET',
|
|
36
|
+
});
|
|
37
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { PcoClientState } from '../core';
|
|
2
|
+
import type { ErrorContext } from '../error-handling';
|
|
3
|
+
import { NoteCategoriesList, NoteSingle, NotesList } from '../types';
|
|
4
|
+
/**
|
|
5
|
+
* Get all notes
|
|
6
|
+
*/
|
|
7
|
+
export declare function getNotes(client: PcoClientState, params?: {
|
|
8
|
+
where?: Record<string, any>;
|
|
9
|
+
include?: string[];
|
|
10
|
+
per_page?: number;
|
|
11
|
+
page?: number;
|
|
12
|
+
}, context?: Partial<ErrorContext>): Promise<NotesList>;
|
|
13
|
+
/**
|
|
14
|
+
* Get a single note
|
|
15
|
+
*/
|
|
16
|
+
export declare function getNote(client: PcoClientState, noteId: string, params?: {
|
|
17
|
+
where?: Record<string, any>;
|
|
18
|
+
include?: string[];
|
|
19
|
+
per_page?: number;
|
|
20
|
+
page?: number;
|
|
21
|
+
}, context?: Partial<ErrorContext>): Promise<NoteSingle>;
|
|
22
|
+
/**
|
|
23
|
+
* Get all note categories
|
|
24
|
+
*/
|
|
25
|
+
export declare function getNoteCategories(client: PcoClientState, params?: {
|
|
26
|
+
where?: Record<string, any>;
|
|
27
|
+
include?: string[];
|
|
28
|
+
per_page?: number;
|
|
29
|
+
page?: number;
|
|
30
|
+
}, context?: Partial<ErrorContext>): Promise<NoteCategoriesList>;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getNotes = getNotes;
|
|
4
|
+
exports.getNote = getNote;
|
|
5
|
+
exports.getNoteCategories = getNoteCategories;
|
|
6
|
+
const core_1 = require("../core");
|
|
7
|
+
const helpers_1 = require("../helpers");
|
|
8
|
+
/**
|
|
9
|
+
* Get all notes
|
|
10
|
+
*/
|
|
11
|
+
async function getNotes(client, params, context) {
|
|
12
|
+
return (0, core_1.getList)(client, '/notes', (0, helpers_1.buildQueryParams)(params), {
|
|
13
|
+
...context,
|
|
14
|
+
endpoint: '/notes',
|
|
15
|
+
method: 'GET',
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Get a single note
|
|
20
|
+
*/
|
|
21
|
+
async function getNote(client, noteId, params, context) {
|
|
22
|
+
return (0, core_1.getSingle)(client, `/notes/${noteId}`, (0, helpers_1.buildQueryParams)(params), {
|
|
23
|
+
...context,
|
|
24
|
+
endpoint: `/notes/${noteId}`,
|
|
25
|
+
method: 'GET',
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Get all note categories
|
|
30
|
+
*/
|
|
31
|
+
async function getNoteCategories(client, params, context) {
|
|
32
|
+
return (0, core_1.getList)(client, '/note_categories', (0, helpers_1.buildQueryParams)(params), {
|
|
33
|
+
...context,
|
|
34
|
+
endpoint: '/note_categories',
|
|
35
|
+
method: 'GET',
|
|
36
|
+
});
|
|
37
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { PcoClientState } from '../core';
|
|
2
|
+
import type { ErrorContext } from '../error-handling';
|
|
3
|
+
import { OrganizationSingle } from '../types';
|
|
4
|
+
/**
|
|
5
|
+
* Get organization information
|
|
6
|
+
*/
|
|
7
|
+
export declare function getOrganization(client: PcoClientState, params?: {
|
|
8
|
+
where?: Record<string, any>;
|
|
9
|
+
include?: string[];
|
|
10
|
+
per_page?: number;
|
|
11
|
+
page?: number;
|
|
12
|
+
}, context?: Partial<ErrorContext>): Promise<OrganizationSingle>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getOrganization = getOrganization;
|
|
4
|
+
const core_1 = require("../core");
|
|
5
|
+
const helpers_1 = require("../helpers");
|
|
6
|
+
/**
|
|
7
|
+
* Get organization information
|
|
8
|
+
*/
|
|
9
|
+
async function getOrganization(client, params, context) {
|
|
10
|
+
return (0, core_1.getSingle)(client, '/', (0, helpers_1.buildQueryParams)(params), {
|
|
11
|
+
...context,
|
|
12
|
+
endpoint: '/',
|
|
13
|
+
method: 'GET',
|
|
14
|
+
});
|
|
15
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { PcoClientState } from '../core';
|
|
2
|
+
import type { ErrorContext } from '../error-handling';
|
|
3
|
+
import { WorkflowCardNoteAttributes, WorkflowCardNoteSingle, WorkflowCardNotesList, WorkflowCardSingle, WorkflowCardsList, WorkflowSingle, WorkflowsList } from '../types';
|
|
4
|
+
/**
|
|
5
|
+
* List notes for a workflow card
|
|
6
|
+
*/
|
|
7
|
+
export declare function getWorkflowCardNotes(client: PcoClientState, personId: string, workflowCardId: string, context?: Partial<ErrorContext>): Promise<WorkflowCardNotesList>;
|
|
8
|
+
/**
|
|
9
|
+
* Create a note for a workflow card
|
|
10
|
+
*/
|
|
11
|
+
export declare function createWorkflowCardNote(client: PcoClientState, personId: string, workflowCardId: string, data: Partial<WorkflowCardNoteAttributes>, context?: Partial<ErrorContext>): Promise<WorkflowCardNoteSingle>;
|
|
12
|
+
/**
|
|
13
|
+
* List workflow cards for a person
|
|
14
|
+
*/
|
|
15
|
+
export declare function getWorkflowCards(client: PcoClientState, personId: string, context?: Partial<ErrorContext>): Promise<WorkflowCardsList>;
|
|
16
|
+
/**
|
|
17
|
+
* Create a workflow card in a workflow for a person
|
|
18
|
+
*/
|
|
19
|
+
export declare function createWorkflowCard(client: PcoClientState, workflowId: string, personId: string, context?: Partial<ErrorContext>): Promise<WorkflowCardSingle>;
|
|
20
|
+
/**
|
|
21
|
+
* Get all workflows
|
|
22
|
+
*/
|
|
23
|
+
export declare function getWorkflows(client: PcoClientState, params?: {
|
|
24
|
+
where?: Record<string, any>;
|
|
25
|
+
include?: string[];
|
|
26
|
+
per_page?: number;
|
|
27
|
+
page?: number;
|
|
28
|
+
}, context?: Partial<ErrorContext>): Promise<WorkflowsList>;
|
|
29
|
+
/**
|
|
30
|
+
* Get a single workflow
|
|
31
|
+
*/
|
|
32
|
+
export declare function getWorkflow(client: PcoClientState, workflowId: string, params?: {
|
|
33
|
+
where?: Record<string, any>;
|
|
34
|
+
include?: string[];
|
|
35
|
+
per_page?: number;
|
|
36
|
+
page?: number;
|
|
37
|
+
}, context?: Partial<ErrorContext>): Promise<WorkflowSingle>;
|