@mrfylke/nsr-barcode-generator 1.1.0

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.
Files changed (48) hide show
  1. package/README.md +182 -0
  2. package/assets/fonts/poppins-400-normal.ttf +0 -0
  3. package/assets/fonts/poppins-700-normal.ttf +0 -0
  4. package/assets/images/Boat.png +0 -0
  5. package/assets/images/Bus.png +0 -0
  6. package/assets/images/Ferry.png +0 -0
  7. package/assets/images/fram_mor_fylkeskommune_dark.png +0 -0
  8. package/dist/api.d.ts +48 -0
  9. package/dist/api.d.ts.map +1 -0
  10. package/dist/api.js +133 -0
  11. package/dist/api.js.map +1 -0
  12. package/dist/cli.d.ts +3 -0
  13. package/dist/cli.d.ts.map +1 -0
  14. package/dist/cli.js +228 -0
  15. package/dist/cli.js.map +1 -0
  16. package/dist/index.d.ts +4 -0
  17. package/dist/index.d.ts.map +1 -0
  18. package/dist/index.js +28 -0
  19. package/dist/index.js.map +1 -0
  20. package/dist/utils/assets.d.ts +2 -0
  21. package/dist/utils/assets.d.ts.map +1 -0
  22. package/dist/utils/assets.js +11 -0
  23. package/dist/utils/assets.js.map +1 -0
  24. package/dist/utils/enturApi.d.ts +42 -0
  25. package/dist/utils/enturApi.d.ts.map +1 -0
  26. package/dist/utils/enturApi.js +206 -0
  27. package/dist/utils/enturApi.js.map +1 -0
  28. package/dist/utils/fileReader.d.ts +2 -0
  29. package/dist/utils/fileReader.d.ts.map +1 -0
  30. package/dist/utils/fileReader.js +30 -0
  31. package/dist/utils/fileReader.js.map +1 -0
  32. package/dist/utils/fontLoader.d.ts +10 -0
  33. package/dist/utils/fontLoader.d.ts.map +1 -0
  34. package/dist/utils/fontLoader.js +36 -0
  35. package/dist/utils/fontLoader.js.map +1 -0
  36. package/dist/utils/idParser.d.ts +12 -0
  37. package/dist/utils/idParser.d.ts.map +1 -0
  38. package/dist/utils/idParser.js +59 -0
  39. package/dist/utils/idParser.js.map +1 -0
  40. package/dist/utils/nsrId.d.ts +3 -0
  41. package/dist/utils/nsrId.d.ts.map +1 -0
  42. package/dist/utils/nsrId.js +13 -0
  43. package/dist/utils/nsrId.js.map +1 -0
  44. package/dist/utils/pdfGenerator.d.ts +56 -0
  45. package/dist/utils/pdfGenerator.d.ts.map +1 -0
  46. package/dist/utils/pdfGenerator.js +526 -0
  47. package/dist/utils/pdfGenerator.js.map +1 -0
  48. package/package.json +69 -0
