@sqlrooms/cells 0.29.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +9 -0
- package/README.md +32 -0
- package/dist/cellsSlice.d.ts +3 -0
- package/dist/cellsSlice.d.ts.map +1 -0
- package/dist/cellsSlice.js +602 -0
- package/dist/cellsSlice.js.map +1 -0
- package/dist/components/DeleteSheetModal.d.ts +9 -0
- package/dist/components/DeleteSheetModal.d.ts.map +1 -0
- package/dist/components/DeleteSheetModal.js +6 -0
- package/dist/components/DeleteSheetModal.js.map +1 -0
- package/dist/components/Input/ConfigPanel/DropdownConfig.d.ts +2 -0
- package/dist/components/Input/ConfigPanel/DropdownConfig.d.ts.map +1 -0
- package/dist/components/Input/ConfigPanel/DropdownConfig.js +44 -0
- package/dist/components/Input/ConfigPanel/DropdownConfig.js.map +1 -0
- package/dist/components/Input/ConfigPanel/InputConfigPanel.d.ts +11 -0
- package/dist/components/Input/ConfigPanel/InputConfigPanel.d.ts.map +1 -0
- package/dist/components/Input/ConfigPanel/InputConfigPanel.js +65 -0
- package/dist/components/Input/ConfigPanel/InputConfigPanel.js.map +1 -0
- package/dist/components/Input/ConfigPanel/SliderConfig.d.ts +2 -0
- package/dist/components/Input/ConfigPanel/SliderConfig.d.ts.map +1 -0
- package/dist/components/Input/ConfigPanel/SliderConfig.js +19 -0
- package/dist/components/Input/ConfigPanel/SliderConfig.js.map +1 -0
- package/dist/components/Input/ConfigPanel/TextConfig.d.ts +2 -0
- package/dist/components/Input/ConfigPanel/TextConfig.d.ts.map +1 -0
- package/dist/components/Input/ConfigPanel/TextConfig.js +8 -0
- package/dist/components/Input/ConfigPanel/TextConfig.js.map +1 -0
- package/dist/components/Input/helpers.d.ts +3 -0
- package/dist/components/Input/helpers.d.ts.map +1 -0
- package/dist/components/Input/helpers.js +28 -0
- package/dist/components/Input/helpers.js.map +1 -0
- package/dist/components/InputCellContent.d.ts +9 -0
- package/dist/components/InputCellContent.d.ts.map +1 -0
- package/dist/components/InputCellContent.js +38 -0
- package/dist/components/InputCellContent.js.map +1 -0
- package/dist/components/SheetsTabBar.d.ts +6 -0
- package/dist/components/SheetsTabBar.d.ts.map +1 -0
- package/dist/components/SheetsTabBar.js +57 -0
- package/dist/components/SheetsTabBar.js.map +1 -0
- package/dist/components/SqlCellContent.d.ts +9 -0
- package/dist/components/SqlCellContent.d.ts.map +1 -0
- package/dist/components/SqlCellContent.js +222 -0
- package/dist/components/SqlCellContent.js.map +1 -0
- package/dist/components/SqlCellRunButton.d.ts +17 -0
- package/dist/components/SqlCellRunButton.d.ts.map +1 -0
- package/dist/components/SqlCellRunButton.js +11 -0
- package/dist/components/SqlCellRunButton.js.map +1 -0
- package/dist/components/TextCellContent.d.ts +9 -0
- package/dist/components/TextCellContent.d.ts.map +1 -0
- package/dist/components/TextCellContent.js +27 -0
- package/dist/components/TextCellContent.js.map +1 -0
- package/dist/components/VegaCellContent.d.ts +9 -0
- package/dist/components/VegaCellContent.d.ts.map +1 -0
- package/dist/components/VegaCellContent.js +66 -0
- package/dist/components/VegaCellContent.js.map +1 -0
- package/dist/components/VegaConfigPanel.d.ts +8 -0
- package/dist/components/VegaConfigPanel.d.ts.map +1 -0
- package/dist/components/VegaConfigPanel.js +72 -0
- package/dist/components/VegaConfigPanel.js.map +1 -0
- package/dist/dagUtils.d.ts +20 -0
- package/dist/dagUtils.d.ts.map +1 -0
- package/dist/dagUtils.js +233 -0
- package/dist/dagUtils.js.map +1 -0
- package/dist/defaultCellRegistry.d.ts +3 -0
- package/dist/defaultCellRegistry.d.ts.map +1 -0
- package/dist/defaultCellRegistry.js +177 -0
- package/dist/defaultCellRegistry.js.map +1 -0
- package/dist/execution.d.ts +9 -0
- package/dist/execution.d.ts.map +1 -0
- package/dist/execution.js +195 -0
- package/dist/execution.js.map +1 -0
- package/dist/helpers.d.ts +45 -0
- package/dist/helpers.d.ts.map +1 -0
- package/dist/helpers.js +124 -0
- package/dist/helpers.js.map +1 -0
- package/dist/hooks.d.ts +11 -0
- package/dist/hooks.d.ts.map +1 -0
- package/dist/hooks.js +9 -0
- package/dist/hooks.js.map +1 -0
- package/dist/index.d.ts +27 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +26 -0
- package/dist/index.js.map +1 -0
- package/dist/resultRelationPolicy.d.ts +74 -0
- package/dist/resultRelationPolicy.d.ts.map +1 -0
- package/dist/resultRelationPolicy.js +74 -0
- package/dist/resultRelationPolicy.js.map +1 -0
- package/dist/sqlHelpers.d.ts +41 -0
- package/dist/sqlHelpers.d.ts.map +1 -0
- package/dist/sqlHelpers.js +190 -0
- package/dist/sqlHelpers.js.map +1 -0
- package/dist/types.d.ts +501 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +144 -0
- package/dist/types.js.map +1 -0
- package/dist/utils.d.ts +17 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +35 -0
- package/dist/utils.js.map +1 -0
- package/package.json +57 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,CAAC,EAAC,MAAM,KAAK,CAAC;AAKtB,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC;AAEnC,uBAAuB;AACvB,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,QAAQ,EAAE,UAAU,CAAC,CAAC,CAAC;AAGjE,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,CAAC,MAAM,CAAC;IAChC,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC;IACrC,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE;IACnB,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC;CAC9B,CAAC,CAAC;AAGH,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,gBAAgB,GAAG,CAAC,CAAC,MAAM,CAAC;IACvC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,IAAI,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC;IAC5C,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,KAAK,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC;IAC/C,UAAU,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC;IAC3C,cAAc,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CACtC,CAAC,CAAC;AAoFH,MAAM,UAAU,SAAS,CAAC,IAAU;IAClC,OAAO,IAAI,CAAC,IAAI,KAAK,KAAK,CAAC;AAC7B,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,IAAU;IACnC,OAAO,IAAI,CAAC,IAAI,KAAK,MAAM,CAAC;AAC9B,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,IAAU;IACnC,OAAO,IAAI,CAAC,IAAI,KAAK,MAAM,CAAC;AAC9B,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,IAAU;IACpC,OAAO,IAAI,CAAC,IAAI,KAAK,OAAO,CAAC;AAC/B,CAAC","sourcesContent":["import type {DbSliceState} from '@sqlrooms/db';\nimport type {BaseRoomStoreState} from '@sqlrooms/room-store';\nimport type * as arrow from 'apache-arrow';\nimport type React from 'react';\nimport {z} from 'zod';\n\n/** Cell types */\nexport type BuiltInCellType = 'sql' | 'text' | 'vega' | 'input';\nexport type CellType = BuiltInCellType | (string & {});\nexport const CellType = z.string();\n\n/** Input Cell types */\nexport const InputTypes = z.enum(['text', 'slider', 'dropdown']);\nexport type InputTypes = z.infer<typeof InputTypes>;\n\nexport const InputText = z.object({\n kind: z.literal(InputTypes.enum.text),\n varName: z.string(),\n value: z.string().default(''),\n});\nexport type InputText = z.infer<typeof InputText>;\n\nexport const InputSlider = z.object({\n kind: z.literal(InputTypes.enum.slider),\n varName: z.string(),\n min: z.number().default(0),\n max: z.number().default(100),\n step: z.number().default(1),\n value: z.number().default(0),\n});\nexport type InputSlider = z.infer<typeof InputSlider>;\n\nexport const InputDropdown = z.object({\n kind: z.literal(InputTypes.enum.dropdown),\n varName: z.string(),\n options: z.array(z.string()).default([]),\n value: z.string().default(''),\n});\nexport type InputDropdown = z.infer<typeof InputDropdown>;\n\nexport const InputUnion = z.discriminatedUnion('kind', [\n InputText,\n InputSlider,\n InputDropdown,\n]);\nexport type InputUnion = z.infer<typeof InputUnion>;\n\n/** SQL Cell */\nexport const SqlCellData = z.object({\n title: z.string().default('Untitled'),\n sql: z.string().default(''),\n resultName: z.string().optional(), // SQL-friendly identifier for the result view\n connectorId: z.string().optional(),\n});\nexport type SqlCellData = z.infer<typeof SqlCellData>;\n\n/** Text Cell */\nexport const TextCellData = z.object({\n title: z.string().default('Text'),\n text: z.string().default(''),\n});\nexport type TextCellData = z.infer<typeof TextCellData>;\n\n/** Vega Cell */\nexport const VegaCellData = z.object({\n title: z.string().default('Chart'),\n sqlId: z.string().optional(), // In notebook, it links to another cell. In canvas, it might be the same.\n sql: z.string().optional(), // In canvas, it often has its own SQL.\n vegaSpec: z.any().optional(),\n});\nexport type VegaCellData = z.infer<typeof VegaCellData>;\n\n/** Input Cell Data */\nexport const InputCellData = z.object({\n title: z.string().default('Input'),\n input: InputUnion,\n});\nexport type InputCellData = z.infer<typeof InputCellData>;\n\n/** Unified Cell Data */\nexport const CellData = z.object({\n type: CellType,\n data: z.record(z.string(), z.any()),\n});\nexport type CellData = {\n type: CellType;\n data: Record<string, any>;\n};\n\nexport const SqlCell = z.object({\n id: z.string(),\n type: z.literal('sql'),\n data: SqlCellData,\n});\nexport type SqlCell = z.infer<typeof SqlCell>;\n\nexport const TextCell = z.object({\n id: z.string(),\n type: z.literal('text'),\n data: TextCellData,\n});\nexport type TextCell = z.infer<typeof TextCell>;\n\nexport const VegaCell = z.object({\n id: z.string(),\n type: z.literal('vega'),\n data: VegaCellData,\n});\nexport type VegaCell = z.infer<typeof VegaCell>;\n\nexport const InputCell = z.object({\n id: z.string(),\n type: z.literal('input'),\n data: InputCellData,\n});\nexport type InputCell = z.infer<typeof InputCell>;\nexport const SqlCellSchema = SqlCell;\nexport const TextCellSchema = TextCell;\nexport const VegaCellSchema = VegaCell;\nexport const InputCellSchema = InputCell;\n\n/** Canonical Cell */\nexport const Cell = z.object({\n id: z.string(),\n type: CellType,\n data: z.record(z.string(), z.any()),\n});\nexport type Cell = {\n id: string;\n type: CellType;\n data: Record<string, any>;\n};\n\n/** Unified Cell Registry */\nexport type CellContainerProps = {\n header?: React.ReactNode;\n content: React.ReactNode;\n footer?: React.ReactNode;\n};\n\n/** Type for SQL AST parsing function from DuckDB slice */\nexport type SqlSelectToJsonFn = (sql: string) => Promise<{\n error: boolean;\n error_type?: string;\n statements?: unknown[];\n}>;\n\nexport type CellRegistryItem<TCell extends Cell = Cell> = {\n type: string;\n title: string;\n createCell: (id: string) => TCell;\n renderCell: (props: {\n id: string;\n cell: TCell;\n renderContainer: (props: CellContainerProps) => React.ReactElement;\n }) => React.ReactElement;\n /** Find dependencies for DAG using AST-enabled async resolution. */\n findDependencies: (args: {\n cell: TCell;\n cells: Record<string, Cell>;\n sheetId: string;\n sqlSelectToJson: SqlSelectToJsonFn;\n }) => Promise<string[]>;\n /** Optional: custom execution logic (defaults to SQL execution for sql type) */\n runCell?: (args: {\n id: string;\n opts?: {cascade?: boolean; schemaName?: string};\n get: () => CellsRootState;\n set: (updater: (state: CellsRootState) => CellsRootState) => void;\n }) => Promise<void>;\n /** Optional: rename the result view when resultName changes */\n renameResult?: (args: {\n id: string;\n oldResultView: string;\n get: () => CellsRootState;\n set: (updater: (state: CellsRootState) => CellsRootState) => void;\n }) => Promise<void>;\n};\n\nexport type CellRegistry = Record<string, CellRegistryItem<any>>;\n\n/** Sheet and Edge types */\nexport const SheetType = z.enum(['notebook', 'canvas', 'app']);\nexport type SheetType = z.infer<typeof SheetType>;\n\nexport const EdgeKind = z.enum(['dependency', 'manual']);\nexport type EdgeKind = z.infer<typeof EdgeKind>;\n\nexport const Edge = z.object({\n id: z.string(),\n source: z.string(), // cellId\n target: z.string(), // cellId\n kind: EdgeKind.optional(),\n});\nexport type Edge = z.infer<typeof Edge>;\n\nexport const SheetGraphCache = z.object({\n dependencies: z.record(z.string(), z.array(z.string())).default({}),\n dependents: z.record(z.string(), z.array(z.string())).default({}),\n contentHashByCell: z.record(z.string(), z.string()).optional(),\n});\nexport type SheetGraphCache = z.infer<typeof SheetGraphCache>;\n\nexport const Sheet = z.object({\n id: z.string(),\n type: SheetType,\n title: z.string(),\n schemaName: z.string().optional(),\n cellIds: z.array(z.string()).default([]), // Which cells belong to this sheet\n edges: z.array(Edge).default([]), // Dependencies\n graphCache: SheetGraphCache.optional(),\n});\nexport type Sheet = z.infer<typeof Sheet>;\n\n/** Cell Status */\nexport const SqlCellStatus = z.object({\n type: z.literal('sql'),\n status: z.enum(['idle', 'running', 'success', 'cancel', 'error']),\n lastError: z.string().optional(),\n referencedTables: z.array(z.string()).default([]),\n resultName: z.string().optional(),\n resultView: z.string().optional(),\n resultRelationType: z.enum(['view', 'table']).optional(),\n lastRunTime: z.number().optional(),\n});\nexport type SqlCellStatus = z.infer<typeof SqlCellStatus>;\n\nexport const OtherCellStatus = z.object({\n type: z.literal('other'),\n});\nexport type OtherCellStatus = z.infer<typeof OtherCellStatus>;\n\nexport const CellStatus = z.union([SqlCellStatus, OtherCellStatus]);\nexport type CellStatus = z.infer<typeof CellStatus>;\n\n/** SQL execution results */\nexport type SqlRunResult = {\n resultName?: string;\n referencedTables?: string[];\n lastRunTime?: number;\n};\n\nexport type SqlRunCallbacks = {\n onStart?: () => void;\n onSuccess?: (result: SqlRunResult) => void;\n onError?: (message: string) => void;\n onFinally?: () => void;\n};\n\nexport type SqlRenderInput = {\n varName: string;\n value: string | number;\n};\n\nexport type SqlDependencyOptions = {\n inputTypes?: string[];\n sqlTypes?: string[];\n};\n\nexport type SqlCellRunStatus =\n | {\n state: 'idle' | 'running' | 'success' | 'cancel' | 'error';\n message?: string;\n resultName?: string;\n }\n | undefined;\n\nexport const CellsSliceConfig = z.object({\n data: z.record(z.string(), Cell).default({}),\n sheets: z.record(z.string(), Sheet).default({}),\n sheetOrder: z.array(z.string()).default([]),\n currentSheetId: z.string().optional(),\n});\nexport type CellsSliceConfig = z.infer<typeof CellsSliceConfig>;\n\nexport type CellsSliceOptions = {\n config?: Partial<CellsSliceConfig>;\n cellRegistry: CellRegistry;\n supportedSheetTypes?: SheetType[];\n};\n\n/** Data stored for a cell's query result */\nexport type CellResultData = {\n arrowTable: arrow.Table;\n totalRows: number;\n};\n\nexport type CellsSliceState = {\n cells: {\n config: CellsSliceConfig;\n status: Record<string, CellStatus>;\n activeAbortControllers: Record<string, AbortController>;\n cellRegistry: CellRegistry;\n supportedSheetTypes: SheetType[];\n /** Monotonic counter per cell, incremented when a new execution result arrives. Used to trigger pagination reset and re-render. */\n resultVersion: Record<string, number>;\n /** Monotonic counter per cell, incremented when a pagination/sorting fetch completes. Used to trigger re-render without resetting pagination. */\n pageVersion: Record<string, number>;\n\n // Cell CRUD\n addCell: (sheetId: string, cell: Cell, index?: number) => Promise<void>;\n removeCell: (id: string) => void;\n updateCell: (\n id: string,\n updater: (cell: Cell) => Cell,\n opts?: {cascade?: boolean},\n ) => Promise<void>;\n\n // Sheet CRUD\n addSheet: (title?: string, type?: SheetType) => string;\n removeSheet: (sheetId: string) => void;\n closeSheet: (sheetId: string) => void;\n openSheet: (sheetId: string) => void;\n setSheetOrder: (sheetOrder: string[]) => void;\n renameSheet: (sheetId: string, title: string) => void;\n setCurrentSheet: (sheetId: string) => void;\n\n // Edge management\n addEdge: (sheetId: string, edge: Omit<Edge, 'id'>) => void;\n removeEdge: (sheetId: string, edgeId: string) => void;\n updateEdgesFromSql: (sheetId: string, cellId: string) => Promise<void>;\n\n // Execution\n runCell: (\n id: string,\n opts?: {cascade?: boolean; schemaName?: string},\n ) => Promise<void>;\n cancelCell: (id: string) => void;\n invalidateCellStatus: (id: string) => void;\n\n // Cell result cache\n setCellResult: (id: string, data: CellResultData) => void;\n setCellResultPage: (id: string, data: CellResultData) => void;\n getCellResult: (id: string) => CellResultData | undefined;\n clearCellResult: (id: string) => void;\n fetchCellResultPage: (\n id: string,\n pagination: {pageIndex: number; pageSize: number},\n sorting?: {id: string; desc: boolean}[],\n ) => Promise<void>;\n\n // DAG methods\n getDownstream: (sheetId: string, sourceCellId: string) => string[];\n getRootCells: (sheetId: string) => string[];\n runAllCellsCascade: (sheetId: string) => Promise<void>;\n runDownstreamCascade: (\n sheetId: string,\n sourceCellId: string,\n ) => Promise<void>;\n };\n};\n\nexport type CellsRootState = BaseRoomStoreState &\n DbSliceState &\n CellsSliceState;\n\nexport function isSqlCell(cell: Cell): cell is SqlCell {\n return cell.type === 'sql';\n}\n\nexport function isTextCell(cell: Cell): cell is TextCell {\n return cell.type === 'text';\n}\n\nexport function isVegaCell(cell: Cell): cell is VegaCell {\n return cell.type === 'vega';\n}\n\nexport function isInputCell(cell: Cell): cell is InputCell {\n return cell.type === 'input';\n}\n"]}
|
package/dist/utils.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { SqlCellData } from './types';
|
|
2
|
+
export declare function isDefined<T>(value: T | undefined): value is T;
|
|
3
|
+
/**
|
|
4
|
+
* Validates that a string is a valid SQL identifier.
|
|
5
|
+
* Must start with a letter or underscore, followed by letters, digits, or underscores.
|
|
6
|
+
*/
|
|
7
|
+
export declare function isValidSqlIdentifier(name: string): boolean;
|
|
8
|
+
/**
|
|
9
|
+
* Gets the effective result name for a SQL cell.
|
|
10
|
+
* Returns explicit resultName if valid, otherwise auto-generates from title.
|
|
11
|
+
*/
|
|
12
|
+
export declare function getEffectiveResultName(data: SqlCellData, convertToValidName: (name: string) => string): string;
|
|
13
|
+
/**
|
|
14
|
+
* Generates a stable SQL schema name for a sheet id.
|
|
15
|
+
*/
|
|
16
|
+
export declare function getSheetSchemaName(sheetId: string): string;
|
|
17
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,SAAS,CAAC;AAEzC,wBAAgB,SAAS,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,SAAS,GAAG,KAAK,IAAI,CAAC,CAE7D;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAE1D;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CACpC,IAAI,EAAE,WAAW,EACjB,kBAAkB,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,GAC3C,MAAM,CAeR;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAG1D"}
|
package/dist/utils.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export function isDefined(value) {
|
|
2
|
+
return value !== undefined;
|
|
3
|
+
}
|
|
4
|
+
/**
|
|
5
|
+
* Validates that a string is a valid SQL identifier.
|
|
6
|
+
* Must start with a letter or underscore, followed by letters, digits, or underscores.
|
|
7
|
+
*/
|
|
8
|
+
export function isValidSqlIdentifier(name) {
|
|
9
|
+
return /^[a-zA-Z_][a-zA-Z0-9_]*$/.test(name);
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Gets the effective result name for a SQL cell.
|
|
13
|
+
* Returns explicit resultName if valid, otherwise auto-generates from title.
|
|
14
|
+
*/
|
|
15
|
+
export function getEffectiveResultName(data, convertToValidName) {
|
|
16
|
+
if (data.resultName && isValidSqlIdentifier(data.resultName)) {
|
|
17
|
+
return data.resultName;
|
|
18
|
+
}
|
|
19
|
+
const normalizedTitle = convertToValidName(data.title).toLowerCase();
|
|
20
|
+
// Keep SQL default titles mapped to a neutral result_* name:
|
|
21
|
+
// "SQL 1" -> "result_1", "SQL Query 2" -> "result_2".
|
|
22
|
+
const sqlDefaultMatch = normalizedTitle.match(/^sql(?:_query)?(?:_(\d+))?$/);
|
|
23
|
+
if (sqlDefaultMatch) {
|
|
24
|
+
return sqlDefaultMatch[1] ? `result_${sqlDefaultMatch[1]}` : 'result';
|
|
25
|
+
}
|
|
26
|
+
return normalizedTitle;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Generates a stable SQL schema name for a sheet id.
|
|
30
|
+
*/
|
|
31
|
+
export function getSheetSchemaName(sheetId) {
|
|
32
|
+
const normalized = sheetId.replace(/[^a-zA-Z0-9_]/g, '_').toLowerCase();
|
|
33
|
+
return `sheet_${normalized}`;
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,SAAS,CAAI,KAAoB;IAC/C,OAAO,KAAK,KAAK,SAAS,CAAC;AAC7B,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,oBAAoB,CAAC,IAAY;IAC/C,OAAO,0BAA0B,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC/C,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,sBAAsB,CACpC,IAAiB,EACjB,kBAA4C;IAE5C,IAAI,IAAI,CAAC,UAAU,IAAI,oBAAoB,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC;QAC7D,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB,CAAC;IAED,MAAM,eAAe,GAAG,kBAAkB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,WAAW,EAAE,CAAC;IAErE,6DAA6D;IAC7D,sDAAsD;IACtD,MAAM,eAAe,GAAG,eAAe,CAAC,KAAK,CAAC,6BAA6B,CAAC,CAAC;IAC7E,IAAI,eAAe,EAAE,CAAC;QACpB,OAAO,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,UAAU,eAAe,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC;IACxE,CAAC;IAED,OAAO,eAAe,CAAC;AACzB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,kBAAkB,CAAC,OAAe;IAChD,MAAM,UAAU,GAAG,OAAO,CAAC,OAAO,CAAC,gBAAgB,EAAE,GAAG,CAAC,CAAC,WAAW,EAAE,CAAC;IACxE,OAAO,SAAS,UAAU,EAAE,CAAC;AAC/B,CAAC","sourcesContent":["import type {SqlCellData} from './types';\n\nexport function isDefined<T>(value: T | undefined): value is T {\n return value !== undefined;\n}\n\n/**\n * Validates that a string is a valid SQL identifier.\n * Must start with a letter or underscore, followed by letters, digits, or underscores.\n */\nexport function isValidSqlIdentifier(name: string): boolean {\n return /^[a-zA-Z_][a-zA-Z0-9_]*$/.test(name);\n}\n\n/**\n * Gets the effective result name for a SQL cell.\n * Returns explicit resultName if valid, otherwise auto-generates from title.\n */\nexport function getEffectiveResultName(\n data: SqlCellData,\n convertToValidName: (name: string) => string,\n): string {\n if (data.resultName && isValidSqlIdentifier(data.resultName)) {\n return data.resultName;\n }\n\n const normalizedTitle = convertToValidName(data.title).toLowerCase();\n\n // Keep SQL default titles mapped to a neutral result_* name:\n // \"SQL 1\" -> \"result_1\", \"SQL Query 2\" -> \"result_2\".\n const sqlDefaultMatch = normalizedTitle.match(/^sql(?:_query)?(?:_(\\d+))?$/);\n if (sqlDefaultMatch) {\n return sqlDefaultMatch[1] ? `result_${sqlDefaultMatch[1]}` : 'result';\n }\n\n return normalizedTitle;\n}\n\n/**\n * Generates a stable SQL schema name for a sheet id.\n */\nexport function getSheetSchemaName(sheetId: string): string {\n const normalized = sheetId.replace(/[^a-zA-Z0-9_]/g, '_').toLowerCase();\n return `sheet_${normalized}`;\n}\n"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@sqlrooms/cells",
|
|
3
|
+
"version": "0.29.0-rc.1",
|
|
4
|
+
"private": false,
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"module": "dist/index.js",
|
|
8
|
+
"types": "dist/index.d.ts",
|
|
9
|
+
"files": [
|
|
10
|
+
"dist"
|
|
11
|
+
],
|
|
12
|
+
"author": "SQLRooms Contributors",
|
|
13
|
+
"license": "MIT",
|
|
14
|
+
"repository": {
|
|
15
|
+
"type": "git",
|
|
16
|
+
"url": "https://github.com/sqlrooms/sqlrooms.git"
|
|
17
|
+
},
|
|
18
|
+
"sideEffects": false,
|
|
19
|
+
"scripts": {
|
|
20
|
+
"dev": "tsc -w",
|
|
21
|
+
"build": "tsc",
|
|
22
|
+
"test": "NODE_OPTIONS='--experimental-vm-modules --no-warnings' jest",
|
|
23
|
+
"test:watch": "NODE_OPTIONS='--experimental-vm-modules --no-warnings' jest --watch",
|
|
24
|
+
"lint": "eslint .",
|
|
25
|
+
"typecheck": "tsc --noEmit",
|
|
26
|
+
"typedoc": "typedoc"
|
|
27
|
+
},
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"@paralleldrive/cuid2": "^2.2.2",
|
|
30
|
+
"@sqlrooms/data-table": "0.29.0-rc.1",
|
|
31
|
+
"@sqlrooms/db": "0.29.0-rc.1",
|
|
32
|
+
"@sqlrooms/duckdb": "0.29.0-rc.1",
|
|
33
|
+
"@sqlrooms/room-store": "0.29.0-rc.1",
|
|
34
|
+
"@sqlrooms/sql-editor": "0.29.0-rc.1",
|
|
35
|
+
"@sqlrooms/ui": "0.29.0-rc.1",
|
|
36
|
+
"@sqlrooms/utils": "0.29.0-rc.1",
|
|
37
|
+
"@sqlrooms/vega": "0.29.0-rc.1",
|
|
38
|
+
"@tanstack/react-table": "^8.21.3",
|
|
39
|
+
"apache-arrow": "17.0.0",
|
|
40
|
+
"immer": "^11.0.1",
|
|
41
|
+
"lucide-react": "^0.555.0",
|
|
42
|
+
"monaco-editor": "^0.55.1",
|
|
43
|
+
"react-hook-form": "^7.68.0",
|
|
44
|
+
"react-markdown": "^10.1.0",
|
|
45
|
+
"remark-gfm": "^4.0.1",
|
|
46
|
+
"zod": "^4.1.8"
|
|
47
|
+
},
|
|
48
|
+
"devDependencies": {
|
|
49
|
+
"ts-jest": "^29.4.4",
|
|
50
|
+
"zustand": "^5.0.8"
|
|
51
|
+
},
|
|
52
|
+
"peerDependencies": {
|
|
53
|
+
"react": "^18 || ^19",
|
|
54
|
+
"react-dom": "^18 || ^19"
|
|
55
|
+
},
|
|
56
|
+
"gitHead": "69f127fd34bd7f2ce3d75d6098dbf8c1f5ab50f3"
|
|
57
|
+
}
|