@roomwise/calc-engine 0.3.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.ts 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,13 +63,10 @@ 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
- export declare const KitchenTypeSchema: z.ZodEnum<{
62
- KITCHEN_LIVING: "KITCHEN_LIVING";
63
- SEPARATE: "SEPARATE";
64
- }>;
65
- export type KitchenType = z.infer<typeof KitchenTypeSchema>;
66
70
  export declare const CurrencySchema: z.ZodEnum<{
67
71
  USD: "USD";
68
72
  UAH: "UAH";
@@ -76,6 +80,12 @@ export declare const SectionSchema: z.ZodEnum<{
76
80
  MATERIALS: "MATERIALS";
77
81
  }>;
78
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>;
79
89
  export declare const LineStatusSchema: z.ZodEnum<{
80
90
  OK: "OK";
81
91
  INCLUDED: "INCLUDED";
@@ -107,6 +117,8 @@ export declare const RoomConfigurationSchema: z.ZodObject<{
107
117
  KITCHEN: "KITCHEN";
108
118
  KITCHEN_LIVING: "KITCHEN_LIVING";
109
119
  BATHROOM: "BATHROOM";
120
+ HALLWAY: "HALLWAY";
121
+ STORAGE: "STORAGE";
110
122
  }>;
111
123
  lengthM: z.ZodNumber;
112
124
  widthM: z.ZodNumber;
@@ -125,17 +137,18 @@ export declare const OptionSelectionSchema: z.ZodObject<{
125
137
  }, z.core.$strip>;
126
138
  export type OptionSelection = z.infer<typeof OptionSelectionSchema>;
127
139
  export declare const ConfigurationSchema: z.ZodObject<{
140
+ scope: z.ZodDefault<z.ZodEnum<{
141
+ FULL: "FULL";
142
+ PARTIAL: "PARTIAL";
143
+ }>>;
128
144
  finishLevel: z.ZodEnum<{
129
145
  ROUGH: "ROUGH";
130
146
  PRE_FINISH: "PRE_FINISH";
147
+ LIVED_IN: "LIVED_IN";
131
148
  }>;
132
- totalAreaSqm: z.ZodNumber;
149
+ totalAreaSqm: z.ZodNullable<z.ZodNumber>;
133
150
  balconyAreaSqm: z.ZodNumber;
134
151
  balconyTiles: z.ZodBoolean;
135
- kitchenType: z.ZodEnum<{
136
- KITCHEN_LIVING: "KITCHEN_LIVING";
137
- SEPARATE: "SEPARATE";
138
- }>;
139
152
  rooms: z.ZodArray<z.ZodObject<{
140
153
  clientId: z.ZodString;
141
154
  name: z.ZodOptional<z.ZodString>;
@@ -145,6 +158,8 @@ export declare const ConfigurationSchema: z.ZodObject<{
145
158
  KITCHEN: "KITCHEN";
146
159
  KITCHEN_LIVING: "KITCHEN_LIVING";
147
160
  BATHROOM: "BATHROOM";
161
+ HALLWAY: "HALLWAY";
162
+ STORAGE: "STORAGE";
148
163
  }>;
149
164
  lengthM: z.ZodNumber;
150
165
  widthM: z.ZodNumber;
@@ -173,6 +188,17 @@ export declare const EstimateMessageSchema: z.ZodObject<{
173
188
  params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
174
189
  }, z.core.$strip>;
175
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>;
176
202
  export declare const EstimateLineSchema: z.ZodObject<{
177
203
  id: z.ZodString;
178
204
  section: z.ZodEnum<{
@@ -200,6 +226,16 @@ export declare const EstimateLineSchema: z.ZodObject<{
200
226
  unitPriceCents: z.ZodNullable<z.ZodInt>;
201
227
  amountCents: z.ZodInt;
202
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>>>;
203
239
  warnings: z.ZodArray<z.ZodObject<{
204
240
  code: z.ZodString;
205
241
  params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
@@ -277,6 +313,16 @@ export declare const EstimateSchema: z.ZodObject<{
277
313
  unitPriceCents: z.ZodNullable<z.ZodInt>;
278
314
  amountCents: z.ZodInt;
279
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>>>;
280
326
  warnings: z.ZodArray<z.ZodObject<{
281
327
  code: z.ZodString;
282
328
  params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
@@ -318,6 +364,8 @@ export declare const RuleSampleSchema: z.ZodObject<{
318
364
  KITCHEN: "KITCHEN";
319
365
  KITCHEN_LIVING: "KITCHEN_LIVING";
320
366
  BATHROOM: "BATHROOM";
367
+ HALLWAY: "HALLWAY";
368
+ STORAGE: "STORAGE";
321
369
  }>;
322
370
  lengthM: z.ZodNumber;
323
371
  widthM: z.ZodNumber;
@@ -333,26 +381,33 @@ export declare const RuleSampleSchema: z.ZodObject<{
333
381
  }>;
334
382
  wastePercent: z.ZodNumber;
335
383
  }, z.core.$strip>>;
384
+ surfaceArea: z.ZodOptional<z.ZodNumber>;
336
385
  object: z.ZodObject<{
337
- totalAreaSqm: z.ZodNumber;
386
+ scope: z.ZodEnum<{
387
+ FULL: "FULL";
388
+ PARTIAL: "PARTIAL";
389
+ }>;
390
+ totalAreaSqm: z.ZodNullable<z.ZodNumber>;
338
391
  balconyAreaSqm: z.ZodNumber;
339
392
  balconyTiles: z.ZodBoolean;
340
- kitchenType: z.ZodEnum<{
341
- KITCHEN_LIVING: "KITCHEN_LIVING";
342
- SEPARATE: "SEPARATE";
343
- }>;
344
393
  finishLevel: z.ZodEnum<{
345
394
  ROUGH: "ROUGH";
346
395
  PRE_FINISH: "PRE_FINISH";
396
+ LIVED_IN: "LIVED_IN";
347
397
  }>;
348
398
  roomsCount: z.ZodInt;
349
399
  bathroomsCount: z.ZodInt;
400
+ roomsFloorArea: z.ZodNumber;
401
+ roomsWallArea: z.ZodNumber;
402
+ roomsPerimeter: z.ZodNumber;
403
+ wetRoomsCount: z.ZodInt;
350
404
  }, z.core.$strip>;
351
405
  }, z.core.$strip>;
352
406
  export type RuleSample = z.infer<typeof RuleSampleSchema>;
353
407
  export declare const RulePreviewSchema: z.ZodObject<{
354
408
  quantity: z.ZodNullable<z.ZodNumber>;
355
409
  amountCents: z.ZodNullable<z.ZodInt>;
410
+ laborCents: z.ZodNullable<z.ZodInt>;
356
411
  variables: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodNumber, z.ZodBoolean, z.ZodString]>>;
357
412
  coefficients: z.ZodRecord<z.ZodString, z.ZodNumber>;
358
413
  error: z.ZodNullable<z.ZodObject<{
@@ -389,24 +444,16 @@ export declare const PricingLimitsSchema: z.ZodObject<{
389
444
  min: z.ZodNumber;
390
445
  max: z.ZodNumber;
391
446
  }, z.core.$strip>;
447
+ missingAreaHintSqm: z.ZodNumber;
392
448
  }, z.core.$strip>;
393
449
  export type PricingLimits = z.infer<typeof PricingLimitsSchema>;
394
- export declare const BaseRateSchema: z.ZodObject<{
395
- finishLevel: z.ZodEnum<{
396
- ROUGH: "ROUGH";
397
- PRE_FINISH: "PRE_FINISH";
398
- }>;
399
- areaFromSqm: z.ZodNumber;
400
- areaToSqm: z.ZodNumber;
401
- rateCentsPerSqm: z.ZodInt;
402
- }, z.core.$strip>;
403
- export type BaseRate = z.infer<typeof BaseRateSchema>;
404
450
  export declare const PricingRuleSchema: z.ZodObject<{
405
451
  id: z.ZodString;
406
452
  level: z.ZodEnum<{
407
453
  OBJECT: "OBJECT";
408
454
  CATEGORY: "CATEGORY";
409
455
  MATERIAL_TYPE: "MATERIAL_TYPE";
456
+ SURFACE: "SURFACE";
410
457
  }>;
411
458
  categoryId: z.ZodNullable<z.ZodString>;
412
459
  materialTypeId: z.ZodNullable<z.ZodString>;
@@ -415,7 +462,14 @@ export declare const PricingRuleSchema: z.ZodObject<{
415
462
  uk: z.ZodString;
416
463
  }, z.core.$strip>;
417
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;
418
471
  costFormula: z.ZodString;
472
+ laborFormula: z.ZodNullable<z.ZodString>;
419
473
  sortOrder: z.ZodInt;
420
474
  }, z.core.$strip>;
421
475
  export type PricingRule = z.infer<typeof PricingRuleSchema>;
@@ -428,10 +482,10 @@ export declare const PricingCategorySchema: z.ZodObject<{
428
482
  id: z.ZodString;
429
483
  wastePercent: z.ZodNumber;
430
484
  surface: z.ZodEnum<{
431
- NONE: "NONE";
432
485
  FLOOR: "FLOOR";
433
486
  WALLS: "WALLS";
434
487
  CEILING: "CEILING";
488
+ NONE: "NONE";
435
489
  }>;
436
490
  }, z.core.$strip>;
437
491
  export type PricingCategory = z.infer<typeof PricingCategorySchema>;
@@ -484,6 +538,11 @@ export declare const PricingOptionSchema: z.ZodObject<{
484
538
  PROJECT: "PROJECT";
485
539
  }>;
486
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
+ }>>;
487
546
  minQuantity: z.ZodNullable<z.ZodInt>;
488
547
  maxQuantity: z.ZodNullable<z.ZodInt>;
489
548
  available: z.ZodBoolean;
@@ -516,16 +575,8 @@ export declare const PricingDataSchema: z.ZodObject<{
516
575
  min: z.ZodNumber;
517
576
  max: z.ZodNumber;
518
577
  }, z.core.$strip>;
578
+ missingAreaHintSqm: z.ZodNumber;
519
579
  }, z.core.$strip>;
520
- baseRates: z.ZodArray<z.ZodObject<{
521
- finishLevel: z.ZodEnum<{
522
- ROUGH: "ROUGH";
523
- PRE_FINISH: "PRE_FINISH";
524
- }>;
525
- areaFromSqm: z.ZodNumber;
526
- areaToSqm: z.ZodNumber;
527
- rateCentsPerSqm: z.ZodInt;
528
- }, z.core.$strip>>;
529
580
  coefficients: z.ZodRecord<z.ZodString, z.ZodNumber>;
530
581
  rules: z.ZodArray<z.ZodObject<{
531
582
  id: z.ZodString;
@@ -533,6 +584,7 @@ export declare const PricingDataSchema: z.ZodObject<{
533
584
  OBJECT: "OBJECT";
534
585
  CATEGORY: "CATEGORY";
535
586
  MATERIAL_TYPE: "MATERIAL_TYPE";
587
+ SURFACE: "SURFACE";
536
588
  }>;
537
589
  categoryId: z.ZodNullable<z.ZodString>;
538
590
  materialTypeId: z.ZodNullable<z.ZodString>;
@@ -541,7 +593,14 @@ export declare const PricingDataSchema: z.ZodObject<{
541
593
  uk: z.ZodString;
542
594
  }, z.core.$strip>;
543
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;
544
602
  costFormula: z.ZodString;
603
+ laborFormula: z.ZodNullable<z.ZodString>;
545
604
  sortOrder: z.ZodInt;
546
605
  }, z.core.$strip>>;
547
606
  roomTypes: z.ZodArray<z.ZodObject<{
@@ -552,10 +611,10 @@ export declare const PricingDataSchema: z.ZodObject<{
552
611
  id: z.ZodString;
553
612
  wastePercent: z.ZodNumber;
554
613
  surface: z.ZodEnum<{
555
- NONE: "NONE";
556
614
  FLOOR: "FLOOR";
557
615
  WALLS: "WALLS";
558
616
  CEILING: "CEILING";
617
+ NONE: "NONE";
559
618
  }>;
560
619
  }, z.core.$strip>>;
561
620
  materialTypes: z.ZodArray<z.ZodObject<{
@@ -604,6 +663,11 @@ export declare const PricingDataSchema: z.ZodObject<{
604
663
  PROJECT: "PROJECT";
605
664
  }>;
606
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
+ }>>;
607
671
  minQuantity: z.ZodNullable<z.ZodInt>;
608
672
  maxQuantity: z.ZodNullable<z.ZodInt>;
609
673
  available: z.ZodBoolean;
@@ -727,6 +791,7 @@ export interface PreviewRuleInput {
727
791
  readonly level: RuleLevel;
728
792
  readonly quantityFormula: string | null;
729
793
  readonly costFormula: string;
794
+ readonly laborFormula?: string | null;
730
795
  readonly coefficients: Readonly<Record<string, number>>;
731
796
  readonly sample: RuleSample;
732
797
  }
@@ -737,7 +802,7 @@ export declare function levenshtein(a: string, b: string): number;
737
802
  export declare function suggestNearest(name: string, candidates: readonly string[], maxDistance?: number): string | undefined;
738
803
  //#endregion
739
804
  //#region src/formula/validate.d.ts
740
- export type FormulaKind = 'quantity' | 'cost';
805
+ export type FormulaKind = 'quantity' | 'cost' | 'labor';
741
806
  export type FormulaScope = 'room' | 'product' | 'object';
742
807
  export interface FormulaVariable {
743
808
  readonly name: string;
@@ -746,6 +811,7 @@ export interface FormulaVariable {
746
811
  }
747
812
  export declare const FORMULA_SCOPE_VARIABLES: Record<FormulaScope, readonly FormulaVariable[]>;
748
813
  export declare const FORMULA_QUANTITY_VARIABLE: FormulaVariable;
814
+ export declare const FORMULA_SURFACE_AREA_VARIABLE: FormulaVariable;
749
815
  export declare const FORMULA_VARIABLES: Record<RuleLevel, readonly FormulaVariable[]>;
750
816
  export interface ValidateFormulaInput {
751
817
  readonly level: RuleLevel;
@@ -768,14 +834,19 @@ export declare function toCents(dollars: number): number;
768
834
  //#endregion
769
835
  //#region src/variables/object.d.ts
770
836
  export interface ObjectVariables {
837
+ readonly scope: Scope;
771
838
  readonly totalArea: number;
772
839
  readonly balconyArea: number;
773
840
  readonly balconyTiles: boolean;
774
- readonly kitchenType: KitchenType;
775
841
  readonly finishLevel: FinishLevel;
776
842
  readonly roomsCount: number;
777
843
  readonly bathroomsCount: number;
844
+ readonly roomsFloorArea: number;
845
+ readonly roomsWallArea: number;
846
+ readonly roomsPerimeter: number;
847
+ readonly wetRoomsCount: number;
778
848
  }
849
+ export declare function totalAreaOf(scope: Scope, totalAreaSqm: number | null, roomsFloorArea: number): number;
779
850
  export declare function objectVariables(configuration: Configuration): ObjectVariables;
780
851
  //#endregion
781
852
  //#region src/variables/product.d.ts