@openinc/parse-server-opendash 4.5.0 → 4.7.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/hooks/Service_Schedule_Execution.js +9 -0
- package/dist/scripts/migration/lib/articleMeta.d.ts +34 -10
- package/dist/scripts/migration/lib/articleMeta.js +58 -11
- package/dist/scripts/migration/lib/equipmentMeta.d.ts +65 -0
- package/dist/scripts/migration/lib/equipmentMeta.js +155 -0
- package/dist/scripts/migration/passes/03-equipment.js +170 -0
- package/dist/scripts/migration/passes/05-articles.d.ts +12 -15
- package/dist/scripts/migration/passes/05-articles.js +83 -33
- package/dist/scripts/migration/verify.js +156 -1
- package/dist/scripts/seed-v1-testdata.js +57 -4
- package/dist/types/Service_Schedule_Execution.d.ts +16 -3
- package/dist/types/Service_Schedule_Execution.js +24 -0
- package/package.json +1 -1
- package/schema/Service_Schedule_Execution.json +19 -1
|
@@ -42,9 +42,18 @@ async function init() {
|
|
|
42
42
|
// Without it a protocol shows whatever the plan says *now*: renaming a step
|
|
43
43
|
// rewrites every protocol that referenced it, deleting one turns its
|
|
44
44
|
// results into numbered orphans (GRENZEN §5).
|
|
45
|
+
//
|
|
46
|
+
// A direct maintenance (no plan) brings its own steps and is left alone.
|
|
45
47
|
if (object.isNew() && !object.get("steps")) {
|
|
46
48
|
await freezeSteps(object);
|
|
47
49
|
}
|
|
50
|
+
// A protocol has to be about something: the plan it performs, or — for a
|
|
51
|
+
// direct maintenance — the machine it was done on. With neither, no view
|
|
52
|
+
// can place it. A data rule like the snapshot above, so it holds for
|
|
53
|
+
// migrations and master-key writes too.
|
|
54
|
+
if (!object.get("schedule") && !object.get("equipment")) {
|
|
55
|
+
throw new node_1.default.Error(node_1.default.Error.VALIDATION_ERROR, "An execution needs a schedule, or an equipment for a direct maintenance.");
|
|
56
|
+
}
|
|
48
57
|
// A migration replays historical protocols; it must not be refused for
|
|
49
58
|
// lacking a capability, and it supplies `performedBy` itself.
|
|
50
59
|
if ((0, index_js_1.isMigrationMode)() || request.master)
|
|
@@ -2,21 +2,29 @@ import { Meta_Entry } from "../../../types/index.js";
|
|
|
2
2
|
import type { MetaFieldConfig } from "../../../types/custom/MetaField.js";
|
|
3
3
|
import type { MigrationConfig } from "./env.js";
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* Article data that has **no column of its own**, kept as plugin-meta.
|
|
6
6
|
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
7
|
+
* **Narrowed on 2026-09-25.** This used to carry v1's whole stock-keeping set,
|
|
8
|
+
* because `OD3_BDE_Article` was a lean catalogue shared with BDE and its ABAS
|
|
9
|
+
* sync and widening it was not ours to do. That changed on 2026-09-18: the class
|
|
10
|
+
* gained `stock`, `minimumStock`, `storageLocation`, `supplier`, `orderNumber`,
|
|
11
|
+
* `price`, `priceCurrency` and `packageSize` as real columns, and both article
|
|
12
|
+
* admin views edit them there.
|
|
13
|
+
*
|
|
14
|
+
* Pass 05 therefore writes those to the columns now, and only what still has no
|
|
15
|
+
* home stays here: v1's `category` — deliberately never given a column, since
|
|
16
|
+
* tags and `type` already classify and a third such field goes stale — v1's
|
|
17
|
+
* `description` (the label column is taken by v1's `name`), and the `Source`
|
|
18
|
+
* links behind `Item.sources`.
|
|
11
19
|
*
|
|
12
20
|
* ⚠️ The ABAS sync still owns the columns it writes and replaces them on every
|
|
13
21
|
* run. It does not touch the stock-keeping ones today — if that changes, they
|
|
14
22
|
* are the collision to watch.
|
|
15
23
|
*
|
|
16
|
-
*
|
|
24
|
+
* What remains lands in a `Meta_Entry` under the same
|
|
17
25
|
* `["service", <entity>, "meta"]` context every other core master-data entity
|
|
18
|
-
* uses (`constants.metaContext`)
|
|
19
|
-
*
|
|
26
|
+
* uses (`constants.metaContext`), editable through the article admin view in
|
|
27
|
+
* `openservice-core` with no extra machinery.
|
|
20
28
|
*
|
|
21
29
|
* **Deliberately not `["bde","article","custom"]`.** That context belongs to the
|
|
22
30
|
* ABAS sync (`node-stack-scheduler`, `syncArticle.ts`), which replaces `config`
|
|
@@ -26,6 +34,15 @@ import type { MigrationConfig } from "./env.js";
|
|
|
26
34
|
* would have its values clobbered on the next sync.
|
|
27
35
|
*/
|
|
28
36
|
export declare const ARTICLE_META_CONTEXT: string[];
|
|
37
|
+
/**
|
|
38
|
+
* Keys this context used to hold that are **now columns** on `OD3_BDE_Article`.
|
|
39
|
+
*
|
|
40
|
+
* Pass 05 strips them from any entry it finds, so an installation migrated
|
|
41
|
+
* before 2026-09-25 heals on the next run instead of showing every value twice —
|
|
42
|
+
* once in the article form, once under *Kopfdaten*. Listed here rather than in
|
|
43
|
+
* the pass because it is a statement about this context's history.
|
|
44
|
+
*/
|
|
45
|
+
export declare const META_KEYS_NOW_COLUMNS: readonly ["price", "stock", "stockAlarmAt", "stockUnit", "storageLocation", "supplier", "orderNumber"];
|
|
29
46
|
/**
|
|
30
47
|
* The field definitions written to the shared `Meta_Config`.
|
|
31
48
|
*
|
|
@@ -33,8 +50,6 @@ export declare const ARTICLE_META_CONTEXT: string[];
|
|
|
33
50
|
* stock, reorder level, storage location, supplier and order number. Leaving
|
|
34
51
|
* them here would have shown every article twice — once as an empty meta field,
|
|
35
52
|
* once as the column that actually holds the value.
|
|
36
|
-
*
|
|
37
|
-
* What remains is what has no column: the category, and the equipment links.
|
|
38
53
|
*/
|
|
39
54
|
export declare const ARTICLE_META_FIELDS: MetaFieldConfig[];
|
|
40
55
|
/**
|
|
@@ -45,6 +60,15 @@ export declare const ARTICLE_META_FIELDS: MetaFieldConfig[];
|
|
|
45
60
|
* later as "the migration ate our prices".
|
|
46
61
|
*/
|
|
47
62
|
export declare function parsePrice(raw: unknown): number | undefined;
|
|
63
|
+
/**
|
|
64
|
+
* The currency of a v1 price string, where it states one.
|
|
65
|
+
*
|
|
66
|
+
* v1 has no currency column — it stored free text like `"12,50 €"`. Returns
|
|
67
|
+
* `undefined` rather than assuming EUR: the instances are German, but stamping a
|
|
68
|
+
* currency onto a bare `"12,50"` would be asserting something the source never
|
|
69
|
+
* said, and `priceCurrency` is nullable precisely so it can stay unknown.
|
|
70
|
+
*/
|
|
71
|
+
export declare function parsePriceCurrency(raw: unknown): string | undefined;
|
|
48
72
|
/**
|
|
49
73
|
* Ensure the shared `Meta_Config` exists for a tenant, returning its id.
|
|
50
74
|
*
|
|
@@ -3,8 +3,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.ARTICLE_META_FIELDS = exports.ARTICLE_META_CONTEXT = void 0;
|
|
6
|
+
exports.ARTICLE_META_FIELDS = exports.META_KEYS_NOW_COLUMNS = exports.ARTICLE_META_CONTEXT = void 0;
|
|
7
7
|
exports.parsePrice = parsePrice;
|
|
8
|
+
exports.parsePriceCurrency = parsePriceCurrency;
|
|
8
9
|
exports.ensureArticleMetaConfig = ensureArticleMetaConfig;
|
|
9
10
|
exports.loadArticleMetaEntries = loadArticleMetaEntries;
|
|
10
11
|
exports.loadArticleMetaConfigs = loadArticleMetaConfigs;
|
|
@@ -14,21 +15,29 @@ const acl_js_1 = require("./acl.js");
|
|
|
14
15
|
const ptr_js_1 = require("./ptr.js");
|
|
15
16
|
const pass_js_1 = require("./pass.js");
|
|
16
17
|
/**
|
|
17
|
-
*
|
|
18
|
+
* Article data that has **no column of its own**, kept as plugin-meta.
|
|
18
19
|
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
20
|
+
* **Narrowed on 2026-09-25.** This used to carry v1's whole stock-keeping set,
|
|
21
|
+
* because `OD3_BDE_Article` was a lean catalogue shared with BDE and its ABAS
|
|
22
|
+
* sync and widening it was not ours to do. That changed on 2026-09-18: the class
|
|
23
|
+
* gained `stock`, `minimumStock`, `storageLocation`, `supplier`, `orderNumber`,
|
|
24
|
+
* `price`, `priceCurrency` and `packageSize` as real columns, and both article
|
|
25
|
+
* admin views edit them there.
|
|
26
|
+
*
|
|
27
|
+
* Pass 05 therefore writes those to the columns now, and only what still has no
|
|
28
|
+
* home stays here: v1's `category` — deliberately never given a column, since
|
|
29
|
+
* tags and `type` already classify and a third such field goes stale — v1's
|
|
30
|
+
* `description` (the label column is taken by v1's `name`), and the `Source`
|
|
31
|
+
* links behind `Item.sources`.
|
|
23
32
|
*
|
|
24
33
|
* ⚠️ The ABAS sync still owns the columns it writes and replaces them on every
|
|
25
34
|
* run. It does not touch the stock-keeping ones today — if that changes, they
|
|
26
35
|
* are the collision to watch.
|
|
27
36
|
*
|
|
28
|
-
*
|
|
37
|
+
* What remains lands in a `Meta_Entry` under the same
|
|
29
38
|
* `["service", <entity>, "meta"]` context every other core master-data entity
|
|
30
|
-
* uses (`constants.metaContext`)
|
|
31
|
-
*
|
|
39
|
+
* uses (`constants.metaContext`), editable through the article admin view in
|
|
40
|
+
* `openservice-core` with no extra machinery.
|
|
32
41
|
*
|
|
33
42
|
* **Deliberately not `["bde","article","custom"]`.** That context belongs to the
|
|
34
43
|
* ABAS sync (`node-stack-scheduler`, `syncArticle.ts`), which replaces `config`
|
|
@@ -38,6 +47,23 @@ const pass_js_1 = require("./pass.js");
|
|
|
38
47
|
* would have its values clobbered on the next sync.
|
|
39
48
|
*/
|
|
40
49
|
exports.ARTICLE_META_CONTEXT = ["service", "article", "meta"];
|
|
50
|
+
/**
|
|
51
|
+
* Keys this context used to hold that are **now columns** on `OD3_BDE_Article`.
|
|
52
|
+
*
|
|
53
|
+
* Pass 05 strips them from any entry it finds, so an installation migrated
|
|
54
|
+
* before 2026-09-25 heals on the next run instead of showing every value twice —
|
|
55
|
+
* once in the article form, once under *Kopfdaten*. Listed here rather than in
|
|
56
|
+
* the pass because it is a statement about this context's history.
|
|
57
|
+
*/
|
|
58
|
+
exports.META_KEYS_NOW_COLUMNS = [
|
|
59
|
+
"price",
|
|
60
|
+
"stock",
|
|
61
|
+
"stockAlarmAt",
|
|
62
|
+
"stockUnit",
|
|
63
|
+
"storageLocation",
|
|
64
|
+
"supplier",
|
|
65
|
+
"orderNumber",
|
|
66
|
+
];
|
|
41
67
|
/**
|
|
42
68
|
* The field definitions written to the shared `Meta_Config`.
|
|
43
69
|
*
|
|
@@ -45,11 +71,10 @@ exports.ARTICLE_META_CONTEXT = ["service", "article", "meta"];
|
|
|
45
71
|
* stock, reorder level, storage location, supplier and order number. Leaving
|
|
46
72
|
* them here would have shown every article twice — once as an empty meta field,
|
|
47
73
|
* once as the column that actually holds the value.
|
|
48
|
-
*
|
|
49
|
-
* What remains is what has no column: the category, and the equipment links.
|
|
50
74
|
*/
|
|
51
75
|
exports.ARTICLE_META_FIELDS = [
|
|
52
76
|
{ type: "string", name: "category", label: "Kategorie" },
|
|
77
|
+
{ type: "string", name: "notes", label: "Beschreibung (v1)" },
|
|
53
78
|
{
|
|
54
79
|
type: "select_parse",
|
|
55
80
|
name: "equipment",
|
|
@@ -78,6 +103,28 @@ function parsePrice(raw) {
|
|
|
78
103
|
const value = Number(cleaned);
|
|
79
104
|
return Number.isFinite(value) ? value : undefined;
|
|
80
105
|
}
|
|
106
|
+
/**
|
|
107
|
+
* The currency of a v1 price string, where it states one.
|
|
108
|
+
*
|
|
109
|
+
* v1 has no currency column — it stored free text like `"12,50 €"`. Returns
|
|
110
|
+
* `undefined` rather than assuming EUR: the instances are German, but stamping a
|
|
111
|
+
* currency onto a bare `"12,50"` would be asserting something the source never
|
|
112
|
+
* said, and `priceCurrency` is nullable precisely so it can stay unknown.
|
|
113
|
+
*/
|
|
114
|
+
function parsePriceCurrency(raw) {
|
|
115
|
+
if (raw === undefined || raw === null)
|
|
116
|
+
return undefined;
|
|
117
|
+
const text = String(raw).toUpperCase();
|
|
118
|
+
if (text.includes("€") || text.includes("EUR"))
|
|
119
|
+
return "EUR";
|
|
120
|
+
if (text.includes("$") || text.includes("USD"))
|
|
121
|
+
return "USD";
|
|
122
|
+
if (text.includes("£") || text.includes("GBP"))
|
|
123
|
+
return "GBP";
|
|
124
|
+
if (text.includes("CHF"))
|
|
125
|
+
return "CHF";
|
|
126
|
+
return undefined;
|
|
127
|
+
}
|
|
81
128
|
/**
|
|
82
129
|
* Ensure the shared `Meta_Config` exists for a tenant, returning its id.
|
|
83
130
|
*
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { Meta_Entry } from "../../../types/index.js";
|
|
2
|
+
import type { MigrationConfig } from "./env.js";
|
|
3
|
+
/**
|
|
4
|
+
* Equipment header data, migrated from `OD3_SourceMeta`.
|
|
5
|
+
*
|
|
6
|
+
* v1 hangs a single `OD3_SourceMeta` off each `OD3_Source` (`Source.meta`) and
|
|
7
|
+
* lets clients put whatever they like in its `data` Object — a flat
|
|
8
|
+
* `{ field: value | value[] }` map with no schema anywhere. v2 has no column for
|
|
9
|
+
* any of it, so it lands in plugin-meta under the context the equipment admin
|
|
10
|
+
* view already reads: `metaContext("equipment")` in `openservice-core`, i.e.
|
|
11
|
+
* `["service","equipment","meta"]`. Nothing new had to be invented — the meta
|
|
12
|
+
* editor is already wired up on that view.
|
|
13
|
+
*
|
|
14
|
+
* **D2 was reversed on 2026-09-25.** The plan originally dropped `SourceMeta`
|
|
15
|
+
* and called surfacing it on Equipment a v2 feature. Clients are using it, so it
|
|
16
|
+
* migrates.
|
|
17
|
+
*
|
|
18
|
+
* The four `SourceMeta` columns that are not `data` — `name`, `description`,
|
|
19
|
+
* `location`, `file` — have no column on Equipment either, so they join the same
|
|
20
|
+
* entry. A `data` key of the same name wins, and the column value moves aside
|
|
21
|
+
* (see {@link reservedFallback}) rather than being overwritten.
|
|
22
|
+
*/
|
|
23
|
+
export declare const EQUIPMENT_META_CONTEXT: string[];
|
|
24
|
+
/** A plugin-meta field config, as inferred from a v1 value. */
|
|
25
|
+
export interface InferredMetaField {
|
|
26
|
+
name: string;
|
|
27
|
+
label: string;
|
|
28
|
+
type: "string" | "number" | "boolean";
|
|
29
|
+
multiple?: boolean;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Infer a field config from a value, because v1 has no definitions to convert.
|
|
33
|
+
*
|
|
34
|
+
* Unlike ticket meta (pass 07), which migrates real v1 field definitions,
|
|
35
|
+
* `SourceMeta.data` is raw key/value with no schema. The type is therefore read
|
|
36
|
+
* off the value itself; an array becomes the scalar type plus `multiple`, which
|
|
37
|
+
* is what `getSourceMetaMap` already assumed v1 values could be.
|
|
38
|
+
*/
|
|
39
|
+
export declare function inferMetaField(name: string, value: unknown): InferredMetaField | undefined;
|
|
40
|
+
/**
|
|
41
|
+
* Storable form of a v1 value.
|
|
42
|
+
*
|
|
43
|
+
* Plugin-meta has no geo or file field type, so a `GeoPoint` becomes
|
|
44
|
+
* `"lat,lng"` and a `File` becomes its URL. Both are reported by the pass rather
|
|
45
|
+
* than dropped — a string keeps the value readable and recoverable, which is the
|
|
46
|
+
* point.
|
|
47
|
+
*/
|
|
48
|
+
export declare function metaValue(value: unknown): unknown;
|
|
49
|
+
/** Where a `SourceMeta` column goes when `data` already claimed its name. */
|
|
50
|
+
export declare function reservedFallback(name: string): string;
|
|
51
|
+
/**
|
|
52
|
+
* Ensure the shared `Meta_Config` for a tenant, returning its id.
|
|
53
|
+
*
|
|
54
|
+
* Tenant-scoped for the same reason as the article config: the migration reads
|
|
55
|
+
* with the maintenance key, which bypasses ACL, so an unscoped `.first()` would
|
|
56
|
+
* find another tenant's config and overwrite it.
|
|
57
|
+
*
|
|
58
|
+
* Fields are merged into whatever the config already has rather than replacing
|
|
59
|
+
* it, so a config a human has already extended by hand survives a re-run.
|
|
60
|
+
*/
|
|
61
|
+
export declare function ensureEquipmentMetaConfig(config: MigrationConfig, tenantId: string, fields: InferredMetaField[]): Promise<string | undefined>;
|
|
62
|
+
/** Existing equipment meta entries, keyed by the equipment they belong to. */
|
|
63
|
+
export declare function loadEquipmentMetaEntries(config: MigrationConfig): Promise<Map<string, Meta_Entry>>;
|
|
64
|
+
/** The `Meta_Config` ids already present for this context, keyed by tenant. */
|
|
65
|
+
export declare function loadEquipmentMetaConfigs(config: MigrationConfig): Promise<Map<string, string>>;
|
|
@@ -0,0 +1,155 @@
|
|
|
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
|
+
exports.EQUIPMENT_META_CONTEXT = void 0;
|
|
7
|
+
exports.inferMetaField = inferMetaField;
|
|
8
|
+
exports.metaValue = metaValue;
|
|
9
|
+
exports.reservedFallback = reservedFallback;
|
|
10
|
+
exports.ensureEquipmentMetaConfig = ensureEquipmentMetaConfig;
|
|
11
|
+
exports.loadEquipmentMetaEntries = loadEquipmentMetaEntries;
|
|
12
|
+
exports.loadEquipmentMetaConfigs = loadEquipmentMetaConfigs;
|
|
13
|
+
const node_1 = __importDefault(require("parse/node"));
|
|
14
|
+
const index_js_1 = require("../../../types/index.js");
|
|
15
|
+
const acl_js_1 = require("./acl.js");
|
|
16
|
+
const ptr_js_1 = require("./ptr.js");
|
|
17
|
+
const pass_js_1 = require("./pass.js");
|
|
18
|
+
/**
|
|
19
|
+
* Equipment header data, migrated from `OD3_SourceMeta`.
|
|
20
|
+
*
|
|
21
|
+
* v1 hangs a single `OD3_SourceMeta` off each `OD3_Source` (`Source.meta`) and
|
|
22
|
+
* lets clients put whatever they like in its `data` Object — a flat
|
|
23
|
+
* `{ field: value | value[] }` map with no schema anywhere. v2 has no column for
|
|
24
|
+
* any of it, so it lands in plugin-meta under the context the equipment admin
|
|
25
|
+
* view already reads: `metaContext("equipment")` in `openservice-core`, i.e.
|
|
26
|
+
* `["service","equipment","meta"]`. Nothing new had to be invented — the meta
|
|
27
|
+
* editor is already wired up on that view.
|
|
28
|
+
*
|
|
29
|
+
* **D2 was reversed on 2026-09-25.** The plan originally dropped `SourceMeta`
|
|
30
|
+
* and called surfacing it on Equipment a v2 feature. Clients are using it, so it
|
|
31
|
+
* migrates.
|
|
32
|
+
*
|
|
33
|
+
* The four `SourceMeta` columns that are not `data` — `name`, `description`,
|
|
34
|
+
* `location`, `file` — have no column on Equipment either, so they join the same
|
|
35
|
+
* entry. A `data` key of the same name wins, and the column value moves aside
|
|
36
|
+
* (see {@link reservedFallback}) rather than being overwritten.
|
|
37
|
+
*/
|
|
38
|
+
exports.EQUIPMENT_META_CONTEXT = ["service", "equipment", "meta"];
|
|
39
|
+
function scalarType(value) {
|
|
40
|
+
if (typeof value === "number")
|
|
41
|
+
return "number";
|
|
42
|
+
if (typeof value === "boolean")
|
|
43
|
+
return "boolean";
|
|
44
|
+
return "string";
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Infer a field config from a value, because v1 has no definitions to convert.
|
|
48
|
+
*
|
|
49
|
+
* Unlike ticket meta (pass 07), which migrates real v1 field definitions,
|
|
50
|
+
* `SourceMeta.data` is raw key/value with no schema. The type is therefore read
|
|
51
|
+
* off the value itself; an array becomes the scalar type plus `multiple`, which
|
|
52
|
+
* is what `getSourceMetaMap` already assumed v1 values could be.
|
|
53
|
+
*/
|
|
54
|
+
function inferMetaField(name, value) {
|
|
55
|
+
if (value === undefined || value === null)
|
|
56
|
+
return undefined;
|
|
57
|
+
if (Array.isArray(value)) {
|
|
58
|
+
const first = value.find((v) => v !== undefined && v !== null && !Array.isArray(v));
|
|
59
|
+
return { name, label: name, type: scalarType(first), multiple: true };
|
|
60
|
+
}
|
|
61
|
+
return { name, label: name, type: scalarType(value) };
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Storable form of a v1 value.
|
|
65
|
+
*
|
|
66
|
+
* Plugin-meta has no geo or file field type, so a `GeoPoint` becomes
|
|
67
|
+
* `"lat,lng"` and a `File` becomes its URL. Both are reported by the pass rather
|
|
68
|
+
* than dropped — a string keeps the value readable and recoverable, which is the
|
|
69
|
+
* point.
|
|
70
|
+
*/
|
|
71
|
+
function metaValue(value) {
|
|
72
|
+
if (value === undefined || value === null)
|
|
73
|
+
return undefined;
|
|
74
|
+
if (value instanceof node_1.default.GeoPoint) {
|
|
75
|
+
return `${value.latitude},${value.longitude}`;
|
|
76
|
+
}
|
|
77
|
+
if (value instanceof node_1.default.File)
|
|
78
|
+
return value.url();
|
|
79
|
+
if (Array.isArray(value)) {
|
|
80
|
+
const mapped = value.map((v) => metaValue(v)).filter((v) => v !== undefined);
|
|
81
|
+
return mapped.length ? mapped : undefined;
|
|
82
|
+
}
|
|
83
|
+
return value;
|
|
84
|
+
}
|
|
85
|
+
/** Where a `SourceMeta` column goes when `data` already claimed its name. */
|
|
86
|
+
function reservedFallback(name) {
|
|
87
|
+
return `sourceMeta${name.charAt(0).toUpperCase()}${name.slice(1)}`;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Ensure the shared `Meta_Config` for a tenant, returning its id.
|
|
91
|
+
*
|
|
92
|
+
* Tenant-scoped for the same reason as the article config: the migration reads
|
|
93
|
+
* with the maintenance key, which bypasses ACL, so an unscoped `.first()` would
|
|
94
|
+
* find another tenant's config and overwrite it.
|
|
95
|
+
*
|
|
96
|
+
* Fields are merged into whatever the config already has rather than replacing
|
|
97
|
+
* it, so a config a human has already extended by hand survives a re-run.
|
|
98
|
+
*/
|
|
99
|
+
async function ensureEquipmentMetaConfig(config, tenantId, fields) {
|
|
100
|
+
const contextString = (0, ptr_js_1.contextToString)(exports.EQUIPMENT_META_CONTEXT);
|
|
101
|
+
const query = new node_1.default.Query(index_js_1.Meta_Config).equalTo("context", contextString);
|
|
102
|
+
if (tenantId)
|
|
103
|
+
query.equalTo("tenant", (0, ptr_js_1.tenantPtr)(tenantId));
|
|
104
|
+
else
|
|
105
|
+
query.doesNotExist("tenant");
|
|
106
|
+
const existing = await query.first({});
|
|
107
|
+
const target = existing ?? new index_js_1.Meta_Config();
|
|
108
|
+
const current = existing?.get("config")
|
|
109
|
+
?.fields;
|
|
110
|
+
const merged = [...(current ?? [])];
|
|
111
|
+
for (const field of fields) {
|
|
112
|
+
if (!merged.some((f) => f.name === field.name))
|
|
113
|
+
merged.push(field);
|
|
114
|
+
}
|
|
115
|
+
target.set("context", contextString);
|
|
116
|
+
target.set("config", { fields: merged });
|
|
117
|
+
if (tenantId)
|
|
118
|
+
target.set("tenant", (0, ptr_js_1.tenantPtr)(tenantId));
|
|
119
|
+
if (!existing)
|
|
120
|
+
target.setACL((0, acl_js_1.migrationAcl)({ tenantId }));
|
|
121
|
+
if (config.dryRun)
|
|
122
|
+
return existing?.id;
|
|
123
|
+
// No historical timestamp: the config is a v2 artefact the migration
|
|
124
|
+
// synthesises, not a migrated row.
|
|
125
|
+
await (0, acl_js_1.saveMigrated)(config, target, {
|
|
126
|
+
className: index_js_1.Meta_Config.className,
|
|
127
|
+
isNew: !existing,
|
|
128
|
+
});
|
|
129
|
+
return target.id;
|
|
130
|
+
}
|
|
131
|
+
/** Existing equipment meta entries, keyed by the equipment they belong to. */
|
|
132
|
+
async function loadEquipmentMetaEntries(config) {
|
|
133
|
+
const byEquipment = new Map();
|
|
134
|
+
const contextString = (0, ptr_js_1.contextToString)(exports.EQUIPMENT_META_CONTEXT);
|
|
135
|
+
for await (const page of (0, pass_js_1.pages)(() => new node_1.default.Query(index_js_1.Meta_Entry)
|
|
136
|
+
.equalTo("context", contextString)
|
|
137
|
+
.equalTo("entryClassName", index_js_1.Service_Equipment.className), config.batchSize)) {
|
|
138
|
+
for (const row of page) {
|
|
139
|
+
const objectId = row.get("entryObjectId");
|
|
140
|
+
if (objectId)
|
|
141
|
+
byEquipment.set(objectId, row);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
return byEquipment;
|
|
145
|
+
}
|
|
146
|
+
/** The `Meta_Config` ids already present for this context, keyed by tenant. */
|
|
147
|
+
async function loadEquipmentMetaConfigs(config) {
|
|
148
|
+
const byTenant = new Map();
|
|
149
|
+
const contextString = (0, ptr_js_1.contextToString)(exports.EQUIPMENT_META_CONTEXT);
|
|
150
|
+
for (const row of await (0, pass_js_1.all)(() => new node_1.default.Query(index_js_1.Meta_Config).equalTo("context", contextString), config.batchSize)) {
|
|
151
|
+
if (row.id)
|
|
152
|
+
byTenant.set((0, pass_js_1.refId)(row.get("tenant")) ?? "", row.id);
|
|
153
|
+
}
|
|
154
|
+
return byTenant;
|
|
155
|
+
}
|
|
@@ -7,6 +7,7 @@ exports.pass03 = void 0;
|
|
|
7
7
|
const node_1 = __importDefault(require("parse/node"));
|
|
8
8
|
const index_js_1 = require("../../../types/index.js");
|
|
9
9
|
const acl_js_1 = require("../lib/acl.js");
|
|
10
|
+
const equipmentMeta_js_1 = require("../lib/equipmentMeta.js");
|
|
10
11
|
const map_js_1 = require("../lib/map.js");
|
|
11
12
|
const latest_js_1 = require("../lib/latest.js");
|
|
12
13
|
const ptr_js_1 = require("../lib/ptr.js");
|
|
@@ -45,6 +46,169 @@ async function referencedSourceIds(ctx) {
|
|
|
45
46
|
}
|
|
46
47
|
return ids;
|
|
47
48
|
}
|
|
49
|
+
/** `SourceMeta` columns that are not `data` and have no Equipment column either. */
|
|
50
|
+
const RESERVED_COLUMNS = ["name", "description", "location", "file"];
|
|
51
|
+
/**
|
|
52
|
+
* `OD3_SourceMeta` → equipment header data under
|
|
53
|
+
* `["service","equipment","meta"]`.
|
|
54
|
+
*
|
|
55
|
+
* Runs inside pass 03 for the same reason pass 05 writes article meta: the
|
|
56
|
+
* equipment ids are already in hand here, and a separate pass would only have to
|
|
57
|
+
* re-derive them.
|
|
58
|
+
*
|
|
59
|
+
* Only sources that actually became Equipment are covered — meta on a source D3
|
|
60
|
+
* left behind has nothing to hang off, and is counted rather than dropped
|
|
61
|
+
* silently.
|
|
62
|
+
*/
|
|
63
|
+
async function migrateSourceMeta(ctx, allSources, equipmentBySource) {
|
|
64
|
+
const { config, report, entry } = ctx;
|
|
65
|
+
const metaIdBySource = new Map();
|
|
66
|
+
let orphaned = 0;
|
|
67
|
+
for (const source of allSources) {
|
|
68
|
+
const metaId = (0, pass_js_1.refId)(source.get("meta"));
|
|
69
|
+
if (!source.id || !metaId)
|
|
70
|
+
continue;
|
|
71
|
+
if (equipmentBySource.has(source.id))
|
|
72
|
+
metaIdBySource.set(source.id, metaId);
|
|
73
|
+
else
|
|
74
|
+
orphaned += 1;
|
|
75
|
+
}
|
|
76
|
+
if (orphaned > 0) {
|
|
77
|
+
report.info(entry, `${orphaned} source meta record(s) belong to sources that did not become ` +
|
|
78
|
+
`Equipment (D3: referenced sources only) — left on the Source`);
|
|
79
|
+
}
|
|
80
|
+
if (metaIdBySource.size === 0)
|
|
81
|
+
return;
|
|
82
|
+
// Load the SourceMeta rows in id batches; Parse caps containedIn well above
|
|
83
|
+
// this, but the sources on one instance are few enough that 100 is plenty.
|
|
84
|
+
const metaById = new Map();
|
|
85
|
+
const metaIds = [...new Set(metaIdBySource.values())];
|
|
86
|
+
for (let i = 0; i < metaIds.length; i += 100) {
|
|
87
|
+
const slice = metaIds.slice(i, i + 100);
|
|
88
|
+
const rows = await (0, pass_js_1.all)(() => new node_1.default.Query(index_js_1.SourceMeta).containedIn("objectId", slice), config.batchSize);
|
|
89
|
+
for (const row of rows)
|
|
90
|
+
if (row.id)
|
|
91
|
+
metaById.set(row.id, row);
|
|
92
|
+
}
|
|
93
|
+
const contextString = (0, ptr_js_1.contextToString)(equipmentMeta_js_1.EQUIPMENT_META_CONTEXT);
|
|
94
|
+
const existingEntries = config.dryRun
|
|
95
|
+
? new Map()
|
|
96
|
+
: await (0, equipmentMeta_js_1.loadEquipmentMetaEntries)(config);
|
|
97
|
+
const fieldsByTenant = new Map();
|
|
98
|
+
const valuesByEquipment = new Map();
|
|
99
|
+
const conflicts = [];
|
|
100
|
+
let converted = 0;
|
|
101
|
+
for (const source of allSources) {
|
|
102
|
+
const sourceId = source.id;
|
|
103
|
+
if (!sourceId)
|
|
104
|
+
continue;
|
|
105
|
+
const metaId = metaIdBySource.get(sourceId);
|
|
106
|
+
const equipmentId = equipmentBySource.get(sourceId);
|
|
107
|
+
if (!metaId || !equipmentId)
|
|
108
|
+
continue;
|
|
109
|
+
const meta = metaById.get(metaId);
|
|
110
|
+
if (!meta)
|
|
111
|
+
continue;
|
|
112
|
+
const tenantId = (0, pass_js_1.refId)(source.get("tenant")) ?? "";
|
|
113
|
+
const fields = fieldsByTenant.get(tenantId) ?? new Map();
|
|
114
|
+
fieldsByTenant.set(tenantId, fields);
|
|
115
|
+
const values = {};
|
|
116
|
+
const remember = (name, raw) => {
|
|
117
|
+
const inferred = (0, equipmentMeta_js_1.inferMetaField)(name, raw);
|
|
118
|
+
if (!inferred)
|
|
119
|
+
return;
|
|
120
|
+
const seen = fields.get(name);
|
|
121
|
+
if (!seen)
|
|
122
|
+
fields.set(name, inferred);
|
|
123
|
+
else if (seen.type !== inferred.type ||
|
|
124
|
+
Boolean(seen.multiple) !== Boolean(inferred.multiple)) {
|
|
125
|
+
conflicts.push(`"${name}" is ${seen.type}${seen.multiple ? "[]" : ""} on one source ` +
|
|
126
|
+
`and ${inferred.type}${inferred.multiple ? "[]" : ""} on ${sourceId}`);
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
// `data` is the client-authored map and wins on name collisions.
|
|
130
|
+
const data = (meta.get("data") ?? {});
|
|
131
|
+
for (const [key, raw] of Object.entries(data)) {
|
|
132
|
+
const name = key.trim();
|
|
133
|
+
if (!name)
|
|
134
|
+
continue;
|
|
135
|
+
const stored = (0, equipmentMeta_js_1.metaValue)(raw);
|
|
136
|
+
if (stored === undefined)
|
|
137
|
+
continue;
|
|
138
|
+
values[name] = stored;
|
|
139
|
+
remember(name, raw);
|
|
140
|
+
}
|
|
141
|
+
for (const column of RESERVED_COLUMNS) {
|
|
142
|
+
const raw = meta.get(column);
|
|
143
|
+
const stored = (0, equipmentMeta_js_1.metaValue)(raw);
|
|
144
|
+
if (stored === undefined)
|
|
145
|
+
continue;
|
|
146
|
+
const taken = Object.prototype.hasOwnProperty.call(values, column);
|
|
147
|
+
const name = taken ? (0, equipmentMeta_js_1.reservedFallback)(column) : column;
|
|
148
|
+
if (taken) {
|
|
149
|
+
report.warn(entry, `source ${sourceId}: meta data already defines "${column}", so the ` +
|
|
150
|
+
`SourceMeta column moved to "${name}" rather than overwriting it`);
|
|
151
|
+
}
|
|
152
|
+
if (column === "location" || column === "file")
|
|
153
|
+
converted += 1;
|
|
154
|
+
values[name] = stored;
|
|
155
|
+
remember(name, raw);
|
|
156
|
+
}
|
|
157
|
+
if (Object.keys(values).length === 0)
|
|
158
|
+
continue;
|
|
159
|
+
valuesByEquipment.set(equipmentId, { tenantId, values, source });
|
|
160
|
+
}
|
|
161
|
+
if (converted > 0) {
|
|
162
|
+
report.info(entry, `${converted} location/file value(s) stored as text — plugin-meta has no ` +
|
|
163
|
+
`geo or file field type, so a GeoPoint becomes "lat,lng" and a File its URL`);
|
|
164
|
+
}
|
|
165
|
+
for (const conflict of conflicts) {
|
|
166
|
+
report.warn(entry, `equipment meta field type conflict: ${conflict} — first wins`);
|
|
167
|
+
}
|
|
168
|
+
if (config.dryRun) {
|
|
169
|
+
report.info(entry, `${valuesByEquipment.size} equipment would carry header data from ` +
|
|
170
|
+
`OD3_SourceMeta under ["service","equipment","meta"]`);
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
// Config before entries: an entry whose fields are undeclared renders blank.
|
|
174
|
+
const configByTenant = new Map();
|
|
175
|
+
for (const [tenantId, fields] of fieldsByTenant) {
|
|
176
|
+
configByTenant.set(tenantId, await (0, equipmentMeta_js_1.ensureEquipmentMetaConfig)(config, tenantId, [...fields.values()]));
|
|
177
|
+
}
|
|
178
|
+
let written = 0;
|
|
179
|
+
for (const [equipmentId, { tenantId, values, source }] of valuesByEquipment) {
|
|
180
|
+
try {
|
|
181
|
+
const existing = existingEntries.get(equipmentId);
|
|
182
|
+
const target = existing ?? new index_js_1.Meta_Entry();
|
|
183
|
+
target.set("context", contextString);
|
|
184
|
+
target.set("entryClassName", index_js_1.Service_Equipment.className);
|
|
185
|
+
target.set("entryObjectId", equipmentId);
|
|
186
|
+
target.set("values", values);
|
|
187
|
+
const originPtr = (0, ptr_js_1.maybePtr)("OD3_Meta_Config", configByTenant.get(tenantId));
|
|
188
|
+
if (originPtr)
|
|
189
|
+
target.set("origin", originPtr);
|
|
190
|
+
if (tenantId)
|
|
191
|
+
target.set("tenant", (0, ptr_js_1.tenantPtr)(tenantId));
|
|
192
|
+
if (!existing) {
|
|
193
|
+
target.setACL((0, acl_js_1.migrationAcl)({ tenantId, allowTenantUserWrite: true }));
|
|
194
|
+
}
|
|
195
|
+
await (0, acl_js_1.saveMigrated)(config, target, {
|
|
196
|
+
className: index_js_1.Meta_Entry.className,
|
|
197
|
+
isNew: !existing,
|
|
198
|
+
createdAt: source.createdAt,
|
|
199
|
+
updatedAt: source.updatedAt,
|
|
200
|
+
});
|
|
201
|
+
written += 1;
|
|
202
|
+
}
|
|
203
|
+
catch (error) {
|
|
204
|
+
report.error(entry, `equipment ${equipmentId} meta failed: ${error.message}`);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
if (written > 0) {
|
|
208
|
+
report.info(entry, `${written} equipment carry header data from OD3_SourceMeta under ` +
|
|
209
|
+
`["service","equipment","meta"] — editable in the equipment admin view`);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
48
212
|
/**
|
|
49
213
|
* Pass 03 — `OD3_Source` → `OD3_Service_Equipment`.
|
|
50
214
|
*
|
|
@@ -109,6 +273,8 @@ exports.pass03 = {
|
|
|
109
273
|
const ordered = [...needed]
|
|
110
274
|
.map((id) => byId.get(id))
|
|
111
275
|
.sort((a, b) => depth(a.id) - depth(b.id));
|
|
276
|
+
// sourceId -> equipment id, for the SourceMeta step below.
|
|
277
|
+
const equipmentBySource = new Map();
|
|
112
278
|
for (const source of ordered) {
|
|
113
279
|
const sourceId = source.id;
|
|
114
280
|
if (!sourceId)
|
|
@@ -147,6 +313,7 @@ exports.pass03 = {
|
|
|
147
313
|
}
|
|
148
314
|
if (config.dryRun) {
|
|
149
315
|
existingId ? entry.updated++ : entry.created++;
|
|
316
|
+
equipmentBySource.set(sourceId, existingId ?? map_js_1.MigrationMap.dryId(sourceId));
|
|
150
317
|
if (!existingId) {
|
|
151
318
|
await map.record(index_js_1.Source.className, sourceId, index_js_1.Service_Equipment.className, map_js_1.MigrationMap.dryId(sourceId));
|
|
152
319
|
}
|
|
@@ -159,6 +326,7 @@ exports.pass03 = {
|
|
|
159
326
|
createdAt: source.createdAt,
|
|
160
327
|
updatedAt: source.updatedAt,
|
|
161
328
|
});
|
|
329
|
+
equipmentBySource.set(sourceId, newId);
|
|
162
330
|
if (existingId) {
|
|
163
331
|
entry.updated++;
|
|
164
332
|
}
|
|
@@ -172,5 +340,7 @@ exports.pass03 = {
|
|
|
172
340
|
continue;
|
|
173
341
|
}
|
|
174
342
|
}
|
|
343
|
+
// Header data last: it needs the equipment ids this loop just handed out.
|
|
344
|
+
await migrateSourceMeta(ctx, allSources, equipmentBySource);
|
|
175
345
|
},
|
|
176
346
|
};
|
|
@@ -6,24 +6,21 @@ import { type Pass } from "../lib/pass.js";
|
|
|
6
6
|
* retired and material now references the shared article catalogue instead, so
|
|
7
7
|
* the same v1 rows land in `OD3_BDE_Article` with `type: "spare_part"`.
|
|
8
8
|
*
|
|
9
|
-
* **Stock keeping
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
9
|
+
* **Stock keeping goes to columns since 2026-09-25.** `OD3_BDE_Article` gained
|
|
10
|
+
* `stock`, `minimumStock`, `storageLocation`, `supplier`, `orderNumber`,
|
|
11
|
+
* `price`, `priceCurrency` and `packageSize` on 2026-09-18, so the values this
|
|
12
|
+
* pass used to park in plugin-meta are written to the class itself. An entry
|
|
13
|
+
* left from an earlier run has those keys stripped and is removed when nothing
|
|
14
|
+
* else remains — otherwise every value would show twice, once in the article
|
|
15
|
+
* form and once under *Kopfdaten*.
|
|
15
16
|
*
|
|
16
|
-
* What still
|
|
17
|
-
*
|
|
18
|
-
*
|
|
17
|
+
* **What still has no column stays meta** under `["service","article","meta"]`:
|
|
18
|
+
* v1's `category` — deliberately never given a column, since tags and `type`
|
|
19
|
+
* already classify and a third such field goes stale — v1's `description`, for
|
|
20
|
+
* which the label column is taken by v1's `name`, and the equipment links behind
|
|
21
|
+
* `Item.sources`. Nothing is dropped. See `lib/articleMeta.ts` for why that
|
|
19
22
|
* context and not the ABAS one.
|
|
20
23
|
*
|
|
21
|
-
* ⚠️ **Installations migrated before this change keep their values in meta.**
|
|
22
|
-
* There is no repair pass: few installations track material at all, so
|
|
23
|
-
* re-entering the handful of articles was judged cheaper than a script running
|
|
24
|
-
* against customer data. Such an installation shows the values in the meta
|
|
25
|
-
* block of the article admin view while the columns sit empty.
|
|
26
|
-
*
|
|
27
24
|
* Two naming traps, both inherited from BDE: the label column is `description`,
|
|
28
25
|
* not `name`; and the soft-delete flag is `isDeleted`, not `deleted`.
|
|
29
26
|
*
|
|
@@ -28,24 +28,21 @@ const ARTICLE_TYPE_SPARE_PART = "spare_part";
|
|
|
28
28
|
* retired and material now references the shared article catalogue instead, so
|
|
29
29
|
* the same v1 rows land in `OD3_BDE_Article` with `type: "spare_part"`.
|
|
30
30
|
*
|
|
31
|
-
* **Stock keeping
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
31
|
+
* **Stock keeping goes to columns since 2026-09-25.** `OD3_BDE_Article` gained
|
|
32
|
+
* `stock`, `minimumStock`, `storageLocation`, `supplier`, `orderNumber`,
|
|
33
|
+
* `price`, `priceCurrency` and `packageSize` on 2026-09-18, so the values this
|
|
34
|
+
* pass used to park in plugin-meta are written to the class itself. An entry
|
|
35
|
+
* left from an earlier run has those keys stripped and is removed when nothing
|
|
36
|
+
* else remains — otherwise every value would show twice, once in the article
|
|
37
|
+
* form and once under *Kopfdaten*.
|
|
37
38
|
*
|
|
38
|
-
* What still
|
|
39
|
-
*
|
|
40
|
-
*
|
|
39
|
+
* **What still has no column stays meta** under `["service","article","meta"]`:
|
|
40
|
+
* v1's `category` — deliberately never given a column, since tags and `type`
|
|
41
|
+
* already classify and a third such field goes stale — v1's `description`, for
|
|
42
|
+
* which the label column is taken by v1's `name`, and the equipment links behind
|
|
43
|
+
* `Item.sources`. Nothing is dropped. See `lib/articleMeta.ts` for why that
|
|
41
44
|
* context and not the ABAS one.
|
|
42
45
|
*
|
|
43
|
-
* ⚠️ **Installations migrated before this change keep their values in meta.**
|
|
44
|
-
* There is no repair pass: few installations track material at all, so
|
|
45
|
-
* re-entering the handful of articles was judged cheaper than a script running
|
|
46
|
-
* against customer data. Such an installation shows the values in the meta
|
|
47
|
-
* block of the article admin view while the columns sit empty.
|
|
48
|
-
*
|
|
49
46
|
* Two naming traps, both inherited from BDE: the label column is `description`,
|
|
50
47
|
* not `name`; and the soft-delete flag is `isDeleted`, not `deleted`.
|
|
51
48
|
*
|
|
@@ -68,6 +65,9 @@ exports.pass05 = {
|
|
|
68
65
|
const contextString = (0, ptr_js_1.contextToString)(articleMeta_js_1.ARTICLE_META_CONTEXT);
|
|
69
66
|
let withMeta = 0;
|
|
70
67
|
let unparseablePrices = 0;
|
|
68
|
+
let legacyStripped = 0;
|
|
69
|
+
let legacyRemoved = 0;
|
|
70
|
+
const strippedTenants = new Set();
|
|
71
71
|
for (const item of items) {
|
|
72
72
|
const sourceId = item.id;
|
|
73
73
|
if (!sourceId)
|
|
@@ -90,9 +90,8 @@ exports.pass05 = {
|
|
|
90
90
|
}
|
|
91
91
|
if (item.get("stockUnit"))
|
|
92
92
|
target.set("unit", item.get("stockUnit"));
|
|
93
|
-
// Stock keeping
|
|
94
|
-
//
|
|
95
|
-
// were added on 2026-09-18, so the values belong in them.
|
|
93
|
+
// Stock keeping: real columns since 2026-09-18. v1's `stockAlarmAt` is
|
|
94
|
+
// the same idea as `minimumStock` under its older name.
|
|
96
95
|
for (const [from, to] of [
|
|
97
96
|
["storageLocation", "storageLocation"],
|
|
98
97
|
["supplier", "supplier"],
|
|
@@ -103,8 +102,6 @@ exports.pass05 = {
|
|
|
103
102
|
target.set(to, value.trim());
|
|
104
103
|
}
|
|
105
104
|
}
|
|
106
|
-
// v1's `stockAlarmAt` is the reorder level; renamed because it raises no
|
|
107
|
-
// alarm.
|
|
108
105
|
for (const [from, to] of [
|
|
109
106
|
["stock", "stock"],
|
|
110
107
|
["stockAlarmAt", "minimumStock"],
|
|
@@ -113,24 +110,37 @@ exports.pass05 = {
|
|
|
113
110
|
if (typeof value === "number")
|
|
114
111
|
target.set(to, value);
|
|
115
112
|
}
|
|
116
|
-
// Only what still has no column. `category` was deliberately not added —
|
|
117
|
-
// tags and `type` already classify, and a third such field goes stale.
|
|
118
|
-
const metaValues = {};
|
|
119
|
-
const category = item.get("category");
|
|
120
|
-
if (typeof category === "string" && category.trim()) {
|
|
121
|
-
metaValues.category = category.trim();
|
|
122
|
-
}
|
|
123
113
|
// v1 stored price as a free-form string; keep the number, report the rest
|
|
124
114
|
// rather than silently discarding it.
|
|
115
|
+
//
|
|
116
|
+
// Note `price` carries `defaultValue: 0` in the schema, so an unparseable
|
|
117
|
+
// one does not stay empty — it reads as 0, i.e. free. The warning below is
|
|
118
|
+
// the only signal that it was never a number, so do not drop it.
|
|
125
119
|
const rawPrice = item.get("price");
|
|
126
120
|
const price = (0, articleMeta_js_1.parsePrice)(rawPrice);
|
|
127
|
-
if (price !== undefined)
|
|
121
|
+
if (price !== undefined) {
|
|
128
122
|
target.set("price", price);
|
|
123
|
+
const currency = (0, articleMeta_js_1.parsePriceCurrency)(rawPrice);
|
|
124
|
+
if (currency)
|
|
125
|
+
target.set("priceCurrency", currency);
|
|
126
|
+
}
|
|
129
127
|
else if (rawPrice) {
|
|
130
128
|
unparseablePrices += 1;
|
|
131
129
|
report.warn(entry, `item ${sourceId} ("${item.get("name")}") price "${String(rawPrice)}" ` +
|
|
132
130
|
`is not a number — left unset on the article`);
|
|
133
131
|
}
|
|
132
|
+
// What the catalogue still has no column for. v1 carried both a `name`
|
|
133
|
+
// and a `description`; `name` is the label (BDE calls that column
|
|
134
|
+
// `description`), so v1's own description would otherwise be dropped.
|
|
135
|
+
const metaValues = {};
|
|
136
|
+
const category = item.get("category");
|
|
137
|
+
if (typeof category === "string" && category.trim()) {
|
|
138
|
+
metaValues.category = category.trim();
|
|
139
|
+
}
|
|
140
|
+
const notes = item.get("description");
|
|
141
|
+
if (typeof notes === "string" && notes.trim()) {
|
|
142
|
+
metaValues.notes = notes.trim();
|
|
143
|
+
}
|
|
134
144
|
// `Item.sources` (Relation<Source>) -> the migrated Equipment ids.
|
|
135
145
|
const equipmentIds = [];
|
|
136
146
|
for (const src of await (0, latest_js_1.relationObjects)(item, "sources", config.batchSize)) {
|
|
@@ -175,16 +185,42 @@ exports.pass05 = {
|
|
|
175
185
|
}
|
|
176
186
|
// Meta last: it needs the article id, and an entry with no values is
|
|
177
187
|
// not worth a row.
|
|
178
|
-
|
|
188
|
+
const existingMeta = metaByArticle.get(newId);
|
|
189
|
+
// An entry written before 2026-09-25 still carries the stock-keeping
|
|
190
|
+
// values that are columns now. Keep whatever else it holds, drop those.
|
|
191
|
+
const carried = {
|
|
192
|
+
...(existingMeta?.get("values") ?? {}),
|
|
193
|
+
};
|
|
194
|
+
let strippedHere = 0;
|
|
195
|
+
for (const key of articleMeta_js_1.META_KEYS_NOW_COLUMNS) {
|
|
196
|
+
if (key in carried) {
|
|
197
|
+
delete carried[key];
|
|
198
|
+
strippedHere += 1;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
if (strippedHere > 0) {
|
|
202
|
+
legacyStripped += 1;
|
|
203
|
+
strippedTenants.add(tenantId ?? "");
|
|
204
|
+
}
|
|
205
|
+
const nextValues = { ...carried, ...metaValues };
|
|
206
|
+
if (Object.keys(nextValues).length === 0) {
|
|
207
|
+
// Nothing left that has no column of its own. A row holding `{}`
|
|
208
|
+
// would render as an empty *Kopfdaten* block, so drop the row.
|
|
209
|
+
if (existingMeta) {
|
|
210
|
+
await existingMeta.destroy(acl_js_1.MIGRATION_SAVE);
|
|
211
|
+
metaByArticle.delete(newId);
|
|
212
|
+
legacyRemoved += 1;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
else {
|
|
179
216
|
if (!metaConfigByTenant.has(tenantId ?? "")) {
|
|
180
217
|
metaConfigByTenant.set(tenantId ?? "", await (0, articleMeta_js_1.ensureArticleMetaConfig)(config, tenantId ?? ""));
|
|
181
218
|
}
|
|
182
|
-
const existingMeta = metaByArticle.get(newId);
|
|
183
219
|
const metaEntry = existingMeta ?? new index_js_1.Meta_Entry();
|
|
184
220
|
metaEntry.set("context", contextString);
|
|
185
221
|
metaEntry.set("entryClassName", index_js_1.BDE_Article.className);
|
|
186
222
|
metaEntry.set("entryObjectId", newId);
|
|
187
|
-
metaEntry.set("values",
|
|
223
|
+
metaEntry.set("values", nextValues);
|
|
188
224
|
const originPtr = (0, ptr_js_1.maybePtr)("OD3_Meta_Config", metaConfigByTenant.get(tenantId ?? ""));
|
|
189
225
|
if (originPtr)
|
|
190
226
|
metaEntry.set("origin", originPtr);
|
|
@@ -208,9 +244,23 @@ exports.pass05 = {
|
|
|
208
244
|
continue;
|
|
209
245
|
}
|
|
210
246
|
}
|
|
247
|
+
// A tenant whose entries all emptied never reaches ensureArticleMetaConfig
|
|
248
|
+
// in the loop, so its `Meta_Config` would go on offering the stock fields as
|
|
249
|
+
// an empty form — the same duplication, one layer up.
|
|
250
|
+
for (const strippedTenant of strippedTenants) {
|
|
251
|
+
if (!metaConfigByTenant.has(strippedTenant)) {
|
|
252
|
+
await (0, articleMeta_js_1.ensureArticleMetaConfig)(config, strippedTenant);
|
|
253
|
+
}
|
|
254
|
+
}
|
|
211
255
|
if (withMeta > 0) {
|
|
212
|
-
report.info(entry, `${withMeta} article(s) carry
|
|
213
|
-
`["service","article","meta"] —
|
|
256
|
+
report.info(entry, `${withMeta} article(s) carry category, v1 description or equipment ` +
|
|
257
|
+
`links as meta under ["service","article","meta"] — stock keeping is ` +
|
|
258
|
+
`on the article itself`);
|
|
259
|
+
}
|
|
260
|
+
if (legacyStripped > 0) {
|
|
261
|
+
report.info(entry, `${legacyStripped} meta entr(ies) from a run before 2026-09-25 had ` +
|
|
262
|
+
`their stock-keeping values stripped — those are columns now; ` +
|
|
263
|
+
`${legacyRemoved} entr(ies) held nothing else and were removed`);
|
|
214
264
|
}
|
|
215
265
|
if (unparseablePrices > 0) {
|
|
216
266
|
report.info(entry, `${unparseablePrices} price(s) could not be parsed into a number — see ` +
|
|
@@ -5,9 +5,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const node_1 = __importDefault(require("parse/node"));
|
|
7
7
|
const index_js_1 = require("../../types/index.js");
|
|
8
|
+
const articleMeta_js_1 = require("./lib/articleMeta.js");
|
|
9
|
+
const equipmentMeta_js_1 = require("./lib/equipmentMeta.js");
|
|
8
10
|
const env_js_1 = require("./lib/env.js");
|
|
9
11
|
const message_js_1 = require("./lib/message.js");
|
|
10
12
|
const pass_js_1 = require("./lib/pass.js");
|
|
13
|
+
const ptr_js_1 = require("./lib/ptr.js");
|
|
11
14
|
/** Pointer/array-of-ids fields to resolve, and the class they must resolve into. */
|
|
12
15
|
const REFERENCE_FIELDS = [
|
|
13
16
|
{ field: "status", className: index_js_1.Service_Status.className },
|
|
@@ -417,10 +420,20 @@ const checks = [
|
|
|
417
420
|
"material",
|
|
418
421
|
];
|
|
419
422
|
const mismatches = [];
|
|
423
|
+
let nativeSkipped = 0;
|
|
420
424
|
for await (const page of (0, pass_js_1.pages)(() => (0, pass_js_1.scopeToTenant)(new node_1.default.Query(index_js_1.Service_Ticket), tenantId), batchSize)) {
|
|
421
425
|
for (const t of page) {
|
|
422
426
|
if (!t.id)
|
|
423
427
|
continue;
|
|
428
|
+
// Only tickets this migration created. A ticket made in v2 directly has
|
|
429
|
+
// no v1 side tables behind it and therefore no reconstructed history —
|
|
430
|
+
// flagging it would fail the cutover on any instance where v2 was
|
|
431
|
+
// trialled first, which the numbering note explicitly expects.
|
|
432
|
+
const origin = t.get("origin");
|
|
433
|
+
if (typeof origin !== "string" || !origin.startsWith("legacy:")) {
|
|
434
|
+
nativeSkipped += 1;
|
|
435
|
+
continue;
|
|
436
|
+
}
|
|
424
437
|
const snapshot = latestSnapshot.get(t.id);
|
|
425
438
|
if (!snapshot) {
|
|
426
439
|
if (mismatches.length < 10) {
|
|
@@ -443,7 +456,19 @@ const checks = [
|
|
|
443
456
|
}
|
|
444
457
|
}
|
|
445
458
|
}
|
|
446
|
-
|
|
459
|
+
if (mismatches.length) {
|
|
460
|
+
return (`e.g. ${mismatches.join("; ")}` +
|
|
461
|
+
(nativeSkipped
|
|
462
|
+
? ` (${nativeSkipped} non-migrated ticket(s) skipped)`
|
|
463
|
+
: ""));
|
|
464
|
+
}
|
|
465
|
+
// Said out loud rather than silently passing: on an instance that trialled
|
|
466
|
+
// v2 first, the number of tickets this check does not cover is worth seeing.
|
|
467
|
+
if (nativeSkipped > 0) {
|
|
468
|
+
console.log(` note: ${nativeSkipped} ticket(s) were created in v2 directly ` +
|
|
469
|
+
`(no legacy: origin) and are outside this check`);
|
|
470
|
+
}
|
|
471
|
+
return undefined;
|
|
447
472
|
},
|
|
448
473
|
},
|
|
449
474
|
{
|
|
@@ -523,6 +548,136 @@ const checks = [
|
|
|
523
548
|
: undefined;
|
|
524
549
|
},
|
|
525
550
|
},
|
|
551
|
+
// ── Articles: stock keeping belongs on the class ─────────────────────────
|
|
552
|
+
{
|
|
553
|
+
name: "no article carries stock-keeping values as plugin-meta",
|
|
554
|
+
hard: true,
|
|
555
|
+
async run(_tenantId, batchSize) {
|
|
556
|
+
const offenders = [];
|
|
557
|
+
let total = 0;
|
|
558
|
+
for await (const page of (0, pass_js_1.pages)(() => new node_1.default.Query(index_js_1.Meta_Entry)
|
|
559
|
+
.equalTo("context", (0, ptr_js_1.contextToString)(articleMeta_js_1.ARTICLE_META_CONTEXT))
|
|
560
|
+
.equalTo("entryClassName", index_js_1.BDE_Article.className), batchSize)) {
|
|
561
|
+
for (const row of page) {
|
|
562
|
+
const values = (row.get("values") ?? {});
|
|
563
|
+
const stale = articleMeta_js_1.META_KEYS_NOW_COLUMNS.filter((key) => key in values);
|
|
564
|
+
if (stale.length === 0)
|
|
565
|
+
continue;
|
|
566
|
+
total += 1;
|
|
567
|
+
if (offenders.length < 3) {
|
|
568
|
+
offenders.push(`${row.get("entryObjectId")} (${stale.join(", ")})`);
|
|
569
|
+
}
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
// These became columns on 2026-09-18. An entry still holding them means
|
|
573
|
+
// pass 05 last ran before 2026-09-25: the article form and *Kopfdaten*
|
|
574
|
+
// would each show the value, and editing one would not update the other.
|
|
575
|
+
return total > 0
|
|
576
|
+
? `${total} article meta entr(ies) still hold stock-keeping values — ` +
|
|
577
|
+
`re-run pass 05, which strips them. e.g. ${offenders.join("; ")}`
|
|
578
|
+
: undefined;
|
|
579
|
+
},
|
|
580
|
+
},
|
|
581
|
+
{
|
|
582
|
+
name: "migrated articles carry their v1 stock numbers as columns",
|
|
583
|
+
hard: true,
|
|
584
|
+
async run(tenantId, batchSize) {
|
|
585
|
+
let v1WithStock = 0;
|
|
586
|
+
for await (const page of (0, pass_js_1.pages)(() => (0, pass_js_1.scopeToTenant)(new node_1.default.Query(index_js_1.Maintenance_Item), tenantId), batchSize)) {
|
|
587
|
+
for (const item of page) {
|
|
588
|
+
if (typeof item.get("stock") === "number" ||
|
|
589
|
+
typeof item.get("stockAlarmAt") === "number") {
|
|
590
|
+
v1WithStock += 1;
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
if (v1WithStock === 0)
|
|
595
|
+
return undefined;
|
|
596
|
+
let v2WithStock = 0;
|
|
597
|
+
for await (const page of (0, pass_js_1.pages)(() => node_1.default.Query.or(new node_1.default.Query(index_js_1.BDE_Article).exists("stock"), new node_1.default.Query(index_js_1.BDE_Article).exists("minimumStock")), batchSize)) {
|
|
598
|
+
v2WithStock += page.length;
|
|
599
|
+
}
|
|
600
|
+
// The failure this guards: a container still serving the schema baked
|
|
601
|
+
// before 2026-09-25 has no stock columns, and `initSchema` runs with
|
|
602
|
+
// `deleteFields` wherever FORCE_SCHEMA is on — so the values would be
|
|
603
|
+
// written and then removed on the next boot. Counts rather than a join;
|
|
604
|
+
// wholesale loss is the failure mode that matters.
|
|
605
|
+
return v2WithStock >= v1WithStock
|
|
606
|
+
? undefined
|
|
607
|
+
: `${v1WithStock} v1 item(s) carry stock numbers but only ` +
|
|
608
|
+
`${v2WithStock} article(s) do — is the container serving a schema ` +
|
|
609
|
+
`without the stock columns? (pnpm docker:rebuild)`;
|
|
610
|
+
},
|
|
611
|
+
},
|
|
612
|
+
{
|
|
613
|
+
name: "every migrated source's header data reached its equipment",
|
|
614
|
+
hard: true,
|
|
615
|
+
async run(_tenantId, batchSize) {
|
|
616
|
+
// sourceId -> equipmentId, straight from the map: immune to equipment
|
|
617
|
+
// created in v2 afterwards.
|
|
618
|
+
const equipmentBySource = new Map();
|
|
619
|
+
for await (const page of (0, pass_js_1.pages)(() => new node_1.default.Query("OD3_Service_MigrationMap").equalTo("sourceClass", index_js_1.Source.className), batchSize)) {
|
|
620
|
+
for (const row of page) {
|
|
621
|
+
const from = row.get("sourceId");
|
|
622
|
+
const to = row.get("targetId");
|
|
623
|
+
if (from && to)
|
|
624
|
+
equipmentBySource.set(from, to);
|
|
625
|
+
}
|
|
626
|
+
}
|
|
627
|
+
if (equipmentBySource.size === 0)
|
|
628
|
+
return undefined;
|
|
629
|
+
// Which migrated sources carry header data worth an entry. A SourceMeta
|
|
630
|
+
// with nothing in it produces no row, by design.
|
|
631
|
+
const metaIdBySource = new Map();
|
|
632
|
+
for await (const page of (0, pass_js_1.pages)(() => new node_1.default.Query(index_js_1.Source), batchSize)) {
|
|
633
|
+
for (const source of page) {
|
|
634
|
+
const metaId = (0, pass_js_1.refId)(source.get("meta"));
|
|
635
|
+
if (source.id && metaId && equipmentBySource.has(source.id)) {
|
|
636
|
+
metaIdBySource.set(source.id, metaId);
|
|
637
|
+
}
|
|
638
|
+
}
|
|
639
|
+
}
|
|
640
|
+
if (metaIdBySource.size === 0)
|
|
641
|
+
return undefined;
|
|
642
|
+
const hasContent = new Set();
|
|
643
|
+
for await (const page of (0, pass_js_1.pages)(() => new node_1.default.Query(index_js_1.SourceMeta), batchSize)) {
|
|
644
|
+
for (const meta of page) {
|
|
645
|
+
if (!meta.id)
|
|
646
|
+
continue;
|
|
647
|
+
const data = (meta.get("data") ?? {});
|
|
648
|
+
const any = Object.keys(data).length > 0 ||
|
|
649
|
+
["name", "description", "location", "file"].some((c) => Boolean(meta.get(c)));
|
|
650
|
+
if (any)
|
|
651
|
+
hasContent.add(meta.id);
|
|
652
|
+
}
|
|
653
|
+
}
|
|
654
|
+
const entries = new Set();
|
|
655
|
+
for await (const page of (0, pass_js_1.pages)(() => new node_1.default.Query(index_js_1.Meta_Entry)
|
|
656
|
+
.equalTo("context", (0, ptr_js_1.contextToString)(equipmentMeta_js_1.EQUIPMENT_META_CONTEXT))
|
|
657
|
+
.equalTo("entryClassName", index_js_1.Service_Equipment.className), batchSize)) {
|
|
658
|
+
for (const row of page) {
|
|
659
|
+
const id = row.get("entryObjectId");
|
|
660
|
+
if (id)
|
|
661
|
+
entries.add(id);
|
|
662
|
+
}
|
|
663
|
+
}
|
|
664
|
+
const missing = [];
|
|
665
|
+
for (const [sourceId, metaId] of metaIdBySource) {
|
|
666
|
+
if (!hasContent.has(metaId))
|
|
667
|
+
continue;
|
|
668
|
+
const equipmentId = equipmentBySource.get(sourceId);
|
|
669
|
+
if (!entries.has(equipmentId) && missing.length < 5) {
|
|
670
|
+
missing.push(`source ${sourceId} -> equipment ${equipmentId}`);
|
|
671
|
+
}
|
|
672
|
+
}
|
|
673
|
+
// D2 was reversed on 2026-09-25: SourceMeta migrates because clients use
|
|
674
|
+
// it. Losing it silently is exactly the failure this guards.
|
|
675
|
+
return missing.length
|
|
676
|
+
? `${missing.length} source(s) with header data have no equipment meta ` +
|
|
677
|
+
`entry — e.g. ${missing.join("; ")}`
|
|
678
|
+
: undefined;
|
|
679
|
+
},
|
|
680
|
+
},
|
|
526
681
|
// ── Soft: distribution sanity ────────────────────────────────────────────
|
|
527
682
|
{
|
|
528
683
|
name: "ticket status distribution looks plausible",
|
|
@@ -100,13 +100,66 @@ async function seed(ctx) {
|
|
|
100
100
|
const tenant = ptr("OD3_Tenant", tenantId);
|
|
101
101
|
const tenant2 = ptr("OD3_Tenant", tenant2Id);
|
|
102
102
|
const user = ptr("_User", userId);
|
|
103
|
+
// ── source meta: created first, because Source.meta points at it ───────────
|
|
104
|
+
// Covers every branch of the SourceMeta -> equipment-meta step in pass 03:
|
|
105
|
+
// scalar/array values, a cross-source type conflict, a data key colliding with
|
|
106
|
+
// a SourceMeta column, and meta on a source D3 will not migrate.
|
|
107
|
+
const hallMetaId = await create(ctx, "OD3_SourceMeta", {
|
|
108
|
+
name: "Halle B Stammdaten",
|
|
109
|
+
// `baujahr` is a String here and a Number on CNC-04 below: the pass must
|
|
110
|
+
// report the type conflict and keep the first definition.
|
|
111
|
+
data: { hersteller: "Diverse", baujahr: "unbekannt" },
|
|
112
|
+
tenant,
|
|
113
|
+
}, daysAgo(401));
|
|
114
|
+
const cncMetaId = await create(ctx, "OD3_SourceMeta", {
|
|
115
|
+
name: "CNC-04 Stammdaten",
|
|
116
|
+
description: "Kopfdaten der Fräse",
|
|
117
|
+
location: { __type: "GeoPoint", latitude: 52.0211, longitude: 8.5347 },
|
|
118
|
+
data: {
|
|
119
|
+
hersteller: "Siemens",
|
|
120
|
+
baujahr: 2018,
|
|
121
|
+
wartungspflichtig: true,
|
|
122
|
+
zertifikate: ["CE", "ISO9001"],
|
|
123
|
+
},
|
|
124
|
+
tenant,
|
|
125
|
+
}, daysAgo(396));
|
|
126
|
+
// `data.name` collides with the SourceMeta `name` column: data wins, the
|
|
127
|
+
// column moves to `sourceMetaName`.
|
|
128
|
+
const untaggedMetaId = await create(ctx, "OD3_SourceMeta", {
|
|
129
|
+
name: "Presse Stammdaten",
|
|
130
|
+
data: { name: "Presse A intern", hersteller: "Schuler" },
|
|
131
|
+
tenant,
|
|
132
|
+
}, daysAgo(391));
|
|
133
|
+
// Hangs off a source nothing references: must be counted, not migrated.
|
|
134
|
+
const orphanMetaId = await create(ctx, "OD3_SourceMeta", { name: "Sensor Stammdaten", data: { irrelevant: "wird nicht migriert" }, tenant }, daysAgo(381));
|
|
103
135
|
// ── sources: a two-level tree, plus one with no tag, plus one nothing uses ──
|
|
104
|
-
const hallId = await create(ctx, "OD3_Source", {
|
|
105
|
-
|
|
136
|
+
const hallId = await create(ctx, "OD3_Source", {
|
|
137
|
+
name: "Halle B",
|
|
138
|
+
tag: "halle-b",
|
|
139
|
+
meta: ptr("OD3_SourceMeta", hallMetaId),
|
|
140
|
+
tenant,
|
|
141
|
+
}, daysAgo(400));
|
|
142
|
+
const cncId = await create(ctx, "OD3_Source", {
|
|
143
|
+
name: "CNC-04",
|
|
144
|
+
tag: "cnc-04",
|
|
145
|
+
parent: ptr("OD3_Source", hallId),
|
|
146
|
+
meta: ptr("OD3_SourceMeta", cncMetaId),
|
|
147
|
+
tenant,
|
|
148
|
+
}, daysAgo(395));
|
|
106
149
|
// No tag: pass 03 must warn that this equipment cannot match a source.
|
|
107
|
-
const untaggedId = await create(ctx, "OD3_Source", {
|
|
150
|
+
const untaggedId = await create(ctx, "OD3_Source", {
|
|
151
|
+
name: "Presse A (ohne Tag)",
|
|
152
|
+
parent: ptr("OD3_Source", hallId),
|
|
153
|
+
meta: ptr("OD3_SourceMeta", untaggedMetaId),
|
|
154
|
+
tenant,
|
|
155
|
+
}, daysAgo(390));
|
|
108
156
|
// Referenced by nothing: pass 03 must skip it (D3).
|
|
109
|
-
await create(ctx, "OD3_Source", {
|
|
157
|
+
await create(ctx, "OD3_Source", {
|
|
158
|
+
name: "Sensor XYZ (unreferenziert)",
|
|
159
|
+
tag: "sensor-xyz",
|
|
160
|
+
meta: ptr("OD3_SourceMeta", orphanMetaId),
|
|
161
|
+
tenant,
|
|
162
|
+
}, daysAgo(380));
|
|
110
163
|
// ── kanban states: tenant 1 reuses the auto-seeded ones, plus a working state.
|
|
111
164
|
const inProgressId = await create(ctx, "OD3_Maintenance_Kanban_State", { label: "In Arbeit", order: 50, color: "#cce5ff", enabled: true, tenant }, daysAgo(370));
|
|
112
165
|
const finishedId = await create(ctx, "OD3_Maintenance_Kanban_State", {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import Parse from "parse/node";
|
|
2
2
|
import type { _User } from "./_User";
|
|
3
|
+
import type { Service_Equipment } from "./Service_Equipment";
|
|
3
4
|
import type { Service_Schedule } from "./Service_Schedule";
|
|
4
5
|
import type { Tenant } from "./Tenant";
|
|
5
6
|
export interface Service_Schedule_ExecutionAttributes {
|
|
@@ -10,13 +11,17 @@ export interface Service_Schedule_ExecutionAttributes {
|
|
|
10
11
|
asset?: any | undefined;
|
|
11
12
|
completedAt?: Date | undefined;
|
|
12
13
|
coverageOrigin?: any | undefined;
|
|
14
|
+
description?: string | undefined;
|
|
15
|
+
equipment?: Service_Equipment | undefined;
|
|
13
16
|
occurrence?: Date | undefined;
|
|
14
17
|
performedBy?: _User | undefined;
|
|
15
|
-
|
|
18
|
+
performedWith?: Service_Schedule_Execution | undefined;
|
|
19
|
+
schedule?: Service_Schedule | undefined;
|
|
16
20
|
signature?: string | undefined;
|
|
17
21
|
stepResults?: any[] | undefined;
|
|
18
22
|
steps?: any[] | undefined;
|
|
19
23
|
tenant: Tenant;
|
|
24
|
+
title?: string | undefined;
|
|
20
25
|
user?: _User | undefined;
|
|
21
26
|
}
|
|
22
27
|
export declare class Service_Schedule_Execution extends Parse.Object<Service_Schedule_ExecutionAttributes> {
|
|
@@ -28,12 +33,18 @@ export declare class Service_Schedule_Execution extends Parse.Object<Service_Sch
|
|
|
28
33
|
set completedAt(value: Date | undefined);
|
|
29
34
|
get coverageOrigin(): any | undefined;
|
|
30
35
|
set coverageOrigin(value: any | undefined);
|
|
36
|
+
get description(): string | undefined;
|
|
37
|
+
set description(value: string | undefined);
|
|
38
|
+
get equipment(): Service_Equipment | undefined;
|
|
39
|
+
set equipment(value: Service_Equipment | undefined);
|
|
31
40
|
get occurrence(): Date | undefined;
|
|
32
41
|
set occurrence(value: Date | undefined);
|
|
33
42
|
get performedBy(): _User | undefined;
|
|
34
43
|
set performedBy(value: _User | undefined);
|
|
35
|
-
get
|
|
36
|
-
set
|
|
44
|
+
get performedWith(): Service_Schedule_Execution | undefined;
|
|
45
|
+
set performedWith(value: Service_Schedule_Execution | undefined);
|
|
46
|
+
get schedule(): Service_Schedule | undefined;
|
|
47
|
+
set schedule(value: Service_Schedule | undefined);
|
|
37
48
|
get signature(): string | undefined;
|
|
38
49
|
set signature(value: string | undefined);
|
|
39
50
|
get stepResults(): any[] | undefined;
|
|
@@ -42,6 +53,8 @@ export declare class Service_Schedule_Execution extends Parse.Object<Service_Sch
|
|
|
42
53
|
set steps(value: any[] | undefined);
|
|
43
54
|
get tenant(): Tenant;
|
|
44
55
|
set tenant(value: Tenant);
|
|
56
|
+
get title(): string | undefined;
|
|
57
|
+
set title(value: string | undefined);
|
|
45
58
|
get user(): _User | undefined;
|
|
46
59
|
set user(value: _User | undefined);
|
|
47
60
|
}
|
|
@@ -28,6 +28,18 @@ class Service_Schedule_Execution extends node_1.default.Object {
|
|
|
28
28
|
set coverageOrigin(value) {
|
|
29
29
|
super.set("coverageOrigin", value);
|
|
30
30
|
}
|
|
31
|
+
get description() {
|
|
32
|
+
return super.get("description");
|
|
33
|
+
}
|
|
34
|
+
set description(value) {
|
|
35
|
+
super.set("description", value);
|
|
36
|
+
}
|
|
37
|
+
get equipment() {
|
|
38
|
+
return super.get("equipment");
|
|
39
|
+
}
|
|
40
|
+
set equipment(value) {
|
|
41
|
+
super.set("equipment", value);
|
|
42
|
+
}
|
|
31
43
|
get occurrence() {
|
|
32
44
|
return super.get("occurrence");
|
|
33
45
|
}
|
|
@@ -40,6 +52,12 @@ class Service_Schedule_Execution extends node_1.default.Object {
|
|
|
40
52
|
set performedBy(value) {
|
|
41
53
|
super.set("performedBy", value);
|
|
42
54
|
}
|
|
55
|
+
get performedWith() {
|
|
56
|
+
return super.get("performedWith");
|
|
57
|
+
}
|
|
58
|
+
set performedWith(value) {
|
|
59
|
+
super.set("performedWith", value);
|
|
60
|
+
}
|
|
43
61
|
get schedule() {
|
|
44
62
|
return super.get("schedule");
|
|
45
63
|
}
|
|
@@ -70,6 +88,12 @@ class Service_Schedule_Execution extends node_1.default.Object {
|
|
|
70
88
|
set tenant(value) {
|
|
71
89
|
super.set("tenant", value);
|
|
72
90
|
}
|
|
91
|
+
get title() {
|
|
92
|
+
return super.get("title");
|
|
93
|
+
}
|
|
94
|
+
set title(value) {
|
|
95
|
+
super.set("title", value);
|
|
96
|
+
}
|
|
73
97
|
get user() {
|
|
74
98
|
return super.get("user");
|
|
75
99
|
}
|
package/package.json
CHANGED
|
@@ -10,6 +10,15 @@
|
|
|
10
10
|
"type": "Object",
|
|
11
11
|
"required": false
|
|
12
12
|
},
|
|
13
|
+
"description": {
|
|
14
|
+
"type": "String",
|
|
15
|
+
"required": false
|
|
16
|
+
},
|
|
17
|
+
"equipment": {
|
|
18
|
+
"type": "Pointer",
|
|
19
|
+
"targetClass": "{{PREFIX}}Service_Equipment",
|
|
20
|
+
"required": false
|
|
21
|
+
},
|
|
13
22
|
"occurrence": {
|
|
14
23
|
"type": "Date",
|
|
15
24
|
"required": false
|
|
@@ -18,10 +27,15 @@
|
|
|
18
27
|
"type": "Pointer",
|
|
19
28
|
"targetClass": "_User"
|
|
20
29
|
},
|
|
30
|
+
"performedWith": {
|
|
31
|
+
"type": "Pointer",
|
|
32
|
+
"targetClass": "{{PREFIX}}Service_Schedule_Execution",
|
|
33
|
+
"required": false
|
|
34
|
+
},
|
|
21
35
|
"schedule": {
|
|
22
36
|
"type": "Pointer",
|
|
23
37
|
"targetClass": "{{PREFIX}}Service_Schedule",
|
|
24
|
-
"required":
|
|
38
|
+
"required": false
|
|
25
39
|
},
|
|
26
40
|
"signature": {
|
|
27
41
|
"type": "String"
|
|
@@ -38,6 +52,10 @@
|
|
|
38
52
|
"targetClass": "{{PREFIX}}Tenant",
|
|
39
53
|
"required": true
|
|
40
54
|
},
|
|
55
|
+
"title": {
|
|
56
|
+
"type": "String",
|
|
57
|
+
"required": false
|
|
58
|
+
},
|
|
41
59
|
"user": {
|
|
42
60
|
"type": "Pointer",
|
|
43
61
|
"targetClass": "_User",
|