@openinc/parse-server-opendash 4.8.6 → 4.8.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.
- package/dist/features/openservice/serviceSchedules/calendarSync/ServiceSyncTypes.d.ts +3 -1
- package/dist/features/openservice/serviceSchedules/calendarSync/planToEvent.js +4 -2
- package/dist/scripts/migration/lib/latest.js +16 -2
- package/dist/scripts/migration/lib/pass.d.ts +2 -1
- package/dist/scripts/migration/lib/pass.js +2 -1
- package/dist/scripts/migration/passes/16-schedule-meta.js +4 -0
- package/dist/types/Service_Occurrence.d.ts +3 -0
- package/dist/types/Service_Occurrence.js +6 -0
- package/package.json +1 -1
- package/schema/Service_Occurrence.json +4 -0
|
@@ -45,9 +45,11 @@ export type ServiceCadence = {
|
|
|
45
45
|
/** A notification rule of a plan (`notifications`), as far as the sync needs it. */
|
|
46
46
|
export type ServiceNotificationRule = {
|
|
47
47
|
id: string;
|
|
48
|
-
trigger: "before" | "due";
|
|
48
|
+
trigger: "before" | "due" | "overdue";
|
|
49
49
|
offsetDays?: number;
|
|
50
50
|
assignedRoles?: boolean;
|
|
51
|
+
/** Opt-in (absent = `false`) — see the frontend's `ScheduleNotification`. */
|
|
52
|
+
assignedUsers?: boolean;
|
|
51
53
|
serviceProviders?: boolean;
|
|
52
54
|
userIds?: string[];
|
|
53
55
|
roleIds?: string[];
|
|
@@ -138,8 +138,10 @@ function stepsAsText(steps) {
|
|
|
138
138
|
* "no reminder": `undefined` means the plan warns nobody.
|
|
139
139
|
*/
|
|
140
140
|
function reminderMinutes(notifications) {
|
|
141
|
-
|
|
141
|
+
// An "overdue" rule speaks up after the date — no calendar reminder for it.
|
|
142
|
+
const warnings = (notifications ?? []).filter((rule) => rule.trigger !== "overdue");
|
|
143
|
+
if (!warnings.length)
|
|
142
144
|
return undefined;
|
|
143
|
-
const offsets =
|
|
145
|
+
const offsets = warnings.map((rule) => rule.trigger === "before" ? Math.max(0, rule.offsetDays ?? 0) : 0);
|
|
144
146
|
return Math.max(...offsets) * 24 * 60;
|
|
145
147
|
}
|
|
@@ -97,13 +97,27 @@ async function relationObjects(owner, field, batchSize = 500) {
|
|
|
97
97
|
const out = [];
|
|
98
98
|
let skip = 0;
|
|
99
99
|
for (;;) {
|
|
100
|
-
|
|
100
|
+
// Not `stableOrder`: a relation query sorted by `createdAt` makes Parse
|
|
101
|
+
// page the *join table* instead of the objects
|
|
102
|
+
// (`DatabaseController.relatedIds`), while this loop advances by the
|
|
103
|
+
// objects that came back. A join row whose object is gone — v1 deleted
|
|
104
|
+
// steps and media without unlinking them — then shifts every later page
|
|
105
|
+
// and repeats objects: the first customer run wrote a template with one
|
|
106
|
+
// step twice. `objectId` alone is unique and keeps paging on the objects.
|
|
107
|
+
const page = await relation
|
|
108
|
+
.query()
|
|
109
|
+
.limit(batchSize)
|
|
110
|
+
.skip(skip)
|
|
111
|
+
.ascending("objectId")
|
|
112
|
+
.find(env_js_1.MK);
|
|
101
113
|
if (page.length === 0)
|
|
102
114
|
break;
|
|
103
115
|
out.push(...page);
|
|
104
116
|
skip += page.length;
|
|
105
117
|
}
|
|
106
|
-
|
|
118
|
+
// Insert order for the callers, restored in memory.
|
|
119
|
+
return out.sort((a, b) => (a.createdAt?.getTime() ?? 0) - (b.createdAt?.getTime() ?? 0) ||
|
|
120
|
+
(a.id ?? "").localeCompare(b.id ?? ""));
|
|
107
121
|
}
|
|
108
122
|
/** The objectIds of a relation, read completely. */
|
|
109
123
|
async function relationIds(owner, field, batchSize = 500) {
|
|
@@ -45,7 +45,8 @@ export interface Pass {
|
|
|
45
45
|
* order ties differently on every query. With `skip` paging that returns a row on
|
|
46
46
|
* two pages and silently drops another — the first customer dry run did exactly
|
|
47
47
|
* that: pass 10 "updated" 4 comments with an empty map, i.e. saw 4 twice and
|
|
48
|
-
* missed 4. Every paging loop
|
|
48
|
+
* missed 4. Every paging loop over a class uses the same {@link STABLE_ORDER};
|
|
49
|
+
* relation queries must not — see `relationObjects`.
|
|
49
50
|
*/
|
|
50
51
|
export declare function pages<T extends Parse.Object>(build: () => Parse.Query<T>, batchSize: number): AsyncGenerator<T[]>;
|
|
51
52
|
/** Insert order with a unique tie-breaker — the only safe order to `skip` over. */
|
|
@@ -34,7 +34,8 @@ const env_js_1 = require("./env.js");
|
|
|
34
34
|
* order ties differently on every query. With `skip` paging that returns a row on
|
|
35
35
|
* two pages and silently drops another — the first customer dry run did exactly
|
|
36
36
|
* that: pass 10 "updated" 4 comments with an empty map, i.e. saw 4 twice and
|
|
37
|
-
* missed 4. Every paging loop
|
|
37
|
+
* missed 4. Every paging loop over a class uses the same {@link STABLE_ORDER};
|
|
38
|
+
* relation queries must not — see `relationObjects`.
|
|
38
39
|
*/
|
|
39
40
|
async function* pages(build, batchSize) {
|
|
40
41
|
let skip = 0;
|
|
@@ -218,6 +218,10 @@ exports.pass16 = {
|
|
|
218
218
|
updatedAt: row.updatedAt,
|
|
219
219
|
});
|
|
220
220
|
configIds.set(context, id);
|
|
221
|
+
// A step met twice in one run must update, not create a second config.
|
|
222
|
+
if (!existing) {
|
|
223
|
+
existingConfigs.set(context, new index_js_1.Meta_Config({ objectId: id }));
|
|
224
|
+
}
|
|
221
225
|
existing ? entry.updated++ : entry.created++;
|
|
222
226
|
configsWritten += 1;
|
|
223
227
|
}
|
|
@@ -11,6 +11,7 @@ export interface Service_OccurrenceAttributes {
|
|
|
11
11
|
notifiedAt?: Date | undefined;
|
|
12
12
|
originalDate?: Date | undefined;
|
|
13
13
|
schedule: Service_Schedule;
|
|
14
|
+
status?: string | undefined;
|
|
14
15
|
tenant: Tenant;
|
|
15
16
|
}
|
|
16
17
|
export declare class Service_Occurrence extends Parse.Object<Service_OccurrenceAttributes> {
|
|
@@ -26,6 +27,8 @@ export declare class Service_Occurrence extends Parse.Object<Service_OccurrenceA
|
|
|
26
27
|
set originalDate(value: Date | undefined);
|
|
27
28
|
get schedule(): Service_Schedule;
|
|
28
29
|
set schedule(value: Service_Schedule);
|
|
30
|
+
get status(): string | undefined;
|
|
31
|
+
set status(value: string | undefined);
|
|
29
32
|
get tenant(): Tenant;
|
|
30
33
|
set tenant(value: Tenant);
|
|
31
34
|
}
|
|
@@ -40,6 +40,12 @@ class Service_Occurrence extends node_1.default.Object {
|
|
|
40
40
|
set schedule(value) {
|
|
41
41
|
super.set("schedule", value);
|
|
42
42
|
}
|
|
43
|
+
get status() {
|
|
44
|
+
return super.get("status");
|
|
45
|
+
}
|
|
46
|
+
set status(value) {
|
|
47
|
+
super.set("status", value);
|
|
48
|
+
}
|
|
43
49
|
get tenant() {
|
|
44
50
|
return super.get("tenant");
|
|
45
51
|
}
|
package/package.json
CHANGED