@openinc/parse-server-opendash 4.1.7 → 4.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,10 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  exports.init = init;
7
+ const node_1 = __importDefault(require("parse/node"));
4
8
  const index_js_1 = require("../features/schema/index.js");
5
9
  const index_js_2 = require("../types/index.js");
6
10
  async function init() {
@@ -21,4 +25,21 @@ async function init() {
21
25
  const { object, original, user } = request;
22
26
  // TODO
23
27
  });
28
+ (0, index_js_1.beforeDeleteHook)(index_js_2.Service_Schedule, async (request) => {
29
+ const { object } = request;
30
+ // A protocol points at the plan it documents. Destroying the plan leaves
31
+ // that pointer dangling and the protocol — the record that the work
32
+ // happened — unreachable. Retiring a plan is done by setting `deletedAt`
33
+ // (archiving); the whole frontend already does that, including the admin
34
+ // table, which offers "archive" instead of "delete".
35
+ //
36
+ // A plan without any execution carries no history, so removing it stays
37
+ // allowed — that keeps mistakenly created plans cleanable.
38
+ const executions = await new node_1.default.Query(index_js_2.Service_Schedule_Execution)
39
+ .equalTo("schedule", object)
40
+ .count({ useMasterKey: true });
41
+ if (executions > 0) {
42
+ throw new node_1.default.Error(node_1.default.Error.OPERATION_FORBIDDEN, `Cannot delete maintenance schedule: ${executions} execution(s) document it. Set "deletedAt" to archive it instead.`);
43
+ }
44
+ });
24
45
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openinc/parse-server-opendash",
3
- "version": "4.1.7",
3
+ "version": "4.1.8",
4
4
  "description": "Parse Server Cloud Code for open.INC Stack.",
5
5
  "packageManager": "pnpm@11.25.0",
6
6
  "keywords": [