@openinc/parse-server-opendash 4.7.0 → 4.8.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.
Files changed (33) hide show
  1. package/dist/features/schema/helper/migrationMode.js +2 -0
  2. package/dist/hooks/Service_Schedule.js +7 -0
  3. package/dist/hooks/Service_Schedule_Template.js +5 -0
  4. package/dist/scripts/migration/lib/cadence.d.ts +75 -0
  5. package/dist/scripts/migration/lib/cadence.js +246 -0
  6. package/dist/scripts/migration/lib/env.d.ts +5 -0
  7. package/dist/scripts/migration/lib/env.js +23 -0
  8. package/dist/scripts/migration/lib/schedule.d.ts +306 -0
  9. package/dist/scripts/migration/lib/schedule.js +613 -0
  10. package/dist/scripts/migration/passes/03-equipment.js +11 -4
  11. package/dist/scripts/migration/passes/13-schedule-templates.d.ts +15 -0
  12. package/dist/scripts/migration/passes/13-schedule-templates.js +163 -0
  13. package/dist/scripts/migration/passes/14-schedules.d.ts +30 -0
  14. package/dist/scripts/migration/passes/14-schedules.js +239 -0
  15. package/dist/scripts/migration/passes/15-executions.d.ts +34 -0
  16. package/dist/scripts/migration/passes/15-executions.js +244 -0
  17. package/dist/scripts/migration/passes/16-schedule-meta.d.ts +23 -0
  18. package/dist/scripts/migration/passes/16-schedule-meta.js +308 -0
  19. package/dist/scripts/migration/passes/17-schedule-assets.d.ts +30 -0
  20. package/dist/scripts/migration/passes/17-schedule-assets.js +240 -0
  21. package/dist/scripts/migration/passes/18-calendar-links.d.ts +25 -0
  22. package/dist/scripts/migration/passes/18-calendar-links.js +132 -0
  23. package/dist/scripts/migration/passes/19-schedule-history.d.ts +18 -0
  24. package/dist/scripts/migration/passes/19-schedule-history.js +186 -0
  25. package/dist/scripts/migration/run.js +20 -9
  26. package/dist/scripts/migration/verify.js +294 -11
  27. package/dist/scripts/seed-v1-testdata.d.ts +2 -0
  28. package/dist/scripts/seed-v1-testdata.js +392 -6
  29. package/dist/types/Service_Schedule.d.ts +3 -0
  30. package/dist/types/Service_Schedule.js +6 -0
  31. package/dist/types/Service_Schedule_Execution.d.ts +1 -1
  32. package/package.json +1 -1
  33. package/schema/Service_Schedule.json +4 -0
@@ -38,6 +38,8 @@
38
38
  * - an assignment batch (three rows, one `batchStamp`)
39
39
  * - a message referencing a non-ticket object (orphan skip)
40
40
  * - assets on a real and on a `temp-` media context
41
+ * - maintenance plans, templates and executions in every v1 shape — see
42
+ * `seedSchedules`
41
43
  */
