@roomwise/calc-engine 0.4.0 → 0.5.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/index.d.cts CHANGED
@@ -5,15 +5,22 @@ export declare const LocalizedTextSchema: z.ZodObject<{
5
5
  uk: z.ZodString;
6
6
  }, z.core.$strip>;
7
7
  export type LocalizedText = z.infer<typeof LocalizedTextSchema>;
8
+ export declare const ScopeSchema: z.ZodEnum<{
9
+ FULL: "FULL";
10
+ PARTIAL: "PARTIAL";
11
+ }>;
12
+ export type Scope = z.infer<typeof ScopeSchema>;
8
13
  export declare const FinishLevelSchema: z.ZodEnum<{
9
14
  ROUGH: "ROUGH";
10
15
  PRE_FINISH: "PRE_FINISH";
16
+ LIVED_IN: "LIVED_IN";
11
17
  }>;
12
18
  export type FinishLevel = z.infer<typeof FinishLevelSchema>;
13
19
  export declare const RuleLevelSchema: z.ZodEnum<{
14
20
  OBJECT: "OBJECT";
15
21
  CATEGORY: "CATEGORY";
16
22
  MATERIAL_TYPE: "MATERIAL_TYPE";
23
+ SURFACE: "SURFACE";
17
24
  }>;
18
25
  export type RuleLevel = z.infer<typeof RuleLevelSchema>;
