@gzl10/baserow 1.2.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.
- package/CHANGELOG.md +435 -0
- package/README.md +847 -0
- package/dist/index.d.ts +8749 -0
- package/dist/index.js +11167 -0
- package/dist/index.js.map +1 -0
- package/package.json +91 -0
- package/src/BaserowClient.ts +501 -0
- package/src/ClientWithCreds.ts +545 -0
- package/src/ClientWithCredsWs.ts +852 -0
- package/src/ClientWithToken.ts +171 -0
- package/src/contexts/DatabaseClientContext.ts +114 -0
- package/src/contexts/DatabaseContext.ts +870 -0
- package/src/contexts/DatabaseTokenContext.ts +331 -0
- package/src/contexts/FieldContext.ts +399 -0
- package/src/contexts/RowContext.ts +99 -0
- package/src/contexts/TableClientContext.ts +291 -0
- package/src/contexts/TableContext.ts +1247 -0
- package/src/contexts/TableOnlyContext.ts +74 -0
- package/src/contexts/WorkspaceContext.ts +490 -0
- package/src/express/errors.ts +260 -0
- package/src/express/index.ts +69 -0
- package/src/express/middleware.ts +225 -0
- package/src/express/serializers.ts +314 -0
- package/src/index.ts +247 -0
- package/src/presets/performance.ts +262 -0
- package/src/services/AuthService.ts +472 -0
- package/src/services/DatabaseService.ts +246 -0
- package/src/services/DatabaseTokenService.ts +186 -0
- package/src/services/FieldService.ts +1543 -0
- package/src/services/RowService.ts +982 -0
- package/src/services/SchemaControlService.ts +420 -0
- package/src/services/TableService.ts +781 -0
- package/src/services/WorkspaceService.ts +113 -0
- package/src/services/core/BaseAuthClient.ts +111 -0
- package/src/services/core/BaseClient.ts +107 -0
- package/src/services/core/BaseService.ts +71 -0
- package/src/services/core/HttpService.ts +115 -0
- package/src/services/core/ValidationService.ts +149 -0
- package/src/types/auth.ts +177 -0
- package/src/types/core.ts +91 -0
- package/src/types/errors.ts +105 -0
- package/src/types/fields.ts +456 -0
- package/src/types/index.ts +222 -0
- package/src/types/requests.ts +333 -0
- package/src/types/responses.ts +50 -0
- package/src/types/schema.ts +446 -0
- package/src/types/tokens.ts +36 -0
- package/src/types.ts +11 -0
- package/src/utils/auth.ts +174 -0
- package/src/utils/axios.ts +647 -0
- package/src/utils/field-cache.ts +164 -0
- package/src/utils/httpFactory.ts +66 -0
- package/src/utils/jwt-decoder.ts +188 -0
- package/src/utils/jwtTokens.ts +50 -0
- package/src/utils/performance.ts +105 -0
- package/src/utils/prisma-mapper.ts +961 -0
- package/src/utils/validation.ts +463 -0
- package/src/validators/schema.ts +419 -0
|
@@ -0,0 +1,456 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tipos relacionados con campos (fields) de Baserow
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Tipo de campo de Baserow (21/22 tipos soportados - 95% cobertura)
|
|
7
|
+
*
|
|
8
|
+
* @aiContext Usa este tipo para entender los campos disponibles y sus propósitos
|
|
9
|
+
*
|
|
10
|
+
* @aiMapping Mapeo de tipos de campo a casos de uso:
|
|
11
|
+
*
|
|
12
|
+
* **Campos de Texto:**
|
|
13
|
+
* - `text` → String corto (máx 255 chars) - nombres, títulos, códigos
|
|
14
|
+
* - `long_text` → String largo multiline - descripciones, notas, comentarios
|
|
15
|
+
* - `url` → URLs con validación automática - sitios web, enlaces
|
|
16
|
+
* - `email` → Emails con validación automática - contactos
|
|
17
|
+
* - `phone_number` → Teléfonos con formato - contacto telefónico
|
|
18
|
+
*
|
|
19
|
+
* **Campos Numéricos:**
|
|
20
|
+
* - `number` → Números con decimales configurables (0-10) - precios, cantidades
|
|
21
|
+
* - `rating` → Estrellas/hearts/thumbs (1-10 max) - valoraciones, puntuaciones
|
|
22
|
+
* - `boolean` → True/false - checkboxes, estados binarios
|
|
23
|
+
*
|
|
24
|
+
* **Campos de Fecha/Auditoría:**
|
|
25
|
+
* - `date` → Fechas con timezone y formato - eventos, deadlines
|
|
26
|
+
* - `last_modified` → Timestamp automático última modificación (read-only)
|
|
27
|
+
* - `last_modified_by` → Usuario última modificación (read-only)
|
|
28
|
+
* - `created_on` → Timestamp creación (read-only)
|
|
29
|
+
* - `created_by` → Usuario creación (read-only)
|
|
30
|
+
*
|
|
31
|
+
* **Campos de Selección:**
|
|
32
|
+
* - `single_select` → Dropdown opciones predefinidas - status, categorías
|
|
33
|
+
* - `multiple_select` → Tags/chips múltiples opciones - etiquetas, skills
|
|
34
|
+
*
|
|
35
|
+
* **Campos Relacionales:**
|
|
36
|
+
* - `link_row` → Relaciones entre tablas (1:N, N:M) - foreign keys
|
|
37
|
+
* - `formula` → Cálculos dinámicos basados en otros campos - computed values
|
|
38
|
+
*
|
|
39
|
+
* **Campos Avanzados (v1.1.0+):**
|
|
40
|
+
* - `file` → Uploads archivos/imágenes - documentos, fotos
|
|
41
|
+
* - `count` → Contador automático filas relacionadas - total items
|
|
42
|
+
* - `rollup` → Agregaciones (sum, avg, min, max) de relacionados - totales
|
|
43
|
+
* - `lookup` → Buscar valores de tablas relacionadas - referencias
|
|
44
|
+
* - `autonumber` → ID auto-incremental único - tickets, facturas
|
|
45
|
+
*
|
|
46
|
+
* **No Soportado:**
|
|
47
|
+
* - `multiple_collaborators` → ❌ Pendiente implementación
|
|
48
|
+
*
|
|
49
|
+
* @see {@link https://baserow.io/docs/apis/field-types|Baserow Field Types Docs}
|
|
50
|
+
*
|
|
51
|
+
* @example Crear diferentes tipos de campos
|
|
52
|
+
* ```typescript
|
|
53
|
+
* // Campos básicos
|
|
54
|
+
* await table.field.createText('full_name')
|
|
55
|
+
* await table.field.createEmail('contact')
|
|
56
|
+
* await table.field.createLongText('description')
|
|
57
|
+
*
|
|
58
|
+
* // Campos numéricos
|
|
59
|
+
* await table.field.createNumber('price', 2) // 2 decimales
|
|
60
|
+
* await table.field.createRating('satisfaction', 5, 'star') // 1-5 estrellas
|
|
61
|
+
* await table.field.createBoolean('is_active')
|
|
62
|
+
*
|
|
63
|
+
* // Campos de fecha
|
|
64
|
+
* await table.field.createDate('birthday')
|
|
65
|
+
*
|
|
66
|
+
* // Campos de selección
|
|
67
|
+
* await table.field.createSingleSelect('status', [
|
|
68
|
+
* { value: 'pending', color: 'yellow' },
|
|
69
|
+
* { value: 'completed', color: 'green' }
|
|
70
|
+
* ])
|
|
71
|
+
*
|
|
72
|
+
* // Campos relacionales
|
|
73
|
+
* await table.field.createLinkRow('customer', customersTableId)
|
|
74
|
+
* await table.field.createFormula('total', 'field("quantity") * field("price")')
|
|
75
|
+
*
|
|
76
|
+
* // Campos avanzados (v1.1.0+)
|
|
77
|
+
* await table.field.createFile('documents')
|
|
78
|
+
* await table.field.createCount('total_orders', ordersTableId)
|
|
79
|
+
* await table.field.createRollup('revenue', ordersTableId, priceFieldId, 'sum')
|
|
80
|
+
* await table.field.createLookup('customer_name', ordersTableId, nameFieldId)
|
|
81
|
+
* await table.field.createAutonumber('ticket_id')
|
|
82
|
+
* ```
|
|
83
|
+
*
|
|
84
|
+
* @since 1.0.0
|
|
85
|
+
*/
|
|
86
|
+
export type FieldType =
|
|
87
|
+
| 'text'
|
|
88
|
+
| 'long_text'
|
|
89
|
+
| 'url'
|
|
90
|
+
| 'email'
|
|
91
|
+
| 'phone_number'
|
|
92
|
+
| 'number'
|
|
93
|
+
| 'rating'
|
|
94
|
+
| 'boolean'
|
|
95
|
+
| 'date'
|
|
96
|
+
| 'last_modified'
|
|
97
|
+
| 'last_modified_by'
|
|
98
|
+
| 'created_on'
|
|
99
|
+
| 'created_by'
|
|
100
|
+
| 'single_select'
|
|
101
|
+
| 'multiple_select'
|
|
102
|
+
| 'file'
|
|
103
|
+
| 'multiple_collaborators'
|
|
104
|
+
| 'link_row'
|
|
105
|
+
| 'count'
|
|
106
|
+
| 'rollup'
|
|
107
|
+
| 'lookup'
|
|
108
|
+
| 'formula'
|
|
109
|
+
| 'autonumber'
|
|
110
|
+
|
|
111
|
+
export type NumberSeparator = '' | 'SPACE_COMMA' | 'SPACE_PERIOD' | 'COMMA_PERIOD' | 'PERIOD_COMMA'
|
|
112
|
+
|
|
113
|
+
export type RatingStyle = 'star' | 'heart' | 'thumbs-up' | 'flag' | 'smile'
|
|
114
|
+
|
|
115
|
+
export type RatingColor =
|
|
116
|
+
// Colores básicos
|
|
117
|
+
| 'red'
|
|
118
|
+
| 'blue'
|
|
119
|
+
| 'green'
|
|
120
|
+
| 'yellow'
|
|
121
|
+
| 'orange'
|
|
122
|
+
| 'purple'
|
|
123
|
+
// Variantes claras
|
|
124
|
+
| 'light-red'
|
|
125
|
+
| 'light-blue'
|
|
126
|
+
| 'light-green'
|
|
127
|
+
| 'light-yellow'
|
|
128
|
+
| 'light-orange'
|
|
129
|
+
| 'light-purple'
|
|
130
|
+
// Variantes oscuras
|
|
131
|
+
| 'dark-red'
|
|
132
|
+
| 'dark-blue'
|
|
133
|
+
| 'dark-green'
|
|
134
|
+
| 'dark-yellow'
|
|
135
|
+
| 'dark-orange'
|
|
136
|
+
| 'dark-purple'
|
|
137
|
+
// Escala de grises
|
|
138
|
+
| 'gray'
|
|
139
|
+
| 'light-gray'
|
|
140
|
+
| 'dark-gray'
|
|
141
|
+
// Extremos
|
|
142
|
+
| 'black'
|
|
143
|
+
| 'white'
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Tipos de restricciones de valor para campos
|
|
147
|
+
* Introducidos en Baserow v1.35+
|
|
148
|
+
*
|
|
149
|
+
* @since 1.1.0
|
|
150
|
+
*/
|
|
151
|
+
export type ConstraintType =
|
|
152
|
+
| 'unique' // Valores únicos, excluyendo vacíos
|
|
153
|
+
| 'unique_with_empty' // Valores únicos, incluyendo vacíos
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Configuración de restricción de campo
|
|
157
|
+
*
|
|
158
|
+
* @since 1.1.0
|
|
159
|
+
*/
|
|
160
|
+
export interface FieldConstraint {
|
|
161
|
+
type: ConstraintType
|
|
162
|
+
active: boolean
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Opciones avanzadas de campo (v1.35+)
|
|
167
|
+
* Incluye configuración de índices y restricciones
|
|
168
|
+
*
|
|
169
|
+
* @since 1.1.0
|
|
170
|
+
*/
|
|
171
|
+
export interface FieldAdvancedOptions {
|
|
172
|
+
/** Habilitar índice para performance mejorada en filtros */
|
|
173
|
+
index?: boolean
|
|
174
|
+
/** Restricciones de valor para integridad de datos */
|
|
175
|
+
constraints?: FieldConstraint[]
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
export interface SelectOption {
|
|
179
|
+
id?: number
|
|
180
|
+
value: string
|
|
181
|
+
color: string
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
export interface Field {
|
|
185
|
+
id: number
|
|
186
|
+
table_id: number
|
|
187
|
+
name: string
|
|
188
|
+
order: number
|
|
189
|
+
type: FieldType
|
|
190
|
+
primary: boolean
|
|
191
|
+
read_only: boolean
|
|
192
|
+
description?: string
|
|
193
|
+
|
|
194
|
+
// Propiedades específicas por tipo
|
|
195
|
+
select_options?: SelectOption[]
|
|
196
|
+
link_row_table_id?: number
|
|
197
|
+
link_row_related_field_id?: number
|
|
198
|
+
number_decimal_places?: number
|
|
199
|
+
number_negative?: boolean
|
|
200
|
+
number_prefix?: string
|
|
201
|
+
number_suffix?: string
|
|
202
|
+
number_separator?: NumberSeparator
|
|
203
|
+
date_format?: string
|
|
204
|
+
date_include_time?: boolean
|
|
205
|
+
date_time_format?: string
|
|
206
|
+
date_show_tzinfo?: boolean
|
|
207
|
+
date_force_timezone?: string
|
|
208
|
+
date_force_timezone_offset?: number
|
|
209
|
+
max_value?: number
|
|
210
|
+
color?: RatingColor
|
|
211
|
+
style?: RatingStyle
|
|
212
|
+
formula?: string
|
|
213
|
+
formula_type?: string
|
|
214
|
+
text_default?: string
|
|
215
|
+
number_default?: string
|
|
216
|
+
boolean_default?: boolean
|
|
217
|
+
date_default?: string
|
|
218
|
+
|
|
219
|
+
// Funcionalidades avanzadas (v1.35+)
|
|
220
|
+
/** Indica si el campo tiene índice habilitado para performance */
|
|
221
|
+
index?: boolean
|
|
222
|
+
/** Restricciones de valor activas en el campo */
|
|
223
|
+
constraints?: FieldConstraint[]
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
export interface CreateFieldRequest {
|
|
227
|
+
name: string
|
|
228
|
+
type: FieldType
|
|
229
|
+
description?: string
|
|
230
|
+
|
|
231
|
+
// Opciones específicas por tipo
|
|
232
|
+
select_options?: SelectOption[]
|
|
233
|
+
link_row_table_id?: number
|
|
234
|
+
target_field_id?: number
|
|
235
|
+
through_field_id?: number
|
|
236
|
+
rollup_function?: string
|
|
237
|
+
number_decimal_places?: number
|
|
238
|
+
number_negative?: boolean
|
|
239
|
+
number_prefix?: string
|
|
240
|
+
number_suffix?: string
|
|
241
|
+
number_separator?: NumberSeparator
|
|
242
|
+
date_format?: string
|
|
243
|
+
date_include_time?: boolean
|
|
244
|
+
date_time_format?: string
|
|
245
|
+
date_show_tzinfo?: boolean
|
|
246
|
+
date_force_timezone?: string
|
|
247
|
+
date_force_timezone_offset?: number
|
|
248
|
+
max_value?: number
|
|
249
|
+
color?: RatingColor
|
|
250
|
+
style?: RatingStyle
|
|
251
|
+
formula?: string
|
|
252
|
+
text_default?: string
|
|
253
|
+
number_default?: string | null
|
|
254
|
+
boolean_default?: boolean
|
|
255
|
+
date_default?: string
|
|
256
|
+
|
|
257
|
+
// Funcionalidades avanzadas (v1.35+)
|
|
258
|
+
/** Habilitar índice para performance mejorada en filtros */
|
|
259
|
+
index?: boolean
|
|
260
|
+
/** Restricciones de valor para integridad de datos */
|
|
261
|
+
constraints?: FieldConstraint[]
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
export interface UpdateFieldRequest extends Partial<CreateFieldRequest> {
|
|
265
|
+
name?: string
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
// ===== TIPOS CONDICIONALES PARA FIELDS.CREATE() =====
|
|
269
|
+
|
|
270
|
+
/**
|
|
271
|
+
* Tipo base para creación de campos con propiedades comunes
|
|
272
|
+
*/
|
|
273
|
+
interface BaseFieldCreate {
|
|
274
|
+
name: string
|
|
275
|
+
description?: string
|
|
276
|
+
index?: boolean
|
|
277
|
+
constraints?: FieldConstraint[]
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
/**
|
|
281
|
+
* Tipos específicos para cada tipo de campo
|
|
282
|
+
* Proporcionan type safety y autocompletado contextual
|
|
283
|
+
*/
|
|
284
|
+
interface TextFieldCreate extends BaseFieldCreate {
|
|
285
|
+
type: 'text'
|
|
286
|
+
text_default?: string
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
interface LongTextFieldCreate extends BaseFieldCreate {
|
|
290
|
+
type: 'long_text'
|
|
291
|
+
text_default?: string
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
interface UrlFieldCreate extends BaseFieldCreate {
|
|
295
|
+
type: 'url'
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
interface EmailFieldCreate extends BaseFieldCreate {
|
|
299
|
+
type: 'email'
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
interface PhoneNumberFieldCreate extends BaseFieldCreate {
|
|
303
|
+
type: 'phone_number'
|
|
304
|
+
text_default?: string
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
interface NumberFieldCreate extends BaseFieldCreate {
|
|
308
|
+
type: 'number'
|
|
309
|
+
number_decimal_places?: number
|
|
310
|
+
number_negative?: boolean
|
|
311
|
+
number_prefix?: string
|
|
312
|
+
number_suffix?: string
|
|
313
|
+
number_separator?: NumberSeparator
|
|
314
|
+
number_default?: string | null
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
interface BooleanFieldCreate extends BaseFieldCreate {
|
|
318
|
+
type: 'boolean'
|
|
319
|
+
boolean_default?: boolean
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
interface RatingFieldCreate extends BaseFieldCreate {
|
|
323
|
+
type: 'rating'
|
|
324
|
+
max_value?: number
|
|
325
|
+
color?: RatingColor
|
|
326
|
+
style?: RatingStyle
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
interface DateFieldCreate extends BaseFieldCreate {
|
|
330
|
+
type: 'date'
|
|
331
|
+
date_format?: string
|
|
332
|
+
date_include_time?: boolean
|
|
333
|
+
date_time_format?: string
|
|
334
|
+
date_show_tzinfo?: boolean
|
|
335
|
+
date_force_timezone?: string
|
|
336
|
+
date_force_timezone_offset?: number
|
|
337
|
+
date_default?: string
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
interface SingleSelectFieldCreate extends BaseFieldCreate {
|
|
341
|
+
type: 'single_select'
|
|
342
|
+
select_options?: SelectOption[]
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
interface MultipleSelectFieldCreate extends BaseFieldCreate {
|
|
346
|
+
type: 'multiple_select'
|
|
347
|
+
select_options?: SelectOption[]
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
interface LinkRowFieldCreate extends BaseFieldCreate {
|
|
351
|
+
type: 'link_row'
|
|
352
|
+
link_row_table_id: number
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
interface FormulaFieldCreate extends BaseFieldCreate {
|
|
356
|
+
type: 'formula'
|
|
357
|
+
formula: string
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
interface FileFieldCreate extends BaseFieldCreate {
|
|
361
|
+
type: 'file'
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
interface AutonumberFieldCreate extends BaseFieldCreate {
|
|
365
|
+
type: 'autonumber'
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
interface CountFieldCreate extends BaseFieldCreate {
|
|
369
|
+
type: 'count'
|
|
370
|
+
through_field_id: number
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
interface RollupFieldCreate extends BaseFieldCreate {
|
|
374
|
+
type: 'rollup'
|
|
375
|
+
through_field_id: number
|
|
376
|
+
target_field_id: number
|
|
377
|
+
rollup_function?: string
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
interface LookupFieldCreate extends BaseFieldCreate {
|
|
381
|
+
type: 'lookup'
|
|
382
|
+
through_field_id: number
|
|
383
|
+
target_field_id: number
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
interface LastModifiedFieldCreate extends BaseFieldCreate {
|
|
387
|
+
type: 'last_modified'
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
interface LastModifiedByFieldCreate extends BaseFieldCreate {
|
|
391
|
+
type: 'last_modified_by'
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
interface CreatedOnFieldCreate extends BaseFieldCreate {
|
|
395
|
+
type: 'created_on'
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
interface CreatedByFieldCreate extends BaseFieldCreate {
|
|
399
|
+
type: 'created_by'
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
interface MultipleCollaboratorsFieldCreate extends BaseFieldCreate {
|
|
403
|
+
type: 'multiple_collaborators'
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
/**
|
|
407
|
+
* Union type condicional que mapea cada FieldType a su interfaz específica
|
|
408
|
+
* Proporciona IntelliSense dinámico basado en el tipo seleccionado
|
|
409
|
+
*/
|
|
410
|
+
export type CreateFieldByType<T extends FieldType> = T extends 'text'
|
|
411
|
+
? TextFieldCreate
|
|
412
|
+
: T extends 'long_text'
|
|
413
|
+
? LongTextFieldCreate
|
|
414
|
+
: T extends 'url'
|
|
415
|
+
? UrlFieldCreate
|
|
416
|
+
: T extends 'email'
|
|
417
|
+
? EmailFieldCreate
|
|
418
|
+
: T extends 'phone_number'
|
|
419
|
+
? PhoneNumberFieldCreate
|
|
420
|
+
: T extends 'number'
|
|
421
|
+
? NumberFieldCreate
|
|
422
|
+
: T extends 'boolean'
|
|
423
|
+
? BooleanFieldCreate
|
|
424
|
+
: T extends 'rating'
|
|
425
|
+
? RatingFieldCreate
|
|
426
|
+
: T extends 'date'
|
|
427
|
+
? DateFieldCreate
|
|
428
|
+
: T extends 'single_select'
|
|
429
|
+
? SingleSelectFieldCreate
|
|
430
|
+
: T extends 'multiple_select'
|
|
431
|
+
? MultipleSelectFieldCreate
|
|
432
|
+
: T extends 'link_row'
|
|
433
|
+
? LinkRowFieldCreate
|
|
434
|
+
: T extends 'formula'
|
|
435
|
+
? FormulaFieldCreate
|
|
436
|
+
: T extends 'file'
|
|
437
|
+
? FileFieldCreate
|
|
438
|
+
: T extends 'autonumber'
|
|
439
|
+
? AutonumberFieldCreate
|
|
440
|
+
: T extends 'count'
|
|
441
|
+
? CountFieldCreate
|
|
442
|
+
: T extends 'rollup'
|
|
443
|
+
? RollupFieldCreate
|
|
444
|
+
: T extends 'lookup'
|
|
445
|
+
? LookupFieldCreate
|
|
446
|
+
: T extends 'last_modified'
|
|
447
|
+
? LastModifiedFieldCreate
|
|
448
|
+
: T extends 'last_modified_by'
|
|
449
|
+
? LastModifiedByFieldCreate
|
|
450
|
+
: T extends 'created_on'
|
|
451
|
+
? CreatedOnFieldCreate
|
|
452
|
+
: T extends 'created_by'
|
|
453
|
+
? CreatedByFieldCreate
|
|
454
|
+
: T extends 'multiple_collaborators'
|
|
455
|
+
? MultipleCollaboratorsFieldCreate
|
|
456
|
+
: CreateFieldRequest // fallback genérico para tipos no mapeados
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sistema de tipos completo para la librería @gzl10/baserow
|
|
3
|
+
*
|
|
4
|
+
* Este archivo centraliza todos los tipos TypeScript necesarios para interactuar
|
|
5
|
+
* con la API de Baserow. Los tipos están organizados por categorías funcionales
|
|
6
|
+
* y proporcionan tipado estricto para todas las operaciones.
|
|
7
|
+
*
|
|
8
|
+
* **Categorías de tipos:**
|
|
9
|
+
* - **Core**: Entidades principales (Workspace, Database, Table, Row, Field)
|
|
10
|
+
* - **Auth**: Autenticación y configuración (JWT, Database Tokens, credenciales)
|
|
11
|
+
* - **Fields**: 21 tipos de campos con sus configuraciones específicas
|
|
12
|
+
* - **Requests**: Payloads para operaciones CREATE/UPDATE
|
|
13
|
+
* - **Responses**: Estructuras de respuesta de la API
|
|
14
|
+
* - **Errors**: Jerarquía de errores tipados con contexto
|
|
15
|
+
* - **Tokens**: Database tokens con permisos granulares
|
|
16
|
+
*
|
|
17
|
+
* **Beneficios del tipado estricto:**
|
|
18
|
+
* - IntelliSense completo en IDEs
|
|
19
|
+
* - Detección de errores en tiempo de compilación
|
|
20
|
+
* - Refactoring seguro
|
|
21
|
+
* - Documentación viva del API
|
|
22
|
+
* - Compatibilidad con herramientas de generación de tipos
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```typescript
|
|
26
|
+
* import {
|
|
27
|
+
* BaserowClient,
|
|
28
|
+
* Table,
|
|
29
|
+
* Field,
|
|
30
|
+
* QueryOptions,
|
|
31
|
+
* BaserowError
|
|
32
|
+
* } from '@gzl10/baserow'
|
|
33
|
+
*
|
|
34
|
+
* // Tipos inferidos automáticamente
|
|
35
|
+
* const client = new BaserowClient({ url: '...', token: '...' })
|
|
36
|
+
* const tables: Table[] = await client.database(123).tables.findMany()
|
|
37
|
+
* const options: QueryOptions = { page: 1, size: 100, filters: { active: true } }
|
|
38
|
+
* ```
|
|
39
|
+
*
|
|
40
|
+
* @since 1.0.0
|
|
41
|
+
*/
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Entidades principales y utilidades core
|
|
45
|
+
*
|
|
46
|
+
* Tipos fundamentales que representan las entidades principales
|
|
47
|
+
* de Baserow: workspaces, databases, tables, rows y usuarios.
|
|
48
|
+
*
|
|
49
|
+
* @since 1.0.0
|
|
50
|
+
*/
|
|
51
|
+
export type {
|
|
52
|
+
Logger,
|
|
53
|
+
UserReference,
|
|
54
|
+
Workspace,
|
|
55
|
+
Database,
|
|
56
|
+
DatabaseLight,
|
|
57
|
+
Table,
|
|
58
|
+
TableFromAllTables,
|
|
59
|
+
Row,
|
|
60
|
+
User,
|
|
61
|
+
UserProfile
|
|
62
|
+
} from './core'
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Autenticación y configuración
|
|
66
|
+
*
|
|
67
|
+
* Tipos para manejar autenticación JWT, configuración de clientes
|
|
68
|
+
* y operaciones de login/logout. Incluye tanto Database Tokens
|
|
69
|
+
* como JWT tokens para diferentes niveles de acceso.
|
|
70
|
+
*
|
|
71
|
+
* @since 1.0.0
|
|
72
|
+
*/
|
|
73
|
+
export type {
|
|
74
|
+
BaserowCredentials,
|
|
75
|
+
BaserowConfig,
|
|
76
|
+
BaserowAdminConfig,
|
|
77
|
+
BaserowPerformanceOptions,
|
|
78
|
+
LoginRequest,
|
|
79
|
+
LoginResponse,
|
|
80
|
+
RefreshTokenRequest,
|
|
81
|
+
RefreshTokenResponse,
|
|
82
|
+
ChangePasswordRequest,
|
|
83
|
+
BaserowTokenConfig,
|
|
84
|
+
BaserowCredentialsConfig,
|
|
85
|
+
BaserowCredentialsWorkspaceConfig,
|
|
86
|
+
BaserowUnifiedConfig,
|
|
87
|
+
TokenConfig,
|
|
88
|
+
CredentialsConfig,
|
|
89
|
+
CredentialsWorkspaceConfig
|
|
90
|
+
} from './auth'
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Campos y tipos de datos
|
|
94
|
+
*
|
|
95
|
+
* Definiciones completas para los 21 tipos de campos soportados
|
|
96
|
+
* por Baserow, incluyendo configuraciones específicas para cada tipo,
|
|
97
|
+
* opciones de validación y metadatos.
|
|
98
|
+
*
|
|
99
|
+
* **Tipos incluidos:**
|
|
100
|
+
* - Texto: text, long_text, url, email, phone_number
|
|
101
|
+
* - Numéricos: number, boolean, rating
|
|
102
|
+
* - Fecha: date, last_modified, created_on, etc.
|
|
103
|
+
* - Selección: single_select, multiple_select
|
|
104
|
+
* - Relacionales: link_row, formula
|
|
105
|
+
* - Avanzados: file, autonumber, count, rollup, lookup
|
|
106
|
+
* - **v1.35+**: Índices para performance y constraints para integridad
|
|
107
|
+
*
|
|
108
|
+
* @since 1.0.0
|
|
109
|
+
*/
|
|
110
|
+
export type {
|
|
111
|
+
FieldType,
|
|
112
|
+
NumberSeparator,
|
|
113
|
+
RatingStyle,
|
|
114
|
+
RatingColor,
|
|
115
|
+
SelectOption,
|
|
116
|
+
Field,
|
|
117
|
+
CreateFieldRequest,
|
|
118
|
+
UpdateFieldRequest,
|
|
119
|
+
ConstraintType,
|
|
120
|
+
FieldConstraint,
|
|
121
|
+
FieldAdvancedOptions,
|
|
122
|
+
CreateFieldByType
|
|
123
|
+
} from './fields'
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Database Tokens y permisos
|
|
127
|
+
*
|
|
128
|
+
* Sistema de tokens para acceso granular a databases y tablas específicas.
|
|
129
|
+
* Permite configurar permisos CRUD individuales y scope limitado.
|
|
130
|
+
* Incluye utilidades para tokens de librería con prefijo 'br-lib:'.
|
|
131
|
+
*
|
|
132
|
+
* @since 1.0.0
|
|
133
|
+
*/
|
|
134
|
+
export type {
|
|
135
|
+
DatabaseToken,
|
|
136
|
+
DatabaseTokenPermissions,
|
|
137
|
+
CreateDatabaseTokenRequest,
|
|
138
|
+
UpdateDatabaseTokenRequest
|
|
139
|
+
} from './tokens'
|
|
140
|
+
export { LIBRARY_TOKEN_PREFIX } from './tokens'
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Payloads de requests
|
|
144
|
+
*
|
|
145
|
+
* Estructuras de datos para todas las operaciones CREATE y UPDATE.
|
|
146
|
+
* Incluye validación de tipos y opciones para operaciones bulk optimizadas.
|
|
147
|
+
* Cubre tablas, filas, campos, usuarios y configuraciones.
|
|
148
|
+
*
|
|
149
|
+
* @since 1.0.0
|
|
150
|
+
*/
|
|
151
|
+
export type {
|
|
152
|
+
CreateTableRequest,
|
|
153
|
+
UpdateTableRequest,
|
|
154
|
+
CreateRowRequest,
|
|
155
|
+
UpdateRowRequest,
|
|
156
|
+
BulkCreateRowsRequest,
|
|
157
|
+
BulkUpdateRowsRequest,
|
|
158
|
+
CreateSnapshotRequest,
|
|
159
|
+
RestoreSnapshotRequest,
|
|
160
|
+
CreateWebhookRequest,
|
|
161
|
+
UpdateWebhookRequest,
|
|
162
|
+
CreateUserRequest,
|
|
163
|
+
UpdateUserRequest,
|
|
164
|
+
EmailTestRequest,
|
|
165
|
+
QueryOptions,
|
|
166
|
+
PrismaLikeQueryOptions,
|
|
167
|
+
FieldOperators,
|
|
168
|
+
WhereClause,
|
|
169
|
+
OrderByClause,
|
|
170
|
+
SelectClause,
|
|
171
|
+
BulkOptions
|
|
172
|
+
} from './requests'
|
|
173
|
+
|
|
174
|
+
// Schema system types
|
|
175
|
+
export type {
|
|
176
|
+
DatabaseSchema,
|
|
177
|
+
TableSchema,
|
|
178
|
+
FieldSchema,
|
|
179
|
+
RelationshipSchema,
|
|
180
|
+
FieldConfig,
|
|
181
|
+
LoadSchemaOptions,
|
|
182
|
+
LoadSchemaResult,
|
|
183
|
+
SchemaControl,
|
|
184
|
+
SchemaChange,
|
|
185
|
+
LoadSchemaStats,
|
|
186
|
+
LoadSchemaMode,
|
|
187
|
+
SchemaControlStatus
|
|
188
|
+
} from './schema'
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* Estructuras de respuesta
|
|
192
|
+
*
|
|
193
|
+
* Tipos para las respuestas de la API de Baserow, incluyendo
|
|
194
|
+
* paginación, metadatos y estructuras anidadas. Compatible
|
|
195
|
+
* con las diferentes versiones del API.
|
|
196
|
+
*
|
|
197
|
+
* @since 1.0.0
|
|
198
|
+
*/
|
|
199
|
+
export type { BaserowResponse, Snapshot, Webhook, WebhookCall, HealthCheck } from './responses'
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* Sistema de errores tipados
|
|
203
|
+
*
|
|
204
|
+
* Jerarquía completa de errores personalizados con contexto específico
|
|
205
|
+
* para diferentes tipos de fallos: validación, red, timeouts, rate limiting,
|
|
206
|
+
* recursos no encontrados, etc. Facilita el manejo granular de errores.
|
|
207
|
+
*
|
|
208
|
+
* @since 1.0.0
|
|
209
|
+
*/
|
|
210
|
+
export {
|
|
211
|
+
BaserowError,
|
|
212
|
+
BaserowValidationError,
|
|
213
|
+
BaserowNotFoundError,
|
|
214
|
+
BaserowRateLimitError,
|
|
215
|
+
BaserowNetworkError,
|
|
216
|
+
BaserowTimeoutError,
|
|
217
|
+
BaserowConfigError,
|
|
218
|
+
BaserowWorkspaceError,
|
|
219
|
+
BaserowAuthTokenExpiredError,
|
|
220
|
+
BaserowAuthTokenInvalidError,
|
|
221
|
+
BaserowReLoginRequiredError
|
|
222
|
+
} from './errors'
|