@sqlrooms/room-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.
- package/README.md +55 -78
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -1,103 +1,80 @@
|
|
|
1
|
-
|
|
1
|
+
Core Zod schemas and types for persisted Room configuration.
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
- 📝 **Room Configuration**: Define and manage room configuration schemas
|
|
6
|
-
- 🔍 **Type Safety**: Strong TypeScript typing for configuration objects
|
|
7
|
-
- ✅ **Validation**: Zod schemas for runtime validation of configuration
|
|
3
|
+
Use this package when you need to validate, type, or serialize the persisted configuration portion of a SQLRooms app.
|
|
8
4
|
|
|
9
5
|
## Installation
|
|
10
6
|
|
|
11
7
|
```bash
|
|
12
8
|
npm install @sqlrooms/room-config
|
|
13
|
-
# or
|
|
14
|
-
yarn add @sqlrooms/room-config
|
|
15
9
|
```
|
|
16
10
|
|
|
17
|
-
##
|
|
11
|
+
## Main exports
|
|
18
12
|
|
|
19
|
-
|
|
13
|
+
- `BaseRoomConfig`, `createDefaultBaseRoomConfig()`, `DEFAULT_ROOM_TITLE`
|
|
14
|
+
- data source schemas: `DataSource`, `FileDataSource`, `UrlDataSource`, `SqlQueryDataSource`
|
|
15
|
+
- data source type guards: `isFileDataSource`, `isUrlDataSource`, `isSqlQueryDataSource`
|
|
16
|
+
- file load option schemas/types (`LoadFileOptions`, `StandardLoadFileOptions`, etc.)
|
|
17
|
+
- layout schema re-exports from `@sqlrooms/layout-config`
|
|
20
18
|
|
|
21
|
-
|
|
22
|
-
import {BaseRoomConfig} from '@sqlrooms/room-config';
|
|
19
|
+
## Basic usage
|
|
23
20
|
|
|
24
|
-
|
|
25
|
-
const roomConfig: BaseRoomConfig = {
|
|
26
|
-
name: 'My SQL Room',
|
|
27
|
-
description: 'A data analysis room using SQLRooms',
|
|
28
|
-
version: '1.0.0',
|
|
29
|
-
settings: {
|
|
30
|
-
theme: 'dark',
|
|
31
|
-
// Other settings...
|
|
32
|
-
},
|
|
33
|
-
};
|
|
21
|
+
### Validate room config
|
|
34
22
|
|
|
35
|
-
|
|
36
|
-
|
|
23
|
+
```ts
|
|
24
|
+
import {BaseRoomConfig} from '@sqlrooms/room-config';
|
|
25
|
+
|
|
26
|
+
const roomConfig = BaseRoomConfig.parse({
|
|
27
|
+
title: 'Earthquakes Explorer',
|
|
28
|
+
description: 'Browser-based analytics app',
|
|
29
|
+
dataSources: [
|
|
30
|
+
{
|
|
31
|
+
type: 'url',
|
|
32
|
+
tableName: 'earthquakes',
|
|
33
|
+
url: 'https://huggingface.co/datasets/sqlrooms/earthquakes/resolve/main/earthquakes.parquet',
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
type: 'sql',
|
|
37
|
+
tableName: 'top_quakes',
|
|
38
|
+
sqlQuery: 'SELECT * FROM earthquakes ORDER BY Magnitude DESC LIMIT 100',
|
|
39
|
+
},
|
|
40
|
+
],
|
|
41
|
+
});
|
|
37
42
|
```
|
|
38
43
|
|
|
39
|
-
###
|
|
44
|
+
### Create defaults
|
|
40
45
|
|
|
41
|
-
|
|
46
|
+
```ts
|
|
47
|
+
import {createDefaultBaseRoomConfig} from '@sqlrooms/room-config';
|
|
48
|
+
|
|
49
|
+
const defaultConfig = createDefaultBaseRoomConfig();
|
|
50
|
+
```
|
|
42
51
|
|
|
43
|
-
|
|
52
|
+
## Use with persistence
|
|
53
|
+
|
|
54
|
+
```ts
|
|
55
|
+
import {BaseRoomConfig, LayoutConfig} from '@sqlrooms/room-config';
|
|
44
56
|
import {
|
|
45
|
-
createRoomStore,
|
|
46
57
|
createRoomShellSlice,
|
|
47
|
-
|
|
58
|
+
createRoomStore,
|
|
48
59
|
persistSliceConfigs,
|
|
49
|
-
LayoutConfig,
|
|
50
60
|
} from '@sqlrooms/room-shell';
|
|
51
|
-
import {BaseRoomConfig} from '@sqlrooms/room-config';
|
|
52
61
|
|
|
53
|
-
|
|
62
|
+
const persistence = {
|
|
63
|
+
name: 'my-room-storage',
|
|
64
|
+
sliceConfigSchemas: {
|
|
65
|
+
room: BaseRoomConfig,
|
|
66
|
+
layout: LayoutConfig,
|
|
67
|
+
},
|
|
68
|
+
};
|
|
54
69
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
room: BaseRoomConfig,
|
|
62
|
-
layout: LayoutConfig,
|
|
70
|
+
const {roomStore} = createRoomStore(
|
|
71
|
+
persistSliceConfigs(persistence, (set, get, store) => ({
|
|
72
|
+
...createRoomShellSlice({
|
|
73
|
+
config: {
|
|
74
|
+
title: 'My Room',
|
|
75
|
+
dataSources: [],
|
|
63
76
|
},
|
|
64
|
-
},
|
|
65
|
-
|
|
66
|
-
...createRoomShellSlice({
|
|
67
|
-
config: {
|
|
68
|
-
title: 'My Room',
|
|
69
|
-
// Other configuration properties
|
|
70
|
-
},
|
|
71
|
-
layout: {
|
|
72
|
-
config: {
|
|
73
|
-
// Layout configuration
|
|
74
|
-
},
|
|
75
|
-
panels: {
|
|
76
|
-
// Panel definitions
|
|
77
|
-
},
|
|
78
|
-
},
|
|
79
|
-
})(set, get, store),
|
|
80
|
-
}),
|
|
81
|
-
),
|
|
77
|
+
})(set, get, store),
|
|
78
|
+
})),
|
|
82
79
|
);
|
|
83
|
-
|
|
84
|
-
// Access the config in components
|
|
85
|
-
function ConfigComponent() {
|
|
86
|
-
// Config is accessed from state.room.config
|
|
87
|
-
const config = useRoomStore((state) => state.room.config);
|
|
88
|
-
|
|
89
|
-
return <div>{config.title}</div>;
|
|
90
|
-
}
|
|
91
|
-
```
|
|
92
|
-
|
|
93
|
-
## Advanced Features
|
|
94
|
-
|
|
95
|
-
- **Schema Extensions**: Extend base schemas for custom room types
|
|
96
|
-
- **Configuration Validation**: Validate configurations at runtime
|
|
97
|
-
- **Serialization**: Convert configurations to/from JSON for storage
|
|
98
|
-
|
|
99
|
-
For more information, visit the SQLRooms documentation.
|
|
100
|
-
|
|
101
|
-
```
|
|
102
|
-
|
|
103
80
|
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sqlrooms/room-config",
|
|
3
|
-
"version": "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",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"access": "public"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@sqlrooms/layout-config": "0.
|
|
22
|
+
"@sqlrooms/layout-config": "0.28.0",
|
|
23
23
|
"zod": "^4.1.8"
|
|
24
24
|
},
|
|
25
25
|
"peerDependencies": {
|
|
@@ -33,5 +33,5 @@
|
|
|
33
33
|
"typecheck": "tsc --noEmit",
|
|
34
34
|
"typedoc": "typedoc"
|
|
35
35
|
},
|
|
36
|
-
"gitHead": "
|
|
36
|
+
"gitHead": "dcac54f8adf77240e293c93d224a0ce9fd8142a9"
|
|
37
37
|
}
|