@rachelallyson/planning-center-people-ts 2.14.1 → 3.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 (77) hide show
  1. package/CHANGELOG.md +82 -7
  2. package/README.md +42 -4
  3. package/dist/auth.d.ts +1 -1
  4. package/dist/auth.js +14 -6
  5. package/dist/client.d.ts +33 -8
  6. package/dist/client.js +47 -22
  7. package/dist/core.d.ts +4 -2
  8. package/dist/core.js +3 -2
  9. package/dist/error-handling.d.ts +4 -4
  10. package/dist/error-handling.js +13 -2
  11. package/dist/error-scenarios.d.ts +11 -7
  12. package/dist/error-scenarios.js +26 -10
  13. package/dist/helpers.d.ts +124 -48
  14. package/dist/helpers.js +237 -93
  15. package/dist/index.d.ts +10 -8
  16. package/dist/index.js +31 -72
  17. package/dist/matching/matcher.d.ts +8 -4
  18. package/dist/matching/matcher.js +51 -58
  19. package/dist/matching/scoring.d.ts +9 -6
  20. package/dist/matching/scoring.js +18 -14
  21. package/dist/modules/campus.d.ts +31 -36
  22. package/dist/modules/campus.js +36 -49
  23. package/dist/modules/contacts.d.ts +33 -29
  24. package/dist/modules/contacts.js +36 -12
  25. package/dist/modules/fields.d.ts +39 -55
  26. package/dist/modules/fields.js +65 -105
  27. package/dist/modules/forms.d.ts +35 -24
  28. package/dist/modules/forms.js +41 -23
  29. package/dist/modules/households.d.ts +17 -19
  30. package/dist/modules/households.js +25 -34
  31. package/dist/modules/lists.d.ts +38 -28
  32. package/dist/modules/lists.js +62 -42
  33. package/dist/modules/notes.d.ts +32 -30
  34. package/dist/modules/notes.js +40 -52
  35. package/dist/modules/people.d.ts +83 -71
  36. package/dist/modules/people.js +323 -172
  37. package/dist/modules/reports.d.ts +18 -32
  38. package/dist/modules/reports.js +28 -40
  39. package/dist/modules/service-time.d.ts +19 -24
  40. package/dist/modules/service-time.js +28 -28
  41. package/dist/modules/workflows.d.ts +42 -47
  42. package/dist/modules/workflows.js +52 -53
  43. package/dist/performance.d.ts +14 -10
  44. package/dist/performance.js +61 -25
  45. package/dist/testing/recorder.js +11 -2
  46. package/dist/testing/simple-builders.d.ts +6 -4
  47. package/dist/testing/simple-builders.js +36 -49
  48. package/dist/testing/types.d.ts +4 -0
  49. package/dist/types/api-options.d.ts +380 -0
  50. package/dist/types/api-options.js +6 -0
  51. package/dist/types/client.d.ts +4 -2
  52. package/dist/types/client.js +1 -1
  53. package/dist/types/index.d.ts +1 -1
  54. package/dist/types/people.d.ts +61 -9
  55. package/package.json +7 -7
  56. package/dist/core/http.d.ts +0 -56
  57. package/dist/core/http.js +0 -360
  58. package/dist/core/pagination.d.ts +0 -34
  59. package/dist/core/pagination.js +0 -178
  60. package/dist/people/contacts.d.ts +0 -43
  61. package/dist/people/contacts.js +0 -122
  62. package/dist/people/core.d.ts +0 -28
  63. package/dist/people/core.js +0 -69
  64. package/dist/people/fields.d.ts +0 -68
  65. package/dist/people/fields.js +0 -305
  66. package/dist/people/households.d.ts +0 -15
  67. package/dist/people/households.js +0 -31
  68. package/dist/people/index.d.ts +0 -8
  69. package/dist/people/index.js +0 -25
  70. package/dist/people/lists.d.ts +0 -34
  71. package/dist/people/lists.js +0 -48
  72. package/dist/people/notes.d.ts +0 -30
  73. package/dist/people/notes.js +0 -37
  74. package/dist/people/organization.d.ts +0 -12
  75. package/dist/people/organization.js +0 -15
  76. package/dist/people/workflows.d.ts +0 -37
  77. package/dist/people/workflows.js +0 -75
