Skip to content

Commit

Permalink
Merge branch 'Ironclad:main' into qdrant
Browse files Browse the repository at this point in the history
  • Loading branch information
Anush008 authored Mar 27, 2024
2 parents eefe824 + 9786e9c commit a1abb46
Show file tree
Hide file tree
Showing 13 changed files with 64 additions and 39 deletions.
2 changes: 1 addition & 1 deletion packages/app/src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
},
"package": {
"productName": "Rivet",
"version": "1.7.8"
"version": "1.7.9"
},
"tauri": {
"allowlist": {
Expand Down
66 changes: 38 additions & 28 deletions packages/app/src/hooks/useSaveProject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,23 @@ export function useSaveProject() {
saving = toast.info('Saving project');
}, 500);

await ioProvider.saveProjectDataNoPrompt(newProject, { testSuites }, loadedProject.path);
try {
await ioProvider.saveProjectDataNoPrompt(newProject, { testSuites }, loadedProject.path);

if (saving != null) {
toast.dismiss(saving);
}
clearTimeout(savingTimeout);
if (saving != null) {
toast.dismiss(saving);
}
clearTimeout(savingTimeout);

toast.success('Project saved');
setLoadedProject({
loaded: true,
path: loadedProject.path,
});
toast.success('Project saved');
setLoadedProject({
loaded: true,
path: loadedProject.path,
});
} catch (cause) {
clearTimeout(savingTimeout);
toast.error('Failed to save project');
}
}

async function saveProjectAs() {
Expand All @@ -57,26 +62,31 @@ export function useSaveProject() {
saving = toast.info('Saving project');
}, 500);

const filePath = await ioProvider.saveProjectData(newProject, { testSuites });
try {
const filePath = await ioProvider.saveProjectData(newProject, { testSuites });

if (saving != null) {
toast.dismiss(saving);
}
clearTimeout(savingTimeout);
if (saving != null) {
toast.dismiss(saving);
}
clearTimeout(savingTimeout);

if (filePath) {
toast.success('Project saved');
setLoadedProject({
loaded: true,
path: filePath,
});
setOpenedProjects((projects) => ({
...projects,
[project.metadata.id]: {
project,
fsPath: filePath,
},
}));
if (filePath) {
toast.success('Project saved');
setLoadedProject({
loaded: true,
path: filePath,
});
setOpenedProjects((projects) => ({
...projects,
[project.metadata.id]: {
project,
fsPath: filePath,
},
}));
}
} catch (cause) {
clearTimeout(savingTimeout);
toast.error('Failed to save project');
}
}

