@xnetjs/data 0.0.2 → 0.0.3

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 (137) hide show
  1. package/README.md +112 -0
  2. package/dist/account-BZHETMC4.js +12 -0
  3. package/dist/auth/index.d.ts +413 -0
  4. package/dist/auth/index.js +102 -0
  5. package/dist/budget-WR2Q4YH3.js +12 -0
  6. package/dist/canvas-HFMMVQLD.js +10 -0
  7. package/dist/channel-DXDYJ3ZH.js +12 -0
  8. package/dist/chat-message-QUUQGXEW.js +10 -0
  9. package/dist/chunk-2DSDH2ZH.js +52 -0
  10. package/dist/chunk-337E3ZOB.js +54 -0
  11. package/dist/chunk-37267RSF.js +41 -0
  12. package/dist/chunk-3JKW6TDE.js +66 -0
  13. package/dist/chunk-3RB2FMMO.js +148 -0
  14. package/dist/{chunk-BQBPA5HS.js → chunk-4U4KBCDN.js} +16 -2
  15. package/dist/chunk-4UQTURCD.js +722 -0
  16. package/dist/chunk-54Y7QRZN.js +109 -0
  17. package/dist/chunk-5FHJE7RC.js +46 -0
  18. package/dist/chunk-64AM6JPM.js +40 -0
  19. package/dist/chunk-6CN53PON.js +143 -0
  20. package/dist/chunk-6GB7PBCR.js +40 -0
  21. package/dist/chunk-6OPZJ7MG.js +78 -0
  22. package/dist/{chunk-IDMBCRUC.js → chunk-77UDLVQY.js} +1 -1
  23. package/dist/chunk-7GMJOAPF.js +52 -0
  24. package/dist/chunk-7PDRDSFH.js +69 -0
  25. package/dist/chunk-C5IRSEEZ.js +69 -0
  26. package/dist/chunk-CHZUSBSB.js +45 -0
  27. package/dist/chunk-DOZJXPQ6.js +232 -0
  28. package/dist/chunk-DTPSTMUD.js +105 -0
  29. package/dist/chunk-E6S557NC.js +402 -0
  30. package/dist/chunk-EIQX7INF.js +45 -0
  31. package/dist/chunk-ENTHVNOC.js +57 -0
  32. package/dist/chunk-EZA5UT4Y.js +5543 -0
  33. package/dist/chunk-GR3NDMBY.js +76 -0
  34. package/dist/chunk-GWYVY2K4.js +63 -0
  35. package/dist/chunk-IJ675GJR.js +42 -0
  36. package/dist/chunk-IP4BEVVD.js +57 -0
  37. package/dist/chunk-J4IVJA5M.js +102 -0
  38. package/dist/chunk-J6EDPPH4.js +84 -0
  39. package/dist/{chunk-SZC345Z2.js → chunk-JESSJ5CZ.js} +1015 -1110
  40. package/dist/chunk-JO6Y4E5V.js +73 -0
  41. package/dist/chunk-KPVBKKZS.js +47 -0
  42. package/dist/chunk-KTJLFJEQ.js +43 -0
  43. package/dist/chunk-L66WXPTW.js +32 -0
  44. package/dist/chunk-LGD72FVD.js +48 -0
  45. package/dist/chunk-O64EK5FK.js +887 -0
  46. package/dist/chunk-PMUQACPY.js +33 -0
  47. package/dist/chunk-PSUJEKVV.js +1722 -0
  48. package/dist/chunk-QVZXXJSP.js +6122 -0
  49. package/dist/chunk-QWFTRZQT.js +142 -0
  50. package/dist/chunk-RSSZXCLL.js +51 -0
  51. package/dist/chunk-S4B5OPZU.js +415 -0
  52. package/dist/{chunk-VYR5GPJP.js → chunk-SPFKSTPT.js} +9 -3
  53. package/dist/chunk-U6CBYDVZ.js +50 -0
  54. package/dist/chunk-UDUPQKRB.js +49 -0
  55. package/dist/chunk-V6HZ3LF3.js +380 -0
  56. package/dist/chunk-WMSCEBFH.js +64 -0
  57. package/dist/chunk-WUR3WWQM.js +65 -0
  58. package/dist/chunk-XHEA5UER.js +75 -0
  59. package/dist/chunk-XTUGZSYQ.js +75 -0
  60. package/dist/chunk-XWA3CJQ6.js +45 -0
  61. package/dist/chunk-YEQ6LLUY.js +49 -0
  62. package/dist/chunk-YWN27MLD.js +47 -0
  63. package/dist/chunk-YXZGYLKV.js +65 -0
  64. package/dist/chunk-ZICIXDEE.js +54 -0
  65. package/dist/chunk-ZMCO3O2Z.js +70 -0
  66. package/dist/clone-DpbVKLUu.d.ts +2205 -0
  67. package/dist/comment-Y2Y3QYYI.js +10 -0
  68. package/dist/crm-AAJXYIJY.js +68 -0
  69. package/dist/dashboard-3DC6B4BJ.js +10 -0
  70. package/dist/database/index.d.ts +882 -0
  71. package/dist/database/index.js +523 -0
  72. package/dist/database-DRGL5UYS.js +10 -0
  73. package/dist/database-field-F47FY3XX.js +10 -0
  74. package/dist/database-row-77OXW2NF.js +10 -0
  75. package/dist/database-select-option-6S3TTA7A.js +10 -0
  76. package/dist/database-view-YW7DQG5X.js +10 -0
  77. package/dist/experiment-TJOAL3OH.js +10 -0
  78. package/dist/external-item-D654PKLI.js +14 -0
  79. package/dist/external-reference-K5SUJIQN.js +8 -0
  80. package/dist/feed-L23XTNDI.js +12 -0
  81. package/dist/feed-item-GSO242J6.js +12 -0
  82. package/dist/folder-ONKSWHUT.js +21 -0
  83. package/dist/game-BF7DP5JU.js +50 -0
  84. package/dist/grant-NNKMWXPX.js +8 -0
  85. package/dist/grant-expiration-cleaner-DBiNTWbD.d.ts +249 -0
  86. package/dist/import-batch-JMESZ4VI.js +12 -0
  87. package/dist/inbox-state-AN6FPCIY.js +12 -0
  88. package/dist/index.d.ts +224 -4548
  89. package/dist/index.js +2206 -4754
  90. package/dist/map-AUV65YS3.js +10 -0
  91. package/dist/media-asset-4I5YPR4R.js +8 -0
  92. package/dist/memory-NV6EVJBE.js +12 -0
  93. package/dist/metric-X7W55DLC.js +10 -0
  94. package/dist/milestone-JJGOGK4R.js +12 -0
  95. package/dist/moderation-QSUVBCNS.js +30 -0
  96. package/dist/observation-UZSXXGBC.js +10 -0
  97. package/dist/page-NI7XODS6.js +10 -0
  98. package/dist/posting-FZOYVGH2.js +12 -0
  99. package/dist/profile-42A43GES.js +8 -0
  100. package/dist/project-G2CTLDXY.js +10 -0
  101. package/dist/query-ast-CWo6_30h.d.ts +226 -0
  102. package/dist/reaction-VAQBVDUD.js +10 -0
  103. package/dist/registry-CQoN_p8U.d.ts +99 -0
  104. package/dist/saved-view-AOQHGHNM.js +10 -0
  105. package/dist/schema/index.d.ts +6182 -0
  106. package/dist/schema/index.js +631 -0
  107. package/dist/schema-extension-5BUXRDPB.js +18 -0
  108. package/dist/space-PZ737CIS.js +42 -0
  109. package/dist/space-membership-N35NRX6F.js +14 -0
  110. package/dist/store/index.d.ts +391 -0
  111. package/dist/store/index.js +135 -0
  112. package/dist/store-CvgiydME.d.ts +338 -0
  113. package/dist/sync/awareness.d.ts +69 -0
  114. package/dist/sync/awareness.js +20 -0
  115. package/dist/system-Q5I6STDC.js +38 -0
  116. package/dist/tag-C677GKQW.js +16 -0
  117. package/dist/task-WQLMPN5U.js +16 -0
  118. package/dist/task-view-T5S32V4L.js +10 -0
  119. package/dist/transaction-U3ITRGJP.js +12 -0
  120. package/dist/transcription-F3T23LLO.js +12 -0
  121. package/dist/types-Def-5Nka.d.ts +1525 -0
  122. package/dist/updates.d.ts +44 -0
  123. package/dist/updates.js +16 -0
  124. package/dist/user-widget-4SJJFPG5.js +8 -0
  125. package/dist/view-types-DSde-uT_.d.ts +316 -0
  126. package/package.json +32 -9
  127. package/dist/canvas-HSIKIQFK.js +0 -7
  128. package/dist/chunk-2L5ZUGG5.js +0 -53
  129. package/dist/chunk-4MTS5KAQ.js +0 -22
  130. package/dist/chunk-GZHARFKC.js +0 -25
  131. package/dist/chunk-WKIKJTI2.js +0 -45
  132. package/dist/comment-277JD7DV.js +0 -7
  133. package/dist/database-W3KEHLI3.js +0 -7
  134. package/dist/database-row-3O2QSNZN.js +0 -7
  135. package/dist/grant-QVZ454YC.js +0 -7
  136. package/dist/page-O4WTOIEO.js +0 -7
  137. package/dist/task-SEKAYJH7.js +0 -7
