@acm-uiuc/js-shared 3.2.1 → 3.3.1
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/dist/orgs.d.ts +17 -8
- package/dist/orgs.js +25 -14
- package/package.json +1 -1
package/dist/orgs.d.ts
CHANGED
|
@@ -4,20 +4,29 @@ export declare enum OrgType {
|
|
|
4
4
|
COMMITTEE = "committee",
|
|
5
5
|
MISC = "misc"
|
|
6
6
|
}
|
|
7
|
+
export declare const AllOrganizationIdList: readonly ["A01", "S01", "S02", "S03", "S04", "S05", "S06", "S07", "S08", "S09", "S10", "S11", "S12", "S13", "S14", "S15", "S16", "S17", "S18", "C01", "C02", "C03", "C04", "C05", "C06", "C07", "C08"];
|
|
8
|
+
export type OrganizationId = (typeof AllOrganizationIdList)[number];
|
|
7
9
|
export type Organization = {
|
|
8
10
|
name: string;
|
|
9
11
|
type: OrgType;
|
|
10
12
|
shortcode: string;
|
|
11
13
|
color: string;
|
|
12
14
|
};
|
|
13
|
-
export declare const Organizations:
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
export type OrganizationName =
|
|
17
|
-
export
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
15
|
+
export declare const Organizations: {
|
|
16
|
+
readonly [K in OrganizationId]: Organization;
|
|
17
|
+
};
|
|
18
|
+
export type OrganizationName = (typeof Organizations)[OrganizationId]["name"];
|
|
19
|
+
export type OrganizationsByNameType = {
|
|
20
|
+
[K in OrganizationId as (typeof Organizations)[K]["name"]]: K;
|
|
21
|
+
};
|
|
22
|
+
export declare const OrganizationsByName: OrganizationsByNameType;
|
|
23
|
+
export declare const AllOrganizationNameList: OrganizationName[];
|
|
24
|
+
export declare function getOrgIdByName<N extends OrganizationName>(name: N): OrganizationsByNameType[N];
|
|
25
|
+
export declare function getOrgByName<N extends OrganizationName>(name: N): (typeof Organizations)[OrganizationsByNameType[N]] & {
|
|
26
|
+
id: OrganizationsByNameType[N];
|
|
27
|
+
};
|
|
28
|
+
export declare function isValidOrgName(name: string): name is OrganizationName;
|
|
29
|
+
export declare function isValidOrgId(id: string): id is OrganizationId;
|
|
21
30
|
export declare function getOrgsByType(type: OrgType): Array<Organization & {
|
|
22
31
|
id: OrganizationId;
|
|
23
32
|
}>;
|
package/dist/orgs.js
CHANGED
|
@@ -5,6 +5,14 @@ export var OrgType;
|
|
|
5
5
|
OrgType["COMMITTEE"] = "committee";
|
|
6
6
|
OrgType["MISC"] = "misc";
|
|
7
7
|
})(OrgType || (OrgType = {}));
|
|
8
|
+
// IDs are the source of truth
|
|
9
|
+
export const AllOrganizationIdList = [
|
|
10
|
+
"A01",
|
|
11
|
+
"S01", "S02", "S03", "S04", "S05", "S06", "S07", "S08", "S09",
|
|
12
|
+
"S10", "S11", "S12", "S13", "S14", "S15", "S16", "S17", "S18",
|
|
13
|
+
"C01", "C02", "C03", "C04", "C05", "C06", "C07", "C08",
|
|
14
|
+
];
|
|
15
|
+
// This MUST have an entry for every ID (compile error if missing)
|
|
8
16
|
export const Organizations = {
|
|
9
17
|
"A01": { name: "ACM", type: OrgType.MAIN, shortcode: "acm", color: "#4577f8" },
|
|
10
18
|
"S01": { name: "SIGPwny", type: OrgType.SIG, shortcode: "sigpwny", color: "#33cc55" },
|
|
@@ -34,23 +42,26 @@ export const Organizations = {
|
|
|
34
42
|
"C07": { name: "Reflections | Projections", type: OrgType.COMMITTEE, shortcode: "reflproj", color: "#4577f8" },
|
|
35
43
|
"C08": { name: "HackIllinois", type: OrgType.COMMITTEE, shortcode: "hackillinois", color: "#4577f8" },
|
|
36
44
|
};
|
|
37
|
-
export const
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
return acc;
|
|
45
|
-
}, {});
|
|
45
|
+
export const OrganizationsByName = Object.fromEntries(Object.entries(Organizations).map(([id, org]) => [org.name, id]));
|
|
46
|
+
export const AllOrganizationNameList = AllOrganizationIdList.map(id => Organizations[id].name);
|
|
47
|
+
// Helper to get ID from name (typed return)
|
|
48
|
+
export function getOrgIdByName(name) {
|
|
49
|
+
return OrganizationsByName[name];
|
|
50
|
+
}
|
|
51
|
+
// Helper to get org by name (typed return)
|
|
46
52
|
export function getOrgByName(name) {
|
|
47
53
|
const id = OrganizationsByName[name];
|
|
48
|
-
if (!id)
|
|
49
|
-
return undefined;
|
|
50
54
|
return { ...Organizations[id], id };
|
|
51
55
|
}
|
|
56
|
+
// For cases where you have an unknown string and need to check
|
|
57
|
+
export function isValidOrgName(name) {
|
|
58
|
+
return name in OrganizationsByName;
|
|
59
|
+
}
|
|
60
|
+
export function isValidOrgId(id) {
|
|
61
|
+
return id in Organizations;
|
|
62
|
+
}
|
|
52
63
|
export function getOrgsByType(type) {
|
|
53
|
-
return
|
|
54
|
-
.filter(
|
|
55
|
-
.map(
|
|
64
|
+
return AllOrganizationIdList
|
|
65
|
+
.filter(id => Organizations[id].type === type)
|
|
66
|
+
.map(id => ({ ...Organizations[id], id }));
|
|
56
67
|
}
|