@@ -20,7 +20,7 @@ class Airtable_DocumentLoaders implements INode {
20
20
constructor ( ) {
21
21
this . label = 'Airtable'
22
22
this . name = 'airtable'
23
- this . version = 1 .0
23
+ this . version = 2 .0
24
24
this . type = 'Document'
25
25
this . icon = 'airtable.svg'
26
26
this . category = 'Document Loaders'
@@ -55,6 +55,15 @@ class Airtable_DocumentLoaders implements INode {
55
55
description :
56
56
'If your table URL looks like: https://airtable.com/app11RobdGoX0YNsC/tblJdmvbrgizbYICO/viw9UrP77Id0CE4ee, tblJdmvbrgizbYICO is the table id'
57
57
} ,
58
+ {
59
+ label : 'View Id' ,
60
+ name : 'viewId' ,
61
+ type : 'string' ,
62
+ placeholder : 'viw9UrP77Id0CE4ee' ,
63
+ description :
64
+ 'If your view URL looks like: https://airtable.com/app11RobdGoX0YNsC/tblJdmvbrgizbYICO/viw9UrP77Id0CE4ee, viw9UrP77Id0CE4ee is the view id' ,
65
+ optional : true
66
+ } ,
58
67
{
59
68
label : 'Return All' ,
60
69
name : 'returnAll' ,
@@ -83,6 +92,7 @@ class Airtable_DocumentLoaders implements INode {
83
92
async init ( nodeData : INodeData , _ : string , options : ICommonObject ) : Promise < any > {
84
93
const baseId = nodeData . inputs ?. baseId as string
85
94
const tableId = nodeData . inputs ?. tableId as string
95
+ const viewId = nodeData . inputs ?. viewId as string
86
96
const returnAll = nodeData . inputs ?. returnAll as boolean
87
97
const limit = nodeData . inputs ?. limit as string
88
98
const textSplitter = nodeData . inputs ?. textSplitter as TextSplitter
@@ -94,6 +104,7 @@ class Airtable_DocumentLoaders implements INode {
94
104
const airtableOptions : AirtableLoaderParams = {
95
105
baseId,
96
106
tableId,
107
+ viewId,
97
108
returnAll,
98
109
accessToken,
99
110
limit : limit ? parseInt ( limit , 10 ) : 100
@@ -133,6 +144,7 @@ interface AirtableLoaderParams {
133
144
baseId : string
134
145
tableId : string
135
146
accessToken : string
147
+ viewId ?: string
136
148
limit ?: number
137
149
returnAll ?: boolean
138
150
}
@@ -153,16 +165,19 @@ class AirtableLoader extends BaseDocumentLoader {
153
165
154
166
public readonly tableId : string
155
167
168
+ public readonly viewId ?: string
169
+
156
170
public readonly accessToken : string
157
171
158
172
public readonly limit : number
159
173
160
174
public readonly returnAll : boolean
161
175
162
- constructor ( { baseId, tableId, accessToken, limit = 100 , returnAll = false } : AirtableLoaderParams ) {
176
+ constructor ( { baseId, tableId, viewId , accessToken, limit = 100 , returnAll = false } : AirtableLoaderParams ) {
163
177
super ( )
164
178
this . baseId = baseId
165
179
this . tableId = tableId
180
+ this . viewId = viewId
166
181
this . accessToken = accessToken
167
182
this . limit = limit
168
183
this . returnAll = returnAll
@@ -203,7 +218,7 @@ class AirtableLoader extends BaseDocumentLoader {
203
218
}
204
219
205
220
private async loadLimit ( ) : Promise < Document [ ] > {
206
- const params = { maxRecords : this . limit }
221
+ const params = { maxRecords : this . limit , view : this . viewId }
207
222
const data = await this . fetchAirtableData ( `https://api.airtable.com/v0/${ this . baseId } /${ this . tableId } ` , params )
208
223
if ( data . records . length === 0 ) {
209
224
return [ ]
@@ -212,7 +227,7 @@ class AirtableLoader extends BaseDocumentLoader {
212
227
}
213
228
214
229
private async loadAll ( ) : Promise < Document [ ] > {
215
- const params : ICommonObject = { pageSize : 100 }
230
+ const params : ICommonObject = { pageSize : 100 , view : this . viewId }
216
231
let data : AirtableLoaderResponse
217
232
let returnPages : AirtableLoaderPage [ ] = [ ]
218
233
0 commit comments