@ecogood/e-calculator-schemas 2.7.10 → 2.7.13

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.
@@ -0,0 +1,88 @@
1
+ import { z } from 'zod';
2
+ export declare const OrganizationRequestSchema: z.ZodObject<{
3
+ name: z.ZodString;
4
+ address: z.ZodObject<{
5
+ city: z.ZodString;
6
+ houseNumber: z.ZodString;
7
+ street: z.ZodString;
8
+ zip: z.ZodString;
9
+ }, "strip", z.ZodTypeAny, {
10
+ city: string;
11
+ houseNumber: string;
12
+ street: string;
13
+ zip: string;
14
+ }, {
15
+ city: string;
16
+ houseNumber: string;
17
+ street: string;
18
+ zip: string;
19
+ }>;
20
+ }, "strip", z.ZodTypeAny, {
21
+ name: string;
22
+ address: {
23
+ city: string;
24
+ houseNumber: string;
25
+ street: string;
26
+ zip: string;
27
+ };
28
+ }, {
29
+ name: string;
30
+ address: {
31
+ city: string;
32
+ houseNumber: string;
33
+ street: string;
34
+ zip: string;
35
+ };
36
+ }>;
37
+ export declare const OrganizationResponseSchema: z.ZodObject<z.objectUtil.extendShape<{
38
+ name: z.ZodString;
39
+ address: z.ZodObject<{
40
+ city: z.ZodString;
41
+ houseNumber: z.ZodString;
42
+ street: z.ZodString;
43
+ zip: z.ZodString;
44
+ }, "strip", z.ZodTypeAny, {
45
+ city: string;
46
+ houseNumber: string;
47
+ street: string;
48
+ zip: string;
49
+ }, {
50
+ city: string;
51
+ houseNumber: string;
52
+ street: string;
53
+ zip: string;
54
+ }>;
55
+ }, {
56
+ id: z.ZodNumber;
57
+ invitations: z.ZodArray<z.ZodString, "many">;
58
+ }>, "strip", z.ZodTypeAny, {
59
+ name: string;
60
+ id: number;
61
+ address: {
62
+ city: string;
63
+ houseNumber: string;
64
+ street: string;
65
+ zip: string;
66
+ };
67
+ invitations: string[];
68
+ }, {
69
+ name: string;
70
+ id: number;
71
+ address: {
72
+ city: string;
73
+ houseNumber: string;
74
+ street: string;
75
+ zip: string;
76
+ };
77
+ invitations: string[];
78
+ }>;
79
+ export declare const OrganizationItemsResponseSchema: z.ZodArray<z.ZodObject<{
80
+ id: z.ZodNumber;
81
+ name: z.ZodString;
82
+ }, "strip", z.ZodTypeAny, {
83
+ name: string;
84
+ id: number;
85
+ }, {
86
+ name: string;
87
+ id: number;
88
+ }>, "many">;
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.OrganizationItemsResponseSchema = exports.OrganizationResponseSchema = exports.OrganizationRequestSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ const errorMsg = 'Must not be blank';
6
+ const isNonEmptyString = zod_1.z
7
+ .string({ required_error: errorMsg })
8
+ .min(1, { message: errorMsg });
9
+ exports.OrganizationRequestSchema = zod_1.z.object({
10
+ name: isNonEmptyString,
11
+ address: zod_1.z.object({
12
+ city: isNonEmptyString,
13
+ houseNumber: isNonEmptyString,
14
+ street: isNonEmptyString,
15
+ zip: isNonEmptyString,
16
+ }),
17
+ });
18
+ exports.OrganizationResponseSchema = exports.OrganizationRequestSchema.extend({
19
+ id: zod_1.z.number(),
20
+ invitations: zod_1.z.string().email().array(),
21
+ });
22
+ exports.OrganizationItemsResponseSchema = zod_1.z
23
+ .object({ id: zod_1.z.number(), name: isNonEmptyString })
24
+ .array();
@@ -0,0 +1,69 @@
1
+ import { z } from 'zod';
2
+ export declare const RatingRequestBodySchema: z.ZodObject<{
3
+ shortName: z.ZodString;
4
+ weight: z.ZodOptional<z.ZodEffects<z.ZodNumber, number, number>>;
5
+ estimations: z.ZodOptional<z.ZodNumber>;
6
+ }, "strip", z.ZodTypeAny, {
7
+ shortName: string;
8
+ weight?: number | undefined;
9
+ estimations?: number | undefined;
10
+ }, {
11
+ shortName: string;
12
+ weight?: number | undefined;
13
+ estimations?: number | undefined;
14
+ }>;
15
+ export declare enum RatingType {
16
+ topic = "topic",
17
+ aspect = "aspect"
18
+ }
19
+ export declare const RatingResponseBodySchema: z.ZodEffects<z.ZodObject<{
20
+ shortName: z.ZodString;
21
+ name: z.ZodString;
22
+ type: z.ZodNativeEnum<typeof RatingType>;
23
+ isPositive: z.ZodBoolean;
24
+ estimations: z.ZodNumber;
25
+ weight: z.ZodNumber;
26
+ isWeightSelectedByUser: z.ZodBoolean;
27
+ points: z.ZodNumber;
28
+ maxPoints: z.ZodNumber;
29
+ }, "strip", z.ZodTypeAny, {
30
+ name: string;
31
+ type: RatingType;
32
+ shortName: string;
33
+ weight: number;
34
+ estimations: number;
35
+ isPositive: boolean;
36
+ isWeightSelectedByUser: boolean;
37
+ points: number;
38
+ maxPoints: number;
39
+ }, {
40
+ name: string;
41
+ type: RatingType;
42
+ shortName: string;
43
+ weight: number;
44
+ estimations: number;
45
+ isPositive: boolean;
46
+ isWeightSelectedByUser: boolean;
47
+ points: number;
48
+ maxPoints: number;
49
+ }>, {
50
+ name: string;
51
+ type: RatingType;
52
+ shortName: string;
53
+ weight: number;
54
+ estimations: number;
55
+ isPositive: boolean;
56
+ isWeightSelectedByUser: boolean;
57
+ points: number;
58
+ maxPoints: number;
59
+ }, {
60
+ name: string;
61
+ type: RatingType;
62
+ shortName: string;
63
+ weight: number;
64
+ estimations: number;
65
+ isPositive: boolean;
66
+ isWeightSelectedByUser: boolean;
67
+ points: number;
68
+ maxPoints: number;
69
+ }>;
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RatingResponseBodySchema = exports.RatingType = exports.RatingRequestBodySchema = void 0;
4
+ const zod_1 = require("zod");
5
+ const shared_schemas_1 = require("./shared.schemas");
6
+ exports.RatingRequestBodySchema = zod_1.z.object({
7
+ shortName: zod_1.z.string(),
8
+ weight: shared_schemas_1.isWeightOptional,
9
+ estimations: zod_1.z.number().min(-200).max(10).optional(),
10
+ });
11
+ var RatingType;
12
+ (function (RatingType) {
13
+ RatingType["topic"] = "topic";
14
+ RatingType["aspect"] = "aspect";
15
+ })(RatingType || (exports.RatingType = RatingType = {}));
16
+ exports.RatingResponseBodySchema = zod_1.z
17
+ .object({
18
+ shortName: zod_1.z.string(),
19
+ name: zod_1.z.string(),
20
+ type: zod_1.z.nativeEnum(RatingType),
21
+ isPositive: zod_1.z.boolean(),
22
+ estimations: zod_1.z.number({
23
+ invalid_type_error: 'Number expected',
24
+ required_error: 'Number expected',
25
+ }),
26
+ weight: zod_1.z.number(),
27
+ isWeightSelectedByUser: zod_1.z.boolean(),
28
+ points: zod_1.z.number(),
29
+ maxPoints: zod_1.z.number(),
30
+ })
31
+ .refine((data) => {
32
+ const isValid = data.type === RatingType.topic ||
33
+ (data.isPositive &&
34
+ zod_1.z.number().min(0).max(10).safeParse(data.estimations).success) ||
35
+ (!data.isPositive &&
36
+ zod_1.z.number().min(-200).max(0).safeParse(data.estimations).success);
37
+ return isValid;
38
+ }, (data) => ({
39
+ message: `Number should be between ${data.isPositive ? '0 and 10' : '-200 and 0'}`,
40
+ path: [`estimations`],
41
+ }));
@@ -0,0 +1,11 @@
1
+ import { z } from 'zod';
2
+ export declare const RegionResponseBodySchema: z.ZodObject<{
3
+ countryCode: z.ZodString;
4
+ countryName: z.ZodString;
5
+ }, "strip", z.ZodTypeAny, {
6
+ countryCode: string;
7
+ countryName: string;
8
+ }, {
9
+ countryCode: string;
10
+ countryName: string;
11
+ }>;
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RegionResponseBodySchema = void 0;
4
+ const zod_1 = require("zod");
5
+ exports.RegionResponseBodySchema = zod_1.z.object({
6
+ countryCode: zod_1.z.string(),
7
+ countryName: zod_1.z.string(),
8
+ });
@@ -0,0 +1,21 @@
1
+ import { z } from 'zod';
2
+ export declare const isCountryCode: z.ZodString;
3
+ export declare const isIndustryCode: z.ZodString;
4
+ export declare enum BalanceSheetType {
5
+ Compact = "Compact",
6
+ Full = "Full"
7
+ }
8
+ export declare enum BalanceSheetVersion {
9
+ v5_0_6 = "5.06",
10
+ v5_0_8 = "5.08",
11
+ v5_0_9 = "5.09",
12
+ v5_1_0 = "5.10"
13
+ }
14
+ export declare const WEIGHT_VALUES: number[];
15
+ export declare const isWeight: z.ZodEffects<z.ZodNumber, number, number>;
16
+ export declare const isWeightOptional: z.ZodOptional<z.ZodEffects<z.ZodNumber, number, number>>;
17
+ export declare const isNumberWithDefaultZero: z.ZodDefault<z.ZodNumber>;
18
+ export declare const isPositiveNumber: z.ZodDefault<z.ZodNumber>;
19
+ export declare const isPositiveNumberNotZero: z.ZodDefault<z.ZodNumber>;
20
+ export declare const isPercentage: z.ZodNumber;
21
+ export declare const isPercentageNotZero: z.ZodNumber;
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isPercentageNotZero = exports.isPercentage = exports.isPositiveNumberNotZero = exports.isPositiveNumber = exports.isNumberWithDefaultZero = exports.isWeightOptional = exports.isWeight = exports.WEIGHT_VALUES = exports.BalanceSheetVersion = exports.BalanceSheetType = exports.isIndustryCode = exports.isCountryCode = void 0;
4
+ const zod_1 = require("zod");
5
+ exports.isCountryCode = zod_1.z.string().min(3).max(3);
6
+ exports.isIndustryCode = zod_1.z.string().min(1).max(4);
7
+ var BalanceSheetType;
8
+ (function (BalanceSheetType) {
9
+ BalanceSheetType["Compact"] = "Compact";
10
+ BalanceSheetType["Full"] = "Full";
11
+ })(BalanceSheetType || (exports.BalanceSheetType = BalanceSheetType = {}));
12
+ var BalanceSheetVersion;
13
+ (function (BalanceSheetVersion) {
14
+ BalanceSheetVersion["v5_0_6"] = "5.06";
15
+ BalanceSheetVersion["v5_0_8"] = "5.08";
16
+ BalanceSheetVersion["v5_0_9"] = "5.09";
17
+ BalanceSheetVersion["v5_1_0"] = "5.10";
18
+ })(BalanceSheetVersion || (exports.BalanceSheetVersion = BalanceSheetVersion = {}));
19
+ const isNumberCustomError = zod_1.z.number({
20
+ invalid_type_error: 'Number expected',
21
+ required_error: 'Number expected',
22
+ });
23
+ exports.WEIGHT_VALUES = [0, 0.5, 1, 1.5, 2];
24
+ exports.isWeight = zod_1.z
25
+ .number()
26
+ .refine((v) => exports.WEIGHT_VALUES.some((w) => w === v), {
27
+ message: `Weight has to be one of the following values ${exports.WEIGHT_VALUES}`,
28
+ });
29
+ exports.isWeightOptional = exports.isWeight.optional();
30
+ exports.isNumberWithDefaultZero = isNumberCustomError.default(0);
31
+ exports.isPositiveNumber = isNumberCustomError
32
+ .nonnegative('Number should be positive')
33
+ .default(0);
34
+ exports.isPositiveNumberNotZero = isNumberCustomError
35
+ .gt(0, 'Number should be positive and greater than zero')
36
+ .default(0);
37
+ exports.isPercentage = zod_1.z
38
+ .number({
39
+ invalid_type_error: 'Percentage expected',
40
+ required_error: 'Percentage expected',
41
+ })
42
+ .min(0, 'Percentage should be between 0 and 100')
43
+ .max(100, 'Percentage should be between 0 and 100');
44
+ exports.isPercentageNotZero = zod_1.z
45
+ .number({
46
+ invalid_type_error: 'Percentage expected',
47
+ required_error: 'Percentage expected',
48
+ })
49
+ .min(1, 'Percentage should be between 1 and 100')
50
+ .max(100, 'Percentage should be between 0 and 100');
@@ -0,0 +1,11 @@
1
+ import { z } from 'zod';
2
+ export declare const StakeholderWeightSchema: z.ZodObject<{
3
+ shortName: z.ZodEffects<z.ZodString, string, string>;
4
+ weight: z.ZodEffects<z.ZodNumber, number, number>;
5
+ }, "strip", z.ZodTypeAny, {
6
+ shortName: string;
7
+ weight: number;
8
+ }, {
9
+ shortName: string;
10
+ weight: number;
11
+ }>;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.StakeholderWeightSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ const shared_schemas_1 = require("./shared.schemas");
6
+ const STAKEHOLDER_NAMES = ['A', 'B', 'C', 'D', 'E'];
7
+ const isStakeholderShortName = zod_1.z
8
+ .string()
9
+ .refine((v) => STAKEHOLDER_NAMES.some((w) => w === v), {
10
+ message: `Short name has to be one of the following values ${STAKEHOLDER_NAMES}`,
11
+ });
12
+ exports.StakeholderWeightSchema = zod_1.z.object({
13
+ shortName: isStakeholderShortName,
14
+ weight: shared_schemas_1.isWeight,
15
+ });
@@ -0,0 +1,11 @@
1
+ export declare const DE_ERROR_TRANSLATIONS: {
2
+ 'Number expected': string;
3
+ 'Number should be positive': string;
4
+ 'Percentage expected': string;
5
+ 'Percentage should be between 0 and 100': string;
6
+ 'Percentage should be between 1 and 100': string;
7
+ 'Number should be between 0 and 10': string;
8
+ 'Number should be between -200 and 0': string;
9
+ 'Must not be blank': string;
10
+ 'Number should be positive and greater than zero': string;
11
+ };
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DE_ERROR_TRANSLATIONS = void 0;
4
+ exports.DE_ERROR_TRANSLATIONS = {
5
+ 'Number expected': 'Zahl erwartet',
6
+ 'Number should be positive': 'Zahl sollte positiv sein',
7
+ 'Percentage expected': 'Prozentangabe erwartet',
8
+ 'Percentage should be between 0 and 100': 'Prozentangabe sollte zwischen 0 und 100 liegen',
9
+ 'Percentage should be between 1 and 100': 'Prozentangabe sollte zwischen 1 und 100 liegen',
10
+ 'Number should be between 0 and 10': 'Zahl sollte zwischen 0 und 10 liegen',
11
+ 'Number should be between -200 and 0': 'Zahl sollte zwischen -200 und 0 liegen',
12
+ 'Must not be blank': 'Darf nicht leer sein',
13
+ 'Number should be positive and greater than zero': 'Zahl sollte positiv und größer als 0 sein',
14
+ };
@@ -0,0 +1,2 @@
1
+ export declare const EN_WORDS: string[];
2
+ export declare const EN_ERROR_TRANSLATIONS: {};
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EN_ERROR_TRANSLATIONS = exports.EN_WORDS = void 0;
4
+ exports.EN_WORDS = [
5
+ 'Number expected',
6
+ 'Number should be positive',
7
+ 'Percentage expected',
8
+ 'Percentage should be between 0 and 100',
9
+ 'Percentage should be between 1 and 100',
10
+ 'Number should be between 0 and 10',
11
+ 'Number should be between -200 and 0',
12
+ 'Must not be blank',
13
+ 'Number should be positive and greater than zero',
14
+ ];
15
+ exports.EN_ERROR_TRANSLATIONS = Object.assign({}, exports.EN_WORDS.reduce((prevValue, w) => (Object.assign(Object.assign({}, prevValue), { [w]: w })), {}));
@@ -0,0 +1,28 @@
1
+ import { z } from 'zod';
2
+ export declare const UserRequestBodySchema: z.ZodObject<{
3
+ email: z.ZodString;
4
+ password: z.ZodString;
5
+ }, "strip", z.ZodTypeAny, {
6
+ email: string;
7
+ password: string;
8
+ }, {
9
+ email: string;
10
+ password: string;
11
+ }>;
12
+ export declare const PasswordResetRequestBodySchema: z.ZodObject<{
13
+ newPassword: z.ZodString;
14
+ }, "strip", z.ZodTypeAny, {
15
+ newPassword: string;
16
+ }, {
17
+ newPassword: string;
18
+ }>;
19
+ export declare const UserInvitationResponseSchema: z.ZodObject<{
20
+ id: z.ZodNumber;
21
+ name: z.ZodString;
22
+ }, "strip", z.ZodTypeAny, {
23
+ name: string;
24
+ id: number;
25
+ }, {
26
+ name: string;
27
+ id: number;
28
+ }>;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UserInvitationResponseSchema = exports.PasswordResetRequestBodySchema = exports.UserRequestBodySchema = void 0;
4
+ const zod_1 = require("zod");
5
+ const isPassword = zod_1.z.string().min(20);
6
+ exports.UserRequestBodySchema = zod_1.z.object({
7
+ email: zod_1.z.string().email(),
8
+ password: isPassword,
9
+ });
10
+ exports.PasswordResetRequestBodySchema = zod_1.z.object({
11
+ newPassword: isPassword,
12
+ });
13
+ exports.UserInvitationResponseSchema = zod_1.z.object({
14
+ id: zod_1.z.number(),
15
+ name: zod_1.z.string(),
16
+ });
@@ -0,0 +1,58 @@
1
+ import { z } from 'zod';
2
+ import { BalanceSheetType, BalanceSheetVersion } from './shared.schemas';
3
+ export declare const WorkbookResponseBodySchema: z.ZodObject<{
4
+ version: z.ZodNativeEnum<typeof BalanceSheetVersion>;
5
+ type: z.ZodNativeEnum<typeof BalanceSheetType>;
6
+ groups: z.ZodArray<z.ZodObject<{
7
+ shortName: z.ZodString;
8
+ name: z.ZodString;
9
+ }, "strip", z.ZodTypeAny, {
10
+ name: string;
11
+ shortName: string;
12
+ }, {
13
+ name: string;
14
+ shortName: string;
15
+ }>, "many">;
16
+ evaluationLevels: z.ZodArray<z.ZodObject<{
17
+ level: z.ZodNumber;
18
+ name: z.ZodString;
19
+ pointsFrom: z.ZodNumber;
20
+ pointsTo: z.ZodNumber;
21
+ }, "strip", z.ZodTypeAny, {
22
+ name: string;
23
+ level: number;
24
+ pointsFrom: number;
25
+ pointsTo: number;
26
+ }, {
27
+ name: string;
28
+ level: number;
29
+ pointsFrom: number;
30
+ pointsTo: number;
31
+ }>, "many">;
32
+ }, "strip", z.ZodTypeAny, {
33
+ groups: {
34
+ name: string;
35
+ shortName: string;
36
+ }[];
37
+ type: BalanceSheetType;
38
+ version: BalanceSheetVersion;
39
+ evaluationLevels: {
40
+ name: string;
41
+ level: number;
42
+ pointsFrom: number;
43
+ pointsTo: number;
44
+ }[];
45
+ }, {
46
+ groups: {
47
+ name: string;
48
+ shortName: string;
49
+ }[];
50
+ type: BalanceSheetType;
51
+ version: BalanceSheetVersion;
52
+ evaluationLevels: {
53
+ name: string;
54
+ level: number;
55
+ pointsFrom: number;
56
+ pointsTo: number;
57
+ }[];
58
+ }>;
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.WorkbookResponseBodySchema = void 0;
4
+ const zod_1 = require("zod");
5
+ const shared_schemas_1 = require("./shared.schemas");
6
+ const GroupSchema = zod_1.z.object({
7
+ shortName: zod_1.z.string(),
8
+ name: zod_1.z.string(),
9
+ });
10
+ const EvaluationLevelSchema = zod_1.z.object({
11
+ level: zod_1.z.number(),
12
+ name: zod_1.z.string(),
13
+ pointsFrom: zod_1.z.number(),
14
+ pointsTo: zod_1.z.number(),
15
+ });
16
+ exports.WorkbookResponseBodySchema = zod_1.z.object({
17
+ version: zod_1.z.nativeEnum(shared_schemas_1.BalanceSheetVersion),
18
+ type: zod_1.z.nativeEnum(shared_schemas_1.BalanceSheetType),
19
+ groups: GroupSchema.array(),
20
+ evaluationLevels: EvaluationLevelSchema.array(),
21
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ecogood/e-calculator-schemas",
3
- "version": "2.7.10",
3
+ "version": "2.7.13",
4
4
  "description": "A package providing the schemas for the e-calculator application.",
5
5
  "main": "dist/e-calculator-schemas",
6
6
  "types": "dist/e-calculator-schemas",