@@ -0,0 +1,2205 @@
1
+ import { ao as NodeQueryMaterializedViewOptions, h as NodeState, B as PropertyType, S as SchemaIRI, a as Schema } from './types-Def-5Nka.js';
2
+ import { N as NodeStore } from './store-CvgiydME.js';
3
+ import { c as ColumnDefinition, C as ColumnType, d as ColumnConfig, f as SelectColor, i as isNodeStoreColumnType, h as isComputedColumnType, j as isAutoColumnType, k as isYDocColumnType, V as ViewType, m as FilterGroup, p as SortConfig, l as ViewConfig, o as FilterOperator, g as RollupAggregation, a as RollupColumnConfig } from './view-types-DSde-uT_.js';
4
+ import * as Y from 'yjs';
5
+
6
+ /**
7
+ * Cell value types for database rows.
8
+ *
9
+ * Cell values are stored as dynamic properties on DatabaseRow nodes,
10
+ * keyed by column ID with a `cell_` prefix to avoid collisions with
11
+ * schema-defined properties.
12
+ */
13
+ /**
14
+ * Reference to a file stored in the system.
15
+ * Same shape as the blob-layer FileRef (schema/properties/file.ts):
16
+ * content-addressed, resolved to URLs through the BlobService.
17
+ */
18
+ interface FileRef {
19
+ /** Content-addressed ID (CID) of the file */
20
+ cid: string;
21
+ /** Original file name */
22
+ name: string;
23
+ /** MIME type */
24
+ mimeType: string;
25
+ /** File size in bytes */
26
+ size: number;
27
+ }
28
+ /**
29
+ * A date range with start and end dates.
30
+ */
31
+ interface DateRange {
32
+ /** Start date (ISO 8601 string) */
33
+ start: string;
34
+ /** End date (ISO 8601 string) */
35
+ end: string;
36
+ }
37
+ /**
38
+ * All possible cell value types.
39
+ *
40
+ * - string: text, url, email, phone, select (option ID), person (DID)
41
+ * - number: number
42
+ * - boolean: checkbox
43
+ * - string (ISO 8601): date
44
+ * - DateRange: dateRange
45
+ * - string[]: multiSelect (option IDs), relation (row IDs)
46
+ * - FileRef: file
47
+ * - null: empty cell
48
+ */
49
+ type CellValue = string | number | boolean | DateRange | string[] | FileRef | null;
50
+ /**
51
+ * Prefix for cell value property keys.
52
+ * This prevents collisions with schema-defined properties like 'database' and 'sortKey'.
53
+ */
54
+ declare const CELL_PREFIX = "cell_";
55
+ /**
56
+ * Convert a column ID to a cell property key.
57
+ *
58
+ * @example
59
+ * cellKey('name') // 'cell_name'
60
+ * cellKey('status') // 'cell_status'
61
+ */
62
+ declare function cellKey(columnId: string): string;
63
+ /**
64
+ * Check if a property key is a cell value key.
65
+ *
66
+ * @example
67
+ * isCellKey('cell_name') // true
68
+ * isCellKey('database') // false
69
+ */
70
+ declare function isCellKey(key: string): boolean;
71
+ /**
72
+ * Extract the column ID from a cell property key.
73
+ *
74
+ * @example
75
+ * columnIdFromKey('cell_name') // 'name'
76
+ * columnIdFromKey('cell_status') // 'status'
77
+ */
78
+ declare function columnIdFromKey(key: string): string;
79
+ /**
80
+ * Convert a record of column ID -> value to cell key -> value.
81
+ *
82
+ * @example
83
+ * toCellProperties({ name: 'John', age: 30 })
84
+ * // { cell_name: 'John', cell_age: 30 }
85
+ */
86
+ declare function toCellProperties(cells: Record<string, CellValue>): Record<string, CellValue>;
87
+ /**
88
+ * Extract cell values from a node's properties, converting cell keys back to column IDs.
89
+ *
90
+ * @example
91
+ * fromCellProperties({ cell_name: 'John', cell_age: 30, database: 'db1' })
92
+ * // { name: 'John', age: 30 }
93
+ */
94
+ declare function fromCellProperties(properties: Record<string, unknown>): Record<string, CellValue>;
95
+ /**
96
+ * Check if a value is a valid DateRange.
97
+ */
98
+ declare function isDateRange(value: unknown): value is DateRange;
99
+ /**
100
+ * Check if a value is a valid FileRef.
101
+ */
102
+ declare function isFileRef(value: unknown): value is FileRef;
103
+ /**
104
+ * Check if a value is a valid CellValue.
105
+ */
106
+ declare function isCellValue(value: unknown): value is CellValue;
107
+
108
+ /**
109
+ * Row CRUD operations for database rows.
110
+ *
111
+ * These functions provide a high-level API for creating, updating,
112
+ * and querying database rows. They handle:
113
+ * - Cell value storage with column ID prefixes
114
+ * - Sort key generation for row ordering
115
+ * - Database row count maintenance
116
+ */
117
+
118
+ /**
119
+ * Options for creating a new row.
120
+ */
121
+ interface CreateRowOptions {
122
+ /** Parent database ID */
123
+ databaseId: string;
124
+ /** Initial cell values (columnId -> value) */
125
+ cells?: Record<string, CellValue>;
126
+ /**
127
+ * Insert position: before this row's sortKey.
128
+ * If neither before nor after is specified, appends to end.
129
+ */
130
+ before?: string;
131
+ /**
132
+ * Insert position: after this row's sortKey.
133
+ * If neither before nor after is specified, appends to end.
134
+ */
135
+ after?: string;
136
+ }
137
+ /**
138
+ * Options for querying rows.
139
+ */
140
+ interface QueryRowsOptions {
141
+ /** Maximum number of rows to return */
142
+ limit?: number;
143
+ /** Offset for page-based pagination */
144
+ offset?: number;
145
+ /** Cursor for pagination (sortKey of last row from previous page) */
146
+ cursor?: string;
147
+ /** Property to sort by (default: 'sortKey') */
148
+ sortBy?: string;
149
+ /** Sort direction (default: 'asc') */
150
+ sortDirection?: 'asc' | 'desc';
151
+ /** Stable materialized row-list cache for persisted database views */
152
+ materializedView?: string | NodeQueryMaterializedViewOptions;
153
+ }
154
+ /**
155
+ * Result of a row query.
156
+ */
157
+ interface QueryRowsResult {
158
+ /** The rows matching the query */
159
+ rows: DatabaseRowNode[];
160
+ /** Cursor for the next page (undefined if no more rows) */
161
+ cursor?: string;
162
+ /** Whether there are more rows after this page */
163
+ hasMore: boolean;
164
+ }
165
+ /**
166
+ * A database row node with extracted cell values.
167
+ */
168
+ interface DatabaseRowNode extends NodeState {
169
+ /** Extracted cell values (columnId -> value) */
170
+ cells: Record<string, CellValue>;
171
+ }
172
+ /**
173
+ * Create a new row in a database.
174
+ *
175
+ * @example
176
+ * ```typescript
177
+ * const rowId = await createRow(store, {
178
+ * databaseId: 'db_abc123',
179
+ * cells: {
180
+ * name: 'John Doe',
181
+ * status: 'active',
182
+ * priority: 3
183
+ * }
184
+ * })
185
+ * ```
186
+ */
187
+ declare function createRow(store: NodeStore, options: CreateRowOptions): Promise<string>;
188
+ /**
189
+ * Update a single cell value in a row.
190
+ *
191
+ * @example
192
+ * ```typescript
193
+ * await updateCell(store, rowId, 'status', 'completed')
194
+ * ```
195
+ */
196
+ declare function updateCell(store: NodeStore, rowId: string, columnId: string, value: CellValue): Promise<void>;
197
+ /**
198
+ * Update multiple cell values in a row.
199
+ *
200
+ * @example
201
+ * ```typescript
202
+ * await updateCells(store, rowId, {
203
+ * name: 'Jane Doe',
204
+ * status: 'active'
205
+ * })
206
+ * ```
207
+ */
208
+ declare function updateCells(store: NodeStore, rowId: string, cells: Record<string, CellValue>): Promise<void>;
209
+ /**
210
+ * Delete a row from a database.
211
+ *
212
+ * @example
213
+ * ```typescript
214
+ * await deleteRow(store, rowId)
215
+ * ```
216
+ */
217
+ declare function deleteRow(store: NodeStore, rowId: string): Promise<void>;
218
+ /**
219
+ * Get a single row by ID with extracted cell values.
220
+ *
221
+ * @example
222
+ * ```typescript
223
+ * const row = await getRow(store, rowId)
224
+ * console.log(row.cells.name) // 'John Doe'
225
+ * ```
226
+ */
227
+ declare function getRow(store: NodeStore, rowId: string): Promise<DatabaseRowNode | null>;
228
+ /**
229
+ * Query rows for a database with pagination.
230
+ *
231
+ * @example
232
+ * ```typescript
233
+ * const { rows, hasMore, cursor } = await queryRows(store, databaseId, {
234
+ * limit: 50
235
+ * })
236
+ *
237
+ * // Get next page
238
+ * if (hasMore) {
239
+ * const nextPage = await queryRows(store, databaseId, {
240
+ * limit: 50,
241
+ * cursor
242
+ * })
243
+ * }
244
+ * ```
245
+ */
246
+ declare function queryRows(store: NodeStore, databaseId: string, options?: QueryRowsOptions): Promise<QueryRowsResult>;
247
+ /**
248
+ * Move a row to a new position.
249
+ *
250
+ * @example
251
+ * ```typescript
252
+ * // Move row between two other rows
253
+ * await moveRow(store, rowId, {
254
+ * after: 'row_abc',
255
+ * before: 'row_xyz'
256
+ * })
257
+ * ```
258
+ */
259
+ declare function moveRow(store: NodeStore, rowId: string, position: {
260
+ before?: string;
261
+ after?: string;
262
+ }): Promise<void>;
263
+ /**
264
+ * Rebalance all rows in a database.
265
+ * Use this when sort keys get too long (> 10 chars) due to many
266
+ * insertions at the same position.
267
+ *
268
+ * @example
269
+ * ```typescript
270
+ * if (await checkNeedsRebalancing(store, databaseId)) {
271
+ * await rebalanceDatabase(store, databaseId)
272
+ * }
273
+ * ```
274
+ */
275
+ declare function rebalanceDatabase(store: NodeStore, databaseId: string): Promise<void>;
276
+ /**
277
+ * Check if a database needs rebalancing.
278
+ * Returns true if any sort key exceeds the maximum recommended length.
279
+ *
280
+ * @param maxKeyLength - Maximum key length before rebalancing (default: 10)
281
+ */
282
+ declare function checkNeedsRebalancing(store: NodeStore, databaseId: string, maxKeyLength?: number): Promise<boolean>;
283
+
284
+ /**
285
+ * Fractional indexing for O(1) row ordering.
286
+ *
287
+ * Row order uses fractional indexing instead of array positions. Each row has
288
+ * a `sortKey` string that can be sorted lexicographically. Inserting between
289
+ * two rows generates a key that sorts between them, without updating any other rows.
290
+ *
291
+ * This approach is used by Figma, Linear, and other collaborative apps because
292
+ * it enables O(1) insert/reorder operations and works naturally with database
293
+ * queries (`ORDER BY sort_key`).
294
+ *
295
+ * @example
296
+ * ```typescript
297
+ * generateSortKey() // "a0" - first key
298
+ * generateSortKey("a0") // "a1" - append
299
+ * generateSortKey("a0", "a1") // "a0V" - insert between
300
+ * ```
301
+ */
302
+ /**
303
+ * Generate a sort key that orders between `before` and `after`.
304
+ *
305
+ * @param before - The key to sort after (or undefined for start)
306
+ * @param after - The key to sort before (or undefined for end)
307
+ * @returns A new key that sorts between before and after
308
+ *
309
+ * @example
310
+ * ```typescript
311
+ * generateSortKey() // "a0" - first key
312
+ * generateSortKey("a0") // "a1" - append
313
+ * generateSortKey(undefined, "a0") // key before a0
314
+ * generateSortKey("a0", "a1") // "a0V" - insert between
315
+ * ```
316
+ */
317
+ declare function generateSortKey(before?: string, after?: string): string;
318
+ /**
319
+ * Generate a sort key with random jitter to prevent collisions.
320
+ * Use this in high-concurrency scenarios where multiple users might
321
+ * insert at the same position simultaneously.
322
+ *
323
+ * @param before - The key to sort after (or undefined for start)
324
+ * @param after - The key to sort before (or undefined for end)
325
+ * @returns A new key with random suffix
326
+ */
327
+ declare function generateSortKeyWithJitter(before?: string, after?: string): string;
328
+ /**
329
+ * Validate that a key is well-formed.
330
+ */
331
+ declare function isValidSortKey(key: string): boolean;
332
+ /**
333
+ * Compare two sort keys.
334
+ * Returns negative if a < b, positive if a > b, 0 if equal.
335
+ *
336
+ * Uses simple string comparison (not locale-aware) to ensure
337
+ * consistent ordering across all environments.
338
+ */
339
+ declare function compareSortKeys(a: string, b: string): number;
340
+ /**
341
+ * Rebalance sort keys for a set of rows.
342
+ * Generates evenly-spaced keys for all rows.
343
+ *
344
+ * Use this when sort keys get too long (> 10 chars) due to many
345
+ * insertions at the same position.
346
+ *
347
+ * @param rowIds - Row IDs in current sorted order
348
+ * @returns Map of rowId -> new sortKey
349
+ *
350
+ * @example
351
+ * ```typescript
352
+ * const newKeys = rebalanceSortKeys(['row1', 'row2', 'row3'])
353
+ * // Map { 'row1' => '0U', 'row2' => '0q', 'row3' => '1C' }
354
+ * ```
355
+ */
356
+ declare function rebalanceSortKeys(rowIds: string[]): Map<string, string>;
357
+ /**
358
+ * Get the maximum recommended key length before rebalancing.
359
+ */
360
+ declare const MAX_KEY_LENGTH = 10;
361
+ /**
362
+ * Check if any keys in a list exceed the maximum recommended length.
363
+ */
364
+ declare function needsRebalancing(sortKeys: string[]): boolean;
365
+
366
+ /**
367
+ * Rich text cell support for database rows.
368
+ *
369
+ * Rich text cells use the row's Y.Doc for collaborative editing.
370
+ * Each rich text column gets its own Y.XmlFragment in the doc,
371
+ * which supports TipTap/ProseMirror content.
372
+ *
373
+ * Not every row needs a Y.Doc - only rows with rich text columns.
374
+ * This is determined by the database's column definitions.
375
+ */
376
+
377
+ /**
378
+ * Prefix for rich text cell fragments in the Y.Doc.
379
+ */
380
+ declare const RICHTEXT_PREFIX = "richtext_";
381
+ /**
382
+ * Get or create a rich text cell in the row's Y.Doc.
383
+ * The XML fragment supports TipTap/ProseMirror content.
384
+ *
385
+ * @example
386
+ * ```typescript
387
+ * const doc = await store.getOrCreateDoc(rowId)
388
+ * const fragment = getRichTextCell(doc, 'notes')
389
+ *
390
+ * // Use with TipTap editor
391
+ * const editor = new Editor({
392
+ * extensions: [Collaboration.configure({ fragment })]
393
+ * })
394
+ * ```
395
+ */
396
+ declare function getRichTextCell(doc: Y.Doc, columnId: string): Y.XmlFragment;
397
+ /**
398
+ * Check if a row has any rich text content for a specific column.
399
+ */
400
+ declare function hasRichTextContent(doc: Y.Doc, columnId: string): boolean;
401
+ /**
402
+ * Check if any columns in the list are rich text columns.
403
+ * Used to decide whether to create/sync a Y.Doc for a row.
404
+ *
405
+ * @example
406
+ * ```typescript
407
+ * const columns = await getColumns(databaseId)
408
+ * if (hasRichTextColumns(columns)) {
409
+ * // Row needs a Y.Doc
410
+ * const doc = await store.getOrCreateDoc(rowId)
411
+ * }
412
+ * ```
413
+ */
414
+ declare function hasRichTextColumns(columns: ColumnDefinition[]): boolean;
415
+ /**
416
+ * Get all rich text column IDs from a list of columns.
417
+ */
418
+ declare function getRichTextColumnIds(columns: ColumnDefinition[]): string[];
419
+ /**
420
+ * Delete a rich text cell from the row's Y.Doc.
421
+ * Used when a rich text column is deleted.
422
+ */
423
+ declare function deleteRichTextCell(doc: Y.Doc, columnId: string): void;
424
+ /**
425
+ * Get plain text content from a rich text cell.
426
+ * Useful for search indexing and previews.
427
+ */
428
+ declare function getRichTextPlainText(doc: Y.Doc, columnId: string): string;
429
+
430
+ /**
431
+ * Field type definitions for the V2 database model.
432
+ *
433
+ * V2 stores fields as first-class DatabaseField nodes (see
434
+ * schema/schemas/database-field.ts) ordered by fractional sortKey, rather
435
+ * than as Y.Array entries in the database Y.Doc. The type/config unions are
436
+ * shared with the legacy column model (column-types.ts) so the pure engines
437
+ * (filter/sort/group/rollup/formula) work unchanged.
438
+ *
439
+ * Select/multiSelect options are NOT part of the field config in V2 — they
440
+ * are DatabaseSelectOption nodes keyed by `field`, so concurrent option
441
+ * creation merges cleanly. SelectFieldConfig retains only behavioral flags.
442
+ */
443
+
444
+ /** All supported field types. */
445
+ type FieldType = ColumnType;
446
+ /** Type-specific field configuration. */
447
+ type FieldConfig = ColumnConfig;
448
+
449
+ /** Valid field type values, for runtime enforcement in field-operations. */
450
+ declare const FIELD_TYPES: readonly FieldType[];
451
+ declare function isFieldType(value: unknown): value is FieldType;
452
+ /** Valid select option colors. */
453
+ declare const SELECT_COLORS: readonly SelectColor[];
454
+ declare function isSelectColor(value: unknown): value is SelectColor;
455
+ /**
456
+ * Pick a deterministic color for a new option from its name, so
457
+ * typeahead-created tags get stable, pleasant colors without a picker.
458
+ */
459
+ declare function autoColor(name: string): SelectColor;
460
+ declare const isNodeStoreFieldType: typeof isNodeStoreColumnType;
461
+ declare const isComputedFieldType: typeof isComputedColumnType;
462
+ declare const isAutoFieldType: typeof isAutoColumnType;
463
+ declare const isYDocFieldType: typeof isYDocColumnType;
464
+ /** A DatabaseField node narrowed with typed properties access. */
465
+ interface FieldNode {
466
+ id: string;
467
+ database: string;
468
+ name: string;
469
+ type: FieldType;
470
+ config: FieldConfig;
471
+ sortKey: string;
472
+ width?: number;
473
+ isTitle?: boolean;
474
+ hidden?: boolean;
475
+ }
476
+ /** A DatabaseSelectOption node narrowed for picker use. */
477
+ interface SelectOptionNode {
478
+ id: string;
479
+ field: string;
480
+ database: string;
481
+ name: string;
482
+ color?: SelectColor;
483
+ sortKey: string;
484
+ }
485
+ /** Extract a FieldNode from a raw node's properties. */
486
+ declare function toFieldNode(node: {
487
+ id: string;
488
+ properties: Record<string, unknown>;
489
+ }): FieldNode;
490
+ /** Extract a SelectOptionNode from a raw node's properties. */
491
+ declare function toSelectOptionNode(node: {
492
+ id: string;
493
+ properties: Record<string, unknown>;
494
+ }): SelectOptionNode;
495
+
496
+ /**
497
+ * Field CRUD operations for the V2 database model.
498
+ *
499
+ * Fields are DatabaseField nodes; select options are DatabaseSelectOption
500
+ * nodes. Ordering uses the same fractional indexing scheme as rows, so
501
+ * reorders are O(1) single-property updates that merge under LWW.
502
+ */
503
+
504
+ interface CreateFieldOptions {
505
+ /** Parent database ID */
506
+ databaseId: string;
507
+ /** Display name */
508
+ name: string;
509
+ /** Field type */
510
+ type: FieldType;
511
+ /** Type-specific configuration */
512
+ config?: FieldConfig;
513
+ /** Default column width */
514
+ width?: number;
515
+ /** Whether this is the title field */
516
+ isTitle?: boolean;
517
+ /** Insert position: before this field's sortKey */
518
+ before?: string;
519
+ /** Insert position: after this field's sortKey */
520
+ after?: string;
521
+ }
522
+ interface UpdateFieldOptions {
523
+ name?: string;
524
+ type?: FieldType;
525
+ config?: FieldConfig;
526
+ width?: number;
527
+ isTitle?: boolean;
528
+ hidden?: boolean;
529
+ }
530
+ interface CreateSelectOptionOptions {
531
+ /** Parent field ID */
532
+ fieldId: string;
533
+ /** Option display name */
534
+ name: string;
535
+ /** Option color (auto-derived from name when omitted) */
536
+ color?: SelectColor;
537
+ }
538
+ /**
539
+ * Get all fields for a database, ordered by sortKey.
540
+ */
541
+ declare function getFields(store: NodeStore, databaseId: string): Promise<FieldNode[]>;
542
+ /**
543
+ * Get a single field by ID.
544
+ */
545
+ declare function getField(store: NodeStore, fieldId: string): Promise<FieldNode | null>;
546
+ /**
547
+ * Get the title field for a database.
548
+ */
549
+ declare function getTitleField(store: NodeStore, databaseId: string): Promise<FieldNode | null>;
550
+ /**
551
+ * Create a new field. Returns the new field's node ID.
552
+ *
553
+ * @example
554
+ * ```typescript
555
+ * const fieldId = await createField(store, {
556
+ * databaseId,
557
+ * name: 'Status',
558
+ * type: 'select'
559
+ * })
560
+ * ```
561
+ */
562
+ declare function createField(store: NodeStore, options: CreateFieldOptions): Promise<string>;
563
+ /**
564
+ * Update a field's properties. Only provided keys are written, so
565
+ * concurrent edits to different aspects (rename vs resize) merge cleanly.
566
+ */
567
+ declare function updateField(store: NodeStore, fieldId: string, updates: UpdateFieldOptions): Promise<void>;
568
+ /**
569
+ * Delete a field and its select options.
570
+ *
571
+ * Cell values under the field's `cell_<id>` key are left in place on rows
572
+ * (orphaned data is invisible and avoids a full-table write storm — the
573
+ * same call Notion makes).
574
+ */
575
+ declare function deleteField(store: NodeStore, fieldId: string): Promise<void>;
576
+ /**
577
+ * Move a field to a new position via fractional index.
578
+ *
579
+ * @example
580
+ * ```typescript
581
+ * await moveField(store, fieldId, { after: fieldA.sortKey, before: fieldB.sortKey })
582
+ * ```
583
+ */
584
+ declare function moveField(store: NodeStore, fieldId: string, position: {
585
+ before?: string;
586
+ after?: string;
587
+ }): Promise<void>;
588
+ /**
589
+ * Duplicate a field (its select options included).
590
+ * Returns the new field's node ID, positioned right after the source.
591
+ */
592
+ declare function duplicateField(store: NodeStore, fieldId: string, newName?: string): Promise<string | null>;
593
+ /**
594
+ * Get all options for a select/multiSelect field, ordered by sortKey.
595
+ */
596
+ declare function getSelectOptions(store: NodeStore, fieldId: string): Promise<SelectOptionNode[]>;
597
+ /**
598
+ * Create a select option (the typeahead "+ Create" path).
599
+ * Returns the new option's node ID.
600
+ *
601
+ * Concurrent creates from multiple collaborators are safe by construction:
602
+ * each create is an independent node.
603
+ */
604
+ declare function createSelectOption(store: NodeStore, options: CreateSelectOptionOptions): Promise<string>;
605
+ /**
606
+ * Get all options for every select field of a database in one query.
607
+ */
608
+ declare function getDatabaseSelectOptions(store: NodeStore, databaseId: string): Promise<SelectOptionNode[]>;
609
+ /**
610
+ * Rename or recolor an option.
611
+ */
612
+ declare function updateSelectOption(store: NodeStore, optionId: string, updates: {
613
+ name?: string;
614
+ color?: SelectColor;
615
+ }): Promise<void>;
616
+ /**
617
+ * Delete an option. Cells referencing the option keep the dangling ID;
618
+ * renderers must drop unknown option IDs (same behavior as deleted rows
619
+ * in relation cells).
620
+ */
621
+ declare function deleteSelectOption(store: NodeStore, optionId: string): Promise<void>;
622
+ /**
623
+ * Reorder an option via fractional index.
624
+ */
625
+ declare function moveSelectOption(store: NodeStore, optionId: string, position: {
626
+ before?: string;
627
+ after?: string;
628
+ }): Promise<void>;
629
+
630
+ /**
631
+ * Extension field operations — create / list / reorder / delete the custom
632
+ * columns a user adds to an existing schema.
633
+ *
634
+ * These mirror `field-operations.ts` (which manage `DatabaseField` columns for
635
+ * free-form databases) but operate on `ExtensionField` nodes keyed to a
636
+ * `SchemaExtension`. The "+ Add field" affordance on a typed schema's grid
637
+ * calls `createExtensionField`; core (schema-defined) columns are structurally
638
+ * locked and routed nowhere — only extension fields are mutable.
639
+ */
640
+
641
+ interface EnsureExtensionOptions {
642
+ /** Versioned (or base) IRI of the schema being extended. */
643
+ targetSchema: string;
644
+ /** Namespace authority that owns the overlay (Space id, DID, or domain). */
645
+ authority: string;
646
+ /** Human label for the extension set. */
647
+ label?: string;
648
+ /** Optional owning Space for the authorization cascade. */
649
+ space?: string;
650
+ }
651
+ /**
652
+ * Ensure a `SchemaExtension` exists for `(authority, targetSchema)` and return
653
+ * its id. Uses the deterministic id so repeated calls upsert rather than fork.
654
+ */
655
+ declare function ensureSchemaExtension(store: NodeStore, options: EnsureExtensionOptions): Promise<string>;
656
+ interface CreateExtensionFieldOptions {
657
+ targetSchema: string;
658
+ authority: string;
659
+ /** Field token — the `<field>` segment; must be a valid extension field name. */
660
+ name: string;
661
+ /** Field type (FieldType union). */
662
+ type: string;
663
+ config?: Record<string, unknown>;
664
+ width?: number;
665
+ space?: string;
666
+ }
667
+ /**
668
+ * Add a custom column to a schema. Returns the new `ExtensionField` node id.
669
+ * The resulting overlay property key on target nodes is
670
+ * `ext:<authority>/<name>`.
671
+ *
672
+ * @throws if `type` is not a valid field type, or `name` is not a valid
673
+ * extension field token.
674
+ */
675
+ declare function createExtensionField(store: NodeStore, options: CreateExtensionFieldOptions): Promise<{
676
+ fieldId: string;
677
+ key: string;
678
+ }>;
679
+ /** Rename an extension field's display token (does not change the stored key). */
680
+ declare function renameExtensionField(store: NodeStore, fieldId: string, name: string): Promise<void>;
681
+ /** Delete (soft) an extension field. Does not remove overlay values on nodes. */
682
+ declare function deleteExtensionField(store: NodeStore, fieldId: string): Promise<void>;
683
+
684
+ /**
685
+ * View CRUD operations for the V2 database model.
686
+ *
687
+ * Views are DatabaseView nodes. Each concern (filters, sorts, grouping,
688
+ * per-view layout overrides) is a separate property, so concurrent edits
689
+ * to different concerns merge cleanly under per-property LWW.
690
+ */
691
+
692
+ /**
693
+ * A database view, read from a DatabaseView node.
694
+ *
695
+ * This is the single ViewConfig shape for V2 — the `@xnetjs/views` dialect
696
+ * (visibleProperties/propertyWidths) is retired.
697
+ */
698
+ interface ViewNode {
699
+ id: string;
700
+ database: string;
701
+ name: string;
702
+ type: ViewType;
703
+ filters?: FilterGroup | null;
704
+ sorts?: SortConfig[];
705
+ groupBy?: string | null;
706
+ groupSort?: 'asc' | 'desc';
707
+ collapsedGroups?: string[];
708
+ /** Per-view field order overrides: fieldId -> fractional sortKey */
709
+ fieldOrder?: Record<string, string>;
710
+ /** Per-view width overrides: fieldId -> px */
711
+ fieldWidths?: Record<string, number>;
712
+ /** Per-view hidden fields */
713
+ hiddenFields?: string[];
714
+ /** View tab order */
715
+ sortKey: string;
716
+ coverField?: string;
717
+ cardSize?: 'small' | 'medium' | 'large';
718
+ dateField?: string;
719
+ endDateField?: string;
720
+ }
721
+ interface CreateViewOptions {
722
+ databaseId: string;
723
+ name: string;
724
+ type: ViewType;
725
+ /** Insert position among view tabs */
726
+ before?: string;
727
+ after?: string;
728
+ }
729
+ type UpdateViewOptions = Partial<Omit<ViewNode, 'id' | 'database' | 'sortKey'>>;
730
+ /**
731
+ * Get all views for a database, ordered by tab sortKey.
732
+ */
733
+ declare function getViews$1(store: NodeStore, databaseId: string): Promise<ViewNode[]>;
734
+ /**
735
+ * Get a single view by ID.
736
+ */
737
+ declare function getView$1(store: NodeStore, viewId: string): Promise<ViewNode | null>;
738
+ /**
739
+ * Create a view. Returns the new view's node ID.
740
+ */
741
+ declare function createView$1(store: NodeStore, options: CreateViewOptions): Promise<string>;
742
+ /**
743
+ * Update view properties. Only provided keys are written.
744
+ */
745
+ declare function updateView$1(store: NodeStore, viewId: string, updates: UpdateViewOptions): Promise<void>;
746
+ /**
747
+ * Delete a view.
748
+ */
749
+ declare function deleteView$1(store: NodeStore, viewId: string): Promise<void>;
750
+ /**
751
+ * Duplicate a view (all configuration copied), positioned after the source.
752
+ * Returns the new view's node ID.
753
+ */
754
+ declare function duplicateView$1(store: NodeStore, viewId: string, newName?: string): Promise<string | null>;
755
+ /**
756
+ * Move a view tab via fractional index.
757
+ */
758
+ declare function moveView(store: NodeStore, viewId: string, position: {
759
+ before?: string;
760
+ after?: string;
761
+ }): Promise<void>;
762
+ declare function setViewFilters$1(store: NodeStore, viewId: string, filters: FilterGroup | null): Promise<void>;
763
+ declare function setViewSorts$1(store: NodeStore, viewId: string, sorts: SortConfig[]): Promise<void>;
764
+ declare function setViewGroupBy$1(store: NodeStore, viewId: string, groupBy: string | null, groupSort?: 'asc' | 'desc'): Promise<void>;
765
+ declare function toggleViewGroupCollapsed(store: NodeStore, viewId: string, groupKey: string): Promise<void>;
766
+ /**
767
+ * Hide/show a field in this view.
768
+ */
769
+ declare function setFieldHidden(store: NodeStore, viewId: string, fieldId: string, hidden: boolean): Promise<void>;
770
+ /**
771
+ * Set a per-view column width override.
772
+ */
773
+ declare function setViewFieldWidth(store: NodeStore, viewId: string, fieldId: string, width: number): Promise<void>;
774
+ /**
775
+ * Set a per-view field order override (fractional key among the view's
776
+ * effective field order).
777
+ */
778
+ declare function setViewFieldOrder(store: NodeStore, viewId: string, fieldId: string, sortKey: string): Promise<void>;
779
+ /**
780
+ * Compute the effective field order for a view: per-view fieldOrder
781
+ * overrides win, otherwise the field's own sortKey.
782
+ */
783
+ declare function effectiveFieldSortKey(view: Pick<ViewNode, 'fieldOrder'>, field: {
784
+ id: string;
785
+ sortKey: string;
786
+ }): string;
787
+
788
+ /**
789
+ * Cell value conversion for field type changes (exploration 0159,
790
+ * spreadsheet-UX follow-up).
791
+ *
792
+ * When a field is retyped, existing cell values convert rather than
793
+ * orphan: numeric strings become numbers, comma-separated text becomes
794
+ * multi-select names, option IDs stringify back to their names, etc.
795
+ *
796
+ * Pure: select/multiSelect targets return the *names* to resolve —
797
+ * the caller creates/looks up SelectOption nodes and maps names to IDs.
798
+ */
799
+
800
+ interface ConvertContext {
801
+ /** Resolve an option ID to its display name (source select fields) */
802
+ optionName?: (id: string) => string | undefined;
803
+ }
804
+ interface ConvertedCell {
805
+ /** The converted value (null clears the cell) */
806
+ value: CellValue;
807
+ /**
808
+ * For select/multiSelect targets: display names that need resolving to
809
+ * option IDs (create-if-missing). The caller replaces `value` with the
810
+ * resolved ID(s).
811
+ */
812
+ optionNames?: string[];
813
+ }
814
+ /** Render any cell value as plain text (the universal intermediate). */
815
+ declare function cellValueToText(value: CellValue, sourceType: FieldType, ctx?: ConvertContext): string;
816
+ /**
817
+ * Convert a cell value from one field type to another.
818
+ * Unconvertible values become null (never garbage).
819
+ */
820
+ declare function convertCellValue(value: CellValue, sourceType: FieldType, targetType: FieldType, ctx?: ConvertContext): ConvertedCell;
821
+
822
+ /**
823
+ * New-database setup for the V2 node model.
824
+ *
825
+ * Replaces the Y.Doc-based setupNewDatabase (database-doc.ts): a fresh
826
+ * database gets a title field and a default table view as nodes.
827
+ */
828
+
829
+ interface SetupDatabaseResult {
830
+ titleFieldId: string;
831
+ defaultViewId: string;
832
+ }
833
+ /**
834
+ * Initialize a freshly created database with its default structure:
835
+ * a "Name" title field and a "Table" view.
836
+ *
837
+ * Idempotent: skips creation when a title field / view already exists
838
+ * (e.g. when two clients race to initialize a synced database).
839
+ */
840
+ declare function setupDatabase(store: NodeStore, databaseId: string): Promise<SetupDatabaseResult>;
841
+
842
+ /**
843
+ * Database Schema Utilities
844
+ *
845
+ * Utilities for generating unique, versioned schema IRIs for databases
846
+ * and managing schema metadata stored in Y.Doc.
847
+ */
848
+
849
+ /**
850
+ * Schema metadata stored in a database's Y.Doc.
851
+ */
852
+ interface DatabaseSchemaMetadata {
853
+ /** User-editable schema name */
854
+ name: string;
855
+ /** Optional description */
856
+ description?: string;
857
+ /** Semver version (auto-incremented) */
858
+ version: string;
859
+ /** When the database was created */
860
+ createdAt: number;
861
+ /** Last column modification time */
862
+ updatedAt: number;
863
+ }
864
+ /**
865
+ * A stored column in a database's Y.Doc.
866
+ */
867
+ interface StoredColumn {
868
+ id: string;
869
+ name: string;
870
+ type: PropertyType;
871
+ config?: Record<string, unknown>;
872
+ }
873
+ /**
874
+ * Schema version history entry.
875
+ */
876
+ interface SchemaVersionEntry {
877
+ version: string;
878
+ timestamp: number;
879
+ columns: StoredColumn[];
880
+ changeType: 'initial' | 'add' | 'update' | 'delete';
881
+ changeDescription?: string;
882
+ }
883
+ /**
884
+ * Type of version bump.
885
+ */
886
+ type VersionBumpType = 'patch' | 'minor';
887
+ /**
888
+ * Default namespace for database-defined schemas.
889
+ */
890
+ declare const DATABASE_SCHEMA_NAMESPACE = "xnet://xnet.fyi/";
891
+ /**
892
+ * Prefix for database schema IRIs.
893
+ */
894
+ declare const DATABASE_SCHEMA_PREFIX = "xnet://xnet.fyi/db/";
895
+ /**
896
+ * Generate a schema IRI from a database ID and version.
897
+ *
898
+ * @example
899
+ * buildSchemaIRI('abc123', '1.0.0') // => 'xnet://xnet.fyi/db/abc123@1.0.0'
900
+ */
901
+ declare function buildSchemaIRI(databaseId: string, version: string): SchemaIRI;
902
+ /**
903
+ * Parse a database schema IRI to extract the database ID and version.
904
+ *
905
+ * @returns { databaseId, version } or null if the IRI doesn't match the pattern
906
+ *
907
+ * @example
908
+ * parseSchemaIRI('xnet://xnet.fyi/db/abc123@1.0.0')
909
+ * // => { databaseId: 'abc123', version: '1.0.0' }
910
+ */
911
+ declare function parseDatabaseSchemaIRI(iri: string): {
912
+ databaseId: string;
913
+ version: string;
914
+ } | null;
915
+ /**
916
+ * Check if an IRI is a database-defined schema IRI.
917
+ */
918
+ declare function isDatabaseSchemaIRI(iri: string): boolean;
919
+ /**
920
+ * Parse a semver version string.
921
+ *
922
+ * @returns { major, minor, patch } or null if invalid
923
+ */
924
+ declare function parseVersion(version: string): {
925
+ major: number;
926
+ minor: number;
927
+ patch: number;
928
+ } | null;
929
+ /**
930
+ * Bump a schema version.
931
+ *
932
+ * - patch: 1.0.0 -> 1.0.1 (add column, update column, rename)
933
+ * - minor: 1.0.0 -> 1.1.0 (delete column, change column type)
934
+ *
935
+ * @example
936
+ * bumpSchemaVersion('1.0.0', 'patch') // => '1.0.1'
937
+ * bumpSchemaVersion('1.0.5', 'minor') // => '1.1.0'
938
+ */
939
+ declare function bumpSchemaVersion(current: string, type: VersionBumpType): string;
940
+ /**
941
+ * Create initial schema metadata for a new database.
942
+ */
943
+ declare function createInitialSchemaMetadata(name: string): DatabaseSchemaMetadata;
944
+ /**
945
+ * Build a Schema object from database metadata and columns.
946
+ *
947
+ * This creates a unique, versioned schema for the database.
948
+ *
949
+ * @example
950
+ * const schema = buildDatabaseSchema('db123', metadata, columns)
951
+ * // schema['@id'] === 'xnet://xnet.fyi/db/db123@1.0.0'
952
+ */
953
+ declare function buildDatabaseSchema(databaseId: string, metadata: DatabaseSchemaMetadata, columns: StoredColumn[]): Schema;
954
+ /**
955
+ * Create a schema version history entry.
956
+ */
957
+ declare function createVersionEntry(version: string, columns: StoredColumn[], changeType: SchemaVersionEntry['changeType'], changeDescription?: string): SchemaVersionEntry;
958
+ /**
959
+ * Maximum number of version history entries to keep.
960
+ */
961
+ declare const MAX_VERSION_HISTORY = 50;
962
+ /**
963
+ * Prune version history to stay within limits.
964
+ */
965
+ declare function pruneVersionHistory(history: SchemaVersionEntry[]): SchemaVersionEntry[];
966
+ /**
967
+ * Determine the version bump type for a column operation.
968
+ */
969
+ declare function getVersionBumpType(operation: 'add' | 'update' | 'rename' | 'delete' | 'changeType'): VersionBumpType;
970
+
971
+ /**
972
+ * Database-defined schemas from DatabaseField nodes (V2).
973
+ *
974
+ * Replaces the Y.Doc extraction path (schema-resolver.ts): in the V2 model
975
+ * the field list lives in DatabaseField nodes and the schema version lives
976
+ * on the Database node's `schemaVersion` property.
977
+ */
978
+
979
+ /** Default version for databases that have never bumped their schema. */
980
+ declare const DEFAULT_DATABASE_SCHEMA_VERSION = "1.0.0";
981
+ /**
982
+ * Convert field nodes to the StoredColumn shape used by schema building,
983
+ * cloning, and templates.
984
+ */
985
+ declare function fieldsToStoredColumns(fields: FieldNode[]): StoredColumn[];
986
+ /**
987
+ * Build the database-defined Schema for a database from its field nodes.
988
+ * Returns null when the database doesn't exist.
989
+ */
990
+ declare function buildSchemaFromFields(store: NodeStore, databaseId: string): Promise<Schema | null>;
991
+ /**
992
+ * Get the current database-defined schema IRI for a database.
993
+ * Returns null when the database doesn't exist.
994
+ */
995
+ declare function getDatabaseSchemaIRI(store: NodeStore, databaseId: string): Promise<SchemaIRI | null>;
996
+ /**
997
+ * Create a remote resolver for database-defined schemas backed by the
998
+ * NodeStore (V2 replacement for createDatabaseSchemaResolver).
999
+ *
1000
+ * @example
1001
+ * schemaRegistry.setRemoteResolver(createNodeDatabaseSchemaResolver({ store }))
1002
+ */
1003
+ declare function createNodeDatabaseSchemaResolver(options: {
1004
+ store: NodeStore;
1005
+ }): (iri: SchemaIRI) => Promise<Schema | null>;
1006
+
1007
+ /**
1008
+ * Database Y.Doc initialization and management.
1009
+ *
1010
+ * The database's Y.Doc contains:
1011
+ * - columns: Y.Array of column definitions
1012
+ * - views: Y.Map of view configurations
1013
+ * - meta: Y.Map of metadata (row count cache, etc.)
1014
+ */
1015
+
1016
+ /**
1017
+ * Initialize the Y.Doc structure for a new database.
1018
+ * Creates the columns array, views map, and meta map if they don't exist.
1019
+ *
1020
+ * @example
1021
+ * ```typescript
1022
+ * const doc = new Y.Doc()
1023
+ * initializeDatabaseDoc(doc)
1024
+ * ```
1025
+ */
1026
+ declare function initializeDatabaseDoc(doc: Y.Doc): void;
1027
+ /**
1028
+ * Check if a Y.Doc has been initialized as a database doc.
1029
+ */
1030
+ declare function isDatabaseDocInitialized(doc: Y.Doc): boolean;
1031
+ /**
1032
+ * Add a default title column to a new database.
1033
+ * Returns the column ID.
1034
+ *
1035
+ * @example
1036
+ * ```typescript
1037
+ * const doc = new Y.Doc()
1038
+ * initializeDatabaseDoc(doc)
1039
+ * const titleColumnId = addDefaultTitleColumn(doc)
1040
+ * ```
1041
+ */
1042
+ declare function addDefaultTitleColumn(doc: Y.Doc): string;
1043
+ /**
1044
+ * Add a default table view to a new database.
1045
+ * Returns the view ID.
1046
+ *
1047
+ * @example
1048
+ * ```typescript
1049
+ * const doc = new Y.Doc()
1050
+ * initializeDatabaseDoc(doc)
1051
+ * addDefaultTitleColumn(doc)
1052
+ * const viewId = addDefaultTableView(doc)
1053
+ * ```
1054
+ */
1055
+ declare function addDefaultTableView(doc: Y.Doc): string;
1056
+ /**
1057
+ * Set up a new database with default title column and table view.
1058
+ * Returns the column ID and view ID.
1059
+ *
1060
+ * @example
1061
+ * ```typescript
1062
+ * const doc = new Y.Doc()
1063
+ * const { columnId, viewId } = setupNewDatabase(doc)
1064
+ * ```
1065
+ */
1066
+ declare function setupNewDatabase(doc: Y.Doc): {
1067
+ columnId: string;
1068
+ viewId: string;
1069
+ };
1070
+ /**
1071
+ * Get a metadata value from the database doc.
1072
+ */
1073
+ declare function getMeta<T>(doc: Y.Doc, key: string): T | undefined;
1074
+ /**
1075
+ * Set a metadata value in the database doc.
1076
+ */
1077
+ declare function setMeta<T>(doc: Y.Doc, key: string, value: T): void;
1078
+ /**
1079
+ * Delete a metadata value from the database doc.
1080
+ */
1081
+ declare function deleteMeta(doc: Y.Doc, key: string): void;
1082
+ /**
1083
+ * Storage model of a database Y.Doc. V2 keeps the Y.Doc presence-only, so
1084
+ * docs are either 'canonical' (pre-V2 columns/views/meta present) or
1085
+ * 'empty'. The legacy Y.Map row model was removed with exploration 0159.
1086
+ */
1087
+ type DatabaseDocumentModel = 'canonical' | 'empty';
1088
+ /**
1089
+ * Detect whether a database Y.Doc carries canonical column/view state.
1090
+ */
1091
+ declare function getDatabaseDocumentModel(doc: Y.Doc): DatabaseDocumentModel;
1092
+
1093
+ /**
1094
+ * Column CRUD operations for database columns.
1095
+ *
1096
+ * Columns are stored in the database's Y.Doc as a Y.Array of Y.Maps.
1097
+ * This enables CRDT-based ordering and real-time schema sync.
1098
+ */
1099
+
1100
+ /**
1101
+ * Get all columns from a database doc.
1102
+ *
1103
+ * @example
1104
+ * ```typescript
1105
+ * const columns = getColumns(doc)
1106
+ * console.log(columns.map(c => c.name))
1107
+ * ```
1108
+ */
1109
+ declare function getColumns(doc: Y.Doc): ColumnDefinition[];
1110
+ /**
1111
+ * Get a single column by ID.
1112
+ *
1113
+ * @example
1114
+ * ```typescript
1115
+ * const column = getColumn(doc, 'abc123')
1116
+ * if (column) {
1117
+ * console.log(column.name, column.type)
1118
+ * }
1119
+ * ```
1120
+ */
1121
+ declare function getColumn(doc: Y.Doc, columnId: string): ColumnDefinition | null;
1122
+ /**
1123
+ * Get the index of a column by ID.
1124
+ * Returns -1 if not found.
1125
+ */
1126
+ declare function getColumnIndex(doc: Y.Doc, columnId: string): number;
1127
+ /**
1128
+ * Get the title column from a database doc.
1129
+ * Returns null if no title column is defined.
1130
+ */
1131
+ declare function getTitleColumn(doc: Y.Doc): ColumnDefinition | null;
1132
+ /**
1133
+ * Create a new column.
1134
+ * Returns the new column ID.
1135
+ *
1136
+ * @example
1137
+ * ```typescript
1138
+ * const id = createColumn(doc, {
1139
+ * name: 'Status',
1140
+ * type: 'select',
1141
+ * config: {
1142
+ * options: [
1143
+ * { id: 'todo', name: 'To Do', color: 'gray' },
1144
+ * { id: 'done', name: 'Done', color: 'green' }
1145
+ * ]
1146
+ * }
1147
+ * })
1148
+ * ```
1149
+ */
1150
+ declare function createColumn(doc: Y.Doc, definition: Omit<ColumnDefinition, 'id'>): string;
1151
+ /**
1152
+ * Update a column's properties.
1153
+ *
1154
+ * @example
1155
+ * ```typescript
1156
+ * updateColumn(doc, 'abc123', { name: 'Project Status' })
1157
+ * ```
1158
+ */
1159
+ declare function updateColumn(doc: Y.Doc, columnId: string, updates: Partial<Omit<ColumnDefinition, 'id'>>): void;
1160
+ /**
1161
+ * Delete a column.
1162
+ * Also removes the column from all views' visible columns.
1163
+ *
1164
+ * @example
1165
+ * ```typescript
1166
+ * deleteColumn(doc, 'abc123')
1167
+ * ```
1168
+ */
1169
+ declare function deleteColumn(doc: Y.Doc, columnId: string): void;
1170
+ /**
1171
+ * Reorder a column to a new position.
1172
+ *
1173
+ * @example
1174
+ * ```typescript
1175
+ * // Move column to the beginning
1176
+ * reorderColumn(doc, 'abc123', 0)
1177
+ * ```
1178
+ */
1179
+ declare function reorderColumn(doc: Y.Doc, columnId: string, newIndex: number): void;
1180
+ /**
1181
+ * Duplicate a column.
1182
+ * Returns the new column ID.
1183
+ *
1184
+ * @example
1185
+ * ```typescript
1186
+ * const newId = duplicateColumn(doc, 'abc123', 'Status (Copy)')
1187
+ * ```
1188
+ */
1189
+ declare function duplicateColumn(doc: Y.Doc, columnId: string, newName?: string): string | null;
1190
+
1191
+ /**
1192
+ * View CRUD operations for database views.
1193
+ *
1194
+ * Views are stored in the database's Y.Doc as a Y.Map of view configs.
1195
+ * This enables collaborative view editing and real-time sync.
1196
+ */
1197
+
1198
+ /**
1199
+ * Get all views from a database doc.
1200
+ *
1201
+ * @example
1202
+ * ```typescript
1203
+ * const views = getViews(doc)
1204
+ * console.log(views.map(v => v.name))
1205
+ * ```
1206
+ */
1207
+ declare function getViews(doc: Y.Doc): ViewConfig[];
1208
+ /**
1209
+ * Get a single view by ID.
1210
+ *
1211
+ * @example
1212
+ * ```typescript
1213
+ * const view = getView(doc, 'abc123')
1214
+ * if (view) {
1215
+ * console.log(view.name, view.type)
1216
+ * }
1217
+ * ```
1218
+ */
1219
+ declare function getView(doc: Y.Doc, viewId: string): ViewConfig | null;
1220
+ /**
1221
+ * Get the first view of a specific type.
1222
+ */
1223
+ declare function getViewByType(doc: Y.Doc, type: ViewType): ViewConfig | null;
1224
+ /**
1225
+ * Create a new view.
1226
+ * Returns the new view ID.
1227
+ *
1228
+ * @example
1229
+ * ```typescript
1230
+ * const id = createView(doc, {
1231
+ * name: 'Board View',
1232
+ * type: 'board',
1233
+ * visibleColumns: ['col1', 'col2'],
1234
+ * groupBy: 'col1'
1235
+ * })
1236
+ * ```
1237
+ */
1238
+ declare function createView(doc: Y.Doc, config: Omit<ViewConfig, 'id'>): string;
1239
+ /**
1240
+ * Update a view's properties.
1241
+ *
1242
+ * @example
1243
+ * ```typescript
1244
+ * updateView(doc, 'abc123', { name: 'My Board' })
1245
+ * ```
1246
+ */
1247
+ declare function updateView(doc: Y.Doc, viewId: string, updates: Partial<Omit<ViewConfig, 'id'>>): void;
1248
+ /**
1249
+ * Delete a view.
1250
+ *
1251
+ * @example
1252
+ * ```typescript
1253
+ * deleteView(doc, 'abc123')
1254
+ * ```
1255
+ */
1256
+ declare function deleteView(doc: Y.Doc, viewId: string): void;
1257
+ /**
1258
+ * Duplicate a view.
1259
+ * Returns the new view ID.
1260
+ *
1261
+ * @example
1262
+ * ```typescript
1263
+ * const newId = duplicateView(doc, 'abc123', 'My Copy')
1264
+ * ```
1265
+ */
1266
+ declare function duplicateView(doc: Y.Doc, viewId: string, newName?: string): string;
1267
+ /**
1268
+ * Set the filters for a view.
1269
+ *
1270
+ * @example
1271
+ * ```typescript
1272
+ * setViewFilters(doc, 'view123', {
1273
+ * operator: 'and',
1274
+ * conditions: [
1275
+ * { columnId: 'status', operator: 'equals', value: 'done' }
1276
+ * ]
1277
+ * })
1278
+ * ```
1279
+ */
1280
+ declare function setViewFilters(doc: Y.Doc, viewId: string, filters: FilterGroup | null): void;
1281
+ /**
1282
+ * Clear all filters from a view.
1283
+ */
1284
+ declare function clearViewFilters(doc: Y.Doc, viewId: string): void;
1285
+ /**
1286
+ * Set the sorts for a view.
1287
+ *
1288
+ * @example
1289
+ * ```typescript
1290
+ * setViewSorts(doc, 'view123', [
1291
+ * { columnId: 'date', direction: 'desc' },
1292
+ * { columnId: 'name', direction: 'asc' }
1293
+ * ])
1294
+ * ```
1295
+ */
1296
+ declare function setViewSorts(doc: Y.Doc, viewId: string, sorts: SortConfig[]): void;
1297
+ /**
1298
+ * Add a sort to a view.
1299
+ */
1300
+ declare function addViewSort(doc: Y.Doc, viewId: string, sort: SortConfig): void;
1301
+ /**
1302
+ * Remove a sort from a view by column ID.
1303
+ */
1304
+ declare function removeViewSort(doc: Y.Doc, viewId: string, columnId: string): void;
1305
+ /**
1306
+ * Clear all sorts from a view.
1307
+ */
1308
+ declare function clearViewSorts(doc: Y.Doc, viewId: string): void;
1309
+ /**
1310
+ * Set the group by column for a view.
1311
+ */
1312
+ declare function setViewGroupBy(doc: Y.Doc, viewId: string, columnId: string | null): void;
1313
+ /**
1314
+ * Toggle a group's collapsed state.
1315
+ */
1316
+ declare function toggleGroupCollapsed$1(doc: Y.Doc, viewId: string, groupId: string): void;
1317
+ /**
1318
+ * Set which columns are visible in a view.
1319
+ */
1320
+ declare function setVisibleColumns(doc: Y.Doc, viewId: string, columnIds: string[]): void;
1321
+ /**
1322
+ * Show a column in a view.
1323
+ */
1324
+ declare function showColumn(doc: Y.Doc, viewId: string, columnId: string): void;
1325
+ /**
1326
+ * Hide a column in a view.
1327
+ */
1328
+ declare function hideColumn(doc: Y.Doc, viewId: string, columnId: string): void;
1329
+ /**
1330
+ * Reorder columns in a view.
1331
+ */
1332
+ declare function reorderViewColumns(doc: Y.Doc, viewId: string, columnId: string, newIndex: number): void;
1333
+ /**
1334
+ * Set a column's width in a view.
1335
+ */
1336
+ declare function setColumnWidth(doc: Y.Doc, viewId: string, columnId: string, width: number): void;
1337
+
1338
+ /**
1339
+ * Filter operators by column type.
1340
+ *
1341
+ * Maps each column type to the filter operators that are valid for that type.
1342
+ */
1343
+
1344
+ /**
1345
+ * Valid filter operators for each column type.
1346
+ */
1347
+ declare const OPERATORS_BY_TYPE: Record<ColumnType, FilterOperator[]>;
1348
+ /**
1349
+ * Human-readable labels for filter operators.
1350
+ */
1351
+ declare const OPERATOR_LABELS: Record<FilterOperator, string>;
1352
+ /**
1353
+ * Get valid operators for a column type.
1354
+ */
1355
+ declare function getOperatorsForType(type: ColumnType): FilterOperator[];
1356
+ /**
1357
+ * Check if an operator is valid for a column type.
1358
+ */
1359
+ declare function isValidOperator(type: ColumnType, operator: FilterOperator): boolean;
1360
+ /**
1361
+ * Get the human-readable label for an operator.
1362
+ */
1363
+ declare function getOperatorLabel(operator: FilterOperator): string;
1364
+ /**
1365
+ * Check if an operator requires a value.
1366
+ */
1367
+ declare function operatorRequiresValue(operator: FilterOperator): boolean;
1368
+
1369
+ /**
1370
+ * Filter engine for in-memory row filtering.
1371
+ *
1372
+ * Evaluates filter groups and conditions against database rows.
1373
+ */
1374
+
1375
+ /**
1376
+ * A database row with cells.
1377
+ */
1378
+ interface FilterableRow {
1379
+ id: string;
1380
+ cells: Record<string, unknown>;
1381
+ }
1382
+ /**
1383
+ * Filter rows in memory using a filter group.
1384
+ *
1385
+ * @param rows - Rows to filter
1386
+ * @param columns - Column definitions for type information
1387
+ * @param filter - Filter group to apply (null returns all rows)
1388
+ * @returns Filtered rows
1389
+ *
1390
+ * @example
1391
+ * ```typescript
1392
+ * const filtered = filterRows(rows, columns, {
1393
+ * operator: 'and',
1394
+ * conditions: [
1395
+ * { columnId: 'status', operator: 'equals', value: 'active' }
1396
+ * ]
1397
+ * })
1398
+ * ```
1399
+ */
1400
+ declare function filterRows<T extends FilterableRow>(rows: T[], columns: ColumnDefinition[], filter: FilterGroup | null): T[];
1401
+ /**
1402
+ * Create a simple equals filter.
1403
+ */
1404
+ declare function createEqualsFilter(columnId: string, value: unknown): FilterGroup;
1405
+ /**
1406
+ * Create a filter that matches any of the given values.
1407
+ */
1408
+ declare function createAnyOfFilter(columnId: string, values: unknown[]): FilterGroup;
1409
+ /**
1410
+ * Combine multiple filter groups with AND.
1411
+ */
1412
+ declare function combineFiltersAnd(filters: FilterGroup[]): FilterGroup;
1413
+ /**
1414
+ * Combine multiple filter groups with OR.
1415
+ */
1416
+ declare function combineFiltersOr(filters: FilterGroup[]): FilterGroup;
1417
+
1418
+ /**
1419
+ * Sort engine for in-memory row sorting.
1420
+ *
1421
+ * Supports multi-column sorting with type-aware comparison.
1422
+ */
1423
+
1424
+ /**
1425
+ * A database row with cells and sortKey.
1426
+ */
1427
+ interface SortableRow {
1428
+ id: string;
1429
+ sortKey: string;
1430
+ cells: Record<string, unknown>;
1431
+ }
1432
+ /**
1433
+ * Sort rows in memory using multi-column sort config.
1434
+ *
1435
+ * @param rows - Rows to sort
1436
+ * @param columns - Column definitions for type information
1437
+ * @param sorts - Sort configurations (applied in order)
1438
+ * @returns Sorted rows (new array)
1439
+ *
1440
+ * @example
1441
+ * ```typescript
1442
+ * const sorted = sortRows(rows, columns, [
1443
+ * { columnId: 'status', direction: 'asc' },
1444
+ * { columnId: 'name', direction: 'desc' }
1445
+ * ])
1446
+ * ```
1447
+ */
1448
+ declare function sortRows<T extends SortableRow>(rows: T[], columns: ColumnDefinition[], sorts: SortConfig[]): T[];
1449
+ /**
1450
+ * Create a single-column sort config.
1451
+ */
1452
+ declare function createSort(columnId: string, direction?: 'asc' | 'desc'): SortConfig;
1453
+ /**
1454
+ * Toggle sort direction.
1455
+ */
1456
+ declare function toggleSortDirection(direction: 'asc' | 'desc'): 'asc' | 'desc';
1457
+ /**
1458
+ * Add or update a sort in a sort list.
1459
+ * If the column already exists, toggles direction.
1460
+ * If it doesn't exist, adds it at the beginning.
1461
+ */
1462
+ declare function addOrToggleSort(sorts: SortConfig[], columnId: string): SortConfig[];
1463
+ /**
1464
+ * Remove a sort from a sort list.
1465
+ */
1466
+ declare function removeSort(sorts: SortConfig[], columnId: string): SortConfig[];
1467
+
1468
+ /**
1469
+ * Group engine for in-memory row grouping.
1470
+ *
1471
+ * Groups rows by column value and calculates aggregates.
1472
+ */
1473
+
1474
+ /**
1475
+ * A database row with cells.
1476
+ */
1477
+ interface GroupableRow {
1478
+ id: string;
1479
+ cells: Record<string, unknown>;
1480
+ }
1481
+ /**
1482
+ * Group configuration.
1483
+ */
1484
+ interface GroupConfig {
1485
+ /** Column ID to group by */
1486
+ columnId: string;
1487
+ /** Sort direction for groups */
1488
+ sort?: 'asc' | 'desc';
1489
+ /** Collapsed group keys */
1490
+ collapsedGroups?: string[];
1491
+ }
1492
+ /**
1493
+ * A group of rows.
1494
+ */
1495
+ interface RowGroup<T extends GroupableRow = GroupableRow> {
1496
+ /** Group key (column value or special key like '_empty') */
1497
+ key: string;
1498
+ /** Display label */
1499
+ label: string;
1500
+ /** Group color (for select columns) */
1501
+ color?: string;
1502
+ /** Rows in this group */
1503
+ rows: T[];
1504
+ /** Calculated aggregates */
1505
+ aggregates: GroupAggregates;
1506
+ /** Whether this group is collapsed */
1507
+ collapsed?: boolean;
1508
+ }
1509
+ /**
1510
+ * Aggregate values for a group.
1511
+ */
1512
+ interface GroupAggregates {
1513
+ /** Row count */
1514
+ count: number;
1515
+ /** Sum of number columns (keyed by columnId_sum) */
1516
+ [key: string]: number | undefined;
1517
+ }
1518
+ /**
1519
+ * Group rows by a column value.
1520
+ *
1521
+ * @param rows - Rows to group
1522
+ * @param columns - Column definitions for type information
1523
+ * @param groupBy - Group configuration (null returns single group with all rows)
1524
+ * @returns Array of row groups
1525
+ *
1526
+ * @example
1527
+ * ```typescript
1528
+ * const groups = groupRows(rows, columns, { columnId: 'status' })
1529
+ * // Returns: [{ key: 'active', label: 'Active', rows: [...] }, ...]
1530
+ * ```
1531
+ */
1532
+ declare function groupRows<T extends GroupableRow>(rows: T[], columns: ColumnDefinition[], groupBy: GroupConfig | null): RowGroup<T>[];
1533
+ /**
1534
+ * Toggle a group's collapsed state.
1535
+ */
1536
+ declare function toggleGroupCollapsed(collapsedGroups: string[] | undefined, groupKey: string): string[];
1537
+ /**
1538
+ * Expand all groups.
1539
+ */
1540
+ declare function expandAllGroups(): string[];
1541
+ /**
1542
+ * Collapse all groups.
1543
+ */
1544
+ declare function collapseAllGroups<T extends GroupableRow>(groups: RowGroup<T>[]): string[];
1545
+
1546
+ /**
1547
+ * Query pipeline for database rows.
1548
+ *
1549
+ * Executes filter -> sort -> group pipeline on rows.
1550
+ */
1551
+
1552
+ /**
1553
+ * A row that can be processed by the query pipeline.
1554
+ */
1555
+ interface QueryableRow extends FilterableRow, SortableRow, GroupableRow {
1556
+ id: string;
1557
+ sortKey: string;
1558
+ cells: Record<string, unknown>;
1559
+ }
1560
+ /**
1561
+ * Query options for the pipeline.
1562
+ */
1563
+ interface QueryOptions {
1564
+ /** Filter configuration */
1565
+ filter?: FilterGroup | null;
1566
+ /** Sort configurations (applied in order) */
1567
+ sorts?: SortConfig[];
1568
+ /** Group configuration */
1569
+ groupBy?: GroupConfig | null;
1570
+ /** Maximum rows to return */
1571
+ limit?: number;
1572
+ /** Offset for pagination */
1573
+ offset?: number;
1574
+ }
1575
+ /**
1576
+ * Result of a query execution.
1577
+ */
1578
+ interface QueryResult<T extends QueryableRow = QueryableRow> {
1579
+ /** Grouped rows */
1580
+ groups: RowGroup<T>[];
1581
+ /** Total row count (before filtering) */
1582
+ total: number;
1583
+ /** Filtered row count (after filtering, before pagination) */
1584
+ filtered: number;
1585
+ }
1586
+ /**
1587
+ * Execute a full query pipeline: filter -> sort -> group.
1588
+ *
1589
+ * @param rows - Rows to query
1590
+ * @param columns - Column definitions for type information
1591
+ * @param options - Query options
1592
+ * @returns Query result with groups, total, and filtered counts
1593
+ *
1594
+ * @example
1595
+ * ```typescript
1596
+ * const result = executeQuery(rows, columns, {
1597
+ * filter: { operator: 'and', conditions: [{ columnId: 'status', operator: 'equals', value: 'active' }] },
1598
+ * sorts: [{ columnId: 'name', direction: 'asc' }],
1599
+ * groupBy: { columnId: 'status' }
1600
+ * })
1601
+ * ```
1602
+ */
1603
+ declare function executeQuery<T extends QueryableRow>(rows: T[], columns: ColumnDefinition[], options?: QueryOptions): QueryResult<T>;
1604
+ /**
1605
+ * Create a simple query with just filtering.
1606
+ */
1607
+ declare function createFilterQuery(filter: FilterGroup): QueryOptions;
1608
+ /**
1609
+ * Create a simple query with just sorting.
1610
+ */
1611
+ declare function createSortQuery(sorts: SortConfig[]): QueryOptions;
1612
+ /**
1613
+ * Create a paginated query.
1614
+ */
1615
+ declare function createPaginatedQuery(page: number, pageSize: number, options?: Omit<QueryOptions, 'limit' | 'offset'>): QueryOptions;
1616
+ /**
1617
+ * Flatten groups into a single array of rows.
1618
+ */
1619
+ declare function flattenGroups<T extends QueryableRow>(groups: RowGroup<T>[]): T[];
1620
+ /**
1621
+ * Get total row count from groups.
1622
+ */
1623
+ declare function getTotalFromGroups<T extends QueryableRow>(groups: RowGroup<T>[]): number;
1624
+
1625
+ /**
1626
+ * Rollup aggregation engine for computed columns.
1627
+ *
1628
+ * Rollups aggregate values from related rows via relation columns.
1629
+ * Supports count, sum, avg, min, max, concat, unique, and percentage functions.
1630
+ */
1631
+
1632
+ /**
1633
+ * A row with cells for rollup computation.
1634
+ */
1635
+ interface RollupRow {
1636
+ id: string;
1637
+ databaseId: string;
1638
+ cells: Record<string, CellValue>;
1639
+ }
1640
+ /**
1641
+ * Context for rollup computation.
1642
+ */
1643
+ interface RollupContext {
1644
+ /** Get related rows for a row via a relation column */
1645
+ getRelatedRows: (rowId: string, relationColumnId: string) => Promise<RollupRow[]>;
1646
+ /** Get column definitions for a database */
1647
+ getColumns: (databaseId: string) => Promise<ColumnDefinition[]>;
1648
+ /** Get a specific column by ID */
1649
+ getColumn: (databaseId: string, columnId: string) => Promise<ColumnDefinition | undefined>;
1650
+ }
1651
+ /**
1652
+ * Aggregate an array of values using the specified function.
1653
+ */
1654
+ declare function aggregate(values: unknown[], aggregation: RollupAggregation): unknown;
1655
+ /**
1656
+ * Get the default/empty value for an aggregation function.
1657
+ */
1658
+ declare function getEmptyValue(aggregation: RollupAggregation): unknown;
1659
+ /**
1660
+ * Compute a rollup value for a row.
1661
+ *
1662
+ * @example
1663
+ * ```typescript
1664
+ * const value = await computeRollup(row, rollupColumn, context)
1665
+ * // Returns aggregated value from related rows
1666
+ * ```
1667
+ */
1668
+ declare function computeRollup(row: RollupRow, rollupColumn: ColumnDefinition, context: RollupContext): Promise<unknown>;
1669
+ /**
1670
+ * Batch compute rollups for multiple rows.
1671
+ *
1672
+ * @example
1673
+ * ```typescript
1674
+ * const results = await batchComputeRollups(rows, rollupColumn, context)
1675
+ * // Map<rowId, aggregatedValue>
1676
+ * ```
1677
+ */
1678
+ declare function batchComputeRollups(rows: RollupRow[], rollupColumn: ColumnDefinition, context: RollupContext): Promise<Map<string, unknown>>;
1679
+ /**
1680
+ * Validate a rollup column configuration.
1681
+ */
1682
+ declare function validateRollupConfig(config: RollupColumnConfig, columns: ColumnDefinition[]): {
1683
+ valid: boolean;
1684
+ error?: string;
1685
+ };
1686
+ /**
1687
+ * Check if an aggregation function is numeric (requires number values).
1688
+ */
1689
+ declare function isNumericAggregation(aggregation: RollupAggregation): boolean;
1690
+ /**
1691
+ * Get the result type for an aggregation function.
1692
+ */
1693
+ declare function getAggregationResultType(aggregation: RollupAggregation): 'number' | 'text' | 'array';
1694
+
1695
+ /**
1696
+ * Formula service for computing formula column values.
1697
+ *
1698
+ * Provides caching, validation, and batch computation for formula columns.
1699
+ */
1700
+
1701
+ /**
1702
+ * A row with cells for formula computation.
1703
+ */
1704
+ interface FormulaRow {
1705
+ id: string;
1706
+ databaseId: string;
1707
+ cells: Record<string, CellValue>;
1708
+ }
1709
+ /**
1710
+ * Result of formula validation.
1711
+ */
1712
+ interface FormulaValidationResult {
1713
+ valid: boolean;
1714
+ error?: string;
1715
+ dependencies?: string[];
1716
+ }
1717
+ declare class FormulaService {
1718
+ private parser;
1719
+ private astCache;
1720
+ private valueCache;
1721
+ /**
1722
+ * Compute a formula value for a row.
1723
+ *
1724
+ * @example
1725
+ * ```typescript
1726
+ * const service = new FormulaService()
1727
+ * const value = service.compute(row, formulaColumn, columns)
1728
+ * ```
1729
+ */
1730
+ compute(row: FormulaRow, column: ColumnDefinition, columns: ColumnDefinition[]): unknown;
1731
+ /**
1732
+ * Batch compute formulas for multiple rows.
1733
+ */
1734
+ batchCompute(rows: FormulaRow[], column: ColumnDefinition, columns: ColumnDefinition[]): Map<string, unknown>;
1735
+ /**
1736
+ * Validate a formula expression.
1737
+ *
1738
+ * @example
1739
+ * ```typescript
1740
+ * const result = service.validate('{{price}} * {{quantity}}', columns)
1741
+ * if (!result.valid) {
1742
+ * console.error(result.error)
1743
+ * }
1744
+ * ```
1745
+ */
1746
+ validate(expression: string, columns: ColumnDefinition[]): FormulaValidationResult;
1747
+ /**
1748
+ * Invalidate cache for a row.
1749
+ */
1750
+ invalidate(rowId: string): void;
1751
+ /**
1752
+ * Invalidate all cached values.
1753
+ */
1754
+ invalidateAll(): void;
1755
+ /**
1756
+ * Clear AST cache (use when formula expressions change).
1757
+ */
1758
+ clearAstCache(): void;
1759
+ private computeHash;
1760
+ private coerceResult;
1761
+ }
1762
+ /**
1763
+ * Create a new FormulaService instance.
1764
+ */
1765
+ declare function createFormulaService(): FormulaService;
1766
+
1767
+ /**
1768
+ * CSV parser for database import.
1769
+ *
1770
+ * Parses CSV text into headers and rows, with support for:
1771
+ * - Quoted values with commas
1772
+ * - Escaped quotes (doubled quotes)
1773
+ * - Column type inference
1774
+ * - Value parsing by type
1775
+ */
1776
+
1777
+ /**
1778
+ * Result of parsing a CSV file.
1779
+ */
1780
+ interface ParsedCSV {
1781
+ /** Column headers from the first row */
1782
+ headers: string[];
1783
+ /** Data rows (each row is an array of string values) */
1784
+ rows: string[][];
1785
+ }
1786
+ /**
1787
+ * Options for CSV parsing.
1788
+ */
1789
+ interface CsvParseOptions {
1790
+ /** Delimiter character (default: comma) */
1791
+ delimiter?: string;
1792
+ /** Whether the first row contains headers (default: true) */
1793
+ hasHeaders?: boolean;
1794
+ /** Skip empty lines (default: true) */
1795
+ skipEmptyLines?: boolean;
1796
+ }
1797
+ /**
1798
+ * Parse CSV text into headers and rows.
1799
+ *
1800
+ * @example
1801
+ * const csv = `name,age,active
1802
+ * Alice,30,true
1803
+ * Bob,25,false`
1804
+ *
1805
+ * const result = parseCSV(csv)
1806
+ * // { headers: ['name', 'age', 'active'], rows: [['Alice', '30', 'true'], ['Bob', '25', 'false']] }
1807
+ */
1808
+ declare function parseCSV(text: string, options?: CsvParseOptions): ParsedCSV;
1809
+ /**
1810
+ * Parse a single CSV line into an array of values.
1811
+ * Handles quoted values and escaped quotes.
1812
+ */
1813
+ declare function parseCSVLine(line: string, delimiter?: string): string[];
1814
+ /**
1815
+ * Guess the column type from sample values.
1816
+ *
1817
+ * @example
1818
+ * guessColumnType(['1', '2.5', '100']) // 'number'
1819
+ * guessColumnType(['true', 'false', 'yes']) // 'checkbox'
1820
+ * guessColumnType(['2024-01-01', '2024-06-15']) // 'date'
1821
+ */
1822
+ declare function guessColumnType(values: string[]): ColumnType;
1823
+ /**
1824
+ * Parse a string value to the appropriate type.
1825
+ *
1826
+ * @example
1827
+ * parseValue('42', 'number') // 42
1828
+ * parseValue('true', 'checkbox') // true
1829
+ * parseValue('2024-01-15', 'date') // '2024-01-15T00:00:00.000Z'
1830
+ */
1831
+ declare function parseValue(value: string, type: ColumnType): unknown;
1832
+ /**
1833
+ * Parse all values in a row according to column types.
1834
+ */
1835
+ declare function parseRow(row: string[], headers: string[], columnTypes: Map<string, ColumnType>): Record<string, unknown>;
1836
+ /**
1837
+ * Infer column types from all rows.
1838
+ */
1839
+ declare function inferColumnTypes(headers: string[], rows: string[][]): Map<string, ColumnType>;
1840
+
1841
+ /**
1842
+ * JSON parser for database import.
1843
+ *
1844
+ * Parses JSON data into rows and inferred column definitions.
1845
+ * Supports:
1846
+ * - Array of objects: [{ name: 'Alice', age: 30 }, ...]
1847
+ * - Object with rows property: { rows: [...], columns?: [...] }
1848
+ */
1849
+
1850
+ /**
1851
+ * Result of parsing a JSON file.
1852
+ */
1853
+ interface ParsedJSON {
1854
+ /** Data rows as objects */
1855
+ rows: Record<string, unknown>[];
1856
+ /** Inferred or provided column definitions */
1857
+ inferredColumns: InferredColumn[];
1858
+ }
1859
+ /**
1860
+ * Inferred column from JSON data.
1861
+ */
1862
+ interface InferredColumn {
1863
+ /** Column name (from object keys) */
1864
+ name: string;
1865
+ /** Inferred column type */
1866
+ type: ColumnType;
1867
+ /** Sample values for preview */
1868
+ sampleValues?: unknown[];
1869
+ }
1870
+ /**
1871
+ * Options for JSON parsing.
1872
+ */
1873
+ interface JsonParseOptions {
1874
+ /** Maximum rows to parse (for large files) */
1875
+ maxRows?: number;
1876
+ /** Sample size for type inference */
1877
+ sampleSize?: number;
1878
+ }
1879
+ /**
1880
+ * Parse JSON text into rows and inferred columns.
1881
+ *
1882
+ * @example
1883
+ * // Array of objects
1884
+ * parseJSON('[{"name": "Alice", "age": 30}]')
1885
+ *
1886
+ * // Object with rows
1887
+ * parseJSON('{"rows": [{"name": "Alice"}], "columns": [...]}')
1888
+ */
1889
+ declare function parseJSON(text: string, options?: JsonParseOptions): ParsedJSON;
1890
+ /**
1891
+ * Infer column definitions from rows.
1892
+ */
1893
+ declare function inferColumnsFromRows(rows: Record<string, unknown>[], sampleSize?: number): InferredColumn[];
1894
+ /**
1895
+ * Infer column type from JavaScript values.
1896
+ */
1897
+ declare function inferTypeFromValues(values: unknown[]): ColumnType;
1898
+ /**
1899
+ * Convert parsed JSON to column definitions with IDs.
1900
+ */
1901
+ declare function toColumnDefinitions(inferredColumns: InferredColumn[]): ColumnDefinition[];
1902
+ /**
1903
+ * Validate JSON data structure.
1904
+ */
1905
+ declare function validateJsonData(data: unknown): {
1906
+ valid: boolean;
1907
+ errors: string[];
1908
+ };
1909
+
1910
+ /**
1911
+ * CSV exporter for database data.
1912
+ *
1913
+ * Exports database rows to CSV format with:
1914
+ * - Configurable column selection
1915
+ * - Proper escaping of special characters
1916
+ * - Type-aware value formatting
1917
+ */
1918
+
1919
+ /**
1920
+ * A database row for export.
1921
+ */
1922
+ interface ExportRow$1 {
1923
+ id: string;
1924
+ sortKey: string;
1925
+ cells: Record<string, unknown>;
1926
+ }
1927
+ /**
1928
+ * Options for CSV export.
1929
+ */
1930
+ interface CsvExportOptions {
1931
+ /** Column IDs to include (default: all) */
1932
+ columns?: string[];
1933
+ /** Include header row (default: true) */
1934
+ includeHeaders?: boolean;
1935
+ /** Delimiter character (default: comma) */
1936
+ delimiter?: string;
1937
+ /** Line ending (default: CRLF for Windows compatibility) */
1938
+ lineEnding?: string;
1939
+ /** Date format (default: ISO) */
1940
+ dateFormat?: 'iso' | 'locale' | 'short';
1941
+ }
1942
+ /**
1943
+ * Export database rows to CSV format.
1944
+ *
1945
+ * @example
1946
+ * const csv = exportToCsv(rows, columns)
1947
+ * // "Name,Age\r\nAlice,30\r\nBob,25"
1948
+ */
1949
+ declare function exportToCsv(rows: ExportRow$1[], columns: ColumnDefinition[], options?: CsvExportOptions): string;
1950
+ /**
1951
+ * Escape a value for CSV output.
1952
+ * Wraps in quotes if the value contains delimiter, quotes, or newlines.
1953
+ */
1954
+ declare function escapeCSV(value: string, delimiter?: string): string;
1955
+ /**
1956
+ * Format a cell value for CSV output.
1957
+ */
1958
+ declare function formatValue(value: unknown, column: ColumnDefinition, dateFormat?: 'iso' | 'locale' | 'short'): string;
1959
+ /**
1960
+ * Create a downloadable CSV blob.
1961
+ */
1962
+ declare function createCsvBlob(csvContent: string): Blob;
1963
+ /**
1964
+ * Trigger a CSV file download in the browser.
1965
+ */
1966
+ declare function downloadCsv(csvContent: string, filename: string): void;
1967
+
1968
+ /**
1969
+ * JSON exporter for database data.
1970
+ *
1971
+ * Exports database rows to JSON format with:
1972
+ * - Optional schema/column definitions
1973
+ * - Configurable column selection
1974
+ * - Pretty printing option
1975
+ */
1976
+
1977
+ /**
1978
+ * A database row for export.
1979
+ */
1980
+ interface ExportRow {
1981
+ id: string;
1982
+ sortKey: string;
1983
+ cells: Record<string, unknown>;
1984
+ }
1985
+ /**
1986
+ * Options for JSON export.
1987
+ */
1988
+ interface JsonExportOptions {
1989
+ /** Column IDs to include (default: all) */
1990
+ columns?: string[];
1991
+ /** Include column definitions in output (default: true) */
1992
+ includeSchema?: boolean;
1993
+ /** Pretty print with indentation (default: true) */
1994
+ pretty?: boolean;
1995
+ /** Include row IDs (default: false) */
1996
+ includeIds?: boolean;
1997
+ /** Use column names as keys instead of IDs (default: true) */
1998
+ useColumnNames?: boolean;
1999
+ }
2000
+ /**
2001
+ * Exported JSON structure.
2002
+ */
2003
+ interface ExportedJSON {
2004
+ /** Column definitions (if includeSchema is true) */
2005
+ columns?: ExportedColumn[];
2006
+ /** Data rows */
2007
+ rows: Record<string, unknown>[];
2008
+ /** Export metadata */
2009
+ metadata?: {
2010
+ exportedAt: string;
2011
+ rowCount: number;
2012
+ columnCount: number;
2013
+ };
2014
+ }
2015
+ /**
2016
+ * Exported column definition.
2017
+ */
2018
+ interface ExportedColumn {
2019
+ name: string;
2020
+ type: string;
2021
+ config?: Record<string, unknown>;
2022
+ }
2023
+ /**
2024
+ * Export database rows to JSON format.
2025
+ *
2026
+ * @example
2027
+ * const json = exportToJson(rows, columns)
2028
+ * // { "columns": [...], "rows": [...] }
2029
+ */
2030
+ declare function exportToJson(rows: ExportRow[], columns: ColumnDefinition[], options?: JsonExportOptions): string;
2031
+ /**
2032
+ * Export rows as a simple array of objects (no schema).
2033
+ */
2034
+ declare function exportToJsonArray(rows: ExportRow[], columns: ColumnDefinition[], options?: Omit<JsonExportOptions, 'includeSchema'>): string;
2035
+ /**
2036
+ * Create a downloadable JSON blob.
2037
+ */
2038
+ declare function createJsonBlob(jsonContent: string): Blob;
2039
+ /**
2040
+ * Trigger a JSON file download in the browser.
2041
+ */
2042
+ declare function downloadJson(jsonContent: string, filename: string): void;
2043
+ /**
2044
+ * Export to NDJSON (Newline Delimited JSON) format.
2045
+ * Useful for streaming large datasets.
2046
+ */
2047
+ declare function exportToNdjson(rows: ExportRow[], columns: ColumnDefinition[], options?: Omit<JsonExportOptions, 'pretty' | 'includeSchema'>): string;
2048
+
2049
+ /**
2050
+ * Database Schema Resolver
2051
+ *
2052
+ * Factory for creating a remote resolver that can fetch database-defined schemas
2053
+ * from their Y.Doc storage.
2054
+ */
2055
+
2056
+ /**
2057
+ * Interface for fetching Y.Doc by document ID.
2058
+ * This allows the resolver to work with any sync mechanism.
2059
+ */
2060
+ interface DocFetcher {
2061
+ /**
2062
+ * Fetch a Y.Doc by its document ID.
2063
+ * @returns The Y.Doc, or null if not found
2064
+ */
2065
+ getDoc(docId: string): Promise<Y.Doc | null>;
2066
+ }
2067
+ /**
2068
+ * Options for creating a database schema resolver.
2069
+ */
2070
+ interface CreateDatabaseSchemaResolverOptions {
2071
+ /** The doc fetcher to use for retrieving Y.Doc instances */
2072
+ docFetcher: DocFetcher;
2073
+ }
2074
+ /**
2075
+ * Create a remote resolver for database-defined schemas.
2076
+ *
2077
+ * The resolver:
2078
+ * 1. Parses the IRI to extract database ID and version
2079
+ * 2. Fetches the database's Y.Doc
2080
+ * 3. Extracts schema metadata and columns
2081
+ * 4. Builds and returns the Schema object
2082
+ *
2083
+ * @example
2084
+ * const resolver = createDatabaseSchemaResolver({
2085
+ * docFetcher: syncManager
2086
+ * })
2087
+ * schemaRegistry.setRemoteResolver(resolver)
2088
+ */
2089
+ declare function createDatabaseSchemaResolver(options: CreateDatabaseSchemaResolverOptions): (iri: SchemaIRI) => Promise<Schema | null>;
2090
+ /**
2091
+ * Extract schema from a loaded Y.Doc.
2092
+ * Useful for direct access without going through the resolver.
2093
+ *
2094
+ * @param databaseId - The database node ID
2095
+ * @param doc - The database's Y.Doc
2096
+ * @returns The Schema object, or null if data is missing
2097
+ */
2098
+ declare function extractSchemaFromDoc(databaseId: string, doc: Y.Doc): Schema | null;
2099
+ /**
2100
+ * Get the current schema IRI for a database from its Y.Doc.
2101
+ *
2102
+ * @param databaseId - The database node ID
2103
+ * @param doc - The database's Y.Doc
2104
+ * @returns The schema IRI, or null if metadata is missing
2105
+ */
2106
+ declare function getSchemaIRIFromDoc(databaseId: string, doc: Y.Doc): SchemaIRI | null;
2107
+
2108
+ /**
2109
+ * Database Schema Clone
2110
+ *
2111
+ * Utilities for cloning a database schema to create a new database
2112
+ * with the same structure but fresh data.
2113
+ */
2114
+
2115
+ /**
2116
+ * Options for cloning a database schema.
2117
+ */
2118
+ interface CloneSchemaOptions {
2119
+ /** Name for the new database (defaults to "Original Name (Copy)") */
2120
+ name?: string;
2121
+ /** Description for the new database */
2122
+ description?: string;
2123
+ /** Whether to include sample rows (default: false) */
2124
+ includeRows?: boolean;
2125
+ /** Maximum number of sample rows to include (default: 10) */
2126
+ maxSampleRows?: number;
2127
+ }
2128
+ /**
2129
+ * Result of cloning a database schema.
2130
+ */
2131
+ interface CloneSchemaResult {
2132
+ /** New column definitions with remapped IDs */
2133
+ columns: StoredColumn[];
2134
+ /** Mapping from old column IDs to new column IDs */
2135
+ columnIdMap: Map<string, string>;
2136
+ /** New schema metadata */
2137
+ metadata: DatabaseSchemaMetadata;
2138
+ /** Remapped view configurations */
2139
+ views: {
2140
+ tableView?: ViewConfig;
2141
+ boardView?: ViewConfig;
2142
+ [key: string]: ViewConfig | undefined;
2143
+ };
2144
+ /** Sample rows (if includeRows was true) */
2145
+ sampleRows?: Array<Record<string, unknown>>;
2146
+ }
2147
+ /**
2148
+ * Source data for cloning.
2149
+ */
2150
+ interface CloneSourceData {
2151
+ columns: StoredColumn[];
2152
+ metadata: DatabaseSchemaMetadata;
2153
+ tableView?: ViewConfig;
2154
+ boardView?: ViewConfig;
2155
+ rows?: Array<Record<string, unknown>>;
2156
+ }
2157
+ /**
2158
+ * Generate new column IDs for cloning.
2159
+ * Returns a map from old IDs to new IDs.
2160
+ */
2161
+ declare function generateColumnIdMap(columns: StoredColumn[]): Map<string, string>;
2162
+ /**
2163
+ * Clone columns with new IDs.
2164
+ */
2165
+ declare function cloneColumns(columns: StoredColumn[], idMap: Map<string, string>): StoredColumn[];
2166
+ /**
2167
+ * Remap column IDs in a view configuration.
2168
+ * This handles all the places where column IDs are referenced.
2169
+ */
2170
+ declare function remapViewColumnIds(view: ViewConfig, idMap: Map<string, string>): ViewConfig;
2171
+ /**
2172
+ * Clone sample rows with new IDs.
2173
+ */
2174
+ declare function cloneSampleRows(rows: Array<Record<string, unknown>>, idMap: Map<string, string>, maxRows?: number): Array<Record<string, unknown>>;
2175
+ /**
2176
+ * Clone a database schema to create a new database.
2177
+ *
2178
+ * This creates new column definitions, remapped view configs,
2179
+ * and fresh schema metadata with version 1.0.0.
2180
+ *
2181
+ * @param source - The source database data
2182
+ * @param options - Clone options
2183
+ * @returns The cloned schema data ready to be saved to a new Y.Doc
2184
+ *
2185
+ * @example
2186
+ * ```typescript
2187
+ * const source = {
2188
+ * columns: getColumns(doc),
2189
+ * metadata: getSchemaMetadata(doc),
2190
+ * tableView: getTableView(doc),
2191
+ * boardView: getBoardView(doc),
2192
+ * rows: getRows(doc)
2193
+ * }
2194
+ *
2195
+ * const result = cloneSchema(source, { name: 'My New Database' })
2196
+ *
2197
+ * // Apply to new Y.Doc
2198
+ * newDoc.getMap('data').set('columns', result.columns)
2199
+ * newDoc.getMap('data').set('schema', result.metadata)
2200
+ * // etc.
2201
+ * ```
2202
+ */
2203
+ declare function cloneSchema(source: CloneSourceData, options?: CloneSchemaOptions): CloneSchemaResult;
2204
+
2205
+ export { toSelectOptionNode as $, needsRebalancing as A, getRichTextCell as B, type CellValue as C, type DateRange as D, hasRichTextContent as E, type FileRef as F, hasRichTextColumns as G, getRichTextColumnIds as H, deleteRichTextCell as I, getRichTextPlainText as J, type FieldType as K, type FieldConfig as L, MAX_KEY_LENGTH as M, type FieldNode as N, FIELD_TYPES as O, SELECT_COLORS as P, type QueryRowsOptions as Q, RICHTEXT_PREFIX as R, type SelectOptionNode as S, isFieldType as T, isSelectColor as U, autoColor as V, isNodeStoreFieldType as W, isComputedFieldType as X, isAutoFieldType as Y, isYDocFieldType as Z, toFieldNode as _, CELL_PREFIX as a, computeRollup as a$, type CreateFieldOptions as a0, type UpdateFieldOptions as a1, type CreateSelectOptionOptions as a2, getFields as a3, getField as a4, getTitleField as a5, createField as a6, updateField as a7, deleteField as a8, moveField as a9, toggleViewGroupCollapsed as aA, setFieldHidden as aB, setViewFieldWidth as aC, setViewFieldOrder as aD, effectiveFieldSortKey as aE, setupDatabase as aF, type SetupDatabaseResult as aG, DEFAULT_DATABASE_SCHEMA_VERSION as aH, fieldsToStoredColumns as aI, buildSchemaFromFields as aJ, getDatabaseSchemaIRI as aK, createNodeDatabaseSchemaResolver as aL, initializeDatabaseDoc as aM, isDatabaseDocInitialized as aN, addDefaultTitleColumn as aO, addDefaultTableView as aP, setupNewDatabase as aQ, getMeta as aR, setMeta as aS, deleteMeta as aT, getDatabaseDocumentModel as aU, type DatabaseDocumentModel as aV, convertCellValue as aW, cellValueToText as aX, type ConvertContext as aY, type ConvertedCell as aZ, aggregate as a_, duplicateField as aa, ensureSchemaExtension as ab, createExtensionField as ac, renameExtensionField as ad, deleteExtensionField as ae, type EnsureExtensionOptions as af, type CreateExtensionFieldOptions as ag, getSelectOptions as ah, getDatabaseSelectOptions as ai, createSelectOption as aj, updateSelectOption as ak, deleteSelectOption as al, moveSelectOption as am, type ViewNode as an, type CreateViewOptions as ao, type UpdateViewOptions as ap, getViews$1 as aq, getView$1 as ar, createView$1 as as, updateView$1 as at, deleteView$1 as au, duplicateView$1 as av, moveView as aw, setViewFilters$1 as ax, setViewSorts$1 as ay, setViewGroupBy$1 as az, columnIdFromKey as b, setVisibleColumns as b$, batchComputeRollups as b0, validateRollupConfig as b1, type RollupRow as b2, type RollupContext as b3, FormulaService as b4, createFormulaService as b5, type FormulaRow as b6, type FormulaValidationResult as b7, parseCSV as b8, parseCSVLine as b9, type JsonExportOptions as bA, type ExportedJSON as bB, type ExportedColumn as bC, getColumns as bD, getColumn as bE, getColumnIndex as bF, getTitleColumn as bG, createColumn as bH, updateColumn as bI, deleteColumn as bJ, reorderColumn as bK, duplicateColumn as bL, getViews as bM, getView as bN, getViewByType as bO, createView as bP, updateView as bQ, deleteView as bR, duplicateView as bS, setViewFilters as bT, clearViewFilters as bU, setViewSorts as bV, addViewSort as bW, removeViewSort as bX, clearViewSorts as bY, setViewGroupBy as bZ, toggleGroupCollapsed$1 as b_, guessColumnType as ba, parseValue as bb, parseRow as bc, inferColumnTypes as bd, parseJSON as be, inferColumnsFromRows as bf, inferTypeFromValues as bg, toColumnDefinitions as bh, validateJsonData as bi, type ParsedCSV as bj, type CsvParseOptions as bk, type ParsedJSON as bl, type InferredColumn as bm, type JsonParseOptions as bn, exportToCsv as bo, escapeCSV as bp, formatValue as bq, createCsvBlob as br, downloadCsv as bs, exportToJson as bt, exportToJsonArray as bu, exportToNdjson as bv, createJsonBlob as bw, downloadJson as bx, type ExportRow$1 as by, type CsvExportOptions as bz, cellKey as c, cloneSampleRows as c$, showColumn as c0, hideColumn as c1, reorderViewColumns as c2, setColumnWidth as c3, OPERATORS_BY_TYPE as c4, OPERATOR_LABELS as c5, getOperatorsForType as c6, isValidOperator as c7, getOperatorLabel as c8, operatorRequiresValue as c9, type QueryableRow as cA, type QueryOptions as cB, type QueryResult as cC, buildSchemaIRI as cD, parseDatabaseSchemaIRI as cE, isDatabaseSchemaIRI as cF, parseVersion as cG, bumpSchemaVersion as cH, createInitialSchemaMetadata as cI, buildDatabaseSchema as cJ, createVersionEntry as cK, pruneVersionHistory as cL, getVersionBumpType as cM, DATABASE_SCHEMA_NAMESPACE as cN, DATABASE_SCHEMA_PREFIX as cO, MAX_VERSION_HISTORY as cP, type DatabaseSchemaMetadata as cQ, type StoredColumn as cR, type SchemaVersionEntry as cS, type VersionBumpType as cT, createDatabaseSchemaResolver as cU, extractSchemaFromDoc as cV, getSchemaIRIFromDoc as cW, type DocFetcher as cX, type CreateDatabaseSchemaResolverOptions as cY, cloneSchema as cZ, cloneColumns as c_, filterRows as ca, createEqualsFilter as cb, createAnyOfFilter as cc, combineFiltersAnd as cd, combineFiltersOr as ce, type FilterableRow as cf, sortRows as cg, createSort as ch, toggleSortDirection as ci, addOrToggleSort as cj, removeSort as ck, type SortableRow as cl, groupRows as cm, toggleGroupCollapsed as cn, expandAllGroups as co, collapseAllGroups as cp, type GroupableRow as cq, type GroupConfig as cr, type RowGroup as cs, type GroupAggregates as ct, executeQuery as cu, createFilterQuery as cv, createSortQuery as cw, createPaginatedQuery as cx, flattenGroups as cy, getTotalFromGroups as cz, isDateRange as d, generateColumnIdMap as d0, remapViewColumnIds as d1, type CloneSchemaOptions as d2, type CloneSchemaResult as d3, type CloneSourceData as d4, getEmptyValue as d5, isNumericAggregation as d6, getAggregationResultType as d7, isFileRef as e, fromCellProperties as f, isCellValue as g, type CreateRowOptions as h, isCellKey as i, type QueryRowsResult as j, type DatabaseRowNode as k, createRow as l, updateCells as m, deleteRow as n, getRow as o, moveRow as p, queryRows as q, rebalanceDatabase as r, checkNeedsRebalancing as s, toCellProperties as t, updateCell as u, generateSortKey as v, generateSortKeyWithJitter as w, isValidSortKey as x, compareSortKeys as y, rebalanceSortKeys as z };