@indexeddb-orm/idb-orm 0.0.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/.vscode/extensions.json +5 -0
- package/README.md +1280 -0
- package/angular-demo-app/README.md +84 -0
- package/angular-demo-app/angular.json +109 -0
- package/angular-demo-app/package-lock.json +14215 -0
- package/angular-demo-app/package.json +41 -0
- package/angular-demo-app/src/app/app.component.ts +481 -0
- package/angular-demo-app/src/app/app.routes.ts +8 -0
- package/angular-demo-app/src/app/components/actions.component.ts +202 -0
- package/angular-demo-app/src/app/components/cloud-sync-demo.component.ts +296 -0
- package/angular-demo-app/src/app/components/live-query-demo.component.ts +307 -0
- package/angular-demo-app/src/app/components/main-info.component.ts +148 -0
- package/angular-demo-app/src/app/components/posts-live-query-demo.component.ts +336 -0
- package/angular-demo-app/src/app/components/typescript-demo.component.ts +268 -0
- package/angular-demo-app/src/entities/post-tag.entity.ts +25 -0
- package/angular-demo-app/src/entities/post.entity.ts +49 -0
- package/angular-demo-app/src/entities/profile.entity.ts +42 -0
- package/angular-demo-app/src/entities/tag.entity.ts +36 -0
- package/angular-demo-app/src/entities/user.entity.ts +59 -0
- package/angular-demo-app/src/favicon.ico +1 -0
- package/angular-demo-app/src/index.html +16 -0
- package/angular-demo-app/src/main.ts +13 -0
- package/angular-demo-app/src/services/app-logic.service.ts +449 -0
- package/angular-demo-app/src/services/cloud-sync.service.ts +95 -0
- package/angular-demo-app/src/services/database.service.ts +26 -0
- package/angular-demo-app/src/services/live-query.service.ts +63 -0
- package/angular-demo-app/src/services/posts-live-query.service.ts +86 -0
- package/angular-demo-app/src/services/typescript-demo.service.ts +59 -0
- package/angular-demo-app/src/styles.scss +50 -0
- package/angular-demo-app/tsconfig.app.json +13 -0
- package/angular-demo-app/tsconfig.json +34 -0
- package/angular-demo-app/tsconfig.spec.json +13 -0
- package/dist/Database.d.ts +206 -0
- package/dist/Database.js +288 -0
- package/dist/decorators/Column.d.ts +79 -0
- package/dist/decorators/Column.js +236 -0
- package/dist/decorators/Entity.d.ts +32 -0
- package/dist/decorators/Entity.js +44 -0
- package/dist/decorators/Relation.d.ts +70 -0
- package/dist/decorators/Relation.js +120 -0
- package/dist/decorators/index.d.ts +3 -0
- package/dist/decorators/index.js +3 -0
- package/dist/errors/ValidationError.d.ts +4 -0
- package/dist/errors/ValidationError.js +8 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +7 -0
- package/dist/metadata/Column.d.ts +8 -0
- package/dist/metadata/Column.js +44 -0
- package/dist/metadata/Entity.d.ts +11 -0
- package/dist/metadata/Entity.js +21 -0
- package/dist/metadata/Relation.d.ts +20 -0
- package/dist/metadata/Relation.js +74 -0
- package/dist/metadata/index.d.ts +3 -0
- package/dist/metadata/index.js +3 -0
- package/dist/services/AggregationService.d.ts +38 -0
- package/dist/services/AggregationService.js +229 -0
- package/dist/services/BaseEntity.d.ts +32 -0
- package/dist/services/BaseEntity.js +62 -0
- package/dist/services/CloudSyncService.d.ts +100 -0
- package/dist/services/CloudSyncService.js +196 -0
- package/dist/services/DecoratorUtils.d.ts +12 -0
- package/dist/services/DecoratorUtils.js +10 -0
- package/dist/services/EntityFactory.d.ts +25 -0
- package/dist/services/EntityFactory.js +27 -0
- package/dist/services/EntityRegistry.d.ts +61 -0
- package/dist/services/EntityRegistry.js +56 -0
- package/dist/services/EntitySchema.d.ts +56 -0
- package/dist/services/EntitySchema.js +125 -0
- package/dist/services/MigrationManager.d.ts +70 -0
- package/dist/services/MigrationManager.js +181 -0
- package/dist/services/RelationLoader.d.ts +66 -0
- package/dist/services/RelationLoader.js +310 -0
- package/dist/services/SchemaBuilder.d.ts +68 -0
- package/dist/services/SchemaBuilder.js +191 -0
- package/dist/services/index.d.ts +7 -0
- package/dist/services/index.js +7 -0
- package/dist/types.d.ts +152 -0
- package/dist/types.js +1 -0
- package/dist/utils/logger.d.ts +12 -0
- package/dist/utils/logger.js +16 -0
- package/eslint.config.js +49 -0
- package/homepage/favicon.svg +36 -0
- package/homepage/index.html +1725 -0
- package/package.json +78 -0
- package/react-demo-app/README.md +61 -0
- package/react-demo-app/eslint.config.js +60 -0
- package/react-demo-app/index.html +13 -0
- package/react-demo-app/package-lock.json +4955 -0
- package/react-demo-app/package.json +39 -0
- package/react-demo-app/src/App.tsx +172 -0
- package/react-demo-app/src/assets/react.svg +1 -0
- package/react-demo-app/src/components/Actions.tsx +171 -0
- package/react-demo-app/src/components/CloudSyncDemo.tsx +191 -0
- package/react-demo-app/src/components/LiveQueryDemo.tsx +122 -0
- package/react-demo-app/src/components/MainInfo.tsx +75 -0
- package/react-demo-app/src/components/PostsLiveQueryDemo.tsx +185 -0
- package/react-demo-app/src/components/TypeScriptDemo.tsx +190 -0
- package/react-demo-app/src/database/Database.ts +30 -0
- package/react-demo-app/src/entities/Post.ts +48 -0
- package/react-demo-app/src/entities/PostTag.ts +26 -0
- package/react-demo-app/src/entities/Profile.ts +41 -0
- package/react-demo-app/src/entities/Tag.ts +35 -0
- package/react-demo-app/src/entities/User.ts +61 -0
- package/react-demo-app/src/hooks/useAppLogic.ts +565 -0
- package/react-demo-app/src/hooks/useCloudSyncDemo.ts +84 -0
- package/react-demo-app/src/hooks/useLiveQueryDemo.ts +68 -0
- package/react-demo-app/src/hooks/usePostsLiveQueryDemo.ts +64 -0
- package/react-demo-app/src/hooks/useTypeScriptDemo.ts +43 -0
- package/react-demo-app/src/index.css +26 -0
- package/react-demo-app/src/main.tsx +18 -0
- package/react-demo-app/src/migrations/001-add-user-email-index.ts +17 -0
- package/react-demo-app/src/migrations/002-add-post-category.ts +37 -0
- package/react-demo-app/src/migrations/index.ts +8 -0
- package/react-demo-app/src/vite-env.d.ts +1 -0
- package/react-demo-app/tsconfig.app.json +22 -0
- package/react-demo-app/tsconfig.json +6 -0
- package/react-demo-app/vite.config.ts +10 -0
- package/src/Database.ts +405 -0
- package/src/errors/ValidationError.ts +9 -0
- package/src/index.ts +13 -0
- package/src/metadata/Column.ts +74 -0
- package/src/metadata/Entity.ts +42 -0
- package/src/metadata/Relation.ts +121 -0
- package/src/metadata/index.ts +5 -0
- package/src/services/AggregationService.ts +348 -0
- package/src/services/BaseEntity.ts +77 -0
- package/src/services/CloudSyncService.ts +248 -0
- package/src/services/EntityFactory.ts +35 -0
- package/src/services/EntityRegistry.ts +109 -0
- package/src/services/EntitySchema.ts +154 -0
- package/src/services/MigrationManager.ts +276 -0
- package/src/services/RelationLoader.ts +532 -0
- package/src/services/SchemaBuilder.ts +237 -0
- package/src/services/index.ts +7 -0
- package/src/types.d.ts +1 -0
- package/src/types.ts +169 -0
- package/src/utils/logger.ts +40 -0
- package/svelte-demo-app/README.md +61 -0
- package/svelte-demo-app/package-lock.json +3000 -0
- package/svelte-demo-app/package.json +30 -0
- package/svelte-demo-app/src/app.d.ts +12 -0
- package/svelte-demo-app/src/app.html +13 -0
- package/svelte-demo-app/src/components/Actions.svelte +121 -0
- package/svelte-demo-app/src/components/CloudSyncDemo.svelte +333 -0
- package/svelte-demo-app/src/components/LiveQueryDemo.svelte +191 -0
- package/svelte-demo-app/src/components/MainInfo.svelte +133 -0
- package/svelte-demo-app/src/components/PostsLiveQueryDemo.svelte +330 -0
- package/svelte-demo-app/src/components/TypeScriptDemo.svelte +251 -0
- package/svelte-demo-app/src/database/Database.ts +29 -0
- package/svelte-demo-app/src/entities/Post.ts +46 -0
- package/svelte-demo-app/src/entities/PostTag.ts +22 -0
- package/svelte-demo-app/src/entities/Profile.ts +39 -0
- package/svelte-demo-app/src/entities/Tag.ts +33 -0
- package/svelte-demo-app/src/entities/User.ts +62 -0
- package/svelte-demo-app/src/lib/database/Database.ts +30 -0
- package/svelte-demo-app/src/lib/entities/Post.ts +47 -0
- package/svelte-demo-app/src/lib/entities/PostTag.ts +23 -0
- package/svelte-demo-app/src/lib/entities/Profile.ts +40 -0
- package/svelte-demo-app/src/lib/entities/Tag.ts +34 -0
- package/svelte-demo-app/src/lib/entities/User.ts +59 -0
- package/svelte-demo-app/src/lib/index.ts +7 -0
- package/svelte-demo-app/src/lib/migrations/001-add-user-email-index.ts +17 -0
- package/svelte-demo-app/src/lib/migrations/002-add-post-category.ts +37 -0
- package/svelte-demo-app/src/lib/migrations/index.ts +8 -0
- package/svelte-demo-app/src/migrations/001-add-user-email-index.ts +17 -0
- package/svelte-demo-app/src/migrations/002-add-post-category.ts +37 -0
- package/svelte-demo-app/src/migrations/index.ts +8 -0
- package/svelte-demo-app/src/routes/+layout.js +3 -0
- package/svelte-demo-app/src/routes/+layout.svelte +228 -0
- package/svelte-demo-app/src/routes/+page.js +3 -0
- package/svelte-demo-app/src/routes/+page.svelte +1305 -0
- package/svelte-demo-app/src/stores/appStore.js +603 -0
- package/svelte-demo-app/svelte.config.js +18 -0
- package/svelte-demo-app/tsconfig.json +14 -0
- package/svelte-demo-app/vite.config.ts +6 -0
- package/tests/aggregation.e2e.test.ts +87 -0
- package/tests/base-entity.e2e.test.ts +47 -0
- package/tests/database-api.e2e.test.ts +177 -0
- package/tests/decorators.e2e.test.ts +40 -0
- package/tests/entity-schema.e2e.test.ts +58 -0
- package/tests/relation-loader-table-names.test.ts +192 -0
- package/tests/relations.e2e.test.ts +178 -0
- package/tests/zod-runtime.e2e.test.ts +69 -0
- package/tsconfig.json +21 -0
- package/vitest.config.ts +21 -0
- package/vitest.setup.ts +27 -0
- package/vue-demo-app/README.md +61 -0
- package/vue-demo-app/index.html +13 -0
- package/vue-demo-app/package-lock.json +1537 -0
- package/vue-demo-app/package.json +27 -0
- package/vue-demo-app/src/App.vue +100 -0
- package/vue-demo-app/src/components/Actions.vue +135 -0
- package/vue-demo-app/src/components/CloudSyncDemo.vue +139 -0
- package/vue-demo-app/src/components/LiveQueryDemo.vue +122 -0
- package/vue-demo-app/src/components/MainInfo.vue +80 -0
- package/vue-demo-app/src/components/PostsLiveQueryDemo.vue +136 -0
- package/vue-demo-app/src/components/TypeScriptDemo.vue +133 -0
- package/vue-demo-app/src/database/Database.ts +29 -0
- package/vue-demo-app/src/entities/Post.ts +48 -0
- package/vue-demo-app/src/entities/PostTag.ts +24 -0
- package/vue-demo-app/src/entities/Profile.ts +41 -0
- package/vue-demo-app/src/entities/Tag.ts +35 -0
- package/vue-demo-app/src/entities/User.ts +61 -0
- package/vue-demo-app/src/main.ts +29 -0
- package/vue-demo-app/src/migrations/001-add-user-email-index.ts +23 -0
- package/vue-demo-app/src/migrations/002-add-post-category.ts +46 -0
- package/vue-demo-app/src/migrations/index.ts +14 -0
- package/vue-demo-app/src/services/useAppLogic.ts +565 -0
- package/vue-demo-app/src/services/useCloudSyncDemo.ts +84 -0
- package/vue-demo-app/src/services/useLiveQueryDemo.ts +82 -0
- package/vue-demo-app/src/services/usePostsLiveQueryDemo.ts +77 -0
- package/vue-demo-app/src/services/useTypeScriptDemo.ts +56 -0
- package/vue-demo-app/src/vite-env.d.ts +1 -0
- package/vue-demo-app/tsconfig.json +25 -0
- package/vue-demo-app/tsconfig.node.json +10 -0
- package/vue-demo-app/vite.config.ts +16 -0
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"dependencies": {
|
|
3
|
+
"@emotion/react": "^11.14.0",
|
|
4
|
+
"@emotion/styled": "^11.14.1",
|
|
5
|
+
"@mui/icons-material": "^7.3.2",
|
|
6
|
+
"@mui/material": "^7.3.2",
|
|
7
|
+
"idb-orm": "^0.0.1",
|
|
8
|
+
"dexie-react-hooks": "^4.2.0",
|
|
9
|
+
"react": "^19.1.1",
|
|
10
|
+
"react-dom": "^19.1.1",
|
|
11
|
+
"zod": "^4.1.5"
|
|
12
|
+
},
|
|
13
|
+
"devDependencies": {
|
|
14
|
+
"@eslint/js": "^9.33.0",
|
|
15
|
+
"@tailwindcss/postcss": "^4.1.12",
|
|
16
|
+
"@types/dexie": "^1.3.32",
|
|
17
|
+
"@types/react": "^19.1.13",
|
|
18
|
+
"@types/react-dom": "^19.1.9",
|
|
19
|
+
"@vitejs/plugin-react": "^5.0.3",
|
|
20
|
+
"eslint": "^9.33.0",
|
|
21
|
+
"eslint-plugin-react-hooks": "^5.2.0",
|
|
22
|
+
"eslint-plugin-react-refresh": "^0.4.20",
|
|
23
|
+
"eslint-plugin-simple-import-sort": "^12.1.1",
|
|
24
|
+
"globals": "^16.3.0",
|
|
25
|
+
"typescript": "~5.8.3",
|
|
26
|
+
"typescript-eslint": "^8.39.1",
|
|
27
|
+
"vite": "^7.1.2"
|
|
28
|
+
},
|
|
29
|
+
"name": "indexeddb-orm-reactdemo-app",
|
|
30
|
+
"private": true,
|
|
31
|
+
"scripts": {
|
|
32
|
+
"build": "tsc -b && vite build",
|
|
33
|
+
"dev": "vite",
|
|
34
|
+
"lint": "eslint .",
|
|
35
|
+
"preview": "vite preview"
|
|
36
|
+
},
|
|
37
|
+
"type": "module",
|
|
38
|
+
"version": "0.0.1"
|
|
39
|
+
}
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import MenuIcon from '@mui/icons-material/Menu';
|
|
2
|
+
import {
|
|
3
|
+
AppBar,
|
|
4
|
+
Box,
|
|
5
|
+
Drawer,
|
|
6
|
+
IconButton,
|
|
7
|
+
List,
|
|
8
|
+
ListItemButton,
|
|
9
|
+
ListItemText,
|
|
10
|
+
Toolbar,
|
|
11
|
+
Typography,
|
|
12
|
+
} from '@mui/material';
|
|
13
|
+
|
|
14
|
+
import { Actions } from './components/Actions';
|
|
15
|
+
import { CloudSyncDemo } from './components/CloudSyncDemo';
|
|
16
|
+
import { LiveQueryDemo } from './components/LiveQueryDemo';
|
|
17
|
+
import { MainInfo } from './components/MainInfo';
|
|
18
|
+
import { PostsLiveQueryDemo } from './components/PostsLiveQueryDemo';
|
|
19
|
+
import { TypeScriptDemo } from './components/TypeScriptDemo';
|
|
20
|
+
import { useAppLogic } from './hooks/useAppLogic';
|
|
21
|
+
|
|
22
|
+
function App() {
|
|
23
|
+
const {
|
|
24
|
+
users,
|
|
25
|
+
tabIndex,
|
|
26
|
+
setTabIndex,
|
|
27
|
+
mobileOpen,
|
|
28
|
+
tabs,
|
|
29
|
+
addUser,
|
|
30
|
+
testZodValidation,
|
|
31
|
+
testSchemaMigration,
|
|
32
|
+
toggleAutoReset,
|
|
33
|
+
testTransactions,
|
|
34
|
+
testCompoundIndexes,
|
|
35
|
+
testRelations,
|
|
36
|
+
testAggregations,
|
|
37
|
+
clearAll,
|
|
38
|
+
handleDrawerToggle,
|
|
39
|
+
} = useAppLogic();
|
|
40
|
+
|
|
41
|
+
return (
|
|
42
|
+
<Box sx={{ display: 'flex', flexDirection: 'column', minHeight: '100vh' }}>
|
|
43
|
+
<AppBar position="static" sx={{ zIndex: (theme) => theme.zIndex.drawer + 1 }}>
|
|
44
|
+
<Toolbar>
|
|
45
|
+
<IconButton
|
|
46
|
+
color="inherit"
|
|
47
|
+
aria-label="open drawer"
|
|
48
|
+
edge="start"
|
|
49
|
+
onClick={handleDrawerToggle}
|
|
50
|
+
sx={{ mr: 2, display: { md: 'none' } }}
|
|
51
|
+
>
|
|
52
|
+
<MenuIcon />
|
|
53
|
+
</IconButton>
|
|
54
|
+
<Typography variant="h6" noWrap component="div" sx={{ flexGrow: 1 }}>
|
|
55
|
+
Dexie ORM Demo
|
|
56
|
+
</Typography>
|
|
57
|
+
</Toolbar>
|
|
58
|
+
</AppBar>
|
|
59
|
+
|
|
60
|
+
<Box sx={{ display: 'flex', flex: 1 }}>
|
|
61
|
+
<Drawer
|
|
62
|
+
variant="temporary"
|
|
63
|
+
open={mobileOpen}
|
|
64
|
+
onClose={handleDrawerToggle}
|
|
65
|
+
ModalProps={{
|
|
66
|
+
keepMounted: true,
|
|
67
|
+
}}
|
|
68
|
+
sx={{
|
|
69
|
+
display: { xs: 'block', md: 'none' },
|
|
70
|
+
'& .MuiDrawer-paper': {
|
|
71
|
+
boxSizing: 'border-box',
|
|
72
|
+
width: 240,
|
|
73
|
+
zIndex: (theme) => theme.zIndex.appBar + 1,
|
|
74
|
+
paddingTop: '64px', // Height of AppBar
|
|
75
|
+
},
|
|
76
|
+
}}
|
|
77
|
+
>
|
|
78
|
+
<Box sx={{ overflow: 'auto' }}>
|
|
79
|
+
<List>
|
|
80
|
+
{tabs.map((tab, index) => {
|
|
81
|
+
console.log('Mobile drawer tab:', tab, 'index:', index);
|
|
82
|
+
return (
|
|
83
|
+
<ListItemButton
|
|
84
|
+
key={tab.key}
|
|
85
|
+
selected={tabIndex === index}
|
|
86
|
+
onClick={() => {
|
|
87
|
+
setTabIndex(index);
|
|
88
|
+
handleDrawerToggle();
|
|
89
|
+
}}
|
|
90
|
+
>
|
|
91
|
+
<ListItemText primary={tab.label} />
|
|
92
|
+
</ListItemButton>
|
|
93
|
+
);
|
|
94
|
+
})}
|
|
95
|
+
</List>
|
|
96
|
+
</Box>
|
|
97
|
+
</Drawer>
|
|
98
|
+
|
|
99
|
+
<Drawer
|
|
100
|
+
variant="permanent"
|
|
101
|
+
sx={{
|
|
102
|
+
display: { xs: 'none', md: 'block' },
|
|
103
|
+
'& .MuiDrawer-paper': {
|
|
104
|
+
boxSizing: 'border-box',
|
|
105
|
+
width: 240,
|
|
106
|
+
position: 'relative',
|
|
107
|
+
flexShrink: 0,
|
|
108
|
+
},
|
|
109
|
+
}}
|
|
110
|
+
>
|
|
111
|
+
<Box sx={{ overflow: 'auto' }}>
|
|
112
|
+
<List>
|
|
113
|
+
{tabs.map((tab, index) => (
|
|
114
|
+
<ListItemButton
|
|
115
|
+
key={tab.key}
|
|
116
|
+
selected={tabIndex === index}
|
|
117
|
+
onClick={() => setTabIndex(index)}
|
|
118
|
+
>
|
|
119
|
+
<ListItemText primary={tab.label} />
|
|
120
|
+
</ListItemButton>
|
|
121
|
+
))}
|
|
122
|
+
</List>
|
|
123
|
+
</Box>
|
|
124
|
+
</Drawer>
|
|
125
|
+
|
|
126
|
+
<Box
|
|
127
|
+
component="main"
|
|
128
|
+
sx={{
|
|
129
|
+
flexGrow: 1,
|
|
130
|
+
p: 3,
|
|
131
|
+
width: { md: `calc(100% - 240px)` },
|
|
132
|
+
maxWidth: '100%',
|
|
133
|
+
px: { xs: 1, sm: 2, md: 3 },
|
|
134
|
+
mx: 'auto'
|
|
135
|
+
}}>
|
|
136
|
+
{tabIndex === 0 && (
|
|
137
|
+
<>
|
|
138
|
+
<MainInfo />
|
|
139
|
+
|
|
140
|
+
<Actions
|
|
141
|
+
users={users}
|
|
142
|
+
addUser={addUser}
|
|
143
|
+
testZodValidation={testZodValidation}
|
|
144
|
+
testSchemaMigration={testSchemaMigration}
|
|
145
|
+
toggleAutoReset={toggleAutoReset}
|
|
146
|
+
testRelations={testRelations}
|
|
147
|
+
testTransactions={testTransactions}
|
|
148
|
+
testCompoundIndexes={testCompoundIndexes}
|
|
149
|
+
testAggregations={testAggregations}
|
|
150
|
+
clearAll={clearAll}
|
|
151
|
+
/>
|
|
152
|
+
|
|
153
|
+
{/* Keep additional sections inside Admin tab */}
|
|
154
|
+
<Box sx={{ mt: 3 }}>
|
|
155
|
+
<LiveQueryDemo />
|
|
156
|
+
</Box>
|
|
157
|
+
<Box sx={{ mt: 3 }}>
|
|
158
|
+
<TypeScriptDemo />
|
|
159
|
+
</Box>
|
|
160
|
+
<Box sx={{ mt: 3 }}>
|
|
161
|
+
<PostsLiveQueryDemo />
|
|
162
|
+
</Box>
|
|
163
|
+
</>
|
|
164
|
+
)}
|
|
165
|
+
{tabIndex === 1 && <CloudSyncDemo />}
|
|
166
|
+
</Box>
|
|
167
|
+
</Box>
|
|
168
|
+
</Box>
|
|
169
|
+
);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
export default App;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="35.93" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 228"><path fill="#00D8FF" d="M210.483 73.824a171.49 171.49 0 0 0-8.24-2.597c.465-1.9.893-3.777 1.273-5.621c6.238-30.281 2.16-54.676-11.769-62.708c-13.355-7.7-35.196.329-57.254 19.526a171.23 171.23 0 0 0-6.375 5.848a155.866 155.866 0 0 0-4.241-3.917C100.759 3.829 77.587-4.822 63.673 3.233C50.33 10.957 46.379 33.89 51.995 62.588a170.974 170.974 0 0 0 1.892 8.48c-3.28.932-6.445 1.924-9.474 2.98C17.309 83.498 0 98.307 0 113.668c0 15.865 18.582 31.778 46.812 41.427a145.52 145.52 0 0 0 6.921 2.165a167.467 167.467 0 0 0-2.01 9.138c-5.354 28.2-1.173 50.591 12.134 58.266c13.744 7.926 36.812-.22 59.273-19.855a145.567 145.567 0 0 0 5.342-4.923a168.064 168.064 0 0 0 6.92 6.314c21.758 18.722 43.246 26.282 56.54 18.586c13.731-7.949 18.194-32.003 12.4-61.268a145.016 145.016 0 0 0-1.535-6.842c1.62-.48 3.21-.974 4.76-1.488c29.348-9.723 48.443-25.443 48.443-41.52c0-15.417-17.868-30.326-45.517-39.844Zm-6.365 70.984c-1.4.463-2.836.91-4.3 1.345c-3.24-10.257-7.612-21.163-12.963-32.432c5.106-11 9.31-21.767 12.459-31.957c2.619.758 5.16 1.557 7.61 2.4c23.69 8.156 38.14 20.213 38.14 29.504c0 9.896-15.606 22.743-40.946 31.14Zm-10.514 20.834c2.562 12.94 2.927 24.64 1.23 33.787c-1.524 8.219-4.59 13.698-8.382 15.893c-8.067 4.67-25.32-1.4-43.927-17.412a156.726 156.726 0 0 1-6.437-5.87c7.214-7.889 14.423-17.06 21.459-27.246c12.376-1.098 24.068-2.894 34.671-5.345a134.17 134.17 0 0 1 1.386 6.193ZM87.276 214.515c-7.882 2.783-14.16 2.863-17.955.675c-8.075-4.657-11.432-22.636-6.853-46.752a156.923 156.923 0 0 1 1.869-8.499c10.486 2.32 22.093 3.988 34.498 4.994c7.084 9.967 14.501 19.128 21.976 27.15a134.668 134.668 0 0 1-4.877 4.492c-9.933 8.682-19.886 14.842-28.658 17.94ZM50.35 144.747c-12.483-4.267-22.792-9.812-29.858-15.863c-6.35-5.437-9.555-10.836-9.555-15.216c0-9.322 13.897-21.212 37.076-29.293c2.813-.98 5.757-1.905 8.812-2.773c3.204 10.42 7.406 21.315 12.477 32.332c-5.137 11.18-9.399 22.249-12.634 32.792a134.718 134.718 0 0 1-6.318-1.979Zm12.378-84.26c-4.811-24.587-1.616-43.134 6.425-47.789c8.564-4.958 27.502 2.111 47.463 19.835a144.318 144.318 0 0 1 3.841 3.545c-7.438 7.987-14.787 17.08-21.808 26.988c-12.04 1.116-23.565 2.908-34.161 5.309a160.342 160.342 0 0 1-1.76-7.887Zm110.427 27.268a347.8 347.8 0 0 0-7.785-12.803c8.168 1.033 15.994 2.404 23.343 4.08c-2.206 7.072-4.956 14.465-8.193 22.045a381.151 381.151 0 0 0-7.365-13.322Zm-45.032-43.861c5.044 5.465 10.096 11.566 15.065 18.186a322.04 322.04 0 0 0-30.257-.006c4.974-6.559 10.069-12.652 15.192-18.18ZM82.802 87.83a323.167 323.167 0 0 0-7.227 13.238c-3.184-7.553-5.909-14.98-8.134-22.152c7.304-1.634 15.093-2.97 23.209-3.984a321.524 321.524 0 0 0-7.848 12.897Zm8.081 65.352c-8.385-.936-16.291-2.203-23.593-3.793c2.26-7.3 5.045-14.885 8.298-22.6a321.187 321.187 0 0 0 7.257 13.246c2.594 4.48 5.28 8.868 8.038 13.147Zm37.542 31.03c-5.184-5.592-10.354-11.779-15.403-18.433c4.902.192 9.899.29 14.978.29c5.218 0 10.376-.117 15.453-.343c-4.985 6.774-10.018 12.97-15.028 18.486Zm52.198-57.817c3.422 7.8 6.306 15.345 8.596 22.52c-7.422 1.694-15.436 3.058-23.88 4.071a382.417 382.417 0 0 0 7.859-13.026a347.403 347.403 0 0 0 7.425-13.565Zm-16.898 8.101a358.557 358.557 0 0 1-12.281 19.815a329.4 329.4 0 0 1-23.444.823c-7.967 0-15.716-.248-23.178-.732a310.202 310.202 0 0 1-12.513-19.846h.001a307.41 307.41 0 0 1-10.923-20.627a310.278 310.278 0 0 1 10.89-20.637l-.001.001a307.318 307.318 0 0 1 12.413-19.761c7.613-.576 15.42-.876 23.31-.876H128c7.926 0 15.743.303 23.354.883a329.357 329.357 0 0 1 12.335 19.695a358.489 358.489 0 0 1 11.036 20.54a329.472 329.472 0 0 1-11 20.722Zm22.56-122.124c8.572 4.944 11.906 24.881 6.52 51.026c-.344 1.668-.73 3.367-1.15 5.09c-10.622-2.452-22.155-4.275-34.23-5.408c-7.034-10.017-14.323-19.124-21.64-27.008a160.789 160.789 0 0 1 5.888-5.4c18.9-16.447 36.564-22.941 44.612-18.3ZM128 90.808c12.625 0 22.86 10.235 22.86 22.86s-10.235 22.86-22.86 22.86s-22.86-10.235-22.86-22.86s10.235-22.86 22.86-22.86Z"></path></svg>
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import AssessmentIcon from '@mui/icons-material/Assessment';
|
|
2
|
+
import DeleteSweepIcon from '@mui/icons-material/DeleteSweep';
|
|
3
|
+
import LinkIcon from '@mui/icons-material/Link';
|
|
4
|
+
import PersonIcon from '@mui/icons-material/Person';
|
|
5
|
+
import ScienceIcon from '@mui/icons-material/Science';
|
|
6
|
+
import SearchIcon from '@mui/icons-material/Search';
|
|
7
|
+
import SettingsIcon from '@mui/icons-material/Settings';
|
|
8
|
+
import SpeedIcon from '@mui/icons-material/Speed';
|
|
9
|
+
import StorageIcon from '@mui/icons-material/Storage';
|
|
10
|
+
import { Box, Button, Paper, Stack, Typography } from '@mui/material';
|
|
11
|
+
|
|
12
|
+
interface ActionsProps {
|
|
13
|
+
users: any[];
|
|
14
|
+
addUser: () => void;
|
|
15
|
+
testZodValidation: () => void;
|
|
16
|
+
testSchemaMigration: () => void;
|
|
17
|
+
toggleAutoReset: () => void;
|
|
18
|
+
testRelations: () => void;
|
|
19
|
+
testTransactions: () => void;
|
|
20
|
+
testCompoundIndexes: () => void;
|
|
21
|
+
testAggregations: () => void;
|
|
22
|
+
clearAll: () => void;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function Actions({
|
|
26
|
+
users,
|
|
27
|
+
addUser,
|
|
28
|
+
testZodValidation,
|
|
29
|
+
testSchemaMigration,
|
|
30
|
+
toggleAutoReset,
|
|
31
|
+
testRelations,
|
|
32
|
+
testTransactions,
|
|
33
|
+
testCompoundIndexes,
|
|
34
|
+
testAggregations,
|
|
35
|
+
clearAll,
|
|
36
|
+
}: ActionsProps) {
|
|
37
|
+
return (
|
|
38
|
+
<Box>
|
|
39
|
+
<Typography variant="h5" sx={{ mb: 2 }}>
|
|
40
|
+
Admin Actions
|
|
41
|
+
</Typography>
|
|
42
|
+
<Box sx={{
|
|
43
|
+
display: 'grid',
|
|
44
|
+
gridTemplateColumns: {
|
|
45
|
+
xs: '1fr 1fr',
|
|
46
|
+
sm: 'repeat(3, 1fr)',
|
|
47
|
+
md: 'repeat(4, 1fr)',
|
|
48
|
+
lg: 'repeat(5, 1fr)'
|
|
49
|
+
},
|
|
50
|
+
gridTemplateRows: {
|
|
51
|
+
xs: 'repeat(5, auto)',
|
|
52
|
+
sm: 'repeat(3, auto)',
|
|
53
|
+
md: 'repeat(3, auto)',
|
|
54
|
+
lg: 'repeat(2, auto)'
|
|
55
|
+
},
|
|
56
|
+
gap: 1,
|
|
57
|
+
mb: 2
|
|
58
|
+
}}>
|
|
59
|
+
<Button
|
|
60
|
+
variant="outlined"
|
|
61
|
+
onClick={addUser}
|
|
62
|
+
startIcon={<PersonIcon />}
|
|
63
|
+
sx={{
|
|
64
|
+
fontSize: { xs: '0.75rem', sm: '0.875rem' },
|
|
65
|
+
py: { xs: 1, sm: 1.5 }
|
|
66
|
+
}}
|
|
67
|
+
>
|
|
68
|
+
Add User
|
|
69
|
+
</Button>
|
|
70
|
+
<Button
|
|
71
|
+
variant="outlined"
|
|
72
|
+
onClick={testZodValidation}
|
|
73
|
+
startIcon={<ScienceIcon />}
|
|
74
|
+
sx={{
|
|
75
|
+
fontSize: { xs: '0.75rem', sm: '0.875rem' },
|
|
76
|
+
py: { xs: 1, sm: 1.5 }
|
|
77
|
+
}}
|
|
78
|
+
>
|
|
79
|
+
Test Zod
|
|
80
|
+
</Button>
|
|
81
|
+
<Button
|
|
82
|
+
variant="outlined"
|
|
83
|
+
onClick={testSchemaMigration}
|
|
84
|
+
startIcon={<StorageIcon />}
|
|
85
|
+
sx={{
|
|
86
|
+
fontSize: { xs: '0.75rem', sm: '0.875rem' },
|
|
87
|
+
py: { xs: 1, sm: 1.5 }
|
|
88
|
+
}}
|
|
89
|
+
>
|
|
90
|
+
Schema
|
|
91
|
+
</Button>
|
|
92
|
+
<Button
|
|
93
|
+
variant="outlined"
|
|
94
|
+
onClick={toggleAutoReset}
|
|
95
|
+
startIcon={<SettingsIcon />}
|
|
96
|
+
sx={{
|
|
97
|
+
fontSize: { xs: '0.75rem', sm: '0.875rem' },
|
|
98
|
+
py: { xs: 1, sm: 1.5 }
|
|
99
|
+
}}
|
|
100
|
+
>
|
|
101
|
+
Auto-Reset
|
|
102
|
+
</Button>
|
|
103
|
+
<Button
|
|
104
|
+
variant="outlined"
|
|
105
|
+
onClick={testRelations}
|
|
106
|
+
startIcon={<LinkIcon />}
|
|
107
|
+
sx={{
|
|
108
|
+
fontSize: { xs: '0.75rem', sm: '0.875rem' },
|
|
109
|
+
py: { xs: 1, sm: 1.5 }
|
|
110
|
+
}}
|
|
111
|
+
>
|
|
112
|
+
Relations
|
|
113
|
+
</Button>
|
|
114
|
+
<Button
|
|
115
|
+
variant="outlined"
|
|
116
|
+
onClick={testTransactions}
|
|
117
|
+
startIcon={<SpeedIcon />}
|
|
118
|
+
sx={{
|
|
119
|
+
fontSize: { xs: '0.75rem', sm: '0.875rem' },
|
|
120
|
+
py: { xs: 1, sm: 1.5 }
|
|
121
|
+
}}
|
|
122
|
+
>
|
|
123
|
+
Transactions
|
|
124
|
+
</Button>
|
|
125
|
+
<Button
|
|
126
|
+
variant="outlined"
|
|
127
|
+
onClick={testCompoundIndexes}
|
|
128
|
+
startIcon={<SearchIcon />}
|
|
129
|
+
sx={{
|
|
130
|
+
fontSize: { xs: '0.75rem', sm: '0.875rem' },
|
|
131
|
+
py: { xs: 1, sm: 1.5 }
|
|
132
|
+
}}
|
|
133
|
+
>
|
|
134
|
+
Indexes
|
|
135
|
+
</Button>
|
|
136
|
+
<Button
|
|
137
|
+
variant="outlined"
|
|
138
|
+
onClick={testAggregations}
|
|
139
|
+
startIcon={<AssessmentIcon />}
|
|
140
|
+
sx={{
|
|
141
|
+
fontSize: { xs: '0.75rem', sm: '0.875rem' },
|
|
142
|
+
py: { xs: 1, sm: 1.5 }
|
|
143
|
+
}}
|
|
144
|
+
>
|
|
145
|
+
Aggregations
|
|
146
|
+
</Button>
|
|
147
|
+
<Button
|
|
148
|
+
variant="outlined"
|
|
149
|
+
onClick={clearAll}
|
|
150
|
+
startIcon={<DeleteSweepIcon />}
|
|
151
|
+
sx={{
|
|
152
|
+
fontSize: { xs: '0.75rem', sm: '0.875rem' },
|
|
153
|
+
py: { xs: 1, sm: 1.5 },
|
|
154
|
+
gridColumn: { xs: '1 / -1', sm: 'auto' }
|
|
155
|
+
}}
|
|
156
|
+
>
|
|
157
|
+
Clear All
|
|
158
|
+
</Button>
|
|
159
|
+
</Box>
|
|
160
|
+
<Typography variant="h6" sx={{ mb: 1 }}>Users ({users.length})</Typography>
|
|
161
|
+
<Stack spacing={1}>
|
|
162
|
+
{users.map((user, index) => (
|
|
163
|
+
<Paper key={index} variant="outlined" sx={{ p: 1.5 }}>
|
|
164
|
+
<strong>{user.name}</strong> ({user.email})<br />
|
|
165
|
+
Age: {user.age}, Tags: {user.tags?.join(', ') || 'none'}
|
|
166
|
+
</Paper>
|
|
167
|
+
))}
|
|
168
|
+
</Stack>
|
|
169
|
+
</Box>
|
|
170
|
+
);
|
|
171
|
+
}
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import CloudSyncIcon from '@mui/icons-material/CloudSync';
|
|
2
|
+
import InfoIcon from '@mui/icons-material/Info';
|
|
3
|
+
import SettingsIcon from '@mui/icons-material/Settings';
|
|
4
|
+
|
|
5
|
+
import { useCloudSyncDemo } from '../hooks/useCloudSyncDemo';
|
|
6
|
+
|
|
7
|
+
// Component demonstrating cloud sync
|
|
8
|
+
export function CloudSyncDemo() {
|
|
9
|
+
const {
|
|
10
|
+
syncStatus,
|
|
11
|
+
isLoading,
|
|
12
|
+
handleManualSync,
|
|
13
|
+
handleEnableCloudSync,
|
|
14
|
+
handleDisableCloudSync,
|
|
15
|
+
handleSyncTables,
|
|
16
|
+
} = useCloudSyncDemo();
|
|
17
|
+
|
|
18
|
+
return (
|
|
19
|
+
<div
|
|
20
|
+
style={{
|
|
21
|
+
border: '2px solid #2196f3',
|
|
22
|
+
padding: '20px',
|
|
23
|
+
margin: '20px 0',
|
|
24
|
+
borderRadius: '8px',
|
|
25
|
+
backgroundColor: '#e3f2fd',
|
|
26
|
+
}}
|
|
27
|
+
>
|
|
28
|
+
<h2>Cloud Sync Demo</h2>
|
|
29
|
+
<p style={{ color: '#666', marginBottom: '20px' }}>
|
|
30
|
+
<strong>Dexie Cloud Addon Integration:</strong> Cloud synchronization demo
|
|
31
|
+
</p>
|
|
32
|
+
|
|
33
|
+
<div
|
|
34
|
+
style={{
|
|
35
|
+
display: 'grid',
|
|
36
|
+
gridTemplateColumns: '1fr 1fr',
|
|
37
|
+
gap: '20px',
|
|
38
|
+
marginBottom: '20px',
|
|
39
|
+
}}
|
|
40
|
+
>
|
|
41
|
+
<div>
|
|
42
|
+
<h3 style={{ display: 'flex', alignItems: 'center', gap: '8px', margin: 0 }}>
|
|
43
|
+
<CloudSyncIcon color="primary" fontSize="small" />
|
|
44
|
+
Sync status
|
|
45
|
+
</h3>
|
|
46
|
+
<div
|
|
47
|
+
style={{
|
|
48
|
+
backgroundColor: 'white',
|
|
49
|
+
padding: '15px',
|
|
50
|
+
borderRadius: '4px',
|
|
51
|
+
border: '1px solid #ddd',
|
|
52
|
+
}}
|
|
53
|
+
>
|
|
54
|
+
<p>
|
|
55
|
+
<strong>Enabled:</strong> {syncStatus.enabled ? 'Yes' : 'No'}
|
|
56
|
+
</p>
|
|
57
|
+
<p>
|
|
58
|
+
<strong>Online:</strong>{' '}
|
|
59
|
+
{syncStatus.isOnline !== undefined
|
|
60
|
+
? syncStatus.isOnline
|
|
61
|
+
? 'Yes'
|
|
62
|
+
: 'No'
|
|
63
|
+
: 'Unknown'}
|
|
64
|
+
</p>
|
|
65
|
+
<p>
|
|
66
|
+
<strong>Last sync:</strong>{' '}
|
|
67
|
+
{syncStatus.lastSync ? syncStatus.lastSync.toLocaleString() : 'Never'}
|
|
68
|
+
</p>
|
|
69
|
+
</div>
|
|
70
|
+
</div>
|
|
71
|
+
|
|
72
|
+
<div>
|
|
73
|
+
<h3 style={{ display: 'flex', alignItems: 'center', gap: '8px', margin: 0 }}>
|
|
74
|
+
<SettingsIcon color="primary" fontSize="small" />
|
|
75
|
+
Sync controls
|
|
76
|
+
</h3>
|
|
77
|
+
<div
|
|
78
|
+
style={{ display: 'flex', flexDirection: 'column', gap: '10px' }}
|
|
79
|
+
>
|
|
80
|
+
<button
|
|
81
|
+
onClick={handleManualSync}
|
|
82
|
+
disabled={!syncStatus.enabled || isLoading}
|
|
83
|
+
style={{
|
|
84
|
+
padding: '10px 15px',
|
|
85
|
+
backgroundColor: syncStatus.enabled ? '#4caf50' : '#ccc',
|
|
86
|
+
color: 'white',
|
|
87
|
+
border: 'none',
|
|
88
|
+
borderRadius: '4px',
|
|
89
|
+
cursor: syncStatus.enabled ? 'pointer' : 'not-allowed',
|
|
90
|
+
}}
|
|
91
|
+
>
|
|
92
|
+
{isLoading ? 'Syncing...' : 'Sync manually'}
|
|
93
|
+
</button>
|
|
94
|
+
|
|
95
|
+
<button
|
|
96
|
+
onClick={handleSyncTables}
|
|
97
|
+
disabled={!syncStatus.enabled || isLoading}
|
|
98
|
+
style={{
|
|
99
|
+
padding: '10px 15px',
|
|
100
|
+
backgroundColor: syncStatus.enabled ? '#ff9800' : '#ccc',
|
|
101
|
+
color: 'white',
|
|
102
|
+
border: 'none',
|
|
103
|
+
borderRadius: '4px',
|
|
104
|
+
cursor: syncStatus.enabled ? 'pointer' : 'not-allowed',
|
|
105
|
+
}}
|
|
106
|
+
>
|
|
107
|
+
Sync tables (users, posts)
|
|
108
|
+
</button>
|
|
109
|
+
|
|
110
|
+
{!syncStatus.enabled ? (
|
|
111
|
+
<button
|
|
112
|
+
onClick={handleEnableCloudSync}
|
|
113
|
+
disabled={isLoading}
|
|
114
|
+
style={{
|
|
115
|
+
padding: '10px 15px',
|
|
116
|
+
backgroundColor: '#2196f3',
|
|
117
|
+
color: 'white',
|
|
118
|
+
border: 'none',
|
|
119
|
+
borderRadius: '4px',
|
|
120
|
+
cursor: 'pointer',
|
|
121
|
+
}}
|
|
122
|
+
>
|
|
123
|
+
Enable cloud sync
|
|
124
|
+
</button>
|
|
125
|
+
) : (
|
|
126
|
+
<button
|
|
127
|
+
onClick={handleDisableCloudSync}
|
|
128
|
+
disabled={isLoading}
|
|
129
|
+
style={{
|
|
130
|
+
padding: '10px 15px',
|
|
131
|
+
backgroundColor: '#f44336',
|
|
132
|
+
color: 'white',
|
|
133
|
+
border: 'none',
|
|
134
|
+
borderRadius: '4px',
|
|
135
|
+
cursor: 'pointer',
|
|
136
|
+
}}
|
|
137
|
+
>
|
|
138
|
+
Disable cloud sync
|
|
139
|
+
</button>
|
|
140
|
+
)}
|
|
141
|
+
</div>
|
|
142
|
+
</div>
|
|
143
|
+
</div>
|
|
144
|
+
|
|
145
|
+
<div
|
|
146
|
+
style={{
|
|
147
|
+
backgroundColor: '#fff3e0',
|
|
148
|
+
padding: '15px',
|
|
149
|
+
borderRadius: '4px',
|
|
150
|
+
border: '1px solid #ffb74d',
|
|
151
|
+
}}
|
|
152
|
+
>
|
|
153
|
+
<h4 style={{ display: 'flex', alignItems: 'center', gap: '8px', margin: '0 0 16px 0' }}>
|
|
154
|
+
<InfoIcon color="primary" fontSize="small" />
|
|
155
|
+
Instructions:
|
|
156
|
+
</h4>
|
|
157
|
+
<ol style={{ margin: '10px 0', paddingLeft: '20px' }}>
|
|
158
|
+
<li>
|
|
159
|
+
<strong>Install dexie-cloud-addon:</strong> <code>npm install dexie-cloud-addon</code>
|
|
160
|
+
</li>
|
|
161
|
+
<li>
|
|
162
|
+
<strong>Configure database URL</strong> in <code>demo-app/src/database/Database.ts</code>
|
|
163
|
+
</li>
|
|
164
|
+
<li>
|
|
165
|
+
<strong>Enable cloud sync</strong> using the button above
|
|
166
|
+
</li>
|
|
167
|
+
<li>
|
|
168
|
+
<strong>Test sync</strong> – add data and verify it synchronizes
|
|
169
|
+
</li>
|
|
170
|
+
</ol>
|
|
171
|
+
</div>
|
|
172
|
+
|
|
173
|
+
<div
|
|
174
|
+
style={{
|
|
175
|
+
marginTop: '15px',
|
|
176
|
+
fontSize: '0.9em',
|
|
177
|
+
color: '#666',
|
|
178
|
+
backgroundColor: '#e8f5e8',
|
|
179
|
+
padding: '10px',
|
|
180
|
+
borderRadius: '4px',
|
|
181
|
+
}}
|
|
182
|
+
>
|
|
183
|
+
<strong>Configuration:</strong> Cloud sync is configured in Database.ts with automatic sync every 30 seconds.
|
|
184
|
+
<br />
|
|
185
|
+
<strong>Offline Support:</strong> The app works offline and syncs when connection is restored.
|
|
186
|
+
<br />
|
|
187
|
+
<strong>Reactivity:</strong> All changes are automatically synchronized with the cloud!
|
|
188
|
+
</div>
|
|
189
|
+
</div>
|
|
190
|
+
);
|
|
191
|
+
}
|