delete recovered

This commit is contained in:
Drew Ansbacher
2021-10-11 12:52:43 -06:00
committed by Aiden McClelland
parent 7dcb4239df
commit 71ce2b064f
6 changed files with 69 additions and 25 deletions

View File

@@ -178,6 +178,9 @@ export module RR {
export type UninstallPackageReq = WithExpire<{ id: string }> // package.uninstall
export type UninstallPackageRes = WithRevision<null>
export type DeleteRecoveredPackageReq = { id: string } // package.delete-recovered
export type DeleteRecoveredPackageRes = WithRevision<null>
export type DryConfigureDependencyReq = { 'dependency-id': string, 'dependent-id': string } // package.dependency.configure.dry
export type DryConfigureDependencyRes = object

View File

@@ -175,6 +175,12 @@ export abstract class ApiService implements Source<DataModel>, Http<DataModel> {
abstract dryConfigureDependency (params: RR.DryConfigureDependencyReq): Promise<RR.DryConfigureDependencyRes>
protected abstract deleteRecoveredPackageRaw (params: RR.UninstallPackageReq): Promise<RR.UninstallPackageRes>
deleteRecoveredPackage = (params: RR.UninstallPackageReq) => this.syncResponse(
() => this.deleteRecoveredPackageRaw(params),
)()
// Helper allowing quick decoration to sync the response patch and return the response contents.
// Pass in a tempUpdate function which returns a UpdateTemp corresponding to a temporary
// state change you'd like to enact prior to request and expired when request terminates.

View File

@@ -260,6 +260,10 @@ export class LiveApiService extends ApiService {
return this.http.rpcRequest({ method: 'package.uninstall.dry', params })
}
async deleteRecoveredPackageRaw (params: RR.DeleteRecoveredPackageReq): Promise <RR.DeleteRecoveredPackageRes> {
return this.http.rpcRequest({ method: 'package.delete-recovered', params })
}
async uninstallPackageRaw (params: RR.UninstallPackageReq): Promise <RR.UninstallPackageRes> {
return this.http.rpcRequest({ method: 'package.uninstall', params })
}

View File

@@ -478,26 +478,32 @@ export class MockApiService extends ApiService {
},
]
let res: any
try {
res = await this.http.rpcRequest<WithRevision<null>>({ method: 'db.patch', params: { patch } })
setTimeout(async () => {
const patch = [
{
op: PatchOp.REMOVE,
path: `/package-data/${params.id}`,
},
]
this.http.rpcRequest<WithRevision<null>>({ method: 'db.patch', params: { patch } })
}, this.revertTime)
} catch (e) {
res = await this.http.rpcRequest<WithRevision<null>>({ method: 'db.patch', params: { patch } })
setTimeout(async () => {
const patch = [
{
op: PatchOp.REMOVE,
path: `/recovered-packages/${params.id}`,
path: `/package-data/${params.id}`,
},
]
res = await this.http.rpcRequest<WithRevision<null>>({ method: 'db.patch', params: { patch } })
}
this.http.rpcRequest<WithRevision<null>>({ method: 'db.patch', params: { patch } })
}, this.revertTime)
return res
}
async deleteRecoveredPackageRaw (params: RR.DeleteRecoveredPackageReq): Promise<RR.DeleteAllNotificationsRes> {
await pauseFor(2000)
let res: any
const patch = [
{
op: PatchOp.REMOVE,
path: `/recovered-packages/${params.id}`,
},
]
res = await this.http.rpcRequest<WithRevision<null>>({ method: 'db.patch', params: { patch } })
return res
}