@zonetrix/shared 2.4.0 → 2.4.2

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.d.mts CHANGED
@@ -31,6 +31,7 @@ interface SectionConfig {
31
31
  price?: number;
32
32
  color?: string;
33
33
  locked?: boolean;
34
+ [key: string]: unknown;
34
35
  }
35
36
  /**
36
37
  * Row pricing structure for section-based pricing
@@ -196,10 +197,44 @@ interface ValidationResult {
196
197
  warnings: string[];
197
198
  }
198
199
 
200
+ interface ConfigInput {
201
+ version?: string;
202
+ metadata?: {
203
+ name?: string;
204
+ createdAt?: string;
205
+ updatedAt?: string;
206
+ };
207
+ canvas?: {
208
+ width?: number;
209
+ height?: number;
210
+ backgroundColor?: string;
211
+ };
212
+ colors?: Record<string, string>;
213
+ seats?: Array<{
214
+ id?: string;
215
+ position?: {
216
+ x?: number;
217
+ y?: number;
218
+ };
219
+ shape?: string;
220
+ state?: string;
221
+ }>;
222
+ sections?: Array<{
223
+ id?: string;
224
+ name?: string;
225
+ config?: unknown;
226
+ }>;
227
+ stages?: Array<{
228
+ id?: string;
229
+ config?: {
230
+ label?: string;
231
+ };
232
+ }>;
233
+ }
199
234
  /**
200
235
  * Validates a seat map configuration
201
236
  */
202
- declare function validateSeatMapConfig(config: any): ValidationResult;
237
+ declare function validateSeatMapConfig(config: ConfigInput | null | undefined): ValidationResult;
203
238
  /**
204
239
  * Generates a unique ID for seat map objects
205
240
  */
@@ -261,14 +296,14 @@ declare function downloadConfigAsFile(config: SeatMapConfig, filename?: string):
261
296
  /**
262
297
  * Firebase seat state type (excludes 'selected' which is client-only, 'hidden' which is filtered)
263
298
  */
264
- type FirebaseSeatState = 'available' | 'reserved' | 'unavailable';
299
+ type FirebaseSeatState = "available" | "reserved" | "unavailable";
265
300
  /**
266
301
  * Seat state value stored in Firebase (for reserved/unavailable seats)
267
302
  * Available seats: key is deleted (doesn't exist)
268
303
  * Reserved/Unavailable seats: object with state, userId, and timestamp
269
304
  */
270
305
  interface FirebaseSeatStateValue {
271
- state: 'reserved' | 'unavailable';
306
+ state: "reserved" | "unavailable";
272
307
  userId?: string;
273
308
  timestamp?: number;
274
309
  }
package/dist/index.d.ts CHANGED
@@ -31,6 +31,7 @@ interface SectionConfig {
31
31
  price?: number;
32
32
  color?: string;
33
33
  locked?: boolean;
34
+ [key: string]: unknown;
34
35
  }
35
36
  /**
36
37
  * Row pricing structure for section-based pricing
@@ -196,10 +197,44 @@ interface ValidationResult {
196
197
  warnings: string[];
197
198
  }
198
199
 
200
+ interface ConfigInput {
201
+ version?: string;
202
+ metadata?: {
203
+ name?: string;
204
+ createdAt?: string;
205
+ updatedAt?: string;
206
+ };
207
+ canvas?: {
208
+ width?: number;
209
+ height?: number;
210
+ backgroundColor?: string;
211
+ };
212
+ colors?: Record<string, string>;
213
+ seats?: Array<{
214
+ id?: string;
215
+ position?: {
216
+ x?: number;
217
+ y?: number;
218
+ };
219
+ shape?: string;
220
+ state?: string;
221
+ }>;
222
+ sections?: Array<{
223
+ id?: string;
224
+ name?: string;
225
+ config?: unknown;
226
+ }>;
227
+ stages?: Array<{
228
+ id?: string;
229
+ config?: {
230
+ label?: string;
231
+ };
232
+ }>;
233
+ }
199
234
  /**
200
235
  * Validates a seat map configuration
201
236
  */
202
- declare function validateSeatMapConfig(config: any): ValidationResult;
237
+ declare function validateSeatMapConfig(config: ConfigInput | null | undefined): ValidationResult;
203
238
  /**
204
239
  * Generates a unique ID for seat map objects
205
240
  */
@@ -261,14 +296,14 @@ declare function downloadConfigAsFile(config: SeatMapConfig, filename?: string):
261
296
  /**
262
297
  * Firebase seat state type (excludes 'selected' which is client-only, 'hidden' which is filtered)
263
298
  */
264
- type FirebaseSeatState = 'available' | 'reserved' | 'unavailable';
299
+ type FirebaseSeatState = "available" | "reserved" | "unavailable";
265
300
  /**
266
301
  * Seat state value stored in Firebase (for reserved/unavailable seats)
267
302
  * Available seats: key is deleted (doesn't exist)
268
303
  * Reserved/Unavailable seats: object with state, userId, and timestamp
269
304
  */
270
305
  interface FirebaseSeatStateValue {
271
- state: 'reserved' | 'unavailable';
306
+ state: "reserved" | "unavailable";
272
307
  userId?: string;
273
308
  timestamp?: number;
274
309
  }
