@roomwise/calc-engine 0.2.0 → 0.4.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/README.md CHANGED
@@ -136,8 +136,6 @@ const preview = previewRule({
136
136
  totalAreaSqm: 62,
137
137
  balconyAreaSqm: 4,
138
138
  balconyTiles: true,
139
- gas: false,
140
- kitchenType: 'SEPARATE',
141
139
  finishLevel: 'PRE_FINISH',
142
140
  roomsCount: 1,
143
141
  bathroomsCount: 1,
@@ -176,7 +174,7 @@ Every schema is a zod schema with an inferred type of the same name without the
176
174
  - Pricing data: `PricingDataSchema`, `PricingLimitsSchema`, `BaseRateSchema`, `PricingRuleSchema`, `PricingRoomTypeSchema`, `PricingCategorySchema`, `PricingMaterialTypeSchema`, `PricingProductSchema`, `PricingPackageItemSchema`, `PricingOptionSchema`, `ExchangeRateSchema`.
177
175
  - Result: `EstimateSchema`, `EstimateLineSchema`, `EstimateTotalsSchema`, `SectionTotalSchema`, `EstimateWarningSchema`, `EstimateMessageSchema`.
178
176
  - Preview: `RuleSampleSchema`, `RulePreviewSchema`.
179
- - Enums and primitives: `FinishLevelSchema`, `RuleLevelSchema`, `RateSourceSchema`, `SurfaceKindSchema`, `ProductUnitSchema`, `OptionUnitSchema`, `OptionKindSchema`, `RoomTypeCodeSchema`, `KitchenTypeSchema`, `CurrencySchema`, `SectionSchema`, `LineStatusSchema`, `LocalizedTextSchema`, `CentsSchema`, `RangeSchema`.
177
+ - Enums and primitives: `FinishLevelSchema`, `RuleLevelSchema`, `RateSourceSchema`, `SurfaceKindSchema`, `ProductUnitSchema`, `OptionUnitSchema`, `OptionKindSchema`, `RoomTypeCodeSchema`, `CurrencySchema`, `SectionSchema`, `LineStatusSchema`, `LocalizedTextSchema`, `CentsSchema`, `RangeSchema`.
180
178
 
181
179
  ## Formula language
182
180
 
@@ -202,8 +200,7 @@ roomType == 'KITCHEN' ? ceil(floorArea / 2) : 0
202
200
  | product | `waste` | number, a fraction (5% is `0.05`): the product override, else the category value |
203
201
  | product | `unit` | `SQM`, `LINEAR_M`, `PIECE` |
204
202
  | object | `totalArea`, `balconyArea` | number |
205
- | object | `balconyTiles`, `gas` | boolean |
206
- | object | `kitchenType` | `SEPARATE`, `KITCHEN_LIVING` |
203
+ | object | `balconyTiles` | boolean |
207
204
  | object | `finishLevel` | `ROUGH`, `PRE_FINISH` |
208
205
  | object | `roomsCount`, `bathroomsCount` | number (living rooms, bedrooms and kitchen-living rooms count as rooms) |
209
206
  | cost formulas only | `quantity` | the result of the quantity formula |
package/dist/index.cjs CHANGED
@@ -208,8 +208,6 @@ function objectVariables(configuration) {
208
208
  totalArea: configuration.totalAreaSqm,
209
209
  balconyArea: configuration.balconyAreaSqm,
210
210
  balconyTiles: configuration.balconyTiles,
211
- gas: configuration.gas,
212
- kitchenType: configuration.kitchenType,
213
211
  finishLevel: configuration.finishLevel,
214
212
  roomsCount: configuration.rooms.filter((room) => COUNTED_AS_ROOMS.includes(room.roomTypeCode)).length,
215
213
  bathroomsCount: configuration.rooms.filter((room) => room.roomTypeCode === "BATHROOM").length
@@ -799,7 +797,6 @@ const RoomTypeCodeSchema = zod.z.enum([
799
797
  "KITCHEN_LIVING",
800
798
  "BATHROOM"
801
799
  ]);
802
- const KitchenTypeSchema = zod.z.enum(["SEPARATE", "KITCHEN_LIVING"]);
803
800
  const CurrencySchema = zod.z.enum(["USD", "UAH"]);
804
801
  const SectionSchema = zod.z.enum([
805
802
  "BASE",
@@ -855,8 +852,6 @@ const ConfigurationSchema = zod.z.object({
855
852
  totalAreaSqm: zod.z.number().positive(),
856
853
  balconyAreaSqm: zod.z.number().min(0),
857
854
  balconyTiles: zod.z.boolean(),
858
- gas: zod.z.boolean(),
859
- kitchenType: KitchenTypeSchema,
860
855
  rooms: zod.z.array(RoomConfigurationSchema),
861
856
  options: zod.z.array(OptionSelectionSchema),
862
857
  currency: CurrencySchema
@@ -1031,8 +1026,6 @@ const RuleSampleSchema = zod.z.object({
1031
1026
  totalAreaSqm: zod.z.number().positive(),
1032
1027
  balconyAreaSqm: zod.z.number().min(0),
1033
1028
  balconyTiles: zod.z.boolean(),
1034
- gas: zod.z.boolean(),
1035
- kitchenType: KitchenTypeSchema,
1036
1029
  finishLevel: FinishLevelSchema,
1037
1030
  roomsCount: zod.z.int().min(0),
1038
1031
  bathroomsCount: zod.z.int().min(0)
@@ -1190,8 +1183,6 @@ function objectScope({ object }) {
1190
1183
  totalArea: object.totalAreaSqm,
1191
1184
  balconyArea: object.balconyAreaSqm,
1192
1185
  balconyTiles: object.balconyTiles,
1193
- gas: object.gas,
1194
- kitchenType: object.kitchenType,
1195
1186
  finishLevel: object.finishLevel,
1196
1187
  roomsCount: object.roomsCount,
1197
1188
  bathroomsCount: object.bathroomsCount
@@ -1319,8 +1310,6 @@ const FORMULA_SCOPE_VARIABLES = {
1319
1310
  number("totalArea"),
1320
1311
  number("balconyArea"),
1321
1312
  boolean("balconyTiles"),
1322
- boolean("gas"),
1323
- enumeration("kitchenType", KitchenTypeSchema.options),
1324
1313
  enumeration("finishLevel", FinishLevelSchema.options),
1325
1314
  number("roomsCount"),
1326
1315
  number("bathroomsCount")
@@ -1570,7 +1559,6 @@ exports.FORMULA_QUANTITY_VARIABLE = FORMULA_QUANTITY_VARIABLE;
1570
1559
  exports.FORMULA_SCOPE_VARIABLES = FORMULA_SCOPE_VARIABLES;
1571
1560
  exports.FORMULA_VARIABLES = FORMULA_VARIABLES;
1572
1561
  exports.FinishLevelSchema = FinishLevelSchema;
1573
- exports.KitchenTypeSchema = KitchenTypeSchema;
1574
1562
  exports.LineStatusSchema = LineStatusSchema;
1575
1563
  exports.LocalizedTextSchema = LocalizedTextSchema;
1576
1564
  exports.OptionCodeSchema = OptionCodeSchema;
package/dist/index.d.cts CHANGED
@@ -58,11 +58,6 @@ export declare const RoomTypeCodeSchema: z.ZodEnum<{
58
58
  BATHROOM: "BATHROOM";
59
59
  }>;
60
60
  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
61
  export declare const CurrencySchema: z.ZodEnum<{
67
62
  USD: "USD";
68
63
  UAH: "UAH";
@@ -132,11 +127,6 @@ export declare const ConfigurationSchema: z.ZodObject<{
132
127
  totalAreaSqm: z.ZodNumber;
133
128
  balconyAreaSqm: z.ZodNumber;
134
129
  balconyTiles: z.ZodBoolean;
135
- gas: z.ZodBoolean;
136
- kitchenType: z.ZodEnum<{
137
- KITCHEN_LIVING: "KITCHEN_LIVING";
138
- SEPARATE: "SEPARATE";
139
- }>;
140
130
  rooms: z.ZodArray<z.ZodObject<{
141
131
  clientId: z.ZodString;
142
132
  name: z.ZodOptional<z.ZodString>;
@@ -338,11 +328,6 @@ export declare const RuleSampleSchema: z.ZodObject<{
338
328
  totalAreaSqm: z.ZodNumber;
339
329
  balconyAreaSqm: z.ZodNumber;
340
330
  balconyTiles: z.ZodBoolean;
341
- gas: z.ZodBoolean;
342
- kitchenType: z.ZodEnum<{
343
- KITCHEN_LIVING: "KITCHEN_LIVING";
344
- SEPARATE: "SEPARATE";
345
- }>;
346
331
  finishLevel: z.ZodEnum<{
347
332
  ROUGH: "ROUGH";
348
333
  PRE_FINISH: "PRE_FINISH";
@@ -773,8 +758,6 @@ export interface ObjectVariables {
773
758
  readonly totalArea: number;
774
759
  readonly balconyArea: number;
775
760
  readonly balconyTiles: boolean;
776
- readonly gas: boolean;
777
- readonly kitchenType: KitchenType;
778
761
  readonly finishLevel: FinishLevel;
779
762
  readonly roomsCount: number;
780
763
  readonly bathroomsCount: number;
package/dist/index.d.ts CHANGED
@@ -58,11 +58,6 @@ export declare const RoomTypeCodeSchema: z.ZodEnum<{
58
58
  BATHROOM: "BATHROOM";
59
59
  }>;
60
60
  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
61
  export declare const CurrencySchema: z.ZodEnum<{
67
62
  USD: "USD";
68
63
  UAH: "UAH";
@@ -132,11 +127,6 @@ export declare const ConfigurationSchema: z.ZodObject<{
132
127
  totalAreaSqm: z.ZodNumber;
133
128
  balconyAreaSqm: z.ZodNumber;
134
129
  balconyTiles: z.ZodBoolean;
135
- gas: z.ZodBoolean;
136
- kitchenType: z.ZodEnum<{
137
- KITCHEN_LIVING: "KITCHEN_LIVING";
138
- SEPARATE: "SEPARATE";
139
- }>;
140
130
  rooms: z.ZodArray<z.ZodObject<{
141
131
  clientId: z.ZodString;
142
132
  name: z.ZodOptional<z.ZodString>;
@@ -338,11 +328,6 @@ export declare const RuleSampleSchema: z.ZodObject<{
338
328
  totalAreaSqm: z.ZodNumber;
339
329
  balconyAreaSqm: z.ZodNumber;
340
330
  balconyTiles: z.ZodBoolean;
341
- gas: z.ZodBoolean;
342
- kitchenType: z.ZodEnum<{
343
- KITCHEN_LIVING: "KITCHEN_LIVING";
344
- SEPARATE: "SEPARATE";
345
- }>;
346
331
  finishLevel: z.ZodEnum<{
347
332
  ROUGH: "ROUGH";
348
333
  PRE_FINISH: "PRE_FINISH";
@@ -773,8 +758,6 @@ export interface ObjectVariables {
773
758
  readonly totalArea: number;
774
759
  readonly balconyArea: number;
775
760
  readonly balconyTiles: boolean;
776
- readonly gas: boolean;
777
- readonly kitchenType: KitchenType;
778
761
  readonly finishLevel: FinishLevel;
779
762
  readonly roomsCount: number;
780
763
  readonly bathroomsCount: number;
package/dist/index.js CHANGED
@@ -183,8 +183,6 @@ function objectVariables(configuration) {
183
183
  totalArea: configuration.totalAreaSqm,
184
184
  balconyArea: configuration.balconyAreaSqm,
185
185
  balconyTiles: configuration.balconyTiles,
186
- gas: configuration.gas,
187
- kitchenType: configuration.kitchenType,
188
186
  finishLevel: configuration.finishLevel,
189
187
  roomsCount: configuration.rooms.filter((room) => COUNTED_AS_ROOMS.includes(room.roomTypeCode)).length,
190
188
  bathroomsCount: configuration.rooms.filter((room) => room.roomTypeCode === "BATHROOM").length
@@ -774,7 +772,6 @@ const RoomTypeCodeSchema = z.enum([
774
772
  "KITCHEN_LIVING",
775
773
  "BATHROOM"
776
774
  ]);
777
- const KitchenTypeSchema = z.enum(["SEPARATE", "KITCHEN_LIVING"]);
778
775
  const CurrencySchema = z.enum(["USD", "UAH"]);
779
776
  const SectionSchema = z.enum([
780
777
  "BASE",
@@ -830,8 +827,6 @@ const ConfigurationSchema = z.object({
830
827
  totalAreaSqm: z.number().positive(),
831
828
  balconyAreaSqm: z.number().min(0),
832
829
  balconyTiles: z.boolean(),
833
- gas: z.boolean(),
834
- kitchenType: KitchenTypeSchema,
835
830
  rooms: z.array(RoomConfigurationSchema),
836
831
  options: z.array(OptionSelectionSchema),
837
832
  currency: CurrencySchema
@@ -1006,8 +1001,6 @@ const RuleSampleSchema = z.object({
1006
1001
  totalAreaSqm: z.number().positive(),
1007
1002
  balconyAreaSqm: z.number().min(0),
1008
1003
  balconyTiles: z.boolean(),
1009
- gas: z.boolean(),
1010
- kitchenType: KitchenTypeSchema,
1011
1004
  finishLevel: FinishLevelSchema,
1012
1005
  roomsCount: z.int().min(0),
1013
1006
  bathroomsCount: z.int().min(0)
@@ -1165,8 +1158,6 @@ function objectScope({ object }) {
1165
1158
  totalArea: object.totalAreaSqm,
1166
1159
  balconyArea: object.balconyAreaSqm,
1167
1160
  balconyTiles: object.balconyTiles,
1168
- gas: object.gas,
1169
- kitchenType: object.kitchenType,
1170
1161
  finishLevel: object.finishLevel,
1171
1162
  roomsCount: object.roomsCount,
1172
1163
  bathroomsCount: object.bathroomsCount
@@ -1294,8 +1285,6 @@ const FORMULA_SCOPE_VARIABLES = {
1294
1285
  number("totalArea"),
1295
1286
  number("balconyArea"),
1296
1287
  boolean("balconyTiles"),
1297
- boolean("gas"),
1298
- enumeration("kitchenType", KitchenTypeSchema.options),
1299
1288
  enumeration("finishLevel", FinishLevelSchema.options),
1300
1289
  number("roomsCount"),
1301
1290
  number("bathroomsCount")
@@ -1527,4 +1516,4 @@ function validateFormula(input) {
1527
1516
  };
1528
1517
  }
1529
1518
  //#endregion
1530
- export { BaseRateSchema, COEFFICIENT_NAMESPACE, CentsSchema, ConfigurationSchema, CurrencySchema, EstimateLineSchema, EstimateMessageSchema, EstimateSchema, EstimateTotalsSchema, EstimateWarningSchema, ExchangeRateSchema, FORMULA_FUNCTIONS, FORMULA_FUNCTION_TABLE, FORMULA_LIMITS, FORMULA_QUANTITY_VARIABLE, FORMULA_SCOPE_VARIABLES, FORMULA_VARIABLES, FinishLevelSchema, KitchenTypeSchema, LineStatusSchema, LocalizedTextSchema, OptionCodeSchema, OptionKindSchema, OptionSelectionSchema, OptionUnitSchema, PricingCategorySchema, PricingDataSchema, PricingLimitsSchema, PricingMaterialTypeSchema, PricingOptionSchema, PricingPackageItemSchema, PricingProductSchema, PricingRoomTypeSchema, PricingRuleSchema, ProductUnitSchema, RangeSchema, RateSourceSchema, RoomConfigurationSchema, RoomSelectionSchema, RoomTypeCodeSchema, RuleLevelSchema, RulePreviewSchema, RuleSampleSchema, SectionSchema, SectionTotalSchema, SurfaceKindSchema, checkLimits, convertCentsToKopecks, estimate, evaluate, levenshtein, objectVariables, parse, previewRule, productVariables, productVariablesOf, roomVariables, suggestNearest, toCents, validateFormula };
1519
+ export { BaseRateSchema, COEFFICIENT_NAMESPACE, CentsSchema, ConfigurationSchema, CurrencySchema, EstimateLineSchema, EstimateMessageSchema, EstimateSchema, EstimateTotalsSchema, EstimateWarningSchema, ExchangeRateSchema, FORMULA_FUNCTIONS, FORMULA_FUNCTION_TABLE, FORMULA_LIMITS, FORMULA_QUANTITY_VARIABLE, FORMULA_SCOPE_VARIABLES, FORMULA_VARIABLES, FinishLevelSchema, LineStatusSchema, LocalizedTextSchema, OptionCodeSchema, OptionKindSchema, OptionSelectionSchema, OptionUnitSchema, PricingCategorySchema, PricingDataSchema, PricingLimitsSchema, PricingMaterialTypeSchema, PricingOptionSchema, PricingPackageItemSchema, PricingProductSchema, PricingRoomTypeSchema, PricingRuleSchema, ProductUnitSchema, RangeSchema, RateSourceSchema, RoomConfigurationSchema, RoomSelectionSchema, RoomTypeCodeSchema, RuleLevelSchema, RulePreviewSchema, RuleSampleSchema, SectionSchema, SectionTotalSchema, SurfaceKindSchema, checkLimits, convertCentsToKopecks, estimate, evaluate, levenshtein, objectVariables, parse, previewRule, productVariables, productVariablesOf, roomVariables, suggestNearest, toCents, validateFormula };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@roomwise/calc-engine",
3
- "version": "0.2.0",
3
+ "version": "0.4.0",
4
4
  "type": "module",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.js",