Skip to content

Commit 701adaf

Browse files
committed
fix: rm defaults and add semaphore to FileUserData
1 parent e90412e commit 701adaf

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

packages/compass-data-modeling/src/components/diagram-card.spec.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,6 @@ describe('DiagramCard', () => {
4242
render(<DiagramCard {...props} />);
4343
expect(screen.getByText('Test Diagram')).to.be.visible;
4444
expect(screen.getByText('someDatabase')).to.be.visible;
45-
expect(screen.getByText(/modified/)).to.be.visible;
45+
expect(screen.getByText('Last modified: October 3, 2023')).to.be.visible;
4646
});
4747
});

packages/compass-user-data/src/user-data.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ export abstract class IUserData<T extends z.Schema> {
7272
protected readonly validator: T;
7373
protected readonly serialize: SerializeContent<z.input<T>>;
7474
protected readonly deserialize: DeserializeContent;
75-
protected static readonly semaphore = new Semaphore(100);
7675

7776
constructor(
7877
validator: T,
@@ -102,14 +101,15 @@ export class FileUserData<T extends z.Schema> extends IUserData<T> {
102101
private readonly subdir: string;
103102
private readonly basePath?: string;
104103
private readonly getFileName: GetFileName;
104+
protected readonly semaphore = new Semaphore(100);
105105

106106
constructor(
107107
validator: T,
108108
{
109109
subdir,
110110
basePath,
111-
serialize = (content: z.input<T>) => JSON.stringify(content, null, 2),
112-
deserialize = JSON.parse,
111+
serialize,
112+
deserialize,
113113
getFileName = (id) => `${id}.json`,
114114
}: FileUserDataOptions<z.input<T>>
115115
) {
@@ -157,7 +157,7 @@ export class FileUserData<T extends z.Schema> extends IUserData<T> {
157157
let handle: fs.FileHandle | undefined = undefined;
158158
let release: (() => void) | undefined = undefined;
159159
try {
160-
release = await IUserData.semaphore.waitForRelease();
160+
release = await this.semaphore.waitForRelease();
161161
handle = await fs.open(absolutePath, 'r');
162162
[stats, data] = await Promise.all([
163163
handle.stat(),

packages/my-queries-storage/src/compass-query-storage.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,10 @@ export abstract class CompassQueryStorage<TSchema extends z.Schema> {
4646
return await this.userData.delete(id);
4747
}
4848

49-
async updateAttributes(id: string, data: Partial<z.input<TSchema>>) {
49+
async updateAttributes(
50+
id: string,
51+
data: Partial<z.input<TSchema>>
52+
): Promise<z.output<TSchema>> {
5053
return await this.userData.updateAttributes(id, data);
5154
}
5255

0 commit comments

Comments
 (0)