@chahidy/plannr 0.1.0 → 0.1.1

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/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # Plannr – Plannummer Generator für Baupläne
2
2
 
3
- [![npm version](https://img.shields.io/npm/v/plannr-core)](https://www.npmjs.com/package/plannr-core)
4
- [![License](https://img.shields.io/npm/l/plannr-core)](LICENSE)
3
+ [![npm version](https://img.shields.io/npm/v/@chahidy/plannr)](https://www.npmjs.com/package/@chahidy/plannr)
4
+ [![License](https://img.shields.io/npm/l/@chahidy/plannr)](LICENSE)
5
5
 
6
6
  Plannr ist ein TypeScript-Paket zur **automatischen Generierung von Plannummern** für Bauprojekte. Es unterstützt verschiedene **Bürostandards**, **mehrere Geschosse**, **Gewerke** und **Planarten**. Ideal für Web-Apps oder interne Tools.
7
7
 
@@ -9,12 +9,12 @@ Plannr ist ein TypeScript-Paket zur **automatischen Generierung von Plannummern*
9
9
 
10
10
  ## Features
11
11
 
12
- - Frei konfigurierbare Plannummern
13
- - Unterstützung von Untergeschossen (UG), Obergeschossen (OG), Erdgeschoss (EG) und Dachgeschoss (DG)
14
- - Mehrere Gewerke gleichzeitig auswählbar (Lüftung, Heizung, Sanitär …)
15
- - Dynamische Template Literal Typen für Plannummern
16
- - Unterstützung von Grundrissen und Strangschemata
17
- - Vollständig typisiert in TypeScript
12
+ - Frei konfigurierbare Plannummern
13
+ - Unterstützung von Untergeschossen (UG), Obergeschossen (OG), Erdgeschoss (EG) und Dachgeschoss (DG)
14
+ - Mehrere Gewerke gleichzeitig auswählbar (Lüftung, Heizung, Sanitär …)
15
+ - Dynamische Template Literal Typen für Plannummern
16
+ - Unterstützung von Grundrissen und Strangschemata
17
+ - Vollständig typisiert in TypeScript
18
18
  - Einfache Integration in Webanwendungen
19
19
 
20
20
  ---
@@ -22,13 +22,13 @@ Plannr ist ein TypeScript-Paket zur **automatischen Generierung von Plannummern*
22
22
  ## Installation
23
23
 
24
24
  ```bash
25
- npm install plannr-core
25
+ npm i @chahidy/plannr
26
26
  ```
27
27
 
28
28
  oder mit Yarn:
29
29
 
30
30
  ```bash
31
- yarn add plannr-core
31
+ yarn add @chahidy/plannr
32
32
  ```
33
33
 
34
34
  ---
@@ -38,29 +38,35 @@ yarn add plannr-core
38
38
  ### Import
39
39
 
40
40
  ```ts
41
- import { buildPlanNumbers } from "plannr-core";
42
- import { STANDARD_TGA } from "plannr-core/standards";
43
- import type { FloorConfig } from "plannr-core/domain/floor";
41
+ import {
42
+ type FloorConfig,
43
+ buildPlanNumbers,
44
+ STANDARD_TGA,
45
+ } from "@chahidy/plannr";
44
46
  ```
45
47
 
46
48
  ### Beispiel: Pläne generieren
47
49
 
48
50
  ```ts
49
51
  const floorsConfig: FloorConfig = {
50
- ug: { count: 1, prefix: "UG" },
51
- og: { count: 3, prefix: "OG" },
52
- eg: { prefix: "EG" },
53
- dg: { prefix: "DG" }
52
+ ug: { count: 1, prefix: "UG" }, // Anzahl und Prefix Geschoss
53
+ og: { count: 3, prefix: "OG" }, // Anzahl und Prefix Geschoss
54
+ eg: { prefix: "EG" }, // Prefix Geschoss / Standard 1 Geschoss
55
+ dg: { prefix: "DG" }, // Prefix Geschoss / Standard 1 Geschoss
54
56
  };
55
57
 
56
58
  const planNumbers = buildPlanNumbers({
57
59
  projectNumber: "21015",
58
- counts: floorsConfig,
60
+ floorcfg: floorsConfig,
59
61
  blocks: [
60
- { trades: ["LUE"], planTypes: ["GR"], perFloor: true },
61
- { trades: ["HEI"], planTypes: ["SC"], minimumPerTrade: 2 }
62
+ { trades: ["LUE"], planTypes: ["GR"], perFloor: true }, // Nur Lüftung und nur Grundrisse
63
+ {
64
+ trades: ["HZ"], // Heizung
65
+ planTypes: ["GR", "SC"], // Grundrisse und Schemata
66
+ minimumPerTrade: 2, // Anzahl Schemata
67
+ perFloor: true, // Für Grundrisse muss dieser Parameter gesetzt sein
68
+ },
62
69
  ],
63
- standard: STANDARD_TGA
64
70
  });
65
71
 
66
72
  console.log(planNumbers);
@@ -81,4 +87,3 @@ console.log(planNumbers);
81
87
  Generiert Plannummern basierend auf:
82
88
 
83
89
  - `projectNumber: string` – Projekt
84
-
package/dist/index.cjs CHANGED
@@ -20,6 +20,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  // src/index.ts
21
21
  var index_exports = {};
22
22
  __export(index_exports, {
23
+ STANDARD_TGA: () => STANDARD_TGA,
23
24
  buildPlanNumbers: () => buildPlanNumbers
24
25
  });
25
26
  module.exports = __toCommonJS(index_exports);
@@ -35,7 +36,7 @@ function generateFloors(counts, cfg) {
35
36
  const egName = cfg?.eg?.prefix ?? "EG";
36
37
  floors.push(egName);
37
38
  const ogCount = counts?.og?.count ?? 0;
38
- const ogPrefix = cfg?.og?.prefix ?? counts?.og?.prefix ?? "OG";
39
+ const ogPrefix = counts?.og?.prefix ?? counts?.og?.prefix ?? "OG";
39
40
  for (let i = 1; i <= ogCount; i++) {
40
41
  floors.push(`${ogPrefix}${i}`);
41
42
  }
@@ -47,7 +48,7 @@ function generateFloors(counts, cfg) {
47
48
  }
48
49
 
49
50
  // src/generators/plan-number.ts
50
- function buildPlanNumber(plan, projectNumber, separator = "_", suffix, index) {
51
+ function buildPlanNumber(plan, projectNumber, separator, suffix, index) {
51
52
  const floor = plan.floor ?? "XX";
52
53
  const trade = plan.trade ?? "AR";
53
54
  const running = String(plan.runningNumber).padStart(3, "0");
@@ -59,11 +60,17 @@ function buildPlanNumbers(input) {
59
60
  let runningNumber = 1;
60
61
  const plans = [];
61
62
  for (const block of input.blocks) {
63
+ const mergedBlock = {
64
+ ...input.standards,
65
+ // Standard-TGA Defaults
66
+ ...block
67
+ // individuelle Blockwerte überschreiben
68
+ };
62
69
  const floors = generateFloors(input.floorcfg);
63
- for (const trade of block.trades) {
64
- for (const type of block.planTypes) {
70
+ for (const trade of mergedBlock.trades) {
71
+ for (const type of mergedBlock.planTypes) {
65
72
  if (type === "GR") {
66
- const perFloor = block.plansPerFloor ?? 1;
73
+ const perFloor = mergedBlock.plansPerFloor ?? (mergedBlock.perFloor ? 1 : 0);
67
74
  for (const floor of floors) {
68
75
  for (let i = 0; i < perFloor; i++) {
69
76
  plans.push({
@@ -75,7 +82,7 @@ function buildPlanNumbers(input) {
75
82
  }
76
83
  }
77
84
  } else if (type === "SC") {
78
- const count = block.minimumPerTrade ?? 1;
85
+ const count = mergedBlock.minimumPerTrade ?? 1;
79
86
  for (let i = 0; i < count; i++) {
80
87
  plans.push({
81
88
  trade,
@@ -98,7 +105,17 @@ function buildPlanNumbers(input) {
98
105
  )
99
106
  );
100
107
  }
108
+
109
+ // src/standards/default-tga.ts
110
+ var STANDARD_TGA = {
111
+ separator: "_",
112
+ planRules: [
113
+ { type: "GR", perFloor: true, minimumPerTrade: 5 },
114
+ { type: "SC", perFloor: false, minimumPerTrade: 5 }
115
+ ]
116
+ };
101
117
  // Annotate the CommonJS export names for ESM import in node:
102
118
  0 && (module.exports = {
119
+ STANDARD_TGA,
103
120
  buildPlanNumbers
104
121
  });
package/dist/index.d.cts CHANGED
@@ -124,15 +124,15 @@ interface FloorConfig {
124
124
  * Untergeschoss-Bezeichnung (z. B. "UG" oder "-01").
125
125
  */
126
126
  ug?: {
127
- prefix?: Floor;
128
- count: number;
127
+ prefix?: string;
128
+ count?: number;
129
129
  };
130
130
  /**
131
131
  * Erdgeschoss-Bezeichnung (z. B. "EG").
132
132
  */
133
133
  eg?: {
134
- prefix?: Floor;
135
- count: number;
134
+ prefix?: string;
135
+ count?: number;
136
136
  };
137
137
  /**
138
138
  * Präfix für Obergeschosse.
@@ -142,18 +142,43 @@ interface FloorConfig {
142
142
  * - Ergebnis: OG1, OG2, OG3, ...
143
143
  */
144
144
  og?: {
145
- prefix?: Floor;
146
- count: number;
145
+ prefix?: string;
146
+ count?: number;
147
147
  };
148
148
  /**
149
149
  * Dachgeschoss-Bezeichnung (z. B. "DG").
150
150
  */
151
151
  dg?: {
152
- prefix?: Floor;
153
- count: number;
152
+ prefix?: string;
153
+ count?: number;
154
154
  };
155
155
  }
156
156
 
157
+ /**
158
+ * Projektnummer (z. B. "21015")
159
+ */
160
+ type ProjectNumber = string;
161
+ /**
162
+ * Laufende Plannummer innerhalb eines Projekts
163
+ * (z. B. "001", "002", ...)
164
+ */
165
+ type RunningNumber = string;
166
+ /**
167
+ * Planstatus / Freigabestatus
168
+ * (z. B. "F", "A", "P")
169
+ */
170
+ type PlanStatus = string;
171
+ /**
172
+ * Index / Revisionskennzeichen
173
+ * (z. B. "a", "b", "c")
174
+ */
175
+ type PlanIndex = string;
176
+ /**
177
+ * Trennzeichen zwischen Plannummernblöcken
178
+ * (z. B. "-", "_")
179
+ */
180
+ type Separator = string;
181
+
157
182
  /**
158
183
  * Erzeugt Plannummern auf Basis von Blöcken, Geschossen und Projektparametern.
159
184
  *
@@ -170,53 +195,38 @@ interface FloorConfig {
170
195
  * ```
171
196
  */
172
197
  interface BuildPlanNumbersInput {
173
- /**
174
- * Vereinfachte Angabe:
175
- * Gesamtanzahl Geschosse (inkl. EG).
176
- *
177
- * ⚠️ Wird ignoriert, wenn `floorCounts` gesetzt ist.
178
- */
179
- floors?: number;
180
198
  /**
181
199
  * Erweiterte Geschossdefinition.
182
200
  *
183
201
  * Überschreibt die automatische Geschossermittlung.
184
202
  */
185
- floorCounts?: FloorConfig;
186
203
  floorcfg?: FloorConfig;
187
204
  blocks: PlanBlockConfig[];
188
- projectNumber: string;
189
- separator?: string;
190
- suffix?: string;
191
- index?: string;
205
+ projectNumber: ProjectNumber;
206
+ separator?: Separator;
207
+ suffix?: PlanStatus;
208
+ index?: PlanIndex;
209
+ standards?: Partial<PlanBlockConfig>;
192
210
  }
193
211
 
194
- declare function buildPlanNumbers(input: BuildPlanNumbersInput): string[];
195
-
196
212
  /**
197
- * Projektnummer (z. B. "21015")
198
- */
199
- type ProjectNumber = string;
200
- /**
201
- * Laufende Plannummer innerhalb eines Projekts
202
- * (z. B. "001", "002", ...)
203
- */
204
- type RunningNumber = string;
205
- /**
206
- * Planstatus / Freigabestatus
207
- * (z. B. "F", "A", "P")
208
- */
209
- type PlanStatus = string;
210
- /**
211
- * Index / Revisionskennzeichen
212
- * (z. B. "a", "b", "c")
213
- */
214
- type PlanIndex = string;
215
- /**
216
- * Trennzeichen zwischen Plannummernblöcken
217
- * (z. B. "-", "_")
213
+ * Generiert Plannummern für ein Projekt.
214
+ * Standardwerte werden automatisch übernommen, individuelle Blockwerte überschreiben sie.
218
215
  */
219
- type Separator = string;
216
+ declare function buildPlanNumbers(input: BuildPlanNumbersInput): string[];
217
+
218
+ interface PlanRule {
219
+ type?: PlanType;
220
+ perFloor?: boolean;
221
+ minimumPerTrade?: number;
222
+ }
223
+
224
+ interface OfficeStandard {
225
+ separator: Separator;
226
+ planRules: PlanRule[];
227
+ }
228
+
229
+ declare const STANDARD_TGA: OfficeStandard;
220
230
 
221
231
  /**
222
232
  * Template Literal Type für eine Plannummer.
@@ -228,6 +238,6 @@ type Plannummer<Sep extends Separator, PN extends ProjectNumber, G extends Trade
228
238
  /**
229
239
  * Standard-Plannummer, wie sie von der API zurückgegeben wird.
230
240
  */
231
- type DefaultPlannummer = Plannummer<"-", ProjectNumber, Trade, PlanType, Floor, RunningNumber, PlanStatus, PlanIndex>;
241
+ type DefaultPlannummer = Plannummer<Separator, ProjectNumber, Trade, PlanType, Floor, RunningNumber, PlanStatus, PlanIndex>;
232
242
 
233
- export { type BuildPlanNumbersInput, type DefaultPlannummer, type FloorConfig, type PlanBlockConfig, type PlanType, type Trade, buildPlanNumbers };
243
+ export { type BuildPlanNumbersInput, type DefaultPlannummer, type FloorConfig, type PlanBlockConfig, type PlanType, STANDARD_TGA, type Trade, buildPlanNumbers };
package/dist/index.d.ts CHANGED
@@ -124,15 +124,15 @@ interface FloorConfig {
124
124
  * Untergeschoss-Bezeichnung (z. B. "UG" oder "-01").
125
125
  */
126
126
  ug?: {
127
- prefix?: Floor;
128
- count: number;
127
+ prefix?: string;
128
+ count?: number;
129
129
  };
130
130
  /**
131
131
  * Erdgeschoss-Bezeichnung (z. B. "EG").
132
132
  */
133
133
  eg?: {
134
- prefix?: Floor;
135
- count: number;
134
+ prefix?: string;
135
+ count?: number;
136
136
  };
137
137
  /**
138
138
  * Präfix für Obergeschosse.
@@ -142,18 +142,43 @@ interface FloorConfig {
142
142
  * - Ergebnis: OG1, OG2, OG3, ...
143
143
  */
144
144
  og?: {
145
- prefix?: Floor;
146
- count: number;
145
+ prefix?: string;
146
+ count?: number;
147
147
  };
148
148
  /**
149
149
  * Dachgeschoss-Bezeichnung (z. B. "DG").
150
150
  */
151
151
  dg?: {
152
- prefix?: Floor;
153
- count: number;
152
+ prefix?: string;
153
+ count?: number;
154
154
  };
155
155
  }
156
156
 
157
+ /**
158
+ * Projektnummer (z. B. "21015")
159
+ */
160
+ type ProjectNumber = string;
161
+ /**
162
+ * Laufende Plannummer innerhalb eines Projekts
163
+ * (z. B. "001", "002", ...)
164
+ */
165
+ type RunningNumber = string;
166
+ /**
167
+ * Planstatus / Freigabestatus
168
+ * (z. B. "F", "A", "P")
169
+ */
170
+ type PlanStatus = string;
171
+ /**
172
+ * Index / Revisionskennzeichen
173
+ * (z. B. "a", "b", "c")
174
+ */
175
+ type PlanIndex = string;
176
+ /**
177
+ * Trennzeichen zwischen Plannummernblöcken
178
+ * (z. B. "-", "_")
179
+ */
180
+ type Separator = string;
181
+
157
182
  /**
158
183
  * Erzeugt Plannummern auf Basis von Blöcken, Geschossen und Projektparametern.
159
184
  *
@@ -170,53 +195,38 @@ interface FloorConfig {
170
195
  * ```
171
196
  */
172
197
  interface BuildPlanNumbersInput {
173
- /**
174
- * Vereinfachte Angabe:
175
- * Gesamtanzahl Geschosse (inkl. EG).
176
- *
177
- * ⚠️ Wird ignoriert, wenn `floorCounts` gesetzt ist.
178
- */
179
- floors?: number;
180
198
  /**
181
199
  * Erweiterte Geschossdefinition.
182
200
  *
183
201
  * Überschreibt die automatische Geschossermittlung.
184
202
  */
185
- floorCounts?: FloorConfig;
186
203
  floorcfg?: FloorConfig;
187
204
  blocks: PlanBlockConfig[];
188
- projectNumber: string;
189
- separator?: string;
190
- suffix?: string;
191
- index?: string;
205
+ projectNumber: ProjectNumber;
206
+ separator?: Separator;
207
+ suffix?: PlanStatus;
208
+ index?: PlanIndex;
209
+ standards?: Partial<PlanBlockConfig>;
192
210
  }
193
211
 
194
- declare function buildPlanNumbers(input: BuildPlanNumbersInput): string[];
195
-
196
212
  /**
197
- * Projektnummer (z. B. "21015")
198
- */
199
- type ProjectNumber = string;
200
- /**
201
- * Laufende Plannummer innerhalb eines Projekts
202
- * (z. B. "001", "002", ...)
203
- */
204
- type RunningNumber = string;
205
- /**
206
- * Planstatus / Freigabestatus
207
- * (z. B. "F", "A", "P")
208
- */
209
- type PlanStatus = string;
210
- /**
211
- * Index / Revisionskennzeichen
212
- * (z. B. "a", "b", "c")
213
- */
214
- type PlanIndex = string;
215
- /**
216
- * Trennzeichen zwischen Plannummernblöcken
217
- * (z. B. "-", "_")
213
+ * Generiert Plannummern für ein Projekt.
214
+ * Standardwerte werden automatisch übernommen, individuelle Blockwerte überschreiben sie.
218
215
  */
219
- type Separator = string;
216
+ declare function buildPlanNumbers(input: BuildPlanNumbersInput): string[];
217
+
218
+ interface PlanRule {
219
+ type?: PlanType;
220
+ perFloor?: boolean;
221
+ minimumPerTrade?: number;
222
+ }
223
+
224
+ interface OfficeStandard {
225
+ separator: Separator;
226
+ planRules: PlanRule[];
227
+ }
228
+
229
+ declare const STANDARD_TGA: OfficeStandard;
220
230
 
221
231
  /**
222
232
  * Template Literal Type für eine Plannummer.
@@ -228,6 +238,6 @@ type Plannummer<Sep extends Separator, PN extends ProjectNumber, G extends Trade
228
238
  /**
229
239
  * Standard-Plannummer, wie sie von der API zurückgegeben wird.
230
240
  */
231
- type DefaultPlannummer = Plannummer<"-", ProjectNumber, Trade, PlanType, Floor, RunningNumber, PlanStatus, PlanIndex>;
241
+ type DefaultPlannummer = Plannummer<Separator, ProjectNumber, Trade, PlanType, Floor, RunningNumber, PlanStatus, PlanIndex>;
232
242
 
233
- export { type BuildPlanNumbersInput, type DefaultPlannummer, type FloorConfig, type PlanBlockConfig, type PlanType, type Trade, buildPlanNumbers };
243
+ export { type BuildPlanNumbersInput, type DefaultPlannummer, type FloorConfig, type PlanBlockConfig, type PlanType, STANDARD_TGA, type Trade, buildPlanNumbers };
package/dist/index.js CHANGED
@@ -9,7 +9,7 @@ function generateFloors(counts, cfg) {
9
9
  const egName = cfg?.eg?.prefix ?? "EG";
10
10
  floors.push(egName);
11
11
  const ogCount = counts?.og?.count ?? 0;
12
- const ogPrefix = cfg?.og?.prefix ?? counts?.og?.prefix ?? "OG";
12
+ const ogPrefix = counts?.og?.prefix ?? counts?.og?.prefix ?? "OG";
13
13
  for (let i = 1; i <= ogCount; i++) {
14
14
  floors.push(`${ogPrefix}${i}`);
15
15
  }
@@ -21,7 +21,7 @@ function generateFloors(counts, cfg) {
21
21
  }
22
22
 
23
23
  // src/generators/plan-number.ts
24
- function buildPlanNumber(plan, projectNumber, separator = "_", suffix, index) {
24
+ function buildPlanNumber(plan, projectNumber, separator, suffix, index) {
25
25
  const floor = plan.floor ?? "XX";
26
26
  const trade = plan.trade ?? "AR";
27
27
  const running = String(plan.runningNumber).padStart(3, "0");
@@ -33,11 +33,17 @@ function buildPlanNumbers(input) {
33
33
  let runningNumber = 1;
34
34
  const plans = [];
35
35
  for (const block of input.blocks) {
36
+ const mergedBlock = {
37
+ ...input.standards,
38
+ // Standard-TGA Defaults
39
+ ...block
40
+ // individuelle Blockwerte überschreiben
41
+ };
36
42
  const floors = generateFloors(input.floorcfg);
37
- for (const trade of block.trades) {
38
- for (const type of block.planTypes) {
43
+ for (const trade of mergedBlock.trades) {
44
+ for (const type of mergedBlock.planTypes) {
39
45
  if (type === "GR") {
40
- const perFloor = block.plansPerFloor ?? 1;
46
+ const perFloor = mergedBlock.plansPerFloor ?? (mergedBlock.perFloor ? 1 : 0);
41
47
  for (const floor of floors) {
42
48
  for (let i = 0; i < perFloor; i++) {
43
49
  plans.push({
@@ -49,7 +55,7 @@ function buildPlanNumbers(input) {
49
55
  }
50
56
  }
51
57
  } else if (type === "SC") {
52
- const count = block.minimumPerTrade ?? 1;
58
+ const count = mergedBlock.minimumPerTrade ?? 1;
53
59
  for (let i = 0; i < count; i++) {
54
60
  plans.push({
55
61
  trade,
@@ -72,6 +78,16 @@ function buildPlanNumbers(input) {
72
78
  )
73
79
  );
74
80
  }
81
+
82
+ // src/standards/default-tga.ts
83
+ var STANDARD_TGA = {
84
+ separator: "_",
85
+ planRules: [
86
+ { type: "GR", perFloor: true, minimumPerTrade: 5 },
87
+ { type: "SC", perFloor: false, minimumPerTrade: 5 }
88
+ ]
89
+ };
75
90
  export {
91
+ STANDARD_TGA,
76
92
  buildPlanNumbers
77
93
  };
package/main.ts ADDED
@@ -0,0 +1,28 @@
1
+ import {
2
+ type FloorConfig,
3
+ buildPlanNumbers,
4
+ STANDARD_TGA,
5
+ } from "./dist/index.cjs";
6
+
7
+ const floorsConfig: FloorConfig = {
8
+ ug: { count: 1, prefix: "UG" }, // Anzahl und Prefix Geschoss
9
+ og: { count: 3, prefix: "OG" }, // Anzahl und Prefix Geschoss
10
+ eg: { prefix: "EG" }, // Prefix Geschoss / Standard 1 Geschoss
11
+ dg: { prefix: "DG" }, // Prefix Geschoss / Standard 1 Geschoss
12
+ };
13
+
14
+ const planNumbers = buildPlanNumbers({
15
+ projectNumber: "21015",
16
+ floorcfg: floorsConfig,
17
+ blocks: [
18
+ { trades: ["LUE"], planTypes: ["GR"], perFloor: true }, // Nur Lüftung und nur Grundrisse
19
+ {
20
+ trades: ["HZ"], // Heizung
21
+ planTypes: ["GR", "SC"], // Grundrisse und Schemata
22
+ minimumPerTrade: 2, // Anzahl Schemata
23
+ perFloor: true, // Für Grundrisse muss dieser Parameter gesetzt sein
24
+ },
25
+ ],
26
+ });
27
+
28
+ console.log(planNumbers);
package/package.json CHANGED
@@ -1,18 +1,11 @@
1
1
  {
2
2
  "name": "@chahidy/plannr",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "type": "module",
5
- "author": "Chahid Yahya",
6
5
  "main": "dist/index.cjs",
7
6
  "module": "dist/index.js",
8
7
  "types": "dist/index.d.ts",
9
- "exports": {
10
- ".": {
11
- "import": "./dist/index.js",
12
- "require": "./dist/index.cjs",
13
- "types": "./dist/index.d.ts"
14
- }
15
- },
8
+ "author": "Chahid Yahya",
16
9
  "scripts": {
17
10
  "build": "tsup"
18
11
  },
@@ -1,20 +1,31 @@
1
1
  // api/build-plan-numbers.ts
2
+ import { PlanBlockConfig } from "../../dist/index.cjs";
2
3
  import { BuildPlanNumbersInput } from "../domain/build-plan-numbers";
3
4
  import { Plan } from "../domain/plan";
4
5
  import { generateFloors } from "../generators/floors";
5
6
  import { buildPlanNumber } from "../generators/plan-number";
6
7
 
8
+ /**
9
+ * Generiert Plannummern für ein Projekt.
10
+ * Standardwerte werden automatisch übernommen, individuelle Blockwerte überschreiben sie.
11
+ */
7
12
  export function buildPlanNumbers(input: BuildPlanNumbersInput): string[] {
8
13
  let runningNumber = 1;
9
14
  const plans: Plan[] = [];
10
15
 
11
16
  for (const block of input.blocks) {
17
+ const mergedBlock: PlanBlockConfig = {
18
+ ...input.standards, // Standard-TGA Defaults
19
+ ...block, // individuelle Blockwerte überschreiben
20
+ };
21
+
12
22
  const floors = generateFloors(input.floorcfg);
13
23
 
14
- for (const trade of block.trades) {
15
- for (const type of block.planTypes) {
24
+ for (const trade of mergedBlock.trades) {
25
+ for (const type of mergedBlock.planTypes) {
16
26
  if (type === "GR") {
17
- const perFloor = block.plansPerFloor ?? 1;
27
+ const perFloor =
28
+ mergedBlock.plansPerFloor ?? (mergedBlock.perFloor ? 1 : 0);
18
29
 
19
30
  for (const floor of floors) {
20
31
  for (let i = 0; i < perFloor; i++) {
@@ -27,7 +38,7 @@ export function buildPlanNumbers(input: BuildPlanNumbersInput): string[] {
27
38
  }
28
39
  }
29
40
  } else if (type === "SC") {
30
- const count = block.minimumPerTrade ?? 1;
41
+ const count = mergedBlock.minimumPerTrade ?? 1;
31
42
 
32
43
  for (let i = 0; i < count; i++) {
33
44
  plans.push({
@@ -1,5 +1,11 @@
1
1
  import { PlanBlockConfig } from "./block-config";
2
2
  import { FloorConfig } from "./floor";
3
+ import {
4
+ PlanIndex,
5
+ PlanStatus,
6
+ ProjectNumber,
7
+ Separator,
8
+ } from "./plan-number-parts";
3
9
 
4
10
  /**
5
11
  * Erzeugt Plannummern auf Basis von Blöcken, Geschossen und Projektparametern.
@@ -17,24 +23,16 @@ import { FloorConfig } from "./floor";
17
23
  * ```
18
24
  */
19
25
  export interface BuildPlanNumbersInput {
20
- /**
21
- * Vereinfachte Angabe:
22
- * Gesamtanzahl Geschosse (inkl. EG).
23
- *
24
- * ⚠️ Wird ignoriert, wenn `floorCounts` gesetzt ist.
25
- */
26
- floors?: number;
27
-
28
26
  /**
29
27
  * Erweiterte Geschossdefinition.
30
28
  *
31
29
  * Überschreibt die automatische Geschossermittlung.
32
30
  */
33
- floorCounts?: FloorConfig;
34
31
  floorcfg?: FloorConfig;
35
32
  blocks: PlanBlockConfig[];
36
- projectNumber: string;
37
- separator?: string;
38
- suffix?: string;
39
- index?: string;
33
+ projectNumber: ProjectNumber;
34
+ separator?: Separator;
35
+ suffix?: PlanStatus;
36
+ index?: PlanIndex;
37
+ standards?: Partial<PlanBlockConfig>;
40
38
  }
@@ -29,16 +29,16 @@ export interface FloorConfig {
29
29
  * Untergeschoss-Bezeichnung (z. B. "UG" oder "-01").
30
30
  */
31
31
  ug?: {
32
- prefix?: Floor;
33
- count: number;
32
+ prefix?: string;
33
+ count?: number;
34
34
  };
35
35
 
36
36
  /**
37
37
  * Erdgeschoss-Bezeichnung (z. B. "EG").
38
38
  */
39
39
  eg?: {
40
- prefix?: Floor;
41
- count: number;
40
+ prefix?: string;
41
+ count?: number;
42
42
  };
43
43
 
44
44
  /**
@@ -49,15 +49,15 @@ export interface FloorConfig {
49
49
  * - Ergebnis: OG1, OG2, OG3, ...
50
50
  */
51
51
  og?: {
52
- prefix?: Floor;
53
- count: number;
52
+ prefix?: string;
53
+ count?: number;
54
54
  };
55
55
 
56
56
  /**
57
57
  * Dachgeschoss-Bezeichnung (z. B. "DG").
58
58
  */
59
59
  dg?: {
60
- prefix?: Floor;
61
- count: number;
60
+ prefix?: string;
61
+ count?: number;
62
62
  };
63
63
  }
@@ -30,7 +30,7 @@ export type Plannummer<
30
30
  * Standard-Plannummer, wie sie von der API zurückgegeben wird.
31
31
  */
32
32
  export type DefaultPlannummer = Plannummer<
33
- "-",
33
+ Separator,
34
34
  ProjectNumber,
35
35
  Trade,
36
36
  PlanType,
@@ -1,11 +1,13 @@
1
1
  import { Trade } from "./trade";
2
2
  import { PlanType } from "./plan-type";
3
- import { FloorCode } from "./plan-number-parts";
4
3
  import { Floor } from "./floor";
4
+ import { PlanRule } from "../rules/plan-rule";
5
5
 
6
6
  export interface Plan {
7
7
  trade: Trade;
8
8
  type: PlanType;
9
9
  floor?: Floor;
10
10
  runningNumber: number;
11
+ seperator?: string;
12
+ rule?: PlanRule;
11
13
  }
@@ -1,7 +1,5 @@
1
1
  // generators/floors.ts
2
2
  import { Floor, FloorConfig } from "../domain/floor";
3
- import { FloorCode } from "../domain/plan-number-parts";
4
-
5
3
  /**
6
4
  * Generiert alle Geschosse basierend auf FloorConfig und optionaler Zählung.
7
5
  * Unterstützt UG, EG, OGs, DG.
@@ -35,7 +33,7 @@ export function generateFloors(
35
33
  // Obergeschosse (OG)
36
34
  // -------------------
37
35
  const ogCount = counts?.og?.count ?? 0;
38
- const ogPrefix = cfg?.og?.prefix ?? counts?.og?.prefix ?? "OG";
36
+ const ogPrefix = counts?.og?.prefix ?? counts?.og?.prefix ?? "OG";
39
37
  for (let i = 1; i <= ogCount; i++) {
40
38
  floors.push(`${ogPrefix}${i}` as Floor<`${number}`>);
41
39
  }
@@ -3,31 +3,44 @@ import { Plan } from "../domain/plan";
3
3
  import { Trade } from "../domain/trade";
4
4
  import { PlanType } from "../domain/plan-type";
5
5
  import { Plannummer } from "../domain/plan-number-type";
6
+ import { Floor } from "../domain/floor";
7
+ import {
8
+ PlanIndex,
9
+ PlanStatus,
10
+ ProjectNumber,
11
+ RunningNumber,
12
+ Separator,
13
+ } from "../domain/plan-number-parts";
6
14
 
7
- export function buildPlanNumber<
8
- P extends string,
9
- Suf extends string = "F",
10
- I extends string = "A"
11
- >(
15
+ export function buildPlanNumber(
12
16
  plan: Plan,
13
- projectNumber: P,
14
- separator: string = "_",
15
- suffix: Suf,
16
- index: I
17
- ): Plannummer<typeof separator, P, Trade, PlanType, string, string, Suf, I> {
17
+ projectNumber: ProjectNumber,
18
+ separator: Separator,
19
+ suffix: PlanStatus,
20
+ index: PlanIndex
21
+ ): Plannummer<
22
+ Separator,
23
+ ProjectNumber,
24
+ Trade,
25
+ PlanType,
26
+ Floor,
27
+ RunningNumber,
28
+ PlanStatus,
29
+ PlanIndex
30
+ > {
18
31
  const floor = plan.floor ?? "XX";
19
32
  const trade = plan.trade ?? "AR";
20
33
  const running = String(plan.runningNumber).padStart(3, "0");
21
34
 
22
35
  // TypeScript prüft hier den Typ via Template Literal Type
23
36
  return `${projectNumber}${separator}${trade}${separator}${plan.type}${separator}${floor}${separator}${running}${separator}${suffix}${separator}${index}` as Plannummer<
24
- typeof separator,
25
- P,
37
+ Separator,
38
+ ProjectNumber,
26
39
  Trade,
27
40
  PlanType,
28
- string,
29
- string,
30
- Suf,
31
- I
41
+ Floor,
42
+ RunningNumber,
43
+ PlanStatus,
44
+ PlanIndex
32
45
  >;
33
46
  }
package/src/index.ts CHANGED
@@ -23,6 +23,7 @@
23
23
  * ```
24
24
  */
25
25
  export { buildPlanNumbers } from "./api/build-plan-numbers";
26
+ export { STANDARD_TGA } from "./standards/default-tga";
26
27
  // zentrale Domänen-Typen
27
28
  export type { Trade } from "./domain/trade";
28
29
  export type { PlanType } from "./domain/plan-type";
@@ -1,7 +1,7 @@
1
1
  import { PlanType } from "../domain/plan-type";
2
2
 
3
3
  export interface PlanRule {
4
- type: PlanType;
5
- perFloor: boolean;
4
+ type?: PlanType;
5
+ perFloor?: boolean;
6
6
  minimumPerTrade?: number;
7
7
  }
@@ -1,9 +1,9 @@
1
1
  import { OfficeStandard } from "./office-standard";
2
2
 
3
3
  export const STANDARD_TGA: OfficeStandard = {
4
- separator: "-",
4
+ separator: "_",
5
5
  planRules: [
6
- { type: "GR", perFloor: true },
7
- { type: "SC", perFloor: false, minimumPerTrade: 1 }
8
- ]
6
+ { type: "GR", perFloor: true, minimumPerTrade: 5 },
7
+ { type: "SC", perFloor: false, minimumPerTrade: 5 },
8
+ ],
9
9
  };
@@ -1,6 +1,7 @@
1
+ import { Separator } from "../domain/plan-number-parts";
1
2
  import { PlanRule } from "../rules/plan-rule";
2
3
 
3
4
  export interface OfficeStandard {
4
- separator: string;
5
+ separator: Separator;
5
6
  planRules: PlanRule[];
6
7
  }
package/main.js DELETED
@@ -1,14 +0,0 @@
1
- import { buildPlanNumbers } from "./dist/index.cjs";
2
-
3
- const plans = buildPlanNumbers({
4
- projectNumber: "21015",
5
- floorcfg: { ug: {prefix: "KG", count:2} },
6
- blocks: [
7
- {
8
- trades: ["LUE"],
9
- planTypes: ["GR"],
10
- },
11
- ],
12
- });
13
-
14
- console.log(plans);
@@ -1,46 +0,0 @@
1
- // src/generators/plan-generator.ts
2
- import { Trade } from "../domain/trade";
3
- import { OfficeStandard } from "../standards/office-standard";
4
- import { Plan } from "../domain/plan";
5
-
6
- export function generatePlans(
7
- trades: Trade[],
8
- floors: string[],
9
- standard: OfficeStandard
10
- ): Plan[] {
11
- let runningNumber = 1;
12
- const plans: Plan[] = [];
13
-
14
- for (const trade of trades) {
15
- for (const rule of standard.planRules) {
16
- if (rule.perFloor) {
17
- for (const floor of floors) {
18
- plans.push({
19
- trade,
20
- type: rule.type,
21
- floor,
22
- runningNumber: runningNumber++,
23
- });
24
- }
25
- } else {
26
- // Strangschemata / minimumPerTrade
27
- const existingCount = plans.filter(
28
- (p) => p.trade === trade && p.type === rule.type
29
- ).length;
30
- const needed = rule.minimumPerTrade
31
- ? Math.max(rule.minimumPerTrade - existingCount, 0)
32
- : 0;
33
-
34
- for (let i = 0; i < needed; i++) {
35
- plans.push({
36
- trade,
37
- type: rule.type,
38
- runningNumber: runningNumber++,
39
- });
40
- }
41
- }
42
- }
43
- }
44
-
45
- return plans;
46
- }
package/src/package.json DELETED
@@ -1,18 +0,0 @@
1
- {
2
- "name": "@plannr/core",
3
- "version": "0.1.0",
4
- "type": "module",
5
- "main": "dist/index.cjs",
6
- "module": "dist/index.js",
7
- "types": "dist/index.d.ts",
8
- "exports": {
9
- ".": {
10
- "import": "./dist/index.js",
11
- "require": "./dist/index.cjs",
12
- "types": "./dist/index.d.ts"
13
- }
14
- },
15
- "scripts": {
16
- "build": "tsup"
17
- }
18
- }