@stiava/cta 1.0.0 → 1.0.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.
@@ -17,3 +17,7 @@ export type CTATrainStopRaw = {
17
17
  location_type: string;
18
18
  parent_station: string;
19
19
  };
20
+ export declare class CTASystemGuide {
21
+ static getTrainLines(): string[];
22
+ static readInTrainStationsByRoute(line: 'blue' | 'red' | 'brown' | 'yellow' | 'orange' | 'pink' | 'green'): unknown[];
23
+ }
package/dist/index.cjs CHANGED
@@ -30,6 +30,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
30
30
  var index_exports = {};
31
31
  __export(index_exports, {
32
32
  CTABusService: () => CTABusService,
33
+ CTASystemGuide: () => CTASystemGuide,
33
34
  CTATrainService: () => CTATrainService
34
35
  });
35
36
  module.exports = __toCommonJS(index_exports);
@@ -147,8 +148,43 @@ var CTABusService = class {
147
148
 
148
149
  // cta_system_data.ts
149
150
  var Papa = __toESM(require("papaparse"), 1);
151
+ var import_node_fs = require("fs");
152
+ var import_node_url = require("url");
153
+ var import_node_path = __toESM(require("path"), 1);
154
+ var import_meta = {};
155
+ var __dirname = import_node_path.default.dirname((0, import_node_url.fileURLToPath)(import_meta.url));
156
+ var CTASystemGuide = class {
157
+ static getTrainLines() {
158
+ return ["Red", "Green", "Pink", "Blue", "Purple", "Orange", "Brown"];
159
+ }
160
+ static readInTrainStationsByRoute(line) {
161
+ const csvFilePath = (0, import_node_fs.readFileSync)(
162
+ import_node_path.default.join(__dirname, "public", "trains", `${line}_stations.csv`),
163
+ "utf8"
164
+ );
165
+ const result = Papa.parse(csvFilePath, {
166
+ header: true,
167
+ dynamicTyping: true,
168
+ skipEmptyLines: true,
169
+ transform(value, field) {
170
+ switch (field) {
171
+ case "parking_capacity":
172
+ return value === "" ? null : Number(value);
173
+ case "platforms":
174
+ return value.split(",").map((v) => v.trim()).filter(Boolean);
175
+ case "connected_buses":
176
+ return value === "true";
177
+ default:
178
+ return value;
179
+ }
180
+ }
181
+ });
182
+ return result.data;
183
+ }
184
+ };
150
185
  // Annotate the CommonJS export names for ESM import in node:
151
186
  0 && (module.exports = {
152
187
  CTABusService,
188
+ CTASystemGuide,
153
189
  CTATrainService
154
190
  });
package/dist/index.js CHANGED
@@ -111,7 +111,41 @@ var CTABusService = class {
111
111
 
112
112
  // cta_system_data.ts
113
113
  import * as Papa from "papaparse";
114
+ import { readFileSync } from "fs";
115
+ import { fileURLToPath } from "url";
116
+ import path from "path";
117
+ var __dirname = path.dirname(fileURLToPath(import.meta.url));
118
+ var CTASystemGuide = class {
119
+ static getTrainLines() {
120
+ return ["Red", "Green", "Pink", "Blue", "Purple", "Orange", "Brown"];
121
+ }
122
+ static readInTrainStationsByRoute(line) {
123
+ const csvFilePath = readFileSync(
124
+ path.join(__dirname, "public", "trains", `${line}_stations.csv`),
125
+ "utf8"
126
+ );
127
+ const result = Papa.parse(csvFilePath, {
128
+ header: true,
129
+ dynamicTyping: true,
130
+ skipEmptyLines: true,
131
+ transform(value, field) {
132
+ switch (field) {
133
+ case "parking_capacity":
134
+ return value === "" ? null : Number(value);
135
+ case "platforms":
136
+ return value.split(",").map((v) => v.trim()).filter(Boolean);
137
+ case "connected_buses":
138
+ return value === "true";
139
+ default:
140
+ return value;
141
+ }
142
+ }
143
+ });
144
+ return result.data;
145
+ }
146
+ };
114
147
  export {
115
148
  CTABusService,
149
+ CTASystemGuide,
116
150
  CTATrainService
117
151
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stiava/cta",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "A NodeJS package for interacting with the CTA Bus and Train apis",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -30,4 +30,4 @@
30
30
  "dependencies": {
31
31
  "papaparse": "^5.5.4"
32
32
  }
33
- }
33
+ }