@openinc/parse-server-opendash 4.39.0 → 4.41.0
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.
- package/dist/features/config/helper/customOptions.js +9 -0
- package/dist/features/openservice/alarms/alarmIdentity.d.ts +2 -0
- package/dist/features/openservice/alarms/alarmIdentity.js +4 -1
- package/dist/features/openservice/alarms/schedule/AlarmScheduleTypes.d.ts +4 -21
- package/dist/hooks/Service_Schedule_Execution.js +41 -14
- package/dist/hooks/Tenant.js +68 -10
- package/dist/scripts/backfill-execution-snapshot.d.ts +1 -0
- package/dist/scripts/backfill-execution-snapshot.js +124 -0
- package/package.json +12 -11
- package/pnpm-workspace.yaml +1 -1
|
@@ -117,6 +117,15 @@ exports.customoptions = {
|
|
|
117
117
|
default: "false",
|
|
118
118
|
description: "If set to true, users must be verified by a tenant admin before they can log in.",
|
|
119
119
|
},
|
|
120
|
+
TENANT_ACCESS_PERMISSION_ENABLE: {
|
|
121
|
+
env: "OPENINC_PARSE_TENANT_ACCESS_PERMISSION_ENABLE",
|
|
122
|
+
type: "boolean",
|
|
123
|
+
required: false,
|
|
124
|
+
secret: false,
|
|
125
|
+
public: false,
|
|
126
|
+
default: "false",
|
|
127
|
+
description: "If set to true, saving a tenant creates an open.WARE AccessPermission that gives the tenant admin role read/write/delete on all data sources whose tag starts with the tenant's tag prefix.",
|
|
128
|
+
},
|
|
120
129
|
AUTH_ALLOW_USERNAME: {
|
|
121
130
|
env: "OPENINC_PARSE_AUTH_ALLOW_USERNAME",
|
|
122
131
|
type: "boolean",
|
|
@@ -21,6 +21,8 @@ export declare function alarmKey(event: AlarmEvent): string | undefined;
|
|
|
21
21
|
* A free-form, greppable string that says where a record came from and can be
|
|
22
22
|
* queried back (`equalTo("origin", …)`) — the same idea as the schedule
|
|
23
23
|
* plugin's `schedule:<id>:<occurrence>`. Stable across firings of one alarm.
|
|
24
|
+
* Spelled by `@opendash/openservice-shared`, whose `isAlarmOrigin` the
|
|
25
|
+
* frontend reads it back with.
|
|
24
26
|
*/
|
|
25
27
|
export declare function alarmOrigin(event: AlarmEvent): string;
|
|
26
28
|
/** When the alarm fired — never when we happened to receive the call. */
|
|
@@ -7,6 +7,7 @@ exports.sensorLabel = sensorLabel;
|
|
|
7
7
|
exports.formatValue = formatValue;
|
|
8
8
|
exports.renderTitleTemplate = renderTitleTemplate;
|
|
9
9
|
exports.alarmDetailLines = alarmDetailLines;
|
|
10
|
+
const openservice_shared_1 = require("@opendash/openservice-shared");
|
|
10
11
|
/**
|
|
11
12
|
* Identity and text rendering for a fired alarm — pure, so the `origin` marker
|
|
12
13
|
* and the wording can be checked without a database.
|
|
@@ -38,9 +39,11 @@ function alarmKey(event) {
|
|
|
38
39
|
* A free-form, greppable string that says where a record came from and can be
|
|
39
40
|
* queried back (`equalTo("origin", …)`) — the same idea as the schedule
|
|
40
41
|
* plugin's `schedule:<id>:<occurrence>`. Stable across firings of one alarm.
|
|
42
|
+
* Spelled by `@opendash/openservice-shared`, whose `isAlarmOrigin` the
|
|
43
|
+
* frontend reads it back with.
|
|
41
44
|
*/
|
|
42
45
|
function alarmOrigin(event) {
|
|
43
|
-
return
|
|
46
|
+
return (0, openservice_shared_1.alarmOrigin)(String(alarmKey(event)));
|
|
44
47
|
}
|
|
45
48
|
/** When the alarm fired — never when we happened to receive the call. */
|
|
46
49
|
function firedAt(event) {
|
|
@@ -65,26 +65,9 @@ export interface AlarmScheduleParams {
|
|
|
65
65
|
/**
|
|
66
66
|
* The alarm that produced a plan, recorded on `Schedule.asset.alarm`.
|
|
67
67
|
*
|
|
68
|
-
* A plan has no
|
|
68
|
+
* A plan has no room for the firing in its title, so the context would
|
|
69
69
|
* otherwise be lost between the title and the `origin` marker. Structured
|
|
70
|
-
* rather than prose because the trigger overview reads it back. The
|
|
71
|
-
*
|
|
72
|
-
* with `alarmOrigin` / `isAlarmOrigin`); this copy has to match it until the
|
|
73
|
-
* server depends on a release of that package which contains it.
|
|
70
|
+
* rather than prose because the trigger overview reads it back. The shape
|
|
71
|
+
* lives in `@opendash/openservice-shared`, where the frontend reads it too.
|
|
74
72
|
*/
|
|
75
|
-
export
|
|
76
|
-
/** `OD3_Alarm.objectId`, when the executor reported one. */
|
|
77
|
-
alarmId?: string;
|
|
78
|
-
/** The alarm's name at the time it fired. */
|
|
79
|
-
name?: string;
|
|
80
|
-
/** `source/id [dimension]` — the sensor, as shown to a human. */
|
|
81
|
-
sensor?: string;
|
|
82
|
-
/** The value that broke the rule. */
|
|
83
|
-
value?: number | string | boolean;
|
|
84
|
-
/** Human-readable rule, e.g. `> 80`. */
|
|
85
|
-
condition?: string;
|
|
86
|
-
/** ISO timestamp of the firing. */
|
|
87
|
-
firedAt: string;
|
|
88
|
-
/** Which action row created the plan. */
|
|
89
|
-
actionId: string;
|
|
90
|
-
}
|
|
73
|
+
export type { ScheduleAlarmContext } from "@opendash/openservice-shared";
|
|
@@ -31,7 +31,8 @@ async function init() {
|
|
|
31
31
|
// the colleague on the next shift — are not necessarily the person who
|
|
32
32
|
// carried it out. Write is what gets restricted, below and by Parse.
|
|
33
33
|
await (0, index_js_1.defaultAclHandler)(request, { allowCustomACL: true });
|
|
34
|
-
// Freeze the
|
|
34
|
+
// Freeze what the protocol reads from its plan onto the execution as it is
|
|
35
|
+
// created: the work steps, the machine and the name.
|
|
35
36
|
//
|
|
36
37
|
// Deliberately **before** the migration/master escape below: this is not an
|
|
37
38
|
// authorisation question but a data one. A protocol written by the seed
|
|
@@ -41,11 +42,18 @@ async function init() {
|
|
|
41
42
|
//
|
|
42
43
|
// Without it a protocol shows whatever the plan says *now*: renaming a step
|
|
43
44
|
// rewrites every protocol that referenced it, deleting one turns its
|
|
44
|
-
// results into numbered orphans (GRENZEN §5).
|
|
45
|
+
// results into numbered orphans (GRENZEN §5). The same goes for the plan
|
|
46
|
+
// itself — moved to another machine, every old protocol would move with it
|
|
47
|
+
// (machine book, KPIs, the execution list); renamed, every old protocol
|
|
48
|
+
// would be renamed too. It also makes "executions of machine X" one query
|
|
49
|
+
// on `equipment`, whatever created the run — the open.WARE automation has
|
|
50
|
+
// always set it, the UI never did.
|
|
45
51
|
//
|
|
46
|
-
//
|
|
47
|
-
|
|
48
|
-
|
|
52
|
+
// Only fills what is missing: a direct maintenance (no plan) brings all of
|
|
53
|
+
// it itself, and an explicit value — the automation's `title`, a migrated
|
|
54
|
+
// v1 title — is what was actually recorded.
|
|
55
|
+
if (object.isNew()) {
|
|
56
|
+
await freezePlanSnapshot(object);
|
|
49
57
|
}
|
|
50
58
|
// A protocol has to be about something: the plan it performs, or — for a
|
|
51
59
|
// direct maintenance — the machine it was done on. With neither, no view
|
|
@@ -81,9 +89,9 @@ async function init() {
|
|
|
81
89
|
// Without this, anyone holding `can-perform-execution` could record a run
|
|
82
90
|
// of a plan they were never assigned to, given its objectId (which every
|
|
83
91
|
// tenant-readable execution of that plan carries). It would count towards
|
|
84
|
-
// the plan's due dates, and `
|
|
85
|
-
// master key — would copy the private plan's steps into a
|
|
86
|
-
// tenant can read.
|
|
92
|
+
// the plan's due dates, and `freezePlanSnapshot` above — which reads with
|
|
93
|
+
// the master key — would copy the private plan's steps and title into a
|
|
94
|
+
// record the whole tenant can read.
|
|
87
95
|
//
|
|
88
96
|
// Checked whenever `schedule` changes, not only on create: re-pointing an
|
|
89
97
|
// open execution at another plan is the same question.
|
|
@@ -161,27 +169,46 @@ async function requireReadableSchedule(execution, sessionToken) {
|
|
|
161
169
|
throw new node_1.default.Error(node_1.default.Error.OPERATION_FORBIDDEN, "Maintenance plan not found, or not assigned to you.");
|
|
162
170
|
}
|
|
163
171
|
}
|
|
172
|
+
/** What an execution copies from its plan on create — see the hook. */
|
|
173
|
+
const SNAPSHOT_FIELDS = ["steps", "equipment", "title"];
|
|
164
174
|
/**
|
|
165
|
-
* Copy the plan's steps onto the execution
|
|
175
|
+
* Copy the plan's steps, machine and title onto the execution, where it does
|
|
176
|
+
* not carry its own.
|
|
166
177
|
*
|
|
167
178
|
* Failure is logged, not thrown: a missing snapshot degrades the protocol to
|
|
168
179
|
* what it was before this existed — readable, just not frozen — while throwing
|
|
169
180
|
* would stop somebody from recording maintenance they actually performed.
|
|
170
181
|
*/
|
|
171
|
-
async function
|
|
182
|
+
async function freezePlanSnapshot(execution) {
|
|
172
183
|
const schedule = execution.get("schedule");
|
|
173
184
|
if (!schedule?.id)
|
|
174
185
|
return;
|
|
186
|
+
const missing = SNAPSHOT_FIELDS.filter((field) => !present(execution.get(field)));
|
|
187
|
+
if (missing.length === 0)
|
|
188
|
+
return;
|
|
175
189
|
try {
|
|
176
190
|
const plan = await new node_1.default.Query(index_js_3.Service_Schedule)
|
|
177
191
|
.equalTo("objectId", schedule.id)
|
|
178
192
|
.first({ useMasterKey: true });
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
193
|
+
if (!plan)
|
|
194
|
+
return;
|
|
195
|
+
for (const field of missing) {
|
|
196
|
+
const value = plan.get(field);
|
|
197
|
+
if (present(value))
|
|
198
|
+
execution.set(field, value);
|
|
182
199
|
}
|
|
183
200
|
}
|
|
184
201
|
catch (error) {
|
|
185
|
-
console.error(`[ServiceScheduleExecution] Could not snapshot
|
|
202
|
+
console.error(`[ServiceScheduleExecution] Could not snapshot plan ${schedule.id}:`, error);
|
|
186
203
|
}
|
|
187
204
|
}
|
|
205
|
+
/** Empty steps or a blank title count as missing — on either side. */
|
|
206
|
+
function present(value) {
|
|
207
|
+
if (value === undefined || value === null)
|
|
208
|
+
return false;
|
|
209
|
+
if (Array.isArray(value))
|
|
210
|
+
return value.length > 0;
|
|
211
|
+
if (typeof value === "string")
|
|
212
|
+
return value.trim().length > 0;
|
|
213
|
+
return true;
|
|
214
|
+
}
|
package/dist/hooks/Tenant.js
CHANGED
|
@@ -5,14 +5,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.init = init;
|
|
7
7
|
const node_1 = __importDefault(require("parse/node"));
|
|
8
|
-
const index_js_1 = require("../features/
|
|
8
|
+
const index_js_1 = require("../features/config/index.js");
|
|
9
|
+
const index_js_2 = require("../features/schema/index.js");
|
|
9
10
|
const openinc_rmq_create_tenant_js_1 = require("../functions/openinc-rmq-create-tenant.js");
|
|
10
|
-
const
|
|
11
|
+
const index_js_3 = require("../types/index.js");
|
|
11
12
|
async function init() {
|
|
12
|
-
(0,
|
|
13
|
+
(0, index_js_2.beforeSaveHook)(index_js_3.Tenant, async (request) => {
|
|
13
14
|
const { object, original, user } = request;
|
|
14
|
-
await (0,
|
|
15
|
-
await (0,
|
|
15
|
+
await (0, index_js_2.defaultHandler)(request);
|
|
16
|
+
await (0, index_js_2.immutableField)(request, "tagPrefix", "opendash:tenant:change-tag-prefix");
|
|
16
17
|
if (object.id) {
|
|
17
18
|
object.setACL(new node_1.default.ACL({
|
|
18
19
|
[`role:od-tenant-user-${object.id}`]: {
|
|
@@ -34,10 +35,10 @@ async function init() {
|
|
|
34
35
|
}
|
|
35
36
|
}
|
|
36
37
|
});
|
|
37
|
-
(0,
|
|
38
|
+
(0, index_js_2.afterSaveHook)(index_js_3.Tenant, async ({ object, original, user }) => {
|
|
38
39
|
// Handle Data Source
|
|
39
40
|
if (object.id && !original?.get("dataSource")) {
|
|
40
|
-
const rootSource = await new node_1.default.Query(
|
|
41
|
+
const rootSource = await new node_1.default.Query(index_js_3.Source)
|
|
41
42
|
.equalTo("tag", "tenant-root-source")
|
|
42
43
|
.first({ useMasterKey: true });
|
|
43
44
|
const sourceACL = new node_1.default.ACL({
|
|
@@ -47,7 +48,7 @@ async function init() {
|
|
|
47
48
|
});
|
|
48
49
|
let dataSource = object.get("dataSource");
|
|
49
50
|
if (!dataSource) {
|
|
50
|
-
dataSource = new
|
|
51
|
+
dataSource = new index_js_3.Source();
|
|
51
52
|
}
|
|
52
53
|
dataSource.setACL(sourceACL);
|
|
53
54
|
if (rootSource) {
|
|
@@ -60,10 +61,10 @@ async function init() {
|
|
|
60
61
|
object.set("dataSource", dataSource);
|
|
61
62
|
await object.save(null, { useMasterKey: true });
|
|
62
63
|
}
|
|
63
|
-
await (0,
|
|
64
|
+
await (0, index_js_2.ensureRole)(`od-tenant-admin-${object.id}`, {
|
|
64
65
|
label: `${object.get("label")} (Admin)`,
|
|
65
66
|
});
|
|
66
|
-
await (0,
|
|
67
|
+
await (0, index_js_2.ensureRole)(`od-tenant-user-${object.id}`, {
|
|
67
68
|
label: object.get("label"),
|
|
68
69
|
acl: new node_1.default.ACL({
|
|
69
70
|
[`role:od-tenant-user-${object.id}`]: {
|
|
@@ -71,6 +72,10 @@ async function init() {
|
|
|
71
72
|
},
|
|
72
73
|
}),
|
|
73
74
|
});
|
|
75
|
+
if (object.id &&
|
|
76
|
+
index_js_1.ConfigInstance.getInstance().getBoolean("TENANT_ACCESS_PERMISSION_ENABLE")) {
|
|
77
|
+
await ensureTenantAccessPermission(object);
|
|
78
|
+
}
|
|
74
79
|
if (!original && object.id && process.env.OPENINC_PARSE_CLOUD_RMQ_HOST) {
|
|
75
80
|
try {
|
|
76
81
|
await (0, openinc_rmq_create_tenant_js_1.createRabbitMQTenant)(object.id);
|
|
@@ -87,4 +92,57 @@ async function init() {
|
|
|
87
92
|
});
|
|
88
93
|
}
|
|
89
94
|
});
|
|
95
|
+
(0, index_js_2.beforeDeleteHook)(index_js_3.Tenant, async ({ object }) => {
|
|
96
|
+
try {
|
|
97
|
+
const permissions = await new node_1.default.Query(ACCESS_PERMISSIONS)
|
|
98
|
+
.equalTo("tenant", object)
|
|
99
|
+
.find({ useMasterKey: true });
|
|
100
|
+
await node_1.default.Object.destroyAll(permissions, { useMasterKey: true });
|
|
101
|
+
}
|
|
102
|
+
catch (error) {
|
|
103
|
+
console.error(`[@openinc/parse-server-opendash][Tenant] Could not delete open.WARE AccessPermissions of tenant ${object.id}:`, error);
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
/** open.WARE class, not an OD3_* class — there is no generated type for it. */
|
|
108
|
+
const ACCESS_PERMISSIONS = "AccessPermissions";
|
|
109
|
+
function escapeRegex(value) {
|
|
110
|
+
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Keeps one open.WARE `AccessPermissions` row per tenant that gives the tenant
|
|
114
|
+
* admin role read/write/delete on every data source whose tag starts with the
|
|
115
|
+
* tenant's tag prefix (`ownerGroup: true`, `owner` is a regex).
|
|
116
|
+
*
|
|
117
|
+
* The row is found again by its `tenant` pointer, so repeated saves update it
|
|
118
|
+
* instead of adding a new one — e.g. when the tag prefix is set after creation.
|
|
119
|
+
* Visible to od-admin (read/write); the tenant admin role reads it, which is
|
|
120
|
+
* what grants the access in open.WARE.
|
|
121
|
+
*/
|
|
122
|
+
async function ensureTenantAccessPermission(tenant) {
|
|
123
|
+
try {
|
|
124
|
+
const prefix = tenant.get("tagPrefix") || `tenant-${tenant.id}-`;
|
|
125
|
+
const permission = (await new node_1.default.Query(ACCESS_PERMISSIONS)
|
|
126
|
+
.equalTo("tenant", tenant)
|
|
127
|
+
.first({ useMasterKey: true })) ?? new node_1.default.Object(ACCESS_PERMISSIONS);
|
|
128
|
+
permission.set("tenant", tenant);
|
|
129
|
+
permission.set("owner", `^${escapeRegex(prefix)}.*`);
|
|
130
|
+
permission.set("ownerGroup", true);
|
|
131
|
+
permission.set("read", ".*");
|
|
132
|
+
permission.set("write", ".*");
|
|
133
|
+
permission.set("delete", ".*");
|
|
134
|
+
permission.setACL(new node_1.default.ACL({
|
|
135
|
+
[`role:od-tenant-admin-${tenant.id}`]: {
|
|
136
|
+
read: true,
|
|
137
|
+
},
|
|
138
|
+
[`role:od-admin`]: {
|
|
139
|
+
read: true,
|
|
140
|
+
write: true,
|
|
141
|
+
},
|
|
142
|
+
}));
|
|
143
|
+
await permission.save(null, { useMasterKey: true });
|
|
144
|
+
}
|
|
145
|
+
catch (error) {
|
|
146
|
+
console.error(`[@openinc/parse-server-opendash][Tenant] open.WARE AccessPermissions for tenant ${tenant.id} were not saved:`, error);
|
|
147
|
+
}
|
|
90
148
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const node_1 = __importDefault(require("parse/node"));
|
|
7
|
+
const index_js_1 = require("../types/index.js");
|
|
8
|
+
/**
|
|
9
|
+
* One-off backfill for `OD3_Service_Schedule_Execution.equipment` and `title`
|
|
10
|
+
* on plan runs.
|
|
11
|
+
*
|
|
12
|
+
* From here on the execution hook copies both from the plan as a run is
|
|
13
|
+
* created (next to the steps), so a protocol stays on the machine and under the
|
|
14
|
+
* name it was performed with. Runs created before that carry neither — except
|
|
15
|
+
* the ones the open.WARE automation or the v1 migration wrote. This fills the
|
|
16
|
+
* gap from the plan as it reads **today**: the best that is known, and the
|
|
17
|
+
* value every view already showed for them.
|
|
18
|
+
*
|
|
19
|
+
* PARSE_URL=… PARSE_APP_ID=… PARSE_MASTER_KEY=… \
|
|
20
|
+
* node dist/scripts/backfill-execution-snapshot.js [--dry-run]
|
|
21
|
+
*
|
|
22
|
+
* Only fills what is missing; an existing value is never overwritten. Direct
|
|
23
|
+
* maintenance (no plan) is skipped — it brings both itself. Completed
|
|
24
|
+
* protocols are written too: the master key passes the hook's "completed is
|
|
25
|
+
* closed" guard, and this adds what the protocol already showed rather than
|
|
26
|
+
* changing it. No changelog entry (`skipChangelog`). Safe to re-run.
|
|
27
|
+
*
|
|
28
|
+
* Steps are deliberately left alone: a run without its own steps predates the
|
|
29
|
+
* snapshot (2026-09-21), and its results may reference steps the plan has
|
|
30
|
+
* since changed — today's steps would be a guess presented as a record.
|
|
31
|
+
*/
|
|
32
|
+
const BATCH_SIZE = 500;
|
|
33
|
+
function requireEnv(name) {
|
|
34
|
+
const value = process.env[name];
|
|
35
|
+
if (!value) {
|
|
36
|
+
console.error(`Missing required environment variable ${name}.`);
|
|
37
|
+
process.exit(1);
|
|
38
|
+
}
|
|
39
|
+
return value;
|
|
40
|
+
}
|
|
41
|
+
/** Iterate the plan runs in `createdAt` order, page by page. */
|
|
42
|
+
async function* pages() {
|
|
43
|
+
let after;
|
|
44
|
+
for (;;) {
|
|
45
|
+
const query = new node_1.default.Query(index_js_1.Service_Schedule_Execution)
|
|
46
|
+
.exists("schedule")
|
|
47
|
+
.select("schedule", "equipment", "title")
|
|
48
|
+
.ascending("createdAt")
|
|
49
|
+
.limit(BATCH_SIZE);
|
|
50
|
+
// `createdAt` is not part of the generic attribute map, hence the cast.
|
|
51
|
+
if (after)
|
|
52
|
+
query.greaterThan("createdAt", after);
|
|
53
|
+
const results = await query.find({ useMasterKey: true });
|
|
54
|
+
if (results.length === 0)
|
|
55
|
+
return;
|
|
56
|
+
yield results;
|
|
57
|
+
after = results[results.length - 1].createdAt;
|
|
58
|
+
if (results.length < BATCH_SIZE)
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
/** The plans of one page — archived ones included (master key). */
|
|
63
|
+
async function plansOf(executions) {
|
|
64
|
+
const ids = [
|
|
65
|
+
...new Set(executions
|
|
66
|
+
.map((e) => e.get("schedule")?.id)
|
|
67
|
+
.filter((id) => !!id)),
|
|
68
|
+
];
|
|
69
|
+
const plans = await new node_1.default.Query(index_js_1.Service_Schedule)
|
|
70
|
+
.containedIn("objectId", ids)
|
|
71
|
+
.select("equipment", "title")
|
|
72
|
+
.limit(ids.length)
|
|
73
|
+
.find({ useMasterKey: true });
|
|
74
|
+
return new Map(plans.map((plan) => [plan.id, plan]));
|
|
75
|
+
}
|
|
76
|
+
async function main() {
|
|
77
|
+
const dryRun = process.argv.includes("--dry-run");
|
|
78
|
+
node_1.default.initialize(requireEnv("PARSE_APP_ID"), undefined, requireEnv("PARSE_MASTER_KEY"));
|
|
79
|
+
node_1.default.serverURL =
|
|
80
|
+
process.env.PARSE_URL ?? "http://localhost:1337/parse";
|
|
81
|
+
let scanned = 0;
|
|
82
|
+
let equipmentSet = 0;
|
|
83
|
+
let titleSet = 0;
|
|
84
|
+
let planMissing = 0;
|
|
85
|
+
for await (const page of pages()) {
|
|
86
|
+
const plans = await plansOf(page);
|
|
87
|
+
for (const execution of page) {
|
|
88
|
+
scanned++;
|
|
89
|
+
const planId = execution.get("schedule")
|
|
90
|
+
?.id;
|
|
91
|
+
const plan = planId ? plans.get(planId) : undefined;
|
|
92
|
+
if (!plan) {
|
|
93
|
+
planMissing++;
|
|
94
|
+
continue;
|
|
95
|
+
}
|
|
96
|
+
let dirty = false;
|
|
97
|
+
if (!execution.get("equipment") && plan.get("equipment")) {
|
|
98
|
+
execution.set("equipment", plan.get("equipment"));
|
|
99
|
+
equipmentSet++;
|
|
100
|
+
dirty = true;
|
|
101
|
+
}
|
|
102
|
+
const title = plan.get("title");
|
|
103
|
+
if (!execution.get("title")?.trim() && title?.trim()) {
|
|
104
|
+
execution.set("title", title);
|
|
105
|
+
titleSet++;
|
|
106
|
+
dirty = true;
|
|
107
|
+
}
|
|
108
|
+
if (!dirty || dryRun)
|
|
109
|
+
continue;
|
|
110
|
+
await execution.save(null, {
|
|
111
|
+
useMasterKey: true,
|
|
112
|
+
context: { skipChangelog: true },
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
console.log(`${dryRun ? "[dry run] " : ""}scanned ${scanned} plan runs, ` +
|
|
117
|
+
`equipment ${dryRun ? "to set" : "set"} on ${equipmentSet}, ` +
|
|
118
|
+
`title ${dryRun ? "to set" : "set"} on ${titleSet}` +
|
|
119
|
+
(planMissing ? `, ${planMissing} with a plan that no longer exists` : ""));
|
|
120
|
+
}
|
|
121
|
+
main().catch((error) => {
|
|
122
|
+
console.error(error);
|
|
123
|
+
process.exit(1);
|
|
124
|
+
});
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openinc/parse-server-opendash",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.41.0",
|
|
4
4
|
"description": "Parse Server Cloud Code for open.INC Stack.",
|
|
5
|
-
"packageManager": "pnpm@12.
|
|
5
|
+
"packageManager": "pnpm@12.21.0",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"parse",
|
|
8
8
|
"opendash"
|
|
@@ -69,32 +69,33 @@
|
|
|
69
69
|
"backfill:meta-contexts": "node dist/scripts/backfill-meta-contexts.js",
|
|
70
70
|
"backfill:changelog-search": "node dist/scripts/backfill-changelog-search.js",
|
|
71
71
|
"backfill:stock-alert": "node dist/scripts/backfill-stock-alert.js",
|
|
72
|
+
"backfill:execution-snapshot": "node dist/scripts/backfill-execution-snapshot.js",
|
|
72
73
|
"repair:ticket-acl": "node dist/scripts/repair-ticket-acl.js",
|
|
73
74
|
"test:integration": "node --test --test-concurrency=1 \"test/integration/**/*.test.mjs\"",
|
|
74
75
|
"test:unit": "node --test \"test/unit/**/*.test.mjs\"",
|
|
75
76
|
"seed:v1": "node dist/scripts/seed-v1-testdata.js"
|
|
76
77
|
},
|
|
77
78
|
"dependencies": {
|
|
78
|
-
"@opendash/openservice-shared": "0.2.0-nightly.
|
|
79
|
+
"@opendash/openservice-shared": "0.2.0-nightly.7",
|
|
79
80
|
"@opendash/ruleset-core": "nightly",
|
|
80
81
|
"@opendash/schedule": "1.2.0-nightly.24",
|
|
81
82
|
"@openinc/parse-server-schema": "^4.1.8",
|
|
82
83
|
"amqplib": "^0.10.9",
|
|
83
84
|
"cron": "^4.4.0",
|
|
84
85
|
"dayjs": "^1.11.23",
|
|
85
|
-
"dotenv": "^18.0.
|
|
86
|
-
"fast-equals": "^6.
|
|
87
|
-
"i18next": "^26.7.
|
|
88
|
-
"i18next-fs-backend": "^2.
|
|
86
|
+
"dotenv": "^18.0.10",
|
|
87
|
+
"fast-equals": "^6.4.0",
|
|
88
|
+
"i18next": "^26.7.2",
|
|
89
|
+
"i18next-fs-backend": "^2.7.0",
|
|
89
90
|
"jsonwebtoken": "^9.0.3",
|
|
90
91
|
"jwks-rsa": "^4.1.0",
|
|
91
|
-
"nodemailer": "^10.
|
|
92
|
+
"nodemailer": "^10.6.0",
|
|
92
93
|
"nunjucks": "^3.2.4",
|
|
93
94
|
"parse": "8.6.2",
|
|
94
95
|
"parse-server": "9.10.7",
|
|
95
96
|
"pdf-img-convert": "2.0.0",
|
|
96
97
|
"rimraf": "^6.1.4",
|
|
97
|
-
"table": "^6.
|
|
98
|
+
"table": "^6.10.1",
|
|
98
99
|
"web-push": "^3.6.7",
|
|
99
100
|
"winston": "^3.19.0"
|
|
100
101
|
},
|
|
@@ -105,8 +106,8 @@
|
|
|
105
106
|
"@types/nunjucks": "^3.2.6",
|
|
106
107
|
"@types/safe-timers": "^1.1.2",
|
|
107
108
|
"@types/web-push": "^3.6.4",
|
|
108
|
-
"concurrently": "^10.0.
|
|
109
|
-
"prettier": "^3.
|
|
109
|
+
"concurrently": "^10.0.7",
|
|
110
|
+
"prettier": "^3.10.1",
|
|
110
111
|
"prettier-plugin-organize-imports": "^4.3.0",
|
|
111
112
|
"ts-node": "^10.9.2",
|
|
112
113
|
"typedoc": "^0.28.20",
|