-
Notifications
You must be signed in to change notification settings - Fork 115
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[front] Import/export apps api (#9870)
* Import/export apps * use system keys * more flexible schema * Add read permission check * Skip app run if no dataset * extract method to lib * Use poke for triggering sync * swagger * missing files * missing files * more logging/error info * Add possibility to display previous specification stored in core * Update front/lib/api/poke/plugins/spaces/sync_apps.ts Co-authored-by: Flavien David <flavien.david74@gmail.com> * Update front/lib/api/poke/plugins/spaces/sync_apps.ts Co-authored-by: Flavien David <flavien.david74@gmail.com> * Update front/lib/utils/apps.ts Co-authored-by: Flavien David <flavien.david74@gmail.com> * review comments * split function * doc * replaced promise.all * lint * Add column with dust-app status * review comments * Track and return app run errors * cleaning results * Add app checks script * check endpoint * Update front/components/spaces/SpaceAppsList.tsx Co-authored-by: Flavien David <flavien.david74@gmail.com> * review comments * format --------- Co-authored-by: Flavien David <flavien.david74@gmail.com>
- Loading branch information
Showing
14 changed files
with
948 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
export * from "./data_source_views"; | ||
export * from "./data_sources"; | ||
export * from "./global"; | ||
export * from "./spaces"; | ||
export * from "./workspaces"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from "./sync_apps"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { Err, Ok } from "@dust-tt/types"; | ||
|
||
import { createPlugin } from "@app/lib/api/poke/types"; | ||
import { SpaceResource } from "@app/lib/resources/space_resource"; | ||
import { synchronizeDustApps } from "@app/lib/utils/apps"; | ||
|
||
export const syncAppsPlugin = createPlugin( | ||
{ | ||
id: "sync-apps", | ||
name: "Sync dust-apps", | ||
description: "Synchronize dust-apps from production", | ||
resourceTypes: ["spaces"], | ||
args: {}, | ||
}, | ||
async (auth, spaceId) => { | ||
if (!spaceId) { | ||
return new Err(new Error("No space specified")); | ||
} | ||
|
||
const space = await SpaceResource.fetchById(auth, spaceId); | ||
if (!space) { | ||
return new Err(new Error("Space not found")); | ||
} | ||
const result = await synchronizeDustApps(auth, space); | ||
if (result.isErr()) { | ||
return new Err(new Error(`Error when syncing: ${result.error.message}`)); | ||
} | ||
if (!result.value) { | ||
return new Ok({ | ||
display: "text", | ||
value: "Sync not enabled.", | ||
}); | ||
} | ||
|
||
return new Ok({ | ||
display: "json", | ||
value: { importedApp: result.value }, | ||
}); | ||
} | ||
); |
Oops, something went wrong.