Skip to content

Commit 843972f

Browse files
authored
Feat/entity sync (#112)
* feat: entity sync * fs upgrade, elevated system context * adjusted changelogs and versions * code review fixes * prettier fix * startup fixes
1 parent aa07f58 commit 843972f

45 files changed

Lines changed: 857 additions & 547 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<!-- version-type: patch -->
2+
3+
# common
4+
5+
<!--
6+
FORMATTING GUIDE:
7+
8+
### Detailed Entry (appears first when merging)
9+
10+
Use h3 (###) and below for detailed entries with paragraphs, code examples, and lists.
11+
12+
### Simple List Items
13+
14+
- Simple changes can be added as list items
15+
- They are collected together at the bottom of each section
16+
17+
TIP: When multiple changelog drafts are merged, heading-based entries
18+
appear before simple list items within each section.
19+
-->
20+
21+
## ⬆️ Dependencies
22+
23+
- Upgrade `@furystack/core` to `^15.1.0` with `useSystemIdentityContext` support
24+
- Upgrade `@furystack/rest` to `^8.0.37`
25+
- Add `@furystack/entity-sync` `^0.1.1` for entity synchronization capabilities
26+
- Upgrade `@types/node` to `^25.3.0`
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<!-- version-type: patch -->
2+
3+
# frontend
4+
5+
<!--
6+
FORMATTING GUIDE:
7+
8+
### Detailed Entry (appears first when merging)
9+
10+
Use h3 (###) and below for detailed entries with paragraphs, code examples, and lists.
11+
12+
### Simple List Items
13+
14+
- Simple changes can be added as list items
15+
- They are collected together at the bottom of each section
16+
17+
TIP: When multiple changelog drafts are merged, heading-based entries
18+
appear before simple list items within each section.
19+
-->
20+
21+
## ⬆️ Dependencies
22+
23+
- Upgrade `@furystack/core` to `^15.1.0`
24+
- Upgrade `@furystack/rest` to `^8.0.37`
25+
- Upgrade `@furystack/rest-client-fetch` to `^8.0.37`
26+
- Upgrade `@furystack/shades` to `^12.1.0`
27+
- Upgrade `@furystack/shades-common-components` to `^12.2.0`
28+
- Upgrade `@furystack/shades-lottie` to `^8.0.2`
29+
- Add `@furystack/entity-sync` `^0.1.1` for entity synchronization
30+
- Add `@furystack/entity-sync-client` `^0.1.1` for client-side entity sync
31+
- Upgrade `marked` to `^17.0.3`
32+
- Upgrade `@types/node` to `^25.3.0`
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<!-- version-type: patch -->
2+
3+
# pi-rat
4+
5+
<!--
6+
FORMATTING GUIDE:
7+
8+
### Detailed Entry (appears first when merging)
9+
10+
Use h3 (###) and below for detailed entries with paragraphs, code examples, and lists.
11+
12+
### Simple List Items
13+
14+
- Simple changes can be added as list items
15+
- They are collected together at the bottom of each section
16+
17+
TIP: When multiple changelog drafts are merged, heading-based entries
18+
appear before simple list items within each section.
19+
-->
20+
21+
## ⬆️ Dependencies
22+
23+
- Upgrade `@types/node` to `^25.3.0`
24+
- Upgrade `eslint-plugin-jsdoc` to `^62.6.1`
25+
- Upgrade `eslint-plugin-playwright` to `^2.7.0`
26+
- Upgrade `jsdom` to `^28.1.0`
27+
- Upgrade `rimraf` to `^6.1.3`
28+
- Upgrade `typescript-eslint` to `^8.56.0`
29+
- Upgrade `@furystack/yarn-plugin-changelog` to `^1.0.4`
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<!-- version-type: patch -->
2+
3+
# service
4+
5+
<!--
6+
FORMATTING GUIDE:
7+
8+
### Detailed Entry (appears first when merging)
9+
10+
Use h3 (###) and below for detailed entries with paragraphs, code examples, and lists.
11+
12+
### Simple List Items
13+
14+
- Simple changes can be added as list items
15+
- They are collected together at the bottom of each section
16+
17+
TIP: When multiple changelog drafts are merged, heading-based entries
18+
appear before simple list items within each section.
19+
-->
20+
21+
## ♻️ Refactoring
22+
23+
### Migrate from `StoreManager`/`PhysicalStore` to `DataSet`/`getDataSetFor`
24+
25+
All service-layer data access now uses `DataSet` from `@furystack/repository` instead of directly accessing `PhysicalStore` via `StoreManager`. This enables authorization-aware data operations through the repository layer.
26+
27+
Affected modules: AI (ollama, setup), chat actions (accept/reject/revoke invitation, setup), drives (file watcher), identity (register, setup), install (service installer), IoT (device availability), logging (db logger), media (scan, OMDB, movie maintainer, stream caches, ensure/link utils), ffprobe, and patcher (setup, run, orphan check).
28+
29+
### Use `useSystemIdentityContext` for elevated operations
30+
31+
Background services and event handlers now use `useSystemIdentityContext` to create system-level injectors with named identities (e.g. `ollama-service`, `chat-events`, `movie-maintainer`) instead of accessing stores directly without authorization context.
32+
33+
- Move `sequelize?.sync()` call from `service.ts` to `setup-identity-store.ts` for proper initialization ordering
34+
35+
## ⬆️ Dependencies
36+
37+
- Upgrade `@furystack/core` to `^15.1.0`
38+
- Upgrade `@furystack/repository` to `^10.0.37`
39+
- Upgrade `@furystack/rest` to `^8.0.37`
40+
- Upgrade `@furystack/rest-service` to `^11.0.5`
41+
- Upgrade `@furystack/security` to `^6.0.37`
42+
- Upgrade `@furystack/sequelize-store` to `^6.0.38`
43+
- Upgrade `@furystack/websocket-api` to `^13.1.9`
44+
- Add `@furystack/entity-sync` `^0.1.1` for entity synchronization
45+
- Add `@furystack/entity-sync-service` `^0.1.1` for server-side entity sync
46+
- Upgrade `@types/node` to `^25.3.0`

.yarn/versions/53378eac.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
releases:
2+
common: patch
3+
frontend: patch
4+
pi-rat: patch
5+
service: patch

common/package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,14 @@
2525
"create-schemas": "node ./dist/bin/create-schemas.js"
2626
},
2727
"devDependencies": {
28-
"@types/node": "^25.2.3",
28+
"@types/node": "^25.3.0",
2929
"ts-json-schema-generator": "^2.5.0",
3030
"vitest": "^4.0.18"
3131
},
3232
"dependencies": {
33-
"@furystack/core": "^15.0.36",
34-
"@furystack/rest": "^8.0.36",
33+
"@furystack/core": "^15.1.0",
34+
"@furystack/entity-sync": "^0.1.1",
35+
"@furystack/rest": "^8.0.37",
3536
"ollama": "^0.6.3"
3637
}
3738
}

frontend/package.json

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,28 +12,30 @@
1212
"license": "ISC",
1313
"devDependencies": {
1414
"@codecov/vite-plugin": "^1.9.1",
15-
"@furystack/rest": "^8.0.36",
15+
"@furystack/rest": "^8.0.37",
1616
"@types/marked": "^6.0.0",
1717
"typescript": "^5.9.3",
1818
"vite": "^7.3.1"
1919
},
2020
"dependencies": {
2121
"@furystack/cache": "^6.0.0",
22-
"@furystack/core": "^15.0.36",
22+
"@furystack/core": "^15.1.0",
23+
"@furystack/entity-sync": "^0.1.1",
24+
"@furystack/entity-sync-client": "^0.1.1",
2325
"@furystack/inject": "^12.0.30",
2426
"@furystack/logging": "^8.0.30",
25-
"@furystack/rest-client-fetch": "^8.0.36",
26-
"@furystack/shades": "^12.0.1",
27-
"@furystack/shades-common-components": "^12.1.0",
28-
"@furystack/shades-lottie": "^8.0.1",
27+
"@furystack/rest-client-fetch": "^8.0.37",
28+
"@furystack/shades": "^12.1.0",
29+
"@furystack/shades-common-components": "^12.2.0",
30+
"@furystack/shades-lottie": "^8.0.2",
2931
"@furystack/utils": "^8.1.10",
30-
"@types/node": "^25.2.3",
32+
"@types/node": "^25.3.0",
3133
"@xterm/addon-fit": "^0.11.0",
3234
"@xterm/addon-search": "^0.16.0",
3335
"@xterm/addon-web-links": "^0.12.0",
3436
"@xterm/xterm": "^6.0.0",
3537
"common": "workspace:^",
36-
"marked": "^17.0.2",
38+
"marked": "^17.0.3",
3739
"media-chrome": "^4.17.2",
3840
"monaco-editor": "^0.55.1",
3941
"ollama": "^0.6.3",

package.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,24 +17,24 @@
1717
},
1818
"devDependencies": {
1919
"@eslint/js": "^10.0.1",
20-
"@furystack/yarn-plugin-changelog": "^1.0.3",
20+
"@furystack/yarn-plugin-changelog": "^1.0.4",
2121
"@playwright/test": "^1.58.2",
2222
"@types/jsdom": "^27.0.0",
23-
"@types/node": "^25.2.3",
23+
"@types/node": "^25.3.0",
2424
"@vitest/coverage-v8": "^4.0.18",
2525
"eslint": "^10.0.0",
2626
"eslint-config-prettier": "^10.1.8",
2727
"eslint-plugin-import": "2.32.0",
28-
"eslint-plugin-jsdoc": "^62.5.4",
29-
"eslint-plugin-playwright": "^2.5.1",
28+
"eslint-plugin-jsdoc": "^62.6.1",
29+
"eslint-plugin-playwright": "^2.7.0",
3030
"eslint-plugin-prettier": "^5.5.5",
3131
"husky": "^9.1.7",
32-
"jsdom": "^28.0.0",
32+
"jsdom": "^28.1.0",
3333
"lint-staged": "^16.2.7",
3434
"prettier": "^3.8.1",
35-
"rimraf": "^6.1.2",
35+
"rimraf": "^6.1.3",
3636
"typescript": "^5.9.3",
37-
"typescript-eslint": "^8.55.0",
37+
"typescript-eslint": "^8.56.0",
3838
"vite": "^7.3.1",
3939
"vitest": "^4.0.18"
4040
},

service/package.json

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,24 @@
1414
"devDependencies": {
1515
"@types/ffprobe": "^1.1.8",
1616
"@types/formidable": "^3.4.6",
17-
"@types/node": "^25.2.3",
17+
"@types/node": "^25.3.0",
1818
"@types/ping": "^0.4.4",
1919
"typescript": "^5.9.3"
2020
},
2121
"dependencies": {
2222
"@furystack/cache": "^6.0.0",
23-
"@furystack/core": "^15.0.36",
23+
"@furystack/core": "^15.1.0",
24+
"@furystack/entity-sync": "^0.1.1",
25+
"@furystack/entity-sync-service": "^0.1.1",
2426
"@furystack/inject": "^12.0.30",
2527
"@furystack/logging": "^8.0.30",
26-
"@furystack/repository": "^10.0.36",
27-
"@furystack/rest": "^8.0.36",
28-
"@furystack/rest-service": "^11.0.4",
29-
"@furystack/security": "^6.0.36",
30-
"@furystack/sequelize-store": "^6.0.37",
28+
"@furystack/repository": "^10.0.37",
29+
"@furystack/rest": "^8.0.37",
30+
"@furystack/rest-service": "^11.0.5",
31+
"@furystack/security": "^6.0.37",
32+
"@furystack/sequelize-store": "^6.0.38",
3133
"@furystack/utils": "^8.1.10",
32-
"@furystack/websocket-api": "^13.1.8",
34+
"@furystack/websocket-api": "^13.1.9",
3335
"chokidar": "^5.0.0",
3436
"common": "workspace:^",
3537
"formidable": "^3.5.4",

service/src/ai/ollama-client-service.ts

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
import { getCurrentUser, getStoreManager, type PhysicalStore } from '@furystack/core'
1+
import { getCurrentUser, useSystemIdentityContext } from '@furystack/core'
22
import { Injectable, Injected, type Injector } from '@furystack/inject'
33
import { getLogger, type ScopedLogger } from '@furystack/logging'
4+
import { getDataSetFor, type DataSet } from '@furystack/repository'
45
import { AiChatMessage, Config, type AiChat, type OllamaConfig } from 'common'
56
import type { Message } from 'ollama'
67
import { Ollama, type ChatRequest } from 'ollama'
@@ -40,8 +41,14 @@ export class OllamaClientService {
4041
@Injected((injector) => getLogger(injector).withScope('Ollama Client Service'))
4142
declare private logger: ScopedLogger
4243

43-
@Injected((injector) => getStoreManager(injector).getStoreFor(AiChatMessage, 'id'))
44-
declare private chatMessageStore: PhysicalStore<AiChatMessage, 'id'>
44+
@Injected((injector) => getDataSetFor(injector, AiChatMessage, 'id'))
45+
declare private chatMessageDataSet: DataSet<AiChatMessage, 'id'>
46+
47+
@Injected((injector) => getDataSetFor(injector, Config, 'id'))
48+
declare private configDataSet: DataSet<Config, 'id'>
49+
50+
@Injected((injector) => useSystemIdentityContext({ injector, username: 'ollama-service' }))
51+
declare private systemInjector: Injector
4552

4653
declare ollama: Ollama
4754

@@ -56,10 +63,8 @@ export class OllamaClientService {
5663
)
5764
}
5865

59-
private getOllamaConfig = async (injector: Injector): Promise<OllamaConfig | undefined> => {
60-
const storeManager = getStoreManager(injector)
61-
const configStore = storeManager.getStoreFor(Config, 'id')
62-
const [ollamaConfig] = await configStore.find({
66+
private getOllamaConfig = async (): Promise<OllamaConfig | undefined> => {
67+
const [ollamaConfig] = await this.configDataSet.find(this.systemInjector, {
6368
top: 1,
6469
filter: {
6570
id: { $eq: 'OLLAMA_CONFIG' },
@@ -73,8 +78,8 @@ export class OllamaClientService {
7378
return this.isValidOllamaConfig(ollamaConfig) ? ollamaConfig : undefined
7479
}
7580

76-
public async init(injector: Injector) {
77-
const config = await this.getOllamaConfig(injector)
81+
public async init() {
82+
const config = await this.getOllamaConfig()
7883
if (!config) {
7984
this.config = undefined
8085
await this.logger.information({
@@ -239,7 +244,7 @@ export class OllamaClientService {
239244
})
240245
: result
241246

242-
await this.chatMessageStore.add({
247+
await this.chatMessageDataSet.add(this.systemInjector, {
243248
aiChatId: chat.id,
244249
role: 'assistant',
245250
content: resultWithToolResponses.message.content,

0 commit comments

Comments
 (0)