42
44
  var __importDefault = (this && this.__importDefault) || function (mod) {
43
45
  return (mod && mod.__esModule) ? mod : { "default": mod };
@@ -63,16 +65,26 @@ function daysAgo(days, hour = 9) {
63
65
  }
64
66
  /** Marker so `--purge` can find exactly what this seeder created. */
65
67
  const SEED_MARKER = "seed:v1-testdata";
66
- async function create(ctx, className, payload, createdAt, updatedAt) {
68
+ async function create(ctx, className, payload, createdAt, updatedAt,
69
+ /**
70
+ * The ACL to write instead of the default one — `null` for none at all,
71
+ * which is what v1 left on every plan written with the master key.
72
+ */
73
+ acl) {
67
74
  const tenantId = payload.tenant?.objectId;
68
75
  const userId = payload.user?.objectId;
69
76
  const body = {
70
77
  ...payload,
71
- ACL: (0, acl_js_1.migrationAcl)({
72
- tenantId,
73
- userId,
74
- allowTenantUserWrite: true,
75
- }).toJSON(),
78
+ ...(acl === null
79
+ ? {}
80
+ : {
81
+ ACL: acl ??
82
+ (0, acl_js_1.migrationAcl)({
83
+ tenantId,
84
+ userId,
85
+ allowTenantUserWrite: true,
86
+ }).toJSON(),
87
+ }),
76
88
  };
77
89
  const result = await (0, rest_js_1.restCreateRaw)(ctx.config, className, body, createdAt, updatedAt);
78
90
  ctx.created.set(className, (ctx.created.get(className) ?? 0) + 1);
@@ -94,6 +106,22 @@ async function unsetField(config, className, objectId, field) {
94
106
  throw new Error(`unset ${className}.${field} → ${response.status}: ${(await response.text()).slice(0, 200)}`);
95
107
  }
96
108
  }
109
+ /** Update fields of an existing object — after whatever its hooks made of it. */
110
+ async function update(config, className, objectId, body) {
111
+ const response = await fetch(`${config.parseUrl}/classes/${className}/${objectId}`, {
112
+ method: "PUT",
113
+ headers: {
114
+ "X-Parse-Application-Id": config.appId,
115
+ "X-Parse-Maintenance-Key": config.maintenanceKey,
116
+ "X-Parse-Cloud-Context": JSON.stringify({ skipChangelog: true }),
117
+ "Content-Type": "application/json",
118
+ },
119
+ body: JSON.stringify(body),
120
+ });
121
+ if (!response.ok) {
122
+ throw new Error(`update ${className} ${objectId} → ${response.status}: ${(await response.text()).slice(0, 200)}`);
123
+ }
124
+ }
97
125
  // ── the data ───────────────────────────────────────────────────────────────
98
126
  async function seed(ctx) {
99
127
  const { tenantId, tenant2Id, userId, roleId } = ctx;
@@ -453,6 +481,7 @@ async function seed(ctx) {
453
481
  }
454
482
  : {}),
455
483
  }, daysAgo(340));
484
+ await seedSchedules(ctx, { hallId, cncId, untaggedId, itemOel });
456
485
  // ── assets: one real ticket-media context, one abandoned temp context ────
457
486
  await create(ctx, "OD3_Assets", {
458
487
  context: `ticket-media-${t1}`,
@@ -469,8 +498,334 @@ async function seed(ctx) {
469
498
  tenant,
470
499
  }, daysAgo(56, 10));
471
500
  }
