@hubspot/ui-extensions 0.12.4 → 0.13.1

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 (85) hide show
  1. package/dist/__generated__/version.d.ts +2 -0
  2. package/dist/__generated__/version.js +4 -0
  3. package/dist/__tests__/crm/hooks/useAssociations.spec.js +79 -0
  4. package/dist/__tests__/crm/utils/fetchAssociations.spec.js +0 -10
  5. package/dist/__tests__/experimental/hooks/useCrmSearch.spec.js +586 -0
  6. package/dist/__tests__/experimental/hooks/utils/fetchCrmSearch.spec.js +217 -0
  7. package/dist/__tests__/hooks/useDebounce.spec.js +123 -0
  8. package/dist/__tests__/hooks/utils/useFetchLifecycle.spec.js +324 -0
  9. package/dist/__tests__/internal/hook-utils.spec.js +17 -0
  10. package/dist/__tests__/test-d/extension-points.test-d.js +1 -0
  11. package/dist/crm/hooks/useAssociations.d.ts +3 -3
  12. package/dist/crm/hooks/useAssociations.js +55 -139
  13. package/dist/crm/hooks/useCrmProperties.js +29 -125
  14. package/dist/crm/utils/fetchAssociations.js +0 -3
  15. package/dist/experimental/hooks/useCrmSearch.d.ts +2 -0
  16. package/dist/experimental/hooks/useCrmSearch.js +206 -0
  17. package/dist/experimental/hooks/utils/fetchCrmSearch.d.ts +6 -0
  18. package/dist/experimental/hooks/utils/fetchCrmSearch.js +39 -0
  19. package/dist/experimental/index.d.ts +1 -0
  20. package/dist/experimental/index.js +1 -0
  21. package/dist/hooks/useDebounce.d.ts +19 -0
  22. package/dist/hooks/useDebounce.js +32 -0
  23. package/dist/hooks/utils/useFetchLifecycle.d.ts +35 -0
  24. package/dist/hooks/utils/useFetchLifecycle.js +103 -0
  25. package/dist/index.d.ts +1 -0
  26. package/dist/index.js +1 -0
  27. package/dist/internal/hook-utils.d.ts +6 -0
  28. package/dist/internal/hook-utils.js +16 -1
  29. package/dist/{experimental/pages → pages}/components/page-routes.d.ts +1 -2
  30. package/dist/{experimental/pages → pages}/components/page-routes.js +0 -4
  31. package/dist/{experimental/pages → pages}/create-page-router.d.ts +1 -3
  32. package/dist/{experimental/pages → pages}/create-page-router.js +1 -3
  33. package/dist/{experimental/pages → pages}/create-page-router.test.js +2 -2
  34. package/dist/{experimental/pages → pages}/hooks.d.ts +0 -1
  35. package/dist/{experimental/pages → pages}/hooks.js +0 -1
  36. package/dist/pages/index.d.ts +6 -1
  37. package/dist/pages/index.js +4 -1
  38. package/dist/{experimental/pages → pages}/internal/page-router-internal-types.d.ts +1 -1
  39. package/dist/pages/internal/useAppPageLocation.d.ts +1 -0
  40. package/dist/{experimental/pages → pages}/internal/useAppPageLocation.js +2 -2
  41. package/dist/{experimental/pages → pages}/types.d.ts +1 -2
  42. package/dist/pages/types.js +1 -0
  43. package/dist/shared/types/actions.d.ts +12 -2
  44. package/dist/shared/types/components/table.d.ts +16 -0
  45. package/dist/shared/types/context.d.ts +6 -0
  46. package/dist/shared/types/crm.d.ts +4 -0
  47. package/dist/shared/types/experimental.d.ts +1 -1
  48. package/dist/shared/types/extension-points.d.ts +9 -3
  49. package/dist/shared/types/extension-points.js +1 -0
  50. package/dist/shared/types/hooks.d.ts +72 -0
  51. package/dist/shared/types/hooks.js +1 -0
  52. package/dist/shared/types/shared.d.ts +8 -0
  53. package/dist/shared/types/worker-globals.d.ts +5 -0
  54. package/dist/testing/__tests__/createRenderer.spec.js +1 -1
  55. package/dist/testing/internal/mocks/index.d.ts +1 -1
  56. package/dist/testing/internal/mocks/mock-extension-point-api.js +21 -1
  57. package/dist/testing/internal/mocks/mock-hooks.js +26 -0
  58. package/dist/testing/internal/types-internal.d.ts +2 -0
  59. package/dist/testing/types.d.ts +11 -1
  60. package/dist/utils/pagination.d.ts +0 -9
  61. package/package.json +3 -2
  62. package/dist/experimental/pages/index.d.ts +0 -6
  63. package/dist/experimental/pages/index.js +0 -4
  64. package/dist/experimental/pages/internal/useAppPageLocation.d.ts +0 -1
  65. package/dist/shared/types/pages/app-pages-types.d.ts +0 -75
  66. package/dist/shared/types/pages/components/page-routes.d.ts +0 -115
  67. package/dist/shared/types/pages/index.d.ts +0 -1
  68. package/dist/shared/types/pages.d.ts +0 -1
  69. /package/dist/{experimental/pages/create-page-router.test.d.ts → __tests__/experimental/hooks/useCrmSearch.spec.d.ts} +0 -0
  70. /package/dist/{experimental/pages/internal/trie-router.test.d.ts → __tests__/experimental/hooks/utils/fetchCrmSearch.spec.d.ts} +0 -0
  71. /package/dist/{experimental/pages/types.js → __tests__/hooks/useDebounce.spec.d.ts} +0 -0
  72. /package/dist/{shared/types/pages.js → __tests__/hooks/utils/useFetchLifecycle.spec.d.ts} +0 -0
  73. /package/dist/{shared/types/pages/app-pages-types.js → __tests__/internal/hook-utils.spec.d.ts} +0 -0
  74. /package/dist/{experimental/pages → pages}/components/index.d.ts +0 -0
  75. /package/dist/{experimental/pages → pages}/components/index.js +0 -0
  76. /package/dist/{shared/types/pages/components/page-routes.js → pages/create-page-router.test.d.ts} +0 -0
  77. /package/dist/{experimental/pages → pages}/internal/app-page-route-context.d.ts +0 -0
  78. /package/dist/{experimental/pages → pages}/internal/app-page-route-context.js +0 -0
  79. /package/dist/{experimental/pages → pages}/internal/convert-page-routes-react-elements.d.ts +0 -0
  80. /package/dist/{experimental/pages → pages}/internal/convert-page-routes-react-elements.js +0 -0
  81. /package/dist/{experimental/pages → pages}/internal/page-router-internal-types.js +0 -0
  82. /package/dist/{experimental/pages → pages}/internal/trie-router.d.ts +0 -0
  83. /package/dist/{experimental/pages → pages}/internal/trie-router.js +0 -0
  84. /package/dist/{shared/types/pages/index.js → pages/internal/trie-router.test.d.ts} +0 -0
  85. /package/dist/{experimental/pages → pages}/internal/trie-router.test.js +0 -0
