@rachelallyson/planning-center-people-ts 1.1.0 → 2.1.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 (56) hide show
  1. package/CHANGELOG.md +181 -0
  2. package/README.md +16 -0
  3. package/dist/batch.d.ts +47 -0
  4. package/dist/batch.js +376 -0
  5. package/dist/client-manager.d.ts +66 -0
  6. package/dist/client-manager.js +156 -0
  7. package/dist/client.d.ts +71 -0
  8. package/dist/client.js +123 -0
  9. package/dist/core/http.d.ts +48 -0
  10. package/dist/core/http.js +265 -0
  11. package/dist/core/pagination.d.ts +34 -0
  12. package/dist/core/pagination.js +164 -0
  13. package/dist/index.d.ts +13 -3
  14. package/dist/index.js +23 -5
  15. package/dist/matching/matcher.d.ts +41 -0
  16. package/dist/matching/matcher.js +161 -0
  17. package/dist/matching/scoring.d.ts +35 -0
  18. package/dist/matching/scoring.js +141 -0
  19. package/dist/matching/strategies.d.ts +35 -0
  20. package/dist/matching/strategies.js +79 -0
  21. package/dist/modules/base.d.ts +46 -0
  22. package/dist/modules/base.js +82 -0
  23. package/dist/modules/contacts.d.ts +103 -0
  24. package/dist/modules/contacts.js +130 -0
  25. package/dist/modules/fields.d.ts +157 -0
  26. package/dist/modules/fields.js +294 -0
  27. package/dist/modules/households.d.ts +42 -0
  28. package/dist/modules/households.js +74 -0
  29. package/dist/modules/lists.d.ts +62 -0
  30. package/dist/modules/lists.js +92 -0
  31. package/dist/modules/notes.d.ts +74 -0
  32. package/dist/modules/notes.js +125 -0
  33. package/dist/modules/people.d.ts +196 -0
  34. package/dist/modules/people.js +221 -0
  35. package/dist/modules/workflows.d.ts +131 -0
  36. package/dist/modules/workflows.js +221 -0
  37. package/dist/monitoring.d.ts +53 -0
  38. package/dist/monitoring.js +142 -0
  39. package/dist/testing/index.d.ts +9 -0
  40. package/dist/testing/index.js +24 -0
  41. package/dist/testing/recorder.d.ts +58 -0
  42. package/dist/testing/recorder.js +195 -0
  43. package/dist/testing/simple-builders.d.ts +33 -0
  44. package/dist/testing/simple-builders.js +124 -0
  45. package/dist/testing/simple-factories.d.ts +91 -0
  46. package/dist/testing/simple-factories.js +288 -0
  47. package/dist/testing/types.d.ts +160 -0
  48. package/dist/testing/types.js +5 -0
  49. package/dist/types/batch.d.ts +50 -0
  50. package/dist/types/batch.js +5 -0
  51. package/dist/types/client.d.ts +89 -0
  52. package/dist/types/client.js +5 -0
  53. package/dist/types/events.d.ts +85 -0
  54. package/dist/types/events.js +5 -0
  55. package/dist/types/people.d.ts +20 -1
  56. package/package.json +9 -3