package/dist/index.js CHANGED
@@ -109,6 +109,7 @@ function validateSeatMapConfig(config) {
109
109
  if (!config.colors) {
110
110
  warnings.push("Missing color configuration");
111
111
  } else {
112
+ const colors = config.colors;
112
113
  const requiredColors = [
113
114
  "canvasBackground",
114
115
  "stageColor",
@@ -119,7 +120,7 @@ function validateSeatMapConfig(config) {
119
120
  "gridLines"
120
121
  ];
121
122
  requiredColors.forEach((color) => {
122
- if (!config.colors[color] || typeof config.colors[color] !== "string") {
123
+ if (!colors[color] || typeof colors[color] !== "string") {
123
124
  warnings.push(`Missing or invalid color: ${color}`);
124
125
  }
125
126
  });
@@ -142,7 +143,9 @@ function validateSeatMapConfig(config) {
142
143
  }
143
144
  });
144
145
  const seatIds = config.seats.map((s) => s.id);
145
- const duplicates = seatIds.filter((id, index) => seatIds.indexOf(id) !== index);
146
+ const duplicates = seatIds.filter(
147
+ (id, index) => seatIds.indexOf(id) !== index
148
+ );
146
149
  if (duplicates.length > 0) {
147
150
  errors.push(`Duplicate seat IDs found: ${duplicates.join(", ")}`);
148
151
  }
@@ -177,10 +180,10 @@ function validateSeatMapConfig(config) {
177
180
  };
178
181
  }
179
182
  function isValidSeatState(state) {
180
- return ["available", "reserved", "selected", "unavailable"].includes(state);
183
+ return typeof state === "string" && ["available", "reserved", "selected", "unavailable"].includes(state);
181
184
  }
182
185
  function isValidSeatShape(shape) {
183
- return ["circle", "square", "rounded-square"].includes(shape);
186
+ return typeof shape === "string" && ["circle", "square", "rounded-square"].includes(shape);
184
187
  }
185
188
  function generateId(prefix = "obj") {
186
189
  return `${prefix}_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
@@ -257,7 +260,9 @@ function importConfigFromJSON(jsonString) {
257
260
  const config = JSON.parse(jsonString);
258
261
  return config;
259
262
  } catch (error) {
260
- throw new Error(`Failed to parse JSON: ${error instanceof Error ? error.message : "Unknown error"}`);
263
+ throw new Error(
264
+ `Failed to parse JSON: ${error instanceof Error ? error.message : "Unknown error"}`
265
+ );
261
266
  }
262
267
  }
263
268
  function downloadConfigAsFile(config, filename = "seat-map-config.json") {
package/dist/index.mjs CHANGED
@@ -59,6 +59,7 @@ function validateSeatMapConfig(config) {
59
59
  if (!config.colors) {
60
60
  warnings.push("Missing color configuration");
61
61
  } else {
62
+ const colors = config.colors;
62
63
  const requiredColors = [
63
64
  "canvasBackground",
64
65
  "stageColor",
@@ -69,7 +70,7 @@ function validateSeatMapConfig(config) {
69
70
  "gridLines"
70
71
  ];
71
72
  requiredColors.forEach((color) => {
72
- if (!config.colors[color] || typeof config.colors[color] !== "string") {
73
+ if (!colors[color] || typeof colors[color] !== "string") {
73
74
  warnings.push(`Missing or invalid color: ${color}`);
74
75
  }
75
76
  });
@@ -92,7 +93,9 @@ function validateSeatMapConfig(config) {
92
93
  }
93
94
  });
94
95
  const seatIds = config.seats.map((s) => s.id);
95
- const duplicates = seatIds.filter((id, index) => seatIds.indexOf(id) !== index);
96
+ const duplicates = seatIds.filter(
97
+ (id, index) => seatIds.indexOf(id) !== index
98
+ );
96
99
  if (duplicates.length > 0) {
97
100
  errors.push(`Duplicate seat IDs found: ${duplicates.join(", ")}`);
98
101
  }
@@ -127,10 +130,10 @@ function validateSeatMapConfig(config) {
127
130
  };
128
131
  }
129
132
  function isValidSeatState(state) {
130
- return ["available", "reserved", "selected", "unavailable"].includes(state);
133
+ return typeof state === "string" && ["available", "reserved", "selected", "unavailable"].includes(state);
131
134
  }
132
135
  function isValidSeatShape(shape) {
133
- return ["circle", "square", "rounded-square"].includes(shape);
136
+ return typeof shape === "string" && ["circle", "square", "rounded-square"].includes(shape);
134
137
  }
135
138
  function generateId(prefix = "obj") {
136
139
  return `${prefix}_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
@@ -207,7 +210,9 @@ function importConfigFromJSON(jsonString) {
207
210
  const config = JSON.parse(jsonString);
208
211
  return config;
209
212
  } catch (error) {
210
- throw new Error(`Failed to parse JSON: ${error instanceof Error ? error.message : "Unknown error"}`);
213
+ throw new Error(
214
+ `Failed to parse JSON: ${error instanceof Error ? error.message : "Unknown error"}`
215
+ );
211
216
  }
212
217
  }
213
218
  function downloadConfigAsFile(config, filename = "seat-map-config.json") {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zonetrix/shared",
3
- "version": "2.4.0",
3
+ "version": "2.4.2",
4
4
  "description": "Shared types and utilities for seat-map-studio packages",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -8,9 +8,9 @@
8
8
  "sideEffects": false,
9
9
  "exports": {
10
10
  ".": {
11
+ "types": "./dist/index.d.ts",
11
12
  "import": "./dist/index.mjs",
12
- "require": "./dist/index.js",
13
- "types": "./dist/index.d.ts"
13
+ "require": "./dist/index.js"
14
14
  }
15
15
  },
16
16
  "files": [