@sqlrooms/sql-editor-config 0.28.0-rc.0 → 0.28.1-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +46 -25
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,47 +1,68 @@
|
|
|
1
|
-
|
|
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
|
-
##
|
|
9
|
+
## Exports
|
|
18
10
|
|
|
19
|
-
|
|
11
|
+
- `SqlEditorSliceConfig`
|
|
12
|
+
- `createDefaultSqlEditorConfig()`
|
|
20
13
|
|
|
21
|
-
|
|
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
|
-
|
|
28
|
-
const sqlEditorConfig: SqlEditorSliceConfig = createDefaultSqlEditorConfig();
|
|
22
|
+
const defaultSqlEditorConfig = createDefaultSqlEditorConfig();
|
|
29
23
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
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
|
-
##
|
|
37
|
+
## Migration behavior
|
|
38
38
|
|
|
39
|
-
|
|
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
|
-
|
|
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.28.
|
|
3
|
+
"version": "0.28.1-rc.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": "
|
|
31
|
+
"gitHead": "1e0dcae95d1ccdbcd1b32df1d647d0f794b94e5e"
|
|
32
32
|
}
|