|
1 | 1 | import { QuickBooksIcon } from '@/components/icons' |
2 | 2 | import { getScopesForService } from '@/lib/oauth/utils' |
3 | | -import type { BlockConfig, BlockMeta } from '@/blocks/types' |
| 3 | +import type { BlockConfig, BlockMeta, OutputCondition } from '@/blocks/types' |
4 | 4 | import { AuthMode, IntegrationType } from '@/blocks/types' |
5 | 5 | import { |
6 | 6 | parseQuickBooksInvoiceAllocations, |
@@ -69,16 +69,16 @@ const MUTATION_OPERATIONS = [ |
69 | 69 | ...VENDOR_OPERATIONS, |
70 | 70 | ...SALES_MUTATION_OPERATIONS, |
71 | 71 | ] as const |
72 | | -const PAGINATED_OPERATIONS = [ |
73 | | - MASTER_DATA_OPERATION, |
74 | | - SALES_READ_OPERATION, |
75 | | - 'quickbooks_list_purchase_orders', |
76 | | - 'quickbooks_list_bills', |
77 | | -] as const |
78 | 72 | const TRANSACTION_LIST_OPERATIONS = [ |
79 | 73 | 'quickbooks_list_purchase_orders', |
80 | 74 | 'quickbooks_list_bills', |
81 | 75 | ] as const |
| 76 | +const LIST_OUTPUT_CONDITION: OutputCondition = { |
| 77 | + field: 'operation', |
| 78 | + value: [MASTER_DATA_OPERATION, SALES_READ_OPERATION], |
| 79 | + and: { field: 'readMode', value: 'list' }, |
| 80 | + or: { field: 'operation', value: [...TRANSACTION_LIST_OPERATIONS] }, |
| 81 | +} |
82 | 82 | const QUICKBOOKS_OPERATIONS = [ |
83 | 83 | 'quickbooks_get_company_info', |
84 | 84 | MASTER_DATA_OPERATION, |
@@ -1027,27 +1027,27 @@ export const QuickBooksBlock: BlockConfig<QuickBooksResponse> = { |
1027 | 1027 | type: 'array', |
1028 | 1028 | description: |
1029 | 1029 | 'Master-data, sales transaction, PurchaseOrder, or Bill objects with native QuickBooks fields', |
1030 | | - condition: { field: 'operation', value: [...PAGINATED_OPERATIONS] }, |
| 1030 | + condition: LIST_OUTPUT_CONDITION, |
1031 | 1031 | }, |
1032 | 1032 | startPosition: { |
1033 | 1033 | type: 'number', |
1034 | 1034 | description: 'One-based position of the first returned list item', |
1035 | | - condition: { field: 'operation', value: [...PAGINATED_OPERATIONS] }, |
| 1035 | + condition: LIST_OUTPUT_CONDITION, |
1036 | 1036 | }, |
1037 | 1037 | maxResults: { |
1038 | 1038 | type: 'number', |
1039 | 1039 | description: 'Actual number of items reported for the list response', |
1040 | | - condition: { field: 'operation', value: [...PAGINATED_OPERATIONS] }, |
| 1040 | + condition: LIST_OUTPUT_CONDITION, |
1041 | 1041 | }, |
1042 | 1042 | nextStartPosition: { |
1043 | 1043 | type: 'number', |
1044 | 1044 | description: 'Position to pass into an explicit next-page request', |
1045 | | - condition: { field: 'operation', value: [...PAGINATED_OPERATIONS] }, |
| 1045 | + condition: LIST_OUTPUT_CONDITION, |
1046 | 1046 | }, |
1047 | 1047 | hasMore: { |
1048 | 1048 | type: 'boolean', |
1049 | 1049 | description: 'Conservative indication that another list page may exist', |
1050 | | - condition: { field: 'operation', value: [...PAGINATED_OPERATIONS] }, |
| 1050 | + condition: LIST_OUTPUT_CONDITION, |
1051 | 1051 | }, |
1052 | 1052 | record: { |
1053 | 1053 | type: 'json', |
|
0 commit comments