triangle-types 1.0.107 → 1.0.108

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.
@@ -1,4 +1,5 @@
1
1
  export * from "./types/APIError.js";
2
+ export * from "./types/County.js";
2
3
  export * from "./types/State.js";
3
4
  export * from "./types/User.js";
4
5
  export * from "./types/application/ApplicationStage.js";
package/dist/src/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  export * from "./types/APIError.js";
2
+ export * from "./types/County.js";
2
3
  export * from "./types/State.js";
3
4
  export * from "./types/User.js";
4
5
  export * from "./types/application/ApplicationStage.js";
@@ -0,0 +1,8 @@
1
+ import { StateID } from "./State.js";
2
+ export declare class County {
3
+ readonly county_id: string;
4
+ readonly state_id: StateID;
5
+ readonly name: string;
6
+ constructor(county: any);
7
+ static is(county: any): county is County;
8
+ }
@@ -0,0 +1,25 @@
1
+ // export const county_type_ids = ["H1", "H4", "H5", "H6", "C7"] as const
2
+ import { is_state_id } from "./State.js";
3
+ // export type CountyTypeID = typeof county_type_ids[number]
4
+ // export function is_county_type_id(county_type_id : any) : county_type_id is CountyTypeID {
5
+ // return county_type_ids.includes(county_type_id)
6
+ // }
7
+ export class County {
8
+ county_id;
9
+ state_id;
10
+ name;
11
+ constructor(county) {
12
+ if (!County.is(county)) {
13
+ throw Error("Invalid input.");
14
+ }
15
+ this.county_id = county.county_id;
16
+ this.state_id = county.state_id;
17
+ this.name = county.name;
18
+ }
19
+ static is(county) {
20
+ return (county !== undefined &&
21
+ typeof county.county_id === "string" &&
22
+ is_state_id(county.state_id) &&
23
+ typeof county.name === "string");
24
+ }
25
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "triangle-types",
3
- "version": "1.0.107",
3
+ "version": "1.0.108",
4
4
  "main": "dist/src/index.js",
5
5
  "types": "dist/src/index.d.ts",
6
6
  "scripts": {
package/src/index.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export * from "./types/APIError"
2
+ export * from "./types/County"
2
3
  export * from "./types/State"
3
4
  export * from "./types/User"
4
5
 
@@ -0,0 +1,33 @@
1
+ // export const county_type_ids = ["H1", "H4", "H5", "H6", "C7"] as const
2
+
3
+ import { is_state_id, StateID } from "./State"
4
+
5
+ // export type CountyTypeID = typeof county_type_ids[number]
6
+
7
+ // export function is_county_type_id(county_type_id : any) : county_type_id is CountyTypeID {
8
+ // return county_type_ids.includes(county_type_id)
9
+ // }
10
+
11
+ export class County {
12
+ readonly county_id : string
13
+ readonly state_id : StateID
14
+ readonly name : string
15
+
16
+ constructor(county : any) {
17
+ if (!County.is(county)) {
18
+ throw Error("Invalid input.")
19
+ }
20
+ this.county_id = county.county_id
21
+ this.state_id = county.state_id
22
+ this.name = county.name
23
+ }
24
+
25
+ static is(county : any) : county is County {
26
+ return (
27
+ county !== undefined &&
28
+ typeof county.county_id === "string" &&
29
+ is_state_id(county.state_id) &&
30
+ typeof county.name === "string"
31
+ )
32
+ }
33
+ }