501
+ // ── schedules ──────────────────────────────────────────────────────────────
502
+ /**
503
+ * v1 maintenance plans, templates and executions for passes 13–19.
504
+ *
505
+ * v1 wrote these rows in several shapes over two years, and the passes have a
506
+ * branch for each — so each shape appears once:
507
+ *
508
+ * - a plan that inherits interval and steps from its template, overriding
509
+ * only the interval number; the template starts on 31 January (month end)
510
+ * - a template in the pre-2025-07 interval shape (`run_cron`), disabled
511
+ * - a yearly plan starting 29 February, with no ACL at all (as the v1 Outlook
512
+ * import left them), disabled, a sub-day reminder and an Outlook link
513
+ * - a plan with interval number 0 (a single appointment) and an `endDate`
514
+ * stored as a bare ISO string (what v1's "shift" left behind)
515
+ * - steps in all three eras: static admin fields (A), field configs (B), a
516
+ * `Meta_Config` (C); one step shared by a template and two plans
517
+ * - executions: a protocol with material, a comment and era-C values; a
518
+ * `terminated` run; a run v1 rewrote to `completed` although a step is
519
+ * open; an open run with era-B values; a direct maintenance with a skipped
520
+ * step; a pre-2025-08 run naming only template and source
521
+ * - files on every v1 context, and in the old `Maintenance_Media` relations
522
+ */
523
+ async function seedSchedules(ctx, sources) {
524
+ const { tenantId, userId, roleId } = ctx;
525
+ const tenant = ptr("OD3_Tenant", tenantId);
526
+ const user = ptr("_User", userId);
527
+ const P = (cls, id) => ptr(cls, id);
528
+ const relation = (className, ids) => ({
529
+ __op: "AddRelation",
530
+ objects: ids.map((id) => ptr(className, id)),
531
+ });
532
+ const localDate = (y, m, d, h = 8) => new Date(y, m - 1, d, h, 0, 0, 0);
533
+ // What v1's afterSave wrote on a plan or template a user created: the
534
+ // creator reads and writes, od-admin too, tenant users do not read.
535
+ const creatorAcl = {
536
+ [userId]: { read: true, write: true },
537
+ "role:od-admin": { read: true, write: true },
538
+ };
539
+ const roleName = roleId
540
+ ? (await new node_1.default.Query(node_1.default.Role).get(roleId, env_js_1.MK)).getName()
541
+ : undefined;
542
+ const kompressorId = await create(ctx, "OD3_Source", { name: "Kompressor K1", tag: "kompressor-k1", tenant }, daysAgo(380));
543
+ const contactId = await create(ctx, "OD3_Contact", {
544
+ firstname: "Max",
545
+ lastname: "Dienstleister",
546
+ email: "service@example.invalid",
547
+ description: SEED_MARKER,
548
+ tenant,
549
+ }, daysAgo(370));
550
+ // ── files in the old Media store ─────────────────────────────────────────
551
+ const file = (name) => ({
552
+ __type: "File",
553
+ name,
554
+ url: `https://example.invalid/${name}`,
555
+ });
556
+ const stepMediaId = await create(ctx, "OD3_Maintenance_Media", { media: file("anleitung-oelwechsel.txt"), description: "Anleitung Ölwechsel", tenant }, daysAgo(365));
557
+ const executionMediaId = await create(ctx, "OD3_Maintenance_Media", { media: file("foto-altoel.txt"), description: "Foto Altöl", tenant }, daysAgo(90, 11));
558
+ // ── steps, one per era ───────────────────────────────────────────────────
559
+ const drainId = await create(ctx, "OD3_Maintenance_Schedule_Step", {
560
+ title: "Öl ablassen",
561
+ description: "Ablassschraube lösen, Altöl auffangen.",
562
+ order: 1,
563
+ // Era A: a static value an admin set, shown to the technician.
564
+ fields: [
565
+ { value: "Handschuhe, Schutzbrille", metafield: { label: "PSA", allowedValues: [], required: false } },
566
+ ],
567
+ media: relation("OD3_Maintenance_Media", [stepMediaId]),
568
+ tenant,
569
+ }, daysAgo(365));
570
+ const pressureId = await create(ctx, "OD3_Maintenance_Schedule_Step", { title: "Druck messen", order: 2, tenant }, daysAgo(365));
571
+ // Era C: the step's capture fields as a Meta_Config.
572
+ await create(ctx, "OD3_Meta_Config", {
573
+ context: JSON.stringify(["schedule", "step", "meta", pressureId]),
574
+ config: {
575
+ fields: [{ name: "druck", label: "Druck (bar)", type: "number" }],
576
+ description: SEED_MARKER,
577
+ },
578
+ tenant,
579
+ }, daysAgo(200));
580
+ const filterId = await create(ctx, "OD3_Maintenance_Schedule_Step", {
581
+ title: "Filter prüfen",
582
+ order: 1,
583
+ // Era B: a field config, values captured per run into `meta`.
584
+ fields: [
585
+ { name: "zustand", label: "Zustand", type: "select", options: ["gut", "verschlissen"] },
586
+ ],
587
+ tenant,
588
+ }, daysAgo(250));
589
+ const visualId = await create(ctx, "OD3_Maintenance_Schedule_Step", { title: "Sichtprüfung Hallendach", order: 1, tenant }, daysAgo(250));
590
+ // ── templates ────────────────────────────────────────────────────────────
591
+ const templateId = await create(ctx, "OD3_Maintenance_Schedule_Template", {
592
+ title: "Ölwechsel",
593
+ description: "Standard-Ölwechsel für Werkzeugmaschinen",
594
+ color: "#336699",
595
+ enabled: true,
596
+ // Starts on 31 January: v1's dayjs clamps to the month end.
597
+ cron: {
598
+ schedule_type: "timestamp",
599
+ timestamp: { startDate: dateVal(localDate(2025, 1, 31)), number: 1, unit: "months" },
600
+ },
601
+ notifyBeforeDue: { value: 7, unit: "days" },
602
+ steps: relation("OD3_Maintenance_Schedule_Step", [drainId, pressureId]),
603
+ contacts: relation("OD3_Contact", [contactId]),
604
+ sources: relation("OD3_Source", [sources.cncId]),
605
+ tenant,
606
+ }, daysAgo(365), undefined, creatorAcl);
607
+ await create(ctx, "OD3_Maintenance_Schedule_Template", {
608
+ title: "Alte Vorlage (Editor-Format 2024)",
609
+ enabled: false,
610
+ cron: {
611
+ scheduletype: "human",
612
+ run_cron: "0 8 * * 1",
613
+ run_startdate: dateVal(daysAgo(700)),
614
+ is_week: false,
615
+ week_interval: 1,
616
+ is_one_time: false,
617
+ },
618
+ tenant,
619
+ }, daysAgo(700), undefined, creatorAcl);
620
+ // ── plans ────────────────────────────────────────────────────────────────
621
+ // Inherits the template's steps (none of its own) and interval, overriding
622
+ // only the number: every 3 months from 31 January.
623
+ const inheritedId = await create(ctx, "OD3_Maintenance_Schedule", {
624
+ title: "CNC-04 - Ölwechsel",
625
+ description: "Laut Herstellerhandbuch, Kap. 7",
626
+ color: "#ff8800",
627
+ enabled: true,
628
+ template: P("OD3_Maintenance_Schedule_Template", templateId),
629
+ source: P("OD3_Source", sources.cncId),
630
+ cron: { schedule_type: "timestamp", timestamp: { number: 3 } },
631
+ contacts: relation("OD3_Contact", [contactId]),
632
+ tenant,
633
+ }, daysAgo(360), undefined, roleName
634
+ ? { ...creatorAcl, [`role:${roleName}`]: { read: true } }
635
+ : creatorAcl);
636
+ const filterPlanId = await create(ctx, "OD3_Maintenance_Schedule", {
637
+ title: "Presse A - Filter",
638
+ enabled: true,
639
+ source: P("OD3_Source", sources.untaggedId),
640
+ cron: {
641
+ schedule_type: "timestamp",
642
+ timestamp: {
643
+ startDate: dateVal(daysAgo(200)),
644
+ // A bare string, as `shiftScheduleInterval` leaves it.
645
+ endDate: daysAgo(-100).toISOString(),
646
+ number: 2,
647
+ unit: "weeks",
648
+ },
649
+ },
650
+ // What the admin form writes on mount: no reminder.
651
+ notifyBeforeDue: { value: 0, unit: "milliseconds" },
652
+ steps: relation("OD3_Maintenance_Schedule_Step", [filterId]),
653
+ tenant,
654
+ }, daysAgo(210), undefined, creatorAcl);
655
+ // Imported by the v1 Outlook poller: master key, so no ACL was ever saved.
656
+ const importedId = await create(ctx, "OD3_Maintenance_Schedule", {
657
+ title: "Halle B - Jahresprüfung",
658
+ enabled: false,
659
+ source: P("OD3_Source", sources.hallId),
660
+ cron: {
661
+ schedule_type: "timestamp",
662
+ timestamp: { startDate: dateVal(localDate(2024, 2, 29, 9)), number: 1, unit: "years" },
663
+ },
664
+ notifyBeforeDue: { value: 3, unit: "hours" },
665
+ steps: relation("OD3_Maintenance_Schedule_Step", [visualId]),
666
+ tenant,
667
+ }, daysAgo(300), undefined, null);
668
+ // v1's afterSave gives a new plan an ACL and saves it whenever the write
669
+ // was not master — and a maintenance-key write is not. So the plan above
670
+ // got `od-admin` after all. Readable-by-everybody is what the import left in
671
+ // effect; public read is the nearest this seeder can write.
672
+ await update(ctx.config, "OD3_Maintenance_Schedule", importedId, {
673
+ ACL: { "*": { read: true, write: true } },
674
+ });
675
+ await create(ctx, "OD3_Meta_Entry", {
676
+ context: JSON.stringify(["schedule", "sync", "microsoft"]),
677
+ entryClassName: "OD3_Maintenance_Schedule",
678
+ entryObjectId: importedId,
679
+ config: { description: SEED_MARKER },
680
+ values: {
681
+ microsoftCalendarEventId: "seed-outlook-event-1",
682
+ microsoftCalendarChangeKey: "seed-change-key-1",
683
+ },
684
+ tenant,
685
+ }, daysAgo(300));
686
+ // Interval number 0: "only on the start date". Shares a step with the
687
+ // template, on the same machine as the inherited plan.
688
+ await create(ctx, "OD3_Maintenance_Schedule", {
689
+ title: "CNC-04 - Einmalprüfung",
690
+ enabled: true,
691
+ source: P("OD3_Source", sources.cncId),
692
+ cron: {
693
+ schedule_type: "timestamp",
694
+ timestamp: { startDate: dateVal(daysAgo(-20)), number: 0, unit: "days" },
695
+ },
696
+ steps: relation("OD3_Maintenance_Schedule_Step", [drainId]),
697
+ tenant,
698
+ }, daysAgo(40), undefined, creatorAcl);
699
+ // ── executions ───────────────────────────────────────────────────────────
700
+ // Created without their plan, which is set afterwards. v1's afterSave builds
701
+ // a fresh set of execution steps from the plan whenever an execution is
702
+ // *created* with one — on top of the steps seeded here, which would leave
703
+ // every run with a second, all-open set. Real v1 data has one set: the
704
+ // hook's, ticked off by the runner. The hook ignores updates.
705
+ const execution = async (payload, createdAt, updatedAt) => {
706
+ const { schedule, ...rest } = payload;
707
+ const id = await create(ctx, "OD3_Maintenance_Schedule_Execution", { user, tenant, ...rest }, createdAt, updatedAt);
708
+ if (schedule) {
709
+ await update(ctx.config, "OD3_Maintenance_Schedule_Execution", id, {
710
+ schedule,
711
+ });
712
+ }
713
+ return id;
714
+ };
715
+ const executionStep = (executionId, payload, createdAt) => create(ctx, "OD3_Maintenance_Schedule_Execution_Step", {
716
+ scheduleexecution: P("OD3_Maintenance_Schedule_Execution", executionId),
717
+ tenant,
718
+ ...payload,
719
+ }, createdAt);
720
+ const planRef = P("OD3_Maintenance_Schedule", inheritedId);
721
+ const templateRef = P("OD3_Maintenance_Schedule_Template", templateId);
722
+ // A protocol: completed, with material, a comment and era-C values.
723
+ const protocolId = await execution({
724
+ schedule: planRef,
725
+ origin: templateRef,
726
+ source: P("OD3_Source", sources.cncId),
727
+ title: "CNC-04 - Ölwechsel",
728
+ status: "completed",
729
+ finishedAt: dateVal(daysAgo(90, 11)),
730
+ material: [
731
+ { id: sources.itemOel, name: "Spezialöl", quantity: 2, unit: "L" },
732
+ { id: "manual-7", name: "Putzlappen", quantity: 3, unit: "Stk" },
733
+ ],
734
+ media: relation("OD3_Maintenance_Media", [executionMediaId]),
735
+ }, daysAgo(90, 10), daysAgo(90, 11));
736
+ await executionStep(protocolId, {
737
+ step: P("OD3_Maintenance_Schedule_Step", drainId),
738
+ title: "Öl ablassen",
739
+ description: "Ablassschraube lösen, Altöl auffangen.",
740
+ order: 1,
741
+ done: true,
742
+ comment: "Altöl sehr dunkel, Intervall prüfen",
743
+ }, daysAgo(90, 10));
744
+ const measuredId = await executionStep(protocolId, {
745
+ step: P("OD3_Maintenance_Schedule_Step", pressureId),
746
+ title: "Druck messen",
747
+ order: 2,
748
+ done: true,
749
+ comment: "",
750
+ }, daysAgo(90, 10));
751
+ await create(ctx, "OD3_Meta_Entry", {
752
+ context: JSON.stringify(["schedule", "step", "meta", pressureId]),
753
+ entryClassName: "OD3_Maintenance_Schedule_Execution_Step",
754
+ entryObjectId: measuredId,
755
+ values: { druck: 5.5 },
756
+ config: {
757
+ fields: [{ name: "druck", label: "Druck (bar)", type: "number" }],
758
+ description: SEED_MARKER,
759
+ },
760
+ tenant,
761
+ }, daysAgo(90, 11));
762
+ // Closed by a re-run: `terminated` — not a protocol.
763
+ const terminatedId = await execution({
764
+ schedule: planRef,
765
+ title: "CNC-04 - Ölwechsel",
766
+ status: "terminated",
767
+ finishedAt: dateVal(daysAgo(60, 9)),
768
+ }, daysAgo(60, 8));
769
+ await executionStep(terminatedId, { step: P("OD3_Maintenance_Schedule_Step", drainId), title: "Öl ablassen", order: 1, done: false }, daysAgo(60, 8));
770
+ // The same, after a server restart rewrote the status to `completed`.
771
+ const rewrittenId = await execution({
772
+ schedule: planRef,
773
+ title: "CNC-04 - Ölwechsel",
774
+ status: "completed",
775
+ finishedAt: dateVal(daysAgo(30, 9)),
776
+ }, daysAgo(30, 8));
777
+ await executionStep(rewrittenId, { step: P("OD3_Maintenance_Schedule_Step", drainId), title: "Öl ablassen", order: 1, done: true }, daysAgo(30, 8));
778
+ await executionStep(rewrittenId, { step: P("OD3_Maintenance_Schedule_Step", pressureId), title: "Druck messen", order: 2, done: false }, daysAgo(30, 8));
779
+ // An open run, with an era-B value captured so far.
780
+ const openId = await execution({
781
+ schedule: P("OD3_Maintenance_Schedule", filterPlanId),
782
+ title: "Presse A - Filter",
783
+ status: "running",
784
+ }, daysAgo(3, 7));
785
+ await executionStep(openId, {
786
+ step: P("OD3_Maintenance_Schedule_Step", filterId),
787
+ title: "Filter prüfen",
788
+ order: 1,
789
+ done: false,
790
+ meta: [
791
+ { name: "zustand", label: "Zustand", type: "select", options: ["gut", "verschlissen"], value: "verschlissen" },
792
+ ],
793
+ }, daysAgo(3, 7));
794
+ // A direct maintenance ("Direkte Wartung"): no plan, one step skipped.
795
+ const directId = await execution({
796
+ source: P("OD3_Source", kompressorId),
797
+ title: "Sichtprüfung Kompressor",
798
+ description: "Nach Störungsmeldung der Frühschicht",
799
+ status: "completed",
800
+ finishedAt: dateVal(daysAgo(15, 10)),
801
+ }, daysAgo(15, 9));
802
+ await executionStep(directId, { title: "Leckage prüfen", order: 0, done: true }, daysAgo(15, 9));
803
+ await executionStep(directId, { title: "Riemen prüfen", order: 0, done: false }, daysAgo(15, 9));
804
+ // Before 2025-08: template and source, no plan pointer, no step pointer.
805
+ const legacyId = await execution({
806
+ origin: templateRef,
807
+ source: P("OD3_Source", sources.cncId),
808
+ title: "CNC-04 - Ölwechsel",
809
+ status: "completed",
810
+ finishedAt: dateVal(daysAgo(200, 12)),
811
+ }, daysAgo(200, 11));
812
+ await executionStep(legacyId, { title: "Öl ablassen", order: 0, done: true }, daysAgo(200, 11));
813
+ // ── files on the v1 asset contexts ───────────────────────────────────────
814
+ const asset = (context, description, name, at) => create(ctx, "OD3_Assets", { context, description, file: file(name), user, tenant }, at);
815
+ await asset(`schedule-media-${inheritedId}`, "Handbuch CNC-04", "handbuch-cnc04.txt", daysAgo(350));
816
+ await asset(`schedule-step-media-${drainId}`, "Ablassschraube (Foto)", "ablassschraube.txt", daysAgo(340));
817
+ await asset(`schedule-execution-${protocolId}`, "Foto nach Ölwechsel", "nach-oelwechsel.txt", daysAgo(90, 11));
818
+ // On a run that is not migrated: must stay where it is.
819
+ await asset(`schedule-execution-${terminatedId}`, "Foto abgebrochener Lauf", "abgebrochen.txt", daysAgo(60, 9));
820
+ }
472
821
  // ── purge ──────────────────────────────────────────────────────────────────
