jansathi-community-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/dist/community.d.ts +219 -8
- package/dist/community.d.ts.map +1 -1
- package/dist/community.js +201 -10
- package/dist/community.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -4
- package/dist/index.js.map +1 -1
- package/dist/poll.d.ts.map +1 -1
- package/dist/poll.js +15 -25
- package/dist/poll.js.map +1 -1
- package/dist/profile.d.ts +49 -0
- package/dist/profile.d.ts.map +1 -1
- package/dist/profile.js +33 -2
- package/dist/profile.js.map +1 -1
- package/dist/report.d.ts +2 -2
- package/dist/social.d.ts +15 -0
- package/dist/social.d.ts.map +1 -1
- package/dist/social.js +22 -0
- package/dist/social.js.map +1 -1
- package/package.json +1 -1
package/dist/community.d.ts
CHANGED
|
@@ -27,6 +27,63 @@
|
|
|
27
27
|
* @module community-schema/community
|
|
28
28
|
*/
|
|
29
29
|
import { z } from 'zod';
|
|
30
|
+
/**
|
|
31
|
+
* Two fundamentally different community shapes share the same wire
|
|
32
|
+
* schema:
|
|
33
|
+
*
|
|
34
|
+
* user — topic-of-interest community a regular user creates and
|
|
35
|
+
* owns (Reddit subreddit / Facebook group analogue). Owner
|
|
36
|
+
* + admins manage; members join. The default kind.
|
|
37
|
+
* official — area-based civic community for a specific administrative
|
|
38
|
+
* area (village / block / district / urban body / ... up
|
|
39
|
+
* to state). Created by the elected area leader; has NO
|
|
40
|
+
* owner. Permission is computed at read time from the
|
|
41
|
+
* current area-leader binding:
|
|
42
|
+
* - admin role = whoever is the area's leader right now
|
|
43
|
+
* (falls back to platform superadmin when no leader is
|
|
44
|
+
* appointed)
|
|
45
|
+
* - representative role = the elected official the area
|
|
46
|
+
* leader names (Pradhan / Mayor / MLA / ...); replaced
|
|
47
|
+
* on each new political election
|
|
48
|
+
* - moderator role = community-scoped; can hide reported
|
|
49
|
+
* posts. Representative can override moderator
|
|
50
|
+
* decisions from settings.
|
|
51
|
+
* Always auto-verified (the leader's act of creating it IS
|
|
52
|
+
* the verification) and immune to delete from anyone
|
|
53
|
+
* except platform superadmin / manager.
|
|
54
|
+
*/
|
|
55
|
+
export declare const COMMUNITY_KIND_VALUES: readonly ["user", "official"];
|
|
56
|
+
export type CommunityKind = (typeof COMMUNITY_KIND_VALUES)[number];
|
|
57
|
+
export declare const communityKindSchema: z.ZodEnum<{
|
|
58
|
+
user: "user";
|
|
59
|
+
official: "official";
|
|
60
|
+
}>;
|
|
61
|
+
/**
|
|
62
|
+
* Administrative area levels that can host an official community.
|
|
63
|
+
*
|
|
64
|
+
* Mirrors a subset of the reform-backend `JURISDICTION_LEVEL` enum —
|
|
65
|
+
* NATIONAL and GLOBAL are intentionally excluded because they are
|
|
66
|
+
* virtual tiers (no `Area` row) and don't fit the "community for THIS
|
|
67
|
+
* area" model. If we ever want national / global civic communities
|
|
68
|
+
* they should be a separate concept.
|
|
69
|
+
*
|
|
70
|
+
* The leader-jurisdiction → area-kind binding is 1:1:
|
|
71
|
+
* leader.jurisdictionLevel === community.officialAreaKind AND
|
|
72
|
+
* leader.jurisdictionAreaId === community.officialAreaId
|
|
73
|
+
* is the gate for who can create / admin the community.
|
|
74
|
+
*/
|
|
75
|
+
export declare const OFFICIAL_COMMUNITY_AREA_KIND_VALUES: readonly ["STATE", "DISTRICT", "BLOCK", "GRAM_PANCHAYAT", "VILLAGE", "URBAN_BODY", "URBAN_WARD", "LOCALITY"];
|
|
76
|
+
export type OfficialCommunityAreaKind = (typeof OFFICIAL_COMMUNITY_AREA_KIND_VALUES)[number];
|
|
77
|
+
export declare const officialCommunityAreaKindSchema: z.ZodEnum<{
|
|
78
|
+
STATE: "STATE";
|
|
79
|
+
DISTRICT: "DISTRICT";
|
|
80
|
+
BLOCK: "BLOCK";
|
|
81
|
+
GRAM_PANCHAYAT: "GRAM_PANCHAYAT";
|
|
82
|
+
VILLAGE: "VILLAGE";
|
|
83
|
+
URBAN_BODY: "URBAN_BODY";
|
|
84
|
+
URBAN_WARD: "URBAN_WARD";
|
|
85
|
+
LOCALITY: "LOCALITY";
|
|
86
|
+
}>;
|
|
30
87
|
/**
|
|
31
88
|
* public — anyone can read + post.
|
|
32
89
|
* restricted — anyone can read; only approved members can post. The
|
|
@@ -411,17 +468,37 @@ export declare const communityCenterCoordsSchema: z.ZodObject<{
|
|
|
411
468
|
export type CommunityCenterCoords = z.infer<typeof communityCenterCoordsSchema>;
|
|
412
469
|
/** Role hierarchy within a single community.
|
|
413
470
|
*
|
|
414
|
-
*
|
|
415
|
-
*
|
|
416
|
-
*
|
|
417
|
-
*
|
|
418
|
-
*
|
|
471
|
+
* The role set is shared across `user` and `official` communities, but
|
|
472
|
+
* not every role is valid for every kind:
|
|
473
|
+
*
|
|
474
|
+
* owner — `kind: 'user'` only. The creator; can edit
|
|
475
|
+
* metadata, transfer ownership (deferred), and
|
|
476
|
+
* delete the community.
|
|
477
|
+
* admin — `kind: 'user'`: granted by the owner; can edit
|
|
478
|
+
* metadata, kick members, soft-delete posts.
|
|
479
|
+
* `kind: 'official'`: computed from the current
|
|
480
|
+
* area-leader binding (never stored on a membership
|
|
481
|
+
* row); platform superadmin fills the slot when no
|
|
482
|
+
* leader is appointed.
|
|
483
|
+
* representative — `kind: 'official'` only. The elected official the
|
|
484
|
+
* area leader names (Pradhan / Mayor / ...).
|
|
485
|
+
* Replaced on every new political election. Can
|
|
486
|
+
* override moderator decisions from the community
|
|
487
|
+
* settings page.
|
|
488
|
+
* moderator — `kind: 'official'` only. Community-scoped; can
|
|
489
|
+
* hide reported posts. Multiple moderators allowed
|
|
490
|
+
* per community. The current admin (area leader)
|
|
491
|
+
* grants and revokes.
|
|
492
|
+
* member — joined; can post and comment, can leave at any
|
|
493
|
+
* time. Valid for both kinds.
|
|
419
494
|
*/
|
|
420
|
-
export declare const COMMUNITY_ROLE_VALUES: readonly ["owner", "admin", "member"];
|
|
495
|
+
export declare const COMMUNITY_ROLE_VALUES: readonly ["owner", "admin", "representative", "moderator", "member"];
|
|
421
496
|
export type CommunityRole = (typeof COMMUNITY_ROLE_VALUES)[number];
|
|
422
497
|
export declare const communityRoleSchema: z.ZodEnum<{
|
|
423
498
|
owner: "owner";
|
|
424
499
|
admin: "admin";
|
|
500
|
+
representative: "representative";
|
|
501
|
+
moderator: "moderator";
|
|
425
502
|
member: "member";
|
|
426
503
|
}>;
|
|
427
504
|
/** Membership lifecycle.
|
|
@@ -456,7 +533,12 @@ export declare const communityWireSchema: z.ZodObject<{
|
|
|
456
533
|
restricted: "restricted";
|
|
457
534
|
}>;
|
|
458
535
|
coverImageUrl: z.ZodOptional<z.ZodString>;
|
|
459
|
-
|
|
536
|
+
kind: z.ZodEnum<{
|
|
537
|
+
user: "user";
|
|
538
|
+
official: "official";
|
|
539
|
+
}>;
|
|
540
|
+
ownerUserId: z.ZodNullable<z.ZodString>;
|
|
541
|
+
createdBy: z.ZodNullable<z.ZodString>;
|
|
460
542
|
memberCount: z.ZodNumber;
|
|
461
543
|
postCount: z.ZodNumber;
|
|
462
544
|
groupId: z.ZodString;
|
|
@@ -703,10 +785,23 @@ export declare const communityWireSchema: z.ZodObject<{
|
|
|
703
785
|
national: "national";
|
|
704
786
|
global: "global";
|
|
705
787
|
}>>;
|
|
788
|
+
officialAreaKind: z.ZodNullable<z.ZodEnum<{
|
|
789
|
+
STATE: "STATE";
|
|
790
|
+
DISTRICT: "DISTRICT";
|
|
791
|
+
BLOCK: "BLOCK";
|
|
792
|
+
GRAM_PANCHAYAT: "GRAM_PANCHAYAT";
|
|
793
|
+
VILLAGE: "VILLAGE";
|
|
794
|
+
URBAN_BODY: "URBAN_BODY";
|
|
795
|
+
URBAN_WARD: "URBAN_WARD";
|
|
796
|
+
LOCALITY: "LOCALITY";
|
|
797
|
+
}>>;
|
|
798
|
+
officialAreaId: z.ZodNullable<z.ZodString>;
|
|
706
799
|
viewer: z.ZodOptional<z.ZodObject<{
|
|
707
800
|
role: z.ZodNullable<z.ZodEnum<{
|
|
708
801
|
owner: "owner";
|
|
709
802
|
admin: "admin";
|
|
803
|
+
representative: "representative";
|
|
804
|
+
moderator: "moderator";
|
|
710
805
|
member: "member";
|
|
711
806
|
}>>;
|
|
712
807
|
status: z.ZodNullable<z.ZodEnum<{
|
|
@@ -750,6 +845,8 @@ export declare const communityMemberWireSchema: z.ZodObject<{
|
|
|
750
845
|
role: z.ZodEnum<{
|
|
751
846
|
owner: "owner";
|
|
752
847
|
admin: "admin";
|
|
848
|
+
representative: "representative";
|
|
849
|
+
moderator: "moderator";
|
|
753
850
|
member: "member";
|
|
754
851
|
}>;
|
|
755
852
|
status: z.ZodEnum<{
|
|
@@ -1368,7 +1465,12 @@ export declare const communityListResponseSchema: z.ZodObject<{
|
|
|
1368
1465
|
restricted: "restricted";
|
|
1369
1466
|
}>;
|
|
1370
1467
|
coverImageUrl: z.ZodOptional<z.ZodString>;
|
|
1371
|
-
|
|
1468
|
+
kind: z.ZodEnum<{
|
|
1469
|
+
user: "user";
|
|
1470
|
+
official: "official";
|
|
1471
|
+
}>;
|
|
1472
|
+
ownerUserId: z.ZodNullable<z.ZodString>;
|
|
1473
|
+
createdBy: z.ZodNullable<z.ZodString>;
|
|
1372
1474
|
memberCount: z.ZodNumber;
|
|
1373
1475
|
postCount: z.ZodNumber;
|
|
1374
1476
|
groupId: z.ZodString;
|
|
@@ -1615,10 +1717,23 @@ export declare const communityListResponseSchema: z.ZodObject<{
|
|
|
1615
1717
|
national: "national";
|
|
1616
1718
|
global: "global";
|
|
1617
1719
|
}>>;
|
|
1720
|
+
officialAreaKind: z.ZodNullable<z.ZodEnum<{
|
|
1721
|
+
STATE: "STATE";
|
|
1722
|
+
DISTRICT: "DISTRICT";
|
|
1723
|
+
BLOCK: "BLOCK";
|
|
1724
|
+
GRAM_PANCHAYAT: "GRAM_PANCHAYAT";
|
|
1725
|
+
VILLAGE: "VILLAGE";
|
|
1726
|
+
URBAN_BODY: "URBAN_BODY";
|
|
1727
|
+
URBAN_WARD: "URBAN_WARD";
|
|
1728
|
+
LOCALITY: "LOCALITY";
|
|
1729
|
+
}>>;
|
|
1730
|
+
officialAreaId: z.ZodNullable<z.ZodString>;
|
|
1618
1731
|
viewer: z.ZodOptional<z.ZodObject<{
|
|
1619
1732
|
role: z.ZodNullable<z.ZodEnum<{
|
|
1620
1733
|
owner: "owner";
|
|
1621
1734
|
admin: "admin";
|
|
1735
|
+
representative: "representative";
|
|
1736
|
+
moderator: "moderator";
|
|
1622
1737
|
member: "member";
|
|
1623
1738
|
}>>;
|
|
1624
1739
|
status: z.ZodNullable<z.ZodEnum<{
|
|
@@ -1673,6 +1788,8 @@ export declare const joinCommunityResponseSchema: z.ZodObject<{
|
|
|
1673
1788
|
role: z.ZodNullable<z.ZodEnum<{
|
|
1674
1789
|
owner: "owner";
|
|
1675
1790
|
admin: "admin";
|
|
1791
|
+
representative: "representative";
|
|
1792
|
+
moderator: "moderator";
|
|
1676
1793
|
member: "member";
|
|
1677
1794
|
}>>;
|
|
1678
1795
|
joinedAt: z.ZodNullable<z.ZodString>;
|
|
@@ -1687,6 +1804,8 @@ export declare const communityMembersListResponseSchema: z.ZodObject<{
|
|
|
1687
1804
|
role: z.ZodEnum<{
|
|
1688
1805
|
owner: "owner";
|
|
1689
1806
|
admin: "admin";
|
|
1807
|
+
representative: "representative";
|
|
1808
|
+
moderator: "moderator";
|
|
1690
1809
|
member: "member";
|
|
1691
1810
|
}>;
|
|
1692
1811
|
status: z.ZodEnum<{
|
|
@@ -1836,4 +1955,96 @@ export declare const areaPickerResponseSchema: z.ZodObject<{
|
|
|
1836
1955
|
}, z.core.$strip>>;
|
|
1837
1956
|
}, z.core.$strip>;
|
|
1838
1957
|
export type AreaPickerResponse = z.infer<typeof areaPickerResponseSchema>;
|
|
1958
|
+
/**
|
|
1959
|
+
* `POST /communities/official` body. Single-step flow.
|
|
1960
|
+
*
|
|
1961
|
+
* The area-leader binding gates the call: the caller's elevated
|
|
1962
|
+
* `serviceRoles['reform']` must include `leader` AND their
|
|
1963
|
+
* `jurisdictionLevel + jurisdictionAreaId` must exactly equal the
|
|
1964
|
+
* `areaKind + areaId` supplied here. Backend resolves the rest:
|
|
1965
|
+
*
|
|
1966
|
+
* • `name` and `slug` are derived server-side from the area name +
|
|
1967
|
+
* kind (e.g. "Pataudi Block Community" / `pataudi-block`). The
|
|
1968
|
+
* caller may override `description` and pick a cover image.
|
|
1969
|
+
* • `kind` is fixed to `'official'`; no need to send it.
|
|
1970
|
+
* • `reach`, `category`, `tags`, `mature`, `areaLineage`,
|
|
1971
|
+
* `centerCoords` are derived from the picked area.
|
|
1972
|
+
* • `verifiedAt`, `verifiedBy` are auto-set at create time (the
|
|
1973
|
+
* leader's act of creating it IS the verification).
|
|
1974
|
+
*
|
|
1975
|
+
* Re-creating after an area-level community has been soft-deleted by
|
|
1976
|
+
* superadmin is allowed because the partial unique index excludes
|
|
1977
|
+
* soft-deleted rows.
|
|
1978
|
+
*/
|
|
1979
|
+
export declare const createOfficialCommunityBodySchema: z.ZodObject<{
|
|
1980
|
+
areaKind: z.ZodEnum<{
|
|
1981
|
+
STATE: "STATE";
|
|
1982
|
+
DISTRICT: "DISTRICT";
|
|
1983
|
+
BLOCK: "BLOCK";
|
|
1984
|
+
GRAM_PANCHAYAT: "GRAM_PANCHAYAT";
|
|
1985
|
+
VILLAGE: "VILLAGE";
|
|
1986
|
+
URBAN_BODY: "URBAN_BODY";
|
|
1987
|
+
URBAN_WARD: "URBAN_WARD";
|
|
1988
|
+
LOCALITY: "LOCALITY";
|
|
1989
|
+
}>;
|
|
1990
|
+
areaId: z.ZodString;
|
|
1991
|
+
description: z.ZodOptional<z.ZodString>;
|
|
1992
|
+
coverImageUrl: z.ZodOptional<z.ZodString>;
|
|
1993
|
+
}, z.core.$strip>;
|
|
1994
|
+
export type CreateOfficialCommunityBody = z.infer<typeof createOfficialCommunityBodySchema>;
|
|
1995
|
+
/**
|
|
1996
|
+
* Body for `POST /communities/:slug/moderators` — assign a moderator.
|
|
1997
|
+
* The target user must already be an active member of the community.
|
|
1998
|
+
*
|
|
1999
|
+
* Caller authority:
|
|
2000
|
+
* - `kind: 'official'` admin (the current area leader, or the
|
|
2001
|
+
* platform superadmin when no leader is appointed) can add or
|
|
2002
|
+
* remove a moderator. The representative cannot (representative
|
|
2003
|
+
* can override moderator decisions but does not manage the
|
|
2004
|
+
* moderator roster).
|
|
2005
|
+
*
|
|
2006
|
+
* To remove a moderator use `DELETE /communities/:slug/moderators/:userId`.
|
|
2007
|
+
*/
|
|
2008
|
+
export declare const addOfficialModeratorBodySchema: z.ZodObject<{
|
|
2009
|
+
userId: z.ZodString;
|
|
2010
|
+
}, z.core.$strip>;
|
|
2011
|
+
export type AddOfficialModeratorBody = z.infer<typeof addOfficialModeratorBodySchema>;
|
|
2012
|
+
/**
|
|
2013
|
+
* Body for `PUT /communities/:slug/representative` — set or replace
|
|
2014
|
+
* the community's named elected representative (Pradhan / Mayor / ...).
|
|
2015
|
+
*
|
|
2016
|
+
* The representative slot is single-valued: writing a new user ID
|
|
2017
|
+
* replaces whoever held it before (matching the "new election → new
|
|
2018
|
+
* person" lifecycle). Use `DELETE /communities/:slug/representative`
|
|
2019
|
+
* to clear the slot between elections.
|
|
2020
|
+
*
|
|
2021
|
+
* The target user must already be an active member of the community;
|
|
2022
|
+
* the backend will auto-add them as a member if they're not.
|
|
2023
|
+
*
|
|
2024
|
+
* Caller authority: `kind: 'official'` admin only.
|
|
2025
|
+
*/
|
|
2026
|
+
export declare const setOfficialRepresentativeBodySchema: z.ZodObject<{
|
|
2027
|
+
userId: z.ZodString;
|
|
2028
|
+
}, z.core.$strip>;
|
|
2029
|
+
export type SetOfficialRepresentativeBody = z.infer<typeof setOfficialRepresentativeBodySchema>;
|
|
2030
|
+
/**
|
|
2031
|
+
* Body for `POST /communities/:slug/posts/:postId/hide`.
|
|
2032
|
+
*
|
|
2033
|
+
* Hides a post from the community feed for everyone except the author
|
|
2034
|
+
* (who still sees their own post, marked as "hidden by moderator").
|
|
2035
|
+
*
|
|
2036
|
+
* Caller authority on `kind: 'official'`:
|
|
2037
|
+
* - moderator — can hide a post that has at least one open report.
|
|
2038
|
+
* - representative — can hide or unhide ANY post (including overriding
|
|
2039
|
+
* a moderator's hide). The override is what makes
|
|
2040
|
+
* the representative's "settings" page useful.
|
|
2041
|
+
* - admin — same authority as representative.
|
|
2042
|
+
*
|
|
2043
|
+
* On `kind: 'user'` the existing soft-delete by owner / admin path
|
|
2044
|
+
* continues to apply; this endpoint is `official`-only.
|
|
2045
|
+
*/
|
|
2046
|
+
export declare const hidePostBodySchema: z.ZodObject<{
|
|
2047
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
2048
|
+
}, z.core.$strip>;
|
|
2049
|
+
export type HidePostBody = z.infer<typeof hidePostBodySchema>;
|
|
1839
2050
|
//# sourceMappingURL=community.d.ts.map
|
package/dist/community.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"community.d.ts","sourceRoot":"","sources":["../src/community.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAkBxB;;;;;;;GAOG;AACH,eAAO,MAAM,qBAAqB,8CAA+C,CAAC;AAClF,MAAM,MAAM,aAAa,GAAG,CAAC,OAAO,qBAAqB,CAAC,CAAC,MAAM,CAAC,CAAC;AACnE,eAAO,MAAM,mBAAmB;;;;EAAgC,CAAC;AAEjE;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,sBAAsB,kEAMzB,CAAC;AACX,MAAM,MAAM,cAAc,GAAG,CAAC,OAAO,sBAAsB,CAAC,CAAC,MAAM,CAAC,CAAC;AACrE,eAAO,MAAM,oBAAoB;;;;;;EAAiC,CAAC;AAEnE;;;;;;;GAOG;AACH,eAAO,MAAM,+BAA+B,0CAA2C,CAAC;AACxF,MAAM,MAAM,sBAAsB,GAAG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;;;;iBAKhC,CAAC;AACH,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAEpE,eAAO,MAAM,oBAAoB;;;;;;;;;iBAK/B,CAAC;AACH,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAElE,eAAO,MAAM,wBAAwB;;;;;;;;;;;iBAEnC,CAAC;AACH,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAI1E;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,iCAAiC;;;;;;;;;;;;;;iBAW5C,CAAC;AACH,MAAM,MAAM,2BAA2B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iCAAiC,CAAC,CAAC;AAE5F;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,8BAA8B;;iBAEzC,CAAC;AACH,MAAM,MAAM,wBAAwB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,8BAA8B,CAAC,CAAC;AAEtF;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,mCAAmC;;iBAE9C,CAAC;AACH,MAAM,MAAM,6BAA6B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mCAAmC,CAAC,CAAC;AAIhG;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,kBAAkB;;iBAI7B,CAAC;AACH,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC"}
|
package/dist/community.js
CHANGED
|
@@ -30,6 +30,58 @@ import { z } from 'zod';
|
|
|
30
30
|
import { areaLineageSnapshotSchema } from './area.js';
|
|
31
31
|
import { COMMUNITIES_PAGE_SIZE, COMMUNITY_DESCRIPTION_MAX_CHARS, COMMUNITY_DESIGNATION_CUSTOM_MAX_CHARS, COMMUNITY_DESIGNATION_CUSTOM_MIN_CHARS, COMMUNITY_DESIGNATION_CUSTOM_PATTERN, COMMUNITY_MAX_TAGS, COMMUNITY_NAME_MAX_CHARS, COMMUNITY_NAME_MIN_CHARS, COMMUNITY_SLUG_MAX_CHARS, COMMUNITY_SLUG_MIN_CHARS, COMMUNITY_SLUG_PATTERN, } from './constants.js';
|
|
32
32
|
// ─── Enums ──────────────────────────────────────────────────────────────────
|
|
33
|
+
/**
|
|
34
|
+
* Two fundamentally different community shapes share the same wire
|
|
35
|
+
* schema:
|
|
36
|
+
*
|
|
37
|
+
* user — topic-of-interest community a regular user creates and
|
|
38
|
+
* owns (Reddit subreddit / Facebook group analogue). Owner
|
|
39
|
+
* + admins manage; members join. The default kind.
|
|
40
|
+
* official — area-based civic community for a specific administrative
|
|
41
|
+
* area (village / block / district / urban body / ... up
|
|
42
|
+
* to state). Created by the elected area leader; has NO
|
|
43
|
+
* owner. Permission is computed at read time from the
|
|
44
|
+
* current area-leader binding:
|
|
45
|
+
* - admin role = whoever is the area's leader right now
|
|
46
|
+
* (falls back to platform superadmin when no leader is
|
|
47
|
+
* appointed)
|
|
48
|
+
* - representative role = the elected official the area
|
|
49
|
+
* leader names (Pradhan / Mayor / MLA / ...); replaced
|
|
50
|
+
* on each new political election
|
|
51
|
+
* - moderator role = community-scoped; can hide reported
|
|
52
|
+
* posts. Representative can override moderator
|
|
53
|
+
* decisions from settings.
|
|
54
|
+
* Always auto-verified (the leader's act of creating it IS
|
|
55
|
+
* the verification) and immune to delete from anyone
|
|
56
|
+
* except platform superadmin / manager.
|
|
57
|
+
*/
|
|
58
|
+
export const COMMUNITY_KIND_VALUES = ['user', 'official'];
|
|
59
|
+
export const communityKindSchema = z.enum(COMMUNITY_KIND_VALUES);
|
|
60
|
+
/**
|
|
61
|
+
* Administrative area levels that can host an official community.
|
|
62
|
+
*
|
|
63
|
+
* Mirrors a subset of the reform-backend `JURISDICTION_LEVEL` enum —
|
|
64
|
+
* NATIONAL and GLOBAL are intentionally excluded because they are
|
|
65
|
+
* virtual tiers (no `Area` row) and don't fit the "community for THIS
|
|
66
|
+
* area" model. If we ever want national / global civic communities
|
|
67
|
+
* they should be a separate concept.
|
|
68
|
+
*
|
|
69
|
+
* The leader-jurisdiction → area-kind binding is 1:1:
|
|
70
|
+
* leader.jurisdictionLevel === community.officialAreaKind AND
|
|
71
|
+
* leader.jurisdictionAreaId === community.officialAreaId
|
|
72
|
+
* is the gate for who can create / admin the community.
|
|
73
|
+
*/
|
|
74
|
+
export const OFFICIAL_COMMUNITY_AREA_KIND_VALUES = [
|
|
75
|
+
'STATE',
|
|
76
|
+
'DISTRICT',
|
|
77
|
+
'BLOCK',
|
|
78
|
+
'GRAM_PANCHAYAT',
|
|
79
|
+
'VILLAGE',
|
|
80
|
+
'URBAN_BODY',
|
|
81
|
+
'URBAN_WARD',
|
|
82
|
+
'LOCALITY',
|
|
83
|
+
];
|
|
84
|
+
export const officialCommunityAreaKindSchema = z.enum(OFFICIAL_COMMUNITY_AREA_KIND_VALUES);
|
|
33
85
|
/**
|
|
34
86
|
* public — anyone can read + post.
|
|
35
87
|
* restricted — anyone can read; only approved members can post. The
|
|
@@ -404,13 +456,37 @@ export const communityCenterCoordsSchema = z.object({
|
|
|
404
456
|
});
|
|
405
457
|
/** Role hierarchy within a single community.
|
|
406
458
|
*
|
|
407
|
-
*
|
|
408
|
-
*
|
|
409
|
-
*
|
|
410
|
-
*
|
|
411
|
-
*
|
|
459
|
+
* The role set is shared across `user` and `official` communities, but
|
|
460
|
+
* not every role is valid for every kind:
|
|
461
|
+
*
|
|
462
|
+
* owner — `kind: 'user'` only. The creator; can edit
|
|
463
|
+
* metadata, transfer ownership (deferred), and
|
|
464
|
+
* delete the community.
|
|
465
|
+
* admin — `kind: 'user'`: granted by the owner; can edit
|
|
466
|
+
* metadata, kick members, soft-delete posts.
|
|
467
|
+
* `kind: 'official'`: computed from the current
|
|
468
|
+
* area-leader binding (never stored on a membership
|
|
469
|
+
* row); platform superadmin fills the slot when no
|
|
470
|
+
* leader is appointed.
|
|
471
|
+
* representative — `kind: 'official'` only. The elected official the
|
|
472
|
+
* area leader names (Pradhan / Mayor / ...).
|
|
473
|
+
* Replaced on every new political election. Can
|
|
474
|
+
* override moderator decisions from the community
|
|
475
|
+
* settings page.
|
|
476
|
+
* moderator — `kind: 'official'` only. Community-scoped; can
|
|
477
|
+
* hide reported posts. Multiple moderators allowed
|
|
478
|
+
* per community. The current admin (area leader)
|
|
479
|
+
* grants and revokes.
|
|
480
|
+
* member — joined; can post and comment, can leave at any
|
|
481
|
+
* time. Valid for both kinds.
|
|
412
482
|
*/
|
|
413
|
-
export const COMMUNITY_ROLE_VALUES = [
|
|
483
|
+
export const COMMUNITY_ROLE_VALUES = [
|
|
484
|
+
'owner',
|
|
485
|
+
'admin',
|
|
486
|
+
'representative',
|
|
487
|
+
'moderator',
|
|
488
|
+
'member',
|
|
489
|
+
];
|
|
414
490
|
export const communityRoleSchema = z.enum(COMMUNITY_ROLE_VALUES);
|
|
415
491
|
/** Membership lifecycle.
|
|
416
492
|
*
|
|
@@ -437,7 +513,18 @@ export const communityWireSchema = z.object({
|
|
|
437
513
|
description: z.string().max(COMMUNITY_DESCRIPTION_MAX_CHARS).optional(),
|
|
438
514
|
type: communityTypeSchema,
|
|
439
515
|
coverImageUrl: z.string().url().optional(),
|
|
440
|
-
|
|
516
|
+
/** Discriminator. `user` = topical / interest community; `official`
|
|
517
|
+
* = area-based civic community owned by an area leader. Default at
|
|
518
|
+
* read time when omitted by a pre-v3 backend is `user`. */
|
|
519
|
+
kind: communityKindSchema,
|
|
520
|
+
/** User communities only — the creator. Null for `kind: 'official'`
|
|
521
|
+
* (those have no owner; admin is computed from the area-leader
|
|
522
|
+
* binding). */
|
|
523
|
+
ownerUserId: z.string().nullable(),
|
|
524
|
+
/** Audit-only userId of whoever created the community. Carries no
|
|
525
|
+
* permission on its own — present on both kinds so the wire shape
|
|
526
|
+
* stays uniform. For `kind: 'user'` this equals `ownerUserId`. */
|
|
527
|
+
createdBy: z.string().nullable(),
|
|
441
528
|
/** Active members only. Pending join-requests don't count. */
|
|
442
529
|
memberCount: z.number().int().nonnegative(),
|
|
443
530
|
/** Denormalised post count. Increments on create, decrements on
|
|
@@ -468,13 +555,28 @@ export const communityWireSchema = z.object({
|
|
|
468
555
|
* the `?nearMe=true` 5 km geospatial filter on discovery. */
|
|
469
556
|
centerCoords: communityCenterCoordsSchema.nullable(),
|
|
470
557
|
/** ISO timestamp set by a state+ leader when verifying the
|
|
471
|
-
* community. Null until verified; clearing reverts to null.
|
|
558
|
+
* community. Null until verified; clearing reverts to null. For
|
|
559
|
+
* `kind: 'official'` this is auto-set at create time (the leader's
|
|
560
|
+
* act of creating it IS the verification). */
|
|
472
561
|
verifiedAt: z.string().datetime().nullable(),
|
|
473
|
-
/** UserId of the leader who verified.
|
|
562
|
+
/** UserId of the leader who verified. For `kind: 'official'` this
|
|
563
|
+
* is the leader who created it (same as `createdBy`). */
|
|
474
564
|
verifiedBy: z.string().nullable(),
|
|
475
565
|
/** Which leader tier vouched — drives the badge tooltip ("verified
|
|
476
|
-
* by a state leader" vs "by a national leader").
|
|
566
|
+
* by a state leader" vs "by a national leader"). For
|
|
567
|
+
* `kind: 'official'` this is null because the "official" badge
|
|
568
|
+
* itself communicates authority. */
|
|
477
569
|
verifiedScope: communityVerifiedScopeSchema.nullable(),
|
|
570
|
+
// ─── Official community fields ──────────────────────────────────────
|
|
571
|
+
/** Administrative level of the area this official community is
|
|
572
|
+
* bound to. Null for `kind: 'user'`. */
|
|
573
|
+
officialAreaKind: officialCommunityAreaKindSchema.nullable(),
|
|
574
|
+
/** ObjectId of the specific Area entity this official community
|
|
575
|
+
* represents. Null for `kind: 'user'`. Combined with
|
|
576
|
+
* `officialAreaKind`, the pair `(officialAreaKind, officialAreaId)`
|
|
577
|
+
* is unique among non-deleted official communities — one official
|
|
578
|
+
* community per area, ever. */
|
|
579
|
+
officialAreaId: z.string().nullable(),
|
|
478
580
|
viewer: z
|
|
479
581
|
.object({
|
|
480
582
|
role: communityRoleSchema.nullable(),
|
|
@@ -703,4 +805,93 @@ export const areaPickerItemSchema = z.object({
|
|
|
703
805
|
export const areaPickerResponseSchema = z.object({
|
|
704
806
|
items: z.array(areaPickerItemSchema),
|
|
705
807
|
});
|
|
808
|
+
// ─── Official community — create + manage ──────────────────────────────────
|
|
809
|
+
/**
|
|
810
|
+
* `POST /communities/official` body. Single-step flow.
|
|
811
|
+
*
|
|
812
|
+
* The area-leader binding gates the call: the caller's elevated
|
|
813
|
+
* `serviceRoles['reform']` must include `leader` AND their
|
|
814
|
+
* `jurisdictionLevel + jurisdictionAreaId` must exactly equal the
|
|
815
|
+
* `areaKind + areaId` supplied here. Backend resolves the rest:
|
|
816
|
+
*
|
|
817
|
+
* • `name` and `slug` are derived server-side from the area name +
|
|
818
|
+
* kind (e.g. "Pataudi Block Community" / `pataudi-block`). The
|
|
819
|
+
* caller may override `description` and pick a cover image.
|
|
820
|
+
* • `kind` is fixed to `'official'`; no need to send it.
|
|
821
|
+
* • `reach`, `category`, `tags`, `mature`, `areaLineage`,
|
|
822
|
+
* `centerCoords` are derived from the picked area.
|
|
823
|
+
* • `verifiedAt`, `verifiedBy` are auto-set at create time (the
|
|
824
|
+
* leader's act of creating it IS the verification).
|
|
825
|
+
*
|
|
826
|
+
* Re-creating after an area-level community has been soft-deleted by
|
|
827
|
+
* superadmin is allowed because the partial unique index excludes
|
|
828
|
+
* soft-deleted rows.
|
|
829
|
+
*/
|
|
830
|
+
export const createOfficialCommunityBodySchema = z.object({
|
|
831
|
+
/** Administrative level of the picked area. Must equal the caller's
|
|
832
|
+
* jurisdictionLevel. */
|
|
833
|
+
areaKind: officialCommunityAreaKindSchema,
|
|
834
|
+
/** ObjectId of the picked Area entity. Must equal the caller's
|
|
835
|
+
* jurisdictionAreaId. */
|
|
836
|
+
areaId: z.string(),
|
|
837
|
+
/** Optional one-line description shown on the community card. */
|
|
838
|
+
description: z.string().max(COMMUNITY_DESCRIPTION_MAX_CHARS).optional(),
|
|
839
|
+
/** Optional cover image. */
|
|
840
|
+
coverImageUrl: z.string().url().optional(),
|
|
841
|
+
});
|
|
842
|
+
/**
|
|
843
|
+
* Body for `POST /communities/:slug/moderators` — assign a moderator.
|
|
844
|
+
* The target user must already be an active member of the community.
|
|
845
|
+
*
|
|
846
|
+
* Caller authority:
|
|
847
|
+
* - `kind: 'official'` admin (the current area leader, or the
|
|
848
|
+
* platform superadmin when no leader is appointed) can add or
|
|
849
|
+
* remove a moderator. The representative cannot (representative
|
|
850
|
+
* can override moderator decisions but does not manage the
|
|
851
|
+
* moderator roster).
|
|
852
|
+
*
|
|
853
|
+
* To remove a moderator use `DELETE /communities/:slug/moderators/:userId`.
|
|
854
|
+
*/
|
|
855
|
+
export const addOfficialModeratorBodySchema = z.object({
|
|
856
|
+
userId: z.string(),
|
|
857
|
+
});
|
|
858
|
+
/**
|
|
859
|
+
* Body for `PUT /communities/:slug/representative` — set or replace
|
|
860
|
+
* the community's named elected representative (Pradhan / Mayor / ...).
|
|
861
|
+
*
|
|
862
|
+
* The representative slot is single-valued: writing a new user ID
|
|
863
|
+
* replaces whoever held it before (matching the "new election → new
|
|
864
|
+
* person" lifecycle). Use `DELETE /communities/:slug/representative`
|
|
865
|
+
* to clear the slot between elections.
|
|
866
|
+
*
|
|
867
|
+
* The target user must already be an active member of the community;
|
|
868
|
+
* the backend will auto-add them as a member if they're not.
|
|
869
|
+
*
|
|
870
|
+
* Caller authority: `kind: 'official'` admin only.
|
|
871
|
+
*/
|
|
872
|
+
export const setOfficialRepresentativeBodySchema = z.object({
|
|
873
|
+
userId: z.string(),
|
|
874
|
+
});
|
|
875
|
+
// ─── Post moderation (hide / unhide for moderator + representative) ────────
|
|
876
|
+
/**
|
|
877
|
+
* Body for `POST /communities/:slug/posts/:postId/hide`.
|
|
878
|
+
*
|
|
879
|
+
* Hides a post from the community feed for everyone except the author
|
|
880
|
+
* (who still sees their own post, marked as "hidden by moderator").
|
|
881
|
+
*
|
|
882
|
+
* Caller authority on `kind: 'official'`:
|
|
883
|
+
* - moderator — can hide a post that has at least one open report.
|
|
884
|
+
* - representative — can hide or unhide ANY post (including overriding
|
|
885
|
+
* a moderator's hide). The override is what makes
|
|
886
|
+
* the representative's "settings" page useful.
|
|
887
|
+
* - admin — same authority as representative.
|
|
888
|
+
*
|
|
889
|
+
* On `kind: 'user'` the existing soft-delete by owner / admin path
|
|
890
|
+
* continues to apply; this endpoint is `official`-only.
|
|
891
|
+
*/
|
|
892
|
+
export const hidePostBodySchema = z.object({
|
|
893
|
+
/** Optional moderator note (visible only to other moderators + the
|
|
894
|
+
* representative + admin on the moderation log). Capped at 500. */
|
|
895
|
+
reason: z.string().max(500).optional(),
|
|
896
|
+
});
|
|
706
897
|
//# sourceMappingURL=community.js.map
|