@botler/1403-form-filler-module 1.0.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.
- package/README.md +203 -0
- package/dist/canvasser-data-mapper.d.ts +110 -0
- package/dist/canvasser-data-mapper.d.ts.map +1 -0
- package/dist/canvasser-data-mapper.js +259 -0
- package/dist/canvasser-data-mapper.js.map +1 -0
- package/dist/cli.d.ts +14 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +127 -0
- package/dist/cli.js.map +1 -0
- package/dist/config.d.ts +58 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +297 -0
- package/dist/config.js.map +1 -0
- package/dist/db/index.d.ts +6 -0
- package/dist/db/index.d.ts.map +1 -0
- package/dist/db/index.js +17 -0
- package/dist/db/index.js.map +1 -0
- package/dist/db/pool.d.ts +34 -0
- package/dist/db/pool.d.ts.map +1 -0
- package/dist/db/pool.js +67 -0
- package/dist/db/pool.js.map +1 -0
- package/dist/db/queries.d.ts +56 -0
- package/dist/db/queries.d.ts.map +1 -0
- package/dist/db/queries.js +192 -0
- package/dist/db/queries.js.map +1 -0
- package/dist/form-filler.d.ts +64 -0
- package/dist/form-filler.d.ts.map +1 -0
- package/dist/form-filler.js +328 -0
- package/dist/form-filler.js.map +1 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +36 -0
- package/dist/index.js.map +1 -0
- package/dist/pdf-converter/converter.d.ts +77 -0
- package/dist/pdf-converter/converter.d.ts.map +1 -0
- package/dist/pdf-converter/converter.js +277 -0
- package/dist/pdf-converter/converter.js.map +1 -0
- package/dist/pdf-converter/index.d.ts +7 -0
- package/dist/pdf-converter/index.d.ts.map +1 -0
- package/dist/pdf-converter/index.js +11 -0
- package/dist/pdf-converter/index.js.map +1 -0
- package/dist/pdf-converter/types.d.ts +82 -0
- package/dist/pdf-converter/types.d.ts.map +1 -0
- package/dist/pdf-converter/types.js +16 -0
- package/dist/pdf-converter/types.js.map +1 -0
- package/dist/pdf-filler/fieldMapper.d.ts +48 -0
- package/dist/pdf-filler/fieldMapper.d.ts.map +1 -0
- package/dist/pdf-filler/fieldMapper.js +128 -0
- package/dist/pdf-filler/fieldMapper.js.map +1 -0
- package/dist/pdf-filler/file-sources/base.d.ts +42 -0
- package/dist/pdf-filler/file-sources/base.d.ts.map +1 -0
- package/dist/pdf-filler/file-sources/base.js +9 -0
- package/dist/pdf-filler/file-sources/base.js.map +1 -0
- package/dist/pdf-filler/file-sources/index.d.ts +9 -0
- package/dist/pdf-filler/file-sources/index.d.ts.map +1 -0
- package/dist/pdf-filler/file-sources/index.js +8 -0
- package/dist/pdf-filler/file-sources/index.js.map +1 -0
- package/dist/pdf-filler/file-sources/local-file-source.d.ts +56 -0
- package/dist/pdf-filler/file-sources/local-file-source.d.ts.map +1 -0
- package/dist/pdf-filler/file-sources/local-file-source.js +133 -0
- package/dist/pdf-filler/file-sources/local-file-source.js.map +1 -0
- package/dist/pdf-filler/file-sources/s3-file-source.d.ts +63 -0
- package/dist/pdf-filler/file-sources/s3-file-source.d.ts.map +1 -0
- package/dist/pdf-filler/file-sources/s3-file-source.js +141 -0
- package/dist/pdf-filler/file-sources/s3-file-source.js.map +1 -0
- package/dist/pdf-filler/filler.d.ts +60 -0
- package/dist/pdf-filler/filler.d.ts.map +1 -0
- package/dist/pdf-filler/filler.js +156 -0
- package/dist/pdf-filler/filler.js.map +1 -0
- package/dist/pdf-filler/index.d.ts +16 -0
- package/dist/pdf-filler/index.d.ts.map +1 -0
- package/dist/pdf-filler/index.js +25 -0
- package/dist/pdf-filler/index.js.map +1 -0
- package/dist/pdf-filler/pdfFormFiller.d.ts +95 -0
- package/dist/pdf-filler/pdfFormFiller.d.ts.map +1 -0
- package/dist/pdf-filler/pdfFormFiller.js +352 -0
- package/dist/pdf-filler/pdfFormFiller.js.map +1 -0
- package/dist/pdf-filler/types.d.ts +68 -0
- package/dist/pdf-filler/types.d.ts.map +1 -0
- package/dist/pdf-filler/types.js +10 -0
- package/dist/pdf-filler/types.js.map +1 -0
- package/dist/pdf-filler/utils/path-detector.d.ts +58 -0
- package/dist/pdf-filler/utils/path-detector.d.ts.map +1 -0
- package/dist/pdf-filler/utils/path-detector.js +124 -0
- package/dist/pdf-filler/utils/path-detector.js.map +1 -0
- package/dist/pdf-filler/vercelOGSignatureGenerator.d.ts +41 -0
- package/dist/pdf-filler/vercelOGSignatureGenerator.d.ts.map +1 -0
- package/dist/pdf-filler/vercelOGSignatureGenerator.js +146 -0
- package/dist/pdf-filler/vercelOGSignatureGenerator.js.map +1 -0
- package/dist/pdf-merger/index.d.ts +6 -0
- package/dist/pdf-merger/index.d.ts.map +1 -0
- package/dist/pdf-merger/index.js +9 -0
- package/dist/pdf-merger/index.js.map +1 -0
- package/dist/pdf-merger/merger.d.ts +25 -0
- package/dist/pdf-merger/merger.d.ts.map +1 -0
- package/dist/pdf-merger/merger.js +92 -0
- package/dist/pdf-merger/merger.js.map +1 -0
- package/dist/pdf-merger/types.d.ts +24 -0
- package/dist/pdf-merger/types.d.ts.map +1 -0
- package/dist/pdf-merger/types.js +9 -0
- package/dist/pdf-merger/types.js.map +1 -0
- package/dist/s3/index.d.ts +6 -0
- package/dist/s3/index.d.ts.map +1 -0
- package/dist/s3/index.js +9 -0
- package/dist/s3/index.js.map +1 -0
- package/dist/s3/types.d.ts +45 -0
- package/dist/s3/types.d.ts.map +1 -0
- package/dist/s3/types.js +9 -0
- package/dist/s3/types.js.map +1 -0
- package/dist/s3/uploader.d.ts +47 -0
- package/dist/s3/uploader.d.ts.map +1 -0
- package/dist/s3/uploader.js +112 -0
- package/dist/s3/uploader.js.map +1 -0
- package/dist/shared/index.d.ts +6 -0
- package/dist/shared/index.d.ts.map +1 -0
- package/dist/shared/index.js +10 -0
- package/dist/shared/index.js.map +1 -0
- package/dist/shared/logger.d.ts +59 -0
- package/dist/shared/logger.d.ts.map +1 -0
- package/dist/shared/logger.js +155 -0
- package/dist/shared/logger.js.map +1 -0
- package/dist/types/canvasser-profile.d.ts +38 -0
- package/dist/types/canvasser-profile.d.ts.map +1 -0
- package/dist/types/canvasser-profile.js +11 -0
- package/dist/types/canvasser-profile.js.map +1 -0
- package/dist/types/config.d.ts +137 -0
- package/dist/types/config.d.ts.map +1 -0
- package/dist/types/config.js +9 -0
- package/dist/types/config.js.map +1 -0
- package/dist/types/db-tables.d.ts +143 -0
- package/dist/types/db-tables.d.ts.map +1 -0
- package/dist/types/db-tables.js +53 -0
- package/dist/types/db-tables.js.map +1 -0
- package/dist/types/index.d.ts +8 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +23 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types.d.ts +10 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +26 -0
- package/dist/types.js.map +1 -0
- package/package.json +54 -0
- package/templates/README.md +19 -0
- package/templates/template.pdf +0 -0
package/README.md
ADDED
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
# @botler/1403-form-filler-module
|
|
2
|
+
|
|
3
|
+
Fills Alberta **Form 1403** PDFs for canvassers. Fetches data from Neon PostgreSQL, fills AcroForm fields, overlays cursive signatures, flattens to image-PDFs, merges per-batch, and uploads to AWS S3.
|
|
4
|
+
|
|
5
|
+
Usable as a **library** (`import { FormFiller }`) or as a **CLI** (`npx fill-1403 --all`).
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @botler/1403-form-filler-module
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
> Requires `NPM_TOKEN` for the private `@botler` scope (see `.npmrc`).
|
|
14
|
+
|
|
15
|
+
## Library usage
|
|
16
|
+
|
|
17
|
+
### ESM (`.mjs` / `"type": "module"`)
|
|
18
|
+
|
|
19
|
+
```js
|
|
20
|
+
import { FormFiller } from "@botler/1403-form-filler-module";
|
|
21
|
+
|
|
22
|
+
const filler = new FormFiller({
|
|
23
|
+
databaseUrl: process.env.WNC_TRACKING_DATABASE_URI,
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
// Single user
|
|
27
|
+
const result = await filler.fillForUser("user-abc-123");
|
|
28
|
+
console.log(result); // { success: true, userId: "user-abc-123", outputPath: "..." }
|
|
29
|
+
|
|
30
|
+
// All open batches (fill → flatten → merge → S3 upload)
|
|
31
|
+
const results = await filler.fillAll();
|
|
32
|
+
|
|
33
|
+
// Cleanup (closes DB pool if we created it)
|
|
34
|
+
await filler.destroy();
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### CJS (`require`)
|
|
38
|
+
|
|
39
|
+
```js
|
|
40
|
+
const { FormFiller } = require("@botler/1403-form-filler-module");
|
|
41
|
+
|
|
42
|
+
const filler = new FormFiller({
|
|
43
|
+
databaseUrl: process.env.WNC_TRACKING_DATABASE_URI,
|
|
44
|
+
});
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### Bring your own Pool
|
|
48
|
+
|
|
49
|
+
If your app already has a `pg.Pool` connected to the same database,
|
|
50
|
+
pass it in to avoid creating a second connection pool:
|
|
51
|
+
|
|
52
|
+
```js
|
|
53
|
+
import { FormFiller } from "@botler/1403-form-filler-module";
|
|
54
|
+
import pg from "pg";
|
|
55
|
+
|
|
56
|
+
const pool = new pg.Pool({
|
|
57
|
+
connectionString: process.env.WNC_TRACKING_DATABASE_URI,
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
const filler = new FormFiller({ pool });
|
|
61
|
+
const result = await filler.fillForUser("user-abc-123");
|
|
62
|
+
|
|
63
|
+
// When pool is injected, destroy() does NOT close it — you manage its lifecycle
|
|
64
|
+
await filler.destroy();
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## `FormFillerConfig` reference
|
|
68
|
+
|
|
69
|
+
All fields are optional — sensible defaults are applied.
|
|
70
|
+
|
|
71
|
+
| Field | Type | Default |
|
|
72
|
+
| ------------------------ | ----------------- | ------------------------------------------------- |
|
|
73
|
+
| `pool` | `pg.Pool` | — |
|
|
74
|
+
| `databaseUrl` | `string` | `TEAM_DATABASE_URL` → `WNC_TRACKING_DATABASE_URI` |
|
|
75
|
+
| `templatePath` | `string` | `"s3://coal-forms/template.pdf"` |
|
|
76
|
+
| `outputDirectory` | `string` | `"temp/filled-forms"` |
|
|
77
|
+
| `signatureConfig` | `SignatureConfig` | Great Vibes cursive, 60px, black |
|
|
78
|
+
| `proponentName` | `string` | `"Corby Lund"` |
|
|
79
|
+
| `proponentSignatureText` | `string` | `"Corby Lund"` |
|
|
80
|
+
| `petitionText` | `string` | `"No New Coal Mining in the Eastern Slopes…"` |
|
|
81
|
+
| `s3Bucket` | `string` | `"coal-forms"` |
|
|
82
|
+
| `s3KeyPrefix` | `string` | `"batches/1403"` |
|
|
83
|
+
| `batchSize` | `number` | `10` |
|
|
84
|
+
| `dryRun` | `boolean` | `false` |
|
|
85
|
+
| `skipExisting` | `boolean` | `true` |
|
|
86
|
+
| `keepTemp` | `boolean` | `false` |
|
|
87
|
+
|
|
88
|
+
## Public API
|
|
89
|
+
|
|
90
|
+
```ts
|
|
91
|
+
class FormFiller {
|
|
92
|
+
constructor(config?: FormFillerConfig);
|
|
93
|
+
|
|
94
|
+
/** Fill + flatten the form for a single user */
|
|
95
|
+
fillForUser(userId: string): Promise<ProcessingResult>;
|
|
96
|
+
|
|
97
|
+
/** Fill + flatten for multiple users */
|
|
98
|
+
fillForUsers(userIds: string[]): Promise<ProcessingResult[]>;
|
|
99
|
+
|
|
100
|
+
/** Process all open EA batches (fill → merge → S3) */
|
|
101
|
+
fillAll(): Promise<ProcessingResult[]>;
|
|
102
|
+
|
|
103
|
+
/** Release DB pool (no-op if pool was injected) */
|
|
104
|
+
destroy(): Promise<void>;
|
|
105
|
+
}
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
## CLI usage
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
# Via npx (after install)
|
|
112
|
+
npx fill-1403 --all
|
|
113
|
+
|
|
114
|
+
# Or during development
|
|
115
|
+
npx tsx src/cli.ts --id=<userId>
|
|
116
|
+
npx tsx src/cli.ts --ids=id1,id2,id3
|
|
117
|
+
npx tsx src/cli.ts --all --dry-run
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
| Flag | Description |
|
|
121
|
+
| ------------------- | ------------------------------------------------------- |
|
|
122
|
+
| `--id <userId>` | Process a single user by ID |
|
|
123
|
+
| `--ids <id1,id2,…>` | Process multiple users (comma-separated) |
|
|
124
|
+
| `--all` | Process all users from open EA submission batches |
|
|
125
|
+
| `--dry-run` | Preview what would be processed without generating PDFs |
|
|
126
|
+
| `--skip-existing` | Skip users whose PDF already exists (default: `true`) |
|
|
127
|
+
| `--batch-size <N>` | Records per processing batch (default: `10`) |
|
|
128
|
+
| `--keep-temp` | Keep per-user PDF files after batch merge + S3 upload |
|
|
129
|
+
| `--help` | Show help |
|
|
130
|
+
|
|
131
|
+
## Environment variables
|
|
132
|
+
|
|
133
|
+
| Variable | Required | Description |
|
|
134
|
+
| --------------------------- | -------- | ----------------------------------------------------- |
|
|
135
|
+
| `TEAM_DATABASE_URL` | | Neon PostgreSQL connection string (primary) |
|
|
136
|
+
| `WNC_TRACKING_DATABASE_URI` | | Fallback Neon connection string (same DB) |
|
|
137
|
+
| `AWS_S3_ACCESS_KEY_ID` | ✅ | AWS access key for S3 uploads |
|
|
138
|
+
| `AWS_S3_SECRET_ACCESS_KEY` | ✅ | AWS secret key for S3 uploads |
|
|
139
|
+
| `AWS_S3_REGION` | | AWS region (default: `ca-central-1`) |
|
|
140
|
+
| `LOG_LEVEL` | | `debug`, `info`, `warn`, or `error` (default: `info`) |
|
|
141
|
+
|
|
142
|
+
> When used as a library, pass `databaseUrl` or `pool` in `FormFillerConfig` instead.
|
|
143
|
+
|
|
144
|
+
## Project structure
|
|
145
|
+
|
|
146
|
+
```
|
|
147
|
+
form-filler-module/
|
|
148
|
+
├── src/
|
|
149
|
+
│ ├── index.ts # Library barrel (public API exports)
|
|
150
|
+
│ ├── form-filler.ts # FormFiller class (library core)
|
|
151
|
+
│ ├── cli.ts # CLI entry point (dotenv, arg parsing)
|
|
152
|
+
│ ├── config.ts # CLI argument parsing & validation
|
|
153
|
+
│ ├── canvasser-data-mapper.ts # Maps DB profile → PDF filler data
|
|
154
|
+
│ ├── types/
|
|
155
|
+
│ │ ├── config.ts # FormFillerConfig, ScriptConfig, etc.
|
|
156
|
+
│ │ ├── db-tables.ts # Database table interfaces & enums
|
|
157
|
+
│ │ ├── canvasser-profile.ts # CanvasserProfile interface
|
|
158
|
+
│ │ └── index.ts
|
|
159
|
+
│ ├── shared/
|
|
160
|
+
│ │ └── logger.ts # Console logger with level filtering
|
|
161
|
+
│ ├── pdf-filler/ # Vendored PDF form filler library
|
|
162
|
+
│ ├── pdf-converter/ # MuPDF WASM page rasteriser
|
|
163
|
+
│ ├── pdf-merger/ # pdf-lib page concatenation
|
|
164
|
+
│ ├── s3/ # S3 batch uploader
|
|
165
|
+
│ └── db/ # Neon PostgreSQL pool & queries
|
|
166
|
+
│ ├── pool.ts # getPool / setPool / closePool
|
|
167
|
+
│ ├── queries.ts
|
|
168
|
+
│ └── index.ts
|
|
169
|
+
├── templates/
|
|
170
|
+
│ └── template.pdf # Form 1403 template (also on S3)
|
|
171
|
+
├── dist/ # Built output (published to npm)
|
|
172
|
+
├── package.json
|
|
173
|
+
├── tsconfig.json
|
|
174
|
+
├── .npmrc
|
|
175
|
+
└── .env.example
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
## Development
|
|
179
|
+
|
|
180
|
+
```bash
|
|
181
|
+
# Type-check
|
|
182
|
+
npm run typecheck
|
|
183
|
+
|
|
184
|
+
# Build to dist/
|
|
185
|
+
npm run build
|
|
186
|
+
|
|
187
|
+
# Run CLI in dev
|
|
188
|
+
npx tsx src/cli.ts --all
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
## Publishing
|
|
192
|
+
|
|
193
|
+
```bash
|
|
194
|
+
# Ensure NPM_TOKEN is set
|
|
195
|
+
export NPM_TOKEN=npm_...
|
|
196
|
+
|
|
197
|
+
# Build + publish
|
|
198
|
+
npm publish --access restricted
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
## License
|
|
202
|
+
|
|
203
|
+
Private — internal use only.
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* canvasser-data-mapper.ts - Maps canvasser profile data to PDF filler format
|
|
3
|
+
*
|
|
4
|
+
* Transforms a CanvasserProfile (composed from user_profiles,
|
|
5
|
+
* form_1403_signatures, and addresses) into the CanvasserData
|
|
6
|
+
* interface expected by the pdf-filler library.
|
|
7
|
+
*/
|
|
8
|
+
import type { CanvasserData } from "./pdf-filler";
|
|
9
|
+
import type { CanvasserProfile } from "./types";
|
|
10
|
+
/** Optional overrides for domain-specific values. */
|
|
11
|
+
export interface DataMapperOverrides {
|
|
12
|
+
/** Petition question text. @default "No New Coal Mining in the Eastern Slopes of the Rocky Mountains" */
|
|
13
|
+
petitionText?: string;
|
|
14
|
+
/** Proponent / Thomas name. @default "Corby Lund" */
|
|
15
|
+
proponentName?: string;
|
|
16
|
+
/** Text rendered as proponent signature. @default "Corby Lund" */
|
|
17
|
+
proponentSignatureText?: string;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Static utility class for mapping canvasser profile data to PDF form fields.
|
|
21
|
+
* Contains formatting helpers for phone numbers, postal codes, and addresses.
|
|
22
|
+
*/
|
|
23
|
+
export declare class CanvasserDataMapper {
|
|
24
|
+
/**
|
|
25
|
+
* Map a CanvasserProfile to the CanvasserData shape required by the PDF filler.
|
|
26
|
+
*
|
|
27
|
+
* Selects the RESIDENTIAL address for physical fields and MAILING address
|
|
28
|
+
* for mailing fields. Generates signature data from first/last name and
|
|
29
|
+
* the signedAt date.
|
|
30
|
+
*
|
|
31
|
+
* @param profile - Composed canvasser profile from database queries
|
|
32
|
+
* @param overrides - Optional domain value overrides
|
|
33
|
+
* @returns CanvasserData ready for PDF form filling
|
|
34
|
+
* @throws Error if required fields (firstName, lastName) are missing
|
|
35
|
+
*/
|
|
36
|
+
static mapToFillerData(profile: CanvasserProfile, overrides?: DataMapperOverrides): CanvasserData;
|
|
37
|
+
/**
|
|
38
|
+
* Get a human-readable display name for a canvasser profile.
|
|
39
|
+
*
|
|
40
|
+
* @param profile - The canvasser profile
|
|
41
|
+
* @returns Formatted display name, or a fallback with the userId
|
|
42
|
+
*/
|
|
43
|
+
static getDisplayName(profile: CanvasserProfile): string;
|
|
44
|
+
/**
|
|
45
|
+
* Pick the most recent address of a given type from the addresses array.
|
|
46
|
+
* The DB query already returns DISTINCT ON type ordered by updatedAt DESC,
|
|
47
|
+
* but this serves as a safety fallback for deduplication.
|
|
48
|
+
*
|
|
49
|
+
* @param addresses - All addresses for the user profile
|
|
50
|
+
* @param type - The AddressType to filter for
|
|
51
|
+
* @returns The most recent address of the given type, or undefined
|
|
52
|
+
*/
|
|
53
|
+
private static pickAddressByType;
|
|
54
|
+
/**
|
|
55
|
+
* Build a single-line address string from an Address record.
|
|
56
|
+
* Includes streetAddress2 (unit/suite) when present.
|
|
57
|
+
*
|
|
58
|
+
* @param address - The address record
|
|
59
|
+
* @returns Formatted address line (e.g. "#201, 123 Main St")
|
|
60
|
+
*/
|
|
61
|
+
private static buildAddressLine;
|
|
62
|
+
/**
|
|
63
|
+
* Validate that required fields are present and non-empty.
|
|
64
|
+
*
|
|
65
|
+
* @param profile - The canvasser profile to validate
|
|
66
|
+
* @throws Error listing all missing required fields
|
|
67
|
+
*/
|
|
68
|
+
private static validateRequiredFields;
|
|
69
|
+
/**
|
|
70
|
+
* Capitalize the first letter of each word in a name, handling
|
|
71
|
+
* spaces, hyphens, and apostrophes as word boundaries.
|
|
72
|
+
*
|
|
73
|
+
* @param name - Raw name string
|
|
74
|
+
* @returns Capitalized name, or the original value if falsy
|
|
75
|
+
*/
|
|
76
|
+
private static capitalizeName;
|
|
77
|
+
/**
|
|
78
|
+
* Remove any non-alphabetical characters from a string.
|
|
79
|
+
* Keeps only Unicode letters and spaces. Returns empty string for null/undefined.
|
|
80
|
+
*
|
|
81
|
+
* @param value - The string to sanitize
|
|
82
|
+
* @returns Sanitized string containing only letters and spaces
|
|
83
|
+
*/
|
|
84
|
+
private static sanitizeAlpha;
|
|
85
|
+
/**
|
|
86
|
+
* Format a phone number to the standard (XXX) XXX-XXXX format.
|
|
87
|
+
* Handles 10-digit and 11-digit (1 + area code) North American numbers.
|
|
88
|
+
*
|
|
89
|
+
* @param phoneNumber - Raw phone number string
|
|
90
|
+
* @returns Formatted phone number, or original if format is unrecognised
|
|
91
|
+
*/
|
|
92
|
+
private static formatPhoneNumber;
|
|
93
|
+
/**
|
|
94
|
+
* Format a postal code to the Canadian standard (X1X 1X1).
|
|
95
|
+
* Inserts a space in the middle of a 6-character code.
|
|
96
|
+
*
|
|
97
|
+
* @param postalCode - Raw postal code string
|
|
98
|
+
* @returns Formatted postal code, or original if format is unexpected
|
|
99
|
+
*/
|
|
100
|
+
private static formatPostalCode;
|
|
101
|
+
/**
|
|
102
|
+
* Safely parse a date value into a Date object.
|
|
103
|
+
* Handles Date instances, ISO strings, and objects with toISOString().
|
|
104
|
+
*
|
|
105
|
+
* @param value - The date value to parse
|
|
106
|
+
* @returns Parsed Date or undefined if parsing fails
|
|
107
|
+
*/
|
|
108
|
+
private static parseDate;
|
|
109
|
+
}
|
|
110
|
+
//# sourceMappingURL=canvasser-data-mapper.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"canvasser-data-mapper.d.ts","sourceRoot":"","sources":["../src/canvasser-data-mapper.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAIhD,qDAAqD;AACrD,MAAM,WAAW,mBAAmB;IACjC,yGAAyG;IACzG,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,qDAAqD;IACrD,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,kEAAkE;IAClE,sBAAsB,CAAC,EAAE,MAAM,CAAC;CAClC;AAED;;;GAGG;AACH,qBAAa,mBAAmB;IAC7B;;;;;;;;;;;OAWG;WACW,eAAe,CAC1B,OAAO,EAAE,gBAAgB,EACzB,SAAS,CAAC,EAAE,mBAAmB,GAC/B,aAAa;IAkFhB;;;;;OAKG;WACW,cAAc,CAAC,OAAO,EAAE,gBAAgB,GAAG,MAAM;IAY/D;;;;;;;;OAQG;IACH,OAAO,CAAC,MAAM,CAAC,iBAAiB;IAqBhC;;;;;;OAMG;IACH,OAAO,CAAC,MAAM,CAAC,gBAAgB;IAY/B;;;;;OAKG;IACH,OAAO,CAAC,MAAM,CAAC,sBAAsB;IAqBrC;;;;;;OAMG;IACH,OAAO,CAAC,MAAM,CAAC,cAAc;IAS7B;;;;;;OAMG;IACH,OAAO,CAAC,MAAM,CAAC,aAAa;IAY5B;;;;;;OAMG;IACH,OAAO,CAAC,MAAM,CAAC,iBAAiB;IAsBhC;;;;;;OAMG;IACH,OAAO,CAAC,MAAM,CAAC,gBAAgB;IAY/B;;;;;;OAMG;IACH,OAAO,CAAC,MAAM,CAAC,SAAS;CA+B1B"}
|
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* canvasser-data-mapper.ts - Maps canvasser profile data to PDF filler format
|
|
4
|
+
*
|
|
5
|
+
* Transforms a CanvasserProfile (composed from user_profiles,
|
|
6
|
+
* form_1403_signatures, and addresses) into the CanvasserData
|
|
7
|
+
* interface expected by the pdf-filler library.
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.CanvasserDataMapper = void 0;
|
|
11
|
+
const types_1 = require("./types");
|
|
12
|
+
/**
|
|
13
|
+
* Static utility class for mapping canvasser profile data to PDF form fields.
|
|
14
|
+
* Contains formatting helpers for phone numbers, postal codes, and addresses.
|
|
15
|
+
*/
|
|
16
|
+
class CanvasserDataMapper {
|
|
17
|
+
/**
|
|
18
|
+
* Map a CanvasserProfile to the CanvasserData shape required by the PDF filler.
|
|
19
|
+
*
|
|
20
|
+
* Selects the RESIDENTIAL address for physical fields and MAILING address
|
|
21
|
+
* for mailing fields. Generates signature data from first/last name and
|
|
22
|
+
* the signedAt date.
|
|
23
|
+
*
|
|
24
|
+
* @param profile - Composed canvasser profile from database queries
|
|
25
|
+
* @param overrides - Optional domain value overrides
|
|
26
|
+
* @returns CanvasserData ready for PDF form filling
|
|
27
|
+
* @throws Error if required fields (firstName, lastName) are missing
|
|
28
|
+
*/
|
|
29
|
+
static mapToFillerData(profile, overrides) {
|
|
30
|
+
// Validate that required name fields are present
|
|
31
|
+
this.validateRequiredFields(profile);
|
|
32
|
+
// Pick the best address of each type from the addresses array
|
|
33
|
+
const residentialAddress = this.pickAddressByType(profile.addresses, types_1.AddressType.RESIDENTIAL);
|
|
34
|
+
const mailingAddress = this.pickAddressByType(profile.addresses, types_1.AddressType.MAILING);
|
|
35
|
+
// Build address line strings from the structured address records
|
|
36
|
+
const physicalAddressLine = residentialAddress
|
|
37
|
+
? this.buildAddressLine(residentialAddress)
|
|
38
|
+
: "";
|
|
39
|
+
const mailingAddressLine = mailingAddress
|
|
40
|
+
? this.buildAddressLine(mailingAddress)
|
|
41
|
+
: "";
|
|
42
|
+
// Parse signedAt into a Date if available
|
|
43
|
+
const signedAtDate = this.parseDate(profile.signedAt);
|
|
44
|
+
// Capitalize names before any further processing
|
|
45
|
+
const firstName = this.capitalizeName(profile.firstName) ?? profile.firstName;
|
|
46
|
+
const lastName = this.capitalizeName(profile.lastName) ?? profile.lastName;
|
|
47
|
+
const middleName = this.capitalizeName(profile.middleName) ?? profile.middleName;
|
|
48
|
+
const fillerData = {
|
|
49
|
+
// Required name fields
|
|
50
|
+
surname: this.sanitizeAlpha(lastName),
|
|
51
|
+
givenName: this.sanitizeAlpha(firstName),
|
|
52
|
+
middleName: middleName ? this.sanitizeAlpha(middleName) : undefined,
|
|
53
|
+
// Phone number — prefer mobileNumber, fall back to additionalPhones[0]
|
|
54
|
+
telephoneNumber: this.formatPhoneNumber(profile.mobileNumber || (profile.additionalPhones?.[0] ?? "")),
|
|
55
|
+
// Email address (from users table)
|
|
56
|
+
emailAddress: profile.email || undefined,
|
|
57
|
+
// Physical (residential) address
|
|
58
|
+
physicalAddress: physicalAddressLine,
|
|
59
|
+
physicalMunicipality: residentialAddress?.city?.trim() || "",
|
|
60
|
+
physicalPostalCode: this.formatPostalCode(residentialAddress?.postalCode || ""),
|
|
61
|
+
// Mailing address (optional, only set when present)
|
|
62
|
+
mailingAddress: mailingAddressLine || undefined,
|
|
63
|
+
mailingMunicipality: mailingAddress?.city?.trim() || undefined,
|
|
64
|
+
mailingPostalCode: mailingAddress
|
|
65
|
+
? this.formatPostalCode(mailingAddress.postalCode)
|
|
66
|
+
: undefined,
|
|
67
|
+
// Petition question text (configurable per form requirement)
|
|
68
|
+
proponentName: overrides?.petitionText ??
|
|
69
|
+
"No New Coal Mining in the Eastern Slopes of the Rocky Mountains",
|
|
70
|
+
// Canvasser signature — rendered from capitalized first + last name
|
|
71
|
+
canvasserNameForSignature: `${firstName?.trim() || ""} ${lastName?.trim() || ""}`.trim(),
|
|
72
|
+
canvasserActualSignatureDate: signedAtDate,
|
|
73
|
+
// Proponent (Thomas Lukaszuk) signature data
|
|
74
|
+
ThomasName: overrides?.proponentName ?? "Corby Lund",
|
|
75
|
+
proponentNameForSignature: overrides?.proponentSignatureText ?? "Corby Lund",
|
|
76
|
+
proponentSignatureDate: "",
|
|
77
|
+
};
|
|
78
|
+
return fillerData;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Get a human-readable display name for a canvasser profile.
|
|
82
|
+
*
|
|
83
|
+
* @param profile - The canvasser profile
|
|
84
|
+
* @returns Formatted display name, or a fallback with the userId
|
|
85
|
+
*/
|
|
86
|
+
static getDisplayName(profile) {
|
|
87
|
+
const parts = [profile.firstName, profile.lastName]
|
|
88
|
+
.filter((part) => part && part.trim().length > 0)
|
|
89
|
+
.map((part) => part.trim());
|
|
90
|
+
return parts.length > 0 ? parts.join(" ") : `User ${profile.userId}`;
|
|
91
|
+
}
|
|
92
|
+
// =========================================================================
|
|
93
|
+
// Private helpers
|
|
94
|
+
// =========================================================================
|
|
95
|
+
/**
|
|
96
|
+
* Pick the most recent address of a given type from the addresses array.
|
|
97
|
+
* The DB query already returns DISTINCT ON type ordered by updatedAt DESC,
|
|
98
|
+
* but this serves as a safety fallback for deduplication.
|
|
99
|
+
*
|
|
100
|
+
* @param addresses - All addresses for the user profile
|
|
101
|
+
* @param type - The AddressType to filter for
|
|
102
|
+
* @returns The most recent address of the given type, or undefined
|
|
103
|
+
*/
|
|
104
|
+
static pickAddressByType(addresses, type) {
|
|
105
|
+
// Filter to matching type
|
|
106
|
+
const matching = addresses.filter((a) => a.type === type);
|
|
107
|
+
if (matching.length === 0) {
|
|
108
|
+
return undefined;
|
|
109
|
+
}
|
|
110
|
+
// Sort by updatedAt descending and take the first (most recent)
|
|
111
|
+
matching.sort((a, b) => {
|
|
112
|
+
const dateA = a.updatedAt ? new Date(a.updatedAt).getTime() : 0;
|
|
113
|
+
const dateB = b.updatedAt ? new Date(b.updatedAt).getTime() : 0;
|
|
114
|
+
return dateB - dateA;
|
|
115
|
+
});
|
|
116
|
+
return matching[0];
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Build a single-line address string from an Address record.
|
|
120
|
+
* Includes streetAddress2 (unit/suite) when present.
|
|
121
|
+
*
|
|
122
|
+
* @param address - The address record
|
|
123
|
+
* @returns Formatted address line (e.g. "#201, 123 Main St")
|
|
124
|
+
*/
|
|
125
|
+
static buildAddressLine(address) {
|
|
126
|
+
const line1 = address.streetAddress?.trim() || "";
|
|
127
|
+
const line2 = address.streetAddress2?.trim() || "";
|
|
128
|
+
// Prepend unit/suite number if present
|
|
129
|
+
if (line2) {
|
|
130
|
+
return `${line2}, ${line1}`.trim();
|
|
131
|
+
}
|
|
132
|
+
return line1;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Validate that required fields are present and non-empty.
|
|
136
|
+
*
|
|
137
|
+
* @param profile - The canvasser profile to validate
|
|
138
|
+
* @throws Error listing all missing required fields
|
|
139
|
+
*/
|
|
140
|
+
static validateRequiredFields(profile) {
|
|
141
|
+
const errors = [];
|
|
142
|
+
// Check that first and last name exist and are non-empty
|
|
143
|
+
if (!profile.firstName || profile.firstName.trim().length === 0) {
|
|
144
|
+
errors.push("firstName is required and cannot be empty");
|
|
145
|
+
}
|
|
146
|
+
if (!profile.lastName || profile.lastName.trim().length === 0) {
|
|
147
|
+
errors.push("lastName is required and cannot be empty");
|
|
148
|
+
}
|
|
149
|
+
if (errors.length > 0) {
|
|
150
|
+
throw new Error(`Data validation failed for user ${profile.userId}: ${errors.join(", ")}`);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Capitalize the first letter of each word in a name, handling
|
|
155
|
+
* spaces, hyphens, and apostrophes as word boundaries.
|
|
156
|
+
*
|
|
157
|
+
* @param name - Raw name string
|
|
158
|
+
* @returns Capitalized name, or the original value if falsy
|
|
159
|
+
*/
|
|
160
|
+
static capitalizeName(name) {
|
|
161
|
+
if (!name)
|
|
162
|
+
return name;
|
|
163
|
+
return name
|
|
164
|
+
.toLowerCase()
|
|
165
|
+
.replace(/(?:^|[\s\-'])\S/g, (char) => char.toUpperCase());
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Remove any non-alphabetical characters from a string.
|
|
169
|
+
* Keeps only Unicode letters and spaces. Returns empty string for null/undefined.
|
|
170
|
+
*
|
|
171
|
+
* @param value - The string to sanitize
|
|
172
|
+
* @returns Sanitized string containing only letters and spaces
|
|
173
|
+
*/
|
|
174
|
+
static sanitizeAlpha(value) {
|
|
175
|
+
if (!value)
|
|
176
|
+
return "";
|
|
177
|
+
try {
|
|
178
|
+
// Prefer Unicode letter class to support diacritics
|
|
179
|
+
return value.replace(/[^\p{L} ]/gu, "").trim();
|
|
180
|
+
}
|
|
181
|
+
catch {
|
|
182
|
+
// Fallback to ASCII letters if Unicode property escapes are unsupported
|
|
183
|
+
return value.replace(/[^A-Za-z ]/g, "").trim();
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Format a phone number to the standard (XXX) XXX-XXXX format.
|
|
188
|
+
* Handles 10-digit and 11-digit (1 + area code) North American numbers.
|
|
189
|
+
*
|
|
190
|
+
* @param phoneNumber - Raw phone number string
|
|
191
|
+
* @returns Formatted phone number, or original if format is unrecognised
|
|
192
|
+
*/
|
|
193
|
+
static formatPhoneNumber(phoneNumber) {
|
|
194
|
+
// Strip all non-digit characters
|
|
195
|
+
const digits = phoneNumber.replace(/\D/g, "");
|
|
196
|
+
// Standard 10-digit North American format
|
|
197
|
+
if (digits.length === 10) {
|
|
198
|
+
return `(${digits.slice(0, 3)}) ${digits.slice(3, 6)}-${digits.slice(6)}`;
|
|
199
|
+
}
|
|
200
|
+
// 11-digit with leading country code 1
|
|
201
|
+
if (digits.length === 11 && digits.startsWith("1")) {
|
|
202
|
+
return `(${digits.slice(1, 4)}) ${digits.slice(4, 7)}-${digits.slice(7)}`;
|
|
203
|
+
}
|
|
204
|
+
// Return original if we cannot format it
|
|
205
|
+
return phoneNumber;
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Format a postal code to the Canadian standard (X1X 1X1).
|
|
209
|
+
* Inserts a space in the middle of a 6-character code.
|
|
210
|
+
*
|
|
211
|
+
* @param postalCode - Raw postal code string
|
|
212
|
+
* @returns Formatted postal code, or original if format is unexpected
|
|
213
|
+
*/
|
|
214
|
+
static formatPostalCode(postalCode) {
|
|
215
|
+
// Remove spaces and convert to uppercase
|
|
216
|
+
const cleaned = postalCode.replace(/\s/g, "").toUpperCase();
|
|
217
|
+
// Add space in the middle if it is a valid 6-character code
|
|
218
|
+
if (cleaned.length === 6) {
|
|
219
|
+
return `${cleaned.slice(0, 3)} ${cleaned.slice(3)}`;
|
|
220
|
+
}
|
|
221
|
+
return postalCode;
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* Safely parse a date value into a Date object.
|
|
225
|
+
* Handles Date instances, ISO strings, and objects with toISOString().
|
|
226
|
+
*
|
|
227
|
+
* @param value - The date value to parse
|
|
228
|
+
* @returns Parsed Date or undefined if parsing fails
|
|
229
|
+
*/
|
|
230
|
+
static parseDate(value) {
|
|
231
|
+
if (!value)
|
|
232
|
+
return undefined;
|
|
233
|
+
// Already a Date instance
|
|
234
|
+
if (value instanceof Date) {
|
|
235
|
+
return isNaN(value.getTime()) ? undefined : value;
|
|
236
|
+
}
|
|
237
|
+
// ISO string
|
|
238
|
+
if (typeof value === "string") {
|
|
239
|
+
const d = new Date(value);
|
|
240
|
+
return isNaN(d.getTime()) ? undefined : d;
|
|
241
|
+
}
|
|
242
|
+
// Object with toISOString (e.g. some ORM date wrappers)
|
|
243
|
+
try {
|
|
244
|
+
if (typeof value === "object" &&
|
|
245
|
+
value !== null &&
|
|
246
|
+
"toISOString" in value &&
|
|
247
|
+
typeof value.toISOString === "function") {
|
|
248
|
+
const d = new Date(value.toISOString());
|
|
249
|
+
return isNaN(d.getTime()) ? undefined : d;
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
catch {
|
|
253
|
+
// Ignore parse failures
|
|
254
|
+
}
|
|
255
|
+
return undefined;
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
exports.CanvasserDataMapper = CanvasserDataMapper;
|
|
259
|
+
//# sourceMappingURL=canvasser-data-mapper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"canvasser-data-mapper.js","sourceRoot":"","sources":["../src/canvasser-data-mapper.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAKH,mCAAsC;AAYtC;;;GAGG;AACH,MAAa,mBAAmB;IAC7B;;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AAC,CAAC,CAAC,CAAC;YAC7C,CAAC;QACJ,CAAC;QAAC,MAAM,CAAC;YACN,wBAAwB;QAC3B,CAAC;QAED,OAAO,SAAS,CAAC;IACpB,CAAC;CACH;AAzTD,kDAyTC"}
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* cli.ts — CLI entry point for the 1403 form-filler-module
|
|
4
|
+
*
|
|
5
|
+
* Parses CLI arguments, loads environment variables via dotenv,
|
|
6
|
+
* creates a FormFiller instance, and dispatches to the correct mode.
|
|
7
|
+
*
|
|
8
|
+
* Usage:
|
|
9
|
+
* npx tsx src/cli.ts --id <userId>
|
|
10
|
+
* npx tsx src/cli.ts --ids <id1,id2,...>
|
|
11
|
+
* npx tsx src/cli.ts --all
|
|
12
|
+
*/
|
|
13
|
+
export {};
|
|
14
|
+
//# sourceMappingURL=cli.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAEA;;;;;;;;;;GAUG"}
|