-
Notifications
You must be signed in to change notification settings - Fork 13.8k
chore(apps): consolidate accessor implementation to runtime (4/4) #41171
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
ggazzo
merged 8 commits into
develop
from
claude/base-runtime-accessor-consolidation-ecurei
Jul 31, 2026
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
dfb4665
refactor(apps): Phase 4 - remove the accessor:* message category
claude c197985
refactor(apps): remove dead host accessor layer (Phase 5 / follow-up #4)
claude 0fb8b3a
refactor(apps): make AppResourceBridge an AppManager-owned singleton
claude fb7bc44
refactor(apps): replace RemoteBridges facade with a bridgeCall helper
claude 7f65d15
fix: pass thunk wrappers to accessors instead of senderFn directly
d-gubert b454495
fix: comment alignment
d-gubert a8f7a16
fix: apply reviews
d-gubert 45cb2be
docs: transform the proposal into an ADR
d-gubert File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
94 changes: 0 additions & 94 deletions
94
docs/proposals/apps-accessor-consolidation/base-runtime-app-id-exceptions.md
This file was deleted.
Oops, something went wrong.
31 changes: 20 additions & 11 deletions
31
packages/apps/base-runtime/src/lib/accessors/Persistence.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,44 +1,53 @@ | ||
| import type { IPersistence } from '@rocket.chat/apps-engine/definition/accessors'; | ||
| import type { RocketChatAssociationRecord } from '@rocket.chat/apps-engine/definition/metadata'; | ||
|
|
||
| import type { RemoteBridges } from '../bridges/RemoteBridges'; | ||
| import { bridgeCall } from '../bridges/bridgeCall'; | ||
| import type * as Messenger from '../messenger'; | ||
|
|
||
| export class Persistence implements IPersistence { | ||
| constructor(private readonly bridges: RemoteBridges) {} | ||
| constructor(private readonly senderFn: typeof Messenger.sendRequest) {} | ||
|
|
||
| public create(data: object): Promise<string> { | ||
| return this.bridges.getPersistenceBridge().doCreate(data, 'APP_ID') as Promise<string>; | ||
| return bridgeCall<string>(this.senderFn, 'getPersistenceBridge', 'doCreate', data, 'APP_ID'); | ||
| } | ||
|
|
||
| public createWithAssociation(data: object, association: RocketChatAssociationRecord): Promise<string> { | ||
| return this.bridges.getPersistenceBridge().doCreateWithAssociations(data, new Array(association), 'APP_ID') as Promise<string>; | ||
| return bridgeCall<string>(this.senderFn, 'getPersistenceBridge', 'doCreateWithAssociations', data, new Array(association), 'APP_ID'); | ||
| } | ||
|
|
||
| public createWithAssociations(data: object, associations: Array<RocketChatAssociationRecord>): Promise<string> { | ||
| return this.bridges.getPersistenceBridge().doCreateWithAssociations(data, associations, 'APP_ID') as Promise<string>; | ||
| return bridgeCall<string>(this.senderFn, 'getPersistenceBridge', 'doCreateWithAssociations', data, associations, 'APP_ID'); | ||
| } | ||
|
|
||
| public update(id: string, data: object, upsert = false): Promise<string> { | ||
| return this.bridges.getPersistenceBridge().doUpdate(id, data, upsert, 'APP_ID') as Promise<string>; | ||
| return bridgeCall<string>(this.senderFn, 'getPersistenceBridge', 'doUpdate', id, data, upsert, 'APP_ID'); | ||
| } | ||
|
|
||
| public updateByAssociation(association: RocketChatAssociationRecord, data: object, upsert = false): Promise<string> { | ||
| return this.bridges.getPersistenceBridge().doUpdateByAssociations(new Array(association), data, upsert, 'APP_ID') as Promise<string>; | ||
| return bridgeCall<string>( | ||
| this.senderFn, | ||
| 'getPersistenceBridge', | ||
| 'doUpdateByAssociations', | ||
| new Array(association), | ||
| data, | ||
| upsert, | ||
| 'APP_ID', | ||
| ); | ||
| } | ||
|
|
||
| public updateByAssociations(associations: Array<RocketChatAssociationRecord>, data: object, upsert = false): Promise<string> { | ||
| return this.bridges.getPersistenceBridge().doUpdateByAssociations(associations, data, upsert, 'APP_ID') as Promise<string>; | ||
| return bridgeCall<string>(this.senderFn, 'getPersistenceBridge', 'doUpdateByAssociations', associations, data, upsert, 'APP_ID'); | ||
| } | ||
|
|
||
| public remove(id: string): Promise<object> { | ||
| return this.bridges.getPersistenceBridge().doRemove(id, 'APP_ID') as Promise<object>; | ||
| return bridgeCall<object>(this.senderFn, 'getPersistenceBridge', 'doRemove', id, 'APP_ID'); | ||
| } | ||
|
|
||
| public removeByAssociation(association: RocketChatAssociationRecord): Promise<Array<object>> { | ||
| return this.bridges.getPersistenceBridge().doRemoveByAssociations(new Array(association), 'APP_ID') as Promise<Array<object>>; | ||
| return bridgeCall<Array<object>>(this.senderFn, 'getPersistenceBridge', 'doRemoveByAssociations', new Array(association), 'APP_ID'); | ||
| } | ||
|
|
||
| public removeByAssociations(associations: Array<RocketChatAssociationRecord>): Promise<Array<object>> { | ||
| return this.bridges.getPersistenceBridge().doRemoveByAssociations(associations, 'APP_ID') as Promise<Array<object>>; | ||
| return bridgeCall<Array<object>>(this.senderFn, 'getPersistenceBridge', 'doRemoveByAssociations', associations, 'APP_ID'); | ||
| } | ||
| } |
11 changes: 6 additions & 5 deletions
11
packages/apps/base-runtime/src/lib/accessors/environment/EnvironmentalVariableRead.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,19 +1,20 @@ | ||
| import type { IEnvironmentalVariableRead } from '@rocket.chat/apps-engine/definition/accessors'; | ||
|
|
||
| import type { RemoteBridges } from '../../bridges/RemoteBridges'; | ||
| import { bridgeCall } from '../../bridges/bridgeCall'; | ||
| import type * as Messenger from '../../messenger'; | ||
|
|
||
| export class EnvironmentalVariableRead implements IEnvironmentalVariableRead { | ||
| constructor(private readonly bridges: RemoteBridges) {} | ||
| constructor(private readonly senderFn: typeof Messenger.sendRequest) {} | ||
|
|
||
| public getValueByName(envVarName: string): Promise<string> { | ||
| return this.bridges.getEnvironmentalVariableBridge().doGetValueByName(envVarName, 'APP_ID') as Promise<string>; | ||
| return bridgeCall<string>(this.senderFn, 'getEnvironmentalVariableBridge', 'doGetValueByName', envVarName, 'APP_ID'); | ||
| } | ||
|
|
||
| public isReadable(envVarName: string): Promise<boolean> { | ||
| return this.bridges.getEnvironmentalVariableBridge().doIsReadable(envVarName, 'APP_ID') as Promise<boolean>; | ||
| return bridgeCall<boolean>(this.senderFn, 'getEnvironmentalVariableBridge', 'doIsReadable', envVarName, 'APP_ID'); | ||
| } | ||
|
|
||
| public isSet(envVarName: string): Promise<boolean> { | ||
| return this.bridges.getEnvironmentalVariableBridge().doIsSet(envVarName, 'APP_ID') as Promise<boolean>; | ||
| return bridgeCall<boolean>(this.senderFn, 'getEnvironmentalVariableBridge', 'doIsSet', envVarName, 'APP_ID'); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 5 additions & 4 deletions
9
packages/apps/base-runtime/src/lib/accessors/environment/ServerSettingUpdater.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,16 +1,17 @@ | ||
| import type { IServerSettingUpdater } from '@rocket.chat/apps-engine/definition/accessors'; | ||
| import type { ISetting } from '@rocket.chat/apps-engine/definition/settings'; | ||
|
|
||
| import type { RemoteBridges } from '../../bridges/RemoteBridges'; | ||
| import { bridgeCall } from '../../bridges/bridgeCall'; | ||
| import type * as Messenger from '../../messenger'; | ||
|
|
||
| export class ServerSettingUpdater implements IServerSettingUpdater { | ||
| constructor(private readonly bridges: RemoteBridges) {} | ||
| constructor(private readonly senderFn: typeof Messenger.sendRequest) {} | ||
|
|
||
| public async updateOne(setting: ISetting): Promise<void> { | ||
| await this.bridges.getServerSettingBridge().doUpdateOne(setting, 'APP_ID'); | ||
| await bridgeCall(this.senderFn, 'getServerSettingBridge', 'doUpdateOne', setting, 'APP_ID'); | ||
| } | ||
|
|
||
| public async incrementValue(id: ISetting['id'], value = 1): Promise<void> { | ||
| await this.bridges.getServerSettingBridge().doIncrementValue(id, value, 'APP_ID'); | ||
| await bridgeCall(this.senderFn, 'getServerSettingBridge', 'doIncrementValue', id, value, 'APP_ID'); | ||
| } | ||
| } |
13 changes: 7 additions & 6 deletions
13
packages/apps/base-runtime/src/lib/accessors/environment/ServerSettingsModify.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,24 +1,25 @@ | ||
| import type { IServerSettingsModify } from '@rocket.chat/apps-engine/definition/accessors'; | ||
| import type { ISetting } from '@rocket.chat/apps-engine/definition/settings'; | ||
|
|
||
| import type { RemoteBridges } from '../../bridges/RemoteBridges'; | ||
| import { bridgeCall } from '../../bridges/bridgeCall'; | ||
| import type * as Messenger from '../../messenger'; | ||
|
|
||
| export class ServerSettingsModify implements IServerSettingsModify { | ||
| constructor(private readonly bridges: RemoteBridges) {} | ||
| constructor(private readonly senderFn: typeof Messenger.sendRequest) {} | ||
|
|
||
| public async hideGroup(name: string): Promise<void> { | ||
| await this.bridges.getServerSettingBridge().doHideGroup(name, 'APP_ID'); | ||
| await bridgeCall(this.senderFn, 'getServerSettingBridge', 'doHideGroup', name, 'APP_ID'); | ||
| } | ||
|
|
||
| public async hideSetting(id: string): Promise<void> { | ||
| await this.bridges.getServerSettingBridge().doHideSetting(id, 'APP_ID'); | ||
| await bridgeCall(this.senderFn, 'getServerSettingBridge', 'doHideSetting', id, 'APP_ID'); | ||
| } | ||
|
|
||
| public async modifySetting(setting: ISetting): Promise<void> { | ||
| await this.bridges.getServerSettingBridge().doUpdateOne(setting, 'APP_ID'); | ||
| await bridgeCall(this.senderFn, 'getServerSettingBridge', 'doUpdateOne', setting, 'APP_ID'); | ||
| } | ||
|
|
||
| public async incrementValue(id: ISetting['id'], value = 1): Promise<void> { | ||
| await this.bridges.getServerSettingBridge().doIncrementValue(id, value, 'APP_ID'); | ||
| await bridgeCall(this.senderFn, 'getServerSettingBridge', 'doIncrementValue', id, value, 'APP_ID'); | ||
| } | ||
| } |
7 changes: 4 additions & 3 deletions
7
packages/apps/base-runtime/src/lib/accessors/environment/SettingRead.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 5 additions & 4 deletions
9
packages/apps/base-runtime/src/lib/accessors/environment/SettingUpdater.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,19 +1,20 @@ | ||
| import type { ISettingUpdater } from '@rocket.chat/apps-engine/definition/accessors/ISettingUpdater'; | ||
| import type { ISetting } from '@rocket.chat/apps-engine/definition/settings'; | ||
|
|
||
| import type { RemoteBridges } from '../../bridges/RemoteBridges'; | ||
| import { bridgeCall } from '../../bridges/bridgeCall'; | ||
| import type * as Messenger from '../../messenger'; | ||
|
|
||
| // The "not found" guard and the AppSettingsManager persistence run host-side in the | ||
| // AppResourceBridge (they depend on the ProxiedApp storage item and the settings manager); the | ||
| // runtime accessor is a thin forwarder. | ||
| export class SettingUpdater implements ISettingUpdater { | ||
| constructor(private readonly bridges: RemoteBridges) {} | ||
| constructor(private readonly senderFn: typeof Messenger.sendRequest) {} | ||
|
|
||
| public async updateValue(id: ISetting['id'], value: ISetting['value']): Promise<void> { | ||
| await this.bridges.getAppResourceBridge().doUpdateSettingValue(id, value, 'APP_ID'); | ||
| await bridgeCall(this.senderFn, 'getAppResourceBridge', 'doUpdateSettingValue', id, value, 'APP_ID'); | ||
| } | ||
|
|
||
| public async updateSelectOptions(id: ISetting['id'], values: ISetting['values']): Promise<void> { | ||
| await this.bridges.getAppResourceBridge().doUpdateSettingSelectOptions(id, values, 'APP_ID'); | ||
| await bridgeCall(this.senderFn, 'getAppResourceBridge', 'doUpdateSettingSelectOptions', id, values, 'APP_ID'); | ||
| } | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.