pi-kiosk-shared 1.0.1 → 1.0.3

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.
@@ -6,7 +6,6 @@ export interface EnvironmentConfig {
6
6
  paymentAccountNumber: string;
7
7
  showDebugInfo: boolean;
8
8
  }
9
- export declare const environments: Record<Environment, EnvironmentConfig>;
10
9
  export declare const getCurrentEnvironment: () => Environment;
11
10
  export declare const getEnvironmentConfig: () => EnvironmentConfig;
12
11
  export declare const isDevelopment: () => boolean;
@@ -1,23 +1,35 @@
1
1
  "use strict";
2
2
  // Simple environment configuration
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.isProduction = exports.isDevelopment = exports.getEnvironmentConfig = exports.getCurrentEnvironment = exports.environments = void 0;
5
- exports.environments = {
6
- development: {
7
- apiUrl: 'http://localhost:3015',
8
- wsUrl: 'ws://localhost:3015',
9
- enableMockPayments: true,
10
- paymentAccountNumber: '1234567890',
11
- showDebugInfo: true,
12
- },
13
- production: {
14
- apiUrl: process.env.REACT_APP_API_URL || 'https://kiosk-prod.railway.app',
15
- wsUrl: process.env.REACT_APP_WS_URL || 'wss://kiosk-prod.railway.app',
16
- enableMockPayments: false,
17
- paymentAccountNumber: process.env.REACT_APP_PAYMENT_ACCOUNT || '1234567890',
18
- showDebugInfo: false,
4
+ exports.isProduction = exports.isDevelopment = exports.getEnvironmentConfig = exports.getCurrentEnvironment = void 0;
5
+ // Helper function to get environment variables dynamically
6
+ function getEnvVar(key, defaultValue) {
7
+ return process.env[key] || defaultValue;
8
+ }
9
+ function getEnvBool(key, defaultValue) {
10
+ return process.env[key] === 'true' || defaultValue;
11
+ }
12
+ // Get environment configuration dynamically
13
+ function getConfigForEnvironment(env) {
14
+ if (env === 'development') {
15
+ return {
16
+ apiUrl: getEnvVar('REACT_APP_API_URL', 'http://localhost:3015'),
17
+ wsUrl: getEnvVar('REACT_APP_WS_URL', 'ws://localhost:3015'),
18
+ enableMockPayments: getEnvBool('REACT_APP_ENABLE_MOCK_PAYMENTS', true),
19
+ paymentAccountNumber: getEnvVar('REACT_APP_PAYMENT_ACCOUNT', '1234567890'),
20
+ showDebugInfo: getEnvBool('REACT_APP_SHOW_DEBUG_INFO', true),
21
+ };
19
22
  }
20
- };
23
+ else {
24
+ return {
25
+ apiUrl: getEnvVar('REACT_APP_API_URL', 'https://kiosk-prod.railway.app'),
26
+ wsUrl: getEnvVar('REACT_APP_WS_URL', 'wss://kiosk-prod.railway.app'),
27
+ enableMockPayments: getEnvBool('REACT_APP_ENABLE_MOCK_PAYMENTS', false),
28
+ paymentAccountNumber: getEnvVar('REACT_APP_PAYMENT_ACCOUNT', '1234567890'),
29
+ showDebugInfo: getEnvBool('REACT_APP_SHOW_DEBUG_INFO', false),
30
+ };
31
+ }
32
+ }
21
33
  // Simple environment detection
22
34
  const getCurrentEnvironment = () => {
23
35
  return process.env.NODE_ENV === 'production' ? 'production' : 'development';
@@ -26,7 +38,7 @@ exports.getCurrentEnvironment = getCurrentEnvironment;
26
38
  // Get current environment configuration
27
39
  const getEnvironmentConfig = () => {
28
40
  const env = (0, exports.getCurrentEnvironment)();
29
- return exports.environments[env];
41
+ return getConfigForEnvironment(env);
30
42
  };
31
43
  exports.getEnvironmentConfig = getEnvironmentConfig;
32
44
  // Simple environment checks
@@ -3,7 +3,7 @@ export interface ValidationResult {
3
3
  errors: Record<string, string>;
4
4
  }
5
5
  export declare const validators: {
6
- required: (value: any, fieldName: string) => string | null;
6
+ required: (value: any) => string | null;
7
7
  email: (value: string) => string | null;
8
8
  minLength: (value: string, min: number, fieldName: string) => string | null;
9
9
  maxLength: (value: string, max: number, fieldName: string) => string | null;
@@ -5,9 +5,9 @@ exports.validationSchemas = exports.validateSchema = exports.validators = void 0
5
5
  // ValidationError is imported but not used directly in this file
6
6
  const constants_1 = require("./constants");
7
7
  exports.validators = {
8
- required: (value, fieldName) => {
8
+ required: (value) => {
9
9
  if (value === null || value === undefined || value === '') {
10
- return `${fieldName} ${constants_1.UI_MESSAGES.REQUIRED_FIELD.toLowerCase()}`;
10
+ return constants_1.UI_MESSAGES.REQUIRED_FIELD;
11
11
  }
12
12
  return null;
13
13
  },
@@ -86,28 +86,28 @@ exports.validateSchema = validateSchema;
86
86
  exports.validationSchemas = {
87
87
  login: {
88
88
  username: [
89
- (value) => exports.validators.required(value, 'Uživatelské jméno'),
89
+ (value) => exports.validators.required(value),
90
90
  exports.validators.username
91
91
  ],
92
92
  password: [
93
- (value) => exports.validators.required(value, 'Heslo'),
93
+ (value) => exports.validators.required(value),
94
94
  exports.validators.password
95
95
  ]
96
96
  },
97
97
  customerEmail: {
98
98
  email: [
99
- (value) => exports.validators.required(value, 'Email'),
99
+ (value) => exports.validators.required(value),
100
100
  exports.validators.email
101
101
  ]
102
102
  },
103
103
  product: {
104
104
  name: [
105
- (value) => exports.validators.required(value, 'Název produktu'),
105
+ (value) => exports.validators.required(value),
106
106
  (value) => exports.validators.minLength(value, 2, 'Název produktu'),
107
107
  (value) => exports.validators.maxLength(value, constants_1.APP_CONFIG.MAX_PRODUCT_NAME_LENGTH, 'Název produktu')
108
108
  ],
109
109
  price: [
110
- (value) => exports.validators.required(value, 'Cena'),
110
+ (value) => exports.validators.required(value),
111
111
  (value) => exports.validators.positiveNumber(value, 'Cena')
112
112
  ],
113
113
  description: [
package/package.json CHANGED
@@ -1,9 +1,14 @@
1
1
  {
2
2
  "name": "pi-kiosk-shared",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "private": false,
5
5
  "description": "Shared components and utilities for Pi Kiosk system",
6
- "keywords": ["kiosk", "react", "typescript", "components"],
6
+ "keywords": [
7
+ "kiosk",
8
+ "react",
9
+ "typescript",
10
+ "components"
11
+ ],
7
12
  "author": "tehacko@seznam.cz",
8
13
  "license": "MIT",
9
14
  "repository": {
@@ -11,7 +16,7 @@
11
16
  "url": "https://github.com/tehacko/pi-kiosk-shared"
12
17
  },
13
18
  "main": "dist/index.js",
14
- "module": "dist/index.js",
19
+ "module": "dist/index.js",
15
20
  "types": "dist/index.d.ts",
16
21
  "exports": {
17
22
  ".": {