founder-schema 0.17.0 → 0.19.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 +186 -17
- package/dist/access/access.d.ts +1 -1
- package/dist/access/access.d.ts.map +1 -1
- package/dist/access/access.js +4 -1
- package/dist/access/access.js.map +1 -1
- package/dist/access/permissions.d.ts +27 -29
- package/dist/access/permissions.d.ts.map +1 -1
- package/dist/access/permissions.js +39 -3
- package/dist/access/permissions.js.map +1 -1
- package/dist/core/common.d.ts +54 -23
- package/dist/core/common.d.ts.map +1 -1
- package/dist/core/common.js +49 -24
- package/dist/core/common.js.map +1 -1
- package/dist/core/errors.d.ts +7 -5
- package/dist/core/errors.d.ts.map +1 -1
- package/dist/core/errors.js +17 -11
- package/dist/core/errors.js.map +1 -1
- package/dist/core/limits.d.ts +73 -17
- package/dist/core/limits.d.ts.map +1 -1
- package/dist/core/limits.js +77 -22
- package/dist/core/limits.js.map +1 -1
- package/dist/core/money.d.ts +33 -0
- package/dist/core/money.d.ts.map +1 -0
- package/dist/core/money.js +36 -0
- package/dist/core/money.js.map +1 -0
- package/dist/core/responses.d.ts +14 -4
- package/dist/core/responses.d.ts.map +1 -1
- package/dist/core/responses.js.map +1 -1
- package/dist/core/validation.d.ts +19 -2
- package/dist/core/validation.d.ts.map +1 -1
- package/dist/core/validation.js +19 -2
- package/dist/core/validation.js.map +1 -1
- package/dist/domains/billing/billing.d.ts +61 -8
- package/dist/domains/billing/billing.d.ts.map +1 -1
- package/dist/domains/billing/billing.js +58 -22
- package/dist/domains/billing/billing.js.map +1 -1
- package/dist/domains/billing/gst.d.ts.map +1 -1
- package/dist/domains/billing/gst.js +4 -3
- package/dist/domains/billing/gst.js.map +1 -1
- package/dist/domains/chat/chat.d.ts +0 -21
- package/dist/domains/chat/chat.d.ts.map +1 -1
- package/dist/domains/chat/chat.js +0 -20
- package/dist/domains/chat/chat.js.map +1 -1
- package/dist/domains/communities/communities.d.ts +30 -12
- package/dist/domains/communities/communities.d.ts.map +1 -1
- package/dist/domains/communities/communities.js +43 -15
- package/dist/domains/communities/communities.js.map +1 -1
- package/dist/domains/contributions/contributions.d.ts +1 -1
- package/dist/domains/contributions/contributions.js +1 -1
- package/dist/domains/contributions/contributions.js.map +1 -1
- package/dist/domains/dashboard/dashboard.d.ts +3 -1
- package/dist/domains/dashboard/dashboard.d.ts.map +1 -1
- package/dist/domains/dashboard/dashboard.js +23 -7
- package/dist/domains/dashboard/dashboard.js.map +1 -1
- package/dist/domains/discover/discover.d.ts +8 -8
- package/dist/domains/feed/feed.d.ts +55 -153
- package/dist/domains/feed/feed.d.ts.map +1 -1
- package/dist/domains/feed/feed.js +53 -58
- package/dist/domains/feed/feed.js.map +1 -1
- package/dist/domains/location/areas.d.ts +331 -0
- package/dist/domains/location/areas.d.ts.map +1 -0
- package/dist/domains/location/areas.js +238 -0
- package/dist/domains/location/areas.js.map +1 -0
- package/dist/domains/location/india.d.ts +41 -123
- package/dist/domains/location/india.d.ts.map +1 -1
- package/dist/domains/location/india.js +121 -59
- package/dist/domains/location/india.js.map +1 -1
- package/dist/domains/members/members.d.ts +2 -2
- package/dist/domains/membership/membership.d.ts +26 -0
- package/dist/domains/membership/membership.d.ts.map +1 -1
- package/dist/domains/membership/membership.js +55 -1
- package/dist/domains/membership/membership.js.map +1 -1
- package/dist/domains/moderation/moderation.d.ts +2 -2
- package/dist/domains/moderation/moderation.js +3 -3
- package/dist/domains/moderation/moderation.js.map +1 -1
- package/dist/domains/notifications/notifications.d.ts +1 -10
- package/dist/domains/notifications/notifications.d.ts.map +1 -1
- package/dist/domains/notifications/notifications.js +2 -3
- package/dist/domains/notifications/notifications.js.map +1 -1
- package/dist/domains/onboarding/onboarding-answers.d.ts +42 -14
- package/dist/domains/onboarding/onboarding-answers.d.ts.map +1 -1
- package/dist/domains/onboarding/onboarding-answers.js +49 -33
- package/dist/domains/onboarding/onboarding-answers.js.map +1 -1
- package/dist/domains/onboarding/onboarding.d.ts +332 -138
- package/dist/domains/onboarding/onboarding.d.ts.map +1 -1
- package/dist/domains/onboarding/onboarding.js +47 -59
- package/dist/domains/onboarding/onboarding.js.map +1 -1
- package/dist/domains/products/products.d.ts +43 -8
- package/dist/domains/products/products.d.ts.map +1 -1
- package/dist/domains/products/products.js +57 -11
- package/dist/domains/products/products.js.map +1 -1
- package/dist/domains/profile/founder-profile.d.ts +123 -143
- package/dist/domains/profile/founder-profile.d.ts.map +1 -1
- package/dist/domains/profile/founder-profile.js +77 -35
- package/dist/domains/profile/founder-profile.js.map +1 -1
- package/dist/domains/profile/my-profile.d.ts +3 -3
- package/dist/domains/reviews/reviews.d.ts +1 -1
- package/dist/domains/reviews/reviews.d.ts.map +1 -1
- package/dist/domains/reviews/reviews.js +2 -2
- package/dist/domains/reviews/reviews.js.map +1 -1
- package/dist/domains/support/support.d.ts +22 -3
- package/dist/domains/support/support.d.ts.map +1 -1
- package/dist/domains/support/support.js +19 -5
- package/dist/domains/support/support.js.map +1 -1
- package/dist/domains/team/team.d.ts.map +1 -1
- package/dist/domains/team/team.js +3 -6
- package/dist/domains/team/team.js.map +1 -1
- package/dist/domains/uploads/uploads.d.ts +7 -22
- package/dist/domains/uploads/uploads.d.ts.map +1 -1
- package/dist/domains/uploads/uploads.js +7 -21
- package/dist/domains/uploads/uploads.js.map +1 -1
- package/dist/env.d.ts +26 -13
- package/dist/env.d.ts.map +1 -1
- package/dist/env.js +58 -23
- package/dist/env.js.map +1 -1
- package/dist/index.d.ts +19 -17
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +21 -17
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -3,19 +3,18 @@
|
|
|
3
3
|
* and cities (0.17.0, moved here from the web client, where the location step's
|
|
4
4
|
* lists lived in the screen).
|
|
5
5
|
*
|
|
6
|
-
* Founder Circle is in India for now (the user, 2026-10-18
|
|
7
|
-
*
|
|
8
|
-
*
|
|
6
|
+
* Founder Circle is in India for now (the user, 2026-10-18). Since 0.19.0 a
|
|
7
|
+
* member's location is picked from `master_db`'s area tree (`./areas.ts`), so
|
|
8
|
+
* this file no longer holds a write rule; it is the data that names a place
|
|
9
|
+
* the way members say it, read by every side:
|
|
9
10
|
*
|
|
10
11
|
* states all 28 states and 8 union territories, by their current names: a
|
|
11
12
|
* CLOSED list, so a state is one of these or refused (`stateUnknown`)
|
|
12
|
-
* cities per state, the larger cities first, the rest A to Z
|
|
13
|
-
*
|
|
14
|
-
* text, so the list spares members the typing and the spelling
|
|
15
|
-
* variants, and the picker also takes a town it does not hold
|
|
13
|
+
* cities per state, the larger cities first, the rest A to Z: the
|
|
14
|
+
* spellings Discover's city filter and a stored city are matched in
|
|
16
15
|
* aliases older or other names a member may search by ("Bangalore" finds
|
|
17
16
|
* Bengaluru), and the district names the location lookup answers
|
|
18
|
-
* with ("Bengaluru Urban"), so
|
|
17
|
+
* with ("Bengaluru Urban"), so a district's public city and a member's
|
|
19
18
|
* search land on the list's own spelling
|
|
20
19
|
*
|
|
21
20
|
* Written for this product from public knowledge of India's cities; no
|
|
@@ -23,7 +22,6 @@
|
|
|
23
22
|
*
|
|
24
23
|
* @module founder-schema/domains/location/india
|
|
25
24
|
*/
|
|
26
|
-
import { z } from 'zod';
|
|
27
25
|
import type { GST_STATES } from '../billing/gst.js';
|
|
28
26
|
/**
|
|
29
27
|
* A state or union territory, by the ONE list of their names: GST's
|
|
@@ -68,6 +66,40 @@ export declare const STATE_ALIASES: Readonly<Record<string, readonly string[]>>;
|
|
|
68
66
|
* Bengaluru). Anything else comes back as it was given: never guessed.
|
|
69
67
|
*/
|
|
70
68
|
export declare function listedCityName(state: IndiaState | undefined, name: string): string;
|
|
69
|
+
/**
|
|
70
|
+
* A city as the list writes it from its name ALONE (0.18.0), for where no
|
|
71
|
+
* state comes with it (Discover's `?city=` from a shared link): the list's
|
|
72
|
+
* spelling when the name, or another name of a city, matches exactly ONE
|
|
73
|
+
* spelling in the list ("Bangalore" is Bengaluru; "BILASPUR", a city of two
|
|
74
|
+
* states, is "Bilaspur" either way), and the name unchanged when it matches
|
|
75
|
+
* none or two different spellings (never guessed between them). `states` is
|
|
76
|
+
* the list, India's unless a test hands it another.
|
|
77
|
+
*/
|
|
78
|
+
export declare function canonicalCityName(name: string, states?: readonly Pick<IndiaState, 'cities'>[]): string;
|
|
79
|
+
/**
|
|
80
|
+
* The town an urban body is, from the area tree's name for its council
|
|
81
|
+
* (0.19.0): "Gangtok (M Corp.)", "Kohima Municipal Council", "City Corporation
|
|
82
|
+
* Panaji", "Municipal Committee Akhnoor", "Rajgarh (Alwar)" (a bracket that
|
|
83
|
+
* tells two towns apart) are Gangtok, Kohima, Panaji, Akhnoor, Rajgarh. What
|
|
84
|
+
* is left is the town's own name; one the tree wrote in capitals ("MAUGANJ")
|
|
85
|
+
* reads like the rest (Mauganj).
|
|
86
|
+
*/
|
|
87
|
+
export declare function townName(council: string): string;
|
|
88
|
+
/**
|
|
89
|
+
* The PUBLIC city of a place picked from the area tree (0.19.0): what cards
|
|
90
|
+
* show and Discover's city filter and facets match. A member in a town (they
|
|
91
|
+
* picked the town, or a ward in it) is in that town; anyone else is in their
|
|
92
|
+
* district (a village, a block, the whole district). Either way in the
|
|
93
|
+
* state's own spelling (`listedCityName`: "Bbmp" is Bengaluru, "Greater
|
|
94
|
+
* Mumbai" is Mumbai), else the name as the tree has it, cleaned
|
|
95
|
+
* (`townName`; "Lakshadweep District" is Lakshadweep). A town or district
|
|
96
|
+
* this list does not hold is still a real place, shown as it is.
|
|
97
|
+
*
|
|
98
|
+
* Always fits a stored city (`CITY_MAX`): a town named longer is shown as its
|
|
99
|
+
* district, and a district longer still is cut at a word. The all-India tree
|
|
100
|
+
* has none (its longest town or district is 35, 2026-10-22); a later tree may.
|
|
101
|
+
*/
|
|
102
|
+
export declare function publicCityOf(stateName: string, district: string, town?: string | null): string;
|
|
71
103
|
/**
|
|
72
104
|
* A place as the list writes it, from however it arrived: a member's older
|
|
73
105
|
* draft ("karnataka"), the location lookup ("Bengaluru Urban" in "KARNATAKA"),
|
|
@@ -88,118 +120,4 @@ export declare function canonicalIndiaLocation(place: {
|
|
|
88
120
|
state: string;
|
|
89
121
|
country: typeof INDIA;
|
|
90
122
|
};
|
|
91
|
-
/**
|
|
92
|
-
* A location as it is WRITTEN (0.17.0): onboarding's finish, the Me tab's
|
|
93
|
-
* personal details, and the server's own suggestion. India only, one of its
|
|
94
|
-
* states and union territories, and a city of any name within it.
|
|
95
|
-
*
|
|
96
|
-
* Until 0.17.0 the schema took any country and any state text while the web
|
|
97
|
-
* locked the country to India and chose the state from this list, so another
|
|
98
|
-
* client could store what no screen can show. The read side keeps
|
|
99
|
-
* `locationSchema`: a location stored before this rule is still read as it is.
|
|
100
|
-
*
|
|
101
|
-
* The STATE is required: every Indian city has one, and the picker lists a
|
|
102
|
-
* state's cities only once it is chosen. It is read the way people and the
|
|
103
|
-
* location lookup write it ("KARNATAKA", "Orissa", "Jammu & Kashmir" are the
|
|
104
|
-
* list's Karnataka, Odisha, Jammu and Kashmir: `findIndiaState`), so any client
|
|
105
|
-
* may send another spelling and the list's name is what is kept. Left empty it
|
|
106
|
-
* is `stateRequired`; one the list does not know is `stateUnknown`.
|
|
107
|
-
*/
|
|
108
|
-
export declare const indiaLocationSchema: z.ZodObject<{
|
|
109
|
-
city: z.ZodString;
|
|
110
|
-
state: z.ZodPreprocess<z.ZodEnum<{
|
|
111
|
-
"Jammu and Kashmir": "Jammu and Kashmir";
|
|
112
|
-
"Himachal Pradesh": "Himachal Pradesh";
|
|
113
|
-
Punjab: "Punjab";
|
|
114
|
-
Chandigarh: "Chandigarh";
|
|
115
|
-
Uttarakhand: "Uttarakhand";
|
|
116
|
-
Haryana: "Haryana";
|
|
117
|
-
Delhi: "Delhi";
|
|
118
|
-
Rajasthan: "Rajasthan";
|
|
119
|
-
"Uttar Pradesh": "Uttar Pradesh";
|
|
120
|
-
Bihar: "Bihar";
|
|
121
|
-
Sikkim: "Sikkim";
|
|
122
|
-
"Arunachal Pradesh": "Arunachal Pradesh";
|
|
123
|
-
Nagaland: "Nagaland";
|
|
124
|
-
Manipur: "Manipur";
|
|
125
|
-
Mizoram: "Mizoram";
|
|
126
|
-
Tripura: "Tripura";
|
|
127
|
-
Meghalaya: "Meghalaya";
|
|
128
|
-
Assam: "Assam";
|
|
129
|
-
"West Bengal": "West Bengal";
|
|
130
|
-
Jharkhand: "Jharkhand";
|
|
131
|
-
Odisha: "Odisha";
|
|
132
|
-
Chhattisgarh: "Chhattisgarh";
|
|
133
|
-
"Madhya Pradesh": "Madhya Pradesh";
|
|
134
|
-
Gujarat: "Gujarat";
|
|
135
|
-
"Dadra and Nagar Haveli and Daman and Diu": "Dadra and Nagar Haveli and Daman and Diu";
|
|
136
|
-
Maharashtra: "Maharashtra";
|
|
137
|
-
Karnataka: "Karnataka";
|
|
138
|
-
Goa: "Goa";
|
|
139
|
-
Lakshadweep: "Lakshadweep";
|
|
140
|
-
Kerala: "Kerala";
|
|
141
|
-
"Tamil Nadu": "Tamil Nadu";
|
|
142
|
-
Puducherry: "Puducherry";
|
|
143
|
-
"Andaman and Nicobar Islands": "Andaman and Nicobar Islands";
|
|
144
|
-
Telangana: "Telangana";
|
|
145
|
-
"Andhra Pradesh": "Andhra Pradesh";
|
|
146
|
-
Ladakh: "Ladakh";
|
|
147
|
-
}>, unknown>;
|
|
148
|
-
country: z.ZodLiteral<"India">;
|
|
149
|
-
}, z.core.$strip>;
|
|
150
|
-
export type IndiaLocation = z.infer<typeof indiaLocationSchema>;
|
|
151
|
-
/**
|
|
152
|
-
* The city these coordinates look like, for the member to CONFIRM, or `null`
|
|
153
|
-
* when the lookup could not place them confidently (or they are outside India,
|
|
154
|
-
* whose area data is all there is). A suggestion, never a write: only what the
|
|
155
|
-
* member then submits becomes their location.
|
|
156
|
-
*
|
|
157
|
-
* In the WRITE shape (0.17.0): the server names the state and city the way
|
|
158
|
-
* this list does (`findIndiaState`, `listedCityName`: the lookup's "Bengaluru
|
|
159
|
-
* Urban" is Bengaluru), so what it suggests is what the member could have
|
|
160
|
-
* picked, and saving it unchanged can never be refused.
|
|
161
|
-
*/
|
|
162
|
-
export declare const suggestedLocationSchema: z.ZodNullable<z.ZodObject<{
|
|
163
|
-
city: z.ZodString;
|
|
164
|
-
state: z.ZodPreprocess<z.ZodEnum<{
|
|
165
|
-
"Jammu and Kashmir": "Jammu and Kashmir";
|
|
166
|
-
"Himachal Pradesh": "Himachal Pradesh";
|
|
167
|
-
Punjab: "Punjab";
|
|
168
|
-
Chandigarh: "Chandigarh";
|
|
169
|
-
Uttarakhand: "Uttarakhand";
|
|
170
|
-
Haryana: "Haryana";
|
|
171
|
-
Delhi: "Delhi";
|
|
172
|
-
Rajasthan: "Rajasthan";
|
|
173
|
-
"Uttar Pradesh": "Uttar Pradesh";
|
|
174
|
-
Bihar: "Bihar";
|
|
175
|
-
Sikkim: "Sikkim";
|
|
176
|
-
"Arunachal Pradesh": "Arunachal Pradesh";
|
|
177
|
-
Nagaland: "Nagaland";
|
|
178
|
-
Manipur: "Manipur";
|
|
179
|
-
Mizoram: "Mizoram";
|
|
180
|
-
Tripura: "Tripura";
|
|
181
|
-
Meghalaya: "Meghalaya";
|
|
182
|
-
Assam: "Assam";
|
|
183
|
-
"West Bengal": "West Bengal";
|
|
184
|
-
Jharkhand: "Jharkhand";
|
|
185
|
-
Odisha: "Odisha";
|
|
186
|
-
Chhattisgarh: "Chhattisgarh";
|
|
187
|
-
"Madhya Pradesh": "Madhya Pradesh";
|
|
188
|
-
Gujarat: "Gujarat";
|
|
189
|
-
"Dadra and Nagar Haveli and Daman and Diu": "Dadra and Nagar Haveli and Daman and Diu";
|
|
190
|
-
Maharashtra: "Maharashtra";
|
|
191
|
-
Karnataka: "Karnataka";
|
|
192
|
-
Goa: "Goa";
|
|
193
|
-
Lakshadweep: "Lakshadweep";
|
|
194
|
-
Kerala: "Kerala";
|
|
195
|
-
"Tamil Nadu": "Tamil Nadu";
|
|
196
|
-
Puducherry: "Puducherry";
|
|
197
|
-
"Andaman and Nicobar Islands": "Andaman and Nicobar Islands";
|
|
198
|
-
Telangana: "Telangana";
|
|
199
|
-
"Andhra Pradesh": "Andhra Pradesh";
|
|
200
|
-
Ladakh: "Ladakh";
|
|
201
|
-
}>, unknown>;
|
|
202
|
-
country: z.ZodLiteral<"India">;
|
|
203
|
-
}, z.core.$strip>>;
|
|
204
|
-
export type SuggestedLocation = z.infer<typeof suggestedLocationSchema>;
|
|
205
123
|
//# sourceMappingURL=india.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"india.d.ts","sourceRoot":"","sources":["../../../src/domains/location/india.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"india.d.ts","sourceRoot":"","sources":["../../../src/domains/location/india.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAGH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAEpD;;;;;GAKG;AACH,MAAM,MAAM,cAAc,GAAG,CAAC,OAAO,UAAU,CAAC,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC;AAEjE,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,cAAc,CAAC;IACrB,wDAAwD;IACxD,OAAO,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC5B,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC;CAC3B;AAED,qDAAqD;AACrD,eAAO,MAAM,KAAK,EAAG,OAAgB,CAAC;AAEtC,0GAA0G;AAC1G,eAAO,MAAM,kBAAkB,EAAG,KAAc,CAAC;AAEjD,eAAO,MAAM,YAAY,EAAE,SAAS,UAAU,EAy6B7C,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,YAAY,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC,CAqGpE,CAAC;AAUF;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,UAAU,GAAG,SAAS,CAOtF;AAED;;;GAGG;AACH,eAAO,MAAM,iBAAiB,EAAyD,SAAS,CAC9F,cAAc,EACd,GAAG,cAAc,EAAE,CACpB,CAAC;AAEF,iFAAiF;AACjF,eAAO,MAAM,aAAa,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC,CAErE,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,UAAU,GAAG,SAAS,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAOlF;AAED;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,MAAM,EACZ,MAAM,GAAE,SAAS,IAAI,CAAC,UAAU,EAAE,QAAQ,CAAC,EAAiB,GAC3D,MAAM,CAYR;AAED;;;;;;;GAOG;AACH,wBAAgB,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAuBhD;AAaD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,YAAY,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,CAQ9F;AAqBD;;;;;;;;;;;GAWG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,GAAG;IACtF,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,OAAO,KAAK,CAAC;CACvB,CAOA"}
|
|
@@ -3,19 +3,18 @@
|
|
|
3
3
|
* and cities (0.17.0, moved here from the web client, where the location step's
|
|
4
4
|
* lists lived in the screen).
|
|
5
5
|
*
|
|
6
|
-
* Founder Circle is in India for now (the user, 2026-10-18
|
|
7
|
-
*
|
|
8
|
-
*
|
|
6
|
+
* Founder Circle is in India for now (the user, 2026-10-18). Since 0.19.0 a
|
|
7
|
+
* member's location is picked from `master_db`'s area tree (`./areas.ts`), so
|
|
8
|
+
* this file no longer holds a write rule; it is the data that names a place
|
|
9
|
+
* the way members say it, read by every side:
|
|
9
10
|
*
|
|
10
11
|
* states all 28 states and 8 union territories, by their current names: a
|
|
11
12
|
* CLOSED list, so a state is one of these or refused (`stateUnknown`)
|
|
12
|
-
* cities per state, the larger cities first, the rest A to Z
|
|
13
|
-
*
|
|
14
|
-
* text, so the list spares members the typing and the spelling
|
|
15
|
-
* variants, and the picker also takes a town it does not hold
|
|
13
|
+
* cities per state, the larger cities first, the rest A to Z: the
|
|
14
|
+
* spellings Discover's city filter and a stored city are matched in
|
|
16
15
|
* aliases older or other names a member may search by ("Bangalore" finds
|
|
17
16
|
* Bengaluru), and the district names the location lookup answers
|
|
18
|
-
* with ("Bengaluru Urban"), so
|
|
17
|
+
* with ("Bengaluru Urban"), so a district's public city and a member's
|
|
19
18
|
* search land on the list's own spelling
|
|
20
19
|
*
|
|
21
20
|
* Written for this product from public knowledge of India's cities; no
|
|
@@ -23,10 +22,7 @@
|
|
|
23
22
|
*
|
|
24
23
|
* @module founder-schema/domains/location/india
|
|
25
24
|
*/
|
|
26
|
-
import { z } from 'zod';
|
|
27
|
-
import { emptyStringToUndefined } from '../../core/common.js';
|
|
28
25
|
import { CITY_MAX } from '../../core/limits.js';
|
|
29
|
-
import { VALIDATION_MESSAGE } from '../../core/validation.js';
|
|
30
26
|
/** The one country a location may be in, for now. */
|
|
31
27
|
export const INDIA = 'India';
|
|
32
28
|
/** India's international dialing code: what a phone number is shown with (the stored number has none). */
|
|
@@ -155,6 +151,7 @@ export const INDIA_STATES = [
|
|
|
155
151
|
'Durg',
|
|
156
152
|
'Ambikapur',
|
|
157
153
|
'Bhatapara',
|
|
154
|
+
'Bijapur',
|
|
158
155
|
'Chirmiri',
|
|
159
156
|
'Dhamtari',
|
|
160
157
|
'Jagdalpur',
|
|
@@ -974,9 +971,12 @@ export const INDIA_STATES = [
|
|
|
974
971
|
* any of them shows the city as the list writes it.
|
|
975
972
|
*/
|
|
976
973
|
export const CITY_ALIASES = {
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
974
|
+
// `Bbmp`: how the area tree names Bengaluru's council (0.19.0).
|
|
975
|
+
Bengaluru: ['Bangalore', 'Bengaluru Urban', 'Bangalore Urban', 'Bbmp', 'Bruhat Bengaluru'],
|
|
976
|
+
Mumbai: ['Bombay', 'Mumbai Suburban', 'Mumbai City', 'Greater Mumbai'],
|
|
977
|
+
Chennai: ['Madras', 'Greater Chennai'],
|
|
978
|
+
// The area tree's spelling (LGD).
|
|
979
|
+
Ahmedabad: ['Ahmadabad'],
|
|
980
980
|
Kolkata: ['Calcutta'],
|
|
981
981
|
Gurugram: ['Gurgaon'],
|
|
982
982
|
Noida: ['Gautam Buddha Nagar'],
|
|
@@ -1031,8 +1031,8 @@ export const CITY_ALIASES = {
|
|
|
1031
1031
|
Baharampur: ['Berhampore'],
|
|
1032
1032
|
Bardhaman: ['Burdwan', 'Purba Bardhaman'],
|
|
1033
1033
|
Sohra: ['Cherrapunji'],
|
|
1034
|
-
'Sri Vijaya Puram': ['Port Blair', 'South Andaman'],
|
|
1035
|
-
Mohali: ['SAS Nagar', 'Sahibzada Ajit Singh Nagar'],
|
|
1034
|
+
'Sri Vijaya Puram': ['Port Blair', 'South Andaman', 'South Andamans'],
|
|
1035
|
+
Mohali: ['SAS Nagar', 'Sahibzada Ajit Singh Nagar', 'S.A.S Nagar'],
|
|
1036
1036
|
Kurukshetra: ['Thanesar'],
|
|
1037
1037
|
Gyalshing: ['Geyzing'],
|
|
1038
1038
|
Siaha: ['Saiha'],
|
|
@@ -1074,7 +1074,7 @@ export const CITY_ALIASES = {
|
|
|
1074
1074
|
};
|
|
1075
1075
|
const key = (text) => text
|
|
1076
1076
|
.toLowerCase()
|
|
1077
|
-
.replace(/[.\s
|
|
1077
|
+
.replace(/[.\s&-]+/g, ' ')
|
|
1078
1078
|
.replace(/\band\b/g, ' ')
|
|
1079
1079
|
.replace(/\s+/g, ' ')
|
|
1080
1080
|
.trim();
|
|
@@ -1110,6 +1110,110 @@ export function listedCityName(state, name) {
|
|
|
1110
1110
|
const city = state.cities.find((c) => key(c) === wanted || CITY_ALIASES[c]?.some((alias) => key(alias) === wanted));
|
|
1111
1111
|
return city ?? name;
|
|
1112
1112
|
}
|
|
1113
|
+
/**
|
|
1114
|
+
* A city as the list writes it from its name ALONE (0.18.0), for where no
|
|
1115
|
+
* state comes with it (Discover's `?city=` from a shared link): the list's
|
|
1116
|
+
* spelling when the name, or another name of a city, matches exactly ONE
|
|
1117
|
+
* spelling in the list ("Bangalore" is Bengaluru; "BILASPUR", a city of two
|
|
1118
|
+
* states, is "Bilaspur" either way), and the name unchanged when it matches
|
|
1119
|
+
* none or two different spellings (never guessed between them). `states` is
|
|
1120
|
+
* the list, India's unless a test hands it another.
|
|
1121
|
+
*/
|
|
1122
|
+
export function canonicalCityName(name, states = INDIA_STATES) {
|
|
1123
|
+
const wanted = key(name);
|
|
1124
|
+
if (!wanted)
|
|
1125
|
+
return name;
|
|
1126
|
+
const found = new Set();
|
|
1127
|
+
for (const state of states) {
|
|
1128
|
+
for (const c of state.cities) {
|
|
1129
|
+
if (key(c) === wanted || CITY_ALIASES[c]?.some((alias) => key(alias) === wanted))
|
|
1130
|
+
found.add(c);
|
|
1131
|
+
}
|
|
1132
|
+
}
|
|
1133
|
+
const [only] = found;
|
|
1134
|
+
return found.size === 1 && only ? only : name;
|
|
1135
|
+
}
|
|
1136
|
+
/**
|
|
1137
|
+
* The town an urban body is, from the area tree's name for its council
|
|
1138
|
+
* (0.19.0): "Gangtok (M Corp.)", "Kohima Municipal Council", "City Corporation
|
|
1139
|
+
* Panaji", "Municipal Committee Akhnoor", "Rajgarh (Alwar)" (a bracket that
|
|
1140
|
+
* tells two towns apart) are Gangtok, Kohima, Panaji, Akhnoor, Rajgarh. What
|
|
1141
|
+
* is left is the town's own name; one the tree wrote in capitals ("MAUGANJ")
|
|
1142
|
+
* reads like the rest (Mauganj).
|
|
1143
|
+
*/
|
|
1144
|
+
export function townName(council) {
|
|
1145
|
+
const name = council
|
|
1146
|
+
.replace(/\([^)]*\)/g, ' ')
|
|
1147
|
+
.replace(/\.{2,}/g, ' ')
|
|
1148
|
+
.replace(/^\s*(city corporation|municipal committee|municipal council|municipal board|notified area committee|town area committee|nagar palika,)\s*/i, '')
|
|
1149
|
+
.replace(/\s+(municipal corporation|municipal council|municipal committee|municipal board|municipal co-?operation|muncipal council|town council|town committee|town area committee|notified area committee|cantonment board|corporation|municipality|nagar nigam|nagar palika parishad|nagar palika|nagar parishad|nagar panchayat|nagarpanchayat|mahanagara palike|mahanagar palika|mahanagarpalika)\s*$/i, '')
|
|
1150
|
+
// A twin town is one hyphen however the tree spaced it ("Murwara - Katni" is
|
|
1151
|
+
// Murwara-Katni), as the list writes its own (Pimpri-Chinchwad, Vasai-Virar).
|
|
1152
|
+
.replace(/\s*-\s*/g, '-')
|
|
1153
|
+
.replace(/\s+/g, ' ')
|
|
1154
|
+
.trim()
|
|
1155
|
+
.replace(/\.+$/, '');
|
|
1156
|
+
return /\p{Ll}/u.test(name)
|
|
1157
|
+
? name
|
|
1158
|
+
: name
|
|
1159
|
+
.toLowerCase()
|
|
1160
|
+
.replace(/(^|[\s-])(\p{L})/gu, (_, gap, c) => gap + c.toUpperCase());
|
|
1161
|
+
}
|
|
1162
|
+
/**
|
|
1163
|
+
* States that are one city for the public (0.19.0): the area tree splits
|
|
1164
|
+
* Delhi into districts named by compass point ("South", "Central North"),
|
|
1165
|
+
* which no one calls their city. Any district not itself a listed city (New
|
|
1166
|
+
* Delhi is) is the state's city.
|
|
1167
|
+
*/
|
|
1168
|
+
const ONE_CITY_STATES = {
|
|
1169
|
+
Delhi: 'Delhi',
|
|
1170
|
+
Chandigarh: 'Chandigarh',
|
|
1171
|
+
};
|
|
1172
|
+
/**
|
|
1173
|
+
* The PUBLIC city of a place picked from the area tree (0.19.0): what cards
|
|
1174
|
+
* show and Discover's city filter and facets match. A member in a town (they
|
|
1175
|
+
* picked the town, or a ward in it) is in that town; anyone else is in their
|
|
1176
|
+
* district (a village, a block, the whole district). Either way in the
|
|
1177
|
+
* state's own spelling (`listedCityName`: "Bbmp" is Bengaluru, "Greater
|
|
1178
|
+
* Mumbai" is Mumbai), else the name as the tree has it, cleaned
|
|
1179
|
+
* (`townName`; "Lakshadweep District" is Lakshadweep). A town or district
|
|
1180
|
+
* this list does not hold is still a real place, shown as it is.
|
|
1181
|
+
*
|
|
1182
|
+
* Always fits a stored city (`CITY_MAX`): a town named longer is shown as its
|
|
1183
|
+
* district, and a district longer still is cut at a word. The all-India tree
|
|
1184
|
+
* has none (its longest town or district is 35, 2026-10-22); a later tree may.
|
|
1185
|
+
*/
|
|
1186
|
+
export function publicCityOf(stateName, district, town) {
|
|
1187
|
+
const city = cityOf(stateName, district, town);
|
|
1188
|
+
if (city.length <= CITY_MAX)
|
|
1189
|
+
return city;
|
|
1190
|
+
if (town)
|
|
1191
|
+
return publicCityOf(stateName, district);
|
|
1192
|
+
return city
|
|
1193
|
+
.slice(0, CITY_MAX + 1)
|
|
1194
|
+
.replace(/\s+\S*$/, '')
|
|
1195
|
+
.slice(0, CITY_MAX);
|
|
1196
|
+
}
|
|
1197
|
+
function cityOf(stateName, district, town) {
|
|
1198
|
+
const state = findIndiaState(stateName);
|
|
1199
|
+
const listed = (name) => listedCityName(state, name);
|
|
1200
|
+
const onList = (name) => Boolean(state?.cities.includes(name));
|
|
1201
|
+
const townCity = town ? townName(town) : '';
|
|
1202
|
+
if (townCity) {
|
|
1203
|
+
const named = listed(townCity);
|
|
1204
|
+
if (onList(named))
|
|
1205
|
+
return named;
|
|
1206
|
+
const oneCity = state ? ONE_CITY_STATES[state.name] : undefined;
|
|
1207
|
+
// A Delhi council named by compass ("East Delhi") is Delhi: listed above.
|
|
1208
|
+
return oneCity && /delhi/i.test(townCity) ? oneCity : named;
|
|
1209
|
+
}
|
|
1210
|
+
// A district's own brackets too ("Khandwa (East Nimar)" is Khandwa).
|
|
1211
|
+
const districtCity = listed(townName(district.replace(/\s+district\s*$/i, '')));
|
|
1212
|
+
if (onList(districtCity))
|
|
1213
|
+
return districtCity;
|
|
1214
|
+
const oneCity = state ? ONE_CITY_STATES[state.name] : undefined;
|
|
1215
|
+
return oneCity ?? districtCity;
|
|
1216
|
+
}
|
|
1113
1217
|
/**
|
|
1114
1218
|
* A place as the list writes it, from however it arrived: a member's older
|
|
1115
1219
|
* draft ("karnataka"), the location lookup ("Bengaluru Urban" in "KARNATAKA"),
|
|
@@ -1130,46 +1234,4 @@ export function canonicalIndiaLocation(place) {
|
|
|
1130
1234
|
country: INDIA,
|
|
1131
1235
|
};
|
|
1132
1236
|
}
|
|
1133
|
-
// ─── The rule ────────────────────────────────────────────────────────────────
|
|
1134
|
-
/**
|
|
1135
|
-
* A location as it is WRITTEN (0.17.0): onboarding's finish, the Me tab's
|
|
1136
|
-
* personal details, and the server's own suggestion. India only, one of its
|
|
1137
|
-
* states and union territories, and a city of any name within it.
|
|
1138
|
-
*
|
|
1139
|
-
* Until 0.17.0 the schema took any country and any state text while the web
|
|
1140
|
-
* locked the country to India and chose the state from this list, so another
|
|
1141
|
-
* client could store what no screen can show. The read side keeps
|
|
1142
|
-
* `locationSchema`: a location stored before this rule is still read as it is.
|
|
1143
|
-
*
|
|
1144
|
-
* The STATE is required: every Indian city has one, and the picker lists a
|
|
1145
|
-
* state's cities only once it is chosen. It is read the way people and the
|
|
1146
|
-
* location lookup write it ("KARNATAKA", "Orissa", "Jammu & Kashmir" are the
|
|
1147
|
-
* list's Karnataka, Odisha, Jammu and Kashmir: `findIndiaState`), so any client
|
|
1148
|
-
* may send another spelling and the list's name is what is kept. Left empty it
|
|
1149
|
-
* is `stateRequired`; one the list does not know is `stateUnknown`.
|
|
1150
|
-
*/
|
|
1151
|
-
export const indiaLocationSchema = z.object({
|
|
1152
|
-
city: z.string().trim().min(1).max(CITY_MAX),
|
|
1153
|
-
state: z.preprocess((value) => {
|
|
1154
|
-
const given = emptyStringToUndefined(value);
|
|
1155
|
-
return typeof given === 'string' ? (findIndiaState(given)?.name ?? given) : given;
|
|
1156
|
-
}, z.enum(INDIA_STATE_NAMES, {
|
|
1157
|
-
error: (issue) => issue.input === undefined
|
|
1158
|
-
? VALIDATION_MESSAGE.stateRequired
|
|
1159
|
-
: VALIDATION_MESSAGE.stateUnknown,
|
|
1160
|
-
})),
|
|
1161
|
-
country: z.literal(INDIA),
|
|
1162
|
-
});
|
|
1163
|
-
/**
|
|
1164
|
-
* The city these coordinates look like, for the member to CONFIRM, or `null`
|
|
1165
|
-
* when the lookup could not place them confidently (or they are outside India,
|
|
1166
|
-
* whose area data is all there is). A suggestion, never a write: only what the
|
|
1167
|
-
* member then submits becomes their location.
|
|
1168
|
-
*
|
|
1169
|
-
* In the WRITE shape (0.17.0): the server names the state and city the way
|
|
1170
|
-
* this list does (`findIndiaState`, `listedCityName`: the lookup's "Bengaluru
|
|
1171
|
-
* Urban" is Bengaluru), so what it suggests is what the member could have
|
|
1172
|
-
* picked, and saving it unchanged can never be refused.
|
|
1173
|
-
*/
|
|
1174
|
-
export const suggestedLocationSchema = indiaLocationSchema.nullable();
|
|
1175
1237
|
//# sourceMappingURL=india.js.map
|