Files
upstream-mirror 30810eecd7
Some checks failed
Create issues from TODOs / todos (push) Failing after 3s
Close inactive issues / close-issues (push) Has been cancelled
Deploy GitHub Pages / deploy-preview (push) Has been cancelled
CI / ⚙️ Variables Setup (push) Has been cancelled
CI / ⚙️ Test Guard (push) Has been cancelled
CI / 🚀 Notify external services - draft (push) Has been cancelled
CI / 📦 Build Packages (push) Has been cancelled
CI / 📦 Meteor Build (coverage) (push) Has been cancelled
CI / 📦 Meteor Build (production) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [account-service presence-service omnichannel-transcript-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [account-service presence-service omnichannel-transcript-service], fips) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [authorization-service queue-worker-service ddp-streamer-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [authorization-service queue-worker-service ddp-streamer-service], fips) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], coverage) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], fips) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [account-service presence-service omnichannel-transcript-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [authorization-service queue-worker-service ddp-streamer-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [rocketchat], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [rocketchat], coverage) (push) Has been cancelled
CI / 🚢 Publish Docker Images (ghcr.io) (push) Has been cancelled
CI / 📦 Track Image Sizes (push) Has been cancelled
CI / 🔎 Code Check - Action Lint (push) Has been cancelled
CI / 🔎 Code Check (push) Has been cancelled
CI / 🔨 Test Storybook (push) Has been cancelled
CI / 🔨 Test Unit (push) Has been cancelled
CI / 🔨 Test API (CE) (push) Has been cancelled
CI / 🔨 Test API Livechat (CE) (push) Has been cancelled
CI / 🔨 Test UI (CE) (push) Has been cancelled
CI / 🔨 Test API (EE) (push) Has been cancelled
CI / 🔨 Test API Livechat (EE) (push) Has been cancelled
CI / 🔨 Test API Apps (deno-runtime - EE) (push) Has been cancelled
CI / 🔨 Test UI (EE) (push) Has been cancelled
CI / 🔨 Test API (FIPS) (push) Has been cancelled
CI / 🔨 Test API Livechat (FIPS) (push) Has been cancelled
CI / 🔨 Test UI (FIPS) (push) Has been cancelled
CI / 🔨 Test Federation Matrix (push) Has been cancelled
CI / 📊 Report Coverage (push) Has been cancelled
CI / ✅ Tests Done (push) Has been cancelled
CI / 🚀 Publish build assets (push) Has been cancelled
CI / 🚀 Publish Docker Images (DockerHub) (push) Has been cancelled
CI / 🚀 Notify external services (push) Has been cancelled
CI / Update Version Durability (push) Has been cancelled
Release / Release (push) Has been cancelled
Auto-close duplicate issues / auto-close-duplicates (push) Failing after 1s
Code scanning - action / CodeQL-Build (push) Failing after 2s
snapshot of https://github.com/RocketChat/Rocket.Chat.git (develop, 2026-09-16; blobs > 131072B omitted)
2026-09-16 01:21:02 +05:00

111 lines
3.5 KiB
TypeScript

import type { AppStatus } from '@rocket.chat/apps-engine/definition/AppStatus';
import type { IAppInfo } from '@rocket.chat/apps-engine/definition/metadata';
import type { ISetting } from '@rocket.chat/apps-engine/definition/settings';
import type { IMarketplaceInfo } from '../../../src/server/marketplace';
import type { IAppStorageItem } from '../../../src/server/storage';
import { AppMetadataStorage } from '../../../src/server/storage';
import { AppInstallationSource } from '../../../src/server/storage/IAppStorageItem';
export class TestsAppStorage extends AppMetadataStorage {
private db = new Map<string, IAppStorageItem>();
constructor() {
super('in-memory');
}
public create(item: IAppStorageItem): Promise<IAppStorageItem> {
for (const [id, value] of this.db) {
if (id === item.id || item.info.nameSlug === value.info.nameSlug) {
return Promise.reject(new Error('App already exists.'));
}
}
const stored = { ...item, _id: item._id ?? item.id, createdAt: new Date(), updatedAt: new Date() };
this.db.set(stored.id, stored);
return Promise.resolve(stored);
}
public retrieveOne(id: string): Promise<IAppStorageItem | null> {
return Promise.resolve(this.db.get(id) ?? null);
}
public retrieveAll(): Promise<Map<string, IAppStorageItem>> {
return Promise.resolve(new Map(this.db));
}
public retrieveAllPrivate(): Promise<Map<string, IAppStorageItem>> {
const items = new Map<string, IAppStorageItem>();
for (const [id, item] of this.db) {
if (item.installationSource === AppInstallationSource.PRIVATE) {
items.set(id, item);
}
}
return Promise.resolve(items);
}
public clear(): void {
this.db.clear();
}
public remove(id: string): Promise<{ success: boolean }> {
this.db.delete(id);
return Promise.resolve({ success: true });
}
public updatePartialAndReturnDocument(
item: Partial<IAppStorageItem>,
_options?: { unsetPermissionsGranted?: boolean },
): Promise<IAppStorageItem> {
const lookupId = item.id ?? item._id;
if (!lookupId) {
return Promise.reject(new Error('Cannot update: item has no id.'));
}
const existing = this.db.get(lookupId);
if (!existing) {
return Promise.reject(new Error(`App not found: ${lookupId}`));
}
const updated = { ...existing, ...item, updatedAt: new Date() };
this.db.set(updated.id, updated);
return Promise.resolve(updated);
}
public updateStatus(id: string, status: AppStatus): Promise<boolean> {
const existing = this.db.get(id);
if (!existing) {
return Promise.resolve(false);
}
this.db.set(id, { ...existing, status, updatedAt: new Date() });
return Promise.resolve(true);
}
public updateSetting(id: string, setting: ISetting): Promise<boolean> {
const existing = this.db.get(id);
if (!existing) {
return Promise.resolve(false);
}
this.db.set(id, { ...existing, settings: { ...existing.settings, [setting.id]: setting }, updatedAt: new Date() });
return Promise.resolve(true);
}
public updateAppInfo(id: string, info: IAppInfo): Promise<boolean> {
const existing = this.db.get(id);
if (!existing) {
return Promise.resolve(false);
}
this.db.set(id, { ...existing, info, updatedAt: new Date() });
return Promise.resolve(true);
}
public updateMarketplaceInfo(id: string, marketplaceInfo: IMarketplaceInfo[]): Promise<boolean> {
const existing = this.db.get(id);
if (!existing) {
return Promise.resolve(false);
}
this.db.set(id, { ...existing, marketplaceInfo, updatedAt: new Date() });
return Promise.resolve(true);
}
}