@@ -10,71 +10,89 @@ const planning_center_base_ts_1 = require("@rachelallyson/planning-center-base-t
10
10
  * Most operations are read-only based on API documentation
11
11
  */
12
12
  class FormsModule extends planning_center_base_ts_1.BaseModule {
13
- constructor(httpClient, paginationHelper, eventEmitter) {
14
- super(httpClient, paginationHelper, eventEmitter);
15
- }
16
13
  /**
17
- * Get all forms
14
+ * Get all forms across all pages
18
15
  */
19
16
  async getAll(params) {
20
- return this.getList('/forms', params);
17
+ this.debugLog('forms.getAll', { params });
18
+ return this.getAllPages('/forms', {
19
+ where: params?.where,
20
+ include: params?.include,
21
+ order: params?.order
22
+ });
23
+ }
24
+ /**
25
+ * Get a single page of forms with optional filtering and pagination control
26
+ * Use this when you need a specific page or want to limit the number of results
27
+ * @param params - List parameters including where, include, perPage, page, and order
28
+ * @returns A single page of results with meta and links for pagination
29
+ */
30
+ async getPage(params) {
31
+ this.debugLog('forms.getPage', { params });
32
+ return this.getList('/forms', {
33
+ where: params?.where,
34
+ include: params?.include,
35
+ per_page: params?.perPage,
36
+ page: params?.page,
37
+ order: params?.order
38
+ });
21
39
  }
22
40
  /**
23
41
  * Get a specific form by ID
24
42
  */
25
43
  async getById(id, include) {
26
- const params = {};
27
- if (include) {
28
- params.include = include.join(',');
29
- }
30
- return this.getSingle(`/forms/${id}`, params);
44
+ this.debugLog('forms.getById', { id, include });
45
+ return this.getSingle(`/forms/${id}`, include);
31
46
  }
32
47
  /**
33
48
  * Get form category for a specific form
34
49
  */
35
50
  async getFormCategory(formId) {
51
+ this.debugLog('forms.getFormCategory', { formId });
36
52
  return this.getSingle(`/forms/${formId}/category`);
37
53
  }
38
54
  /**
39
55
  * Get form fields for a specific form
40
56
  */
41
57
  async getFormFields(formId, params) {
42
- const result = await this.getList(`/forms/${formId}/fields`, params);
43
- return { data: result.data };
58
+ this.debugLog('forms.getFormFields', { formId, params });
59
+ return await this.getList(`/forms/${formId}/fields`, {
60
+ where: params?.where,
61
+ include: params?.include,
62
+ per_page: params?.perPage,
63
+ page: params?.page
64
+ });
44
65
  }
45
66
  /**
46
67
  * Get form field options for a specific form field
47
68
  * Note: This requires the formId to get field options
48
69
  */
49
70
  async getFormFieldOptions(formId, formFieldId, params) {
50
- const result = await this.getList(`/forms/${formId}/fields/${formFieldId}/options`, params);
51
- return { data: result.data };
71
+ this.debugLog('forms.getFormFieldOptions', { formId, formFieldId, params });
72
+ return await this.getList(`/forms/${formId}/fields/${formFieldId}/options`, params);
52
73
  }
53
74
  /**
54
75
  * Get form submissions for a specific form
55
76
  */
56
77
  async getFormSubmissions(formId, params) {
57
- const result = await this.getList(`/forms/${formId}/form_submissions`, params);
58
- return { data: result.data };
78
+ this.debugLog('forms.getFormSubmissions', { formId, params });
79
+ return await this.getList(`/forms/${formId}/form_submissions`, params);
59
80
  }
60
81
  /**
61
82
  * Get a specific form submission by ID
62
83
  * Note: This requires the formId to get the submission
63
84
  */
64
85
  async getFormSubmissionById(formId, formSubmissionId, include) {
65
- const params = {};
66
- if (include) {
67
- params.include = include.join(',');
68
- }
69
- return this.getSingle(`/forms/${formId}/form_submissions/${formSubmissionId}`, params);
86
+ this.debugLog('forms.getFormSubmissionById', { formId, formSubmissionId, include });
87
+ return this.getSingle(`/forms/${formId}/form_submissions/${formSubmissionId}`, include);
70
88
  }
71
89
  /**
72
90
  * Get form submission values for a specific form submission
73
91
  * Note: This requires the formId to get submission values
74
92
  */
75
93
  async getFormSubmissionValues(formId, formSubmissionId, params) {
76
- const result = await this.getList(`/forms/${formId}/form_submissions/${formSubmissionId}/form_submission_values`, params);
77
- return { data: result.data };
94
+ this.debugLog('forms.getFormSubmissionValues', { formId, formSubmissionId, params });
95
+ return await this.getList(`/forms/${formId}/form_submissions/${formSubmissionId}/form_submission_values`, params);
78
96
  }
79
97
  }
80
98
  exports.FormsModule = FormsModule;
@@ -2,39 +2,37 @@
2
2
  * v2.0.0 Households Module
3
3
  */
4
4
  import { BaseModule } from '@rachelallyson/planning-center-base-ts';
5
- import type { PaginationOptions, PaginationResult } from '@rachelallyson/planning-center-base-ts';
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
- }
5
+ import type { HouseholdResource, HouseholdAttributes, Meta, TopLevelLinks } from '../types';
6
+ import type { HouseholdListOptions, HouseholdPageOptions } from '../types/api-options';
7
+ export type { HouseholdListOptions };
13
8
  export declare class HouseholdsModule extends BaseModule {
14
9
  /**
15
- * Get all households
10
+ * Get all households across all pages
16
11
  */
17
- getAll(options?: HouseholdListOptions): Promise<{
18
- data: HouseholdResource[];
19
- meta?: any;
20
- links?: any;
21
- }>;
12
+ getAll(options?: HouseholdListOptions): Promise<import("@rachelallyson/planning-center-base-ts").PaginationResult<HouseholdResource, import("@rachelallyson/planning-center-base-ts").ResourceObject<string, any, any>, Record<string, never>>>;
22
13
  /**
23
- * Get all households across all pages
14
+ * Get a single page of households with optional filtering and pagination control
15
+ * Use this when you need a specific page or want to limit the number of results
16
+ * @param options - List options including where, include, perPage, page, and order
17
+ * @returns A single page of results with meta and links for pagination
24
18
  */
25
- getAllPagesPaginated(options?: HouseholdListOptions, paginationOptions?: PaginationOptions): Promise<PaginationResult<HouseholdResource>>;
19
+ getPage(options?: HouseholdPageOptions): Promise<{
20
+ data: import("@rachelallyson/planning-center-base-ts").FlattenedResource<"Household", HouseholdAttributes, import("../types").HouseholdRelationships, Record<string, never>>[];
21
+ meta?: Meta;
22
+ links?: TopLevelLinks;
23
+ }>;
26
24
  /**
27
25
  * Get a single household by ID
28
26
  */
29
- getById(id: string, include?: string[]): Promise<HouseholdResource>;
27
+ getById(id: string, include?: string[]): Promise<import("@rachelallyson/planning-center-base-ts").FlattenedResource<"Household", HouseholdAttributes, import("../types").HouseholdRelationships>>;
30
28
  /**
31
29
  * Create a household
32
30
  */
33
- create(data: HouseholdAttributes): Promise<HouseholdResource>;
31
+ create(data: HouseholdAttributes): Promise<import("@rachelallyson/planning-center-base-ts").FlattenedResource<"Household", HouseholdAttributes, import("../types").HouseholdRelationships>>;
34
32
  /**
35
33
  * Update a household
36
34
  */
37
- update(id: string, data: Partial<HouseholdAttributes>): Promise<HouseholdResource>;
35
+ update(id: string, data: Partial<HouseholdAttributes>): Promise<import("@rachelallyson/planning-center-base-ts").FlattenedResource<"Household", HouseholdAttributes, import("../types").HouseholdRelationships>>;
38
36
  /**
39
37
  * Delete a household
40
38
  */
@@ -7,67 +7,58 @@ exports.HouseholdsModule = void 0;
7
7
  const planning_center_base_ts_1 = require("@rachelallyson/planning-center-base-ts");
8
8
  class HouseholdsModule extends planning_center_base_ts_1.BaseModule {
9
9
  /**
10
- * Get all households
10
+ * Get all households across all pages
11
11
  */
12
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);
13
+ this.debugLog('households.getAll', { options });
14
+ return await this.getAllPages('/households', {
15
+ where: options.where,
16
+ include: options.include,
17
+ order: options.order
18
+ });
29
19
  }
