@sqlrooms/cells 0.29.0-rc.1 → 0.29.0-rc.11

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 (144) hide show
  1. package/LICENSE.md +2 -1
  2. package/README.md +8 -8
  3. package/dist/cellsSlice.d.ts.map +1 -1
  4. package/dist/cellsSlice.js +305 -264
  5. package/dist/cellsSlice.js.map +1 -1
  6. package/dist/components/AggregationSelector.d.ts +8 -0
  7. package/dist/components/AggregationSelector.d.ts.map +1 -0
  8. package/dist/components/AggregationSelector.js +13 -0
  9. package/dist/components/AggregationSelector.js.map +1 -0
  10. package/dist/components/CellSourceSelector.d.ts +12 -0
  11. package/dist/components/CellSourceSelector.d.ts.map +1 -0
  12. package/dist/components/CellSourceSelector.js +34 -0
  13. package/dist/components/CellSourceSelector.js.map +1 -0
  14. package/dist/components/ChartTypeSelector.d.ts +8 -0
  15. package/dist/components/ChartTypeSelector.d.ts.map +1 -0
  16. package/dist/components/ChartTypeSelector.js +13 -0
  17. package/dist/components/ChartTypeSelector.js.map +1 -0
  18. package/dist/components/CollapsibleSectionButton.d.ts +10 -0
  19. package/dist/components/CollapsibleSectionButton.d.ts.map +1 -0
  20. package/dist/components/CollapsibleSectionButton.js +10 -0
  21. package/dist/components/CollapsibleSectionButton.js.map +1 -0
  22. package/dist/components/ColorSelector.d.ts +24 -0
  23. package/dist/components/ColorSelector.d.ts.map +1 -0
  24. package/dist/components/ColorSelector.js +17 -0
  25. package/dist/components/ColorSelector.js.map +1 -0
  26. package/dist/components/FieldSelector.d.ts +11 -0
  27. package/dist/components/FieldSelector.d.ts.map +1 -0
  28. package/dist/components/FieldSelector.js +11 -0
  29. package/dist/components/FieldSelector.js.map +1 -0
  30. package/dist/components/FieldTypeIcon.d.ts +8 -0
  31. package/dist/components/FieldTypeIcon.d.ts.map +1 -0
  32. package/dist/components/FieldTypeIcon.js +27 -0
  33. package/dist/components/FieldTypeIcon.js.map +1 -0
  34. package/dist/components/InputCellContent.d.ts.map +1 -1
  35. package/dist/components/InputCellContent.js +3 -3
  36. package/dist/components/InputCellContent.js.map +1 -1
  37. package/dist/components/SqlCellConnectionSelector.d.ts +9 -0
  38. package/dist/components/SqlCellConnectionSelector.d.ts.map +1 -0
  39. package/dist/components/SqlCellConnectionSelector.js +21 -0
  40. package/dist/components/SqlCellConnectionSelector.js.map +1 -0
  41. package/dist/components/SqlCellContent.d.ts.map +1 -1
  42. package/dist/components/SqlCellContent.js +31 -160
  43. package/dist/components/SqlCellContent.js.map +1 -1
  44. package/dist/components/SqlCellDependentsMenu.d.ts +11 -0
  45. package/dist/components/SqlCellDependentsMenu.d.ts.map +1 -0
  46. package/dist/components/SqlCellDependentsMenu.js +62 -0
  47. package/dist/components/SqlCellDependentsMenu.js.map +1 -0
  48. package/dist/components/SqlCellEditor.d.ts +14 -0
  49. package/dist/components/SqlCellEditor.d.ts.map +1 -0
  50. package/dist/components/SqlCellEditor.js +17 -0
  51. package/dist/components/SqlCellEditor.js.map +1 -0
  52. package/dist/components/SqlCellResultNameEditor.d.ts +8 -0
  53. package/dist/components/SqlCellResultNameEditor.d.ts.map +1 -0
  54. package/dist/components/SqlCellResultNameEditor.js +38 -0
  55. package/dist/components/SqlCellResultNameEditor.js.map +1 -0
  56. package/dist/components/SqlCellResults.d.ts +17 -0
  57. package/dist/components/SqlCellResults.d.ts.map +1 -0
  58. package/dist/components/SqlCellResults.js +44 -0
  59. package/dist/components/SqlCellResults.js.map +1 -0
  60. package/dist/components/SqlCellRunButton.d.ts +5 -6
  61. package/dist/components/SqlCellRunButton.d.ts.map +1 -1
  62. package/dist/components/SqlCellRunButton.js +11 -7
  63. package/dist/components/SqlCellRunButton.js.map +1 -1
  64. package/dist/components/SqlQueryPreview.d.ts +9 -0
  65. package/dist/components/SqlQueryPreview.d.ts.map +1 -0
  66. package/dist/components/SqlQueryPreview.js +14 -0
  67. package/dist/components/SqlQueryPreview.js.map +1 -0
  68. package/dist/components/TextCellContent.d.ts.map +1 -1
  69. package/dist/components/TextCellContent.js +24 -7
  70. package/dist/components/TextCellContent.js.map +1 -1
  71. package/dist/components/VegaCellContent.d.ts +0 -1
  72. package/dist/components/VegaCellContent.d.ts.map +1 -1
  73. package/dist/components/VegaCellContent.js +28 -49
  74. package/dist/components/VegaCellContent.js.map +1 -1
  75. package/dist/components/VegaCellHeader.d.ts +8 -0
  76. package/dist/components/VegaCellHeader.d.ts.map +1 -0
  77. package/dist/components/VegaCellHeader.js +30 -0
  78. package/dist/components/VegaCellHeader.js.map +1 -0
  79. package/dist/components/VegaConfigPanel.d.ts.map +1 -1
  80. package/dist/components/VegaConfigPanel.js +23 -64
  81. package/dist/components/VegaConfigPanel.js.map +1 -1
  82. package/dist/dagUtils.d.ts +10 -9
  83. package/dist/dagUtils.d.ts.map +1 -1
  84. package/dist/dagUtils.js +76 -50
  85. package/dist/dagUtils.js.map +1 -1
  86. package/dist/defaultCellRegistry.d.ts.map +1 -1
  87. package/dist/defaultCellRegistry.js +82 -39
  88. package/dist/defaultCellRegistry.js.map +1 -1
  89. package/dist/execution.d.ts.map +1 -1
  90. package/dist/execution.js +27 -20
  91. package/dist/execution.js.map +1 -1
  92. package/dist/helpers.d.ts +21 -28
  93. package/dist/helpers.d.ts.map +1 -1
  94. package/dist/helpers.js +77 -90
  95. package/dist/helpers.js.map +1 -1
  96. package/dist/hooks/useVegaCellDataSource.d.ts +18 -0
  97. package/dist/hooks/useVegaCellDataSource.d.ts.map +1 -0
  98. package/dist/hooks/useVegaCellDataSource.js +40 -0
  99. package/dist/hooks/useVegaCellDataSource.js.map +1 -0
  100. package/dist/hooks/useVegaCellQuery.d.ts +12 -0
  101. package/dist/hooks/useVegaCellQuery.d.ts.map +1 -0
  102. package/dist/hooks/useVegaCellQuery.js +12 -0
  103. package/dist/hooks/useVegaCellQuery.js.map +1 -0
  104. package/dist/index.d.ts +2 -3
  105. package/dist/index.d.ts.map +1 -1
  106. package/dist/index.js +2 -3
  107. package/dist/index.js.map +1 -1
  108. package/dist/resultRelationPolicy.d.ts +2 -2
  109. package/dist/resultRelationPolicy.d.ts.map +1 -1
  110. package/dist/resultRelationPolicy.js +9 -1
  111. package/dist/resultRelationPolicy.js.map +1 -1
  112. package/dist/sqlHelpers.d.ts +8 -8
  113. package/dist/sqlHelpers.d.ts.map +1 -1
  114. package/dist/sqlHelpers.js +16 -12
  115. package/dist/sqlHelpers.js.map +1 -1
  116. package/dist/types.d.ts +113 -70
  117. package/dist/types.d.ts.map +1 -1
  118. package/dist/types.js +22 -13
  119. package/dist/types.js.map +1 -1
  120. package/dist/useValidateResultName.d.ts +34 -0
  121. package/dist/useValidateResultName.d.ts.map +1 -0
  122. package/dist/useValidateResultName.js +111 -0
  123. package/dist/useValidateResultName.js.map +1 -0
  124. package/dist/utils.d.ts +10 -2
  125. package/dist/utils.d.ts.map +1 -1
  126. package/dist/utils.js +20 -4
  127. package/dist/utils.js.map +1 -1
  128. package/dist/vegaSelectionUtils.d.ts +14 -0
  129. package/dist/vegaSelectionUtils.d.ts.map +1 -0
  130. package/dist/vegaSelectionUtils.js +97 -0
  131. package/dist/vegaSelectionUtils.js.map +1 -0
  132. package/dist/vegaSpecBuilder.d.ts +34 -0
  133. package/dist/vegaSpecBuilder.d.ts.map +1 -0
  134. package/dist/vegaSpecBuilder.js +90 -0
  135. package/dist/vegaSpecBuilder.js.map +1 -0
  136. package/package.json +20 -21
  137. package/dist/components/DeleteSheetModal.d.ts +0 -9
  138. package/dist/components/DeleteSheetModal.d.ts.map +0 -1
  139. package/dist/components/DeleteSheetModal.js +0 -6
  140. package/dist/components/DeleteSheetModal.js.map +0 -1
  141. package/dist/components/SheetsTabBar.d.ts +0 -6
  142. package/dist/components/SheetsTabBar.d.ts.map +0 -1
  143. package/dist/components/SheetsTabBar.js +0 -57
  144. package/dist/components/SheetsTabBar.js.map +0 -1