@@ -0,0 +1,2 @@
1
+ export declare const SDK_VERSION = "0.13.1";
2
+ export declare const SCHEMA_VERSION = "v0";
@@ -0,0 +1,4 @@
1
+ // Auto-generated from package.json — do not edit manually.
2
+ // Regenerated by scripts/generate-version.js before each build.
3
+ export const SDK_VERSION = '0.13.1';
4
+ export const SCHEMA_VERSION = 'v0';
@@ -93,6 +93,57 @@ describe('useAssociations with Pagination', () => {
93
93
  expect(result.current.pagination.pageSize).toBe(10); // DEFAULT_PAGE_SIZE
94
94
  });
95
95
  });
96
+ it('should reflect updated pageLength in pagination.pageSize when config changes', async () => {
97
+ mockFetchAssociations.mockResolvedValue({
98
+ data: {
99
+ results: [],
100
+ hasMore: false,
101
+ nextOffset: 0,
102
+ },
103
+ cleanup: vi.fn(),
104
+ });
105
+ const { result, rerender } = renderHook(({ pageLength }) => useAssociations({
106
+ toObjectType: '0-1',
107
+ properties: ['firstname'],
108
+ pageLength,
109
+ }), { initialProps: { pageLength: 10 } });
110
+ await waitFor(() => {
111
+ expect(result.current.pagination.pageSize).toBe(10);
112
+ });
113
+ rerender({ pageLength: 25 });
114
+ await waitFor(() => {
115
+ expect(result.current.pagination.pageSize).toBe(25);
116
+ });
117
+ });
118
+ it('should reset pagination to first page when pageLength changes mid-session', async () => {
119
+ mockFetchAssociations
120
+ .mockResolvedValueOnce(mockResponse([createAssociation(1)], true, 10))
121
+ .mockResolvedValueOnce(mockResponse([createAssociation(2)], true, 20))
122
+ .mockResolvedValueOnce(mockResponse([createAssociation(3)], true, 25));
123
+ const { result, rerender } = renderHook(({ pageLength }) => useAssociations({
124
+ toObjectType: '0-1',
125
+ pageLength,
126
+ }), { initialProps: { pageLength: 10 } });
127
+ await waitFor(() => {
128
+ expect(result.current.pagination.currentPage).toBe(1);
129
+ expect(result.current.pagination.hasNextPage).toBe(true);
130
+ });
131
+ result.current.pagination.nextPage();
132
+ await waitFor(() => {
133
+ expect(result.current.pagination.currentPage).toBe(2);
134
+ expect(result.current.pagination.hasPreviousPage).toBe(true);
135
+ });
136
+ rerender({ pageLength: 25 });
137
+ await waitFor(() => {
138
+ expect(result.current.pagination.pageSize).toBe(25);
139
+ expect(result.current.pagination.currentPage).toBe(1);
140
+ expect(result.current.pagination.hasPreviousPage).toBe(false);
141
+ });
142
+ expect(mockFetchAssociations).toHaveBeenLastCalledWith(expect.objectContaining({
143
+ pageLength: 25,
144
+ offset: undefined,
145
+ }), expect.any(Object));
146
+ });
96
147
  });
