@roomwise/calc-engine 0.1.0 → 0.2.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.cjs +5 -1
- package/dist/index.d.cts +12 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +5 -2
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -118,7 +118,7 @@ function optionLine(configuration, option, selection) {
|
|
|
118
118
|
params: { optionId: option.id }
|
|
119
119
|
});
|
|
120
120
|
const selected = configuration.rooms.filter((room) => selection.roomClientIds?.includes(room.clientId));
|
|
121
|
-
const allowed = selected.filter((room) => option.roomTypeCodes.includes(room.roomTypeCode));
|
|
121
|
+
const allowed = option.roomTypeCodes.length === 0 ? selected : selected.filter((room) => option.roomTypeCodes.includes(room.roomTypeCode));
|
|
122
122
|
const rejected = selected.filter((room) => !allowed.includes(room));
|
|
123
123
|
const quantity = unitQuantity(option.unit, allowed, selection.quantity ?? option.minQuantity ?? 1);
|
|
124
124
|
return pricedLine({
|
|
@@ -791,6 +791,7 @@ const OptionUnitSchema = zod.z.enum([
|
|
|
791
791
|
"PROJECT"
|
|
792
792
|
]);
|
|
793
793
|
const OptionKindSchema = zod.z.enum(["ENGINEERING", "ADDITIONAL"]);
|
|
794
|
+
const OptionCodeSchema = zod.z.enum(["HEATED_FLOOR"]);
|
|
794
795
|
const RoomTypeCodeSchema = zod.z.enum([
|
|
795
796
|
"LIVING_ROOM",
|
|
796
797
|
"BEDROOM",
|
|
@@ -827,6 +828,7 @@ const RoomSelectionSchema = zod.z.object({
|
|
|
827
828
|
});
|
|
828
829
|
const RoomConfigurationSchema = zod.z.object({
|
|
829
830
|
clientId: zod.z.string(),
|
|
831
|
+
name: zod.z.string().trim().min(1).max(60).optional(),
|
|
830
832
|
roomTypeCode: RoomTypeCodeSchema,
|
|
831
833
|
lengthM: zod.z.number().positive(),
|
|
832
834
|
widthM: zod.z.number().positive(),
|
|
@@ -944,6 +946,7 @@ const PricingPackageItemSchema = zod.z.object({
|
|
|
944
946
|
});
|
|
945
947
|
const PricingOptionSchema = zod.z.object({
|
|
946
948
|
id: zod.z.string(),
|
|
949
|
+
code: OptionCodeSchema.nullable(),
|
|
947
950
|
kind: OptionKindSchema,
|
|
948
951
|
priceCents: CentsSchema,
|
|
949
952
|
unit: OptionUnitSchema,
|
|
@@ -1570,6 +1573,7 @@ exports.FinishLevelSchema = FinishLevelSchema;
|
|
|
1570
1573
|
exports.KitchenTypeSchema = KitchenTypeSchema;
|
|
1571
1574
|
exports.LineStatusSchema = LineStatusSchema;
|
|
1572
1575
|
exports.LocalizedTextSchema = LocalizedTextSchema;
|
|
1576
|
+
exports.OptionCodeSchema = OptionCodeSchema;
|
|
1573
1577
|
exports.OptionKindSchema = OptionKindSchema;
|
|
1574
1578
|
exports.OptionSelectionSchema = OptionSelectionSchema;
|
|
1575
1579
|
exports.OptionUnitSchema = OptionUnitSchema;
|
package/dist/index.d.cts
CHANGED
|
@@ -46,6 +46,10 @@ export declare const OptionKindSchema: z.ZodEnum<{
|
|
|
46
46
|
ADDITIONAL: "ADDITIONAL";
|
|
47
47
|
}>;
|
|
48
48
|
export type OptionKind = z.infer<typeof OptionKindSchema>;
|
|
49
|
+
export declare const OptionCodeSchema: z.ZodEnum<{
|
|
50
|
+
HEATED_FLOOR: "HEATED_FLOOR";
|
|
51
|
+
}>;
|
|
52
|
+
export type OptionCode = z.infer<typeof OptionCodeSchema>;
|
|
49
53
|
export declare const RoomTypeCodeSchema: z.ZodEnum<{
|
|
50
54
|
LIVING_ROOM: "LIVING_ROOM";
|
|
51
55
|
BEDROOM: "BEDROOM";
|
|
@@ -96,6 +100,7 @@ export declare const RoomSelectionSchema: z.ZodObject<{
|
|
|
96
100
|
export type RoomSelection = z.infer<typeof RoomSelectionSchema>;
|
|
97
101
|
export declare const RoomConfigurationSchema: z.ZodObject<{
|
|
98
102
|
clientId: z.ZodString;
|
|
103
|
+
name: z.ZodOptional<z.ZodString>;
|
|
99
104
|
roomTypeCode: z.ZodEnum<{
|
|
100
105
|
LIVING_ROOM: "LIVING_ROOM";
|
|
101
106
|
BEDROOM: "BEDROOM";
|
|
@@ -134,6 +139,7 @@ export declare const ConfigurationSchema: z.ZodObject<{
|
|
|
134
139
|
}>;
|
|
135
140
|
rooms: z.ZodArray<z.ZodObject<{
|
|
136
141
|
clientId: z.ZodString;
|
|
142
|
+
name: z.ZodOptional<z.ZodString>;
|
|
137
143
|
roomTypeCode: z.ZodEnum<{
|
|
138
144
|
LIVING_ROOM: "LIVING_ROOM";
|
|
139
145
|
BEDROOM: "BEDROOM";
|
|
@@ -465,6 +471,9 @@ export declare const PricingPackageItemSchema: z.ZodObject<{
|
|
|
465
471
|
export type PricingPackageItem = z.infer<typeof PricingPackageItemSchema>;
|
|
466
472
|
export declare const PricingOptionSchema: z.ZodObject<{
|
|
467
473
|
id: z.ZodString;
|
|
474
|
+
code: z.ZodNullable<z.ZodEnum<{
|
|
475
|
+
HEATED_FLOOR: "HEATED_FLOOR";
|
|
476
|
+
}>>;
|
|
468
477
|
kind: z.ZodEnum<{
|
|
469
478
|
ENGINEERING: "ENGINEERING";
|
|
470
479
|
ADDITIONAL: "ADDITIONAL";
|
|
@@ -582,6 +591,9 @@ export declare const PricingDataSchema: z.ZodObject<{
|
|
|
582
591
|
}, z.core.$strip>>;
|
|
583
592
|
options: z.ZodArray<z.ZodObject<{
|
|
584
593
|
id: z.ZodString;
|
|
594
|
+
code: z.ZodNullable<z.ZodEnum<{
|
|
595
|
+
HEATED_FLOOR: "HEATED_FLOOR";
|
|
596
|
+
}>>;
|
|
585
597
|
kind: z.ZodEnum<{
|
|
586
598
|
ENGINEERING: "ENGINEERING";
|
|
587
599
|
ADDITIONAL: "ADDITIONAL";
|
package/dist/index.d.ts
CHANGED
|
@@ -46,6 +46,10 @@ export declare const OptionKindSchema: z.ZodEnum<{
|
|
|
46
46
|
ADDITIONAL: "ADDITIONAL";
|
|
47
47
|
}>;
|
|
48
48
|
export type OptionKind = z.infer<typeof OptionKindSchema>;
|
|
49
|
+
export declare const OptionCodeSchema: z.ZodEnum<{
|
|
50
|
+
HEATED_FLOOR: "HEATED_FLOOR";
|
|
51
|
+
}>;
|
|
52
|
+
export type OptionCode = z.infer<typeof OptionCodeSchema>;
|
|
49
53
|
export declare const RoomTypeCodeSchema: z.ZodEnum<{
|
|
50
54
|
LIVING_ROOM: "LIVING_ROOM";
|
|
51
55
|
BEDROOM: "BEDROOM";
|
|
@@ -96,6 +100,7 @@ export declare const RoomSelectionSchema: z.ZodObject<{
|
|
|
96
100
|
export type RoomSelection = z.infer<typeof RoomSelectionSchema>;
|
|
97
101
|
export declare const RoomConfigurationSchema: z.ZodObject<{
|
|
98
102
|
clientId: z.ZodString;
|
|
103
|
+
name: z.ZodOptional<z.ZodString>;
|
|
99
104
|
roomTypeCode: z.ZodEnum<{
|
|
100
105
|
LIVING_ROOM: "LIVING_ROOM";
|
|
101
106
|
BEDROOM: "BEDROOM";
|
|
@@ -134,6 +139,7 @@ export declare const ConfigurationSchema: z.ZodObject<{
|
|
|
134
139
|
}>;
|
|
135
140
|
rooms: z.ZodArray<z.ZodObject<{
|
|
136
141
|
clientId: z.ZodString;
|
|
142
|
+
name: z.ZodOptional<z.ZodString>;
|
|
137
143
|
roomTypeCode: z.ZodEnum<{
|
|
138
144
|
LIVING_ROOM: "LIVING_ROOM";
|
|
139
145
|
BEDROOM: "BEDROOM";
|
|
@@ -465,6 +471,9 @@ export declare const PricingPackageItemSchema: z.ZodObject<{
|
|
|
465
471
|
export type PricingPackageItem = z.infer<typeof PricingPackageItemSchema>;
|
|
466
472
|
export declare const PricingOptionSchema: z.ZodObject<{
|
|
467
473
|
id: z.ZodString;
|
|
474
|
+
code: z.ZodNullable<z.ZodEnum<{
|
|
475
|
+
HEATED_FLOOR: "HEATED_FLOOR";
|
|
476
|
+
}>>;
|
|
468
477
|
kind: z.ZodEnum<{
|
|
469
478
|
ENGINEERING: "ENGINEERING";
|
|
470
479
|
ADDITIONAL: "ADDITIONAL";
|
|
@@ -582,6 +591,9 @@ export declare const PricingDataSchema: z.ZodObject<{
|
|
|
582
591
|
}, z.core.$strip>>;
|
|
583
592
|
options: z.ZodArray<z.ZodObject<{
|
|
584
593
|
id: z.ZodString;
|
|
594
|
+
code: z.ZodNullable<z.ZodEnum<{
|
|
595
|
+
HEATED_FLOOR: "HEATED_FLOOR";
|
|
596
|
+
}>>;
|
|
585
597
|
kind: z.ZodEnum<{
|
|
586
598
|
ENGINEERING: "ENGINEERING";
|
|
587
599
|
ADDITIONAL: "ADDITIONAL";
|
package/dist/index.js
CHANGED
|
@@ -93,7 +93,7 @@ function optionLine(configuration, option, selection) {
|
|
|
93
93
|
params: { optionId: option.id }
|
|
94
94
|
});
|
|
95
95
|
const selected = configuration.rooms.filter((room) => selection.roomClientIds?.includes(room.clientId));
|
|
96
|
-
const allowed = selected.filter((room) => option.roomTypeCodes.includes(room.roomTypeCode));
|
|
96
|
+
const allowed = option.roomTypeCodes.length === 0 ? selected : selected.filter((room) => option.roomTypeCodes.includes(room.roomTypeCode));
|
|
97
97
|
const rejected = selected.filter((room) => !allowed.includes(room));
|
|
98
98
|
const quantity = unitQuantity(option.unit, allowed, selection.quantity ?? option.minQuantity ?? 1);
|
|
99
99
|
return pricedLine({
|
|
@@ -766,6 +766,7 @@ const OptionUnitSchema = z.enum([
|
|
|
766
766
|
"PROJECT"
|
|
767
767
|
]);
|
|
768
768
|
const OptionKindSchema = z.enum(["ENGINEERING", "ADDITIONAL"]);
|
|
769
|
+
const OptionCodeSchema = z.enum(["HEATED_FLOOR"]);
|
|
769
770
|
const RoomTypeCodeSchema = z.enum([
|
|
770
771
|
"LIVING_ROOM",
|
|
771
772
|
"BEDROOM",
|
|
@@ -802,6 +803,7 @@ const RoomSelectionSchema = z.object({
|
|
|
802
803
|
});
|
|
803
804
|
const RoomConfigurationSchema = z.object({
|
|
804
805
|
clientId: z.string(),
|
|
806
|
+
name: z.string().trim().min(1).max(60).optional(),
|
|
805
807
|
roomTypeCode: RoomTypeCodeSchema,
|
|
806
808
|
lengthM: z.number().positive(),
|
|
807
809
|
widthM: z.number().positive(),
|
|
@@ -919,6 +921,7 @@ const PricingPackageItemSchema = z.object({
|
|
|
919
921
|
});
|
|
920
922
|
const PricingOptionSchema = z.object({
|
|
921
923
|
id: z.string(),
|
|
924
|
+
code: OptionCodeSchema.nullable(),
|
|
922
925
|
kind: OptionKindSchema,
|
|
923
926
|
priceCents: CentsSchema,
|
|
924
927
|
unit: OptionUnitSchema,
|
|
@@ -1524,4 +1527,4 @@ function validateFormula(input) {
|
|
|
1524
1527
|
};
|
|
1525
1528
|
}
|
|
1526
1529
|
//#endregion
|
|
1527
|
-
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, 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 };
|
|
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 };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@roomwise/calc-engine",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.cjs",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -50,6 +50,6 @@
|
|
|
50
50
|
"tsdown": "^0.23.0",
|
|
51
51
|
"typescript": "^5.9.3",
|
|
52
52
|
"vitest": "^4.1.11",
|
|
53
|
-
"zod": "4.6.
|
|
53
|
+
"zod": "4.6.6"
|
|
54
54
|
}
|
|
55
55
|
}
|