package/dist/helpers.js CHANGED
@@ -1,36 +1,40 @@
1
- import { getSheetSchemaName } from './utils';
1
+ import { getArtifactSchemaName } from './utils';
2
+ /**
3
+ * Normalizes the result of `findDependencies` to a `CellDependencies` object.
4
+ * Accepts either the legacy `string[]` (cell IDs only) or the new `CellDependencies` shape.
5
+ */
6
+ export function normalizeCellDependencies(result) {
7
+ if (Array.isArray(result)) {
8
+ return { cellIds: result };
9
+ }
10
+ return result;
11
+ }
2
12
  /**
3
13
  * Helper to resolve dependencies using the registry's async AST-based resolver.
4
14
  */
5
- export async function resolveDependencies(cell, cells, sheetId, registry, sqlSelectToJson) {
15
+ export async function resolveDependencies(cell, cells, artifactId, registry, sqlSelectToJson) {
6
16
  const item = registry[cell.type];
7
17
  if (!item)
8
- return [];
9
- return item.findDependencies({ cell, cells, sheetId, sqlSelectToJson });
18
+ return { cellIds: [] };
19
+ const raw = await item.findDependencies({
20
+ cell,
21
+ cells,
22
+ artifactId,
23
+ sqlSelectToJson,
24
+ });
25
+ return normalizeCellDependencies(raw);
10
26
  }
11
27
  /**
12
- * Finds the sheet ID that contains the given cell ID.
28
+ * Finds the artifact ID that contains the given cell ID.
13
29
  */
14
- export function findSheetIdForCell(state, cellId) {
15
- for (const [id, sheet] of Object.entries(state.cells.config.sheets)) {
16
- if (sheet.cellIds.includes(cellId)) {
17
- return id;
30
+ export function findArtifactIdForCell(state, cellId) {
31
+ for (const [artifactId, artifact] of Object.entries(state.cells.config.artifacts)) {
32
+ if (artifact.cellIds.includes(cellId)) {
33
+ return artifactId;
18
34
  }
19
35
  }
20
36
  return undefined;
21
37
  }
22
- /**
23
- * Gets all sheets of a specific type.
24
- */
25
- export function getSheetsByType(state, type) {
26
- const sheets = {};
27
- for (const [id, sheet] of Object.entries(state.cells.config.sheets)) {
28
- if (sheet.type === type) {
29
- sheets[id] = sheet;
30
- }
31
- }
32
- return sheets;
33
- }
34
38
  /**
35
39
  * Required accessor for SQL AST parser used in dependency derivation.
36
40
  */
@@ -42,83 +46,66 @@ export function getRequiredSqlSelectToJson(state) {
42
46
  return parser;
43
47
  }
44
48
  /**
45
- * Normalizes structural sheet fields in a partial cells config.
49
+ * Normalizes artifact runtime entries in a partial cells config.
46
50
  *
47
51
  * This enforces internal invariants before the config is applied:
48
- * - `sheets` always contains at least one entry (falls back to defaults).
49
- * - `sheetOrder` only contains existing sheet ids and includes every sheet.
50
- * - `currentSheetId` always points to an existing sheet.
51
- *
52
- * Non-structural fields are preserved by the caller when merging.
52
+ * - `artifacts` always has stable ids that match the record keys.
53
53
  */
54
- export function normalizeCellsConfigStructure(config, defaultConfig) {
55
- const sheets = config.sheets && Object.keys(config.sheets).length > 0
56
- ? config.sheets
57
- : defaultConfig.sheets;
58
- const sheetIds = Object.keys(sheets);
59
- const normalizedSheetOrder = config.sheetOrder?.filter((id) => id in sheets) ?? [];
60
- const missingSheetIds = sheetIds.filter((id) => !normalizedSheetOrder.includes(id));
61
- const sheetOrder = normalizedSheetOrder.length > 0
62
- ? [...normalizedSheetOrder, ...missingSheetIds]
63
- : sheetIds;
64
- const currentSheetId = (config.currentSheetId && config.currentSheetId in sheets
65
- ? config.currentSheetId
66
- : sheetOrder[0]) ?? sheetIds[0];
67
- return { sheets, sheetOrder, currentSheetId };
54
+ export function normalizeCellsConfigStructure(config) {
55
+ const artifacts = Object.fromEntries(Object.entries(config.artifacts ?? {}).map(([artifactId, artifact]) => [
56
+ artifactId,
57
+ {
58
+ ...artifact,
59
+ id: artifactId,
60
+ cellIds: artifact.cellIds ?? [],
61
+ edges: artifact.edges ?? [],
62
+ },
63
+ ]));
64
+ return { artifacts };
68
65
  }
66
+ export { getUnqualifiedSqlIdentifier } from '@sqlrooms/duckdb';
69
67
  /**
70
- * Returns the final identifier segment from a possibly-qualified SQL name.
71
- *
72
- * The parser is quote-aware: dots inside double-quoted identifiers are treated
73
- * as part of the identifier rather than as qualification separators.
74
- *
75
- * Examples:
76
- * - `schema.table` -> `table`
77
- * - `db.schema.table` -> `table`
78
- * - `schema."my.funny.table"` -> `my.funny.table`
68
+ * Resolves the schema name for an artifact runtime, falling back to a stable id-based name.
79
69
  */
80
- export function getUnqualifiedSqlIdentifier(qualifiedName) {
81
- if (!qualifiedName)
82
- return undefined;
83
- const input = qualifiedName.trim();
84
- if (!input)
85
- return undefined;
86
- const parts = [];
87
- let current = '';
88
- let inQuotes = false;
89
- for (let i = 0; i < input.length; i += 1) {
90
- const ch = input[i];
91
- if (ch === '"') {
92
- // In SQL identifiers, escaped quotes inside quoted identifiers are doubled.
93
- if (inQuotes && input[i + 1] === '"') {
94
- current += '"';
95
- i += 1;
96
- continue;
97
- }
98
- inQuotes = !inQuotes;
99
- current += ch;
100
- continue;
101
- }
102
- if (ch === '.' && !inQuotes) {
103
- parts.push(current);
104
- current = '';
105
- continue;
106
- }
107
- current += ch;
70
+ export function resolveArtifactSchemaName(artifact) {
71
+ return artifact.schemaName || getArtifactSchemaName(artifact.id);
72
+ }
73
+ const DATA_SOURCE_CELL_PREFIX = 'cell:';
74
+ const DATA_SOURCE_TABLE_PREFIX = 'table:';
75
+ export function toDataSourceCell(cell) {
76
+ const id = typeof cell === 'string' ? cell : cell.id;
77
+ return `${DATA_SOURCE_CELL_PREFIX}${id}`;
78
+ }
79
+ export function toDataSourceTable(table) {
80
+ if (typeof table === 'string') {
81
+ return `${DATA_SOURCE_TABLE_PREFIX}${table}`;
108
82
  }
109
- parts.push(current);
110
- const last = parts[parts.length - 1]?.trim();
111
- if (!last)
112
- return undefined;
113
- if (last.startsWith('"') && last.endsWith('"') && last.length >= 2) {
114
- return last.slice(1, -1).replaceAll('""', '"');
83
+ // Escape each identifier segment: double any internal quotes, then wrap in quotes
84
+ const escapeIdentifier = (id) => `"${id.replace(/"/g, '""')}"`;
85
+ const qualifiedName = [
86
+ table.schema ? escapeIdentifier(table.schema) : null,
87
+ escapeIdentifier(table.table),
88
+ ]
89
+ .filter(Boolean)
90
+ .join('.');
91
+ return `${DATA_SOURCE_TABLE_PREFIX}${qualifiedName}`;
92
+ }
93
+ export function isDataSourceCell(value) {
94
+ return value.startsWith(DATA_SOURCE_CELL_PREFIX);
95
+ }
96
+ export function isDataSourceTable(value) {
97
+ return value.startsWith(DATA_SOURCE_TABLE_PREFIX);
98
+ }
99
+ export function fromDataSourceCell(value) {
100
+ if (isDataSourceCell(value)) {
101
+ return value.slice(DATA_SOURCE_CELL_PREFIX.length);
115
102
  }
116
- return last;
103
+ return undefined;
117
104
  }
118
- /**
119
- * Resolves the schema name for a sheet, falling back to a stable id-based name.
120
- */
121
- export function resolveSheetSchemaName(sheet) {
122
- return sheet.schemaName || getSheetSchemaName(sheet.id);
105
+ export function fromDataSourceTable(value) {
106
+ if (isDataSourceTable(value)) {
107
+ return value.slice(DATA_SOURCE_TABLE_PREFIX.length);
108
+ }
109
+ return undefined;
123
110
  }
124
111
  //# sourceMappingURL=helpers.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.js","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":"AASA,OAAO,EAAC,kBAAkB,EAAC,MAAM,SAAS,CAAC;AAE3C;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CACvC,IAAU,EACV,KAA2B,EAC3B,OAAe,EACf,QAAsB,EACtB,eAAkC;IAElC,MAAM,IAAI,GAAG,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACjC,IAAI,CAAC,IAAI;QAAE,OAAO,EAAE,CAAC;IACrB,OAAO,IAAI,CAAC,gBAAgB,CAAC,EAAC,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,eAAe,EAAC,CAAC,CAAC;AACxE,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,kBAAkB,CAChC,KAAqB,EACrB,MAAc;IAEd,KAAK,MAAM,CAAC,EAAE,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC;QACpE,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;YACnC,OAAO,EAAE,CAAC;QACZ,CAA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AC,QAAQ,CAAC;YACrB,OAAO,IAAI,EAAE,CAAC;YACd,SAAS;QACX,CAAC;QAED,IAAI,EAAE,KAAK,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC;YAC5B,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;YACpB,OAAO,GAAG,EAAE,CAAC;YACb,SAAS;QACX,CAAC;QAED,OAAO,IAAI,EAAE,CAAC;IAChB,CAAC;IACD,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAEpB,MAAM,IAAI,GAAG,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC;IAC7C,IAAI,CAAC,IAAI;QAAE,OAAO,SAAS,CAAC;IAC5B,IAAI,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,MAAM,IAAI,CAAC,EAAE,CAAC;QACnE,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;IACjD,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,sBAAsB,CACpC,KAAuC;IAEvC,OAAO,KAAK,CAAC,UAAU,IAAI,kBAAkB,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;AAC1D,CAAC","sourcesContent":["import {\n Cell,\n CellRegistry,\n CellsRootState,\n CellsSliceConfig,\n Sheet,\n SheetType,\n SqlSelectToJsonFn,\n} from './types';\nimport {getSheetSchemaName} from './utils';\n\n/**\n * Helper to resolve dependencies using the registry's async AST-based resolver.\n */\nexport async function resolveDependencies(\n cell: Cell,\n cells: Record<string, Cell>,\n sheetId: string,\n registry: CellRegistry,\n sqlSelectToJson: SqlSelectToJsonFn,\n): Promise<string[]> {\n const item = registry[cell.type];\n if (!item) return [];\n return item.findDependencies({cell, cells, sheetId, sqlSelectToJson});\n}\n\n/**\n * Finds the sheet ID that contains the given cell ID.\n */\nexport function findSheetIdForCell(\n state: CellsRootState,\n cellId: string,\n): string | undefined {\n for (const [id, sheet] of Object.entries(state.cells.config.sheets)) {\n if (sheet.cellIds.includes(cellId)) {\n return id;\n }\n }\n return undefined;\n}\n\n/**\n * Gets all sheets of a specific type.\n */\nexport function getSheetsByType(\n state: CellsRootState,\n type: SheetType,\n): Record<string, Sheet> {\n const sheets: Record<string, Sheet> = {};\n for (const [id, sheet] of Object.entries(state.cells.config.sheets)) {\n if (sheet.type === type) {\n sheets[id] = sheet;\n }\n }\n return sheets;\n}\n\n/**\n * Required accessor for SQL AST parser used in dependency derivation.\n */\nexport function getRequiredSqlSelectToJson(\n state: CellsRootState,\n): SqlSelectToJsonFn {\n const parser = state.db?.sqlSelectToJson;\n if (!parser) {\n throw new Error(\n 'cells dependency derivation requires db.sqlSelectToJson. Ensure the DuckDB slice is mounted and initialized before running cell dependency operations.',\n );\n }\n return parser;\n}\n\n/**\n * Normalizes structural sheet fields in a partial cells config.\n *\n * This enforces internal invariants before the config is applied:\n * - `sheets` always contains at least one entry (falls back to defaults).\n * - `sheetOrder` only contains existing sheet ids and includes every sheet.\n * - `currentSheetId` always points to an existing sheet.\n *\n * Non-structural fields are preserved by the caller when merging.\n */\nexport function normalizeCellsConfigStructure(\n config: Partial<CellsSliceConfig>,\n defaultConfig: CellsSliceConfig,\n): Pick<CellsSliceConfig, 'sheets' | 'sheetOrder' | 'currentSheetId'> {\n const sheets =\n config.sheets && Object.keys(config.sheets).length > 0\n ? config.sheets\n : defaultConfig.sheets;\n const sheetIds = Object.keys(sheets);\n const normalizedSheetOrder =\n config.sheetOrder?.filter((id) => id in sheets) ?? [];\n const missingSheetIds = sheetIds.filter(\n (id) => !normalizedSheetOrder.includes(id),\n );\n const sheetOrder =\n normalizedSheetOrder.length > 0\n ? [...normalizedSheetOrder, ...missingSheetIds]\n : sheetIds;\n const currentSheetId =\n (config.currentSheetId && config.currentSheetId in sheets\n ? config.currentSheetId\n : sheetOrder[0]) ?? sheetIds[0];\n\n return {sheets, sheetOrder, currentSheetId};\n}\n\n/**\n * Returns the final identifier segment from a possibly-qualified SQL name.\n *\n * The parser is quote-aware: dots inside double-quoted identifiers are treated\n * as part of the identifier rather than as qualification separators.\n *\n * Examples:\n * - `schema.table` -> `table`\n * - `db.schema.table` -> `table`\n * - `schema.\"my.funny.table\"` -> `my.funny.table`\n */\nexport function getUnqualifiedSqlIdentifier(\n qualifiedName: string | undefined,\n): string | undefined {\n if (!qualifiedName) return undefined;\n const input = qualifiedName.trim();\n if (!input) return undefined;\n\n const parts: string[] = [];\n let current = '';\n let inQuotes = false;\n\n for (let i = 0; i < input.length; i += 1) {\n const ch = input[i];\n if (ch === '\"') {\n // In SQL identifiers, escaped quotes inside quoted identifiers are doubled.\n if (inQuotes && input[i + 1] === '\"') {\n current += '\"';\n i += 1;\n continue;\n }\n inQuotes = !inQuotes;\n current += ch;\n continue;\n }\n\n if (ch === '.' && !inQuotes) {\n parts.push(current);\n current = '';\n continue;\n }\n\n current += ch;\n }\n parts.push(current);\n\n const last = parts[parts.length - 1]?.trim();\n if (!last) return undefined;\n if (last.startsWith('\"') && last.endsWith('\"') && last.length >= 2) {\n return last.slice(1, -1).replaceAll('\"\"', '\"');\n }\n return last;\n}\n\n/**\n * Resolves the schema name for a sheet, falling back to a stable id-based name.\n */\nexport function resolveSheetSchemaName(\n sheet: Pick<Sheet, 'id' | 'schemaName'>,\n) {\n return sheet.schemaName || getSheetSchemaName(sheet.id);\n}\n"]}
1
+ {"version":3,"file":"helpers.js","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":"AAWA,OAAO,EAAC,qBAAqB,EAAC,MAAM,SAAS,CAAC;AAE9C;;;GAGG;AACH,MAAM,UAAU,yBAAyB,CACvC,MAAmC;IAEnC,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;QAC1B,OA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AAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI;QACpD,gBAAgB,CAAC,KAAK,CAAC,KAAK,CAAC;KAC9B;SACE,MAAM,CAAC,OAAO,CAAC;SACf,IAAI,CAAC,GAAG,CAAC,CAAC;IAEb,OAAO,GAAG,wBAAwB,GAAG,aAAa,EAAE,CAAC;AACvD,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,KAAa;IAC5C,OAAO,KAAK,CAAC,UAAU,CAAC,uBAAuB,CAAC,CAAC;AACnD,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,KAAa;IAC7C,OAAO,KAAK,CAAC,UAAU,CAAC,wBAAwB,CAAC,CAAC;AACpD,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,KAAa;IAC9C,IAAI,gBAAgB,CAAC,KAAK,CAAC,EAAE,CAAC;QAC5B,OAAO,KAAK,CAAC,KAAK,CAAC,uBAAuB,CAAC,MAAM,CAAC,CAAC;IACrD,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAC,KAAa;IAC/C,IAAI,iBAAiB,CAAC,KAAK,CAAC,EAAE,CAAC;QAC7B,OAAO,KAAK,CAAC,KAAK,CAAC,wBAAwB,CAAC,MAAM,CAAC,CAAC;IACtD,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC","sourcesContent":["import {QualifiedTableName} from '@sqlrooms/db';\nimport {\n Cell,\n CellDependencies,\n CellRegistry,\n CellsRootState,\n CellsSliceConfig,\n SqlCell,\n SqlSelectToJsonFn,\n CellArtifactRuntime,\n} from './types';\nimport {getArtifactSchemaName} from './utils';\n\n/**\n * Normalizes the result of `findDependencies` to a `CellDependencies` object.\n * Accepts either the legacy `string[]` (cell IDs only) or the new `CellDependencies` shape.\n */\nexport function normalizeCellDependencies(\n result: string[] | CellDependencies,\n): CellDependencies {\n if (Array.isArray(result)) {\n return {cellIds: result};\n }\n return result;\n}\n\n/**\n * Helper to resolve dependencies using the registry's async AST-based resolver.\n */\nexport async function resolveDependencies(\n cell: Cell,\n cells: Record<string, Cell>,\n artifactId: string,\n registry: CellRegistry,\n sqlSelectToJson: SqlSelectToJsonFn,\n): Promise<CellDependencies> {\n const item = registry[cell.type];\n if (!item) return {cellIds: []};\n const raw = await item.findDependencies({\n cell,\n cells,\n artifactId,\n sqlSelectToJson,\n });\n return normalizeCellDependencies(raw);\n}\n\n/**\n * Finds the artifact ID that contains the given cell ID.\n */\nexport function findArtifactIdForCell(\n state: Pick<CellsRootState, 'cells'>,\n cellId: string,\n): string | undefined {\n for (const [artifactId, artifact] of Object.entries(\n state.cells.config.artifacts,\n )) {\n if (artifact.cellIds.includes(cellId)) {\n return artifactId;\n }\n }\n return undefined;\n}\n\n/**\n * Required accessor for SQL AST parser used in dependency derivation.\n */\nexport function getRequiredSqlSelectToJson(\n state: CellsRootState,\n): SqlSelectToJsonFn {\n const parser = state.db?.sqlSelectToJson;\n if (!parser) {\n throw new Error(\n 'cells dependency derivation requires db.sqlSelectToJson. Ensure the DuckDB slice is mounted and initialized before running cell dependency operations.',\n );\n }\n return parser;\n}\n\n/**\n * Normalizes artifact runtime entries in a partial cells config.\n *\n * This enforces internal invariants before the config is applied:\n * - `artifacts` always has stable ids that match the record keys.\n */\nexport function normalizeCellsConfigStructure(\n config: Partial<CellsSliceConfig>,\n): Pick<CellsSliceConfig, 'artifacts'> {\n const artifacts = Object.fromEntries(\n Object.entries(config.artifacts ?? {}).map(([artifactId, artifact]) => [\n artifactId,\n {\n ...artifact,\n id: artifactId,\n cellIds: artifact.cellIds ?? [],\n edges: artifact.edges ?? [],\n },\n ]),\n ) as Record<string, CellArtifactRuntime>;\n\n return {artifacts};\n}\n\nexport {getUnqualifiedSqlIdentifier} from '@sqlrooms/duckdb';\n\n/**\n * Resolves the schema name for an artifact runtime, falling back to a stable id-based name.\n */\nexport function resolveArtifactSchemaName(\n artifact: Pick<CellArtifactRuntime, 'id' | 'schemaName'>,\n) {\n return artifact.schemaName || getArtifactSchemaName(artifact.id);\n}\n\nconst DATA_SOURCE_CELL_PREFIX = 'cell:';\nconst DATA_SOURCE_TABLE_PREFIX = 'table:';\n\nexport function toDataSourceCell(cell: SqlCell | string): string {\n const id = typeof cell === 'string' ? cell : cell.id;\n\n return `${DATA_SOURCE_CELL_PREFIX}${id}`;\n}\n\nexport function toDataSourceTable(table: QualifiedTableName | string): string {\n if (typeof table === 'string') {\n return `${DATA_SOURCE_TABLE_PREFIX}${table}`;\n }\n\n // Escape each identifier segment: double any internal quotes, then wrap in quotes\n const escapeIdentifier = (id: string) => `\"${id.replace(/\"/g, '\"\"')}\"`;\n\n const qualifiedName = [\n table.schema ? escapeIdentifier(table.schema) : null,\n escapeIdentifier(table.table),\n ]\n .filter(Boolean)\n .join('.');\n\n return `${DATA_SOURCE_TABLE_PREFIX}${qualifiedName}`;\n}\n\nexport function isDataSourceCell(value: string): boolean {\n return value.startsWith(DATA_SOURCE_CELL_PREFIX);\n}\n\nexport function isDataSourceTable(value: string): boolean {\n return value.startsWith(DATA_SOURCE_TABLE_PREFIX);\n}\n\nexport function fromDataSourceCell(value: string): string | undefined {\n if (isDataSourceCell(value)) {\n return value.slice(DATA_SOURCE_CELL_PREFIX.length);\n }\n return undefined;\n}\n\nexport function fromDataSourceTable(value: string): string | undefined {\n if (isDataSourceTable(value)) {\n return value.slice(DATA_SOURCE_TABLE_PREFIX.length);\n }\n return undefined;\n}\n"]}
@@ -0,0 +1,18 @@
1
+ import type { VegaCell, CellStatus } from '../types';
2
+ export type VegaCellDataSource = {
3
+ selectedSqlId: string | undefined;
4
+ selectedTableRef: string | undefined;
5
+ selectedSqlStatus: CellStatus | undefined;
6
+ baseSqlQuery: string;
7
+ lastRunTime: number | undefined;
8
+ hasDataSource: boolean;
9
+ };
10
+ /**
11
+ * Resolves the data source for a Vega cell and builds the base SQL query.
12
+ * Handles three data source types:
13
+ * 1. Direct table reference (tableRef)
14
+ * 2. Result view from another SQL cell (sqlId with resultView)
15
+ * 3. Raw SQL from another cell (sqlId with sql)
16
+ */
17
+ export declare function useVegaCellDataSource(cell: VegaCell): VegaCellDataSource;
18
+ //# sourceMappingURL=useVegaCellDataSource.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useVegaCellDataSource.d.ts","sourceRoot":"","sources":["../../src/hooks/useVegaCellDataSource.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAC,QAAQ,EAAE,UAAU,EAAC,MAAM,UAAU,CAAC;AAEnD,MAAM,MAAM,kBAAkB,GAAG;IAC/B,aAAa,EAAE,MAAM,GAAG,SAAS,CAAC;IAClC,gBAAgB,EAAE,MAAM,GAAG,SAAS,CAAC;IACrC,iBAAiB,EAAE,UAAU,GAAG,SAAS,CAAC;IAC1C,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;IAChC,aAAa,EAAE,OAAO,CAAC;CACxB,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,QAAQ,GAAG,kBAAkB,CAwCxE"}
@@ -0,0 +1,40 @@
1
+ import { useCellsStore } from '../hooks';
2
+ import { isSqlCell, isSqlCellStatus } from '../types';
3
+ /**
4
+ * Resolves the data source for a Vega cell and builds the base SQL query.
5
+ * Handles three data source types:
6
+ * 1. Direct table reference (tableRef)
7
+ * 2. Result view from another SQL cell (sqlId with resultView)
8
+ * 3. Raw SQL from another cell (sqlId with sql)
9
+ */
10
+ export function useVegaCellDataSource(cell) {
11
+ const cellsData = useCellsStore((s) => s.cells.config.data);
12
+ const cellsStatus = useCellsStore((s) => s.cells.status);
13
+ const selectedSqlId = cell.data.sqlId;
14
+ const selectedTableRef = cell.data.tableRef;
15
+ const selectedSqlStatus = selectedSqlId
16
+ ? cellsStatus[selectedSqlId]
17
+ : undefined;
18
+ const hasDataSource = !!(selectedSqlId || selectedTableRef);
19
+ const selectedCell = selectedSqlId ? cellsData[selectedSqlId] : null;
20
+ const selectedCellSql = selectedCell && isSqlCell(selectedCell) ? selectedCell.data.sql : '';
21
+ const selectedResultView = isSqlCellStatus(selectedSqlStatus)
22
+ ? selectedSqlStatus.resultView
23
+ : undefined;
24
+ const baseTable = selectedTableRef || selectedResultView;
25
+ const baseSqlQuery = baseTable
26
+ ? `SELECT * FROM ${baseTable}`
27
+ : selectedCellSql;
28
+ const lastRunTime = isSqlCellStatus(selectedSqlStatus)
29
+ ? selectedSqlStatus.lastRunTime
30
+ : undefined;
31
+ return {
32
+ selectedSqlId,
33
+ selectedTableRef,
34
+ selectedSqlStatus,
35
+ baseSqlQuery,
36
+ lastRunTime,
37
+ hasDataSource,
38
+ };
39
+ }
40
+ //# sourceMappingURL=useVegaCellDataSource.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useVegaCellDataSource.js","sourceRoot":"","sources":["../../src/hooks/useVegaCellDataSource.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAC,MAAM,UAAU,CAAC;AACvC,OAAO,EAAC,SAAS,EAAE,eAAe,EAAC,MAAM,UAAU,CAAC;AAYpD;;;;;;GAMG;AACH,MAAM,UAAU,qBAAqB,CAAC,IAAc;IAClD,MAAM,SAAS,GAAG,aAAa,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAC5D,MAAM,WAAW,GAAG,aAAa,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IAEzD,MAAM,aAAa,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC;IACtC,MAAM,gBAAgB,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC;IAE5C,MAAM,iBAAiB,GAAG,aAAa;QACrC,CAAC,CAAC,WAAW,CAAC,aAAa,CAAC;QAC5B,CAAC,CAAC,SAAS,CAAC;IAEd,MAAM,aAAa,GAAG,CAAC,CAAC,CAAC,aAAa,IAAI,gBAAgB,CAAC,CAAC;IAE5D,MAAM,YAAY,GAAG,aAAa,CAAC,CAAC,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IAErE,MAAM,eAAe,GACnB,YAAY,IAAI,SAAS,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;IAEvE,MAAM,kBAAkB,GAAG,eAAe,CAAC,iBAAiB,CAAC;QAC3D,CAAC,CAAC,iBAAiB,CAAC,UAAU;QAC9B,CAAC,CAAC,SAAS,CAAC;IAEd,MAAM,SAAS,GAAG,gBAAgB,IAAI,kBAAkB,CAAC;IAEzD,MAAM,YAAY,GAAG,SAAS;QAC5B,CAAC,CAAC,iBAAiB,SAAS,EAAE;QAC9B,CAAC,CAAC,eAAe,CAAC;IAEpB,MAAM,WAAW,GAAG,eAAe,CAAC,iBAAiB,CAAC;QACpD,CAAC,CAAC,iBAAiB,CAAC,WAAW;QAC/B,CAAC,CAAC,SAAS,CAAC;IAEd,OAAO;QACL,aAAa;QACb,gBAAgB;QAChB,iBAAiB;QACjB,YAAY;QACZ,WAAW;QACX,aAAa;KACd,CAAC;AACJ,CAAC","sourcesContent":["import {useCellsStore} from '../hooks';\nimport {isSqlCell, isSqlCellStatus} from '../types';\nimport type {VegaCell, CellStatus} from '../types';\n\nexport type VegaCellDataSource = {\n selectedSqlId: string | undefined;\n selectedTableRef: string | undefined;\n selectedSqlStatus: CellStatus | undefined;\n baseSqlQuery: string;\n lastRunTime: number | undefined;\n hasDataSource: boolean;\n};\n\n/**\n * Resolves the data source for a Vega cell and builds the base SQL query.\n * Handles three data source types:\n * 1. Direct table reference (tableRef)\n * 2. Result view from another SQL cell (sqlId with resultView)\n * 3. Raw SQL from another cell (sqlId with sql)\n */\nexport function useVegaCellDataSource(cell: VegaCell): VegaCellDataSource {\n const cellsData = useCellsStore((s) => s.cells.config.data);\n const cellsStatus = useCellsStore((s) => s.cells.status);\n\n const selectedSqlId = cell.data.sqlId;\n const selectedTableRef = cell.data.tableRef;\n\n const selectedSqlStatus = selectedSqlId\n ? cellsStatus[selectedSqlId]\n : undefined;\n\n const hasDataSource = !!(selectedSqlId || selectedTableRef);\n\n const selectedCell = selectedSqlId ? cellsData[selectedSqlId] : null;\n\n const selectedCellSql =\n selectedCell && isSqlCell(selectedCell) ? selectedCell.data.sql : '';\n\n const selectedResultView = isSqlCellStatus(selectedSqlStatus)\n ? selectedSqlStatus.resultView\n : undefined;\n\n const baseTable = selectedTableRef || selectedResultView;\n\n const baseSqlQuery = baseTable\n ? `SELECT * FROM ${baseTable}`\n : selectedCellSql;\n\n const lastRunTime = isSqlCellStatus(selectedSqlStatus)\n ? selectedSqlStatus.lastRunTime\n : undefined;\n\n return {\n selectedSqlId,\n selectedTableRef,\n selectedSqlStatus,\n baseSqlQuery,\n lastRunTime,\n hasDataSource,\n };\n}\n"]}
@@ -0,0 +1,12 @@
1
+ export type VegaCellQuery = {
2
+ selectedSqlQuery: string;
3
+ };
4
+ /**
5
+ * Builds the final SQL query for a Vega cell with optional cross-filter predicates.
6
+ * If cross-filtering is enabled and active, wraps the base query as a subquery
7
+ * and applies the WHERE clause to avoid breaking raw SQL with existing clauses.
8
+ */
9
+ export declare function useVegaCellQuery(params: {
10
+ baseSqlQuery: string;
11
+ }): VegaCellQuery;
12
+ //# sourceMappingURL=useVegaCellQuery.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useVegaCellQuery.d.ts","sourceRoot":"","sources":["../../src/hooks/useVegaCellQuery.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,aAAa,GAAG;IAC1B,gBAAgB,EAAE,MAAM,CAAC;CAC1B,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE;IACvC,YAAY,EAAE,MAAM,CAAC;CACtB,GAAG,aAAa,CAMhB"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Builds the final SQL query for a Vega cell with optional cross-filter predicates.
3
+ * If cross-filtering is enabled and active, wraps the base query as a subquery
4
+ * and applies the WHERE clause to avoid breaking raw SQL with existing clauses.
5
+ */
6
+ export function useVegaCellQuery(params) {
7
+ const { baseSqlQuery } = params;
8
+ return {
9
+ selectedSqlQuery: baseSqlQuery,
10
+ };
11
+ }
12
+ //# sourceMappingURL=useVegaCellQuery.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useVegaCellQuery.js","sourceRoot":"","sources":["../../src/hooks/useVegaCellQuery.ts"],"names":[],"mappings":"AAIA;;;;GAIG;AACH,MAAM,UAAU,gBAAgB,CAAC,MAEhC;IACC,MAAM,EAAC,YAAY,EAAC,GAAG,MAAM,CAAC;IAE9B,OAAO;QACL,gBAAgB,EAAE,YAAY;KAC/B,CAAC;AACJ,CAAC","sourcesContent":["export type VegaCellQuery = {\n selectedSqlQuery: string;\n};\n\n/**\n * Builds the final SQL query for a Vega cell with optional cross-filter predicates.\n * If cross-filtering is enabled and active, wraps the base query as a subquery\n * and applies the WHERE clause to avoid breaking raw SQL with existing clauses.\n */\nexport function useVegaCellQuery(params: {\n baseSqlQuery: string;\n}): VegaCellQuery {\n const {baseSqlQuery} = params;\n\n return {\n selectedSqlQuery: baseSqlQuery,\n };\n}\n"]}
package/dist/index.d.ts CHANGED
@@ -8,18 +8,17 @@ export { createCellsSlice } from './cellsSlice';
8
8
  export type { CellsRootState } from './types';
9
9
  export { initializeInput } from './components/Input/helpers';
10
10
  export { InputCellContent } from './components/InputCellContent';
11
- export { SheetsTabBar } from './components/SheetsTabBar';
12
11
  export { SqlCellContentComponent as SqlCellContent };
13
12
  export { SqlCellRunButtonComponent as SqlCellRunButton };
14
13
  export { TextCellContent } from './components/TextCellContent';
15
14
  export { VegaCellContent } from './components/VegaCellContent';
15
+ export { CellSourceSelector } from './components/CellSourceSelector';
16
16
  export { createDefaultCellRegistry } from './defaultCellRegistry';
17
17
  export { getRenderableDependencyEdges } from './dagUtils';
18
- export { findSheetIdForCell, getSheetsByType } from './helpers';
18
+ export { findArtifactIdForCell, getUnqualifiedSqlIdentifier, normalizeCellDependencies, resolveArtifactSchemaName, toDataSourceCell, toDataSourceTable, isDataSourceCell, isDataSourceTable, fromDataSourceCell, fromDataSourceTable, } from './helpers';
19
19
  export { useCellsStore } from './hooks';
20
20
  export { findSqlDependencies, findSqlDependenciesFromAst, renderSqlWithInputs, runSqlWithCallbacks, } from './sqlHelpers';
21
21
  export * from './types';
22
- export { getEffectiveResultName, isValidSqlIdentifier } from './utils';
23
22
  export declare const SqlCell: {
24
23
  RunButton: typeof SqlCellRunButtonComponent;
25
24
  Content: import("react").FC<import("./components/SqlCellContent").SqlCellContentProps>;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAC,cAAc,IAAI,uBAAuB,EAAC,MAAM,6BAA6B,CAAC;AACtF,OAAO,EAAC,gBAAgB,IAAI,yBAAyB,EAAC,MAAM,+BAA+B,CAAC;AAE5F,OAAO,EAAC,gBAAgB,EAAC,MAAM,cAAc,CAAC;AAC9C,YAAY,EAAC,cAAc,EAAC,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAC,eAAe,EAAC,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAC,gBAAgB,EAAC,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAC,YAAY,EAAC,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAC,uBAAuB,IAAI,cAAc,EAAC,CAAC;AACnD,OAAO,EAAC,yBAAyB,IAAI,gBAAgB,EAAC,CAAC;AACvD,OAAO,EAAC,eAAe,EAAC,MAAM,8BAA8B,CAAC;AAC7D,OAAO,EAAC,eAAe,EAAC,MAAM,8BAA8B,CAAC;AAC7D,OAAO,EAAC,yBAAyB,EAAC,MAAM,uBAAuB,CAAC;AAChE,OAAO,EAAC,4BAA4B,EAAC,MAAM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EACjB,gBAAgB,EAChB,iBAAiB,EACjB,kBAAkB,EAClB,mBAAmB,GACpB,MAAM,WAAW,CAAC;AACnB,OAAO,EAAC,aAAa,EAAC,MAAM,SAAS,CAAC;AACtC,OAAO,EACL,mBAAmB,EACnB,0BAA0B,EAC1B,mBAAmB,EACnB,mBAAmB,GACpB,MAAM,cAAc,CAAC;AACtB,cAAc,SAAS,CAAC;AAExB,eAAO,MAAM,OAAO;;;CAGnB,CAAC"}
package/dist/index.js CHANGED
@@ -7,18 +7,17 @@ import { SqlCellRunButton as SqlCellRunButtonComponent } from './components/SqlC
7
7
  export { createCellsSlice } from './cellsSlice';
8
8
  export { initializeInput } from './components/Input/helpers';
9
9
  export { InputCellContent } from './components/InputCellContent';
10
- export { SheetsTabBar } from './components/SheetsTabBar';
11
10
  export { SqlCellContentComponent as SqlCellContent };
12
11
  export { SqlCellRunButtonComponent as SqlCellRunButton };
13
12
  export { TextCellContent } from './components/TextCellContent';
14
13
  export { VegaCellContent } from './components/VegaCellContent';
14
+ export { CellSourceSelector } from './components/CellSourceSelector';
15
15
  export { createDefaultCellRegistry } from './defaultCellRegistry';
16
16
  export { getRenderableDependencyEdges } from './dagUtils';
17
- export { findSheetIdForCell, getSheetsByType } from './helpers';
17
+ export { findArtifactIdForCell, getUnqualifiedSqlIdentifier, normalizeCellDependencies, resolveArtifactSchemaName, toDataSourceCell, toDataSourceTable, isDataSourceCell, isDataSourceTable, fromDataSourceCell, fromDataSourceTable, } from './helpers';
18
18
  export { useCellsStore } from './hooks';
19
19
  export { findSqlDependencies, findSqlDependenciesFromAst, renderSqlWithInputs, runSqlWithCallbacks, } from './sqlHelpers';
20
20
  export * from './types';
21
- export { getEffectiveResultName, isValidSqlIdentifier } from './utils';
22
21
  export const SqlCell = {
23
22
  RunButton: SqlCellRunButtonComponent,
24
23
  Content: SqlCellContentComponent,
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAC,cAAc,IAAI,uBAAuB,EAAC,MAAM,6BAA6B,CAAC;AACtF,OAAO,EAAC,gBAAgB,IAAI,yBAAyB,EAAC,MAAM,+BAA+B,CAAC;AAE5F,OAAO,EAAC,gBAAgB,EAAC,MAAM,cAAc,CAAC;AAE9C,OAAO,EAAC,eAAe,EAAC,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAC,gBAAgB,EAAC,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAC,YAAY,EAAC,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAC,uBAAuB,IAAI,cAAc,EAAC,CAAC;AACnD,OAAO,EAAC,yBAAyB,IAAI,gBAAgB,EAAC,CAAC;AACvD,OAAO,EAAC,eAAe,EAAC,MAAM,8BAA8B,CAAC;AAC7D,OAAO,EAAC,eAAe,EAAC,MAAM,8BAA8B,CAAC;AAC7D,OAAO,EAAC,yBAAyB,EAAC,MAAM,uBAAuB,CAAC;AAChE,OAAO,EAAC,4BAA4B,EAAC,MAAM,YAAY,CAAC;AACxD,OAAO,EAAC,kBAAkB,EAAE,eAAe,EAAC,MAAM,WAAW,CAAC;AAC9D,OAAO,EAAC,aAAa,EAAC,MAAM,SAAS,CAAC;AACtC,OAAO,EACL,mBAAmB,EACnB,0BAA0B,EAC1B,mBAAmB,EACnB,mBAAmB,GACpB,MAAM,cAAc,CAAC;AACtB,cAAc,SAAS,CAAC;AACxB,OAAO,EAAC,sBAAsB,EAAE,oBAAoB,EAAC,MAAM,SAAS,CAAC;AAErE,MAAM,CAAC,MAAM,OAAO,GAAG;IACrB,SAAS,EAAE,yBAAyB;IACpC,OAAO,EAAE,uBAAuB;CACjC,CAAC","sourcesContent":["/**\n * {@include ../README.md}\n * @packageDocumentation\n */\n\nimport {SqlCellContent as SqlCellContentComponent} from './components/SqlCellContent';\nimport {SqlCellRunButton as SqlCellRunButtonComponent} from './components/SqlCellRunButton';\n\nexport {createCellsSlice} from './cellsSlice';\nexport type {CellsRootState} from './types';\nexport {initializeInput} from './components/Input/helpers';\nexport {InputCellContent} from './components/InputCellContent';\nexport {SheetsTabBar} from './components/SheetsTabBar';\nexport {SqlCellContentComponent as SqlCellContent};\nexport {SqlCellRunButtonComponent as SqlCellRunButton};\nexport {TextCellContent} from './components/TextCellContent';\nexport {VegaCellContent} from './components/VegaCellContent';\nexport {createDefaultCellRegistry} from './defaultCellRegistry';\nexport {getRenderableDependencyEdges} from './dagUtils';\nexport {findSheetIdForCell, getSheetsByType} from './helpers';\nexport {useCellsStore} from './hooks';\nexport {\n findSqlDependencies,\n findSqlDependenciesFromAst,\n renderSqlWithInputs,\n runSqlWithCallbacks,\n} from './sqlHelpers';\nexport * from './types';\nexport {getEffectiveResultName, isValidSqlIdentifier} from './utils';\n\nexport const SqlCell = {\n RunButton: SqlCellRunButtonComponent,\n Content: SqlCellContentComponent,\n};\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAC,cAAc,IAAI,uBAAuB,EAAC,MAAM,6BAA6B,CAAC;AACtF,OAAO,EAAC,gBAAgB,IAAI,yBAAyB,EAAC,MAAM,+BAA+B,CAAC;AAE5F,OAAO,EAAC,gBAAgB,EAAC,MAAM,cAAc,CAAC;AAE9C,OAAO,EAAC,eAAe,EAAC,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAC,gBAAgB,EAAC,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAC,uBAAuB,IAAI,cAAc,EAAC,CAAC;AACnD,OAAO,EAAC,yBAAyB,IAAI,gBAAgB,EAAC,CAAC;AACvD,OAAO,EAAC,eAAe,EAAC,MAAM,8BAA8B,CAAC;AAC7D,OAAO,EAAC,eAAe,EAAC,MAAM,8BAA8B,CAAC;AAC7D,OAAO,EAAC,kBAAkB,EAAC,MAAM,iCAAiC,CAAC;AACnE,OAAO,EAAC,yBAAyB,EAAC,MAAM,uBAAuB,CAAC;AAChE,OAAO,EAAC,4BAA4B,EAAC,MAAM,YAAY,CAAC;AACxD,OAAO,EACL,qBAAqB,EACrB,2BAA2B,EAC3B,yBAAyB,EACzB,yBAAyB,EACzB,gBAAgB,EAChB,iBAAiB,EACjB,gBAAgB,EAChB,iBAAiB,EACjB,kBAAkB,EAClB,mBAAmB,GACpB,MAAM,WAAW,CAAC;AACnB,OAAO,EAAC,aAAa,EAAC,MAAM,SAAS,CAAC;AACtC,OAAO,EACL,mBAAmB,EACnB,0BAA0B,EAC1B,mBAAmB,EACnB,mBAAmB,GACpB,MAAM,cAAc,CAAC;AACtB,cAAc,SAAS,CAAC;AAExB,MAAM,CAAC,MAAM,OAAO,GAAG;IACrB,SAAS,EAAE,yBAAyB;IACpC,OAAO,EAAE,uBAAuB;CACjC,CAAC","sourcesContent":["/**\n * {@include ../README.md}\n * @packageDocumentation\n */\n\nimport {SqlCellContent as SqlCellContentComponent} from './components/SqlCellContent';\nimport {SqlCellRunButton as SqlCellRunButtonComponent} from './components/SqlCellRunButton';\n\nexport {createCellsSlice} from './cellsSlice';\nexport type {CellsRootState} from './types';\nexport {initializeInput} from './components/Input/helpers';\nexport {InputCellContent} from './components/InputCellContent';\nexport {SqlCellContentComponent as SqlCellContent};\nexport {SqlCellRunButtonComponent as SqlCellRunButton};\nexport {TextCellContent} from './components/TextCellContent';\nexport {VegaCellContent} from './components/VegaCellContent';\nexport {CellSourceSelector} from './components/CellSourceSelector';\nexport {createDefaultCellRegistry} from './defaultCellRegistry';\nexport {getRenderableDependencyEdges} from './dagUtils';\nexport {\n findArtifactIdForCell,\n getUnqualifiedSqlIdentifier,\n normalizeCellDependencies,\n resolveArtifactSchemaName,\n toDataSourceCell,\n toDataSourceTable,\n isDataSourceCell,\n isDataSourceTable,\n fromDataSourceCell,\n fromDataSourceTable,\n} from './helpers';\nexport {useCellsStore} from './hooks';\nexport {\n findSqlDependencies,\n findSqlDependenciesFromAst,\n renderSqlWithInputs,\n runSqlWithCallbacks,\n} from './sqlHelpers';\nexport * from './types';\n\nexport const SqlCell = {\n RunButton: SqlCellRunButtonComponent,\n Content: SqlCellContentComponent,\n};\n"]}
@@ -1,4 +1,4 @@
1
- import type { QualifiedTableName } from '@sqlrooms/duckdb';
1
+ import { type QualifiedTableName, type RawSqlTableReference } from '@sqlrooms/duckdb';
2
2
  /**
3
3
  * Centralized policy for persisting SQL cell query results.
4
4
  *
@@ -13,7 +13,7 @@ import type { QualifiedTableName } from '@sqlrooms/duckdb';
13
13
  * migrations may have created either form for the same logical result name.
14
14
  */
15
15
  export type ResultRelationType = 'view' | 'table';
16
- export type ResultRelationName = string | QualifiedTableName;
16
+ export type ResultRelationName = string | QualifiedTableName | RawSqlTableReference;
17
17
  type SqlConnectorLike = {
18
18
  query: (sql: string, options?: {
19
19
  signal?: AbortSignal;
@@ -1 +1 @@
1
- {"version":3,"file":"resultRelationPolicy.d.ts","sourceRoot":"","sources":["../src/resultRelationPolicy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,kBAAkB,EAAC,MAAM,kBAAkB,CAAC;AAEzD;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,kBAAkB,GAAG,MAAM,GAAG,OAAO,CAAC;AAClD,MAAM,MAAM,kBAAkB,GAAG,MAAM,GAAG,kBAAkB,CAAC;AAE7D,KAAK,gBAAgB,GAAG;IACtB,KAAK,EAAE,CACL,GAAG,EAAE,MAAM,EACX,OAAO,CAAC,EAAE;QAAC,MAAM,CAAC,EAAE,WAAW,CAAA;KAAC,KAC7B,WAAW,CAAC,OAAO,CAAC,CAAC;CAC3B,CAAC;AAMF;;;;;;;GAOG;AACH,wBAAgB,0BAA0B,CAAC,IAAI,EAAE;IAC/C,oBAAoB,CAAC,EAAE,kBAAkB,CAAC;IAC1C,aAAa,EAAE,OAAO,CAAC;CACxB,GAAG,kBAAkB,CAIrB;AAED;;;;;GAKG;AACH,wBAAsB,6BAA6B,CAAC,IAAI,EAAE;IACxD,SAAS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wBAAsB,6BAA6B,CAAC,IAAI,EAAE;IACxD,SAAS,EAAE,gBAAgB,CAAC;IAC5B,YAAY,EAAE,kBAAkB,CAAC;IACjC,YAAY,EAAE,kBAAkB,CAAC;IACjC,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB,iBAeA;AAED;;;;;GAKG;AACH,wBAAsB,kBAAkB,CAAC,IAAI,EAAE;IAC7C,SAAS,EAAE,gBAAgB,CAAC;IAC5B,YAAY,CAAC,EAAE,kBAAkB,CAAC;CACnC,iBAMA;AAED;;;;;;;;GAQG;AACH,wBAAsB,oBAAoB,CAAC,IAAI,EAAE;IAC/C,SAAS,EAAE,gBAAgB,CAAC;IAC5B,eAAe,EAAE,kBAAkB,CAAC;IACpC,eAAe,EAAE,kBAAkB,CAAC;IACpC,YAAY,EAAE,kBAAkB,CAAC;IACjC,OAAO,EAAE,MAAM,CAAC;CACjB,iBAkBA"}
@@ -1,5 +1,13 @@
1
+ import { getRawSqlTableReference, quoteParsedRawSqlTableReference, } from '@sqlrooms/duckdb';
1
2
  function toRelationSqlName(relationName) {
2
- return relationName.toString();
3
+ const relationReference = typeof relationName === 'string'
4
+ ? relationName
5
+ : getRawSqlTableReference(relationName);
6
+ const rawSqlTableReference = quoteParsedRawSqlTableReference(relationReference);
7
+ if (!rawSqlTableReference) {
8
+ throw new Error(`Invalid SQL cell result relation "${relationReference}".`);
9
+ }
10
+ return rawSqlTableReference;
3
11
  }
4
12
  /**
5
13
  * Chooses whether a SQL cell result should be stored as a logical view or a
@@ -1 +1 @@
1
- {"version":3,"file":"resultRelationPolicy.js","sourceRoot":"","sources":["../src/resultRelationPolicy.ts"],"names":[],"mappings":"AAyBA,SAAS,iBAAiB,CAAC,YAAgC;IACzD,OAAO,YAAY,CAAC,QAAQ,EAAE,CAAC;AACjC,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,0BAA0B,CAAC,IAG1C;IACC,MAAM,EAAC,oBAAoB,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,CAAC,eAAe,CAAC,CAAC;IAC9D,MAAM,kBAAkB,GAAG,iBAAiB,CAAC,eAAe,CAAC,CAAC;IAE9D,yDAAyD;IACzD,MAAM,kBAAkB,CAAC,EAAC,SAAS,EAAE,YAAY,EAAE,kBAAkB,EAAC,CAAC,CAAC;IAExE,IAAI,YAAY,KAAK,OAAO,EAAE,CAAC;QAC7B,MAAM,SAAS,CAAC,KAAK,CACnB,gBAAgB,kBAAkB,qBAAqB,kBAAkB,EAAE,CAC5E,CAAC;IACJ,CAAC;SAAM,CAAC;QACN,MAAM,SAAS,CAAC,KAAK,CAAC,eAAe,kBAAkB,OAAO,OAAO,EAAE,CAAC,CAAC;IAC3E,CAAC;IAED,MAAM,kBAAkB,CAAC,EAAC,SAAS,EAAE,YAAY,EAAE,kBAAkB,EAAC,CAAC,CAAC;AAC1E,CAAC","sourcesContent":["import type {QualifiedTableName} from '@sqlrooms/duckdb';\n\n/**\n * Centralized policy for persisting SQL cell query results.\n *\n * This module implements an adaptive strategy:\n * - first run chooses `table` when downstream dependencies exist, otherwise\n * `view`;\n * - subsequent runs preserve the previously chosen relation type.\n *\n * The policy is shared by execution, rename, and cleanup paths so behavior\n * stays consistent across cross-cutting lifecycle events. Cleanup intentionally\n * drops both relation variants (`VIEW` and `TABLE`) because historical runs or\n * migrations may have created either form for the same logical result name.\n */\nexport type ResultRelationType = 'view' | 'table';\nexport type ResultRelationName = string | QualifiedTableName;\n\ntype SqlConnectorLike = {\n query: (\n sql: string,\n options?: {signal?: AbortSignal},\n ) => PromiseLike<unknown>;\n};\n\nfunction toRelationSqlName(relationName: ResultRelationName): string {\n return relationName.toString();\n}\n\n/**\n * Chooses whether a SQL cell result should be stored as a logical view or a\n * materialized table.\n *\n * The policy is sticky: once a relation type has been selected for a cell,\n * later executions preserve that choice. On first execution, downstream usage\n * is used as a proxy for reuse.\n */\nexport function chooseAdaptiveRelationType(args: {\n previousRelationType?: ResultRelationType;\n hasDownstream: boolean;\n}): ResultRelationType {\n const {previousRelationType, hasDownstream} = args;\n if (previousRelationType) return previousRelationType;\n return hasDownstream ? 'table' : 'view';\n}\n\n/**\n * Creates or replaces the relation that backs a SQL cell result.\n *\n * - `table`: materializes data for stable repeated reads.\n * - `view`: stores query definition for lightweight freshness.\n */\nexport async function createOrReplaceResultRelation(args: {\n connector: SqlConnectorLike;\n relationName: ResultRelationName;\n relationType: ResultRelationType;\n sql: string;\n signal?: AbortSignal;\n}) {\n const {connector, relationName, relationType, sql, signal} = args;\n const relationSqlName = toRelationSqlName(relationName);\n if (relationType === 'table') {\n await connector.query(\n `CREATE OR REPLACE TABLE ${relationSqlName} AS ${sql}`,\n {\n signal,\n },\n );\n return;\n }\n await connector.query(`CREATE OR REPLACE VIEW ${relationSqlName} AS ${sql}`, {\n signal,\n });\n}\n\n/**\n * Drops both view and table variants for a relation name.\n *\n * This is intentionally defensive because different runs may have used\n * different relation modes.\n */\nexport async function dropResultRelation(args: {\n connector: SqlConnectorLike;\n relationName?: ResultRelationName;\n}) {\n const {connector, relationName} = args;\n if (!relationName) return;\n const relationSqlName = toRelationSqlName(relationName);\n await connector.query(`DROP VIEW IF EXISTS ${relationSqlName}`);\n await connector.query(`DROP TABLE IF EXISTS ${relationSqlName}`);\n}\n\n/**\n * Renames a saved SQL cell result relation while preserving its mode.\n *\n * - `table`: copies current relation data into the new name.\n * - `view`: recreates the view definition under the new name.\n *\n * Any existing destination relation is removed first, and the old source name\n * is cleaned up after the new relation is created.\n */\nexport async function renameResultRelation(args: {\n connector: SqlConnectorLike;\n oldRelationName: ResultRelationName;\n newRelationName: ResultRelationName;\n relationType: ResultRelationType;\n viewSql: string;\n}) {\n const {connector, oldRelationName, newRelationName, relationType, viewSql} =\n args;\n const oldRelationSqlName = toRelationSqlName(oldRelationName);\n const newRelationSqlName = toRelationSqlName(newRelationName);\n\n // Clear destination first in case a stale object exists.\n await dropResultRelation({connector, relationName: newRelationSqlName});\n\n if (relationType === 'table') {\n await connector.query(\n `CREATE TABLE ${newRelationSqlName} AS SELECT * FROM ${oldRelationSqlName}`,\n );\n } else {\n await connector.query(`CREATE VIEW ${newRelationSqlName} AS ${viewSql}`);\n }\n\n await dropResultRelation({connector, relationName: oldRelationSqlName});\n}\n"]}
1
+ {"version":3,"file":"resultRelationPolicy.js","sourceRoot":"","sources":["../src/resultRelationPolicy.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,uBAAuB,EACvB,+BAA+B,GAGhC,MAAM,kBAAkB,CAAC;AA4B1B,SAAS,iBAAiB,CAAC,YAAgC;IACzD,MAAM,iBAAiB,GACrB,OAAO,YAAY,KAAK,QAAQ;QAC9B,CAAC,CAAC,YAAY;QACd,CAAC,CAAC,uBAAuB,CAAC,YAAY,CAAC,CAAC;IAC5C,MAAM,oBAAoB,GACxB,+BAA+B,CAAC,iBAAiB,CAAC,CAAC;IACrD,IAAI,CAAC,oBAAoB,EAAE,CAAC;QAC1B,MAAM,IAAI,KAAK,CAAC,qCAAqC,iBAAiB,IAAI,CAAC,CAAC;IAC9E,CAAC;IACD,OAAO,oBAAoB,CAAC;AAC9B,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,0BAA0B,CAAC,IAG1C;IACC,MAAM,EAAC,oBAAoB,EAAE,aAAa,EAAC,GAAG,IAAI,CAAC;IACnD,IAAI,oBAAoB;QAAE,OAAO,oBAAoB,CAAC;IACtD,OAAO,aAAa,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC;AAC1C,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,6BAA6B,CAAC,IAMnD;IACC,MAAM,EAAC,SAAS,EAAE,YAAY,EAAE,YAAY,EAAE,GAAG,EAAE,MAAM,EAAC,GAAG,IAAI,CAAC;IAClE,MAAM,eAAe,GAAG,iBAAiB,CAAC,YAAY,CAAC,CAAC;IACxD,IAAI,YAAY,KAAK,OAAO,EAAE,CAAC;QAC7B,MAAM,SAAS,CAAC,KAAK,CACnB,2BAA2B,eAAe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AY,EAAE,kBAAkB,EAAC,CAAC,CAAC;AAC1E,CAAC","sourcesContent":["import {\n getRawSqlTableReference,\n quoteParsedRawSqlTableReference,\n type QualifiedTableName,\n type RawSqlTableReference,\n} from '@sqlrooms/duckdb';\n\n/**\n * Centralized policy for persisting SQL cell query results.\n *\n * This module implements an adaptive strategy:\n * - first run chooses `table` when downstream dependencies exist, otherwise\n * `view`;\n * - subsequent runs preserve the previously chosen relation type.\n *\n * The policy is shared by execution, rename, and cleanup paths so behavior\n * stays consistent across cross-cutting lifecycle events. Cleanup intentionally\n * drops both relation variants (`VIEW` and `TABLE`) because historical runs or\n * migrations may have created either form for the same logical result name.\n */\nexport type ResultRelationType = 'view' | 'table';\nexport type ResultRelationName =\n | string\n | QualifiedTableName\n | RawSqlTableReference;\n\ntype SqlConnectorLike = {\n query: (\n sql: string,\n options?: {signal?: AbortSignal},\n ) => PromiseLike<unknown>;\n};\n\nfunction toRelationSqlName(relationName: ResultRelationName): string {\n const relationReference =\n typeof relationName === 'string'\n ? relationName\n : getRawSqlTableReference(relationName);\n const rawSqlTableReference =\n quoteParsedRawSqlTableReference(relationReference);\n if (!rawSqlTableReference) {\n throw new Error(`Invalid SQL cell result relation \"${relationReference}\".`);\n }\n return rawSqlTableReference;\n}\n\n/**\n * Chooses whether a SQL cell result should be stored as a logical view or a\n * materialized table.\n *\n * The policy is sticky: once a relation type has been selected for a cell,\n * later executions preserve that choice. On first execution, downstream usage\n * is used as a proxy for reuse.\n */\nexport function chooseAdaptiveRelationType(args: {\n previousRelationType?: ResultRelationType;\n hasDownstream: boolean;\n}): ResultRelationType {\n const {previousRelationType, hasDownstream} = args;\n if (previousRelationType) return previousRelationType;\n return hasDownstream ? 'table' : 'view';\n}\n\n/**\n * Creates or replaces the relation that backs a SQL cell result.\n *\n * - `table`: materializes data for stable repeated reads.\n * - `view`: stores query definition for lightweight freshness.\n */\nexport async function createOrReplaceResultRelation(args: {\n connector: SqlConnectorLike;\n relationName: ResultRelationName;\n relationType: ResultRelationType;\n sql: string;\n signal?: AbortSignal;\n}) {\n const {connector, relationName, relationType, sql, signal} = args;\n const relationSqlName = toRelationSqlName(relationName);\n if (relationType === 'table') {\n await connector.query(\n `CREATE OR REPLACE TABLE ${relationSqlName} AS ${sql}`,\n {\n signal,\n },\n );\n return;\n }\n await connector.query(`CREATE OR REPLACE VIEW ${relationSqlName} AS ${sql}`, {\n signal,\n });\n}\n\n/**\n * Drops both view and table variants for a relation name.\n *\n * This is intentionally defensive because different runs may have used\n * different relation modes.\n */\nexport async function dropResultRelation(args: {\n connector: SqlConnectorLike;\n relationName?: ResultRelationName;\n}) {\n const {connector, relationName} = args;\n if (!relationName) return;\n const relationSqlName = toRelationSqlName(relationName);\n await connector.query(`DROP VIEW IF EXISTS ${relationSqlName}`);\n await connector.query(`DROP TABLE IF EXISTS ${relationSqlName}`);\n}\n\n/**\n * Renames a saved SQL cell result relation while preserving its mode.\n *\n * - `table`: copies current relation data into the new name.\n * - `view`: recreates the view definition under the new name.\n *\n * Any existing destination relation is removed first, and the old source name\n * is cleaned up after the new relation is created.\n */\nexport async function renameResultRelation(args: {\n connector: SqlConnectorLike;\n oldRelationName: ResultRelationName;\n newRelationName: ResultRelationName;\n relationType: ResultRelationType;\n viewSql: string;\n}) {\n const {connector, oldRelationName, newRelationName, relationType, viewSql} =\n args;\n const oldRelationSqlName = toRelationSqlName(oldRelationName);\n const newRelationSqlName = toRelationSqlName(newRelationName);\n\n // Clear destination first in case a stale object exists.\n await dropResultRelation({connector, relationName: newRelationSqlName});\n\n if (relationType === 'table') {\n await connector.query(\n `CREATE TABLE ${newRelationSqlName} AS SELECT * FROM ${oldRelationSqlName}`,\n );\n } else {\n await connector.query(`CREATE VIEW ${newRelationSqlName} AS ${viewSql}`);\n }\n\n await dropResultRelation({connector, relationName: oldRelationSqlName});\n}\n"]}
@@ -1,4 +1,4 @@
1
- import type { Cell, Edge, SqlDependencyOptions, SqlRenderInput, SqlRunCallbacks, SqlRunResult } from './types';
1
+ import type { Cell, CellDependencies, Edge, SqlDependencyOptions, SqlRenderInput, SqlRunCallbacks, SqlRunResult } from './types';
2
2
  export declare function deriveEdgesFromSql(cellId: string, sql: string, allCells: Record<string, Cell>): Edge[];
3
3
  export declare function renderSqlWithInputs(rawSql: string, inputs: SqlRenderInput[]): string;
4
4
  export declare function findSqlDependencies<TCell extends {
@@ -15,7 +15,7 @@ export declare function findSqlDependencies<TCell extends {
15
15
  export declare function runSqlWithCallbacks(run: () => Promise<SqlRunResult>, callbacks?: SqlRunCallbacks): Promise<void>;
16
16
  /**
17
17
  * Find SQL cell dependencies using AST-based parsing.
18
- * This provides more accurate detection than text-based matching.
18
+ * Returns cell dependencies and unmatched table references.
19
19
  */
20
20
  export declare function findSqlDependenciesFromAst(opts: {
21
21
  sql: string;
@@ -24,17 +24,17 @@ export declare function findSqlDependenciesFromAst(opts: {
24
24
  error: boolean;
25
25
  statements?: unknown[];
26
26
  }>;
27
- }): Promise<string[]>;
27
+ }): Promise<CellDependencies>;
28
28
  /**
29
- * Rewrites unqualified references to known sheet-local result names as
29
+ * Rewrites unqualified references to known artifact-local result names as
30
30
  * schema-qualified references. This keeps SQL ergonomic without mutable
31
31
  * connector-level current schema state.
32
32
  */
33
- export declare function qualifySheetLocalResultNames(opts: {
33
+ export declare function qualifyArtifactLocalResultNames(opts: {
34
34
  sql: string;
35
- sheetSchema: string;
36
- sheetDatabase?: string;
37
- sheetCellIds: string[];
35
+ artifactSchema: string;
36
+ artifactDatabase?: string;
37
+ artifactCellIds: string[];
38
38
  cells: Record<string, Cell>;
39
39
  getSqlResultName: (cellId: string) => string | undefined;
40
40
  }): string;
@@ -1 +1 @@
1
- {"version":3,"file":"sqlHelpers.d.ts","sourceRoot":"","sources":["../src/sqlHelpers.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,IAAI,EACJ,IAAI,EAEJ,oBAAoB,EACpB,cAAc,EACd,eAAe,EACf,YAAY,EACb,MAAM,SAAS,CAAC;AAIjB,wBAAg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