@roomwise/calc-engine 0.3.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 +1 -3
- package/dist/index.cjs +0 -7
- package/dist/index.d.cts +0 -14
- package/dist/index.d.ts +0 -14
- package/dist/index.js +1 -7
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -136,7 +136,6 @@ const preview = previewRule({
|
|
|
136
136
|
totalAreaSqm: 62,
|
|
137
137
|
balconyAreaSqm: 4,
|
|
138
138
|
balconyTiles: true,
|
|
139
|
-
kitchenType: 'SEPARATE',
|
|
140
139
|
finishLevel: 'PRE_FINISH',
|
|
141
140
|
roomsCount: 1,
|
|
142
141
|
bathroomsCount: 1,
|
|
@@ -175,7 +174,7 @@ Every schema is a zod schema with an inferred type of the same name without the
|
|
|
175
174
|
- Pricing data: `PricingDataSchema`, `PricingLimitsSchema`, `BaseRateSchema`, `PricingRuleSchema`, `PricingRoomTypeSchema`, `PricingCategorySchema`, `PricingMaterialTypeSchema`, `PricingProductSchema`, `PricingPackageItemSchema`, `PricingOptionSchema`, `ExchangeRateSchema`.
|
|
176
175
|
- Result: `EstimateSchema`, `EstimateLineSchema`, `EstimateTotalsSchema`, `SectionTotalSchema`, `EstimateWarningSchema`, `EstimateMessageSchema`.
|
|
177
176
|
- Preview: `RuleSampleSchema`, `RulePreviewSchema`.
|
|
178
|
-
- Enums and primitives: `FinishLevelSchema`, `RuleLevelSchema`, `RateSourceSchema`, `SurfaceKindSchema`, `ProductUnitSchema`, `OptionUnitSchema`, `OptionKindSchema`, `RoomTypeCodeSchema`, `
|
|
177
|
+
- Enums and primitives: `FinishLevelSchema`, `RuleLevelSchema`, `RateSourceSchema`, `SurfaceKindSchema`, `ProductUnitSchema`, `OptionUnitSchema`, `OptionKindSchema`, `RoomTypeCodeSchema`, `CurrencySchema`, `SectionSchema`, `LineStatusSchema`, `LocalizedTextSchema`, `CentsSchema`, `RangeSchema`.
|
|
179
178
|
|
|
180
179
|
## Formula language
|
|
181
180
|
|
|
@@ -202,7 +201,6 @@ roomType == 'KITCHEN' ? ceil(floorArea / 2) : 0
|
|
|
202
201
|
| product | `unit` | `SQM`, `LINEAR_M`, `PIECE` |
|
|
203
202
|
| object | `totalArea`, `balconyArea` | number |
|
|
204
203
|
| object | `balconyTiles` | boolean |
|
|
205
|
-
| object | `kitchenType` | `SEPARATE`, `KITCHEN_LIVING` |
|
|
206
204
|
| object | `finishLevel` | `ROUGH`, `PRE_FINISH` |
|
|
207
205
|
| object | `roomsCount`, `bathroomsCount` | number (living rooms, bedrooms and kitchen-living rooms count as rooms) |
|
|
208
206
|
| cost formulas only | `quantity` | the result of the quantity formula |
|
package/dist/index.cjs
CHANGED
|
@@ -208,7 +208,6 @@ function objectVariables(configuration) {
|
|
|
208
208
|
totalArea: configuration.totalAreaSqm,
|
|
209
209
|
balconyArea: configuration.balconyAreaSqm,
|
|
210
210
|
balconyTiles: configuration.balconyTiles,
|
|
211
|
-
kitchenType: configuration.kitchenType,
|
|
212
211
|
finishLevel: configuration.finishLevel,
|
|
213
212
|
roomsCount: configuration.rooms.filter((room) => COUNTED_AS_ROOMS.includes(room.roomTypeCode)).length,
|
|
214
213
|
bathroomsCount: configuration.rooms.filter((room) => room.roomTypeCode === "BATHROOM").length
|
|
@@ -798,7 +797,6 @@ const RoomTypeCodeSchema = zod.z.enum([
|
|
|
798
797
|
"KITCHEN_LIVING",
|
|
799
798
|
"BATHROOM"
|
|
800
799
|
]);
|
|
801
|
-
const KitchenTypeSchema = zod.z.enum(["SEPARATE", "KITCHEN_LIVING"]);
|
|
802
800
|
const CurrencySchema = zod.z.enum(["USD", "UAH"]);
|
|
803
801
|
const SectionSchema = zod.z.enum([
|
|
804
802
|
"BASE",
|
|
@@ -854,7 +852,6 @@ const ConfigurationSchema = zod.z.object({
|
|
|
854
852
|
totalAreaSqm: zod.z.number().positive(),
|
|
855
853
|
balconyAreaSqm: zod.z.number().min(0),
|
|
856
854
|
balconyTiles: zod.z.boolean(),
|
|
857
|
-
kitchenType: KitchenTypeSchema,
|
|
858
855
|
rooms: zod.z.array(RoomConfigurationSchema),
|
|
859
856
|
options: zod.z.array(OptionSelectionSchema),
|
|
860
857
|
currency: CurrencySchema
|
|
@@ -1029,7 +1026,6 @@ const RuleSampleSchema = zod.z.object({
|
|
|
1029
1026
|
totalAreaSqm: zod.z.number().positive(),
|
|
1030
1027
|
balconyAreaSqm: zod.z.number().min(0),
|
|
1031
1028
|
balconyTiles: zod.z.boolean(),
|
|
1032
|
-
kitchenType: KitchenTypeSchema,
|
|
1033
1029
|
finishLevel: FinishLevelSchema,
|
|
1034
1030
|
roomsCount: zod.z.int().min(0),
|
|
1035
1031
|
bathroomsCount: zod.z.int().min(0)
|
|
@@ -1187,7 +1183,6 @@ function objectScope({ object }) {
|
|
|
1187
1183
|
totalArea: object.totalAreaSqm,
|
|
1188
1184
|
balconyArea: object.balconyAreaSqm,
|
|
1189
1185
|
balconyTiles: object.balconyTiles,
|
|
1190
|
-
kitchenType: object.kitchenType,
|
|
1191
1186
|
finishLevel: object.finishLevel,
|
|
1192
1187
|
roomsCount: object.roomsCount,
|
|
1193
1188
|
bathroomsCount: object.bathroomsCount
|
|
@@ -1315,7 +1310,6 @@ const FORMULA_SCOPE_VARIABLES = {
|
|
|
1315
1310
|
number("totalArea"),
|
|
1316
1311
|
number("balconyArea"),
|
|
1317
1312
|
boolean("balconyTiles"),
|
|
1318
|
-
enumeration("kitchenType", KitchenTypeSchema.options),
|
|
1319
1313
|
enumeration("finishLevel", FinishLevelSchema.options),
|
|
1320
1314
|
number("roomsCount"),
|
|
1321
1315
|
number("bathroomsCount")
|
|
@@ -1565,7 +1559,6 @@ exports.FORMULA_QUANTITY_VARIABLE = FORMULA_QUANTITY_VARIABLE;
|
|
|
1565
1559
|
exports.FORMULA_SCOPE_VARIABLES = FORMULA_SCOPE_VARIABLES;
|
|
1566
1560
|
exports.FORMULA_VARIABLES = FORMULA_VARIABLES;
|
|
1567
1561
|
exports.FinishLevelSchema = FinishLevelSchema;
|
|
1568
|
-
exports.KitchenTypeSchema = KitchenTypeSchema;
|
|
1569
1562
|
exports.LineStatusSchema = LineStatusSchema;
|
|
1570
1563
|
exports.LocalizedTextSchema = LocalizedTextSchema;
|
|
1571
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,10 +127,6 @@ export declare const ConfigurationSchema: z.ZodObject<{
|
|
|
132
127
|
totalAreaSqm: z.ZodNumber;
|
|
133
128
|
balconyAreaSqm: z.ZodNumber;
|
|
134
129
|
balconyTiles: z.ZodBoolean;
|
|
135
|
-
kitchenType: z.ZodEnum<{
|
|
136
|
-
KITCHEN_LIVING: "KITCHEN_LIVING";
|
|
137
|
-
SEPARATE: "SEPARATE";
|
|
138
|
-
}>;
|
|
139
130
|
rooms: z.ZodArray<z.ZodObject<{
|
|
140
131
|
clientId: z.ZodString;
|
|
141
132
|
name: z.ZodOptional<z.ZodString>;
|
|
@@ -337,10 +328,6 @@ export declare const RuleSampleSchema: z.ZodObject<{
|
|
|
337
328
|
totalAreaSqm: z.ZodNumber;
|
|
338
329
|
balconyAreaSqm: z.ZodNumber;
|
|
339
330
|
balconyTiles: z.ZodBoolean;
|
|
340
|
-
kitchenType: z.ZodEnum<{
|
|
341
|
-
KITCHEN_LIVING: "KITCHEN_LIVING";
|
|
342
|
-
SEPARATE: "SEPARATE";
|
|
343
|
-
}>;
|
|
344
331
|
finishLevel: z.ZodEnum<{
|
|
345
332
|
ROUGH: "ROUGH";
|
|
346
333
|
PRE_FINISH: "PRE_FINISH";
|
|
@@ -771,7 +758,6 @@ export interface ObjectVariables {
|
|
|
771
758
|
readonly totalArea: number;
|
|
772
759
|
readonly balconyArea: number;
|
|
773
760
|
readonly balconyTiles: boolean;
|
|
774
|
-
readonly kitchenType: KitchenType;
|
|
775
761
|
readonly finishLevel: FinishLevel;
|
|
776
762
|
readonly roomsCount: number;
|
|
777
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,10 +127,6 @@ export declare const ConfigurationSchema: z.ZodObject<{
|
|
|
132
127
|
totalAreaSqm: z.ZodNumber;
|
|
133
128
|
balconyAreaSqm: z.ZodNumber;
|
|
134
129
|
balconyTiles: z.ZodBoolean;
|
|
135
|
-
kitchenType: z.ZodEnum<{
|
|
136
|
-
KITCHEN_LIVING: "KITCHEN_LIVING";
|
|
137
|
-
SEPARATE: "SEPARATE";
|
|
138
|
-
}>;
|
|
139
130
|
rooms: z.ZodArray<z.ZodObject<{
|
|
140
131
|
clientId: z.ZodString;
|
|
141
132
|
name: z.ZodOptional<z.ZodString>;
|
|
@@ -337,10 +328,6 @@ export declare const RuleSampleSchema: z.ZodObject<{
|
|
|
337
328
|
totalAreaSqm: z.ZodNumber;
|
|
338
329
|
balconyAreaSqm: z.ZodNumber;
|
|
339
330
|
balconyTiles: z.ZodBoolean;
|
|
340
|
-
kitchenType: z.ZodEnum<{
|
|
341
|
-
KITCHEN_LIVING: "KITCHEN_LIVING";
|
|
342
|
-
SEPARATE: "SEPARATE";
|
|
343
|
-
}>;
|
|
344
331
|
finishLevel: z.ZodEnum<{
|
|
345
332
|
ROUGH: "ROUGH";
|
|
346
333
|
PRE_FINISH: "PRE_FINISH";
|
|
@@ -771,7 +758,6 @@ export interface ObjectVariables {
|
|
|
771
758
|
readonly totalArea: number;
|
|
772
759
|
readonly balconyArea: number;
|
|
773
760
|
readonly balconyTiles: boolean;
|
|
774
|
-
readonly kitchenType: KitchenType;
|
|
775
761
|
readonly finishLevel: FinishLevel;
|
|
776
762
|
readonly roomsCount: number;
|
|
777
763
|
readonly bathroomsCount: number;
|
package/dist/index.js
CHANGED
|
@@ -183,7 +183,6 @@ function objectVariables(configuration) {
|
|
|
183
183
|
totalArea: configuration.totalAreaSqm,
|
|
184
184
|
balconyArea: configuration.balconyAreaSqm,
|
|
185
185
|
balconyTiles: configuration.balconyTiles,
|
|
186
|
-
kitchenType: configuration.kitchenType,
|
|
187
186
|
finishLevel: configuration.finishLevel,
|
|
188
187
|
roomsCount: configuration.rooms.filter((room) => COUNTED_AS_ROOMS.includes(room.roomTypeCode)).length,
|
|
189
188
|
bathroomsCount: configuration.rooms.filter((room) => room.roomTypeCode === "BATHROOM").length
|
|
@@ -773,7 +772,6 @@ const RoomTypeCodeSchema = z.enum([
|
|
|
773
772
|
"KITCHEN_LIVING",
|
|
774
773
|
"BATHROOM"
|
|
775
774
|
]);
|
|
776
|
-
const KitchenTypeSchema = z.enum(["SEPARATE", "KITCHEN_LIVING"]);
|
|
777
775
|
const CurrencySchema = z.enum(["USD", "UAH"]);
|
|
778
776
|
const SectionSchema = z.enum([
|
|
779
777
|
"BASE",
|
|
@@ -829,7 +827,6 @@ const ConfigurationSchema = z.object({
|
|
|
829
827
|
totalAreaSqm: z.number().positive(),
|
|
830
828
|
balconyAreaSqm: z.number().min(0),
|
|
831
829
|
balconyTiles: z.boolean(),
|
|
832
|
-
kitchenType: KitchenTypeSchema,
|
|
833
830
|
rooms: z.array(RoomConfigurationSchema),
|
|
834
831
|
options: z.array(OptionSelectionSchema),
|
|
835
832
|
currency: CurrencySchema
|
|
@@ -1004,7 +1001,6 @@ const RuleSampleSchema = z.object({
|
|
|
1004
1001
|
totalAreaSqm: z.number().positive(),
|
|
1005
1002
|
balconyAreaSqm: z.number().min(0),
|
|
1006
1003
|
balconyTiles: z.boolean(),
|
|
1007
|
-
kitchenType: KitchenTypeSchema,
|
|
1008
1004
|
finishLevel: FinishLevelSchema,
|
|
1009
1005
|
roomsCount: z.int().min(0),
|
|
1010
1006
|
bathroomsCount: z.int().min(0)
|
|
@@ -1162,7 +1158,6 @@ function objectScope({ object }) {
|
|
|
1162
1158
|
totalArea: object.totalAreaSqm,
|
|
1163
1159
|
balconyArea: object.balconyAreaSqm,
|
|
1164
1160
|
balconyTiles: object.balconyTiles,
|
|
1165
|
-
kitchenType: object.kitchenType,
|
|
1166
1161
|
finishLevel: object.finishLevel,
|
|
1167
1162
|
roomsCount: object.roomsCount,
|
|
1168
1163
|
bathroomsCount: object.bathroomsCount
|
|
@@ -1290,7 +1285,6 @@ const FORMULA_SCOPE_VARIABLES = {
|
|
|
1290
1285
|
number("totalArea"),
|
|
1291
1286
|
number("balconyArea"),
|
|
1292
1287
|
boolean("balconyTiles"),
|
|
1293
|
-
enumeration("kitchenType", KitchenTypeSchema.options),
|
|
1294
1288
|
enumeration("finishLevel", FinishLevelSchema.options),
|
|
1295
1289
|
number("roomsCount"),
|
|
1296
1290
|
number("bathroomsCount")
|
|
@@ -1522,4 +1516,4 @@ function validateFormula(input) {
|
|
|
1522
1516
|
};
|
|
1523
1517
|
}
|
|
1524
1518
|
//#endregion
|
|
1525
|
-
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,
|
|
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 };
|