triage-types 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.
@@ -0,0 +1,6 @@
1
+ export * from "./types/APIError.js";
2
+ export * from "./types/State.js";
3
+ export * from "./types/AR/ARStateFacility.js";
4
+ export * from "./types/AR/ARStatePermit.js";
5
+ export * from "./types/AR/ARStatePermitSource.js";
6
+ export * from "./types/AR/ARStatePermitSourcePollutant.js";
@@ -0,0 +1,6 @@
1
+ export * from "./types/APIError.js";
2
+ export * from "./types/State.js";
3
+ export * from "./types/AR/ARStateFacility.js";
4
+ export * from "./types/AR/ARStatePermit.js";
5
+ export * from "./types/AR/ARStatePermitSource.js";
6
+ export * from "./types/AR/ARStatePermitSourcePollutant.js";
@@ -0,0 +1,4 @@
1
+ export declare class APIError extends Error {
2
+ status: number;
3
+ constructor(status: number, message?: string);
4
+ }
@@ -0,0 +1,19 @@
1
+ const default_messages_by_status = {
2
+ 400: "Bad Request",
3
+ 401: "Unauthorized",
4
+ 403: "Forbidden",
5
+ 404: "Not Found",
6
+ 405: "Method Not Allowed",
7
+ 500: "Internal Server Error",
8
+ 504: "Gateway Timeout",
9
+ 600: "Failed to Parse Output"
10
+ };
11
+ export class APIError extends Error {
12
+ status;
13
+ constructor(status, message) {
14
+ const default_message = default_messages_by_status[status];
15
+ super(message !== undefined ? message : default_message !== undefined ? default_message : "Error");
16
+ this.name = "APIError";
17
+ this.status = status;
18
+ }
19
+ }
@@ -0,0 +1,11 @@
1
+ import { StateID } from "../State.js";
2
+ export declare class ARStateFacility {
3
+ readonly state_facility_id: string;
4
+ readonly state_id: StateID;
5
+ readonly facility_id: string;
6
+ readonly name: string;
7
+ readonly active: boolean;
8
+ readonly type_id: string;
9
+ constructor(ar_state_facility: any);
10
+ static is(ar_state_facility: any): ar_state_facility is ARStateFacility;
11
+ }
@@ -0,0 +1,29 @@
1
+ import { is_state_id } from "../State.js";
2
+ export class ARStateFacility {
3
+ state_facility_id;
4
+ state_id;
5
+ facility_id;
6
+ name;
7
+ active;
8
+ type_id;
9
+ constructor(ar_state_facility) {
10
+ if (!ARStateFacility.is(ar_state_facility)) {
11
+ throw Error("Invalid input.");
12
+ }
13
+ this.state_facility_id = ar_state_facility.state_facility_id;
14
+ this.state_id = ar_state_facility.state_id;
15
+ this.facility_id = ar_state_facility.facility_id;
16
+ this.name = ar_state_facility.name;
17
+ this.active = ar_state_facility.active;
18
+ this.type_id = ar_state_facility.type_id;
19
+ }
20
+ static is(ar_state_facility) {
21
+ return (ar_state_facility !== undefined &&
22
+ is_state_id(ar_state_facility.state_id) &&
23
+ typeof ar_state_facility.state_facility_id === "string" &&
24
+ typeof ar_state_facility.facility_id === "string" &&
25
+ typeof ar_state_facility.name === "string" &&
26
+ typeof ar_state_facility.active === "boolean" &&
27
+ typeof ar_state_facility.type_id === "string");
28
+ }
29
+ }
@@ -0,0 +1,18 @@
1
+ import { StateID } from "../State.js";
2
+ export declare class ARStatePermit {
3
+ readonly state_permit_id: string;
4
+ readonly state_id: StateID;
5
+ readonly permit_id: string;
6
+ readonly state_facility_id: string;
7
+ readonly issue_date?: string;
8
+ readonly expiration_date?: string;
9
+ readonly void_date?: string;
10
+ readonly status?: string;
11
+ readonly media?: string;
12
+ readonly type?: string;
13
+ readonly s3_filename?: string;
14
+ readonly s3_text_filename?: string;
15
+ readonly source_ids?: string[];
16
+ constructor(ar_state_permit: any);
17
+ static is(ar_state_permit: any): ar_state_permit is ARStatePermit;
18
+ }
@@ -0,0 +1,67 @@
1
+ // import { StateRegisterDocument } from "src/types/StatePermit"
2
+ import { is_state_id } from "../State.js";
3
+ // export class NYStateRegisterDocument extends StateRegisterDocument {
4
+ // readonly state_id : "NY"
5
+ // constructor(ny_state_register_document : any) {
6
+ // if (!StateRegisterDocument.is(ny_state_register_document)) {
7
+ // throw Error("Invalid input.")
8
+ // }
9
+ // super(ny_state_register_document)
10
+ // this.state_id = "NY"
11
+ // }
12
+ // static is(ny_state_register_document : any) : ny_state_register_document is NYStateRegisterDocument {
13
+ // return (
14
+ // StateRegisterDocument.is(ny_state_register_document) &&
15
+ // ny_state_register_document.state_id === "NY"
16
+ // )
17
+ // }
18
+ // }
19
+ export class ARStatePermit {
20
+ state_permit_id;
21
+ state_id;
22
+ permit_id;
23
+ state_facility_id;
24
+ issue_date;
25
+ expiration_date;
26
+ void_date;
27
+ status;
28
+ media;
29
+ type;
30
+ s3_filename;
31
+ s3_text_filename;
32
+ source_ids;
33
+ constructor(ar_state_permit) {
34
+ if (!ARStatePermit.is(ar_state_permit)) {
35
+ throw Error("Invalid input.");
36
+ }
37
+ this.state_permit_id = ar_state_permit.state_permit_id;
38
+ this.state_id = ar_state_permit.state_id;
39
+ this.permit_id = ar_state_permit.permit_id;
40
+ this.state_facility_id = ar_state_permit.state_facility_id;
41
+ this.issue_date = ar_state_permit.issue_date;
42
+ this.expiration_date = ar_state_permit.expiration_date;
43
+ this.void_date = ar_state_permit.void_date;
44
+ this.status = ar_state_permit.status;
45
+ this.media = ar_state_permit.media;
46
+ this.type = ar_state_permit.type;
47
+ this.s3_filename = ar_state_permit.s3_filename;
48
+ this.s3_text_filename = ar_state_permit.s3_text_filename;
49
+ this.source_ids = ar_state_permit.source_ids;
50
+ }
51
+ static is(ar_state_permit) {
52
+ return (ar_state_permit !== undefined &&
53
+ typeof ar_state_permit.state_permit_id === "string" &&
54
+ is_state_id(ar_state_permit.state_id) &&
55
+ typeof ar_state_permit.permit_id === "string" &&
56
+ typeof ar_state_permit.state_facility_id === "string" &&
57
+ (ar_state_permit.issue_date === undefined || typeof ar_state_permit.issue_date === "string") &&
58
+ (ar_state_permit.expiration_date === undefined || typeof ar_state_permit.expiration_date === "string") &&
59
+ (ar_state_permit.void_date === undefined || typeof ar_state_permit.void_date === "string") &&
60
+ (ar_state_permit.status === undefined || typeof ar_state_permit.status === "string") &&
61
+ (ar_state_permit.media === undefined || typeof ar_state_permit.media === "string") &&
62
+ (ar_state_permit.type === undefined || typeof ar_state_permit.type === "string") &&
63
+ (ar_state_permit.s3_filename === undefined || typeof ar_state_permit.s3_filename === "string") &&
64
+ (ar_state_permit.s3_text_filename === undefined || typeof ar_state_permit.s3_text_filename === "string") &&
65
+ (ar_state_permit.source_ids === undefined || Array.isArray(ar_state_permit.source_ids) && ar_state_permit.source_ids.map((source_id) => typeof source_id === "string")));
66
+ }
67
+ }
@@ -0,0 +1,13 @@
1
+ import { StateID } from "../State.js";
2
+ export declare class ARStatePermitSource {
3
+ readonly state_permit_source_id: string;
4
+ readonly state_id: StateID;
5
+ readonly state_permit_id: string;
6
+ readonly source_id: string;
7
+ readonly page_nums: number[];
8
+ readonly description?: string;
9
+ readonly is_rice?: string;
10
+ readonly pollutant_ids?: string[];
11
+ constructor(ar_state_permit_source: ARStatePermitSource);
12
+ static is(ar_state_permit_source: any): ar_state_permit_source is ARStatePermitSource;
13
+ }
@@ -0,0 +1,42 @@
1
+ import { is_state_id } from "../State.js";
2
+ export class ARStatePermitSource {
3
+ state_permit_source_id;
4
+ state_id;
5
+ state_permit_id;
6
+ source_id;
7
+ page_nums;
8
+ description;
9
+ is_rice;
10
+ pollutant_ids;
11
+ // readonly pollutants? : string[]
12
+ // readonly pollutant_limits? : any[]
13
+ constructor(ar_state_permit_source) {
14
+ if (!ARStatePermitSource.is(ar_state_permit_source)) {
15
+ throw Error("Invalid input.");
16
+ }
17
+ this.state_permit_source_id = ar_state_permit_source.state_permit_source_id;
18
+ this.state_id = ar_state_permit_source.state_id;
19
+ this.state_permit_id = ar_state_permit_source.state_permit_id;
20
+ this.source_id = ar_state_permit_source.source_id;
21
+ this.page_nums = ar_state_permit_source.page_nums;
22
+ this.description = ar_state_permit_source.description;
23
+ this.is_rice = ar_state_permit_source.is_rice;
24
+ this.pollutant_ids = ar_state_permit_source.pollutant_ids;
25
+ // this.pollutants = ar_state_permit_source.pollutants
26
+ // this.pollutant_limits = ar_state_permit_source.pollutant_limits
27
+ }
28
+ static is(ar_state_permit_source) {
29
+ return (ar_state_permit_source !== undefined &&
30
+ typeof ar_state_permit_source.state_permit_source_id === "string" &&
31
+ is_state_id(ar_state_permit_source.state_id) &&
32
+ typeof ar_state_permit_source.state_permit_id === "string" &&
33
+ typeof ar_state_permit_source.source_id === "string" &&
34
+ Array.isArray(ar_state_permit_source.page_nums) && ar_state_permit_source.page_nums.every((page_num) => typeof page_num === "number") &&
35
+ (ar_state_permit_source.description === undefined || typeof ar_state_permit_source.description === "string") &&
36
+ (ar_state_permit_source.is_rice === undefined || typeof ar_state_permit_source.is_rice === "string") &&
37
+ (ar_state_permit_source.pollutant_ids === undefined || Array.isArray(ar_state_permit_source.pollutant_ids) && ar_state_permit_source.pollutant_ids.every((pollutant_id) => typeof pollutant_id === "string")) // &&
38
+ // (ar_state_permit_source.pollutants === undefined || Array.isArray(ar_state_permit_source.pollutants) && ar_state_permit_source.pollutants.every((pollutant : any) => typeof pollutant === "string"))&&
39
+ // (ar_state_permit_source.pollutant_limits === undefined || Array.isArray(ar_state_permit_source.pollutant_limits))
40
+ );
41
+ }
42
+ }
@@ -0,0 +1,14 @@
1
+ import { StateID } from "../State.js";
2
+ export declare class ARStatePermitSourcePollutant {
3
+ readonly state_permit_source_pollutant_id: string;
4
+ readonly state_id: StateID;
5
+ readonly state_permit_id: string;
6
+ readonly state_permit_source_id: string;
7
+ readonly pollutant_id: string;
8
+ readonly TPY_text: string;
9
+ readonly LBPH_text: string;
10
+ readonly TPY?: number;
11
+ readonly LBPH?: number;
12
+ constructor(ar_state_permit_source_pollutant: ARStatePermitSourcePollutant);
13
+ static is(ar_state_permit_source_pollutant: any): ar_state_permit_source_pollutant is ARStatePermitSourcePollutant;
14
+ }
@@ -0,0 +1,38 @@
1
+ import { is_state_id } from "../State.js";
2
+ export class ARStatePermitSourcePollutant {
3
+ state_permit_source_pollutant_id;
4
+ state_id;
5
+ state_permit_id;
6
+ state_permit_source_id;
7
+ pollutant_id;
8
+ TPY_text;
9
+ LBPH_text;
10
+ TPY;
11
+ LBPH;
12
+ constructor(ar_state_permit_source_pollutant) {
13
+ if (!ARStatePermitSourcePollutant.is(ar_state_permit_source_pollutant)) {
14
+ throw Error("Invalid input.");
15
+ }
16
+ this.state_permit_source_pollutant_id = ar_state_permit_source_pollutant.state_permit_source_pollutant_id;
17
+ this.state_id = ar_state_permit_source_pollutant.state_id;
18
+ this.state_permit_id = ar_state_permit_source_pollutant.state_permit_id;
19
+ this.state_permit_source_id = ar_state_permit_source_pollutant.state_permit_source_id;
20
+ this.pollutant_id = ar_state_permit_source_pollutant.pollutant_id;
21
+ this.TPY_text = ar_state_permit_source_pollutant.TPY_text;
22
+ this.LBPH_text = ar_state_permit_source_pollutant.LBPH_text;
23
+ this.TPY = ar_state_permit_source_pollutant.TPY;
24
+ this.LBPH = ar_state_permit_source_pollutant.LBPH;
25
+ }
26
+ static is(ar_state_permit_source_pollutant) {
27
+ return (ar_state_permit_source_pollutant !== undefined &&
28
+ typeof ar_state_permit_source_pollutant.state_permit_source_pollutant_id === "string" &&
29
+ is_state_id(ar_state_permit_source_pollutant.state_id) &&
30
+ typeof ar_state_permit_source_pollutant.state_permit_id === "string" &&
31
+ typeof ar_state_permit_source_pollutant.state_permit_source_id === "string" &&
32
+ typeof ar_state_permit_source_pollutant.pollutant_id === "string" &&
33
+ typeof ar_state_permit_source_pollutant.TPY_text === "string" &&
34
+ typeof ar_state_permit_source_pollutant.LBPH_text === "string" &&
35
+ (ar_state_permit_source_pollutant.TPY === undefined || typeof ar_state_permit_source_pollutant.TPY === "number" && !isNaN(ar_state_permit_source_pollutant.TPY)) &&
36
+ (ar_state_permit_source_pollutant.LBPH === undefined || typeof ar_state_permit_source_pollutant.LBPH === "number" && !isNaN(ar_state_permit_source_pollutant.LBPH)));
37
+ }
38
+ }
@@ -0,0 +1,8 @@
1
+ export declare const state_ids: readonly ["AL", "AK", "AZ", "AR", "CA", "CO", "CT", "DE", "FL", "GA", "HI", "ID", "IL", "IN", "IA", "KS", "KY", "LA", "ME", "MD", "MA", "MI", "MN", "MS", "MO", "MT", "NE", "NV", "NH", "NJ", "NM", "NY", "NC", "ND", "OH", "OK", "OR", "PA", "RI", "SC", "SD", "TN", "TX", "UT", "VT", "VA", "WA", "WV", "WI", "WY"];
2
+ export type StateID = typeof state_ids[number];
3
+ export declare function is_state_id(state_id: any): state_id is StateID;
4
+ export interface State {
5
+ state_id: StateID;
6
+ name: string;
7
+ }
8
+ export declare const states_by_state_id: Record<StateID, State>;
@@ -0,0 +1,206 @@
1
+ export const state_ids = ["AL", "AK", "AZ", "AR", "CA", "CO", "CT", "DE", "FL", "GA", "HI", "ID", "IL", "IN", "IA", "KS", "KY", "LA", "ME", "MD", "MA", "MI", "MN", "MS", "MO", "MT", "NE", "NV", "NH", "NJ", "NM", "NY", "NC", "ND", "OH", "OK", "OR", "PA", "RI", "SC", "SD", "TN", "TX", "UT", "VT", "VA", "WA", "WV", "WI", "WY"];
2
+ export function is_state_id(state_id) {
3
+ return state_ids.includes(state_id);
4
+ }
5
+ export const states_by_state_id = {
6
+ AL: {
7
+ state_id: "AL",
8
+ name: "Alabama"
9
+ },
10
+ AK: {
11
+ state_id: "AK",
12
+ name: "Alaska"
13
+ },
14
+ AZ: {
15
+ state_id: "AZ",
16
+ name: "Arizona"
17
+ },
18
+ AR: {
19
+ state_id: "AR",
20
+ name: "Arkansas"
21
+ },
22
+ CA: {
23
+ state_id: "CA",
24
+ name: "California"
25
+ },
26
+ CO: {
27
+ state_id: "CO",
28
+ name: "Colorado"
29
+ },
30
+ CT: {
31
+ state_id: "CT",
32
+ name: "Connecticut"
33
+ },
34
+ DE: {
35
+ state_id: "DE",
36
+ name: "Delaware"
37
+ },
38
+ FL: {
39
+ state_id: "FL",
40
+ name: "Florida"
41
+ },
42
+ GA: {
43
+ state_id: "GA",
44
+ name: "Georgia"
45
+ },
46
+ HI: {
47
+ state_id: "HI",
48
+ name: "Hawaii"
49
+ },
50
+ ID: {
51
+ state_id: "ID",
52
+ name: "Idaho"
53
+ },
54
+ IL: {
55
+ state_id: "IL",
56
+ name: "Illinois"
57
+ },
58
+ IN: {
59
+ state_id: "IN",
60
+ name: "Indiana"
61
+ },
62
+ IA: {
63
+ state_id: "IA",
64
+ name: "Iowa"
65
+ },
66
+ KS: {
67
+ state_id: "KS",
68
+ name: "Kansas"
69
+ },
70
+ KY: {
71
+ state_id: "KY",
72
+ name: "Kentucky"
73
+ },
74
+ LA: {
75
+ state_id: "LA",
76
+ name: "Louisiana"
77
+ },
78
+ ME: {
79
+ state_id: "ME",
80
+ name: "Maine"
81
+ },
82
+ MD: {
83
+ state_id: "MD",
84
+ name: "Maryland"
85
+ },
86
+ MA: {
87
+ state_id: "MA",
88
+ name: "Massachusetts"
89
+ },
90
+ MI: {
91
+ state_id: "MI",
92
+ name: "Michigan"
93
+ },
94
+ MN: {
95
+ state_id: "MN",
96
+ name: "Minnesota"
97
+ },
98
+ MS: {
99
+ state_id: "MS",
100
+ name: "Mississippi"
101
+ },
102
+ MO: {
103
+ state_id: "MO",
104
+ name: "Missouri"
105
+ },
106
+ MT: {
107
+ state_id: "MT",
108
+ name: "Montana"
109
+ },
110
+ NE: {
111
+ state_id: "NE",
112
+ name: "Nebraska"
113
+ },
114
+ NV: {
115
+ state_id: "NV",
116
+ name: "Nevada"
117
+ },
118
+ NH: {
119
+ state_id: "NH",
120
+ name: "New Hampshire"
121
+ },
122
+ NJ: {
123
+ state_id: "NJ",
124
+ name: "New Jersey"
125
+ },
126
+ NM: {
127
+ state_id: "NM",
128
+ name: "New Mexico"
129
+ },
130
+ NY: {
131
+ state_id: "NY",
132
+ name: "New York"
133
+ },
134
+ NC: {
135
+ state_id: "NC",
136
+ name: "North Carolina"
137
+ },
138
+ ND: {
139
+ state_id: "ND",
140
+ name: "North Dakota"
141
+ },
142
+ OH: {
143
+ state_id: "OH",
144
+ name: "Ohio"
145
+ },
146
+ OK: {
147
+ state_id: "OK",
148
+ name: "Oklahoma"
149
+ },
150
+ OR: {
151
+ state_id: "OR",
152
+ name: "Oregon"
153
+ },
154
+ PA: {
155
+ state_id: "PA",
156
+ name: "Pennsylvania"
157
+ },
158
+ RI: {
159
+ state_id: "RI",
160
+ name: "Rhode Island"
161
+ },
162
+ SC: {
163
+ state_id: "SC",
164
+ name: "South Carolina"
165
+ },
166
+ SD: {
167
+ state_id: "SD",
168
+ name: "South Dakota"
169
+ },
170
+ TN: {
171
+ state_id: "TN",
172
+ name: "Tennessee"
173
+ },
174
+ TX: {
175
+ state_id: "TX",
176
+ name: "Texas"
177
+ },
178
+ UT: {
179
+ state_id: "UT",
180
+ name: "Utah"
181
+ },
182
+ VT: {
183
+ state_id: "VT",
184
+ name: "Vermont"
185
+ },
186
+ VA: {
187
+ state_id: "VA",
188
+ name: "Virginia"
189
+ },
190
+ WA: {
191
+ state_id: "WA",
192
+ name: "Washington"
193
+ },
194
+ WV: {
195
+ state_id: "WV",
196
+ name: "West Virginia"
197
+ },
198
+ WI: {
199
+ state_id: "WI",
200
+ name: "Wisconsin"
201
+ },
202
+ WY: {
203
+ state_id: "WY",
204
+ name: "Wyoming"
205
+ }
206
+ };
@@ -0,0 +1,13 @@
1
+ import js from "@eslint/js";
2
+ import globals from "globals";
3
+ import tseslint from "typescript-eslint";
4
+ import { defineConfig } from "eslint/config";
5
+
6
+ export default defineConfig([
7
+ { files: ["**/*.{js,mjs,cjs,ts,mts,cts}"], plugins: { js }, extends: ["js/recommended"], languageOptions: { globals: globals.browser } },
8
+ {
9
+ rules: {
10
+ "@typescript-eslint/explicit-function-return-type": "error"
11
+ },
12
+ },
13
+ ]);
package/jest.config.js ADDED
@@ -0,0 +1,20 @@
1
+ import { createDefaultPreset } from "ts-jest"
2
+
3
+ const tsJestTransformCfg = createDefaultPreset().transform;
4
+
5
+ /** @type {import("jest").Config} **/
6
+ export default {
7
+ testEnvironment: "node",
8
+ transform: {
9
+ ...tsJestTransformCfg,
10
+ },
11
+ transformIgnorePatterns: ["/node_modules/(?!@smithy|@aws-sdk).+\\.js$"],
12
+ globals : {
13
+ "ts-jest" : {
14
+ useESM : true
15
+ }
16
+ },
17
+ extensionsToTreatAsEsm : [".ts"],
18
+ testTimeout : 30000,
19
+ testPathIgnorePatterns: ['dist/']
20
+ };
package/package.json ADDED
@@ -0,0 +1,31 @@
1
+ {
2
+ "name": "triage-types",
3
+ "version": "1.0.0",
4
+ "main": "dist/src/index.js",
5
+ "types": "dist/src/index.d.ts",
6
+ "directories": {
7
+ "test": "test"
8
+ },
9
+ "scripts": {
10
+ "test": "node --experimental-vm-modules node_modules/jest/bin/jest.js",
11
+ "build": "tsc && tsc-alias"
12
+ },
13
+ "author": "",
14
+ "license": "ISC",
15
+ "description": "",
16
+ "type": "module",
17
+ "dependencies": {},
18
+ "devDependencies": {
19
+ "@eslint/js": "^9.39.2",
20
+ "@types/jest": "^30.0.0",
21
+ "eslint": "^9.39.2",
22
+ "globals": "^17.3.0",
23
+ "jest": "^30.2.0",
24
+ "jiti": "^2.6.1",
25
+ "ts-jest": "^29.4.6",
26
+ "tsc-alias": "^1.8.16",
27
+ "tsx": "^4.21.0",
28
+ "typescript": "^5.9.3",
29
+ "typescript-eslint": "^8.55.0"
30
+ }
31
+ }
package/src/index.ts ADDED
@@ -0,0 +1,6 @@
1
+ export * from "./types/APIError"
2
+ export * from "./types/State"
3
+ export * from "./types/AR/ARStateFacility"
4
+ export * from "./types/AR/ARStatePermit"
5
+ export * from "./types/AR/ARStatePermitSource"
6
+ export * from "./types/AR/ARStatePermitSourcePollutant"
@@ -0,0 +1,21 @@
1
+ const default_messages_by_status : Record<number, string> = {
2
+ 400 : "Bad Request",
3
+ 401 : "Unauthorized",
4
+ 403 : "Forbidden",
5
+ 404 : "Not Found",
6
+ 405 : "Method Not Allowed",
7
+ 500 : "Internal Server Error",
8
+ 504 : "Gateway Timeout",
9
+ 600 : "Failed to Parse Output"
10
+ }
11
+
12
+
13
+ export class APIError extends Error {
14
+ status : number
15
+ constructor(status : number, message?: string) {
16
+ const default_message = default_messages_by_status[status]
17
+ super(message !== undefined ? message : default_message !== undefined ? default_message : "Error")
18
+ this.name = "APIError"
19
+ this.status = status
20
+ }
21
+ }
@@ -0,0 +1,34 @@
1
+ import { is_state_id, StateID } from "../State"
2
+
3
+ export class ARStateFacility {
4
+ readonly state_facility_id : string
5
+ readonly state_id : StateID
6
+ readonly facility_id : string
7
+ readonly name : string
8
+ readonly active : boolean
9
+ readonly type_id : string
10
+
11
+ constructor(ar_state_facility : any) {
12
+ if (!ARStateFacility.is(ar_state_facility)) {
13
+ throw Error("Invalid input.")
14
+ }
15
+ this.state_facility_id = ar_state_facility.state_facility_id
16
+ this.state_id = ar_state_facility.state_id
17
+ this.facility_id = ar_state_facility.facility_id
18
+ this.name = ar_state_facility.name
19
+ this.active = ar_state_facility.active
20
+ this.type_id = ar_state_facility.type_id
21
+ }
22
+
23
+ static is(ar_state_facility : any) : ar_state_facility is ARStateFacility {
24
+ return (
25
+ ar_state_facility !== undefined &&
26
+ is_state_id(ar_state_facility.state_id) &&
27
+ typeof ar_state_facility.state_facility_id === "string" &&
28
+ typeof ar_state_facility.facility_id === "string" &&
29
+ typeof ar_state_facility.name === "string" &&
30
+ typeof ar_state_facility.active === "boolean" &&
31
+ typeof ar_state_facility.type_id === "string"
32
+ )
33
+ }
34
+ }
@@ -0,0 +1,76 @@
1
+ // import { StateRegisterDocument } from "src/types/StatePermit"
2
+
3
+ import { is_state_id, StateID } from "../State"
4
+
5
+ // export class NYStateRegisterDocument extends StateRegisterDocument {
6
+ // readonly state_id : "NY"
7
+
8
+ // constructor(ny_state_register_document : any) {
9
+ // if (!StateRegisterDocument.is(ny_state_register_document)) {
10
+ // throw Error("Invalid input.")
11
+ // }
12
+ // super(ny_state_register_document)
13
+ // this.state_id = "NY"
14
+ // }
15
+
16
+ // static is(ny_state_register_document : any) : ny_state_register_document is NYStateRegisterDocument {
17
+ // return (
18
+ // StateRegisterDocument.is(ny_state_register_document) &&
19
+ // ny_state_register_document.state_id === "NY"
20
+ // )
21
+ // }
22
+ // }
23
+
24
+ export class ARStatePermit {
25
+ readonly state_permit_id : string
26
+ readonly state_id : StateID
27
+ readonly permit_id : string
28
+ readonly state_facility_id : string
29
+ readonly issue_date? : string
30
+ readonly expiration_date? : string
31
+ readonly void_date? : string
32
+ readonly status? : string
33
+ readonly media? : string
34
+ readonly type? : string
35
+ readonly s3_filename? : string
36
+ readonly s3_text_filename? : string
37
+ readonly source_ids? : string[]
38
+
39
+ constructor(ar_state_permit : any) {
40
+ if (!ARStatePermit.is(ar_state_permit)) {
41
+ throw Error("Invalid input.")
42
+ }
43
+ this.state_permit_id = ar_state_permit.state_permit_id
44
+ this.state_id = ar_state_permit.state_id
45
+ this.permit_id = ar_state_permit.permit_id
46
+ this.state_facility_id = ar_state_permit.state_facility_id
47
+ this.issue_date = ar_state_permit.issue_date
48
+ this.expiration_date = ar_state_permit.expiration_date
49
+ this.void_date = ar_state_permit.void_date
50
+ this.status = ar_state_permit.status
51
+ this.media = ar_state_permit.media
52
+ this.type = ar_state_permit.type
53
+ this.s3_filename = ar_state_permit.s3_filename
54
+ this.s3_text_filename = ar_state_permit.s3_text_filename
55
+ this.source_ids = ar_state_permit.source_ids
56
+ }
57
+
58
+ static is(ar_state_permit : any) : ar_state_permit is ARStatePermit {
59
+ return (
60
+ ar_state_permit !== undefined &&
61
+ typeof ar_state_permit.state_permit_id === "string" &&
62
+ is_state_id(ar_state_permit.state_id) &&
63
+ typeof ar_state_permit.permit_id === "string" &&
64
+ typeof ar_state_permit.state_facility_id === "string" &&
65
+ (ar_state_permit.issue_date === undefined || typeof ar_state_permit.issue_date === "string") &&
66
+ (ar_state_permit.expiration_date === undefined || typeof ar_state_permit.expiration_date === "string") &&
67
+ (ar_state_permit.void_date === undefined || typeof ar_state_permit.void_date === "string") &&
68
+ (ar_state_permit.status === undefined || typeof ar_state_permit.status === "string") &&
69
+ (ar_state_permit.media === undefined || typeof ar_state_permit.media === "string") &&
70
+ (ar_state_permit.type === undefined || typeof ar_state_permit.type === "string") &&
71
+ (ar_state_permit.s3_filename === undefined || typeof ar_state_permit.s3_filename === "string") &&
72
+ (ar_state_permit.s3_text_filename === undefined || typeof ar_state_permit.s3_text_filename === "string") &&
73
+ (ar_state_permit.source_ids === undefined || Array.isArray(ar_state_permit.source_ids) && ar_state_permit.source_ids.map((source_id : any) => typeof source_id === "string"))
74
+ )
75
+ }
76
+ }
@@ -0,0 +1,46 @@
1
+ import { is_state_id, StateID } from "../State"
2
+
3
+ export class ARStatePermitSource {
4
+ readonly state_permit_source_id : string
5
+ readonly state_id : StateID
6
+ readonly state_permit_id : string
7
+ readonly source_id : string
8
+ readonly page_nums : number[]
9
+ readonly description? : string
10
+ readonly is_rice? : string
11
+ readonly pollutant_ids? : string[]
12
+ // readonly pollutants? : string[]
13
+ // readonly pollutant_limits? : any[]
14
+
15
+ constructor(ar_state_permit_source : ARStatePermitSource) {
16
+ if (!ARStatePermitSource.is(ar_state_permit_source)) {
17
+ throw Error("Invalid input.")
18
+ }
19
+ this.state_permit_source_id = ar_state_permit_source.state_permit_source_id
20
+ this.state_id = ar_state_permit_source.state_id
21
+ this.state_permit_id = ar_state_permit_source.state_permit_id
22
+ this.source_id = ar_state_permit_source.source_id
23
+ this.page_nums = ar_state_permit_source.page_nums
24
+ this.description = ar_state_permit_source.description
25
+ this.is_rice = ar_state_permit_source.is_rice
26
+ this.pollutant_ids = ar_state_permit_source.pollutant_ids
27
+ // this.pollutants = ar_state_permit_source.pollutants
28
+ // this.pollutant_limits = ar_state_permit_source.pollutant_limits
29
+ }
30
+
31
+ static is(ar_state_permit_source : any) : ar_state_permit_source is ARStatePermitSource {
32
+ return (
33
+ ar_state_permit_source !== undefined &&
34
+ typeof ar_state_permit_source.state_permit_source_id === "string" &&
35
+ is_state_id(ar_state_permit_source.state_id) &&
36
+ typeof ar_state_permit_source.state_permit_id === "string" &&
37
+ typeof ar_state_permit_source.source_id === "string" &&
38
+ Array.isArray(ar_state_permit_source.page_nums) && ar_state_permit_source.page_nums.every((page_num : any) => typeof page_num === "number") &&
39
+ (ar_state_permit_source.description === undefined || typeof ar_state_permit_source.description === "string") &&
40
+ (ar_state_permit_source.is_rice === undefined || typeof ar_state_permit_source.is_rice === "string") &&
41
+ (ar_state_permit_source.pollutant_ids === undefined || Array.isArray(ar_state_permit_source.pollutant_ids) && ar_state_permit_source.pollutant_ids.every((pollutant_id : any) => typeof pollutant_id === "string"))// &&
42
+ // (ar_state_permit_source.pollutants === undefined || Array.isArray(ar_state_permit_source.pollutants) && ar_state_permit_source.pollutants.every((pollutant : any) => typeof pollutant === "string"))&&
43
+ // (ar_state_permit_source.pollutant_limits === undefined || Array.isArray(ar_state_permit_source.pollutant_limits))
44
+ )
45
+ }
46
+ }
@@ -0,0 +1,43 @@
1
+ import { is_state_id, StateID } from "../State"
2
+
3
+ export class ARStatePermitSourcePollutant {
4
+ readonly state_permit_source_pollutant_id : string
5
+ readonly state_id : StateID
6
+ readonly state_permit_id : string
7
+ readonly state_permit_source_id : string
8
+ readonly pollutant_id : string
9
+ readonly TPY_text : string
10
+ readonly LBPH_text : string
11
+ readonly TPY? : number
12
+ readonly LBPH? : number
13
+
14
+ constructor(ar_state_permit_source_pollutant : ARStatePermitSourcePollutant) {
15
+ if (!ARStatePermitSourcePollutant.is(ar_state_permit_source_pollutant)) {
16
+ throw Error("Invalid input.")
17
+ }
18
+ this.state_permit_source_pollutant_id = ar_state_permit_source_pollutant.state_permit_source_pollutant_id
19
+ this.state_id = ar_state_permit_source_pollutant.state_id
20
+ this.state_permit_id = ar_state_permit_source_pollutant.state_permit_id
21
+ this.state_permit_source_id = ar_state_permit_source_pollutant.state_permit_source_id
22
+ this.pollutant_id = ar_state_permit_source_pollutant.pollutant_id
23
+ this.TPY_text = ar_state_permit_source_pollutant.TPY_text
24
+ this.LBPH_text = ar_state_permit_source_pollutant.LBPH_text
25
+ this.TPY = ar_state_permit_source_pollutant.TPY
26
+ this.LBPH = ar_state_permit_source_pollutant.LBPH
27
+ }
28
+
29
+ static is(ar_state_permit_source_pollutant : any) : ar_state_permit_source_pollutant is ARStatePermitSourcePollutant {
30
+ return (
31
+ ar_state_permit_source_pollutant !== undefined &&
32
+ typeof ar_state_permit_source_pollutant.state_permit_source_pollutant_id === "string" &&
33
+ is_state_id(ar_state_permit_source_pollutant.state_id) &&
34
+ typeof ar_state_permit_source_pollutant.state_permit_id === "string" &&
35
+ typeof ar_state_permit_source_pollutant.state_permit_source_id === "string" &&
36
+ typeof ar_state_permit_source_pollutant.pollutant_id === "string" &&
37
+ typeof ar_state_permit_source_pollutant.TPY_text === "string" &&
38
+ typeof ar_state_permit_source_pollutant.LBPH_text === "string" &&
39
+ (ar_state_permit_source_pollutant.TPY === undefined || typeof ar_state_permit_source_pollutant.TPY === "number" && !isNaN(ar_state_permit_source_pollutant.TPY)) &&
40
+ (ar_state_permit_source_pollutant.LBPH === undefined || typeof ar_state_permit_source_pollutant.LBPH === "number" && !isNaN(ar_state_permit_source_pollutant.LBPH))
41
+ )
42
+ }
43
+ }
@@ -0,0 +1,215 @@
1
+ export const state_ids = ["AL", "AK", "AZ", "AR", "CA", "CO", "CT", "DE", "FL", "GA", "HI", "ID", "IL", "IN", "IA", "KS", "KY", "LA", "ME", "MD", "MA", "MI", "MN", "MS", "MO", "MT", "NE", "NV", "NH", "NJ", "NM", "NY", "NC", "ND", "OH", "OK", "OR", "PA", "RI", "SC", "SD", "TN", "TX", "UT", "VT", "VA", "WA", "WV", "WI", "WY"] as const
2
+
3
+ export type StateID = typeof state_ids[number]
4
+
5
+ export function is_state_id(state_id : any) : state_id is StateID {
6
+ return state_ids.includes(state_id)
7
+ }
8
+
9
+ export interface State {
10
+ state_id : StateID,
11
+ name : string
12
+ }
13
+
14
+ export const states_by_state_id : Record<StateID, State> = {
15
+ AL : {
16
+ state_id : "AL",
17
+ name : "Alabama"
18
+ },
19
+ AK : {
20
+ state_id : "AK",
21
+ name : "Alaska"
22
+ },
23
+ AZ : {
24
+ state_id : "AZ",
25
+ name : "Arizona"
26
+ },
27
+ AR : {
28
+ state_id : "AR",
29
+ name : "Arkansas"
30
+ },
31
+ CA : {
32
+ state_id : "CA",
33
+ name : "California"
34
+ },
35
+ CO : {
36
+ state_id : "CO",
37
+ name : "Colorado"
38
+ },
39
+ CT : {
40
+ state_id : "CT",
41
+ name : "Connecticut"
42
+ },
43
+ DE : {
44
+ state_id : "DE",
45
+ name : "Delaware"
46
+ },
47
+ FL : {
48
+ state_id : "FL",
49
+ name : "Florida"
50
+ },
51
+ GA : {
52
+ state_id : "GA",
53
+ name : "Georgia"
54
+ },
55
+ HI : {
56
+ state_id : "HI",
57
+ name : "Hawaii"
58
+ },
59
+ ID : {
60
+ state_id : "ID",
61
+ name : "Idaho"
62
+ },
63
+ IL : {
64
+ state_id : "IL",
65
+ name : "Illinois"
66
+ },
67
+ IN : {
68
+ state_id : "IN",
69
+ name : "Indiana"
70
+ },
71
+ IA : {
72
+ state_id : "IA",
73
+ name : "Iowa"
74
+ },
75
+ KS : {
76
+ state_id : "KS",
77
+ name : "Kansas"
78
+ },
79
+ KY : {
80
+ state_id : "KY",
81
+ name : "Kentucky"
82
+ },
83
+ LA : {
84
+ state_id : "LA",
85
+ name : "Louisiana"
86
+ },
87
+ ME : {
88
+ state_id : "ME",
89
+ name : "Maine"
90
+ },
91
+ MD : {
92
+ state_id : "MD",
93
+ name : "Maryland"
94
+ },
95
+ MA : {
96
+ state_id : "MA",
97
+ name : "Massachusetts"
98
+ },
99
+ MI : {
100
+ state_id : "MI",
101
+ name : "Michigan"
102
+ },
103
+ MN : {
104
+ state_id : "MN",
105
+ name : "Minnesota"
106
+ },
107
+ MS : {
108
+ state_id : "MS",
109
+ name : "Mississippi"
110
+ },
111
+ MO : {
112
+ state_id : "MO",
113
+ name : "Missouri"
114
+ },
115
+ MT : {
116
+ state_id : "MT",
117
+ name : "Montana"
118
+ },
119
+ NE : {
120
+ state_id : "NE",
121
+ name : "Nebraska"
122
+ },
123
+ NV : {
124
+ state_id : "NV",
125
+ name : "Nevada"
126
+ },
127
+ NH : {
128
+ state_id : "NH",
129
+ name : "New Hampshire"
130
+ },
131
+ NJ : {
132
+ state_id : "NJ",
133
+ name : "New Jersey"
134
+ },
135
+ NM : {
136
+ state_id : "NM",
137
+ name : "New Mexico"
138
+ },
139
+ NY : {
140
+ state_id : "NY",
141
+ name : "New York"
142
+ },
143
+ NC : {
144
+ state_id : "NC",
145
+ name : "North Carolina"
146
+ },
147
+ ND : {
148
+ state_id : "ND",
149
+ name : "North Dakota"
150
+ },
151
+ OH : {
152
+ state_id : "OH",
153
+ name : "Ohio"
154
+ },
155
+ OK : {
156
+ state_id : "OK",
157
+ name : "Oklahoma"
158
+ },
159
+ OR : {
160
+ state_id : "OR",
161
+ name : "Oregon"
162
+ },
163
+ PA : {
164
+ state_id : "PA",
165
+ name : "Pennsylvania"
166
+ },
167
+ RI : {
168
+ state_id : "RI",
169
+ name : "Rhode Island"
170
+ },
171
+ SC : {
172
+ state_id : "SC",
173
+ name : "South Carolina"
174
+ },
175
+ SD : {
176
+ state_id : "SD",
177
+ name : "South Dakota"
178
+ },
179
+ TN : {
180
+ state_id : "TN",
181
+ name : "Tennessee"
182
+ },
183
+ TX : {
184
+ state_id : "TX",
185
+ name : "Texas"
186
+ },
187
+ UT : {
188
+ state_id : "UT",
189
+ name : "Utah"
190
+ },
191
+ VT : {
192
+ state_id : "VT",
193
+ name : "Vermont"
194
+ },
195
+ VA : {
196
+ state_id : "VA",
197
+ name : "Virginia"
198
+ },
199
+ WA : {
200
+ state_id : "WA",
201
+ name : "Washington"
202
+ },
203
+ WV : {
204
+ state_id : "WV",
205
+ name : "West Virginia"
206
+ },
207
+ WI : {
208
+ state_id : "WI",
209
+ name : "Wisconsin"
210
+ },
211
+ WY : {
212
+ state_id : "WY",
213
+ name : "Wyoming"
214
+ }
215
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,34 @@
1
+ {
2
+ "compilerOptions": {
3
+ "outDir": "./dist",
4
+
5
+ // Treat files as modules even if it doesn't use import/export
6
+ "moduleDetection": "force",
7
+
8
+ // Ignore module structure
9
+ "module" : "esnext",
10
+ "target" : "es2022",
11
+ "noImplicitAny" : true,
12
+ "noImplicitReturns" : true,
13
+ "moduleResolution": "bundler",
14
+ "declaration": true,
15
+ // Allow JS files to be imported from TS and vice versa
16
+ "allowJs": true,
17
+ "strict" : true,
18
+ // Use correct ESM import behavior
19
+ "esModuleInterop": true,
20
+ "resolveJsonModule": true,
21
+ // Disallow features that require cross-file awareness
22
+ "isolatedModules": true,
23
+ "lib": ["es2022"],
24
+ "rootDir": "./",
25
+ "skipLibCheck": true,
26
+ "maxNodeModuleJsDepth": 0,
27
+ "types": ["node"]
28
+ },
29
+ "tsc-alias": {
30
+ "resolveFullPaths": true,
31
+ "verbose": false
32
+ },
33
+ "include" : ["src/**/*", "test/**/*"]
34
+ }