30
20
  /**
31
- * Get all households across all pages
21
+ * Get a single page of households with optional filtering and pagination control
22
+ * Use this when you need a specific page or want to limit the number of results
23
+ * @param options - List options including where, include, perPage, page, and order
24
+ * @returns A single page of results with meta and links for pagination
32
25
  */
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);
26
+ async getPage(options = {}) {
27
+ this.debugLog('households.getPage', { options });
28
+ return this.getList('/households', {
29
+ where: options.where,
30
+ include: options.include,
31
+ per_page: options.perPage,
32
+ page: options.page,
33
+ order: options.order
34
+ });
44
35
  }
45
36
  /**
46
37
  * Get a single household by ID
47
38
  */
48
39
  async getById(id, include) {
49
- const params = {};
50
- if (include) {
51
- params.include = include.join(',');
52
- }
53
- return this.getSingle(`/households/${id}`, params);
40
+ this.debugLog('households.getById', { id, include });
41
+ return this.getSingle(`/households/${id}`, include);
54
42
  }
55
43
  /**
56
44
  * Create a household
57
45
  */
58
46
  async create(data) {
47
+ this.debugLog('households.create', { data });
59
48
  return this.createResource('/households', data);
60
49
  }
61
50
  /**
62
51
  * Update a household
63
52
  */