@@ -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
+ }
@@ -0,0 +1,125 @@
1
+ "use strict";
2
+ /**
3
+ * v2.0.0 Notes Module
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.NotesModule = void 0;
7
+ const base_1 = require("./base");
8
+ class NotesModule extends base_1.BaseModule {
9
+ /**
10
+ * Get all notes
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('/notes', params);
29
+ }
30
+ /**
31
+ * Get all notes 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('/notes', params, paginationOptions);
44
+ }
45
+ /**
46
+ * Get a single note by ID
47
+ */
48
+ async getById(id, include) {
49
+ const params = {};
50
+ if (include) {
51
+ params.include = include.join(',');
52
+ }
53
+ return this.getSingle(`/notes/${id}`, params);
54
+ }
55
+ /**
56
+ * Get notes for a specific person
57
+ */
58
+ async getNotesForPerson(personId, options = {}) {
59
+ const params = {};
60
+ if (options.where) {
61
+ Object.entries(options.where).forEach(([key, value]) => {
62
+ params[`where[${key}]`] = value;
63
+ });
64
+ }
65
+ if (options.include) {
66
+ params.include = options.include.join(',');
67
+ }
68
+ if (options.perPage) {
69
+ params.per_page = options.perPage;
70
+ }
71
+ if (options.page) {
72
+ params.page = options.page;
73
+ }
74
+ return this.getList(`/people/${personId}/notes`, params);
75
+ }
76
+ /**
77
+ * Create a note for a person
78
+ */
79
+ async create(personId, data) {
80
+ return this.createResource(`/people/${personId}/notes`, data);
81
+ }
82
+ /**
83
+ * Update a note
84
+ */
85
+ async update(id, data) {
86
+ return this.updateResource(`/notes/${id}`, data);
87
+ }
88
+ /**
89
+ * Delete a note
90
+ */
91
+ async delete(id) {
92
+ return this.deleteResource(`/notes/${id}`);
93
+ }
94
+ /**
95
+ * Get all note categories
96
+ */
97
+ async getNoteCategories() {
98
+ return this.getList('/note_categories');
99
+ }
100
+ /**
101
+ * Get a single note category by ID
102
+ */
103
+ async getNoteCategoryById(id) {
104
+ return this.getSingle(`/note_categories/${id}`);
105
+ }
106
+ /**
107
+ * Create a note category
108
+ */
109
+ async createNoteCategory(data) {
110
+ return this.createResource('/note_categories', data);
111
+ }
112
+ /**
113
+ * Update a note category
114
+ */
115
+ async updateNoteCategory(id, data) {
116
+ return this.updateResource(`/note_categories/${id}`, data);
117
+ }
118
+ /**
119
+ * Delete a note category
120
+ */
121
+ async deleteNoteCategory(id) {
122
+ return this.deleteResource(`/note_categories/${id}`);
123
+ }
124
+ }
125
+ exports.NotesModule = NotesModule;
@@ -0,0 +1,196 @@
1
+ /**
2
+ * v2.0.0 People Module
3
+ */
4
+ import { BaseModule } from './base';
5
+ import type { PcoHttpClient } from '../core/http';
6
+ import type { PaginationHelper } from '../core/pagination';
7
+ import type { PcoEventEmitter } from '../monitoring';
8
+ import type { PaginationOptions, PaginationResult } from '../core/pagination';
9
+ import type { PersonResource, EmailResource, EmailAttributes, PhoneNumberResource, PhoneNumberAttributes, AddressResource, AddressAttributes, SocialProfileResource, SocialProfileAttributes } from '../types';
10
+ export interface PeopleListOptions {
11
+ where?: Record<string, any>;
12
+ include?: string[];
13
+ perPage?: number;
14
+ page?: number;
15
+ }
16
+ export interface PersonCreateOptions {
17
+ firstName?: string;
18
+ lastName?: string;
19
+ givenName?: string;
20
+ middleName?: string;
21
+ nickname?: string;
22
+ birthdate?: string;
23
+ anniversary?: string;
24
+ gender?: string;
25
+ grade?: string;
26
+ child?: boolean;
27
+ status?: string;
28
+ medicalNotes?: string;
29
+ jobTitle?: string;
30
+ employer?: string;
31
+ school?: string;
32
+ graduationYear?: string;
33
+ avatar?: string;
34
+ siteAdministrator?: boolean;
35
+ accountingAdministrator?: boolean;
36
+ peoplePermissions?: string;
37
+ directoryStatus?: string;
38
+ loginIdentifier?: string;
39
+ membership?: string;
40
+ remoteId?: string;
41
+ demographicAvatarUrl?: string;
42
+ inactivatedAt?: string;
43
+ resourcePermissionFlags?: Record<string, boolean>;
44
+ }
45
+ export interface PersonMatchOptions {
46
+ firstName?: string;
47
+ lastName?: string;
48
+ email?: string;
49
+ phone?: string;
50
+ matchStrategy?: 'exact' | 'fuzzy' | 'aggressive';
51
+ campus?: string;
52
+ createIfNotFound?: boolean;
53
+ }
54
+ export declare class PeopleModule extends BaseModule {
55
+ private personMatcher;
56
+ constructor(httpClient: PcoHttpClient, paginationHelper: PaginationHelper, eventEmitter: PcoEventEmitter);
57
+ /**
58
+ * Get all people with optional filtering
59
+ */
60
+ getAll(options?: PeopleListOptions): Promise<{
61
+ data: PersonResource[];
62
+ meta?: any;
63
+ links?: any;
64
+ }>;
65
+ /**
66
+ * Get all people across all pages
67
+ */
68
+ getAllPagesPaginated(options?: PeopleListOptions, paginationOptions?: PaginationOptions): Promise<PaginationResult<PersonResource>>;
69
+ /**
70
+ * Get a single person by ID
71
+ */
72
+ getById(id: string, include?: string[]): Promise<PersonResource>;
73
+ /**
74
+ * Create a new person
75
+ */
76
+ create(data: PersonCreateOptions): Promise<PersonResource>;
77
+ /**
78
+ * Update a person
79
+ */
80
+ update(id: string, data: Partial<PersonCreateOptions>): Promise<PersonResource>;
81
+ /**
82
+ * Delete a person
83
+ */
84
+ delete(id: string): Promise<void>;
85
+ /**
86
+ * Find or create a person with smart matching
87
+ */
88
+ findOrCreate(options: PersonMatchOptions): Promise<PersonResource>;
89
+ /**
90
+ * Search people by multiple criteria
91
+ */
92
+ search(criteria: {
93
+ name?: string;
94
+ email?: string;
95
+ phone?: string;
96
+ status?: string;
97
+ perPage?: number;
98
+ }): Promise<{
99
+ data: PersonResource[];
100
+ meta?: any;
101
+ links?: any;
102
+ }>;
103
+ /**
104
+ * Get person's emails
105
+ */
106
+ getEmails(personId: string): Promise<{
107
+ data: EmailResource[];
108
+ meta?: any;
109
+ links?: any;
110
+ }>;
111
+ /**
112
+ * Add an email to a person
113
+ */
114
+ addEmail(personId: string, data: EmailAttributes): Promise<EmailResource>;
115
+ /**
116
+ * Update a person's email
117
+ */
118
+ updateEmail(personId: string, emailId: string, data: Partial<EmailAttributes>): Promise<EmailResource>;
119
+ /**
120
+ * Delete a person's email
121
+ */
122
+ deleteEmail(personId: string, emailId: string): Promise<void>;
123
+ /**
124
+ * Get person's phone numbers
125
+ */
126
+ getPhoneNumbers(personId: string): Promise<{
127
+ data: PhoneNumberResource[];
128
+ meta?: any;
129
+ links?: any;
130
+ }>;
131
+ /**
132
+ * Add a phone number to a person
133
+ */
134
+ addPhoneNumber(personId: string, data: PhoneNumberAttributes): Promise<PhoneNumberResource>;
135
+ /**
136
+ * Update a person's phone number
137
+ */
138
+ updatePhoneNumber(personId: string, phoneId: string, data: Partial<PhoneNumberAttributes>): Promise<PhoneNumberResource>;
139
+ /**
140
+ * Delete a person's phone number
141
+ */
142
+ deletePhoneNumber(personId: string, phoneId: string): Promise<void>;
143
+ /**
144
+ * Get person's addresses
145
+ */
146
+ getAddresses(personId: string): Promise<{
147
+ data: AddressResource[];
148
+ meta?: any;
149
+ links?: any;
150
+ }>;
151
+ /**
152
+ * Add an address to a person
153
+ */
154
+ addAddress(personId: string, data: AddressAttributes): Promise<AddressResource>;
155
+ /**
156
+ * Update a person's address
157
+ */
158
+ updateAddress(personId: string, addressId: string, data: Partial<AddressAttributes>): Promise<AddressResource>;
159
+ /**
160
+ * Delete a person's address
161
+ */
162
+ deleteAddress(personId: string, addressId: string): Promise<void>;
163
+ /**
164
+ * Get person's social profiles
165
+ */
166
+ getSocialProfiles(personId: string): Promise<{
167
+ data: SocialProfileResource[];
168
+ meta?: any;
169
+ links?: any;
170
+ }>;
171
+ /**
172
+ * Add a social profile to a person
173
+ */
174
+ addSocialProfile(personId: string, data: SocialProfileAttributes): Promise<SocialProfileResource>;
175
+ /**
176
+ * Update a person's social profile
177
+ */
178
+ updateSocialProfile(personId: string, profileId: string, data: Partial<SocialProfileAttributes>): Promise<SocialProfileResource>;
179
+ /**
180
+ * Delete a person's social profile
181
+ */
182
+ deleteSocialProfile(personId: string, profileId: string): Promise<void>;
183
+ /**
184
+ * Create a person with contact information
185
+ */
186
+ createWithContacts(personData: PersonCreateOptions, contacts?: {
187
+ email?: EmailAttributes;
188
+ phone?: PhoneNumberAttributes;
189
+ address?: AddressAttributes;
190
+ }): Promise<{
191
+ person: PersonResource;
192
+ email?: EmailResource;
193
+ phone?: PhoneNumberResource;
194
+ address?: AddressResource;
195
+ }>;
196
+ }