package/README.md ADDED
@@ -0,0 +1,182 @@
1
+ # NSR Barcode Generator
2
+
3
+ CLI and programmatic API for generating branded PDF posters (with a QR code) for NSR stop places. Embeddable in other apps (server, desktop) or used standalone.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ pnpm add @mrfylke/nsr-barcode-generator
9
+ ```
10
+
11
+ ## Quick start
12
+
13
+ ```typescript
14
+ import { NsrBarcodeApi } from "@mrfylke/nsr-barcode-generator";
15
+
16
+ await NsrBarcodeApi.generateSinglePdf({
17
+ nsrId: "NSR:StopPlace:39598",
18
+ outputDirectory: "./output",
19
+ });
20
+
21
+ const result = await NsrBarcodeApi.generateMultiplePdfs(
22
+ ["NSR:StopPlace:39598", "NSR:StopPlace:40308"],
23
+ { outputDirectory: "./output" }
24
+ );
25
+ console.log(result.generated, result.skipped, result.failed);
26
+ ```
27
+
28
+ ## API
29
+
30
+ ```typescript
31
+ class NsrBarcodeApi {
32
+ static generateSinglePdf(options: GenerateSinglePdfOptions): Promise<GenerateSinglePdfResult>;
33
+ static generateMultiplePdfs(stopPlaces: StopPlaceRequest[], options: PdfGenerationOptions): Promise<PdfGenerationResult>;
34
+ static processFile(options: ProcessFileOptions): Promise<ProcessFileResult>;
35
+ static validateNsrId(nsrId: string): ValidationResult;
36
+ static parseIds(content: string): Promise<IdParseResult>;
37
+ static parseIdsFromFile(filePath: string): Promise<IdParseResult>;
38
+ }
39
+ ```
40
+
41
+ ### Options
42
+
43
+ All three generation methods share these options:
44
+
45
+ ```typescript
46
+ interface PdfGenerationOptions {
47
+ outputDirectory: string;
48
+ format?: "A4" | "A3" | "Letter"; // default "A4"
49
+ orientation?: "landscape" | "portrait"; // default "landscape"
50
+ style?: PdfStyleConfig; // colors/logo, see below
51
+ overwrite?: boolean; // replace existing files (default false = skip)
52
+ onProgress?: (event: PdfProgressEvent) => void;
53
+
54
+ // Custom QR payload. Called once metadata is resolved; the returned
55
+ // string is used verbatim (no rewriting). Must be an absolute http(s)
56
+ // URL, otherwise that item fails with a per-item error. Defaults to
57
+ // `https://reise.frammr.no/departures/<id>?qr`.
58
+ generateQrUrl?: (stopPlace: StopPlaceQrContext) => string;
59
+
60
+ // Overrides how stop-place metadata is looked up for bare IDs.
61
+ // Defaults to the built-in Entur client. Useful for tests.
62
+ stopPlaceFetcher?: (ids: string[]) => Promise<(StopPlaceInfo | null)[]>;
63
+
64
+ // See "Supplying stop place data" below.
65
+ enrichTransportMode?: boolean; // default false
66
+ }
67
+
68
+ interface PdfStyleConfig {
69
+ headerFooterColor?: string; // default "#1A4D75"
70
+ logoPath?: string; // default: bundled FRAM logo
71
+ logoWidth?: number; // default 105
72
+ fallbackLogoText?: string; // default "FRAM"
73
+ fallbackLogoSubtext?: string; // default "Møre og Romsdal fylkeskommune"
74
+ }
75
+ ```
76
+
77
+ `generateSinglePdf` additionally takes `nsrId: string`, plus `name?`/`transportMode?` shortcuts (see below). `processFile` takes `filePath: string` instead of a stop-place array.
78
+
79
+ ### Supplying stop place data (skip Entur)
80
+
81
+ `generateMultiplePdfs` accepts a mix of bare IDs and known data - no separate list to keep in sync:
82
+
83
+ ```typescript
84
+ type StopPlaceRequest = string | { id: string; name: string; transportMode?: string[] };
85
+
86
+ await NsrBarcodeApi.generateMultiplePdfs(
87
+ [
88
+ { id: "NSR:StopPlace:10003", name: "Malmefjorden" }, // Entur skipped
89
+ { id: "NSR:StopPlace:10004", name: "X", transportMode: ["bus"] },
90
+ "NSR:StopPlace:40308", // resolved via Entur
91
+ ],
92
+ { outputDirectory: "./output" }
93
+ );
94
+ ```
95
+
96
+ Duplicate IDs: last entry wins. If every entry has data, Entur is never called. If a bare ID can't be resolved, that item fails (`result.failed`) rather than producing a poster with a misleading name.
97
+
98
+ `generateSinglePdf` has the same shortcut as flat fields: `{ nsrId, name?, transportMode? }` - supplying `name` skips Entur.
99
+
100
+ Missing `transportMode` just falls back to the default bus icon. To fetch the correct icon while keeping your supplied `name`, set `enrichTransportMode: true` - it fetches only the entries missing a transport mode, only reads that field, and never overwrites your `name` (a failed fetch still succeeds with the bus icon).
101
+
102
+ ### Result & progress
103
+
104
+ ```typescript
105
+ interface PdfGenerationResult {
106
+ generated: { nsrId: string; outputPath: string }[];
107
+ skipped: { nsrId: string; outputPath: string }[]; // overwrite: false and file existed
108
+ failed: { nsrId: string; error: string }[];
109
+ generatedFiles: string[]; // = generated.map(g => g.outputPath), kept for compatibility
110
+ totalGenerated: number; // = generated.length
111
+ outputDirectory: string;
112
+ }
113
+
114
+ interface PdfProgressEvent {
115
+ current: number; total: number; nsrId: string;
116
+ outputPath?: string;
117
+ status: "generated" | "skipped" | "error";
118
+ error?: string;
119
+ }
120
+ ```
121
+
122
+ `onProgress` fires once per requested ID. One item failing never aborts the batch.
123
+
124
+ ### Types
125
+
126
+ `ProcessFileOptions/Result`, `GenerateSinglePdfOptions/Result`, `PdfGenerationOptions/Result`, `PdfProgressEvent`, `PdfStyleConfig`, `StopPlaceQrContext`, `StopPlaceId`/`StopPlaceInput`/`StopPlaceRequest`, `ValidationResult`, `IdParseResult`/`IdParseError` are all exported.
127
+
128
+ ### NSR ID format & filenames
129
+
130
+ Only `NSR:StopPlace:<digits>` is accepted (no whitespace, no `NSR:Quay:*`, no extra segments).
131
+
132
+ Output files are named `{NSR_ID}-{slugified-name}.pdf`, e.g. `NSR_StopPlace_39598-malmefjorden.pdf` (Norwegian characters transliterated: `æ→ae`, `ø→o`, `å→aa`).
133
+
134
+ ## CLI
135
+
136
+ ```bash
137
+ nsr-barcode file ids.txt -o ./output [-f A4|A3|Letter] [--orientation landscape|portrait] [--overwrite] \
138
+ [--header-color "#2E8B57"] [--logo-path ./logo.png] [--logo-width 120] \
139
+ [--fallback-text "MY ORG"] [--fallback-subtext "Subtitle"]
140
+
141
+ nsr-barcode id NSR:StopPlace:39598 -o ./output # same options as above
142
+ nsr-barcode validate NSR:StopPlace:39598 # check ID format only
143
+ nsr-barcode parse ids.txt # list unique IDs, no PDFs
144
+ ```
145
+
146
+ ## Embeddability
147
+
148
+ Fonts (bundled Poppins) and images resolve relative to the package's own install location, not `process.cwd()` - safe inside a packaged desktop app with a read-only install dir. Nothing is downloaded or cached to disk at runtime; a bundled font that fails to read falls back to Helvetica.
149
+
150
+ ## Development
151
+
152
+ ```bash
153
+ pnpm install
154
+ pnpm run build # compile
155
+ pnpm run test # vitest
156
+ pnpm run dev ... # tsx, same args as the CLI
157
+ ```
158
+
159
+ ```
160
+ src/
161
+ ├── api.ts, cli.ts, index.ts
162
+ └── utils/ fileReader, idParser, nsrId, assets, fontLoader, pdfGenerator, enturApi
163
+ assets/
164
+ ├── fonts/ bundled Poppins TTFs
165
+ └── images/ transport-mode icons, default logo
166
+ ```
167
+
168
+ ## Migrating to 1.1.0
169
+
170
+ Backward-compatible minor release:
171
+
172
+ - New optional options across all generation methods: `generateQrUrl`, `overwrite`, `onProgress`, `stopPlaceFetcher`, `enrichTransportMode`; `generateSinglePdf` also gained `name`/`transportMode`. Omitting them keeps prior behavior, including the prior QR URL.
173
+ - `generateMultiplePdfs`'s first parameter is now `StopPlaceRequest[]` instead of `string[]` - a plain `string[]` still works unchanged.
174
+ - `PdfGenerationResult` gained `generated`/`skipped`/`failed`; `generatedFiles`/`totalGenerated` are unchanged.
175
+ - Package renamed to the scoped `@mrfylke/nsr-barcode-generator`.
176
+ - `options.format` now actually controls page size (previously accepted but ignored - pages were always A4).
177
+ - Fonts are bundled, no longer downloaded from GitHub at runtime.
178
+ - Unresolvable stop-place metadata (no Entur match, no supplied `name`) is now a per-item error instead of silently falling back to the raw ID as the poster title.
179
+
180
+ ## License
181
+
182
+ MIT
Binary file
Binary file
Binary file
package/dist/api.d.ts ADDED
@@ -0,0 +1,48 @@
1
+ import { formatIdCountResult, IdParseError, IdParseResult } from "./utils/idParser";
2
+ import { PdfGenerationOptions, PdfGenerationResult, PdfGenerationItemResult, PdfGenerationFailure, PdfProgressEvent, PdfStyleConfig, StopPlaceQrContext, StopPlaceId, StopPlaceInput, StopPlaceRequest } from "./utils/pdfGenerator";
3
+ import { extractStopPlaceNumber } from "./utils/nsrId";
4
+ interface CommonPdfOptions {
5
+ format?: "A4" | "A3" | "Letter";
6
+ orientation?: "landscape" | "portrait";
7
+ style?: PdfStyleConfig;
8
+ generateQrUrl?: (stopPlace: StopPlaceQrContext) => string;
9
+ overwrite?: boolean;
10
+ onProgress?: (event: PdfProgressEvent) => void;
11
+ stopPlaceFetcher?: PdfGenerationOptions["stopPlaceFetcher"];
12
+ enrichTransportMode?: boolean;
13
+ }
14
+ export interface ProcessFileOptions extends CommonPdfOptions {
15
+ filePath: string;
16
+ outputDirectory: string;
17
+ }
18
+ export interface ProcessFileResult {
19
+ parseResult: IdParseResult;
20
+ pdfResult: PdfGenerationResult;
21
+ summary: string;
22
+ }
23
+ export interface GenerateSinglePdfOptions extends CommonPdfOptions {
24
+ nsrId: string;
25
+ outputDirectory: string;
26
+ name?: string;
27
+ transportMode?: string[];
28
+ }
29
+ export interface GenerateSinglePdfResult {
30
+ pdfResult: PdfGenerationResult;
31
+ success: boolean;
32
+ summary: string;
33
+ }
34
+ export interface ValidationResult {
35
+ isValid: boolean;
36
+ error?: string;
37
+ }
38
+ export declare class NsrBarcodeApi {
39
+ static processFile(options: ProcessFileOptions): Promise<ProcessFileResult>;
40
+ static generateSinglePdf(options: GenerateSinglePdfOptions): Promise<GenerateSinglePdfResult>;
41
+ static generateMultiplePdfs(stopPlaces: StopPlaceRequest[], options: PdfGenerationOptions): Promise<PdfGenerationResult>;
42
+ static validateNsrId(nsrId: string): ValidationResult;
43
+ static parseIds(content: string): Promise<IdParseResult>;
44
+ static parseIdsFromFile(filePath: string): Promise<IdParseResult>;
45
+ }
46
+ export { IdParseResult, IdParseError, PdfGenerationOptions, PdfGenerationResult, PdfGenerationItemResult, PdfGenerationFailure, PdfProgressEvent, PdfStyleConfig, StopPlaceQrContext, StopPlaceId, StopPlaceInput, StopPlaceRequest, formatIdCountResult, extractStopPlaceNumber, };
47
+ export default NsrBarcodeApi;
48
+ //# sourceMappingURL=api.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAMA,OAAO,EAEL,mBAAmB,EACnB,YAAY,EACZ,aAAa,EACd,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAEL,oBAAoB,EACpB,mBAAmB,EACnB,uBAAuB,EACvB,oBAAoB,EACpB,gBAAgB,EAChB,cAAc,EACd,kBAAkB,EAClB,WAAW,EACX,cAAc,EACd,gBAAgB,EACjB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAyB,sBAAsB,EAAE,MAAM,eAAe,CAAC;AAM9E,UAAU,gBAAgB;IAExB,MAAM,CAAC,EAAE,IAAI,GAAG,IAAI,GAAG,QAAQ,CAAC;IAEhC,WAAW,CAAC,EAAE,WAAW,GAAG,UAAU,CAAC;IAEvC,KAAK,CAAC,EAAE,cAAc,CAAC;IAKvB,aAAa,CAAC,EAAE,CAAC,SAAS,EAAE,kBAAkB,KAAK,MAAM,CAAC;IAE1D,SAAS,CAAC,EAAE,OAAO,CAAC;IAEpB,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,gBAAgB,KAAK,IAAI,CAAC;IAE/C,gBAAgB,CAAC,EAAE,oBAAoB,CAAC,kBAAkB,CAAC,CAAC;IAS5D,mBAAmB,CAAC,EAAE,OAAO,CAAC;CAC/B;AAKD,MAAM,WAAW,kBAAmB,SAAQ,gBAAgB;IAE1D,QAAQ,EAAE,MAAM,CAAC;IAEjB,eAAe,EAAE,MAAM,CAAC;CACzB;AAKD,MA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ClB,WAAW,EACX,cAAc,EACd,gBAAgB,EAChB,mBAAmB,EACnB,sBAAsB,GACvB,CAAC;eAGa,aAAa"}
package/dist/api.js ADDED
@@ -0,0 +1,133 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.extractStopPlaceNumber = exports.formatIdCountResult = exports.NsrBarcodeApi = void 0;
4
+ const fileReader_1 = require("./utils/fileReader");
5
+ const idParser_1 = require("./utils/idParser");
6
+ Object.defineProperty(exports, "formatIdCountResult", { enumerable: true, get: function () { return idParser_1.formatIdCountResult; } });
7
+ const pdfGenerator_1 = require("./utils/pdfGenerator");
8
+ const nsrId_1 = require("./utils/nsrId");
9
+ Object.defineProperty(exports, "extractStopPlaceNumber", { enumerable: true, get: function () { return nsrId_1.extractStopPlaceNumber; } });
10
+ function buildPdfOptions(outputDirectory, options) {
11
+ const pdfOptions = { outputDirectory };
12
+ if (options.format) {
13
+ pdfOptions.format = options.format;
14
+ }
15
+ if (options.orientation) {
16
+ pdfOptions.orientation = options.orientation;
17
+ }
18
+ if (options.style) {
19
+ pdfOptions.style = options.style;
20
+ }
21
+ if (options.generateQrUrl) {
22
+ pdfOptions.generateQrUrl = options.generateQrUrl;
23
+ }
24
+ if (options.overwrite !== undefined) {
25
+ pdfOptions.overwrite = options.overwrite;
26
+ }
27
+ if (options.onProgress) {
28
+ pdfOptions.onProgress = options.onProgress;
29
+ }
30
+ if (options.stopPlaceFetcher) {
31
+ pdfOptions.stopPlaceFetcher = options.stopPlaceFetcher;
32
+ }
33
+ if (options.enrichTransportMode !== undefined) {
34
+ pdfOptions.enrichTransportMode = options.enrichTransportMode;
35
+ }
36
+ return pdfOptions;
37
+ }
38
+ class NsrBarcodeApi {
39
+ static async processFile(options) {
40
+ const { filePath, outputDirectory } = options;
41
+ try {
42
+ const content = await (0, fileReader_1.readFile)(filePath);
43
+ const parseResult = await (0, idParser_1.parseUniqueIds)(content);
44
+ const uniqueIdsArray = Array.from(parseResult.uniqueIds);
45
+ for (const nsrId of uniqueIdsArray) {
46
+ const validation = this.validateNsrId(nsrId);
47
+ if (!validation.isValid) {
48
+ throw new Error(`Invalid NSR ID "${nsrId}": ${validation.error}`);
49
+ }
50
+ }
51
+ const pdfOptions = buildPdfOptions(outputDirectory, options);
52
+ const pdfResult = await (0, pdfGenerator_1.generatePdfsForStopPlaces)(uniqueIdsArray, pdfOptions);
53
+ const parseSummary = (0, idParser_1.formatIdCountResult)(parseResult);
54
+ const pdfSummary = `Generated ${pdfResult.totalGenerated} PDF files in ${pdfResult.outputDirectory}`;
55
+ const summary = `${parseSummary}\n\n${pdfSummary}`;
56
+ return {
57
+ parseResult,
58
+ pdfResult,
59
+ summary,
60
+ };
61
+ }
62
+ catch (error) {
63
+ if (error instanceof Error) {
64
+ throw error;
65
+ }
66
+ throw new Error("An unexpected error occurred during file processing");
67
+ }
68
+ }
69
+ static async generateSinglePdf(options) {
70
+ const { nsrId, outputDirectory, name, transportMode } = options;
71
+ try {
72
+ const validation = this.validateNsrId(nsrId);
73
+ if (!validation.isValid) {
74
+ throw new Error(validation.error);
75
+ }
76
+ const request = name
77
+ ? { id: nsrId, name, ...(transportMode ? { transportMode } : {}) }
78
+ : nsrId;
79
+ const pdfOptions = buildPdfOptions(outputDirectory, options);
80
+ const pdfResult = await (0, pdfGenerator_1.generatePdfsForStopPlaces)([request], pdfOptions);
81
+ const success = pdfResult.totalGenerated > 0 || pdfResult.skipped.length > 0;
82
+ const summary = success
83
+ ? `Successfully generated PDF for ${nsrId} in ${pdfResult.outputDirectory}`
84
+ : `Failed to generate PDF for ${nsrId}`;
85
+ return {
86
+ pdfResult,
87
+ success,
88
+ summary,
89
+ };
90
+ }
91
+ catch (error) {
92
+ if (error instanceof Error) {
93
+ throw error;
94
+ }
95
+ throw new Error("An unexpected error occurred during PDF generation");
96
+ }
97
+ }
98
+ static async generateMultiplePdfs(stopPlaces, options) {
99
+ for (const request of stopPlaces) {
100
+ const nsrId = typeof request === "string" ? request : request.id;
101
+ const validation = this.validateNsrId(nsrId);
102
+ if (!validation.isValid) {
103
+ throw new Error(`Invalid NSR ID "${nsrId}": ${validation.error}`);
104
+ }
105
+ }
106
+ return (0, pdfGenerator_1.generatePdfsForStopPlaces)(stopPlaces, options);
107
+ }
108
+ static validateNsrId(nsrId) {
109
+ if (!nsrId) {
110
+ return {
111
+ isValid: false,
112
+ error: "NSR ID cannot be empty",
113
+ };
114
+ }
115
+ if (!(0, nsrId_1.isValidNsrStopPlaceId)(nsrId)) {
116
+ return {
117
+ isValid: false,
118
+ error: "Invalid NSR ID format. Expected format: NSR:StopPlace:<digits> with no extra whitespace or characters",
119
+ };
120
+ }
121
+ return { isValid: true };
122
+ }
123
+ static async parseIds(content) {
124
+ return (0, idParser_1.parseUniqueIds)(content);
125
+ }
126
+ static async parseIdsFromFile(filePath) {
127
+ const content = await (0, fileReader_1.readFile)(filePath);
128
+ return (0, idParser_1.parseUniqueIds)(content);
129
+ }
130
+ }
131
+ exports.NsrBarcodeApi = NsrBarcodeApi;
132
+ exports.default = NsrBarcodeApi;
133
+ //# sourceMappingURL=api.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api.js","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":";;;AAKA,mDAA8C;AAC9C,+CAK0B;oGAHxB,8BAAmB;AAIrB,uDAY8B;AAC9B,yCAA8E;uGAA9C,8BAAsB;AAoGtD,SAAS,eAAe,CACtB,eAAuB,EACvB,OAAyB;IAEzB,MAAM,UAAU,GAAyB,EAAE,eAAe,EAAE,CAAC;IAC7D,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;QACnB,UAAU,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IACrC,CAAC;IACD,IAAI,OAAO,CAAC,WAAW,EAAE,CAAC;QACxB,UAAU,CAAC,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC;IAC/C,CAAC;IACD,IAAI,OAAO,CAAC,KAAK,EAAE,CAAC;QAClB,UAAU,CAAC,K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QAChC,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,OAAO;gBACL,OAAO,EAAE,KAAK;gBACd,KAAK,EAAE,wBAAwB;aAChC,CAAC;QACJ,CAAC;QAED,IAAI,CAAC,IAAA,6BAAqB,EAAC,KAAK,CAAC,EAAE,CAAC;YAClC,OAAO;gBACL,OAAO,EAAE,KAAK;gBACd,KAAK,EACH,uGAAuG;aAC1G,CAAC;QACJ,CAAC;QAED,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;IAC3B,CAAC;IAOD,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,OAAe;QACnC,OAAO,IAAA,yBAAc,EAAC,OAAO,CAAC,CAAC;IACjC,CAAC;IAOD,MAAM,CAAC,KAAK,CAAC,gBAAgB,CAAC,QAAgB;QAC5C,MAAM,OAAO,GAAG,MAAM,IAAA,qBAAQ,EAAC,QAAQ,CAAC,CAAC;QACzC,OAAO,IAAA,yBAAc,EAAC,OAAO,CAAC,CAAC;IACjC,CAAC;CACF;;kBAqBc,aAAa"}
package/dist/cli.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=cli.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":""}
package/dist/cli.js ADDED
@@ -0,0 +1,228 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ const commander_1 = require("commander");
5
+ const api_1 = require("./api");
6
+ const package_json_1 = require("../package.json");
7
+ const program = new commander_1.Command();
8
+ program
9
+ .name("nsr-barcode")
10
+ .description("Generate PDF files for unique IDs from input files")
11
+ .version(package_json_1.version);
12
+ program
13
+ .command("file")
14
+ .argument("<file>", "path to the file containing IDs (one per line)")
15
+ .requiredOption("-o, --output <directory>", "output directory for generated PDFs")
16
+ .option("-f, --format <format>", "PDF format (A4, A3, Letter)", "A4")
17
+ .option("--orientation <orientation>", "PDF orientation (landscape, portrait)", "landscape")
18
+ .option("--header-color <color>", "Header and footer background color (hex format, e.g., #1A4D75)")
19
+ .option("--logo-path <path>", "Path to logo image file for lower right corner")
20
+ .option("--logo-width <width>", "Logo width in pixels", parseInt)
21
+ .option("--fallback-text <text>", "Fallback text if logo cannot be loaded")
22
+ .option("--fallback-subtext <text>", "Additional fallback text (subtitle)")
23
+ .option("--overwrite", "Replace existing output PDFs instead of skipping them")
24
+ .description("Generate PDF files for unique IDs from an input file")
25
+ .action(async (filePath, options) => {
26
+ try {
27
+ const format = options.format;
28
+ if (format && !["A4", "A3", "Letter"].includes(format)) {
29
+ console.error(`Error: Invalid format "${format}". Supported formats: A4, A3, Letter`);
30
+ process.exit(1);
31
+ }
32
+ const orientation = options.orientation;
33
+ if (orientation && !["landscape", "portrait"].includes(orientation)) {
34
+ console.error(`Error: Invalid orientation "${orientation}". Supported orientations: landscape, portrait`);
35
+ process.exit(1);
36
+ }
37
+ console.log(`Processing file: ${filePath}`);
38
+ console.log(`Output directory: ${options.output}`);
39
+ if (format && format !== "A4") {
40
+ console.log(`PDF format: ${format}`);
41
+ }
42
+ if (orientation && orientation !== "landscape") {
43
+ console.log(`PDF orientation: ${orientation}`);
44
+ }
45
+ const styleConfig = {};
46
+ if (options.headerColor) {
47
+ styleConfig.headerFooterColor = options.headerColor;
48
+ }
49
+ if (options.logoPath) {
50
+ styleConfig.logoPath = options.logoPath;
51
+ }
52
+ if (options.logoWidth) {
53
+ styleConfig.logoWidth = options.logoWidth;
54
+ }
55
+ if (options.fallbackText) {
56
+ styleConfig.fallbackLogoText = options.fallbackText;
57
+ }
58
+ if (options.fallbackSubtext) {
59
+ styleConfig.fallbackLogoSubtext = options.fallbackSubtext;
60
+ }
61
+ const processOptions = {
62
+ filePath,
63
+ outputDirectory: options.output,
64
+ };
65
+ if (format && format !== "A4") {
66
+ processOptions.format = format;
67
+ }
68
+ if (orientation && orientation !== "landscape") {
69
+ processOptions.orientation = orientation;
70
+ }
71
+ if (Object.keys(styleConfig).length > 0) {
72
+ processOptions.style = styleConfig;
73
+ }
74
+ if (options.overwrite) {
75
+ processOptions.overwrite = true;
76
+ }
77
+ const result = await api_1.NsrBarcodeApi.processFile(processOptions);
78
+ console.log("\n" + result.summary);
79
+ const uniqueIdsCount = result.parseResult.uniqueIds.size;
80
+ if (result.pdfResult.totalGenerated !== uniqueIdsCount) {
81
+ console.warn(`\nWarning: Only ${result.pdfResult.totalGenerated} of ${uniqueIdsCount} PDFs were generated successfully`);
82
+ }
83
+ }
84
+ catch (error) {
85
+ handleError(error);
86
+ }
87
+ });
88
+ program
89
+ .command("id")
90
+ .argument("<nsrId>", "single NSR ID (e.g., NSR:StopPlace:39598)")
91
+ .requiredOption("-o, --output <directory>", "output directory for generated PDF")
92
+ .option("-f, --format <format>", "PDF format (A4, A3, Letter)", "A4")
93
+ .option("--orientation <orientation>", "PDF orientation (landscape, portrait)", "landscape")
94
+ .option("--header-color <color>", "Header and footer background color (hex format, e.g., #1A4D75)")
95
+ .option("--logo-path <path>", "Path to logo image file for lower right corner")
96
+ .option("--logo-width <width>", "Logo width in pixels", parseInt)
97
+ .option("--fallback-text <text>", "Fallback text if logo cannot be loaded")
98
+ .option("--fallback-subtext <text>", "Additional fallback text (subtitle)")
99
+ .option("--overwrite", "Replace an existing output PDF instead of skipping it")
100
+ .description("Generate PDF for a single NSR ID")
101
+ .action(async (nsrId, options) => {
102
+ try {
103
+ const format = options.format;
104
+ if (format && !["A4", "A3", "Letter"].includes(format)) {
105
+ console.error(`Error: Invalid format "${format}". Supported formats: A4, A3, Letter`);
106
+ process.exit(1);
107
+ }
108
+ const orientation = options.orientation;
109
+ if (orientation && !["landscape", "portrait"].includes(orientation)) {
110
+ console.error(`Error: Invalid orientation "${orientation}". Supported orientations: landscape, portrait`);
111
+ process.exit(1);
112
+ }
113
+ console.log(`Generating PDF for ID: ${nsrId}`);
114
+ console.log(`Output directory: ${options.output}`);
115
+ if (format && format !== "A4") {
116
+ console.log(`PDF format: ${format}`);
117
+ }
118
+ if (orientation && orientation !== "landscape") {
119
+ console.log(`PDF orientation: ${orientation}`);
120
+ }
121
+ const styleConfig = {};
122
+ if (options.headerColor) {
123
+ styleConfig.headerFooterColor = options.headerColor;
124
+ }
125
+ if (options.logoPath) {
126
+ styleConfig.logoPath = options.logoPath;
127
+ }
128
+ if (options.logoWidth) {
129
+ styleConfig.logoWidth = options.logoWidth;
130
+ }
131
+ if (options.fallbackText) {
132
+ styleConfig.fallbackLogoText = options.fallbackText;
133
+ }
134
+ if (options.fallbackSubtext) {
135
+ styleConfig.fallbackLogoSubtext = options.fallbackSubtext;
136
+ }
137
+ const generateOptions = {
138
+ nsrId,
139
+ outputDirectory: options.output,
140
+ };
141
+ if (format && format !== "A4") {
142
+ generateOptions.format = format;
143
+ }
144
+ if (orientation && orientation !== "landscape") {
145
+ generateOptions.orientation = orientation;
146
+ }
147
+ if (Object.keys(styleConfig).length > 0) {
148
+ generateOptions.style = styleConfig;
149
+ }
150
+ if (options.overwrite) {
151
+ generateOptions.overwrite = true;
152
+ }
153
+ const result = await api_1.NsrBarcodeApi.generateSinglePdf(generateOptions);
154
+ console.log("\n" + result.summary);
155
+ if (!result.success) {
156
+ console.error(`Error: Failed to generate PDF for ID: ${nsrId}`);
157
+ process.exit(1);
158
+ }
159
+ }
160
+ catch (error) {
161
+ handleError(error);
162
+ }
163
+ });
164
+ program
165
+ .command("validate")
166
+ .argument("<nsrId>", "NSR ID to validate (e.g., NSR:StopPlace:39598)")
167
+ .description("Validate NSR ID format without generating PDF")
168
+ .action((nsrId) => {
169
+ const validation = api_1.NsrBarcodeApi.validateNsrId(nsrId);
170
+ if (validation.isValid) {
171
+ console.log(`✓ Valid NSR ID: ${nsrId}`);
172
+ }
173
+ else {
174
+ console.error(`✗ Invalid NSR ID: ${validation.error}`);
175
+ process.exit(1);
176
+ }
177
+ });
178
+ program
179
+ .command("parse")
180
+ .argument("<file>", "path to the file containing IDs (one per line)")
181
+ .description("Parse and validate IDs from file without generating PDFs")
182
+ .action(async (filePath) => {
183
+ try {
184
+ console.log(`Parsing file: ${filePath}`);
185
+ const result = await api_1.NsrBarcodeApi.parseIdsFromFile(filePath);
186
+ const summary = require("./utils/idParser").formatIdCountResult(result);
187
+ console.log("\n" + summary);
188
+ console.log(`\nUnique IDs found:`);
189
+ Array.from(result.uniqueIds).forEach((id, index) => {
190
+ console.log(`${index + 1}. ${id}`);
191
+ });
192
+ }
193
+ catch (error) {
194
+ handleError(error);
195
+ }
196
+ });
197
+ function handleError(error) {
198
+ if (error instanceof Error) {
199
+ if ("code" in error) {
200
+ const idError = error;
201
+ switch (idError.code) {
202
+ case "EMPTY_FILE":
203
+ console.error(`Error: Input file is empty or contains no content`);
204
+ break;
205
+ case "NO_VALID_IDS":
206
+ console.error(`Error: No valid IDs found in the file`);
207
+ break;
208
+ case "INVALID_FORMAT":
209
+ console.error(`Error: ${idError.message}`);
210
+ break;
211
+ default:
212
+ console.error(`Error: ${error.message}`);
213
+ }
214
+ }
215
+ else {
216
+ console.error(`Error: ${error.message}`);
217
+ }
218
+ }
219
+ else {
220
+ console.error("An unexpected error occurred");
221
+ }
222
+ process.exit(1);
223
+ }
224
+ if (process.argv.length === 2) {
225
+ program.help();
226
+ }
227
+ program.parse();
228
+ //# sourceMappingURL=cli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";;;AAOA,yCAAoC;AACpC,+BAAoE;AACpE,kDAA0C;AAE1C,MAAM,OAAO,GAAG,IAAI,mBAAO,EAAE,CAAC;AAE9B,OAAO;KACJ,IAAI,CAAC,aAAa,CAAC;KACnB,WAAW,CAAC,oDAAoD,CAAC;KACjE,OAAO,CAAC,sBAAO,CAAC,CAAC;AAEpB,OAAO;KACJ,OAAO,CAAC,MAAM,CAAC;KACf,QAAQ,CAAC,QAAQ,EAAE,gDAAgD,CAAC;KACpE,cAAc,CACb,0B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0 +1,4 @@
1
+ #!/usr/bin/env node
2
+ export * from "./api";
3
+ export { default as NsrBarcodeApi } from "./api";
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AASA,cAAc,OAAO,CAAC;AACtB,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,OAAO,CAAC"}