pi-kiosk-shared 2.1.12 → 2.1.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.
@@ -1,42 +1,42 @@
1
- export type Environment = 'development' | 'production';
2
- export interface EnvironmentConfig {
3
- apiUrl: string;
4
- wsUrl: string;
5
- enableMockPayments: boolean;
6
- paymentAccountNumber: string;
7
- paymentMode: 'mock' | 'sandbox' | 'production';
8
- showDebugInfo: boolean;
9
- logLevel: 'debug' | 'info' | 'warn' | 'error';
10
- kioskUrl: string;
11
- adminUrl: string;
12
- backendUrl: string;
13
- sseHealthCheckInitialInterval: number;
14
- sseHealthCheckBackoffMultiplier: number;
15
- sseHealthCheckMaxInterval: number;
16
- sseHealthCheckMaxAttempts: number;
17
- sseHealthCheckMaxTotalTime: number;
18
- }
19
- declare global {
20
- interface Window {
21
- __RUNTIME_CONFIG__?: Partial<EnvironmentConfig>;
22
- }
23
- }
24
- export declare const getCurrentEnvironment: () => Environment;
25
- export declare const getEnvironmentConfig: () => EnvironmentConfig;
26
- export declare const isDevelopment: () => boolean;
27
- export declare const isProduction: () => boolean;
28
- export declare const getBackendUrl: () => string;
29
- export declare const getKioskUrl: () => string;
30
- export declare const getAdminUrl: () => string;
31
- export declare const getApiUrl: () => string;
32
- export declare const getWsUrl: () => string;
33
- export declare const getPaymentConfig: () => {
34
- enableMockPayments: boolean;
35
- paymentAccountNumber: string;
36
- paymentMode: "production" | "mock" | "sandbox";
37
- };
38
- export declare const getUIConfig: () => {
39
- showDebugInfo: boolean;
40
- logLevel: "error" | "debug" | "info" | "warn";
41
- };
1
+ export type Environment = 'development' | 'production';
2
+ export interface EnvironmentConfig {
3
+ apiUrl: string;
4
+ wsUrl: string;
5
+ enableMockPayments: boolean;
6
+ paymentAccountNumber: string;
7
+ paymentMode: 'mock' | 'sandbox' | 'production';
8
+ showDebugInfo: boolean;
9
+ logLevel: 'debug' | 'info' | 'warn' | 'error';
10
+ kioskUrl: string;
11
+ adminUrl: string;
12
+ backendUrl: string;
13
+ sseHealthCheckInitialInterval: number;
14
+ sseHealthCheckBackoffMultiplier: number;
15
+ sseHealthCheckMaxInterval: number;
16
+ sseHealthCheckMaxAttempts: number;
17
+ sseHealthCheckMaxTotalTime: number;
18
+ }
19
+ declare global {
20
+ interface Window {
21
+ __RUNTIME_CONFIG__?: Partial<EnvironmentConfig>;
22
+ }
23
+ }
24
+ export declare const getCurrentEnvironment: () => Environment;
25
+ export declare const getEnvironmentConfig: () => EnvironmentConfig;
26
+ export declare const isDevelopment: () => boolean;
27
+ export declare const isProduction: () => boolean;
28
+ export declare const getBackendUrl: () => string;
29
+ export declare const getKioskUrl: () => string;
30
+ export declare const getAdminUrl: () => string;
31
+ export declare const getApiUrl: () => string;
32
+ export declare const getWsUrl: () => string;
33
+ export declare const getPaymentConfig: () => {
34
+ enableMockPayments: boolean;
35
+ paymentAccountNumber: string;
36
+ paymentMode: "production" | "mock" | "sandbox";
37
+ };
38
+ export declare const getUIConfig: () => {
39
+ showDebugInfo: boolean;
40
+ logLevel: "debug" | "info" | "warn" | "error";
41
+ };
42
42
  //# sourceMappingURL=environments.d.ts.map