473
822
  const SEEDED_CLASSES = [
823
+ "OD3_Maintenance_Schedule_Execution_Step",
824
+ "OD3_Maintenance_Schedule_Execution",
825
+ "OD3_Maintenance_Schedule",
826
+ "OD3_Maintenance_Schedule_Template",
827
+ "OD3_Maintenance_Schedule_Step",
828
+ "OD3_Maintenance_Media",
474
829
  "OD3_Maintenance_Ticket_Assignment",
475
830
  "OD3_Maintenance_Ticket_Material",
476
831
  "OD3_Maintenance_Ticket_Kanban_State_Current",
@@ -514,6 +869,37 @@ async function purge() {
514
869
  if (removed)
515
870
  console.log(` purged ${removed.toString().padStart(4)} ${className}`);
516
871
  }
872
+ // Shared classes: only rows carrying the seed marker. Not "everything in a
873
+ // v1 context" — a dev database can hold v1 meta from before the seeder
874
+ // existed, and a reset of test data must not take real data with it.
875
+ const shared = [
876
+ [
877
+ "OD3_Meta_Config (seeded)",
878
+ () => new node_1.default.Query("OD3_Meta_Config").equalTo("config.description", SEED_MARKER),
879
+ ],
880
+ [
881
+ "OD3_Meta_Entry (seeded)",
882
+ () => new node_1.default.Query("OD3_Meta_Entry").equalTo("config.description", SEED_MARKER),
883
+ ],
884
+ [
885
+ "OD3_Contact (seeded)",
886
+ () => new node_1.default.Query("OD3_Contact").equalTo("description", SEED_MARKER),
887
+ ],
888
+ ];
889
+ for (const [label, build] of shared) {
890
+ let removed = 0;
891
+ for (;;) {
892
+ const page = await build().limit(200).find(env_js_1.MK);
893
+ if (page.length === 0)
894
+ break;
895
+ await node_1.default.Object.destroyAll(page, {
896
+ context: { skipChangelog: true },
897
+ });
898
+ removed += page.length;
899
+ }
900
+ if (removed)
901
+ console.log(` purged ${removed.toString().padStart(4)} ${label}`);
902
+ }
517
903
  console.log(`\n (OD3_Source, OD3_Assets, OD3_Tenant and _User left alone — shared with the stack)\n`);
518
904
  }