19
26
  export declare const RateSourceSchema: z.ZodEnum<{
@@ -22,10 +29,10 @@ export declare const RateSourceSchema: z.ZodEnum<{
22
29
  }>;
23
30
  export type RateSource = z.infer<typeof RateSourceSchema>;
24
31
  export declare const SurfaceKindSchema: z.ZodEnum<{
25
- NONE: "NONE";
26
32
  FLOOR: "FLOOR";
27
33
  WALLS: "WALLS";
28
34
  CEILING: "CEILING";
35
+ NONE: "NONE";
29
36
  }>;
30
37
  export type SurfaceKind = z.infer<typeof SurfaceKindSchema>;
31
38
  export declare const ProductUnitSchema: z.ZodEnum<{
@@ -56,6 +63,8 @@ export declare const RoomTypeCodeSchema: z.ZodEnum<{
56
63
  KITCHEN: "KITCHEN";
57
64
  KITCHEN_LIVING: "KITCHEN_LIVING";
58
65
  BATHROOM: "BATHROOM";
66
+ HALLWAY: "HALLWAY";
67
+ STORAGE: "STORAGE";
59
68
  }>;
60
69
  export type RoomTypeCode = z.infer<typeof RoomTypeCodeSchema>;
61
70
  export declare const CurrencySchema: z.ZodEnum<{
@@ -71,6 +80,12 @@ export declare const SectionSchema: z.ZodEnum<{
71
80
  MATERIALS: "MATERIALS";
72
81
  }>;
73
82
  export type Section = z.infer<typeof SectionSchema>;
83
+ export declare const LineComponentKindSchema: z.ZodEnum<{
84
+ MATERIAL: "MATERIAL";
85
+ LABOR: "LABOR";
86
+ PREP: "PREP";
87
+ }>;
88
+ export type LineComponentKind = z.infer<typeof LineComponentKindSchema>;
74
89
  export declare const LineStatusSchema: z.ZodEnum<{
75
90
  OK: "OK";
76
91
  INCLUDED: "INCLUDED";
@@ -102,6 +117,8 @@ export declare const RoomConfigurationSchema: z.ZodObject<{
102
117
  KITCHEN: "KITCHEN";
103
118
  KITCHEN_LIVING: "KITCHEN_LIVING";
104
119
  BATHROOM: "BATHROOM";
120
+ HALLWAY: "HALLWAY";
121
+ STORAGE: "STORAGE";
105
122
  }>;
106
123
  lengthM: z.ZodNumber;
107
124
  widthM: z.ZodNumber;
@@ -120,11 +137,16 @@ export declare const OptionSelectionSchema: z.ZodObject<{
120
137
  }, z.core.$strip>;
121
138
  export type OptionSelection = z.infer<typeof OptionSelectionSchema>;
122
139
  export declare const ConfigurationSchema: z.ZodObject<{
140
+ scope: z.ZodDefault<z.ZodEnum<{
141
+ FULL: "FULL";
142
+ PARTIAL: "PARTIAL";
143
+ }>>;
123
144
  finishLevel: z.ZodEnum<{
124
145
  ROUGH: "ROUGH";
125
146
  PRE_FINISH: "PRE_FINISH";
147
+ LIVED_IN: "LIVED_IN";
126
148
  }>;
127
- totalAreaSqm: z.ZodNumber;
149
+ totalAreaSqm: z.ZodNullable<z.ZodNumber>;
128
150
  balconyAreaSqm: z.ZodNumber;
129
151
  balconyTiles: z.ZodBoolean;
130
152
  rooms: z.ZodArray<z.ZodObject<{
@@ -136,6 +158,8 @@ export declare const ConfigurationSchema: z.ZodObject<{
136
158
  KITCHEN: "KITCHEN";
137
159
  KITCHEN_LIVING: "KITCHEN_LIVING";
138
160
  BATHROOM: "BATHROOM";
161
+ HALLWAY: "HALLWAY";
162
+ STORAGE: "STORAGE";
139
163
  }>;
140
164
  lengthM: z.ZodNumber;
141
165
  widthM: z.ZodNumber;
@@ -164,6 +188,17 @@ export declare const EstimateMessageSchema: z.ZodObject<{
164
188
  params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
165
189
  }, z.core.$strip>;
166
190
  export type EstimateMessage = z.infer<typeof EstimateMessageSchema>;
191
+ export declare const LineComponentSchema: z.ZodObject<{
192
+ kind: z.ZodEnum<{
193
+ MATERIAL: "MATERIAL";
194
+ LABOR: "LABOR";
195
+ PREP: "PREP";
196
+ }>;
197
+ ruleId: z.ZodString;
198
+ amountCents: z.ZodNumber;
199
+ sharedWithCategoryId: z.ZodOptional<z.ZodString>;
200
+ }, z.core.$strip>;
201
+ export type LineComponent = z.infer<typeof LineComponentSchema>;
167
202
  export declare const EstimateLineSchema: z.ZodObject<{
168
203
  id: z.ZodString;
169
204
  section: z.ZodEnum<{
@@ -191,6 +226,16 @@ export declare const EstimateLineSchema: z.ZodObject<{
191
226
  unitPriceCents: z.ZodNullable<z.ZodInt>;
192
227
  amountCents: z.ZodInt;
193
228
  amountUahKopecks: z.ZodNullable<z.ZodInt>;
229
+ components: z.ZodOptional<z.ZodArray<z.ZodObject<{
230
+ kind: z.ZodEnum<{
231
+ MATERIAL: "MATERIAL";
232
+ LABOR: "LABOR";
233
+ PREP: "PREP";
234
+ }>;
235
+ ruleId: z.ZodString;
236
+ amountCents: z.ZodNumber;
237
+ sharedWithCategoryId: z.ZodOptional<z.ZodString>;
238
+ }, z.core.$strip>>>;
194
239
  warnings: z.ZodArray<z.ZodObject<{
195
240
  code: z.ZodString;
196
241
  params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
@@ -268,6 +313,16 @@ export declare const EstimateSchema: z.ZodObject<{
268
313
  unitPriceCents: z.ZodNullable<z.ZodInt>;
269
314
  amountCents: z.ZodInt;
270
315
  amountUahKopecks: z.ZodNullable<z.ZodInt>;
316
+ components: z.ZodOptional<z.ZodArray<z.ZodObject<{
317
+ kind: z.ZodEnum<{
318
+ MATERIAL: "MATERIAL";
319
+ LABOR: "LABOR";
320
+ PREP: "PREP";
321
+ }>;
322
+ ruleId: z.ZodString;
323
+ amountCents: z.ZodNumber;
324
+ sharedWithCategoryId: z.ZodOptional<z.ZodString>;
325
+ }, z.core.$strip>>>;
271
326
  warnings: z.ZodArray<z.ZodObject<{
272
327
  code: z.ZodString;
273
328
  params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
@@ -309,6 +364,8 @@ export declare const RuleSampleSchema: z.ZodObject<{
309
364
  KITCHEN: "KITCHEN";
310
365
  KITCHEN_LIVING: "KITCHEN_LIVING";
311
366
  BATHROOM: "BATHROOM";
367
+ HALLWAY: "HALLWAY";
368
+ STORAGE: "STORAGE";
312
369
  }>;
313
370
  lengthM: z.ZodNumber;
314
371
  widthM: z.ZodNumber;
@@ -324,22 +381,33 @@ export declare const RuleSampleSchema: z.ZodObject<{
324
381
  }>;
325
382
  wastePercent: z.ZodNumber;
326
383
  }, z.core.$strip>>;
384
+ surfaceArea: z.ZodOptional<z.ZodNumber>;
327
385
  object: z.ZodObject<{
328
- totalAreaSqm: z.ZodNumber;
386
+ scope: z.ZodEnum<{
387
+ FULL: "FULL";
388
+ PARTIAL: "PARTIAL";
389
+ }>;
390
+ totalAreaSqm: z.ZodNullable<z.ZodNumber>;
329
391
  balconyAreaSqm: z.ZodNumber;
330
392
  balconyTiles: z.ZodBoolean;
331
393
  finishLevel: z.ZodEnum<{
332
394
  ROUGH: "ROUGH";
333
395
  PRE_FINISH: "PRE_FINISH";
396
+ LIVED_IN: "LIVED_IN";
334
397
  }>;
335
398
  roomsCount: z.ZodInt;
336
399
  bathroomsCount: z.ZodInt;
400
+ roomsFloorArea: z.ZodNumber;
401
+ roomsWallArea: z.ZodNumber;
402
+ roomsPerimeter: z.ZodNumber;
403
+ wetRoomsCount: z.ZodInt;
337
404
  }, z.core.$strip>;
338
405
  }, z.core.$strip>;
339
406
  export type RuleSample = z.infer<typeof RuleSampleSchema>;
340
407
  export declare const RulePreviewSchema: z.ZodObject<{
341
408
  quantity: z.ZodNullable<z.ZodNumber>;
342
409
  amountCents: z.ZodNullable<z.ZodInt>;
410
+ laborCents: z.ZodNullable<z.ZodInt>;
343
411
  variables: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodNumber, z.ZodBoolean, z.ZodString]>>;
344
412
  coefficients: z.ZodRecord<z.ZodString, z.ZodNumber>;
345
413
  error: z.ZodNullable<z.ZodObject<{
@@ -376,24 +444,16 @@ export declare const PricingLimitsSchema: z.ZodObject<{
376
444
  min: z.ZodNumber;
377
445
  max: z.ZodNumber;
378
446
  }, z.core.$strip>;
447
+ missingAreaHintSqm: z.ZodNumber;
379
448
  }, z.core.$strip>;
380
449
  export type PricingLimits = z.infer<typeof PricingLimitsSchema>;
381
- export declare const BaseRateSchema: z.ZodObject<{
382
- finishLevel: z.ZodEnum<{
383
- ROUGH: "ROUGH";
384
- PRE_FINISH: "PRE_FINISH";
385
- }>;
386
- areaFromSqm: z.ZodNumber;
387
- areaToSqm: z.ZodNumber;
388
- rateCentsPerSqm: z.ZodInt;
389
- }, z.core.$strip>;
390
- export type BaseRate = z.infer<typeof BaseRateSchema>;
391
450
  export declare const PricingRuleSchema: z.ZodObject<{
392
451
  id: z.ZodString;
393
452
  level: z.ZodEnum<{
394
453
  OBJECT: "OBJECT";
395
454
  CATEGORY: "CATEGORY";
396
455
  MATERIAL_TYPE: "MATERIAL_TYPE";
456
+ SURFACE: "SURFACE";
397
457
  }>;
398
458
  categoryId: z.ZodNullable<z.ZodString>;
399
459
  materialTypeId: z.ZodNullable<z.ZodString>;
@@ -402,7 +462,14 @@ export declare const PricingRuleSchema: z.ZodObject<{
402
462
  uk: z.ZodString;
403
463
  }, z.core.$strip>;
404
464
  quantityFormula: z.ZodNullable<z.ZodString>;
465
+ surface: z.ZodNullable<z.ZodEnum<{
466
+ FLOOR: "FLOOR";
467
+ WALLS: "WALLS";
468
+ CEILING: "CEILING";
469
+ }>>;
470
+ baseComponent: z.ZodBoolean;
405
471
  costFormula: z.ZodString;
472
+ laborFormula: z.ZodNullable<z.ZodString>;
406
473
  sortOrder: z.ZodInt;
407
474
  }, z.core.$strip>;
408
475
  export type PricingRule = z.infer<typeof PricingRuleSchema>;
@@ -415,10 +482,10 @@ export declare const PricingCategorySchema: z.ZodObject<{
415
482
  id: z.ZodString;
416
483
  wastePercent: z.ZodNumber;
417
484
  surface: z.ZodEnum<{
418
- NONE: "NONE";
419
485
  FLOOR: "FLOOR";
420
486
  WALLS: "WALLS";
421
487
  CEILING: "CEILING";
488
+ NONE: "NONE";
422
489
  }>;
423
490
  }, z.core.$strip>;
424
491
  export type PricingCategory = z.infer<typeof PricingCategorySchema>;
@@ -471,6 +538,11 @@ export declare const PricingOptionSchema: z.ZodObject<{
471
538
  PROJECT: "PROJECT";
472
539
  }>;
473
540
  roomTypeCodes: z.ZodArray<z.ZodString>;
541
+ priceCoefficientKeys: z.ZodArray<z.ZodString>;
542
+ scopes: z.ZodArray<z.ZodEnum<{
543
+ FULL: "FULL";
544
+ PARTIAL: "PARTIAL";
545
+ }>>;
474
546
  minQuantity: z.ZodNullable<z.ZodInt>;
475
547
  maxQuantity: z.ZodNullable<z.ZodInt>;
476
548
  available: z.ZodBoolean;
@@ -503,16 +575,8 @@ export declare const PricingDataSchema: z.ZodObject<{
503
575
  min: z.ZodNumber;
504
576
  max: z.ZodNumber;
505
577
  }, z.core.$strip>;
578
+ missingAreaHintSqm: z.ZodNumber;
506
579
  }, z.core.$strip>;
507
- baseRates: z.ZodArray<z.ZodObject<{
508
- finishLevel: z.ZodEnum<{
509
- ROUGH: "ROUGH";
510
- PRE_FINISH: "PRE_FINISH";
511
- }>;
512
- areaFromSqm: z.ZodNumber;
513
- areaToSqm: z.ZodNumber;
514
- rateCentsPerSqm: z.ZodInt;
515
- }, z.core.$strip>>;
516
580
  coefficients: z.ZodRecord<z.ZodString, z.ZodNumber>;
517
581
  rules: z.ZodArray<z.ZodObject<{
518
582
  id: z.ZodString;
@@ -520,6 +584,7 @@ export declare const PricingDataSchema: z.ZodObject<{
520
584
  OBJECT: "OBJECT";
521
585
  CATEGORY: "CATEGORY";
522
586
  MATERIAL_TYPE: "MATERIAL_TYPE";
587
+ SURFACE: "SURFACE";
523
588
  }>;
524
589
  categoryId: z.ZodNullable<z.ZodString>;
525
590
  materialTypeId: z.ZodNullable<z.ZodString>;
@@ -528,7 +593,14 @@ export declare const PricingDataSchema: z.ZodObject<{
528
593
  uk: z.ZodString;
529
594
  }, z.core.$strip>;
530
595
  quantityFormula: z.ZodNullable<z.ZodString>;
596
+ surface: z.ZodNullable<z.ZodEnum<{
597
+ FLOOR: "FLOOR";
598
+ WALLS: "WALLS";
599
+ CEILING: "CEILING";
600
+ }>>;
601
+ baseComponent: z.ZodBoolean;
531
602
  costFormula: z.ZodString;
603
+ laborFormula: z.ZodNullable<z.ZodString>;
532
604
  sortOrder: z.ZodInt;
533
605
  }, z.core.$strip>>;
534
606
  roomTypes: z.ZodArray<z.ZodObject<{
@@ -539,10 +611,10 @@ export declare const PricingDataSchema: z.ZodObject<{
539
611
  id: z.ZodString;
540
612
  wastePercent: z.ZodNumber;
541
613
  surface: z.ZodEnum<{
542
- NONE: "NONE";
543
614
  FLOOR: "FLOOR";
544
615
  WALLS: "WALLS";
545
616
  CEILING: "CEILING";
617
+ NONE: "NONE";
546
618
  }>;
547
619
  }, z.core.$strip>>;
548
620
  materialTypes: z.ZodArray<z.ZodObject<{
@@ -591,6 +663,11 @@ export declare const PricingDataSchema: z.ZodObject<{
591
663
  PROJECT: "PROJECT";
592
664
  }>;
593
665
  roomTypeCodes: z.ZodArray<z.ZodString>;
666
+ priceCoefficientKeys: z.ZodArray<z.ZodString>;
667
+ scopes: z.ZodArray<z.ZodEnum<{
668
+ FULL: "FULL";
669
+ PARTIAL: "PARTIAL";
670
+ }>>;
594
671
  minQuantity: z.ZodNullable<z.ZodInt>;
595
672
  maxQuantity: z.ZodNullable<z.ZodInt>;
596
673
  available: z.ZodBoolean;
@@ -714,6 +791,7 @@ export interface PreviewRuleInput {
714
791
  readonly level: RuleLevel;
715
792
  readonly quantityFormula: string | null;
716
793
  readonly costFormula: string;
794
+ readonly laborFormula?: string | null;
717
795
  readonly coefficients: Readonly<Record<string, number>>;
718
796
  readonly sample: RuleSample;
719
797
  }
@@ -724,7 +802,7 @@ export declare function levenshtein(a: string, b: string): number;
724
802
  export declare function suggestNearest(name: string, candidates: readonly string[], maxDistance?: number): string | undefined;
725
803
  //#endregion
726
804
  //#region src/formula/validate.d.ts
727
- export type FormulaKind = 'quantity' | 'cost';
805
+ export type FormulaKind = 'quantity' | 'cost' | 'labor';
728
806
  export type FormulaScope = 'room' | 'product' | 'object';
729
807
  export interface FormulaVariable {
730
808
  readonly name: string;
@@ -733,6 +811,7 @@ export interface FormulaVariable {
733
811
  }
734
812
  export declare const FORMULA_SCOPE_VARIABLES: Record<FormulaScope, readonly FormulaVariable[]>;
735
813
  export declare const FORMULA_QUANTITY_VARIABLE: FormulaVariable;
814
+ export declare const FORMULA_SURFACE_AREA_VARIABLE: FormulaVariable;
736
815
  export declare const FORMULA_VARIABLES: Record<RuleLevel, readonly FormulaVariable[]>;
737
816
  export interface ValidateFormulaInput {
738
817
  readonly level: RuleLevel;
@@ -755,13 +834,19 @@ export declare function toCents(dollars: number): number;
755
834
  //#endregion
756
835
  //#region src/variables/object.d.ts
757
836
  export interface ObjectVariables {
837
+ readonly scope: Scope;
758
838
  readonly totalArea: number;
759
839
  readonly balconyArea: number;
760
840
  readonly balconyTiles: boolean;
761
841
  readonly finishLevel: FinishLevel;
762
842
  readonly roomsCount: number;
763
843
  readonly bathroomsCount: number;
844
+ readonly roomsFloorArea: number;
845
+ readonly roomsWallArea: number;
846
+ readonly roomsPerimeter: number;
847
+ readonly wetRoomsCount: number;
764
848
  }
849
+ export declare function totalAreaOf(scope: Scope, totalAreaSqm: number | null, roomsFloorArea: number): number;
765
850
  export declare function objectVariables(configuration: Configuration): ObjectVariables;
766
851
  //#endregion
767
852
  //#region src/variables/product.d.ts