64
53
  async update(id, data) {
54
+ this.debugLog('households.update', { id, data });
65
55
  return this.updateResource(`/households/${id}`, data);
66
56
  }
67
57
  /**
68
58
  * Delete a household
69
59
  */
70
60
  async delete(id) {
61
+ this.debugLog('households.delete', { id });
71
62
  return this.deleteResource(`/households/${id}`);
72
63
  }
73
64
  }
@@ -2,51 +2,53 @@
2
2
  * v2.0.0 Lists Module
3
3
  */
4
4
  import { BaseModule } from '@rachelallyson/planning-center-base-ts';
5
- import type { PaginationOptions, PaginationResult } from '@rachelallyson/planning-center-base-ts';
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
- }
5
+ import type { ListResource, ListAttributes, ListCategoryAttributes, Meta, TopLevelLinks } from '../types';
6
+ import type { ListListOptions, ListPageOptions } from '../types/api-options';
7
+ export type ListsListOptions = ListListOptions;
13
8
  export declare class ListsModule extends BaseModule {
14
9
  /**
15
- * Get all lists
10
+ * Get all lists across all pages
16
11
  */
17
- getAll(options?: ListsListOptions): Promise<{
18
- data: ListResource[];
19
- meta?: any;
20
- links?: any;
21
- }>;
12
+ getAll(options?: ListsListOptions): Promise<import("@rachelallyson/planning-center-base-ts").PaginationResult<ListResource, import("@rachelallyson/planning-center-base-ts").ResourceObject<string, any, any>, Record<string, never>>>;
22
13
  /**
23
- * Get all lists across all pages
14
+ * Get a single page of lists with optional filtering and pagination control
15
+ * Use this when you need a specific page or want to limit the number of results
16
+ * @param options - List options including where, include, perPage, page, and order
17
+ * @returns A single page of results with meta and links for pagination
24
18
  */
25
- getAllPagesPaginated(options?: ListsListOptions, paginationOptions?: PaginationOptions): Promise<PaginationResult<ListResource>>;
19
+ getPage(options?: ListPageOptions): Promise<{
20
+ data: import("@rachelallyson/planning-center-base-ts").FlattenedResource<"List", ListAttributes, {}, Record<string, never>>[];
21
+ meta?: Meta;
22
+ links?: TopLevelLinks;
23
+ }>;
26
24
  /**
27
25
  * Get a single list by ID
28
26
  */
29
- getById(id: string, include?: string[]): Promise<ListResource>;
27
+ getById(id: string, include?: string[]): Promise<import("@rachelallyson/planning-center-base-ts").FlattenedResource<"List", ListAttributes, {}>>;
30
28
  /**
31
29
  * Get all list categories
30
+ * @param options - Optional pagination options
32
31
  */
33
- getListCategories(): Promise<{
34
- data: ListCategoryResource[];
35
- meta?: any;
36
- links?: any;
32
+ getListCategories(options?: {
33
+ perPage?: number;
34
+ page?: number;
35
+ }): Promise<{
36
+ data: import("@rachelallyson/planning-center-base-ts").FlattenedResource<"ListCategory", ListCategoryAttributes, import("../types").ListCategoryRelationships, Record<string, never>>[];
37
+ meta?: Meta;
38
+ links?: TopLevelLinks;
37
39
  }>;
38
40
  /**
39
41
  * Get a single list category by ID
40
42
  */
41
- getListCategoryById(id: string): Promise<ListCategoryResource>;
43
+ getListCategoryById(id: string): Promise<import("@rachelallyson/planning-center-base-ts").FlattenedResource<"ListCategory", ListCategoryAttributes, import("../types").ListCategoryRelationships>>;
42
44
  /**
43
45
  * Create a new list category
44
46
  */
45
- createListCategory(data: ListCategoryAttributes): Promise<ListCategoryResource>;
47
+ createListCategory(data: Partial<ListCategoryAttributes>): Promise<import("@rachelallyson/planning-center-base-ts").FlattenedResource<"ListCategory", ListCategoryAttributes, import("../types").ListCategoryRelationships>>;
46
48
  /**
47
49
  * Update an existing list category
48
50
  */
49
- updateListCategory(id: string, data: Partial<ListCategoryAttributes>): Promise<ListCategoryResource>;
51
+ updateListCategory(id: string, data: Partial<ListCategoryAttributes>): Promise<import("@rachelallyson/planning-center-base-ts").FlattenedResource<"ListCategory", ListCategoryAttributes, import("../types").ListCategoryRelationships>>;
50
52
  /**
51
53
  * Delete a list category
52
54
  */
@@ -55,12 +57,20 @@ export declare class ListsModule extends BaseModule {
55
57
  * Get people in a list (via the people relationship)
56
58
  */
57
59
  getPeople(listId: string): Promise<{
58
- data: PersonResource[];
59
- meta?: any;
60
- links?: any;
60
+ data: import("@rachelallyson/planning-center-base-ts").FlattenedResource<"Person", import("../types").PersonAttributes, import("../types").PersonRelationships, Record<string, never>>[];
61
+ meta?: Meta;
62
+ links?: TopLevelLinks;
63
+ }>;
64
+ /**
65
+ * Get rules for a list (GET /people/v2/lists/:id/rules)
66
+ */
67
+ getRules(listId: string): Promise<{
68
+ data: import("@rachelallyson/planning-center-base-ts").FlattenedResource<"Rule", import("../types").ListRuleAttributes, import("../types").ListRuleRelationships, Record<string, never>>[];
69
+ meta?: Meta;
70
+ links?: TopLevelLinks;
61
71
  }>;
62
72
  /**
63
73
  * Run a List to update its results
64
74
  */
65
- run(listId: string): Promise<ListResource>;
75
+ refresh(listId: string): Promise<ListResource | import("@rachelallyson/planning-center-base-ts").FlattenedResource<"List", ListAttributes, {}>>;
66
76
  }
@@ -7,56 +7,49 @@ exports.ListsModule = void 0;
7
7
  const planning_center_base_ts_1 = require("@rachelallyson/planning-center-base-ts");
8
8
  class ListsModule extends planning_center_base_ts_1.BaseModule {
9
9
  /**
10
- * Get all lists
10
+ * Get all lists across all pages
11
11
  */
12
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);
13
+ this.debugLog('lists.getAll', { options });
14
+ return await this.getAllPages('/lists', {
15
+ where: options.where,
16
+ include: options.include,
17
+ order: options.order
18
+ });
29
19
  }
30
20
  /**
31
- * Get all lists across all pages
21
+ * Get a single page of lists with optional filtering and pagination control
22
+ * Use this when you need a specific page or want to limit the number of results
23
+ * @param options - List options including where, include, perPage, page, and order
24
+ * @returns A single page of results with meta and links for pagination
32
25
  */
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);
26
+ async getPage(options = {}) {
27
+ this.debugLog('lists.getPage', { options });
28
+ return this.getList('/lists', {
29
+ where: options.where,
30
+ include: options.include,
31
+ per_page: options.perPage,
32
+ page: options.page,
33
+ order: options.order
34
+ });
44
35
  }