519
905
  // ── main ───────────────────────────────────────────────────────────────────
@@ -17,6 +17,7 @@ export interface Service_ScheduleAttributes {
17
17
  color?: string | undefined;
18
18
  coversTasks: any[];
19
19
  deletedAt?: Date | undefined;
20
+ description?: string | undefined;
20
21
  equipment?: Service_Equipment | undefined;
21
22
  escalationAfterDays?: number | undefined;
22
23
  escalationRoles: Parse.Relation<Service_Schedule, _Role>;
@@ -51,6 +52,8 @@ export declare class Service_Schedule extends Parse.Object<Service_ScheduleAttri
51
52
  set coversTasks(value: any[]);
52
53
  get deletedAt(): Date | undefined;
53
54
  set deletedAt(value: Date | undefined);
55
+ get description(): string | undefined;
56
+ set description(value: string | undefined);
54
57
  get equipment(): Service_Equipment | undefined;
55
58
  set equipment(value: Service_Equipment | undefined);
56
59
  get escalationAfterDays(): number | undefined;
@@ -58,6 +58,12 @@ class Service_Schedule extends node_1.default.Object {
58
58
  set deletedAt(value) {
59
59
  super.set("deletedAt", value);
60
60
  }
61
+ get description() {
62
+ return super.get("description");
63
+ }
64
+ set description(value) {
65
+ super.set("description", value);
66
+ }
61
67
  get equipment() {
62
68
  return super.get("equipment");
63
69
  }
@@ -1,6 +1,6 @@
1
1
  import Parse from "parse/node";
2
- import type { _User } from "./_User";
3
2
  import type { Service_Equipment } from "./Service_Equipment";
3
+ import type { _User } from "./_User";
4
4
  import type { Service_Schedule } from "./Service_Schedule";
5
5
  import type { Tenant } from "./Tenant";
6
6
  export interface Service_Schedule_ExecutionAttributes {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openinc/parse-server-opendash",
3
- "version": "4.7.0",
3
+ "version": "4.8.0",
4
4
  "description": "Parse Server Cloud Code for open.INC Stack.",
5
5
  "packageManager": "pnpm@11.25.0",
6
6
  "keywords": [
@@ -36,6 +36,10 @@
36
36
  "deletedAt": {
37
37
  "type": "Date"
38
38
  },
39
+ "description": {
40
+ "type": "String",
41
+ "required": false
42
+ },
39
43
  "equipment": {
40
44
  "type": "Pointer",
41
45
  "targetClass": "{{PREFIX}}Service_Equipment"