97
148
  describe('data fetching', () => {
98
149
  it('should successfully fetch and return associations with pagination info', async () => {
@@ -284,6 +335,34 @@ describe('useAssociations with Pagination', () => {
284
335
  expect(result.current.pagination.hasPreviousPage).toBe(false);
285
336
  });
286
337
  });
338
+ it('should not reset if already on first page', async () => {
339
+ mockFetchAssociations.mockResolvedValueOnce({
340
+ data: {
341
+ results: [{ toObjectId: 1, associationTypes: [], properties: {} }],
342
+ hasMore: true,
343
+ nextOffset: 10,
344
+ },
345
+ cleanup: vi.fn(),
346
+ });
347
+ const { result } = renderHook(() => useAssociations({
348
+ toObjectType: '0-1',
349
+ pageLength: 10,
350
+ }));
351
+ // Wait for initial load
352
+ await waitFor(() => {
353
+ expect(result.current.pagination.currentPage).toBe(1);
354
+ });
355
+ // Try to reset while on first page
356
+ result.current.pagination.reset();
357
+ await waitFor(() => {
358
+ expect(result.current.pagination.currentPage).toBe(1);
359
+ });
360
+ // Verify results were not wiped and API was not called again
361
+ expect(result.current.results).toEqual([
362
+ { toObjectId: 1, associationTypes: [], properties: {} },
363
+ ]);
364
+ expect(mockFetchAssociations).toHaveBeenCalledTimes(1);
365
+ });
287
366
  it('should not allow navigation beyond boundaries', async () => {
288
367
  mockFetchAssociations.mockResolvedValue({
289
368
  data: {
@@ -18,11 +18,6 @@ describe('fetchAssociations', () => {
18
18
  json: vi.fn().mockResolvedValue({ data, cleanup: vi.fn() }),
19
19
  ...overrides,
20
20
  });
21
- const createErrorResponse = (statusText) => ({
22
- ok: false,
23
- statusText,
24
- json: vi.fn().mockResolvedValue({}),
25
- });
26
21
  const expectError = async (request, expectedMessage) => {
27
22
  await expect(fetchAssociations(request)).rejects.toThrow(expectedMessage);
28
23
  };
@@ -222,11 +217,6 @@ describe('fetchAssociations', () => {
222
217
  });
223
218
  });
224
219
  describe('error handling', () => {
225
- it('should throw an error when response is not OK', async () => {
226
- mockFetchAssociations.mockResolvedValueOnce(createErrorResponse('Not Found'));
227
- const request = createBasicRequest({ properties: ['firstname'] });
228
- await expectError(request, 'Failed to fetch associations: Not Found');
229
- });
230
220
  it('should throw an error when fetch fails', async () => {
231
221
  mockFetchAssociations.mockRejectedValueOnce(new Error('Network error'));
232
222
  const request = createBasicRequest({ properties: ['firstname'] });