| 528 | } |
| 529 | |
| 530 | async deleteScripts(uuids: string[]) { |
| 531 | const logger = this.logger.with({ uuids }); |
| 532 | const scripts = (await this.scriptDAO.gets(uuids)).filter((s) => !!s); |
| 533 | if (!scripts.length) { |
| 534 | logger.error("scripts not found"); |
| 535 | throw new Error("scripts not found"); |
| 536 | } |
| 537 | return this.scriptDAO |
| 538 | .deletes(uuids) |
| 539 | .then(async () => { |
| 540 | await this.scriptCodeDAO.deletes(uuids); |
| 541 | await this.compiledResourceDAO.deletes(uuids); |
| 542 | logger.info("delete success"); |
| 543 | const data = scripts.map((script) => ({ |
| 544 | uuid: script.uuid, |
| 545 | storageName: getStorageName(script), |
| 546 | type: script.type, |
| 547 | })) as TDeleteScript[]; |
| 548 | this.mq.publish<TDeleteScript[]>("deleteScripts", data); |
| 549 | return true; |
| 550 | }) |
| 551 | .catch((e) => { |
| 552 | logger.error("delete error", Logger.E(e)); |
| 553 | throw e; |
| 554 | }); |
| 555 | } |
| 556 | |
| 557 | async enableScript(param: { uuid: string; enable: boolean }) { |
| 558 | const { uuid, enable } = param; |