1541 extensibility twenty cli use workspace migration v2 to synchronize application objects fields views (#14706)
- synchronize objects https://github.com/user-attachments/assets/257317bc-2881-4b98-a3d4-6ae52bd72aa0
This commit is contained in:
@@ -83,15 +83,7 @@ export class ApiService {
|
||||
try {
|
||||
const mutation = `
|
||||
mutation SyncApplication($manifest: JSON!) {
|
||||
syncApplication(manifest: $manifest) {
|
||||
id
|
||||
standardId
|
||||
label
|
||||
description
|
||||
version
|
||||
createdAt
|
||||
updatedAt
|
||||
}
|
||||
syncApplication(manifest: $manifest)
|
||||
}
|
||||
`;
|
||||
|
||||
@@ -137,124 +129,4 @@ export class ApiService {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
async installApplication(
|
||||
source: string,
|
||||
sourceType: 'git' | 'local' | 'marketplace' = 'local',
|
||||
): Promise<ApiResponse> {
|
||||
// For now, installation is the same as syncing a local manifest
|
||||
// In the future, this could handle different source types
|
||||
try {
|
||||
if (sourceType === 'local') {
|
||||
// Try to load manifest using the new loader
|
||||
try {
|
||||
const { loadAppManifest } = await import(
|
||||
'../utils/app-manifest-loader'
|
||||
);
|
||||
const manifest = await loadAppManifest(source);
|
||||
return this.syncApplication(manifest);
|
||||
} catch (manifestError) {
|
||||
return {
|
||||
success: false,
|
||||
error: `Failed to load manifest: ${manifestError instanceof Error ? manifestError.message : 'Unknown error'}`,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
success: false,
|
||||
error: `Source type "${sourceType}" not yet supported`,
|
||||
};
|
||||
} catch (error) {
|
||||
return {
|
||||
success: false,
|
||||
error: error instanceof Error ? error.message : 'Installation failed',
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
async listApplications(): Promise<ApiResponse> {
|
||||
try {
|
||||
const query = `
|
||||
query FindManyAgents {
|
||||
findManyAgents {
|
||||
id
|
||||
name
|
||||
label
|
||||
description
|
||||
isCustom
|
||||
createdAt
|
||||
updatedAt
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
const response: AxiosResponse = await this.client.post('/metadata', {
|
||||
query,
|
||||
});
|
||||
|
||||
if (response.data.errors) {
|
||||
return {
|
||||
success: false,
|
||||
error: response.data.errors[0]?.message || 'Failed to fetch agents',
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
success: true,
|
||||
data: response.data.data.findManyAgents,
|
||||
};
|
||||
} catch (error) {
|
||||
if (axios.isAxiosError(error) && error.response) {
|
||||
return {
|
||||
success: false,
|
||||
error: error.response.data?.errors?.[0]?.message || error.message,
|
||||
};
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
async getWorkspaces(): Promise<ApiResponse> {
|
||||
try {
|
||||
const query = `
|
||||
query CurrentUser {
|
||||
currentUser {
|
||||
id
|
||||
email
|
||||
currentWorkspace {
|
||||
id
|
||||
displayName
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
const response: AxiosResponse = await this.client.post('/metadata', {
|
||||
query,
|
||||
});
|
||||
|
||||
if (response.data.errors) {
|
||||
return {
|
||||
success: false,
|
||||
error:
|
||||
response.data.errors[0]?.message || 'Failed to fetch workspace',
|
||||
};
|
||||
}
|
||||
|
||||
const workspace = response.data.data.currentUser?.currentWorkspace;
|
||||
return {
|
||||
success: true,
|
||||
data: workspace ? [workspace] : [],
|
||||
};
|
||||
} catch (error) {
|
||||
if (axios.isAxiosError(error) && error.response) {
|
||||
return {
|
||||
success: false,
|
||||
error: error.response.data?.errors?.[0]?.message || error.message,
|
||||
};
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user