45
36
  /**
46
37
  * Get a single list by ID
47
38
  */
48
39
  async getById(id, include) {
49
- const params = {};
50
- if (include) {
51
- params.include = include.join(',');
52
- }
53
- return this.getSingle(`/lists/${id}`, params);
40
+ this.debugLog('lists.getById', { id, include });
41
+ return this.getSingle(`/lists/${id}`, include);
54
42
  }
55
43
  /**
56
44
  * Get all list categories
45
+ * @param options - Optional pagination options
57
46
  */
58
- async getListCategories() {
59
- return this.getList('/list_categories');
47
+ async getListCategories(options) {
48
+ this.debugLog('lists.getListCategories', { options });
49
+ return this.getList('/list_categories', options ? {
50
+ per_page: options.perPage,
51
+ page: options.page,
52
+ } : undefined);
60
53
  }
61
54
  /**
62
55
  * Get a single list category by ID
@@ -88,15 +81,42 @@ class ListsModule extends planning_center_base_ts_1.BaseModule {
88
81
  async getPeople(listId) {
89
82
  return this.getList(`/lists/${listId}/people`);
90
83
  }
84
+ /**
85
+ * Get rules for a list (GET /people/v2/lists/:id/rules)
86
+ */
87
+ async getRules(listId) {
88
+ this.debugLog('lists.getRules', { listId });
89
+ return this.getList(`/lists/${listId}/rules`);
90
+ }
91
91
  /**
92
92
  * Run a List to update its results
93
93
  */
94
- async run(listId) {
95
- const response = await this.httpClient.request({
96
- method: 'POST',
97
- endpoint: `/lists/${listId}/run`,
98
- });
99
- return response.data.data;
94
+ async refresh(listId) {
95
+ this.debugLog('lists.refresh', { listId });
96
+ try {
97
+ const response = await this.httpClient.request({
98
+ method: 'POST',
99
+ endpoint: `/lists/${listId}/run`,
100
+ });
101
+ // If response has data, return it; otherwise return the list by ID
102
+ if (response.data?.data) {
103
+ return response.data.data;
104
+ }
105
+ // If no data in response (204 No Content or empty response), return the list itself
106
+ return this.getById(listId);
107
+ }
108
+ catch (error) {
109
+ // The run endpoint may return an empty response (204 No Content)
110
+ // If we get a JSON parse error, try to get the list by ID instead
111
+ if (error && typeof error === 'object' && 'message' in error) {
112
+ const errorMessage = error?.message;
113
+ if (typeof errorMessage === 'string' && (errorMessage.includes('JSON') || errorMessage.includes('Unexpected end'))) {
114
+ // Return the list itself as the result
115
+ return this.getById(listId);
116
+ }
117
+ }
118
+ throw error;
119
+ }
100
120
  }
101
121
  }
102
122
  exports.ListsModule = ListsModule;
@@ -2,71 +2,73 @@
2
2
  * v2.0.0 Notes Module
3
3
  */
4
4
  import { BaseModule } from '@rachelallyson/planning-center-base-ts';
5
- import type { PaginationOptions, PaginationResult } from '@rachelallyson/planning-center-base-ts';
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
- }
5
+ import type { NoteResource, NoteAttributes, NoteCategoryAttributes, Meta, TopLevelLinks } from '../types';
6
+ import type { NoteListOptions, NotePageOptions } from '../types/api-options';
7
+ export type NotesListOptions = NoteListOptions;
13
8
  export declare class NotesModule extends BaseModule {
14
9
  /**
15
- * Get all notes
10
+ * Get all notes across all pages
16
11
  */
17
- getAll(options?: NotesListOptions): Promise<{
18
- data: NoteResource[];
19
- meta?: any;
20
- links?: any;
21
- }>;
12
+ getAll(options?: NotesListOptions): Promise<import("@rachelallyson/planning-center-base-ts").PaginationResult<NoteResource, import("@rachelallyson/planning-center-base-ts").ResourceObject<string, any, any>, Record<string, never>>>;
22
13
  /**
23
- * Get all notes across all pages
14
+ * Get a single page of notes with optional filtering and pagination control
15
+ * Use this when you need a specific page or want to limit the number of results
16
+ * @param options - List options including where, include, perPage, page, and order
17
+ * @returns A single page of results with meta and links for pagination
24
18
  */
25
- getAllPagesPaginated(options?: NotesListOptions, paginationOptions?: PaginationOptions): Promise<PaginationResult<NoteResource>>;
19
+ getPage(options?: NotePageOptions): Promise<{
20
+ data: import("@rachelallyson/planning-center-base-ts").FlattenedResource<"Note", NoteAttributes, import("../types").NoteRelationships, Record<string, never>>[];
21
+ meta?: Meta;
22
+ links?: TopLevelLinks;
23
+ }>;
26
24
  /**
27
25
  * Get a single note by ID
28
26
  */
29
- getById(id: string, include?: string[]): Promise<NoteResource>;
27
+ getById(id: string, include?: string[]): Promise<import("@rachelallyson/planning-center-base-ts").FlattenedResource<"Note", NoteAttributes, import("../types").NoteRelationships>>;
30
28
  /**
31
29
  * Get notes for a specific person
32
30
  */
33
- getNotesForPerson(personId: string, options?: NotesListOptions): Promise<{
34
- data: NoteResource[];
35
- meta?: any;
36
- links?: any;
31
+ getNotesForPerson(personId: string, options?: NotePageOptions): Promise<{
32
+ data: import("@rachelallyson/planning-center-base-ts").FlattenedResource<"Note", NoteAttributes, import("../types").NoteRelationships, Record<string, never>>[];
33
+ meta?: Meta;
34
+ links?: TopLevelLinks;
37
35
  }>;
38
36
  /**
39
37
  * Create a note for a person
40
38
  */
41
- create(personId: string, data: NoteAttributes): Promise<NoteResource>;
39
+ create(personId: string, data: NoteAttributes): Promise<import("@rachelallyson/planning-center-base-ts").FlattenedResource<"Note", NoteAttributes, import("../types").NoteRelationships>>;
42
40
  /**
43
41
  * Update a note
44
42
  */
45
- update(id: string, data: Partial<NoteAttributes>): Promise<NoteResource>;
43
+ update(id: string, data: Partial<NoteAttributes>): Promise<import("@rachelallyson/planning-center-base-ts").FlattenedResource<"Note", NoteAttributes, import("../types").NoteRelationships>>;
46
44
  /**
47
45
  * Delete a note
48
46
  */
49
47
  delete(id: string): Promise<void>;
50
48
  /**
51
49
  * Get all note categories
50
+ * @param options - Optional pagination options
52
51
  */
53
- getNoteCategories(): Promise<{
54
- data: NoteCategoryResource[];
55
- meta?: any;
56
- links?: any;
52
+ getNoteCategories(options?: {
53
+ perPage?: number;
54
+ page?: number;
55
+ }): Promise<{
56
+ data: import("@rachelallyson/planning-center-base-ts").FlattenedResource<"NoteCategory", NoteCategoryAttributes, import("../types").NoteCategoryRelationships, Record<string, never>>[];
57
+ meta?: Meta;
58
+ links?: TopLevelLinks;
57
59
  }>;
58
60
  /**
59
61
  * Get a single note category by ID
60
62
  */
61
- getNoteCategoryById(id: string): Promise<NoteCategoryResource>;
63
+ getNoteCategoryById(id: string): Promise<import("@rachelallyson/planning-center-base-ts").FlattenedResource<"NoteCategory", NoteCategoryAttributes, import("../types").NoteCategoryRelationships>>;
62
64
  /**
63
65
  * Create a note category
64
66
  */
65
- createNoteCategory(data: NoteCategoryAttributes): Promise<NoteCategoryResource>;
67
+ createNoteCategory(data: Partial<NoteCategoryAttributes>): Promise<import("@rachelallyson/planning-center-base-ts").FlattenedResource<"NoteCategory", NoteCategoryAttributes, import("../types").NoteCategoryRelationships>>;
66
68
  /**
67
69
  * Update a note category
68
70
  */
69
- updateNoteCategory(id: string, data: Partial<NoteCategoryAttributes>): Promise<NoteCategoryResource>;
71
+ updateNoteCategory(id: string, data: Partial<NoteCategoryAttributes>): Promise<import("@rachelallyson/planning-center-base-ts").FlattenedResource<"NoteCategory", NoteCategoryAttributes, import("../types").NoteCategoryRelationships>>;
70
72
  /**
71
73
  * Delete a note category
72
74
  */