-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from projectatomic/feature/setup-communication
Feature/setup communication
- Loading branch information
Showing
13 changed files
with
278 additions
and
109 deletions.
There are no files selected for viewing
File renamed without changes.
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,51 @@ | ||
import type { StudioAPI } from '@shared/StudioAPI'; | ||
import { Category } from '@shared/models/ICategory'; | ||
import { Recipe } from '@shared/models/IRecipe'; | ||
import content from './ai.json'; | ||
import { Task } from '@shared/models/ITask'; | ||
|
||
export const RECENT_CATEGORY_ID = 'recent-category'; | ||
|
||
export class StudioApiImpl implements StudioAPI { | ||
|
||
private status: Map<string, Task[]> = new Map<string, Task[]>(); | ||
|
||
async getPullingStatus(recipeId: string): Promise<Task[]> { | ||
return []; | ||
} | ||
|
||
async ping(): Promise<string> { | ||
return 'pong'; | ||
} | ||
|
||
async getRecentRecipes(): Promise<Recipe[]> { | ||
return content.recipes.toSpliced(0, 10); | ||
} | ||
|
||
async getCategories(): Promise<Category[]> { | ||
return content.categories; | ||
} | ||
|
||
async getRecipesByCategory(categoryId: string): Promise<Recipe[]> { | ||
if (categoryId === RECENT_CATEGORY_ID) return this.getRecentRecipes(); | ||
|
||
return content.recipes.filter(recipe => recipe.categories.includes(categoryId)); | ||
} | ||
|
||
async getRecipeById(recipeId: string): Promise<Recipe> { | ||
const recipe = (content.recipes as Recipe[]).find(recipe => recipe.id === recipeId); | ||
if (recipe) return recipe; | ||
throw new Error('Not found'); | ||
} | ||
|
||
async searchRecipes(query: string): Promise<Recipe[]> { | ||
return []; // todo: not implemented | ||
} | ||
|
||
async pullApplication(recipeId: string): Promise<void> { | ||
const recipe: Recipe = await this.getRecipeById(recipeId); | ||
|
||
//todo: stuff here | ||
return Promise.resolve(undefined); | ||
} | ||
} |
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
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,40 +1,8 @@ | ||
import type { Recipe } from '@shared/models/IRecipe'; | ||
import type { Category } from '@shared/models/ICategory'; | ||
import content from './ai.json'; | ||
import type { StudioAPI } from '@shared/StudioAPI'; | ||
import { RpcBrowser } from '@shared/MessageProxy'; | ||
|
||
export const RECENT_CATEGORY_ID = 'recent-category'; | ||
const podmanDesktopApi = acquirePodmanDesktopApi(); | ||
const rpcBrowser: RpcBrowser = new RpcBrowser(window, podmanDesktopApi); | ||
|
||
export class StudioClient implements StudioAPI { | ||
// podmanDesktopApi = acquirePodmanDesktopApi?.(); | ||
|
||
async ping(): Promise<string> { | ||
return 'pong'; | ||
} | ||
|
||
async getRecentRecipes(): Promise<Recipe[]> { | ||
return content.recipes.toSpliced(0, 10); | ||
} | ||
|
||
async getCategories(): Promise<Category[]> { | ||
return content.categories; | ||
} | ||
|
||
async getRecipesByCategory(categoryId: string): Promise<Recipe[]> { | ||
if (categoryId === RECENT_CATEGORY_ID) return this.getRecentRecipes(); | ||
|
||
return content.recipes.filter(recipe => recipe.categories.includes(categoryId)); | ||
} | ||
|
||
async getRecipeById(recipeId: string): Promise<Recipe> { | ||
const recipe = (content.recipes as Recipe[]).find(recipe => recipe.id === recipeId); | ||
if (recipe) return recipe; | ||
throw new Error('Not found'); | ||
} | ||
|
||
async searchRecipes(query: string): Promise<Recipe[]> { | ||
return []; // todo: not implemented | ||
} | ||
} | ||
|
||
export const studioClient = new StudioClient(); | ||
export const studioClient: StudioAPI = rpcBrowser.getProxy<StudioAPI>(); |
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
Oops, something went wrong.