@rachelallyson/planning-center-people-ts 1.1.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 +116 -0
- package/README.md +16 -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/index.d.ts +13 -3
- package/dist/index.js +23 -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/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 +20 -1
- package/package.json +9 -3
|
@@ -0,0 +1,294 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* v2.0.0 Fields Module
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.FieldsModule = void 0;
|
|
7
|
+
const base_1 = require("./base");
|
|
8
|
+
class FieldsModule extends base_1.BaseModule {
|
|
9
|
+
constructor(httpClient, paginationHelper, eventEmitter) {
|
|
10
|
+
super(httpClient, paginationHelper, eventEmitter);
|
|
11
|
+
this.fieldDefinitionCache = null;
|
|
12
|
+
this.cacheTtl = 300000; // 5 minutes
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Get all field definitions with caching
|
|
16
|
+
*/
|
|
17
|
+
async getAllFieldDefinitions(useCache = true) {
|
|
18
|
+
if (useCache && this.isCacheValid()) {
|
|
19
|
+
return Array.from(this.fieldDefinitionCache.byId.values());
|
|
20
|
+
}
|
|
21
|
+
const result = await this.getAllPages('/field_definitions', {
|
|
22
|
+
include: ['tab'],
|
|
23
|
+
});
|
|
24
|
+
// Update cache
|
|
25
|
+
this.updateFieldDefinitionCache(result.data);
|
|
26
|
+
return result.data;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Get a single field definition by ID
|
|
30
|
+
*/
|
|
31
|
+
async getFieldDefinition(id) {
|
|
32
|
+
return this.getSingle(`/field_definitions/${id}`);
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Get field definition by slug
|
|
36
|
+
*/
|
|
37
|
+
async getFieldDefinitionBySlug(slug) {
|
|
38
|
+
await this.ensureCacheLoaded();
|
|
39
|
+
return this.fieldDefinitionCache?.bySlug.get(slug) || null;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Get field definition by name
|
|
43
|
+
*/
|
|
44
|
+
async getFieldDefinitionByName(name) {
|
|
45
|
+
await this.ensureCacheLoaded();
|
|
46
|
+
return this.fieldDefinitionCache?.byName.get(name) || null;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Create a field definition
|
|
50
|
+
*/
|
|
51
|
+
async createFieldDefinition(tabId, data) {
|
|
52
|
+
const fieldDef = await this.createResource(`/tabs/${tabId}/field_definitions`, data);
|
|
53
|
+
// Invalidate cache
|
|
54
|
+
this.invalidateCache();
|
|
55
|
+
return fieldDef;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Update a field definition
|
|
59
|
+
*/
|
|
60
|
+
async updateFieldDefinition(id, data) {
|
|
61
|
+
const fieldDef = await this.updateResource(`/field_definitions/${id}`, data);
|
|
62
|
+
// Update cache
|
|
63
|
+
if (this.fieldDefinitionCache && fieldDef.attributes) {
|
|
64
|
+
this.fieldDefinitionCache.byId.set(id, fieldDef);
|
|
65
|
+
this.fieldDefinitionCache.bySlug.set(fieldDef.attributes.slug, fieldDef);
|
|
66
|
+
this.fieldDefinitionCache.byName.set(fieldDef.attributes.name, fieldDef);
|
|
67
|
+
}
|
|
68
|
+
return fieldDef;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Delete a field definition
|
|
72
|
+
*/
|
|
73
|
+
async deleteFieldDefinition(id) {
|
|
74
|
+
await this.deleteResource(`/field_definitions/${id}`);
|
|
75
|
+
// Remove from cache
|
|
76
|
+
if (this.fieldDefinitionCache) {
|
|
77
|
+
const fieldDef = this.fieldDefinitionCache.byId.get(id);
|
|
78
|
+
if (fieldDef && fieldDef.attributes) {
|
|
79
|
+
this.fieldDefinitionCache.byId.delete(id);
|
|
80
|
+
this.fieldDefinitionCache.bySlug.delete(fieldDef.attributes.slug);
|
|
81
|
+
this.fieldDefinitionCache.byName.delete(fieldDef.attributes.name);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Get field options for a field definition
|
|
87
|
+
*/
|
|
88
|
+
async getFieldOptions(fieldDefinitionId) {
|
|
89
|
+
return this.getList(`/field_definitions/${fieldDefinitionId}/field_options`);
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Create a field option
|
|
93
|
+
*/
|
|
94
|
+
async createFieldOption(fieldDefinitionId, data) {
|
|
95
|
+
return this.createResource(`/field_definitions/${fieldDefinitionId}/field_options`, data);
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Get person's field data
|
|
99
|
+
*/
|
|
100
|
+
async getPersonFieldData(personId) {
|
|
101
|
+
return this.getList(`/people/${personId}/field_data`);
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Set a person's field value with automatic field lookup
|
|
105
|
+
*/
|
|
106
|
+
async setPersonField(personId, options) {
|
|
107
|
+
const fieldDef = await this.resolveFieldDefinition(options);
|
|
108
|
+
if (!fieldDef) {
|
|
109
|
+
throw new Error(`Field definition not found for: ${options.fieldId || options.fieldSlug || options.fieldName}`);
|
|
110
|
+
}
|
|
111
|
+
return this.createPersonFieldData(personId, fieldDef.id, options.value, {
|
|
112
|
+
handleFileUploads: options.handleFileUploads ?? true,
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Set a person's field value by field definition ID
|
|
117
|
+
*/
|
|
118
|
+
async setPersonFieldById(personId, fieldId, value) {
|
|
119
|
+
return this.createPersonFieldData(personId, fieldId, value);
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Set a person's field value by field slug
|
|
123
|
+
*/
|
|
124
|
+
async setPersonFieldBySlug(personId, fieldSlug, value) {
|
|
125
|
+
const fieldDef = await this.getFieldDefinitionBySlug(fieldSlug);
|
|
126
|
+
if (!fieldDef) {
|
|
127
|
+
throw new Error(`Field definition not found for slug: ${fieldSlug}`);
|
|
128
|
+
}
|
|
129
|
+
return this.createPersonFieldData(personId, fieldDef.id, value);
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Set a person's field value by field name
|
|
133
|
+
*/
|
|
134
|
+
async setPersonFieldByName(personId, fieldName, value) {
|
|
135
|
+
const fieldDef = await this.getFieldDefinitionByName(fieldName);
|
|
136
|
+
if (!fieldDef) {
|
|
137
|
+
throw new Error(`Field definition not found for name: ${fieldName}`);
|
|
138
|
+
}
|
|
139
|
+
return this.createPersonFieldData(personId, fieldDef.id, value);
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Create field data for a person
|
|
143
|
+
*/
|
|
144
|
+
async createPersonFieldData(personId, fieldDefinitionId, value, options = {}) {
|
|
145
|
+
const { handleFileUploads = true } = options;
|
|
146
|
+
// Get field definition to determine type
|
|
147
|
+
const fieldDef = await this.getFieldDefinition(fieldDefinitionId);
|
|
148
|
+
// Check if this is a file field and handle accordingly
|
|
149
|
+
if (fieldDef.attributes && fieldDef.attributes.data_type === 'file' && handleFileUploads) {
|
|
150
|
+
return this.createPersonFileFieldData(personId, fieldDefinitionId, value);
|
|
151
|
+
}
|
|
152
|
+
// For text fields, clean the value if it's a file URL
|
|
153
|
+
const cleanValue = this.isFileUrl(value) ? this.extractFileUrl(value) : value;
|
|
154
|
+
// Check if field data already exists for this person and field
|
|
155
|
+
try {
|
|
156
|
+
const existingFieldData = await this.getPersonFieldData(personId);
|
|
157
|
+
const existingDatum = existingFieldData.data.find(datum => {
|
|
158
|
+
const fieldDefData = datum.relationships?.field_definition?.data;
|
|
159
|
+
return Array.isArray(fieldDefData)
|
|
160
|
+
? fieldDefData.some(fd => fd.id === fieldDefinitionId)
|
|
161
|
+
: fieldDefData?.id === fieldDefinitionId;
|
|
162
|
+
});
|
|
163
|
+
if (existingDatum) {
|
|
164
|
+
// Update existing field data
|
|
165
|
+
return this.updateResource(`/people/${personId}/field_data/${existingDatum.id}`, { value: cleanValue });
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
catch (error) {
|
|
169
|
+
// If we can't get existing field data, continue with creation
|
|
170
|
+
}
|
|
171
|
+
return this.createResource(`/people/${personId}/field_data`, {
|
|
172
|
+
field_definition_id: fieldDefinitionId,
|
|
173
|
+
value: cleanValue,
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Delete person's field data
|
|
178
|
+
*/
|
|
179
|
+
async deletePersonFieldData(personId, fieldDataId) {
|
|
180
|
+
return this.deleteResource(`/people/${personId}/field_data/${fieldDataId}`);
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Get all tabs
|
|
184
|
+
*/
|
|
185
|
+
async getTabs() {
|
|
186
|
+
return this.getList('/tabs');
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Create a tab
|
|
190
|
+
*/
|
|
191
|
+
async createTab(data) {
|
|
192
|
+
return this.createResource('/tabs', data);
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Update a tab
|
|
196
|
+
*/
|
|
197
|
+
async updateTab(id, data) {
|
|
198
|
+
return this.updateResource(`/tabs/${id}`, data);
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Delete a tab
|
|
202
|
+
*/
|
|
203
|
+
async deleteTab(id) {
|
|
204
|
+
return this.deleteResource(`/tabs/${id}`);
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Resolve field definition from options
|
|
208
|
+
*/
|
|
209
|
+
async resolveFieldDefinition(options) {
|
|
210
|
+
if (options.fieldId) {
|
|
211
|
+
return this.getFieldDefinition(options.fieldId);
|
|
212
|
+
}
|
|
213
|
+
if (options.fieldSlug) {
|
|
214
|
+
return this.getFieldDefinitionBySlug(options.fieldSlug);
|
|
215
|
+
}
|
|
216
|
+
if (options.fieldName) {
|
|
217
|
+
return this.getFieldDefinitionByName(options.fieldName);
|
|
218
|
+
}
|
|
219
|
+
return null;
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* Create field data for file uploads
|
|
223
|
+
*/
|
|
224
|
+
async createPersonFileFieldData(personId, fieldDefinitionId, fileUrl) {
|
|
225
|
+
// This would implement the file upload logic from the original implementation
|
|
226
|
+
// For now, return a placeholder
|
|
227
|
+
throw new Error('File upload functionality not yet implemented in v2.0');
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Check if cache is valid
|
|
231
|
+
*/
|
|
232
|
+
isCacheValid() {
|
|
233
|
+
if (!this.fieldDefinitionCache) {
|
|
234
|
+
return false;
|
|
235
|
+
}
|
|
236
|
+
return Date.now() - this.fieldDefinitionCache.lastUpdated < this.cacheTtl;
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* Ensure cache is loaded
|
|
240
|
+
*/
|
|
241
|
+
async ensureCacheLoaded() {
|
|
242
|
+
if (!this.isCacheValid()) {
|
|
243
|
+
await this.getAllFieldDefinitions(false);
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* Update field definition cache
|
|
248
|
+
*/
|
|
249
|
+
updateFieldDefinitionCache(fieldDefinitions) {
|
|
250
|
+
this.fieldDefinitionCache = {
|
|
251
|
+
byId: new Map(),
|
|
252
|
+
bySlug: new Map(),
|
|
253
|
+
byName: new Map(),
|
|
254
|
+
lastUpdated: Date.now(),
|
|
255
|
+
};
|
|
256
|
+
for (const fieldDef of fieldDefinitions) {
|
|
257
|
+
if (fieldDef.attributes) {
|
|
258
|
+
this.fieldDefinitionCache.byId.set(fieldDef.id, fieldDef);
|
|
259
|
+
this.fieldDefinitionCache.bySlug.set(fieldDef.attributes.slug, fieldDef);
|
|
260
|
+
this.fieldDefinitionCache.byName.set(fieldDef.attributes.name, fieldDef);
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
/**
|
|
265
|
+
* Invalidate cache
|
|
266
|
+
*/
|
|
267
|
+
invalidateCache() {
|
|
268
|
+
this.fieldDefinitionCache = null;
|
|
269
|
+
}
|
|
270
|
+
/**
|
|
271
|
+
* Check if a value is a file URL
|
|
272
|
+
*/
|
|
273
|
+
isFileUrl(value) {
|
|
274
|
+
return value.includes('s3.') || value.includes('amazonaws.com') || value.includes('<a href=');
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* Extract file URL from HTML markup
|
|
278
|
+
*/
|
|
279
|
+
extractFileUrl(value) {
|
|
280
|
+
if (value.startsWith('http') && !value.includes('<')) {
|
|
281
|
+
return value;
|
|
282
|
+
}
|
|
283
|
+
const hrefMatch = /href=["']([^"']+)["']/.exec(value);
|
|
284
|
+
if (hrefMatch) {
|
|
285
|
+
return hrefMatch[1];
|
|
286
|
+
}
|
|
287
|
+
const urlMatch = /(https?:\/\/[^\s<>"']+)/.exec(value);
|
|
288
|
+
if (urlMatch) {
|
|
289
|
+
return urlMatch[1];
|
|
290
|
+
}
|
|
291
|
+
return value;
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
exports.FieldsModule = FieldsModule;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* v2.0.0 Households Module
|
|
3
|
+
*/
|
|
4
|
+
import { BaseModule } from './base';
|
|
5
|
+
import type { PaginationOptions, PaginationResult } from '../core/pagination';
|
|
6
|
+
import type { HouseholdResource, HouseholdAttributes } from '../types';
|
|
7
|
+
export interface HouseholdListOptions {
|
|
8
|
+
where?: Record<string, any>;
|
|
9
|
+
include?: string[];
|
|
10
|
+
perPage?: number;
|
|
11
|
+
page?: number;
|
|
12
|
+
}
|
|
13
|
+
export declare class HouseholdsModule extends BaseModule {
|
|
14
|
+
/**
|
|
15
|
+
* Get all households
|
|
16
|
+
*/
|
|
17
|
+
getAll(options?: HouseholdListOptions): Promise<{
|
|
18
|
+
data: HouseholdResource[];
|
|
19
|
+
meta?: any;
|
|
20
|
+
links?: any;
|
|
21
|
+
}>;
|
|
22
|
+
/**
|
|
23
|
+
* Get all households across all pages
|
|
24
|
+
*/
|
|
25
|
+
getAllPagesPaginated(options?: HouseholdListOptions, paginationOptions?: PaginationOptions): Promise<PaginationResult<HouseholdResource>>;
|
|
26
|
+
/**
|
|
27
|
+
* Get a single household by ID
|
|
28
|
+
*/
|
|
29
|
+
getById(id: string, include?: string[]): Promise<HouseholdResource>;
|
|
30
|
+
/**
|
|
31
|
+
* Create a household
|
|
32
|
+
*/
|
|
33
|
+
create(data: HouseholdAttributes): Promise<HouseholdResource>;
|
|
34
|
+
/**
|
|
35
|
+
* Update a household
|
|
36
|
+
*/
|
|
37
|
+
update(id: string, data: Partial<HouseholdAttributes>): Promise<HouseholdResource>;
|
|
38
|
+
/**
|
|
39
|
+
* Delete a household
|
|
40
|
+
*/
|
|
41
|
+
delete(id: string): Promise<void>;
|
|
42
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* v2.0.0 Households Module
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.HouseholdsModule = void 0;
|
|
7
|
+
const base_1 = require("./base");
|
|
8
|
+
class HouseholdsModule extends base_1.BaseModule {
|
|
9
|
+
/**
|
|
10
|
+
* Get all households
|
|
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('/households', params);
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Get all households 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('/households', params, paginationOptions);
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Get a single household by ID
|
|
47
|
+
*/
|
|
48
|
+
async getById(id, include) {
|
|
49
|
+
const params = {};
|
|
50
|
+
if (include) {
|
|
51
|
+
params.include = include.join(',');
|
|
52
|
+
}
|
|
53
|
+
return this.getSingle(`/households/${id}`, params);
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Create a household
|
|
57
|
+
*/
|
|
58
|
+
async create(data) {
|
|
59
|
+
return this.createResource('/households', data);
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Update a household
|
|
63
|
+
*/
|
|
64
|
+
async update(id, data) {
|
|
65
|
+
return this.updateResource(`/households/${id}`, data);
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Delete a household
|
|
69
|
+
*/
|
|
70
|
+
async delete(id) {
|
|
71
|
+
return this.deleteResource(`/households/${id}`);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
exports.HouseholdsModule = HouseholdsModule;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* v2.0.0 Lists Module
|
|
3
|
+
*/
|
|
4
|
+
import { BaseModule } from './base';
|
|
5
|
+
import type { PaginationOptions, PaginationResult } from '../core/pagination';
|
|
6
|
+
import type { ListResource, ListCategoryResource, ListCategoryAttributes, PersonResource } from '../types';
|
|
7
|
+
export interface ListsListOptions {
|
|
8
|
+
where?: Record<string, any>;
|
|
9
|
+
include?: string[];
|
|
10
|
+
perPage?: number;
|
|
11
|
+
page?: number;
|
|
12
|
+
}
|
|
13
|
+
export declare class ListsModule extends BaseModule {
|
|
14
|
+
/**
|
|
15
|
+
* Get all lists
|
|
16
|
+
*/
|
|
17
|
+
getAll(options?: ListsListOptions): Promise<{
|
|
18
|
+
data: ListResource[];
|
|
19
|
+
meta?: any;
|
|
20
|
+
links?: any;
|
|
21
|
+
}>;
|
|
22
|
+
/**
|
|
23
|
+
* Get all lists across all pages
|
|
24
|
+
*/
|
|
25
|
+
getAllPagesPaginated(options?: ListsListOptions, paginationOptions?: PaginationOptions): Promise<PaginationResult<ListResource>>;
|
|
26
|
+
/**
|
|
27
|
+
* Get a single list by ID
|
|
28
|
+
*/
|
|
29
|
+
getById(id: string, include?: string[]): Promise<ListResource>;
|
|
30
|
+
/**
|
|
31
|
+
* Get all list categories
|
|
32
|
+
*/
|
|
33
|
+
getListCategories(): Promise<{
|
|
34
|
+
data: ListCategoryResource[];
|
|
35
|
+
meta?: any;
|
|
36
|
+
links?: any;
|
|
37
|
+
}>;
|
|
38
|
+
/**
|
|
39
|
+
* Get a single list category by ID
|
|
40
|
+
*/
|
|
41
|
+
getListCategoryById(id: string): Promise<ListCategoryResource>;
|
|
42
|
+
/**
|
|
43
|
+
* Create a new list category
|
|
44
|
+
*/
|
|
45
|
+
createListCategory(data: ListCategoryAttributes): Promise<ListCategoryResource>;
|
|
46
|
+
/**
|
|
47
|
+
* Update an existing list category
|
|
48
|
+
*/
|
|
49
|
+
updateListCategory(id: string, data: Partial<ListCategoryAttributes>): Promise<ListCategoryResource>;
|
|
50
|
+
/**
|
|
51
|
+
* Delete a list category
|
|
52
|
+
*/
|
|
53
|
+
deleteListCategory(id: string): Promise<void>;
|
|
54
|
+
/**
|
|
55
|
+
* Get people in a list (via the people relationship)
|
|
56
|
+
*/
|
|
57
|
+
getPeople(listId: string): Promise<{
|
|
58
|
+
data: PersonResource[];
|
|
59
|
+
meta?: any;
|
|
60
|
+
links?: any;
|
|
61
|
+
}>;
|
|
62
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* v2.0.0 Lists Module
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.ListsModule = void 0;
|
|
7
|
+
const base_1 = require("./base");
|
|
8
|
+
class ListsModule extends base_1.BaseModule {
|
|
9
|
+
/**
|
|
10
|
+
* Get all lists
|
|
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('/lists', params);
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Get all lists 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('/lists', params, paginationOptions);
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Get a single list by ID
|
|
47
|
+
*/
|
|
48
|
+
async getById(id, include) {
|
|
49
|
+
const params = {};
|
|
50
|
+
if (include) {
|
|
51
|
+
params.include = include.join(',');
|
|
52
|
+
}
|
|
53
|
+
return this.getSingle(`/lists/${id}`, params);
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Get all list categories
|
|
57
|
+
*/
|
|
58
|
+
async getListCategories() {
|
|
59
|
+
return this.getList('/list_categories');
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Get a single list category by ID
|
|
63
|
+
*/
|
|
64
|
+
async getListCategoryById(id) {
|
|
65
|
+
return this.getSingle(`/list_categories/${id}`);
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Create a new list category
|
|
69
|
+
*/
|
|
70
|
+
async createListCategory(data) {
|
|
71
|
+
return this.createResource('/list_categories', data);
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Update an existing list category
|
|
75
|
+
*/
|
|
76
|
+
async updateListCategory(id, data) {
|
|
77
|
+
return this.updateResource(`/list_categories/${id}`, data);
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Delete a list category
|
|
81
|
+
*/
|
|
82
|
+
async deleteListCategory(id) {
|
|
83
|
+
return this.deleteResource(`/list_categories/${id}`);
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Get people in a list (via the people relationship)
|
|
87
|
+
*/
|
|
88
|
+
async getPeople(listId) {
|
|
89
|
+
return this.getList(`/lists/${listId}/people`);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
exports.ListsModule = ListsModule;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* v2.0.0 Notes Module
|
|
3
|
+
*/
|
|
4
|
+
import { BaseModule } from './base';
|
|
5
|
+
import type { PaginationOptions, PaginationResult } from '../core/pagination';
|
|
6
|
+
import type { NoteResource, NoteAttributes, NoteCategoryResource, NoteCategoryAttributes } from '../types';
|
|
7
|
+
export interface NotesListOptions {
|
|
8
|
+
where?: Record<string, any>;
|
|
9
|
+
include?: string[];
|
|
10
|
+
perPage?: number;
|
|
11
|
+
page?: number;
|
|
12
|
+
}
|
|
13
|
+
export declare class NotesModule extends BaseModule {
|
|
14
|
+
/**
|
|
15
|
+
* Get all notes
|
|
16
|
+
*/
|
|
17
|
+
getAll(options?: NotesListOptions): Promise<{
|
|
18
|
+
data: NoteResource[];
|
|
19
|
+
meta?: any;
|
|
20
|
+
links?: any;
|
|
21
|
+
}>;
|
|
22
|
+
/**
|
|
23
|
+
* Get all notes across all pages
|
|
24
|
+
*/
|
|
25
|
+
getAllPagesPaginated(options?: NotesListOptions, paginationOptions?: PaginationOptions): Promise<PaginationResult<NoteResource>>;
|
|
26
|
+
/**
|
|
27
|
+
* Get a single note by ID
|
|
28
|
+
*/
|
|
29
|
+
getById(id: string, include?: string[]): Promise<NoteResource>;
|
|
30
|
+
/**
|
|
31
|
+
* Get notes for a specific person
|
|
32
|
+
*/
|
|
33
|
+
getNotesForPerson(personId: string, options?: NotesListOptions): Promise<{
|
|
34
|
+
data: NoteResource[];
|
|
35
|
+
meta?: any;
|
|
36
|
+
links?: any;
|
|
37
|
+
}>;
|
|
38
|
+
/**
|
|
39
|
+
* Create a note for a person
|
|
40
|
+
*/
|
|
41
|
+
create(personId: string, data: NoteAttributes): Promise<NoteResource>;
|
|
42
|
+
/**
|
|
43
|
+
* Update a note
|
|
44
|
+
*/
|
|
45
|
+
update(id: string, data: Partial<NoteAttributes>): Promise<NoteResource>;
|
|
46
|
+
/**
|
|
47
|
+
* Delete a note
|
|
48
|
+
*/
|
|
49
|
+
delete(id: string): Promise<void>;
|
|
50
|
+
/**
|
|
51
|
+
* Get all note categories
|
|
52
|
+
*/
|
|
53
|
+
getNoteCategories(): Promise<{
|
|
54
|
+
data: NoteCategoryResource[];
|
|
55
|
+
meta?: any;
|
|
56
|
+
links?: any;
|
|
57
|
+
}>;
|
|
58
|
+
/**
|
|
59
|
+
* Get a single note category by ID
|
|
60
|
+
*/
|
|
61
|
+
getNoteCategoryById(id: string): Promise<NoteCategoryResource>;
|
|
62
|
+
/**
|
|
63
|
+
* Create a note category
|
|
64
|
+
*/
|
|
65
|
+
createNoteCategory(data: NoteCategoryAttributes): Promise<NoteCategoryResource>;
|
|
66
|
+
/**
|
|
67
|
+
* Update a note category
|
|
68
|
+
*/
|
|
69
|
+
updateNoteCategory(id: string, data: Partial<NoteCategoryAttributes>): Promise<NoteCategoryResource>;
|
|
70
|
+
/**
|
|
71
|
+
* Delete a note category
|
|
72
|
+
*/
|
|
73
|
+
deleteNoteCategory(id: string): Promise<void>;
|
|
74
|
+
}
|