Skip to content

Commit 272a16b

Browse files
authored
Feat: introduce streamlit integration (#68)
* Streamlit Integration: Introduces RxDB integration within Streamlit environments, e.g. managing RxDB collection as dataframe in Streamlit * Project Structure Refactoring: Refactors tokens names, import statements and project structure to conform to framework-agnostic approach (import & compile service(s) under non-Angular environment)
1 parent 963b05a commit 272a16b

File tree

83 files changed

+11618
-1719
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+11618
-1719
lines changed

.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
node_modules
22
!.commitlintrc.json
33
**/package.json
4+
tools/scripts

.vscode/launch.json

Lines changed: 46 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,24 +71,66 @@
7171
"type": "node",
7272
"request": "launch",
7373
"runtimeExecutable": "node",
74-
"runtimeArgs": ["--nolazy", "-r", "ts-node/register"],
75-
"args": ["${relativeFile}"],
74+
"runtimeArgs": [
75+
"--nolazy",
76+
"-r",
77+
"ts-node/register"
78+
],
79+
"args": [
80+
"${relativeFile}"
81+
],
7682
"sourceMaps": true,
7783
"cwd": "${workspaceRoot}",
7884
"protocol": "inspector",
79-
"skipFiles": ["<node_internals>/**", "node_modules/**"],
85+
"skipFiles": [
86+
"<node_internals>/**",
87+
"node_modules/**"
88+
],
8089
"console": "integratedTerminal",
8190
"internalConsoleOptions": "neverOpen",
8291
"env": {
8392
"TS_NODE_PROJECT": "${workspaceFolder}/tools/tsconfig.tools.json",
8493
"TS_NODE_TRANSPILE_ONLY": "true"
8594
},
8695
"disableOptimisticBPs": true
96+
},
97+
//
98+
{
99+
"name": "Python: Debug Test",
100+
"type": "debugpy",
101+
"request": "launch",
102+
"module": "pytest",
103+
"args": [
104+
"${file}"
105+
],
106+
"env": {
107+
"PYTHONPATH": "${workspaceFolder}"
108+
},
109+
"console": "integratedTerminal"
110+
},
111+
{
112+
"name": "Python: Debug Streamlit",
113+
"type": "debugpy",
114+
"request": "launch",
115+
"module": "streamlit",
116+
"args": [
117+
"run",
118+
"${file}",
119+
"--server.headless=true",
120+
"--browser.gatherUsageStats=false"
121+
],
122+
"env": {
123+
"PYTHONPATH": "${workspaceFolder}"
124+
},
125+
"console": "integratedTerminal"
87126
}
88127
],
89128
"inputs": [
90129
{
91-
"options": ["rxdb", "kinto"],
130+
"options": [
131+
"rxdb",
132+
"kinto"
133+
],
92134
"id": "libName",
93135
"type": "pickString",
94136
"default": "rxdb",

.vscode/settings.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,9 @@
99
"statusBarItem.remoteBackground": "#8d2089",
1010
"statusBarItem.remoteForeground": "#e7e7e7"
1111
},
12-
"peacock.color": "#8d2089"
12+
"peacock.color": "#8d2089",
13+
"python.defaultInterpreterPath": "/home/voznik/.cache/pypoetry/virtualenvs/streamlit-rxdb-dataframe-zuiqvGqO-py3.10",
14+
"flake8.args": ["--max-line-length=100"],
15+
"flake8.importStrategy": "fromEnvironment",
16+
"black-formatter.args": ["--line-length=100"]
1317
}

