🛠 Allow applications to manage the drive (#59)

* Now applications can manage the drive as they wish

* Fix typo

* Fix the access computation

* Test if my code is the issue

* Fix test if app exists

* Fix test if app exists

* Fix test if app exists
This commit is contained in:
Romaric Mourgues
2023-05-22 13:16:51 +02:00
committed by GitHub
parent 4af8e43bb2
commit 62f3b562c0
7 changed files with 124 additions and 15 deletions
@@ -11,7 +11,7 @@ export class ApplicationServiceImpl implements TdriveServiceProvider, Initializa
}
async get(id: string, _: ExecutionContext): Promise<Application> {
return (await this.list(_)).find((app: Application) => app.id === id);
return (await this.list(_)).find((app: Application) => app?.id === id);
}
async list(_: ExecutionContext): Promise<Application[]> {
@@ -18,19 +18,28 @@ export class CompanyApplicationServiceImpl implements TdriveServiceProvider, Ini
pk: Pick<CompanyApplicationPrimaryKey, "company_id" | "application_id"> & { id?: string },
context?: CompanyExecutionContext,
): Promise<CompanyApplicationWithApplication> {
const application = await gr.services.applications.marketplaceApps.get(
pk.application_id,
context,
);
try {
const application = await gr.services.applications.marketplaceApps.get(
pk.application_id,
context,
);
return {
...{
id: pk.application_id,
company_id: pk.company_id,
application_id: pk.application_id,
},
application: application,
};
if (!application?.id) {
return null;
}
return {
...{
id: pk.application_id,
company_id: pk.company_id,
application_id: pk.application_id,
},
application: application,
};
} catch (err) {
console.error(err);
return null;
}
}
async list<ListOptions>(