unleash-server
Version:
Unleash is an enterprise ready feature flag service. It provides different strategies for handling feature flags.
65 lines • 1.85 kB
JavaScript
import NotFoundError from '../../lib/error/notfound-error.js';
export default class FakeClientApplicationsStore {
constructor() {
this.apps = [];
}
async bulkUpsert(details) {
details.forEach((d) => {
// @ts-expect-error
this.apps.push(d);
});
}
async delete(key) {
this.apps.splice(this.apps.findIndex((a) => a.appName === key), 1);
}
async deleteAll() {
this.apps = [];
}
async deleteApplication(appName) {
return this.delete(appName);
}
destroy() { }
async exists(key) {
return this.apps.some((a) => a.appName === key);
}
async get(key) {
const app = this.apps.find((a) => a.appName === key);
if (app) {
return app;
}
throw new NotFoundError(`Could not find application with appName: ${key}`);
}
async getAll() {
return this.apps;
}
async getApplication(appName) {
return this.get(appName);
}
async getApplications(_query) {
return {
applications: this.apps,
total: this.apps.length,
};
}
async getUnannounced() {
return this.apps.filter((a) => !a.announced);
}
async setUnannouncedToAnnounced() {
this.apps = this.apps.map((a) => ({ ...a, announced: true }));
return this.apps;
}
async upsert(details) {
await this.delete(details.appName);
return this.bulkUpsert([details]);
}
getApplicationOverview(_appName) {
throw new Error('Method not implemented.');
}
mapApplicationOverviewData(rows, existingStrategies) {
throw new Error('Method not implemented.');
}
async removeInactiveApplications() {
return 0;
}
}
//# sourceMappingURL=fake-client-applications-store.js.map