@sqlrooms/sql-editor-config 0.27.0 → 0.28.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +46 -25
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -1,47 +1,68 @@
1
- A central configuration and type definitions package that maintains base SQL editor configuration schemas and Zod schema definitions for SQLRooms. It provides TypeScript types and interfaces along with essential constants and utilities used for managing SQL editor state.
2
-
3
- ## Features
4
-
5
- - 📝 **SQL Editor Configuration**: Define and manage room SQL editor configuration schemas.
6
- - 🔍 **Type Safety**: Strong TypeScript typing for SQL editor configuration objects.
7
- - ✅ **Validation**: Zod schemas for runtime validation of SQL editor configurations.
1
+ Zod schema and defaults for persisted SQL editor state.
8
2
 
9
3
  ## Installation
10
4
 
11
5
  ```bash
12
6
  npm install @sqlrooms/sql-editor-config
13
- # or
14
- yarn add @sqlrooms/sql-editor-config
15
7
  ```
16
8
 
17
- ## Basic Usage
9
+ ## Exports
18
10
 
19
- ### Working with SQL Editor Configuration
11
+ - `SqlEditorSliceConfig`
12
+ - `createDefaultSqlEditorConfig()`
20
13
 
21
- ```tsx
14
+ ## Basic usage
15
+
16
+ ```ts
22
17
  import {
23
18
  SqlEditorSliceConfig,
24
19
  createDefaultSqlEditorConfig,
25
20
  } from '@sqlrooms/sql-editor-config';
26
21
 
27
- // Create a new SQL editor configuration
28
- const sqlEditorConfig: SqlEditorSliceConfig = createDefaultSqlEditorConfig();
22
+ const defaultSqlEditorConfig = createDefaultSqlEditorConfig();
29
23
 
30
- // This can be part of a bigger room configuration
31
- interface RoomConfig {
32
- // ... other properties
33
- sqlEditor: SqlEditorSliceConfig['sqlEditor'];
34
- }
24
+ const validated = SqlEditorSliceConfig.parse({
25
+ queries: [
26
+ {
27
+ id: 'q1',
28
+ name: 'Top earthquakes',
29
+ query: 'SELECT * FROM earthquakes ORDER BY Magnitude DESC LIMIT 100',
30
+ },
31
+ ],
32
+ selectedQueryId: 'q1',
33
+ openTabs: ['q1'],
34
+ });
35
35
  ```
36
36
 
37
- ## Advanced Features
37
+ ## Migration behavior
38
38
 
39
- - **Schema Extensions**: Extend base schemas for custom room types
40
- - **Configuration Validation**: Validate configurations at runtime
41
- - **Serialization**: Convert configurations to/from JSON for storage
39
+ `SqlEditorSliceConfig` includes migration logic for legacy persisted data:
42
40
 
43
- For more information, visit the SQLRooms documentation.
41
+ - if `openTabs` is missing and legacy `closedTabIds` is present, it computes `openTabs`
42
+ - this helps old saved configs continue to load without manual migration steps
44
43
 
45
- ```
44
+ ## Use with persistence
45
+
46
+ ```ts
47
+ import {SqlEditorSliceConfig} from '@sqlrooms/sql-editor-config';
48
+ import {
49
+ createRoomStore,
50
+ persistSliceConfigs,
51
+ createRoomShellSlice,
52
+ } from '@sqlrooms/room-shell';
53
+
54
+ const persistence = {
55
+ name: 'my-editor-storage',
56
+ sliceConfigSchemas: {
57
+ sqlEditor: SqlEditorSliceConfig,
58
+ },
59
+ };
46
60
 
61
+ createRoomStore(
62
+ persistSliceConfigs(persistence, (set, get, store) => ({
63
+ ...createRoomShellSlice({
64
+ config: {title: 'Editor App', dataSources: []},
65
+ })(set, get, store),
66
+ })),
67
+ );
47
68
  ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sqlrooms/sql-editor-config",
3
- "version": "0.27.0",
3
+ "version": "0.28.0",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "module": "dist/index.js",
@@ -28,5 +28,5 @@
28
28
  "typecheck": "tsc --noEmit",
29
29
  "typedoc": "typedoc"
30
30
  },
31
- "gitHead": "f215995ab4adeac4c58171739261a15cbba9e82b"
31
+ "gitHead": "dcac54f8adf77240e293c93d224a0ce9fd8142a9"
32
32
  }