@@ -1,191 +1,191 @@
1
- // Centralized environment configuration for all services
2
- // This ensures consistency across backend, kiosk, and admin apps
3
- // Simplified environment variable helper
4
- function getEnvVar(key, defaultValue) {
5
- // Check for process.env (Node.js environment)
6
- if (typeof process !== 'undefined' && process.env) {
7
- return process.env[key] || defaultValue;
8
- }
9
- // Check for import.meta.env (Vite environment)
10
- if (typeof window !== 'undefined') {
11
- try {
12
- // @ts-ignore - Vite environment
13
- const meta = globalThis.import?.meta;
14
- if (meta && meta.env) {
15
- return meta.env[key] || defaultValue;
16
- }
17
- }
18
- catch (e) {
19
- // Fallback for test environments
20
- }
21
- }
22
- return defaultValue;
23
- }
24
- function getEnvBool(key, defaultValue) {
25
- const value = getEnvVar(key, defaultValue.toString());
26
- return value === 'true';
27
- }
28
- function getEnvNumber(key, defaultValue) {
29
- const value = getEnvVar(key, defaultValue.toString());
30
- const parsed = parseInt(value, 10);
31
- return isNaN(parsed) ? defaultValue : parsed;
32
- }
33
- // Centralized service URLs configuration
34
- const SERVICE_URLS = {
35
- development: {
36
- backend: 'http://localhost:3015',
37
- kiosk: 'http://localhost:3000',
38
- admin: 'http://localhost:3001',
39
- },
40
- production: {
41
- backend: 'https://rpapp-bckend-production.up.railway.app',
42
- kiosk: 'https://rpapp-kiosk-production.up.railway.app',
43
- admin: 'https://extraordinary-healing-production-88f4.up.railway.app',
44
- }
45
- };
46
- function getRuntimeConfigOverride() {
47
- if (typeof globalThis === 'undefined') {
48
- return undefined;
49
- }
50
- const maybeWindow = globalThis;
51
- const runtimeConfig = maybeWindow.__RUNTIME_CONFIG__;
52
- if (!runtimeConfig || typeof runtimeConfig !== 'object') {
53
- return undefined;
54
- }
55
- return runtimeConfig;
56
- }
57
- // Get environment configuration dynamically
58
- function getConfigForEnvironment(env) {
59
- const urls = SERVICE_URLS[env];
60
- if (env === 'development') {
61
- return {
62
- // API Configuration
63
- apiUrl: getEnvVar('REACT_APP_API_URL', urls.backend),
64
- wsUrl: getEnvVar('REACT_APP_WS_URL', urls.backend.replace('http', 'ws')),
65
- // Payment Configuration
66
- enableMockPayments: getEnvBool('REACT_APP_ENABLE_MOCK_PAYMENTS', true),
67
- paymentAccountNumber: getEnvVar('REACT_APP_PAYMENT_ACCOUNT', '1234567890'),
68
- paymentMode: getEnvVar('REACT_APP_PAYMENT_MODE', 'mock'),
69
- // UI Configuration
70
- showDebugInfo: getEnvBool('REACT_APP_SHOW_DEBUG_INFO', true),
71
- logLevel: getEnvVar('REACT_APP_LOG_LEVEL', 'debug'),
72
- // Service URLs
73
- kioskUrl: getEnvVar('REACT_APP_KIOSK_URL', urls.kiosk),
74
- adminUrl: getEnvVar('REACT_APP_ADMIN_URL', urls.admin),
75
- backendUrl: getEnvVar('REACT_APP_BACKEND_URL', urls.backend),
76
- // SSE Health Check Configuration
77
- sseHealthCheckInitialInterval: getEnvNumber('REACT_APP_SSE_HEALTH_CHECK_INITIAL_INTERVAL', 300000), // 5 minutes
78
- sseHealthCheckBackoffMultiplier: getEnvNumber('REACT_APP_SSE_HEALTH_CHECK_BACKOFF_MULTIPLIER', 2),
79
- sseHealthCheckMaxInterval: getEnvNumber('REACT_APP_SSE_HEALTH_CHECK_MAX_INTERVAL', 900000), // 15 minutes
80
- sseHealthCheckMaxAttempts: getEnvNumber('REACT_APP_SSE_HEALTH_CHECK_MAX_ATTEMPTS', 8),
81
- sseHealthCheckMaxTotalTime: getEnvNumber('REACT_APP_SSE_HEALTH_CHECK_MAX_TOTAL_TIME', 1800000), // 30 minutes
82
- };
83
- }
84
- else {
85
- return {
86
- // API Configuration
87
- apiUrl: getEnvVar('REACT_APP_API_URL', urls.backend),
88
- wsUrl: getEnvVar('REACT_APP_WS_URL', urls.backend.replace('https', 'wss')),
89
- // Payment Configuration
90
- enableMockPayments: getEnvBool('REACT_APP_ENABLE_MOCK_PAYMENTS', false),
91
- paymentAccountNumber: getEnvVar('REACT_APP_PAYMENT_ACCOUNT', '1234567890'),
92
- paymentMode: getEnvVar('REACT_APP_PAYMENT_MODE', 'production'),
93
- // UI Configuration
94
- showDebugInfo: getEnvBool('REACT_APP_SHOW_DEBUG_INFO', false),
95
- logLevel: getEnvVar('REACT_APP_LOG_LEVEL', 'warn'),
96
- // Service URLs
97
- kioskUrl: getEnvVar('REACT_APP_KIOSK_URL', urls.kiosk),
98
- adminUrl: getEnvVar('REACT_APP_ADMIN_URL', urls.admin),
99
- backendUrl: getEnvVar('REACT_APP_BACKEND_URL', urls.backend),
100
- // SSE Health Check Configuration
101
- sseHealthCheckInitialInterval: getEnvNumber('REACT_APP_SSE_HEALTH_CHECK_INITIAL_INTERVAL', 300000), // 5 minutes
102
- sseHealthCheckBackoffMultiplier: getEnvNumber('REACT_APP_SSE_HEALTH_CHECK_BACKOFF_MULTIPLIER', 2),
103
- sseHealthCheckMaxInterval: getEnvNumber('REACT_APP_SSE_HEALTH_CHECK_MAX_INTERVAL', 900000), // 15 minutes
104
- sseHealthCheckMaxAttempts: getEnvNumber('REACT_APP_SSE_HEALTH_CHECK_MAX_ATTEMPTS', 8),
105
- sseHealthCheckMaxTotalTime: getEnvNumber('REACT_APP_SSE_HEALTH_CHECK_MAX_TOTAL_TIME', 1800000), // 30 minutes
106
- };
107
- }
108
- }
109
- // Simplified environment detection
110
- export const getCurrentEnvironment = () => {
111
- // Check for process.env (Node.js environment)
112
- if (typeof process !== 'undefined' && process.env) {
113
- return process.env.NODE_ENV === 'production' ? 'production' : 'development';
114
- }
115
- // Check if we're on Railway domain (most reliable for production detection)
116
- if (typeof window !== 'undefined' && window.location) {
117
- if (window.location.hostname.includes('railway.app') ||
118
- window.location.hostname.includes('up.railway.app')) {
119
- return 'production';
120
- }
121
- }
122
- // Check for import.meta.env (Vite environment)
123
- if (typeof window !== 'undefined') {
124
- try {
125
- // @ts-ignore - Vite environment
126
- const meta = globalThis.import?.meta;
127
- if (meta && meta.env) {
128
- return meta.env.MODE === 'production' ? 'production' : 'development';
129
- }
130
- }
131
- catch (e) {
132
- // Ignore errors
133
- }
134
- }
135
- // Additional fallback: check for production URLs in environment variables
136
- if (typeof window !== 'undefined') {
137
- try {
138
- // @ts-ignore - Vite environment
139
- const meta = globalThis.import?.meta;
140
- if (meta && meta.env) {
141
- const apiUrl = meta.env.VITE_API_URL || meta.env.REACT_APP_API_URL;
142
- if (apiUrl && apiUrl.includes('railway.app')) {
143
- return 'production';
144
- }
145
- }
146
- }
147
- catch (e) {
148
- // Ignore errors
149
- }
150
- }
151
- return 'development';
152
- };
153
- // Get current environment configuration
154
- export const getEnvironmentConfig = () => {
155
- const env = getCurrentEnvironment();
156
- const baseConfig = getConfigForEnvironment(env);
157
- const runtimeOverride = getRuntimeConfigOverride();
158
- if (!runtimeOverride) {
159
- return baseConfig;
160
- }
161
- return {
162
- ...baseConfig,
163
- ...runtimeOverride,
164
- };
165
- };
166
- // Simple environment checks
167
- export const isDevelopment = () => getCurrentEnvironment() === 'development';
168
- export const isProduction = () => getCurrentEnvironment() === 'production';
169
- // Utility functions for easy access to service URLs
170
- export const getBackendUrl = () => getEnvironmentConfig().backendUrl;
171
- export const getKioskUrl = () => getEnvironmentConfig().kioskUrl;
172
- export const getAdminUrl = () => getEnvironmentConfig().adminUrl;
173
- export const getApiUrl = () => getEnvironmentConfig().apiUrl;
174
- export const getWsUrl = () => getEnvironmentConfig().wsUrl;
175
- // Service-specific configuration helpers
176
- export const getPaymentConfig = () => {
177
- const config = getEnvironmentConfig();
178
- return {
179
- enableMockPayments: config.enableMockPayments,
180
- paymentAccountNumber: config.paymentAccountNumber,
181
- paymentMode: config.paymentMode,
182
- };
183
- };
184
- export const getUIConfig = () => {
185
- const config = getEnvironmentConfig();
186
- return {
187
- showDebugInfo: config.showDebugInfo,
188
- logLevel: config.logLevel,
189
- };
190
- };
1
+ // Centralized environment configuration for all services
2
+ // This ensures consistency across backend, kiosk, and admin apps
3
+ // Simplified environment variable helper
4
+ function getEnvVar(key, defaultValue) {
5
+ // Check for process.env (Node.js environment)
6
+ if (typeof process !== 'undefined' && process.env) {
7
+ return process.env[key] || defaultValue;
8
+ }
9
+ // Check for import.meta.env (Vite environment)
10
+ if (typeof window !== 'undefined') {
11
+ try {
12
+ // @ts-ignore - Vite environment
13
+ const meta = globalThis.import?.meta;
14
+ if (meta && meta.env) {
15
+ return meta.env[key] || defaultValue;
16
+ }
17
+ }
18
+ catch (e) {
19
+ // Fallback for test environments
20
+ }
21
+ }
22
+ return defaultValue;
23
+ }
24
+ function getEnvBool(key, defaultValue) {
25
+ const value = getEnvVar(key, defaultValue.toString());
26
+ return value === 'true';
27
+ }
28
+ function getEnvNumber(key, defaultValue) {
29
+ const value = getEnvVar(key, defaultValue.toString());
30
+ const parsed = parseInt(value, 10);
31
+ return isNaN(parsed) ? defaultValue : parsed;
32
+ }
33
+ // Centralized service URLs configuration
34
+ const SERVICE_URLS = {
35
+ development: {
36
+ backend: 'http://localhost:3015',
37
+ kiosk: 'http://localhost:3000',
38
+ admin: 'http://localhost:3001',
39
+ },
40
+ production: {
41
+ backend: 'https://rpapp-bckend-production.up.railway.app',
42
+ kiosk: 'https://rpapp-kiosk-production.up.railway.app',
43
+ admin: 'https://extraordinary-healing-production-88f4.up.railway.app',
44
+ }
45
+ };
46
+ function getRuntimeConfigOverride() {
47
+ if (typeof globalThis === 'undefined') {
48
+ return undefined;
49
+ }
50
+ const maybeWindow = globalThis;
51
+ const runtimeConfig = maybeWindow.__RUNTIME_CONFIG__;
52
+ if (!runtimeConfig || typeof runtimeConfig !== 'object') {
53
+ return undefined;
54
+ }
55
+ return runtimeConfig;
56
+ }
57
+ // Get environment configuration dynamically
58
+ function getConfigForEnvironment(env) {
59
+ const urls = SERVICE_URLS[env];
60
+ if (env === 'development') {
61
+ return {
62
+ // API Configuration
63
+ apiUrl: getEnvVar('REACT_APP_API_URL', urls.backend),
64
+ wsUrl: getEnvVar('REACT_APP_WS_URL', urls.backend.replace('http', 'ws')),
65
+ // Payment Configuration
66
+ enableMockPayments: getEnvBool('REACT_APP_ENABLE_MOCK_PAYMENTS', true),
67
+ paymentAccountNumber: getEnvVar('REACT_APP_PAYMENT_ACCOUNT', '1234567890'),
68
+ paymentMode: getEnvVar('REACT_APP_PAYMENT_MODE', 'mock'),
69
+ // UI Configuration
70
+ showDebugInfo: getEnvBool('REACT_APP_SHOW_DEBUG_INFO', true),
71
+ logLevel: getEnvVar('REACT_APP_LOG_LEVEL', 'debug'),
72
+ // Service URLs
73
+ kioskUrl: getEnvVar('REACT_APP_KIOSK_URL', urls.kiosk),
74
+ adminUrl: getEnvVar('REACT_APP_ADMIN_URL', urls.admin),
75
+ backendUrl: getEnvVar('REACT_APP_BACKEND_URL', urls.backend),
76
+ // SSE Health Check Configuration
77
+ sseHealthCheckInitialInterval: getEnvNumber('REACT_APP_SSE_HEALTH_CHECK_INITIAL_INTERVAL', 300000), // 5 minutes
78
+ sseHealthCheckBackoffMultiplier: getEnvNumber('REACT_APP_SSE_HEALTH_CHECK_BACKOFF_MULTIPLIER', 2),
79
+ sseHealthCheckMaxInterval: getEnvNumber('REACT_APP_SSE_HEALTH_CHECK_MAX_INTERVAL', 900000), // 15 minutes
80
+ sseHealthCheckMaxAttempts: getEnvNumber('REACT_APP_SSE_HEALTH_CHECK_MAX_ATTEMPTS', 8),
81
+ sseHealthCheckMaxTotalTime: getEnvNumber('REACT_APP_SSE_HEALTH_CHECK_MAX_TOTAL_TIME', 1800000), // 30 minutes
82
+ };
83
+ }
84
+ else {
85
+ return {
86
+ // API Configuration
87
+ apiUrl: getEnvVar('REACT_APP_API_URL', urls.backend),
88
+ wsUrl: getEnvVar('REACT_APP_WS_URL', urls.backend.replace('https', 'wss')),
89
+ // Payment Configuration
90
+ enableMockPayments: getEnvBool('REACT_APP_ENABLE_MOCK_PAYMENTS', false),
91
+ paymentAccountNumber: getEnvVar('REACT_APP_PAYMENT_ACCOUNT', '1234567890'),
92
+ paymentMode: getEnvVar('REACT_APP_PAYMENT_MODE', 'production'),
93
+ // UI Configuration
94
+ showDebugInfo: getEnvBool('REACT_APP_SHOW_DEBUG_INFO', false),
95
+ logLevel: getEnvVar('REACT_APP_LOG_LEVEL', 'warn'),
96
+ // Service URLs
97
+ kioskUrl: getEnvVar('REACT_APP_KIOSK_URL', urls.kiosk),
98
+ adminUrl: getEnvVar('REACT_APP_ADMIN_URL', urls.admin),
99
+ backendUrl: getEnvVar('REACT_APP_BACKEND_URL', urls.backend),
100
+ // SSE Health Check Configuration
101
+ sseHealthCheckInitialInterval: getEnvNumber('REACT_APP_SSE_HEALTH_CHECK_INITIAL_INTERVAL', 300000), // 5 minutes
102
+ sseHealthCheckBackoffMultiplier: getEnvNumber('REACT_APP_SSE_HEALTH_CHECK_BACKOFF_MULTIPLIER', 2),
103
+ sseHealthCheckMaxInterval: getEnvNumber('REACT_APP_SSE_HEALTH_CHECK_MAX_INTERVAL', 900000), // 15 minutes
104
+ sseHealthCheckMaxAttempts: getEnvNumber('REACT_APP_SSE_HEALTH_CHECK_MAX_ATTEMPTS', 8),
105
+ sseHealthCheckMaxTotalTime: getEnvNumber('REACT_APP_SSE_HEALTH_CHECK_MAX_TOTAL_TIME', 1800000), // 30 minutes
106
+ };
107
+ }
108
+ }
109
+ // Simplified environment detection
110
+ export const getCurrentEnvironment = () => {
111
+ // Check for process.env (Node.js environment)
112
+ if (typeof process !== 'undefined' && process.env) {
113
+ return process.env.NODE_ENV === 'production' ? 'production' : 'development';
114
+ }
115
+ // Check if we're on Railway domain (most reliable for production detection)
116
+ if (typeof window !== 'undefined' && window.location) {
117
+ if (window.location.hostname.includes('railway.app') ||
118
+ window.location.hostname.includes('up.railway.app')) {
119
+ return 'production';
120
+ }
121
+ }
122
+ // Check for import.meta.env (Vite environment)
123
+ if (typeof window !== 'undefined') {
124
+ try {
125
+ // @ts-ignore - Vite environment
126
+ const meta = globalThis.import?.meta;
127
+ if (meta && meta.env) {
128
+ return meta.env.MODE === 'production' ? 'production' : 'development';
129
+ }
130
+ }
131
+ catch (e) {
132
+ // Ignore errors
133
+ }
134
+ }
135
+ // Additional fallback: check for production URLs in environment variables
136
+ if (typeof window !== 'undefined') {
137
+ try {
138
+ // @ts-ignore - Vite environment
139
+ const meta = globalThis.import?.meta;
140
+ if (meta && meta.env) {
141
+ const apiUrl = meta.env.VITE_API_URL || meta.env.REACT_APP_API_URL;
142
+ if (apiUrl && apiUrl.includes('railway.app')) {
143
+ return 'production';
144
+ }
145
+ }
146
+ }
147
+ catch (e) {
148
+ // Ignore errors
149
+ }
150
+ }
151
+ return 'development';
152
+ };
153
+ // Get current environment configuration
154
+ export const getEnvironmentConfig = () => {
155
+ const env = getCurrentEnvironment();
156
+ const baseConfig = getConfigForEnvironment(env);
157
+ const runtimeOverride = getRuntimeConfigOverride();
158
+ if (!runtimeOverride) {
159
+ return baseConfig;
160
+ }
161
+ return {
162
+ ...baseConfig,
163
+ ...runtimeOverride,
164
+ };
165
+ };
166
+ // Simple environment checks
167
+ export const isDevelopment = () => getCurrentEnvironment() === 'development';
168
+ export const isProduction = () => getCurrentEnvironment() === 'production';
169
+ // Utility functions for easy access to service URLs
170
+ export const getBackendUrl = () => getEnvironmentConfig().backendUrl;
171
+ export const getKioskUrl = () => getEnvironmentConfig().kioskUrl;
172
+ export const getAdminUrl = () => getEnvironmentConfig().adminUrl;
173
+ export const getApiUrl = () => getEnvironmentConfig().apiUrl;
174
+ export const getWsUrl = () => getEnvironmentConfig().wsUrl;
175
+ // Service-specific configuration helpers
176
+ export const getPaymentConfig = () => {
177
+ const config = getEnvironmentConfig();
178
+ return {
179
+ enableMockPayments: config.enableMockPayments,
180
+ paymentAccountNumber: config.paymentAccountNumber,
181
+ paymentMode: config.paymentMode,
182
+ };
183
+ };
184
+ export const getUIConfig = () => {
185
+ const config = getEnvironmentConfig();
186
+ return {
187
+ showDebugInfo: config.showDebugInfo,
188
+ logLevel: config.logLevel,
189
+ };
190
+ };
191
191
  //# sourceMappingURL=environments.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-kiosk-shared",
3
- "version": "2.1.12",
3
+ "version": "2.1.13",
4
4
  "private": false,
5
5
  "description": "Shared types, API contracts, and error classes for Pi Kiosk system",
6
6
  "keywords": [