Add ProjectStorageDomain with projectStorage sync
CI / check (push) Successful in 48s

This commit is contained in:
edmand46
2026-08-12 23:58:30 +03:00
parent 3ab2d4a6cf
commit fd364fd156
6 changed files with 80 additions and 0 deletions
+26
View File
@@ -0,0 +1,26 @@
import { SyncedState } from '../state/SyncedState.js';
import type { RudderContext } from '../core/context.js';
import { api } from '../generated/api.js';
import type {
GetProjectStorageResponse,
ProjectStorageUpdateItem,
} from '../generated/project-storage.js';
/**
* ProjectStorageDomain — project-wide key/value storage as an observable
* entity, plus its mutations. Synced under revision key `projectStorage`;
* mutations invalidate it so subscribers observe fresh data.
*/
export class ProjectStorageDomain extends SyncedState<GetProjectStorageResponse> {
readonly syncKey = 'projectStorage';
constructor(private readonly ctx: RudderContext) {
super(() => api.getProjectStorage(ctx, { limit: 100 }));
}
/** Saves project storage items, then invalidates. */
async save(items: ProjectStorageUpdateItem[]): Promise<void> {
await api.updateProjectStorage(this.ctx, { items });
this.invalidate();
}
}