Expand Down
2 changes: 1 addition & 1 deletion packages/app/src/io/TauriIOProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ export class TauriIOProvider implements IOProvider {

async loadProjectDataNoPrompt(path: string): Promise<{ project: Project; testData: TrivetData }> {
const data = await readTextFile(path);
const [projectData, attachedData] = deserializeProject(data);
const [projectData, attachedData] = deserializeProject(data, path);

const trivetData = attachedData.trivet
? deserializeTrivetData(attachedData.trivet as SerializedTrivetData)
Expand Down
1 change: 1 addition & 0 deletions packages/cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
<tr>
<td align="center" valign="top" width="14.28%"><a href="http://twitter.com/lou7s"><img src="https://avatars.githubusercontent.com/u/35469434?v=4?s=100" width="100px;" alt="loui7"/><br /><sub><b>loui7</b></sub></a><br /><a href="https://github.com/Ironclad/rivet/commits?author=loui7" title="Code">💻</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://aschen.tech"><img src="https://avatars.githubusercontent.com/u/4447392?v=4?s=100" width="100px;" alt="Adrien Maret"/><br /><sub><b>Adrien Maret</b></sub></a><br /><a href="https://github.com/Ironclad/rivet/commits?author=Aschen" title="Code">💻</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/ShravanSunder"><img src="https://avatars.githubusercontent.com/u/5294949?v=4?s=100" width="100px;" alt="Shravan Sunder"/><br /><sub><b>Shravan Sunder</b></sub></a><br /><a href="https://github.com/Ironclad/rivet/commits?author=ShravanSunder" title="Code">💻</a></td>
</tr>
</tbody>
</table>
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@ironclad/rivet-cli",
"license": "MIT",
"repository": "https://github.com/ironclad/rivet",
"version": "1.15.0",
"version": "1.16.0",
"src": "bin/cli.ts",
"bin": {
"rivet": "bin/cli.js"
Expand Down
1 change: 1 addition & 0 deletions packages/core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
<tr>
<td align="center" valign="top" width="14.28%"><a href="http://twitter.com/lou7s"><img src="https://avatars.githubusercontent.com/u/35469434?v=4?s=100" width="100px;" alt="loui7"/><br /><sub><b>loui7</b></sub></a><br /><a href="https://github.com/Ironclad/rivet/commits?author=loui7" title="Code">💻</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://aschen.tech"><img src="https://avatars.githubusercontent.com/u/4447392?v=4?s=100" width="100px;" alt="Adrien Maret"/><br /><sub><b>Adrien Maret</b></sub></a><br /><a href="https://github.com/Ironclad/rivet/commits?author=Aschen" title="Code">💻</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/ShravanSunder"><img src="https://avatars.githubusercontent.com/u/5294949?v=4?s=100" width="100px;" alt="Shravan Sunder"/><br /><sub><b>Shravan Sunder</b></sub></a><br /><a href="https://github.com/Ironclad/rivet/commits?author=ShravanSunder" title="Code">💻</a></td>
</tr>
</tbody>
</table>
Expand Down
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@ironclad/rivet-core",
"license": "MIT",
"repository": "https://github.com/ironclad/rivet",
"version": "1.15.0",
"version": "1.16.0",
"packageManager": "[email protected]",
"main": "dist/cjs/bundle.cjs",
"module": "dist/esm/index.js",
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/model/Project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export type Project = {
title: string;
description: string;
mainGraphId?: GraphId;
path?: string;
};

plugins?: PluginLoadSpec[];
Expand Down
7 changes: 5 additions & 2 deletions packages/core/src/utils/serialization/serialization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,12 @@ export function serializeProject(project: Project, attachedData?: AttachedData):
return projectV4Serializer(project, attachedData);
}

export function deserializeProject(serializedProject: unknown): [Project, AttachedData] {
export function deserializeProject(serializedProject: unknown, path: string | null = null): [Project, AttachedData] {
try {
return projectV4Deserializer(serializedProject);
const result = projectV4Deserializer(serializedProject);
if (path !== null)
result[0].metadata.path = path;
return result;
} catch (err) {
if (err instanceof yaml.YAMLError) {
yamlProblem(err);
Expand Down
10 changes: 9 additions & 1 deletion packages/core/src/utils/serialization/serialization_v4.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,16 @@ export function graphV4Deserializer(data: unknown): NodeGraph {
}

export function projectV4Serializer(project: Project, attachedData?: AttachedData): unknown {
const filteredProject = {
...project,
metadata: {
...project.metadata,
path: undefined,
}
}

// Make sure all data is ordered deterministically first
const stabilized = JSON.parse(stableStringify(toSerializedProject(project, attachedData)));
const stabilized = JSON.parse(stableStringify(toSerializedProject(filteredProject, attachedData)));

const serialized = yaml.stringify(
{
Expand Down
6 changes: 3 additions & 3 deletions packages/core/test/testUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ export async function loadTestGraphInProcessor(graphName: string) {

export async function loadProjectFromFile(path: string): Promise<Project> {
const content = await readFile(path, { encoding: 'utf8' });
return loadProjectFromString(content);
return loadProjectFromString(content, path);
}

export function loadProjectFromString(content: string): Project {
const [project] = deserializeProject(content);
export function loadProjectFromString(content: string, path: string | null = null): Project {
const [project] = deserializeProject(content, path);
return project;
}

Expand Down
1 change: 1 addition & 0 deletions packages/node/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
<tr>
<td align="center" valign="top" width="14.28%"><a href="http://twitter.com/lou7s"><img src="https://avatars.githubusercontent.com/u/35469434?v=4?s=100" width="100px;" alt="loui7"/><br /><sub><b>loui7</b></sub></a><br /><a href="https://github.com/Ironclad/rivet/commits?author=loui7" title="Code">💻</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://aschen.tech"><img src="https://avatars.githubusercontent.com/u/4447392?v=4?s=100" width="100px;" alt="Adrien Maret"/><br /><sub><b>Adrien Maret</b></sub></a><br /><a href="https://github.com/Ironclad/rivet/commits?author=Aschen" title="Code">💻</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/ShravanSunder"><img src="https://avatars.githubusercontent.com/u/5294949?v=4?s=100" width="100px;" alt="Shravan Sunder"/><br /><sub><b>Shravan Sunder</b></sub></a><br /><a href="https://github.com/Ironclad/rivet/commits?author=ShravanSunder" title="Code">💻</a></td>
</tr>
</tbody>
</table>
Expand Down
2 changes: 1 addition & 1 deletion packages/node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@ironclad/rivet-node",
"license": "MIT",
"repository": "https://github.com/ironclad/rivet",
"version": "1.15.0",
"version": "1.16.0",
"main": "dist/cjs/bundle.cjs",
"module": "dist/esm/index.js",
"src": "src/index.ts",
Expand Down

0 comments on commit a1abb46

Please sign in to comment.