README.md

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,12 @@ import { getRxDatabaseCreator } from '@ngx-odm/rxdb/config';
6363
multiInstance: true, // <- multiInstance (optional, default: true)
6464
ignoreDuplicate: false,
6565
options: {
66+
plugins: [
67+
// will be loaded by together with core plugins
68+
RxDBDevModePlugin, // <- add only for development
69+
RxDBAttachmentsPlugin,
70+
RxDBLeaderElectionPlugin,
71+
],
6672
storageType: 'dexie|memory', // <- storageType (optional, use if you want defaults provided automatically)
6773
dumpPath: 'assets/dump.json', // path to datbase dump file (optional)
6874
},
@@ -106,7 +112,7 @@ const todoCollectionConfig: RxCollectionCreatorExtended = {
106112
})
107113
export class TodosModule {
108114
constructor(
109-
@Inject(NgxRxdbCollectionService) private collectionService: NgxRxdbCollection<Todo>
115+
@Inject(RXDB_COLLECTION) private collectionService: RxDBCollectionService<Todo>
110116
) {
111117
this.collectionService.sync(); // INFO: collection is ready
112118
}
@@ -116,11 +122,13 @@ export class TodosModule {
116122
### In your `FeatureService`
117123

118124
```typescript
125+
import { RXDB_COLLECTION } from '@ngx-odm/rxdb';
126+
import { RxDBCollectionService } from '@ngx-odm/rxdb/collection';
127+
119128
@Injectable()
120129
export class TodosService {
121-
private collectionService: NgxRxdbCollection<Todo> = inject<NgxRxdbCollection<Todo>>(
122-
NgxRxdbCollectionService
123-
);
130+
private collectionService: RxDBCollectionService<Todo> =
131+
inject<RxDBCollectionService<Todo>>(RXDB_COLLECTION);
124132
// store & get filter as property of a `local` document
125133
filter$ = this.collectionService
126134
.getLocal('local', 'filterValue')
@@ -177,6 +185,12 @@ export const appConfig: ApplicationConfig = {
177185
multiInstance: true,
178186
ignoreDuplicate: false,
179187
storage: getRxStorageDexie(),
188+
plugins: [
189+
// will be loaded by together with core plugins
190+
RxDBDevModePlugin, // <- add only for development
191+
RxDBAttachmentsPlugin,
192+
RxDBLeaderElectionPlugin,
193+
],
180194
})
181195
),
182196
],

examples/demo/src/app/app.module.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { RouterModule, Routes } from '@angular/router';
55
import { NgxRxdbModule } from '@ngx-odm/rxdb';
66
import { getRxDatabaseCreator } from '@ngx-odm/rxdb/config';
77
import { RxDBAttachmentsPlugin } from 'rxdb/plugins/attachments';
8+
import { RxDBDevModePlugin } from 'rxdb/plugins/dev-mode';
89
import { RxDBLeaderElectionPlugin } from 'rxdb/plugins/leader-election';
910
import { AppComponent } from './app.component';
1011

@@ -35,6 +36,7 @@ const routes: Routes = [
3536
options: {
3637
plugins: [
3738
// will be loaded by together with core plugins
39+
RxDBDevModePlugin,
3840
RxDBAttachmentsPlugin,
3941
RxDBLeaderElectionPlugin,
4042
],

examples/demo/src/app/todos/todos.module.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import { Inject, NgModule } from '@angular/core';
33
import { FormsModule } from '@angular/forms';
44
import { RouterModule } from '@angular/router';
55
import { LetDirective, PushPipe } from '@ngrx/component';
6-
import { NgxRxdbModule } from '@ngx-odm/rxdb';
7-
import { NgxRxdbCollection, NgxRxdbCollectionService } from '@ngx-odm/rxdb/collection';
6+
import { NgxRxdbModule, RXDB_COLLECTION } from '@ngx-odm/rxdb';
7+
import { RxDBCollectionService } from '@ngx-odm/rxdb/collection';
88
import { TODOS_COLLECTION_CONFIG, Todo } from '@shared';
99
import { TodosComponent } from './todos.component';
1010
import { TodosPipe } from './todos.pipe';
@@ -24,7 +24,7 @@ import { TodosService } from './todos.service';
2424
})
2525
export class TodosModule {
2626
constructor(
27-
@Inject(NgxRxdbCollectionService) private collectionService: NgxRxdbCollection<Todo>
27+
@Inject(RXDB_COLLECTION) private collectionService: RxDBCollectionService<Todo>
2828
) {
2929
this.collectionService.sync();
3030
}

examples/demo/src/app/todos/todos.pipe.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Pipe, PipeTransform, inject } from '@angular/core';
2-
import { RXDB_CONFIG_COLLECTION } from '@ngx-odm/rxdb/config';
2+
import { RXDB_CONFIG_COLLECTION } from '@ngx-odm/rxdb';
33
import { Todo, TodosFilter } from '@shared';
44

55
@Pipe({ name: 'byStatus' })

examples/demo/src/app/todos/todos.service.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/* eslint-disable no-console */
22
import { Injectable, inject } from '@angular/core';
3-
import { NgxRxdbCollection, NgxRxdbCollectionService } from '@ngx-odm/rxdb/collection';
3+
import { RXDB_COLLECTION } from '@ngx-odm/rxdb';
4+
import { RxDBCollectionService } from '@ngx-odm/rxdb/collection';
45
import { DEFAULT_LOCAL_DOCUMENT_ID } from '@ngx-odm/rxdb/config';
56
import { Todo, TodosFilter, TodosLocalState } from '@shared';
67
import { Observable, distinctUntilChanged, startWith } from 'rxjs';
@@ -10,9 +11,8 @@ const withAttachments = true;
1011

1112
@Injectable()
1213
export class TodosService {
13-
private collectionService: NgxRxdbCollection<Todo> = inject<NgxRxdbCollection<Todo>>(
14-
NgxRxdbCollectionService
15-
);
14+
private collectionService: RxDBCollectionService<Todo> =
15+
inject<RxDBCollectionService<Todo>>(RXDB_COLLECTION);
1616
newTodo = '';
1717
current: Todo = undefined;
1818

examples/shared/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
export * from './todos.animation';
33
export * from './todos.config';
44
export * from './todos.model';
5+
export * from './todos.schema';
56
export * from './todos.replication';
67
export * from './todos.migration';
78
export * from './environment';
89
// end:ng42.barrel
9-

examples/shared/todos.schema.ts

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
export const TODO_SCHEMA = {
2+
definitions: {},
3+
type: 'object',
4+
title: 'Todo',
5+
description: 'Todo Schema',
6+
required: ['id', 'title', 'createdAt'],
7+
version: 3,
8+
properties: {
9+
id: {
10+
type: 'string',
11+
title: 'Id',
12+
pattern: '^(.*)$',
13+
maxLength: 36,
14+
readOnly: true,
15+
},
16+
title: {
17+
type: 'string',
18+
title: 'Title',
19+
},
20+
completed: {
21+
type: 'boolean',
22+
title: 'Done',
23+
},
24+
createdAt: {
25+
type: 'string',
26+
title: 'Created Date',
27+
format: 'date-time',
28+
readOnly: true,
29+
},
30+
last_modified: {
31+
type: 'number',
32+
title: 'Last Modified Date',
33+
multipleOf: 1,
34+
},
35+
},
36+
__indexes: ['createdAt'],
37+
primaryKey: 'id',
38+
attachments: {
39+
encrypted: false,
40+
},
41+
};

examples/standalone/src/app/app.config.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { provideRouter, withRouterConfig } from '@angular/router';
66
import { provideRxDatabase } from '@ngx-odm/rxdb';
77
import { getRxDatabaseCreator } from '@ngx-odm/rxdb/config';
88
import { RxDBAttachmentsPlugin } from 'rxdb/plugins/attachments';
9+
import { RxDBDevModePlugin } from 'rxdb/plugins/dev-mode';
910
import { RxDBLeaderElectionPlugin } from 'rxdb/plugins/leader-election';
1011
import { appRoutes } from './app.routes';
1112

@@ -26,6 +27,7 @@ export const appConfig: ApplicationConfig = {
2627
options: {
2728
plugins: [
2829
// will be loaded by together with core plugins
30+
RxDBDevModePlugin,
2931
RxDBAttachmentsPlugin,
3032
RxDBLeaderElectionPlugin,
3133
],

nx.json

Lines changed: 40 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@
99
"defaultBase": "origin/master"
1010
},
1111
"release": {
12-
"projects": [
13-
"packages/*"
14-
],
12+
"projects": ["packages/*"],
1513
"projectChangelogs": {
1614
"createRelease": "github"
1715
},
@@ -23,13 +21,8 @@
2321
},
2422
"targetDefaults": {
2523
"build": {
26-
"dependsOn": [
27-
"^build"
28-
],
29-
"inputs": [
30-
"production",
31-
"^production"
32-
],
24+
"dependsOn": ["^build"],
25+
"inputs": ["production", "^production"],
3326
"cache": true
3427
},
3528
"lint": {
@@ -42,11 +35,7 @@
4235
"cache": true
4336
},
4437
"@nx/jest:jest": {
45-
"inputs": [
46-
"default",
47-
"^production",
48-
"{workspaceRoot}/jest.preset.js"
49-
],
38+
"inputs": ["default", "^production", "{workspaceRoot}/jest.preset.js"],
5039
"cache": true,
5140
"options": {
5241
"passWithNoTests": true
@@ -60,10 +49,7 @@
6049
}
6150
},
6251
"namedInputs": {
63-
"default": [
64-
"{projectRoot}/**/*",
65-
"sharedGlobals"
66-
],
52+
"default": ["{projectRoot}/**/*", "sharedGlobals"],
6753
"production": [
6854
"default",
6955
"!{projectRoot}/**/?(*.)+(spec|test).[jt]s?(x)?(.snap)",
@@ -89,6 +75,40 @@
8975
},
9076
"@nx/angular:component": {
9177
"style": "css"
78+
},
79+
"@nx/react": {
80+
"library": {
81+
"style": "css",
82+
"linter": "eslint",
83+
"unitTestRunner": "jest"
84+
},
85+
"application": {
86+
"babel": true,
87+
"style": "css",
88+
"linter": "eslint",
89+
"bundler": "vite"
90+
},
91+
"component": {
92+
"style": "css"
93+
}
94+
}
95+
},
96+
"plugins": [
97+
{
98+
"plugin": "@nx/eslint/plugin",
99+
"options": {
100+
"targetName": "lint"
101+
}
102+
},
103+
{
104+
"plugin": "@nx/vite/plugin",
105+
"options": {
106+
"buildTargetName": "build",
107+
"previewTargetName": "preview",
108+
"testTargetName": "test",
109+
"serveTargetName": "serve",
110+
"serveStaticTargetName": "serve-static"
111+
}
92112
}
93-
}
113+
]
94114
}

0 commit comments

Comments
 (0)