jansathi-community-schema 0.7.0 → 0.8.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 +5 -4
- package/dist/community.d.ts.map +1 -1
- package/dist/community.js +5 -4
- package/dist/community.js.map +1 -1
- package/dist/enums.d.ts +27 -26
- package/dist/enums.d.ts.map +1 -1
- package/dist/enums.js +28 -27
- package/dist/enums.js.map +1 -1
- package/dist/feed.d.ts +0 -14
- package/dist/feed.d.ts.map +1 -1
- package/dist/post.d.ts +2 -16
- package/dist/post.d.ts.map +1 -1
- package/dist/post.js +9 -13
- package/dist/post.js.map +1 -1
- package/dist/repost.d.ts +1 -17
- package/dist/repost.d.ts.map +1 -1
- package/dist/repost.js +2 -6
- package/dist/repost.js.map +1 -1
- package/dist/settings.d.ts +0 -14
- package/dist/settings.d.ts.map +1 -1
- package/dist/settings.js +1 -5
- package/dist/settings.js.map +1 -1
- package/package.json +1 -1
package/dist/community.d.ts
CHANGED
|
@@ -18,10 +18,11 @@
|
|
|
18
18
|
* member count + join button) so users can request to
|
|
19
19
|
* join.
|
|
20
20
|
*
|
|
21
|
-
* Posts inside a community do NOT participate in the geo cascade
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
21
|
+
* Posts inside a community do NOT participate in the geo cascade —
|
|
22
|
+
* they live and die inside the community surface. Posts authored
|
|
23
|
+
* from the global composer continue to flow through the geo
|
|
24
|
+
* area-proximity cascade ranked by `tierBoost` (see
|
|
25
|
+
* `reform-backend/src/services/community/services/visibility.service.ts`).
|
|
25
26
|
*
|
|
26
27
|
* @module community-schema/community
|
|
27
28
|
*/
|
package/dist/community.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"community.d.ts","sourceRoot":"","sources":["../src/community.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"community.d.ts","sourceRoot":"","sources":["../src/community.ts"],"names":[],"mapp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,CAAC;AAI5E;;iEAEiE;AACjE,eAAO,MAAM,8BAA8B,oCAAqC,CAAC;AACjF,MAAM,MAAM,qBAAqB,GAAG,CAAC,OAAO,8BAA8B,CAAC,CAAC,MAAM,CAAC,CAAC;AACpF,eAAO,MAAM,2BAA2B;;;;EAAyC,CAAC;AAElF,eAAO,MAAM,wBAAwB;;;;;;;;;iBAOnC,CAAC;AACH,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAE1E,eAAO,MAAM,2BAA2B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAGtC,CAAC;AACH,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,2BAA2B,CAAC,CAAC;AAIhF;;;;;;;;GAQG;AACH,eAAO,MAAM,2BAA2B;;;;;;;;;;;iBAItC,CAAC;AACH,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,2BAA2B,CAAC,CAAC;AAEhF,eAAO,MAAM,kCAAkC;;;;;;;;;;;;;;;;;;iBAG7C,CAAC;AACH,MAAM,MAAM,4BAA4B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kCAAkC,CAAC,CAAC;AAE9F;;;qEAGqE;AACrE,eAAO,MAAM,0BAA0B;;;;;iBAErC,CAAC;AACH,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAC"}
|
package/dist/community.js
CHANGED
|
@@ -18,10 +18,11 @@
|
|
|
18
18
|
* member count + join button) so users can request to
|
|
19
19
|
* join.
|
|
20
20
|
*
|
|
21
|
-
* Posts inside a community do NOT participate in the geo cascade
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
21
|
+
* Posts inside a community do NOT participate in the geo cascade —
|
|
22
|
+
* they live and die inside the community surface. Posts authored
|
|
23
|
+
* from the global composer continue to flow through the geo
|
|
24
|
+
* area-proximity cascade ranked by `tierBoost` (see
|
|
25
|
+
* `reform-backend/src/services/community/services/visibility.service.ts`).
|
|
25
26
|
*
|
|
26
27
|
* @module community-schema/community
|
|
27
28
|
*/
|
package/dist/community.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"community.js","sourceRoot":"","sources":["../src/community.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EACL,qBAAqB,EACrB,+BAA+B,EAC/B,wBAAwB,EACxB,wBAAwB,EACxB,wBAAwB,EACxB,wBAAwB,EACxB,sBAAsB,GACvB,MAAM,gBAAgB,CAAC;AAExB,+EAA+E;AAE/E,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,QAAQ,EAAE,SAAS,CAAU,CAAC;AAEpE,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;AAEjE;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,CAAU,CAAC;AAE3E,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;AAEjE;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,kCAAkC,GAAG,CAAC,QAAQ,EAAE,SAAS,CAAU,CAAC;AAEjF,MAAM,CAAC,MAAM,+BAA+B,GAAG,CAAC,CAAC,IAAI,CAAC,kCAAkC,CAAC,CAAC;AAE1F,+EAA+E;AAE/E;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC1C,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE;IACf,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;IAChB,IAAI,EAAE,CAAC,CAAC,MAAM,EAA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,0BAA0B,GAAG,CAAC,CAAC,MAAM,CAAC;IACjD,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;CAClC,CAAC,CAAC","sourcesContent":["/**\n * Topical Community wire shapes.\n *\n * A Community is a Reddit-subreddit / Facebook-group style surface: a\n * named topic users can discover, join, and post into. Distinct from\n * the user-created `Group` (chat-bound, small, private) — each\n * Community auto-owns its own bound `Group` (so members get a\n * Community chat room for free) but they're conceptually different\n * objects with their own roster + permissions.\n *\n * Visibility model\n * ----------------\n * - `public` — anyone can join one-tap; posts are visible to all\n * viewers in the community feed.\n * - `private` — joining requires owner / admin approval; posts and\n * member list are hidden from non-members. Discovery\n * still lists the community card (name + description +\n * member count + join button) so users can request to\n * join.\n *\n * Posts inside a community do NOT participate in the geo cascade or\n * the tier-promotion job — they live and die inside the community\n * surface. Posts authored from the global composer continue to use\n * geo + promotion as before.\n *\n * @module community-schema/community\n */\n\nimport { z } from 'zod';\nimport {\n COMMUNITIES_PAGE_SIZE,\n COMMUNITY_DESCRIPTION_MAX_CHARS,\n COMMUNITY_NAME_MAX_CHARS,\n COMMUNITY_NAME_MIN_CHARS,\n COMMUNITY_SLUG_MAX_CHARS,\n COMMUNITY_SLUG_MIN_CHARS,\n COMMUNITY_SLUG_PATTERN,\n} from './constants.js';\n\n// ─── Enums ──────────────────────────────────────────────────────────────────\n\nexport const COMMUNITY_TYPE_VALUES = ['public', 'private'] as const;\nexport type CommunityType = (typeof COMMUNITY_TYPE_VALUES)[number];\nexport const communityTypeSchema = z.enum(COMMUNITY_TYPE_VALUES);\n\n/** Role hierarchy within a single community.\n *\n * owner — creator; cannot be demoted by anyone, can transfer\n * ownership (deferred for v1) and delete the community.\n * admin — granted by owner; can edit metadata, kick members,\n * soft-delete posts authored in the community.\n * member — joined; can post and comment, can leave at any time.\n */\nexport const COMMUNITY_ROLE_VALUES = ['owner', 'admin', 'member'] as const;\nexport type CommunityRole = (typeof COMMUNITY_ROLE_VALUES)[number];\nexport const communityRoleSchema = z.enum(COMMUNITY_ROLE_VALUES);\n\n/** Membership lifecycle.\n *\n * active — currently in the community.\n * pending — for a `private` community: the join request is awaiting\n * owner/admin approval. Pending rows aren't counted toward\n * `memberCount` and the user can't post yet.\n */\nexport const COMMUNITY_MEMBERSHIP_STATUS_VALUES = ['active', 'pending'] as const;\nexport type CommunityMembershipStatus = (typeof COMMUNITY_MEMBERSHIP_STATUS_VALUES)[number];\nexport const communityMembershipStatusSchema = z.enum(COMMUNITY_MEMBERSHIP_STATUS_VALUES);\n\n// ─── Wire shape ─────────────────────────────────────────────────────────────\n\n/**\n * `GET /communities/:slug` / discovery card / search hit.\n *\n * `viewer` is included when the request is authenticated. It carries\n * the viewer's role + membership status so the UI can render the\n * right CTA (Join / Joined / Pending / Owner) without a follow-up\n * round trip.\n */\nexport const communityWireSchema = z.object({\n _id: z.string(),\n slug: z.string(),\n name: z.string().min(COMMUNITY_NAME_MIN_CHARS).max(COMMUNITY_NAME_MAX_CHARS),\n description: z.string().max(COMMUNITY_DESCRIPTION_MAX_CHARS).optional(),\n type: communityTypeSchema,\n coverImageUrl: z.string().url().optional(),\n ownerUserId: z.string(),\n /** Active members only. Pending join-requests don't count. */\n memberCount: z.number().int().nonnegative(),\n /** Denormalised post count. Increments on create, decrements on\n * soft-delete. */\n postCount: z.number().int().nonnegative(),\n /** Bound chat-group id. Auto-created when the Community is created;\n * members are added to both rosters in lockstep. */\n groupId: z.string(),\n createdAt: z.string().datetime(),\n\n viewer: z\n .object({\n role: communityRoleSchema.nullable(),\n status: communityMembershipStatusSchema.nullable(),\n joinedAt: z.string().datetime().nullable(),\n })\n .optional(),\n});\nexport type CommunityWire = z.infer<typeof communityWireSchema>;\n\n// ─── Member roster row ──────────────────────────────────────────────────────\n\nexport const communityMemberWireSchema = z.object({\n userId: z.string(),\n displayName: z.string(),\n avatarUrl: z.string().url().optional(),\n localName: z.string().optional(),\n role: communityRoleSchema,\n status: communityMembershipStatusSchema,\n joinedAt: z.string().datetime(),\n});\nexport type CommunityMemberWire = z.infer<typeof communityMemberWireSchema>;\n\n// ─── Create body ────────────────────────────────────────────────────────────\n\n/**\n * `POST /communities` body. `slug` is optional — when omitted the\n * backend auto-generates one from the name (lowercased, hyphenated,\n * collision-suffixed). When provided it must match the slug pattern\n * and be unique.\n */\nexport const createCommunityBodySchema = z.object({\n name: z.string().min(COMMUNITY_NAME_MIN_CHARS).max(COMMUNITY_NAME_MAX_CHARS),\n slug: z\n .string()\n .min(COMMUNITY_SLUG_MIN_CHARS)\n .max(COMMUNITY_SLUG_MAX_CHARS)\n .regex(COMMUNITY_SLUG_PATTERN)\n .optional(),\n description: z.string().max(COMMUNITY_DESCRIPTION_MAX_CHARS).optional(),\n type: communityTypeSchema,\n coverImageUrl: z.string().url().optional(),\n});\nexport type CreateCommunityBody = z.infer<typeof createCommunityBodySchema>;\n\n// ─── Update body (owner / admin only) ───────────────────────────────────────\n\n/**\n * `PATCH /communities/:slug` body. All fields optional. Sending\n * `null` for `description` or `coverImageUrl` clears that field.\n * Type changes (`public ↔ private`) are NOT supported in v1 — the\n * decision has implications for already-published posts and pending\n * join requests that we don't want to silently handle. Recreate the\n * community if you need to switch type.\n */\nexport const updateCommunityBodySchema = z.object({\n name: z.string().min(COMMUNITY_NAME_MIN_CHARS).max(COMMUNITY_NAME_MAX_CHARS).optional(),\n description: z.string().max(COMMUNITY_DESCRIPTION_MAX_CHARS).nullable().optional(),\n coverImageUrl: z.string().url().nullable().optional(),\n});\nexport type UpdateCommunityBody = z.infer<typeof updateCommunityBodySchema>;\n\n// ─── List + discover + search responses ─────────────────────────────────────\n\n/** Sort order on the discover page. `popular` ranks by active member\n * count, `new` by createdAt desc. `top` is reserved for a future\n * activity-weighted ranking and accepted as a no-op for now. */\nexport const COMMUNITY_DISCOVER_SORT_VALUES = ['popular', 'new', 'top'] as const;\nexport type CommunityDiscoverSort = (typeof COMMUNITY_DISCOVER_SORT_VALUES)[number];\nexport const communityDiscoverSortSchema = z.enum(COMMUNITY_DISCOVER_SORT_VALUES);\n\nexport const communityListQuerySchema = z.object({\n sort: communityDiscoverSortSchema.optional(),\n /** Free-text fragment matched case-insensitively against the\n * community name. */\n q: z.string().max(60).optional(),\n cursor: z.string().optional(),\n pageSize: z.number().int().min(1).max(COMMUNITIES_PAGE_SIZE).optional(),\n});\nexport type CommunityListQuery = z.infer<typeof communityListQuerySchema>;\n\nexport const communityListResponseSchema = z.object({\n items: z.array(communityWireSchema),\n nextCursor: z.string().nullable(),\n});\nexport type CommunityListResponse = z.infer<typeof communityListResponseSchema>;\n\n// ─── Membership actions ────────────────────────────────────────────────────\n\n/**\n * `POST /communities/:slug/join`. Response carries the new viewer\n * state so the client can update the CTA without a follow-up GET.\n *\n * - public → returns `{ status: 'active', role: 'member' }`\n * - private → returns `{ status: 'pending', role: null }`; the\n * owner / admin approves via the moderation endpoint\n * (`POST /communities/:slug/members/:userId/approve`).\n */\nexport const joinCommunityResponseSchema = z.object({\n status: communityMembershipStatusSchema,\n role: communityRoleSchema.nullable(),\n joinedAt: z.string().datetime().nullable(),\n});\nexport type JoinCommunityResponse = z.infer<typeof joinCommunityResponseSchema>;\n\nexport const communityMembersListResponseSchema = z.object({\n items: z.array(communityMemberWireSchema),\n nextCursor: z.string().nullable(),\n});\nexport type CommunityMembersListResponse = z.infer<typeof communityMembersListResponseSchema>;\n\n/** Body for `POST /communities/:slug/members/:userId/role` — owner-\n * only. Used to promote a member to admin or demote an admin back\n * to plain member. Owner role can't be set via this endpoint;\n * transferring ownership has its own dedicated route (deferred). */\nexport const updateMemberRoleBodySchema = z.object({\n role: z.enum(['admin', 'member']),\n});\nexport type UpdateMemberRoleBody = z.infer<typeof updateMemberRoleBodySchema>;\n"]}
|
|
1
|
+
{"version":3,"file":"community.js","sourceRoot":"","sources":["../src/community.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,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AAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC7B,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,qBAAqB,CAAC,CAAC,QAAQ,EAAE;CACxE,CAAC,CAAC;AAGH,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAAC,CAAC,MAAM,CAAC;IAClD,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,mBAAmB,CAAC;IACnC,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CAClC,CAAC,CAAC;AAGH,8EAA8E;AAE9E;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAAC,CAAC,MAAM,CAAC;IAClD,MAAM,EAAE,+BAA+B;IACvC,IAAI,EAAE,mBAAmB,CAAC,QAAQ,EAAE;IACpC,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE;CAC3C,CAAC,CAAC;AAGH,MAAM,CAAC,MAAM,kCAAkC,GAAG,CAAC,CAAC,MAAM,CAAC;IACzD,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,yBAAyB,CAAC;IACzC,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CAClC,CAAC,CAAC;AAGH;;;qEAGqE;AACrE,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAAC,CAAC,MAAM,CAAC;IACjD,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;CAClC,CAAC,CAAC","sourcesContent":["/**\n * Topical Community wire shapes.\n *\n * A Community is a Reddit-subreddit / Facebook-group style surface: a\n * named topic users can discover, join, and post into. Distinct from\n * the user-created `Group` (chat-bound, small, private) — each\n * Community auto-owns its own bound `Group` (so members get a\n * Community chat room for free) but they're conceptually different\n * objects with their own roster + permissions.\n *\n * Visibility model\n * ----------------\n * - `public` — anyone can join one-tap; posts are visible to all\n * viewers in the community feed.\n * - `private` — joining requires owner / admin approval; posts and\n * member list are hidden from non-members. Discovery\n * still lists the community card (name + description +\n * member count + join button) so users can request to\n * join.\n *\n * Posts inside a community do NOT participate in the geo cascade —\n * they live and die inside the community surface. Posts authored\n * from the global composer continue to flow through the geo\n * area-proximity cascade ranked by `tierBoost` (see\n * `reform-backend/src/services/community/services/visibility.service.ts`).\n *\n * @module community-schema/community\n */\n\nimport { z } from 'zod';\nimport {\n COMMUNITIES_PAGE_SIZE,\n COMMUNITY_DESCRIPTION_MAX_CHARS,\n COMMUNITY_NAME_MAX_CHARS,\n COMMUNITY_NAME_MIN_CHARS,\n COMMUNITY_SLUG_MAX_CHARS,\n COMMUNITY_SLUG_MIN_CHARS,\n COMMUNITY_SLUG_PATTERN,\n} from './constants.js';\n\n// ─── Enums ──────────────────────────────────────────────────────────────────\n\nexport const COMMUNITY_TYPE_VALUES = ['public', 'private'] as const;\nexport type CommunityType = (typeof COMMUNITY_TYPE_VALUES)[number];\nexport const communityTypeSchema = z.enum(COMMUNITY_TYPE_VALUES);\n\n/** Role hierarchy within a single community.\n *\n * owner — creator; cannot be demoted by anyone, can transfer\n * ownership (deferred for v1) and delete the community.\n * admin — granted by owner; can edit metadata, kick members,\n * soft-delete posts authored in the community.\n * member — joined; can post and comment, can leave at any time.\n */\nexport const COMMUNITY_ROLE_VALUES = ['owner', 'admin', 'member'] as const;\nexport type CommunityRole = (typeof COMMUNITY_ROLE_VALUES)[number];\nexport const communityRoleSchema = z.enum(COMMUNITY_ROLE_VALUES);\n\n/** Membership lifecycle.\n *\n * active — currently in the community.\n * pending — for a `private` community: the join request is awaiting\n * owner/admin approval. Pending rows aren't counted toward\n * `memberCount` and the user can't post yet.\n */\nexport const COMMUNITY_MEMBERSHIP_STATUS_VALUES = ['active', 'pending'] as const;\nexport type CommunityMembershipStatus = (typeof COMMUNITY_MEMBERSHIP_STATUS_VALUES)[number];\nexport const communityMembershipStatusSchema = z.enum(COMMUNITY_MEMBERSHIP_STATUS_VALUES);\n\n// ─── Wire shape ─────────────────────────────────────────────────────────────\n\n/**\n * `GET /communities/:slug` / discovery card / search hit.\n *\n * `viewer` is included when the request is authenticated. It carries\n * the viewer's role + membership status so the UI can render the\n * right CTA (Join / Joined / Pending / Owner) without a follow-up\n * round trip.\n */\nexport const communityWireSchema = z.object({\n _id: z.string(),\n slug: z.string(),\n name: z.string().min(COMMUNITY_NAME_MIN_CHARS).max(COMMUNITY_NAME_MAX_CHARS),\n description: z.string().max(COMMUNITY_DESCRIPTION_MAX_CHARS).optional(),\n type: communityTypeSchema,\n coverImageUrl: z.string().url().optional(),\n ownerUserId: z.string(),\n /** Active members only. Pending join-requests don't count. */\n memberCount: z.number().int().nonnegative(),\n /** Denormalised post count. Increments on create, decrements on\n * soft-delete. */\n postCount: z.number().int().nonnegative(),\n /** Bound chat-group id. Auto-created when the Community is created;\n * members are added to both rosters in lockstep. */\n groupId: z.string(),\n createdAt: z.string().datetime(),\n\n viewer: z\n .object({\n role: communityRoleSchema.nullable(),\n status: communityMembershipStatusSchema.nullable(),\n joinedAt: z.string().datetime().nullable(),\n })\n .optional(),\n});\nexport type CommunityWire = z.infer<typeof communityWireSchema>;\n\n// ─── Member roster row ──────────────────────────────────────────────────────\n\nexport const communityMemberWireSchema = z.object({\n userId: z.string(),\n displayName: z.string(),\n avatarUrl: z.string().url().optional(),\n localName: z.string().optional(),\n role: communityRoleSchema,\n status: communityMembershipStatusSchema,\n joinedAt: z.string().datetime(),\n});\nexport type CommunityMemberWire = z.infer<typeof communityMemberWireSchema>;\n\n// ─── Create body ────────────────────────────────────────────────────────────\n\n/**\n * `POST /communities` body. `slug` is optional — when omitted the\n * backend auto-generates one from the name (lowercased, hyphenated,\n * collision-suffixed). When provided it must match the slug pattern\n * and be unique.\n */\nexport const createCommunityBodySchema = z.object({\n name: z.string().min(COMMUNITY_NAME_MIN_CHARS).max(COMMUNITY_NAME_MAX_CHARS),\n slug: z\n .string()\n .min(COMMUNITY_SLUG_MIN_CHARS)\n .max(COMMUNITY_SLUG_MAX_CHARS)\n .regex(COMMUNITY_SLUG_PATTERN)\n .optional(),\n description: z.string().max(COMMUNITY_DESCRIPTION_MAX_CHARS).optional(),\n type: communityTypeSchema,\n coverImageUrl: z.string().url().optional(),\n});\nexport type CreateCommunityBody = z.infer<typeof createCommunityBodySchema>;\n\n// ─── Update body (owner / admin only) ───────────────────────────────────────\n\n/**\n * `PATCH /communities/:slug` body. All fields optional. Sending\n * `null` for `description` or `coverImageUrl` clears that field.\n * Type changes (`public ↔ private`) are NOT supported in v1 — the\n * decision has implications for already-published posts and pending\n * join requests that we don't want to silently handle. Recreate the\n * community if you need to switch type.\n */\nexport const updateCommunityBodySchema = z.object({\n name: z.string().min(COMMUNITY_NAME_MIN_CHARS).max(COMMUNITY_NAME_MAX_CHARS).optional(),\n description: z.string().max(COMMUNITY_DESCRIPTION_MAX_CHARS).nullable().optional(),\n coverImageUrl: z.string().url().nullable().optional(),\n});\nexport type UpdateCommunityBody = z.infer<typeof updateCommunityBodySchema>;\n\n// ─── List + discover + search responses ─────────────────────────────────────\n\n/** Sort order on the discover page. `popular` ranks by active member\n * count, `new` by createdAt desc. `top` is reserved for a future\n * activity-weighted ranking and accepted as a no-op for now. */\nexport const COMMUNITY_DISCOVER_SORT_VALUES = ['popular', 'new', 'top'] as const;\nexport type CommunityDiscoverSort = (typeof COMMUNITY_DISCOVER_SORT_VALUES)[number];\nexport const communityDiscoverSortSchema = z.enum(COMMUNITY_DISCOVER_SORT_VALUES);\n\nexport const communityListQuerySchema = z.object({\n sort: communityDiscoverSortSchema.optional(),\n /** Free-text fragment matched case-insensitively against the\n * community name. */\n q: z.string().max(60).optional(),\n cursor: z.string().optional(),\n pageSize: z.number().int().min(1).max(COMMUNITIES_PAGE_SIZE).optional(),\n});\nexport type CommunityListQuery = z.infer<typeof communityListQuerySchema>;\n\nexport const communityListResponseSchema = z.object({\n items: z.array(communityWireSchema),\n nextCursor: z.string().nullable(),\n});\nexport type CommunityListResponse = z.infer<typeof communityListResponseSchema>;\n\n// ─── Membership actions ────────────────────────────────────────────────────\n\n/**\n * `POST /communities/:slug/join`. Response carries the new viewer\n * state so the client can update the CTA without a follow-up GET.\n *\n * - public → returns `{ status: 'active', role: 'member' }`\n * - private → returns `{ status: 'pending', role: null }`; the\n * owner / admin approves via the moderation endpoint\n * (`POST /communities/:slug/members/:userId/approve`).\n */\nexport const joinCommunityResponseSchema = z.object({\n status: communityMembershipStatusSchema,\n role: communityRoleSchema.nullable(),\n joinedAt: z.string().datetime().nullable(),\n});\nexport type JoinCommunityResponse = z.infer<typeof joinCommunityResponseSchema>;\n\nexport const communityMembersListResponseSchema = z.object({\n items: z.array(communityMemberWireSchema),\n nextCursor: z.string().nullable(),\n});\nexport type CommunityMembersListResponse = z.infer<typeof communityMembersListResponseSchema>;\n\n/** Body for `POST /communities/:slug/members/:userId/role` — owner-\n * only. Used to promote a member to admin or demote an admin back\n * to plain member. Owner role can't be set via this endpoint;\n * transferring ownership has its own dedicated route (deferred). */\nexport const updateMemberRoleBodySchema = z.object({\n role: z.enum(['admin', 'member']),\n});\nexport type UpdateMemberRoleBody = z.infer<typeof updateMemberRoleBodySchema>;\n"]}
|
package/dist/enums.d.ts
CHANGED
|
@@ -9,19 +9,28 @@
|
|
|
9
9
|
*/
|
|
10
10
|
import { z } from 'zod';
|
|
11
11
|
/**
|
|
12
|
-
*
|
|
12
|
+
* Geographic scope the VIEWER chose for their feed — the area-proximity
|
|
13
|
+
* cascade is gated by this value.
|
|
13
14
|
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
* - `national` → matches national + global within the viewer's country
|
|
21
|
-
* - `global` → matches global only
|
|
15
|
+
* Posts do NOT carry a per-post `visibilityLevel` any more. Every post
|
|
16
|
+
* is implicitly global; visibility is purely a function of (a) the
|
|
17
|
+
* author's `areaLineage` at write time and (b) the viewer's scope
|
|
18
|
+
* choice here. The cascade walks from the viewer's locality outward
|
|
19
|
+
* and includes any post whose author was inside the viewer's area at
|
|
20
|
+
* ANY level the viewer's scope reaches.
|
|
22
21
|
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
22
|
+
* - `local` → locality + district + state + national matches
|
|
23
|
+
* - `district` → district + state + national matches (no locality boost)
|
|
24
|
+
* - `state` → state + national matches
|
|
25
|
+
* - `national` → national matches
|
|
26
|
+
* - `global` → all matches (de-facto same as `national` for an
|
|
27
|
+
* India-only product, but kept for forward compat)
|
|
28
|
+
*
|
|
29
|
+
* Read-side ranking — see `feed.service.ts#tierBoost` — multiplies the
|
|
30
|
+
* row's hotScore by an area-proximity factor: locality match 2.0,
|
|
31
|
+
* district 1.2, state 0.9, national 0.7, distant 0.5. So local
|
|
32
|
+
* content dominates at equal quality, while genuinely viral national
|
|
33
|
+
* content still surfaces.
|
|
25
34
|
*/
|
|
26
35
|
export declare const VISIBILITY_LEVEL_VALUES: readonly ["local", "district", "state", "national", "global"];
|
|
27
36
|
export declare const visibilityLevelSchema: z.ZodEnum<{
|
|
@@ -33,9 +42,9 @@ export declare const visibilityLevelSchema: z.ZodEnum<{
|
|
|
33
42
|
}>;
|
|
34
43
|
export type VisibilityLevel = z.infer<typeof visibilityLevelSchema>;
|
|
35
44
|
/**
|
|
36
|
-
* Numeric ranking used for the
|
|
37
|
-
*
|
|
38
|
-
*
|
|
45
|
+
* Numeric ranking used for the area-proximity cascade. `local` is the
|
|
46
|
+
* deepest (most specific) feed scope, `global` the broadest. Higher
|
|
47
|
+
* rank = broader scope.
|
|
39
48
|
*/
|
|
40
49
|
export declare const VISIBILITY_LEVEL_RANK: Record<VisibilityLevel, number>;
|
|
41
50
|
/**
|
|
@@ -92,11 +101,8 @@ export type ConnectionStatus = z.infer<typeof connectionStatusSchema>;
|
|
|
92
101
|
/**
|
|
93
102
|
* Profile-level privacy (single toggle in Settings).
|
|
94
103
|
*
|
|
95
|
-
* `public` — anyone
|
|
96
|
-
* `private` — only accepted Connections see this user's posts.
|
|
97
|
-
* level on each post still applies on top (a private post at
|
|
98
|
-
* state level is visible only to Connections who are in the
|
|
99
|
-
* same state).
|
|
104
|
+
* `public` — anyone the area-proximity cascade reaches sees this user's posts.
|
|
105
|
+
* `private` — only accepted Connections see this user's posts.
|
|
100
106
|
*/
|
|
101
107
|
export declare const PROFILE_PRIVACY_VALUES: readonly ["public", "private"];
|
|
102
108
|
export declare const profilePrivacySchema: z.ZodEnum<{
|
|
@@ -107,13 +113,8 @@ export type ProfilePrivacy = z.infer<typeof profilePrivacySchema>;
|
|
|
107
113
|
/**
|
|
108
114
|
* Per-post audience override chosen by the author at compose time.
|
|
109
115
|
*
|
|
110
|
-
* `public` — anyone
|
|
111
|
-
*
|
|
112
|
-
* `connections` — only the author's accepted Connections see this post,
|
|
113
|
-
* regardless of the geographic visibility level. The geo
|
|
114
|
-
* cascade still applies on top: a connections-only post at
|
|
115
|
-
* state level is visible only to Connections who are in
|
|
116
|
-
* the same state.
|
|
116
|
+
* `public` — anyone the area-proximity cascade reaches (default).
|
|
117
|
+
* `connections` — only the author's accepted Connections see this post.
|
|
117
118
|
*
|
|
118
119
|
* Orthogonal to `ProfilePrivacy`: a public-profile user can mark
|
|
119
120
|
* individual posts as `connections`-only; a private-profile user's
|
package/dist/enums.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"enums.d.ts","sourceRoot":"","sources":["../src/enums.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB
|
|
1
|
+
{"version":3,"file":"enums.d.ts","sourceRoot":"","sources":["../src/enums.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB;;;;;;;;;;;;;;;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AAM,oBAAoB,yIAUvB,CAAC;AACX,eAAO,MAAM,kBAAkB;;;;;;;;;;EAA+B,CAAC;AAC/D,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAE9D,6CAA6C;AAC7C,eAAO,MAAM,oBAAoB,4DAA6D,CAAC;AAC/F,eAAO,MAAM,kBAAkB;;;;;EAA+B,CAAC;AAC/D,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAI9D;;;;;;;;;GASG;AACH,eAAO,MAAM,gBAAgB,gCAAiC,CAAC;AAC/D,eAAO,MAAM,cAAc;;;;EAA2B,CAAC;AACvD,MAAM,MAAM,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAC"}
|
package/dist/enums.js
CHANGED
|
@@ -8,21 +8,30 @@
|
|
|
8
8
|
* @module community-schema/enums
|
|
9
9
|
*/
|
|
10
10
|
import { z } from 'zod';
|
|
11
|
-
// ───
|
|
11
|
+
// ─── Feed viewport (viewer-side geographic filter) ─────────────────────────
|
|
12
12
|
/**
|
|
13
|
-
*
|
|
13
|
+
* Geographic scope the VIEWER chose for their feed — the area-proximity
|
|
14
|
+
* cascade is gated by this value.
|
|
14
15
|
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
* - `national` → matches national + global within the viewer's country
|
|
22
|
-
* - `global` → matches global only
|
|
16
|
+
* Posts do NOT carry a per-post `visibilityLevel` any more. Every post
|
|
17
|
+
* is implicitly global; visibility is purely a function of (a) the
|
|
18
|
+
* author's `areaLineage` at write time and (b) the viewer's scope
|
|
19
|
+
* choice here. The cascade walks from the viewer's locality outward
|
|
20
|
+
* and includes any post whose author was inside the viewer's area at
|
|
21
|
+
* ANY level the viewer's scope reaches.
|
|
23
22
|
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
23
|
+
* - `local` → locality + district + state + national matches
|
|
24
|
+
* - `district` → district + state + national matches (no locality boost)
|
|
25
|
+
* - `state` → state + national matches
|
|
26
|
+
* - `national` → national matches
|
|
27
|
+
* - `global` → all matches (de-facto same as `national` for an
|
|
28
|
+
* India-only product, but kept for forward compat)
|
|
29
|
+
*
|
|
30
|
+
* Read-side ranking — see `feed.service.ts#tierBoost` — multiplies the
|
|
31
|
+
* row's hotScore by an area-proximity factor: locality match 2.0,
|
|
32
|
+
* district 1.2, state 0.9, national 0.7, distant 0.5. So local
|
|
33
|
+
* content dominates at equal quality, while genuinely viral national
|
|
34
|
+
* content still surfaces.
|
|
26
35
|
*/
|
|
27
36
|
export const VISIBILITY_LEVEL_VALUES = [
|
|
28
37
|
'local',
|
|
@@ -33,9 +42,9 @@ export const VISIBILITY_LEVEL_VALUES = [
|
|
|
33
42
|
];
|
|
34
43
|
export const visibilityLevelSchema = z.enum(VISIBILITY_LEVEL_VALUES);
|
|
35
44
|
/**
|
|
36
|
-
* Numeric ranking used for the
|
|
37
|
-
*
|
|
38
|
-
*
|
|
45
|
+
* Numeric ranking used for the area-proximity cascade. `local` is the
|
|
46
|
+
* deepest (most specific) feed scope, `global` the broadest. Higher
|
|
47
|
+
* rank = broader scope.
|
|
39
48
|
*/
|
|
40
49
|
export const VISIBILITY_LEVEL_RANK = {
|
|
41
50
|
local: 0,
|
|
@@ -89,11 +98,8 @@ export const connectionStatusSchema = z.enum(CONNECTION_STATUS_VALUES);
|
|
|
89
98
|
/**
|
|
90
99
|
* Profile-level privacy (single toggle in Settings).
|
|
91
100
|
*
|
|
92
|
-
* `public` — anyone
|
|
93
|
-
* `private` — only accepted Connections see this user's posts.
|
|
94
|
-
* level on each post still applies on top (a private post at
|
|
95
|
-
* state level is visible only to Connections who are in the
|
|
96
|
-
* same state).
|
|
101
|
+
* `public` — anyone the area-proximity cascade reaches sees this user's posts.
|
|
102
|
+
* `private` — only accepted Connections see this user's posts.
|
|
97
103
|
*/
|
|
98
104
|
export const PROFILE_PRIVACY_VALUES = ['public', 'private'];
|
|
99
105
|
export const profilePrivacySchema = z.enum(PROFILE_PRIVACY_VALUES);
|
|
@@ -101,13 +107,8 @@ export const profilePrivacySchema = z.enum(PROFILE_PRIVACY_VALUES);
|
|
|
101
107
|
/**
|
|
102
108
|
* Per-post audience override chosen by the author at compose time.
|
|
103
109
|
*
|
|
104
|
-
* `public` — anyone
|
|
105
|
-
*
|
|
106
|
-
* `connections` — only the author's accepted Connections see this post,
|
|
107
|
-
* regardless of the geographic visibility level. The geo
|
|
108
|
-
* cascade still applies on top: a connections-only post at
|
|
109
|
-
* state level is visible only to Connections who are in
|
|
110
|
-
* the same state.
|
|
110
|
+
* `public` — anyone the area-proximity cascade reaches (default).
|
|
111
|
+
* `connections` — only the author's accepted Connections see this post.
|
|
111
112
|
*
|
|
112
113
|
* Orthogonal to `ProfilePrivacy`: a public-profile user can mark
|
|
113
114
|
* individual posts as `connections`-only; a private-profile user's
|
package/dist/enums.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"enums.js","sourceRoot":"","sources":["../src/enums.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB
|
|
1
|
+
{"version":3,"file":"enums.js","sourceRoot":"","sources":["../src/enums.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,8EAA8E;AAE9E;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG;IACrC,OAAO;IACP,UAAU;IACV,OAAO;IACP,UAAU;IACV,QAAQ;CACA,CAAC;AACX,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,CAAC,IAAI,CAAC,uBAAuB,CAAC,CAAC;AAGrE;;;;GAIG;AACH,MAAM,CAAC,MAA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E;;;;GAIG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAClC,MAAM;IACN,YAAY;IACZ,aAAa;IACb,gBAAgB;IAChB,gBAAgB;IAChB,UAAU;IACV,WAAW;IACX,iBAAiB;IACjB,OAAO;CACC,CAAC;AACX,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC;AAG/D,6CAA6C;AAC7C,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,SAAS,EAAE,WAAW,EAAE,UAAU,EAAE,WAAW,CAAU,CAAC;AAC/F,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC;AAG/D,8EAA8E;AAE9E;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,CAAU,CAAC;AAC/D,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC","sourcesContent":["/**\n * Enum value arrays shared across the community feature.\n *\n * Each enum is exported as both a `*_VALUES` tuple and the corresponding\n * Zod schema so backend Mongoose models and frontend forms validate\n * against the exact same set.\n *\n * @module community-schema/enums\n */\n\nimport { z } from 'zod';\n\n// ─── Feed viewport (viewer-side geographic filter) ─────────────────────────\n\n/**\n * Geographic scope the VIEWER chose for their feed — the area-proximity\n * cascade is gated by this value.\n *\n * Posts do NOT carry a per-post `visibilityLevel` any more. Every post\n * is implicitly global; visibility is purely a function of (a) the\n * author's `areaLineage` at write time and (b) the viewer's scope\n * choice here. The cascade walks from the viewer's locality outward\n * and includes any post whose author was inside the viewer's area at\n * ANY level the viewer's scope reaches.\n *\n * - `local` → locality + district + state + national matches\n * - `district` → district + state + national matches (no locality boost)\n * - `state` → state + national matches\n * - `national` → national matches\n * - `global` → all matches (de-facto same as `national` for an\n * India-only product, but kept for forward compat)\n *\n * Read-side ranking — see `feed.service.ts#tierBoost` — multiplies the\n * row's hotScore by an area-proximity factor: locality match 2.0,\n * district 1.2, state 0.9, national 0.7, distant 0.5. So local\n * content dominates at equal quality, while genuinely viral national\n * content still surfaces.\n */\nexport const VISIBILITY_LEVEL_VALUES = [\n 'local',\n 'district',\n 'state',\n 'national',\n 'global',\n] as const;\nexport const visibilityLevelSchema = z.enum(VISIBILITY_LEVEL_VALUES);\nexport type VisibilityLevel = z.infer<typeof visibilityLevelSchema>;\n\n/**\n * Numeric ranking used for the area-proximity cascade. `local` is the\n * deepest (most specific) feed scope, `global` the broadest. Higher\n * rank = broader scope.\n */\nexport const VISIBILITY_LEVEL_RANK: Record<VisibilityLevel, number> = {\n local: 0,\n district: 1,\n state: 2,\n national: 3,\n global: 4,\n};\n\n// ─── Polymorphic content kind ───────────────────────────────────────────────\n\n/**\n * The kinds of items that show up in the feed. `post` is the new\n * community-native kind; `lost_found`, `voice_box`, and `donate_item`\n * are existing legacy features surfaced into the feed via polymorphic\n * union.\n *\n * Engagement (upvote / reaction / comment / share) is keyed by\n * (contentKind, contentId) so every kind gets the same engagement bar.\n */\nexport const CONTENT_KIND_VALUES = ['post', 'lost_found', 'voice_box', 'donate_item'] as const;\nexport const contentKindSchema = z.enum(CONTENT_KIND_VALUES);\nexport type ContentKind = z.infer<typeof contentKindSchema>;\n\n// ─── Reactions ──────────────────────────────────────────────────────────────\n\n/**\n * Reaction types available on every feed item.\n *\n * `support` replaces Facebook's \"Care\" — better-suited to a civic /\n * hyperlocal context where reacting to a complaint or lost-and-found\n * post deserves a distinct \"I support you\" signal.\n */\nexport const REACTION_TYPE_VALUES = [\n 'like',\n 'love',\n 'haha',\n 'wow',\n 'sad',\n 'angry',\n 'support',\n] as const;\nexport const reactionTypeSchema = z.enum(REACTION_TYPE_VALUES);\nexport type ReactionType = z.infer<typeof reactionTypeSchema>;\n\n// ─── Social graph ──────────────────────────────────────────────────────────\n\n/**\n * Connection (mutual friend) lifecycle.\n *\n * `pending` — requester sent it, recipient hasn't acted yet.\n * `accepted` — both sides confirmed; full visibility regardless of level.\n * `declined` — recipient rejected; surfaces as \"you can't reconnect for X days\" on the requester side.\n * `blocked` — either side blocked; permanently prevents reconnection.\n */\nexport const CONNECTION_STATUS_VALUES = ['pending', 'accepted', 'declined', 'blocked'] as const;\nexport const connectionStatusSchema = z.enum(CONNECTION_STATUS_VALUES);\nexport type ConnectionStatus = z.infer<typeof connectionStatusSchema>;\n\n// ─── Profile privacy ───────────────────────────────────────────────────────\n\n/**\n * Profile-level privacy (single toggle in Settings).\n *\n * `public` — anyone the area-proximity cascade reaches sees this user's posts.\n * `private` — only accepted Connections see this user's posts.\n */\nexport const PROFILE_PRIVACY_VALUES = ['public', 'private'] as const;\nexport const profilePrivacySchema = z.enum(PROFILE_PRIVACY_VALUES);\nexport type ProfilePrivacy = z.infer<typeof profilePrivacySchema>;\n\n// ─── Per-post audience ─────────────────────────────────────────────────────\n\n/**\n * Per-post audience override chosen by the author at compose time.\n *\n * `public` — anyone the area-proximity cascade reaches (default).\n * `connections` — only the author's accepted Connections see this post.\n *\n * Orthogonal to `ProfilePrivacy`: a public-profile user can mark\n * individual posts as `connections`-only; a private-profile user's\n * posts default to connections-only at the profile gate regardless of\n * this value. Effective visibility = most restrictive of the two.\n */\nexport const POST_AUDIENCE_VALUES = ['public', 'connections'] as const;\nexport const postAudienceSchema = z.enum(POST_AUDIENCE_VALUES);\nexport type PostAudience = z.infer<typeof postAudienceSchema>;\n\n// ─── Moderation ────────────────────────────────────────────────────────────\n\n/**\n * Reasons a piece of content can be reported. The list is deliberately\n * short — finer categorization can come from the optional `details`\n * free-text field on a report.\n */\nexport const REPORT_REASON_VALUES = [\n 'spam',\n 'harassment',\n 'hate_speech',\n 'misinformation',\n 'sexual_content',\n 'violence',\n 'self_harm',\n 'illegal_content',\n 'other',\n] as const;\nexport const reportReasonSchema = z.enum(REPORT_REASON_VALUES);\nexport type ReportReason = z.infer<typeof reportReasonSchema>;\n\n/** Moderator decision states on a report. */\nexport const REPORT_STATUS_VALUES = ['pending', 'reviewing', 'actioned', 'dismissed'] as const;\nexport const reportStatusSchema = z.enum(REPORT_STATUS_VALUES);\nexport type ReportStatus = z.infer<typeof reportStatusSchema>;\n\n// ─── Feed sort ─────────────────────────────────────────────────────────────\n\n/**\n * Sort options exposed in the feed UI.\n *\n * `hot` — the default. Reddit-style score blending upvotes, comment count,\n * and recency. Best surface for civic / community engagement.\n * `new` — strict reverse-chronological. Useful when the viewer wants to\n * catch up on everything fresh.\n * `top` — highest upvote count over a configurable window (defaults to\n * 24 hours on the client).\n */\nexport const FEED_SORT_VALUES = ['hot', 'new', 'top'] as const;\nexport const feedSortSchema = z.enum(FEED_SORT_VALUES);\nexport type FeedSort = z.infer<typeof feedSortSchema>;\n"]}
|
package/dist/feed.d.ts
CHANGED
|
@@ -146,13 +146,6 @@ export declare const feedItemSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
146
146
|
bytes: z.ZodNumber;
|
|
147
147
|
duration: z.ZodNumber;
|
|
148
148
|
}, z.core.$strip>>;
|
|
149
|
-
visibilityLevel: z.ZodEnum<{
|
|
150
|
-
local: "local";
|
|
151
|
-
district: "district";
|
|
152
|
-
state: "state";
|
|
153
|
-
national: "national";
|
|
154
|
-
global: "global";
|
|
155
|
-
}>;
|
|
156
149
|
areaLineage: z.ZodObject<{
|
|
157
150
|
countryId: z.ZodOptional<z.ZodString>;
|
|
158
151
|
stateId: z.ZodOptional<z.ZodString>;
|
|
@@ -323,13 +316,6 @@ export declare const feedResponseSchema: z.ZodObject<{
|
|
|
323
316
|
bytes: z.ZodNumber;
|
|
324
317
|
duration: z.ZodNumber;
|
|
325
318
|
}, z.core.$strip>>;
|
|
326
|
-
visibilityLevel: z.ZodEnum<{
|
|
327
|
-
local: "local";
|
|
328
|
-
district: "district";
|
|
329
|
-
state: "state";
|
|
330
|
-
national: "national";
|
|
331
|
-
global: "global";
|
|
332
|
-
}>;
|
|
333
319
|
areaLineage: z.ZodObject<{
|
|
334
320
|
countryId: z.ZodOptional<z.ZodString>;
|
|
335
321
|
stateId: z.ZodOptional<z.ZodString>;
|
package/dist/feed.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"feed.d.ts","sourceRoot":"","sources":["../src/feed.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAMhD;;;;GAIG;AACH,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA4BlC,CAAC;AACH,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAExE;;;;GAIG;AACH,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;iBAiCnC,CAAC;AACH,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAE1E;;GAEG;AACH,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;iBAyBjC,CAAC;AACH,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC;AAItE,eAAO,MAAM,cAAc
|
|
1
|
+
{"version":3,"file":"feed.d.ts","sourceRoot":"","sources":["../src/feed.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAMhD;;;;GAIG;AACH,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA4BlC,CAAC;AACH,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uB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ber;
|
|
95
95
|
duration: z.ZodNumber;
|
|
96
96
|
}, z.core.$strip>>;
|
|
97
|
-
visibilityLevel: z.ZodEnum<{
|
|
98
|
-
local: "local";
|
|
99
|
-
district: "district";
|
|
100
|
-
state: "state";
|
|
101
|
-
national: "national";
|
|
102
|
-
global: "global";
|
|
103
|
-
}>;
|
|
104
97
|
areaLineage: z.ZodObject<{
|
|
105
98
|
countryId: z.ZodOptional<z.ZodString>;
|
|
106
99
|
stateId: z.ZodOptional<z.ZodString>;
|
|
@@ -150,8 +143,8 @@ export declare const communityPostWireSchema: z.ZodObject<{
|
|
|
150
143
|
export type CommunityPostWire = z.infer<typeof communityPostWireSchema>;
|
|
151
144
|
/**
|
|
152
145
|
* What the client sends to `POST /api/v1/community/posts`. The author
|
|
153
|
-
* is taken from the authenticated request;
|
|
154
|
-
* server-side from the user's
|
|
146
|
+
* is taken from the authenticated request; the area lineage is resolved
|
|
147
|
+
* server-side from the user's `currentLocation` (the client cannot
|
|
155
148
|
* spoof a different area).
|
|
156
149
|
*/
|
|
157
150
|
export declare const createPostBodySchema: z.ZodObject<{
|
|
@@ -172,13 +165,6 @@ export declare const createPostBodySchema: z.ZodObject<{
|
|
|
172
165
|
bytes: z.ZodNumber;
|
|
173
166
|
duration: z.ZodNumber;
|
|
174
167
|
}, z.core.$strip>>>;
|
|
175
|
-
visibilityLevel: z.ZodEnum<{
|
|
176
|
-
local: "local";
|
|
177
|
-
district: "district";
|
|
178
|
-
state: "state";
|
|
179
|
-
national: "national";
|
|
180
|
-
global: "global";
|
|
181
|
-
}>;
|
|
182
168
|
audience: z.ZodDefault<z.ZodEnum<{
|
|
183
169
|
public: "public";
|
|
184
170
|
connections: "connections";
|
package/dist/post.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"post.d.ts","sourceRoot":"","sources":["../src/post.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,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AACH,eAAO,MAAM,oBAAoB;;iBAE/B,CAAC;AACH,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC"}
|
package/dist/post.js
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
import { z } from 'zod';
|
|
12
12
|
import { areaLineageSnapshotSchema } from './area.js';
|
|
13
13
|
import { POST_MAX_BODY_CHARS, POST_MAX_IMAGES, POST_MAX_VIDEOS } from './constants.js';
|
|
14
|
-
import { contentKindSchema, postAudienceSchema
|
|
14
|
+
import { contentKindSchema, postAudienceSchema } from './enums.js';
|
|
15
15
|
import { postImageSchema, postVideoSchema } from './media.js';
|
|
16
16
|
// ─── Author snapshot (denormalised on every post) ──────────────────────────
|
|
17
17
|
/**
|
|
@@ -91,18 +91,18 @@ export const communityPostWireSchema = z.object({
|
|
|
91
91
|
text: z.string().max(POST_MAX_BODY_CHARS),
|
|
92
92
|
images: z.array(postImageSchema).max(POST_MAX_IMAGES),
|
|
93
93
|
videos: z.array(postVideoSchema).max(POST_MAX_VIDEOS),
|
|
94
|
-
//
|
|
95
|
-
|
|
94
|
+
// Authorship area + audience
|
|
95
|
+
/** Snapshot of where the author was at write time. Drives the
|
|
96
|
+
* area-proximity cascade and ranking in feed.service. */
|
|
96
97
|
areaLineage: areaLineageSnapshotSchema,
|
|
97
98
|
/** Per-post audience override. Defaults to `public` on creation when
|
|
98
99
|
* the client omits it. See `postAudienceSchema` in enums for the
|
|
99
100
|
* full interaction with `ProfilePrivacy`. */
|
|
100
101
|
audience: postAudienceSchema,
|
|
101
102
|
/** When set, the post is scoped to a topical community and is NOT
|
|
102
|
-
* surfaced via the geo cascade
|
|
103
|
-
*
|
|
104
|
-
*
|
|
105
|
-
* this null. */
|
|
103
|
+
* surfaced via the geo cascade. The community feed adds an explicit
|
|
104
|
+
* `communityId` filter to its read queries. Posts authored from the
|
|
105
|
+
* global composer leave this null. */
|
|
106
106
|
communityId: z.string().optional(),
|
|
107
107
|
// Denormalised engagement counters (drive feed sort + card render)
|
|
108
108
|
upvoteCount: z.number().int().nonnegative(),
|
|
@@ -142,18 +142,14 @@ export const communityPostWireSchema = z.object({
|
|
|
142
142
|
// ─── Create / update bodies ────────────────────────────────────────────────
|
|
143
143
|
/**
|
|
144
144
|
* What the client sends to `POST /api/v1/community/posts`. The author
|
|
145
|
-
* is taken from the authenticated request;
|
|
146
|
-
* server-side from the user's
|
|
145
|
+
* is taken from the authenticated request; the area lineage is resolved
|
|
146
|
+
* server-side from the user's `currentLocation` (the client cannot
|
|
147
147
|
* spoof a different area).
|
|
148
148
|
*/
|
|
149
149
|
export const createPostBodySchema = z.object({
|
|
150
150
|
text: z.string().min(1).max(POST_MAX_BODY_CHARS),
|
|
151
151
|
images: z.array(postImageSchema).max(POST_MAX_IMAGES).optional(),
|
|
152
152
|
videos: z.array(postVideoSchema).max(POST_MAX_VIDEOS).optional(),
|
|
153
|
-
/** Backend ignores client value — every post starts at the deepest
|
|
154
|
-
* tier the author's `currentLocation` resolves and climbs via the
|
|
155
|
-
* tier-promotion job. Kept on the wire for the enum constraint. */
|
|
156
|
-
visibilityLevel: visibilityLevelSchema,
|
|
157
153
|
/** Per-post audience selector chosen by the composer's privacy
|
|
158
154
|
* pill. Optional; defaults to `public` on the server when omitted
|
|
159
155
|
* (the schema applies the default so older clients keep working).
|
package/dist/post.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"post.js","sourceRoot":"","sources":["../src/post.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,yBAAyB,EAAE,MAAM,WAAW,CAAC;AACtD,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACvF,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAC1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ACvD,MAAM,EAAE,CAAC;SACN,MAAM,CAAC;QACN,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE;QACpB;;sDAE8C;QAC9C,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;QAC/B,+EAA+E;QAC/E,QAAQ,EAAE,CAAC,CAAC,OAAO,EAAE;QACrB;;oDAE4C;QAC5C,QAAQ,EAAE,CAAC,CAAC,OAAO,EAAE;KACtB,CAAC;SACD,QAAQ,EAAE;CACd,CAAC,CAAC;AAGH,8EAA8E;AAE9E;;;;;GAKG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC3C,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,mBAAmB,CAAC;IAChD,MAAM,EAAE,CAAC,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC,QAAQ,EAAE;IAChE,MAAM,EAAE,CAAC,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC,QAAQ,EAAE;IAChE;;wEAEoE;IACpE,eAAe,EAAE,qBAAqB;IACtC;;;yEAGqE;IACrE,QAAQ,EAAE,kBAAkB,CAAC,OAAO,CAAC,QAAQ,CAAC;IAC9C;2DACuD;IACvD,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CACnC,CAAC,CAAC;AAGH;;;;GAIG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC3C,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,mBAAmB,CAAC;CACjD,CAAC,CAAC","sourcesContent":["/**\n * Community post wire shapes.\n *\n * A \"post\" is the native community content kind (text-primary + media).\n * Lost-and-found and voice-box items show up in the same feed via\n * polymorphic union; their shapes live in their own schema packages\n * and are projected into a `FeedItem` envelope (see `./feed.ts`).\n *\n * @module community-schema/post\n */\n\nimport { z } from 'zod';\nimport { areaLineageSnapshotSchema } from './area.js';\nimport { POST_MAX_BODY_CHARS, POST_MAX_IMAGES, POST_MAX_VIDEOS } from './constants.js';\nimport { contentKindSchema, postAudienceSchema, visibilityLevelSchema } from './enums.js';\nimport { postImageSchema, postVideoSchema } from './media.js';\n\n// ─── Author snapshot (denormalised on every post) ──────────────────────────\n\n/**\n * The author's display info captured at post time. Denormalising\n * `displayName` / `avatarUrl` / `localName` here avoids a $lookup\n * against the User collection on every feed read — feed scans 20–40\n * posts per page and population would be a hot path.\n *\n * The User document remains the source of truth; a background job\n * (or a hook on User.findOneAndUpdate) refreshes recent posts when\n * a user changes their display name or avatar.\n */\nexport const postAuthorSnapshotSchema = z.object({\n userId: z.string(),\n displayName: z.string(),\n avatarUrl: z.string().url().optional(),\n /**\n * The author's \"local\" area label at post time, e.g. \"Rohini Sector 15\".\n * Powers the byline \"<DisplayName> · <localName> · <relativeTime>\".\n * Hidden when the author has a private profile and the viewer is\n * not an accepted Connection.\n */\n localName: z.string().optional(),\n});\nexport type PostAuthorSnapshot = z.infer<typeof postAuthorSnapshotSchema>;\n\n// ─── Reposted source snapshot ──────────────────────────────────────────────\n\n/**\n * Compact embed shape used when a CommunityPost is a repost (caption +\n * optional quote of another item). Modelled after Twitter's quote-tweet\n * embed: byline + truncated text/title + first image + kind badge + the\n * moment-of-creation timestamp.\n *\n * Engagement counts are intentionally NOT included — they'd drift\n * relative to the live source. The card embeds this as a static teaser\n * that links to the source for the live numbers.\n *\n * Backend snapshots these fields at repost-create time from the source\n * row (post text / item title / first photo / status badge), so the\n * embed survives source edits / soft-deletes / hides — the user's\n * reaction at repost time is preserved.\n */\nexport const repostedSourceSchema = z.object({\n /** Which kind was reposted. Lets the embed render the right icon. */\n contentKind: contentKindSchema,\n /** Source row's id — tap-embed navigates to its thread / detail page. */\n _id: z.string(),\n /** Author snapshot of the source at repost time. */\n author: postAuthorSnapshotSchema,\n /** Primary text. For posts: the body text (truncated). For lost_found /\n * voice_box / donate_item: the title. */\n title: z.string(),\n /** Optional secondary line. For posts: unused. For legacy kinds: the\n * description (truncated server-side). */\n body: z.string().optional(),\n /** First image if any. */\n imageUrl: z.string().url().optional(),\n /** Small kind-specific badge:\n * - posts → undefined\n * - lost_found → 'lost' | 'found'\n * - voice_box → 'complaint' | 'suggestion'\n * - donate_item → 'PENDING' | 'VERIFIED' | 'AT_CENTER' | 'DONATED'\n */\n kindBadge: z.string().optional(),\n createdAt: z.string().datetime(),\n});\nexport type RepostedSource = z.infer<typeof repostedSourceSchema>;\n\n// ─── Wire shape — what the server returns ──────────────────────────────────\n\n/**\n * A community post as it appears in the feed and on the single-post\n * page. Engagement counts are denormalised onto the document for\n * fast feed sorting; the per-user reaction state (\"did I upvote this?\")\n * is computed at read time and returned in the `viewer` block.\n */\nexport const communityPostWireSchema = z.object({\n _id: z.string(),\n contentKind: z.literal('post'),\n author: postAuthorSnapshotSchema,\n\n // Body — for a repost, this carries the caption (may be empty).\n text: z.string().max(POST_MAX_BODY_CHARS),\n images: z.array(postImageSchema).max(POST_MAX_IMAGES),\n videos: z.array(postVideoSchema).max(POST_MAX_VIDEOS),\n\n // Audience\n visibilityLevel: visibilityLevelSchema,\n areaLineage: areaLineageSnapshotSchema,\n /** Per-post audience override. Defaults to `public` on creation when\n * the client omits it. See `postAudienceSchema` in enums for the\n * full interaction with `ProfilePrivacy`. */\n audience: postAudienceSchema,\n /** When set, the post is scoped to a topical community and is NOT\n * surfaced via the geo cascade or the tier-promotion job. The\n * community feed adds an explicit `communityId` filter to its\n * read queries. Posts authored from the global composer leave\n * this null. */\n communityId: z.string().optional(),\n\n // Denormalised engagement counters (drive feed sort + card render)\n upvoteCount: z.number().int().nonnegative(),\n commentCount: z.number().int().nonnegative(),\n /** How many times this post has been reposted. Incremented by the\n * repost endpoint; reposts of reposts are blocked server-side. */\n repostCount: z.number().int().nonnegative(),\n /** Map of `ReactionType` → count, e.g. { like: 4, love: 1 }. */\n reactionCounts: z.record(z.string(), z.number().int().nonnegative()),\n\n /** Source-snapshot when this post is a repost. Absent on regular posts.\n * The wrapper post owns its own engagement counters; this embed is\n * a static teaser of the original at repost time. */\n repostOf: repostedSourceSchema.optional(),\n\n // Lifecycle\n createdAt: z.string().datetime(),\n /** Last edit timestamp, or null if never edited. Edit window is\n * enforced by the server at write time, not by this schema. */\n editedAt: z.string().datetime().nullable(),\n deletedAt: z.string().datetime().nullable(),\n\n // Per-viewer state (filled by the server at read time)\n viewer: z\n .object({\n upvoted: z.boolean(),\n /** The reaction the viewer chose, or null. Mutually exclusive\n * with `upvoted` is intentionally NOT enforced — they're two\n * separate axes per the product decision. */\n reaction: z.string().nullable(),\n /** True when the viewer authored the post (controls edit / delete buttons). */\n isAuthor: z.boolean(),\n /** True when the viewer has already reposted this source. The\n * client uses this to render the repost button as \"already\n * reposted\" rather than as a fresh CTA. */\n reposted: z.boolean(),\n })\n .optional(),\n});\nexport type CommunityPostWire = z.infer<typeof communityPostWireSchema>;\n\n// ─── Create / update bodies ────────────────────────────────────────────────\n\n/**\n * What the client sends to `POST /api/v1/community/posts`. The author\n * is taken from the authenticated request; visibility area is resolved\n * server-side from the user's primary area lineage (the client cannot\n * spoof a different area).\n */\nexport const createPostBodySchema = z.object({\n text: z.string().min(1).max(POST_MAX_BODY_CHARS),\n images: z.array(postImageSchema).max(POST_MAX_IMAGES).optional(),\n videos: z.array(postVideoSchema).max(POST_MAX_VIDEOS).optional(),\n /** Backend ignores client value — every post starts at the deepest\n * tier the author's `currentLocation` resolves and climbs via the\n * tier-promotion job. Kept on the wire for the enum constraint. */\n visibilityLevel: visibilityLevelSchema,\n /** Per-post audience selector chosen by the composer's privacy\n * pill. Optional; defaults to `public` on the server when omitted\n * (the schema applies the default so older clients keep working).\n * See `postAudienceSchema` for the public/connections semantics. */\n audience: postAudienceSchema.default('public'),\n /** When set, the post is scoped to a topical community. The author\n * must be an active member; non-members get a 403. */\n communityId: z.string().optional(),\n});\nexport type CreatePostBody = z.infer<typeof createPostBodySchema>;\n\n/**\n * What the client sends to `PATCH /api/v1/community/posts/:id`. Only\n * the text body is editable — media additions / removals require a new\n * post (matches Twitter / FB convention).\n */\nexport const updatePostBodySchema = z.object({\n text: z.string().min(1).max(POST_MAX_BODY_CHARS),\n});\nexport type UpdatePostBody = z.infer<typeof updatePostBodySchema>;\n"]}
|
|
1
|
+
{"version":3,"file":"post.js","sourceRoot":"","sources":["../src/post.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,yBAAyB,EAAE,MAAM,WAAW,CAAC;AACtD,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACvF,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AACnE,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAE9D,8EAA8E;AAE9E;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC/C,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE;IAClB,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE;IACvB,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE;IACtC;;;;;OAKG;IACH,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CACjC,CAAC,CAAC;AAGH,8EAA8E;AAE9E;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC3C,qEAAqE;IACrE,WAAW,EAAE,iBAAiB;IAC9B,yEAAyE;IACzE,GAAG,EAAE,CAAC,C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,CAAC,QAAQ,EAAE;IAChE,MAAM,EAAE,CAAC,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC,QAAQ,EAAE;IAChE;;;yEAGqE;IACrE,QAAQ,EAAE,kBAAkB,CAAC,OAAO,CAAC,QAAQ,CAAC;IAC9C;2DACuD;IACvD,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CACnC,CAAC,CAAC;AAGH;;;;GAIG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC3C,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,mBAAmB,CAAC;CACjD,CAAC,CAAC","sourcesContent":["/**\n * Community post wire shapes.\n *\n * A \"post\" is the native community content kind (text-primary + media).\n * Lost-and-found and voice-box items show up in the same feed via\n * polymorphic union; their shapes live in their own schema packages\n * and are projected into a `FeedItem` envelope (see `./feed.ts`).\n *\n * @module community-schema/post\n */\n\nimport { z } from 'zod';\nimport { areaLineageSnapshotSchema } from './area.js';\nimport { POST_MAX_BODY_CHARS, POST_MAX_IMAGES, POST_MAX_VIDEOS } from './constants.js';\nimport { contentKindSchema, postAudienceSchema } from './enums.js';\nimport { postImageSchema, postVideoSchema } from './media.js';\n\n// ─── Author snapshot (denormalised on every post) ──────────────────────────\n\n/**\n * The author's display info captured at post time. Denormalising\n * `displayName` / `avatarUrl` / `localName` here avoids a $lookup\n * against the User collection on every feed read — feed scans 20–40\n * posts per page and population would be a hot path.\n *\n * The User document remains the source of truth; a background job\n * (or a hook on User.findOneAndUpdate) refreshes recent posts when\n * a user changes their display name or avatar.\n */\nexport const postAuthorSnapshotSchema = z.object({\n userId: z.string(),\n displayName: z.string(),\n avatarUrl: z.string().url().optional(),\n /**\n * The author's \"local\" area label at post time, e.g. \"Rohini Sector 15\".\n * Powers the byline \"<DisplayName> · <localName> · <relativeTime>\".\n * Hidden when the author has a private profile and the viewer is\n * not an accepted Connection.\n */\n localName: z.string().optional(),\n});\nexport type PostAuthorSnapshot = z.infer<typeof postAuthorSnapshotSchema>;\n\n// ─── Reposted source snapshot ──────────────────────────────────────────────\n\n/**\n * Compact embed shape used when a CommunityPost is a repost (caption +\n * optional quote of another item). Modelled after Twitter's quote-tweet\n * embed: byline + truncated text/title + first image + kind badge + the\n * moment-of-creation timestamp.\n *\n * Engagement counts are intentionally NOT included — they'd drift\n * relative to the live source. The card embeds this as a static teaser\n * that links to the source for the live numbers.\n *\n * Backend snapshots these fields at repost-create time from the source\n * row (post text / item title / first photo / status badge), so the\n * embed survives source edits / soft-deletes / hides — the user's\n * reaction at repost time is preserved.\n */\nexport const repostedSourceSchema = z.object({\n /** Which kind was reposted. Lets the embed render the right icon. */\n contentKind: contentKindSchema,\n /** Source row's id — tap-embed navigates to its thread / detail page. */\n _id: z.string(),\n /** Author snapshot of the source at repost time. */\n author: postAuthorSnapshotSchema,\n /** Primary text. For posts: the body text (truncated). For lost_found /\n * voice_box / donate_item: the title. */\n title: z.string(),\n /** Optional secondary line. For posts: unused. For legacy kinds: the\n * description (truncated server-side). */\n body: z.string().optional(),\n /** First image if any. */\n imageUrl: z.string().url().optional(),\n /** Small kind-specific badge:\n * - posts → undefined\n * - lost_found → 'lost' | 'found'\n * - voice_box → 'complaint' | 'suggestion'\n * - donate_item → 'PENDING' | 'VERIFIED' | 'AT_CENTER' | 'DONATED'\n */\n kindBadge: z.string().optional(),\n createdAt: z.string().datetime(),\n});\nexport type RepostedSource = z.infer<typeof repostedSourceSchema>;\n\n// ─── Wire shape — what the server returns ──────────────────────────────────\n\n/**\n * A community post as it appears in the feed and on the single-post\n * page. Engagement counts are denormalised onto the document for\n * fast feed sorting; the per-user reaction state (\"did I upvote this?\")\n * is computed at read time and returned in the `viewer` block.\n */\nexport const communityPostWireSchema = z.object({\n _id: z.string(),\n contentKind: z.literal('post'),\n author: postAuthorSnapshotSchema,\n\n // Body — for a repost, this carries the caption (may be empty).\n text: z.string().max(POST_MAX_BODY_CHARS),\n images: z.array(postImageSchema).max(POST_MAX_IMAGES),\n videos: z.array(postVideoSchema).max(POST_MAX_VIDEOS),\n\n // Authorship area + audience\n /** Snapshot of where the author was at write time. Drives the\n * area-proximity cascade and ranking in feed.service. */\n areaLineage: areaLineageSnapshotSchema,\n /** Per-post audience override. Defaults to `public` on creation when\n * the client omits it. See `postAudienceSchema` in enums for the\n * full interaction with `ProfilePrivacy`. */\n audience: postAudienceSchema,\n /** When set, the post is scoped to a topical community and is NOT\n * surfaced via the geo cascade. The community feed adds an explicit\n * `communityId` filter to its read queries. Posts authored from the\n * global composer leave this null. */\n communityId: z.string().optional(),\n\n // Denormalised engagement counters (drive feed sort + card render)\n upvoteCount: z.number().int().nonnegative(),\n commentCount: z.number().int().nonnegative(),\n /** How many times this post has been reposted. Incremented by the\n * repost endpoint; reposts of reposts are blocked server-side. */\n repostCount: z.number().int().nonnegative(),\n /** Map of `ReactionType` → count, e.g. { like: 4, love: 1 }. */\n reactionCounts: z.record(z.string(), z.number().int().nonnegative()),\n\n /** Source-snapshot when this post is a repost. Absent on regular posts.\n * The wrapper post owns its own engagement counters; this embed is\n * a static teaser of the original at repost time. */\n repostOf: repostedSourceSchema.optional(),\n\n // Lifecycle\n createdAt: z.string().datetime(),\n /** Last edit timestamp, or null if never edited. Edit window is\n * enforced by the server at write time, not by this schema. */\n editedAt: z.string().datetime().nullable(),\n deletedAt: z.string().datetime().nullable(),\n\n // Per-viewer state (filled by the server at read time)\n viewer: z\n .object({\n upvoted: z.boolean(),\n /** The reaction the viewer chose, or null. Mutually exclusive\n * with `upvoted` is intentionally NOT enforced — they're two\n * separate axes per the product decision. */\n reaction: z.string().nullable(),\n /** True when the viewer authored the post (controls edit / delete buttons). */\n isAuthor: z.boolean(),\n /** True when the viewer has already reposted this source. The\n * client uses this to render the repost button as \"already\n * reposted\" rather than as a fresh CTA. */\n reposted: z.boolean(),\n })\n .optional(),\n});\nexport type CommunityPostWire = z.infer<typeof communityPostWireSchema>;\n\n// ─── Create / update bodies ────────────────────────────────────────────────\n\n/**\n * What the client sends to `POST /api/v1/community/posts`. The author\n * is taken from the authenticated request; the area lineage is resolved\n * server-side from the user's `currentLocation` (the client cannot\n * spoof a different area).\n */\nexport const createPostBodySchema = z.object({\n text: z.string().min(1).max(POST_MAX_BODY_CHARS),\n images: z.array(postImageSchema).max(POST_MAX_IMAGES).optional(),\n videos: z.array(postVideoSchema).max(POST_MAX_VIDEOS).optional(),\n /** Per-post audience selector chosen by the composer's privacy\n * pill. Optional; defaults to `public` on the server when omitted\n * (the schema applies the default so older clients keep working).\n * See `postAudienceSchema` for the public/connections semantics. */\n audience: postAudienceSchema.default('public'),\n /** When set, the post is scoped to a topical community. The author\n * must be an active member; non-members get a 403. */\n communityId: z.string().optional(),\n});\nexport type CreatePostBody = z.infer<typeof createPostBodySchema>;\n\n/**\n * What the client sends to `PATCH /api/v1/community/posts/:id`. Only\n * the text body is editable — media additions / removals require a new\n * post (matches Twitter / FB convention).\n */\nexport const updatePostBodySchema = z.object({\n text: z.string().min(1).max(POST_MAX_BODY_CHARS),\n});\nexport type UpdatePostBody = z.infer<typeof updatePostBodySchema>;\n"]}
|
package/dist/repost.d.ts
CHANGED
|
@@ -17,9 +17,7 @@
|
|
|
17
17
|
import { z } from 'zod';
|
|
18
18
|
/**
|
|
19
19
|
* Body for `POST /api/v1/community/reposts`. The wrapper post's text is
|
|
20
|
-
* the optional caption
|
|
21
|
-
* may differ from the source's level (e.g. amplify a national post
|
|
22
|
-
* locally to flag it for your neighbours).
|
|
20
|
+
* the optional caption.
|
|
23
21
|
*/
|
|
24
22
|
export declare const createRepostBodySchema: z.ZodObject<{
|
|
25
23
|
sourceKind: z.ZodEnum<{
|
|
@@ -30,13 +28,6 @@ export declare const createRepostBodySchema: z.ZodObject<{
|
|
|
30
28
|
}>;
|
|
31
29
|
sourceId: z.ZodString;
|
|
32
30
|
caption: z.ZodOptional<z.ZodString>;
|
|
33
|
-
visibilityLevel: z.ZodEnum<{
|
|
34
|
-
local: "local";
|
|
35
|
-
district: "district";
|
|
36
|
-
state: "state";
|
|
37
|
-
national: "national";
|
|
38
|
-
global: "global";
|
|
39
|
-
}>;
|
|
40
31
|
}, z.core.$strip>;
|
|
41
32
|
export type CreateRepostBody = z.infer<typeof createRepostBodySchema>;
|
|
42
33
|
/**
|
|
@@ -71,13 +62,6 @@ export declare const createRepostResponseSchema: z.ZodObject<{
|
|
|
71
62
|
bytes: z.ZodNumber;
|
|
72
63
|
duration: z.ZodNumber;
|
|
73
64
|
}, z.core.$strip>>;
|
|
74
|
-
visibilityLevel: z.ZodEnum<{
|
|
75
|
-
local: "local";
|
|
76
|
-
district: "district";
|
|
77
|
-
state: "state";
|
|
78
|
-
national: "national";
|
|
79
|
-
global: "global";
|
|
80
|
-
}>;
|
|
81
65
|
areaLineage: z.ZodObject<{
|
|
82
66
|
countryId: z.ZodOptional<z.ZodString>;
|
|
83
67
|
stateId: z.ZodOptional<z.ZodString>;
|
package/dist/repost.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"repost.d.ts","sourceRoot":"","sources":["../src/repost.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAKxB
|
|
1
|
+
{"version":3,"file":"repost.d.ts","sourceRoot":"","sources":["../src/repost.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAKxB;;;GAGG;AACH,eAAO,MAAM,sBAAsB;;;;;;;;;iBASjC,CAAC;AACH,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC;AAEtE;;;;GAIG;AACH,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAErC,CAAC;AACH,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAC"}
|
package/dist/repost.js
CHANGED
|
@@ -16,13 +16,11 @@
|
|
|
16
16
|
*/
|
|
17
17
|
import { z } from 'zod';
|
|
18
18
|
import { POST_MAX_BODY_CHARS } from './constants.js';
|
|
19
|
-
import { contentKindSchema
|
|
19
|
+
import { contentKindSchema } from './enums.js';
|
|
20
20
|
import { communityPostWireSchema } from './post.js';
|
|
21
21
|
/**
|
|
22
22
|
* Body for `POST /api/v1/community/reposts`. The wrapper post's text is
|
|
23
|
-
* the optional caption
|
|
24
|
-
* may differ from the source's level (e.g. amplify a national post
|
|
25
|
-
* locally to flag it for your neighbours).
|
|
23
|
+
* the optional caption.
|
|
26
24
|
*/
|
|
27
25
|
export const createRepostBodySchema = z.object({
|
|
28
26
|
/** Which kind is being reposted. */
|
|
@@ -33,8 +31,6 @@ export const createRepostBodySchema = z.object({
|
|
|
33
31
|
/** Optional caption. Empty string = amplify only (still creates a
|
|
34
32
|
* wrapper post, just with no caption shown on the card). */
|
|
35
33
|
caption: z.string().max(POST_MAX_BODY_CHARS).optional(),
|
|
36
|
-
/** Visibility for the wrapper post. */
|
|
37
|
-
visibilityLevel: visibilityLevelSchema,
|
|
38
34
|
});
|
|
39
35
|
/**
|
|
40
36
|
* Response from a successful repost. The wrapper post is returned in
|
package/dist/repost.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"repost.js","sourceRoot":"","sources":["../src/repost.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,
|
|
1
|
+
{"version":3,"file":"repost.js","sourceRoot":"","sources":["../src/repost.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,EAAE,uBAAuB,EAAE,MAAM,WAAW,CAAC;AAEpD;;;GAGG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC7C,oCAAoC;IACpC,UAAU,EAAE,iBAAiB;IAC7B;iDAC6C;IAC7C,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE;IACpB;iEAC6D;IAC7D,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC,QAAQ,EAAE;CACxD,CAAC,CAAC;AAGH;;;;GAIG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAAC,CAAC,MAAM,CAAC;IACjD,IAAI,EAAE,uBAAuB;CAC9B,CAAC,CAAC","sourcesContent":["/**\n * Repost (quote / amplify) wire shapes.\n *\n * A repost is a CommunityPost with an optional caption that embeds the\n * source via a snapshot. Modelled after Twitter's quote-tweet: the\n * wrapper is its own post with own engagement; tapping the embed\n * navigates to the source for live counts.\n *\n * Constraints enforced server-side:\n * - At most one active repost per (viewer, sourceKind, sourceId).\n * - Reposting a repost is blocked (no chains).\n * - Caption may be empty (amplify-only) but the wrapper is still a\n * full CommunityPost.\n *\n * @module community-schema/repost\n */\n\nimport { z } from 'zod';\nimport { POST_MAX_BODY_CHARS } from './constants.js';\nimport { contentKindSchema } from './enums.js';\nimport { communityPostWireSchema } from './post.js';\n\n/**\n * Body for `POST /api/v1/community/reposts`. The wrapper post's text is\n * the optional caption.\n */\nexport const createRepostBodySchema = z.object({\n /** Which kind is being reposted. */\n sourceKind: contentKindSchema,\n /** Source row's id. Server validates existence + not-already-a-repost\n * + not-already-reposted-by-this-viewer. */\n sourceId: z.string(),\n /** Optional caption. Empty string = amplify only (still creates a\n * wrapper post, just with no caption shown on the card). */\n caption: z.string().max(POST_MAX_BODY_CHARS).optional(),\n});\nexport type CreateRepostBody = z.infer<typeof createRepostBodySchema>;\n\n/**\n * Response from a successful repost. The wrapper post is returned in\n * full (same wire shape as a normal post, but with `repostOf` set) so\n * the client can prepend it to the feed without a follow-up read.\n */\nexport const createRepostResponseSchema = z.object({\n post: communityPostWireSchema,\n});\nexport type CreateRepostResponse = z.infer<typeof createRepostResponseSchema>;\n"]}
|
package/dist/settings.d.ts
CHANGED
|
@@ -20,13 +20,6 @@ export declare const communitySettingsWireSchema: z.ZodObject<{
|
|
|
20
20
|
public: "public";
|
|
21
21
|
private: "private";
|
|
22
22
|
}>;
|
|
23
|
-
defaultPostVisibility: z.ZodEnum<{
|
|
24
|
-
local: "local";
|
|
25
|
-
district: "district";
|
|
26
|
-
state: "state";
|
|
27
|
-
national: "national";
|
|
28
|
-
global: "global";
|
|
29
|
-
}>;
|
|
30
23
|
bio: z.ZodNullable<z.ZodString>;
|
|
31
24
|
blockedCount: z.ZodNumber;
|
|
32
25
|
notifications: z.ZodObject<{
|
|
@@ -55,13 +48,6 @@ export declare const updateCommunitySettingsBodySchema: z.ZodObject<{
|
|
|
55
48
|
public: "public";
|
|
56
49
|
private: "private";
|
|
57
50
|
}>>;
|
|
58
|
-
defaultPostVisibility: z.ZodOptional<z.ZodEnum<{
|
|
59
|
-
local: "local";
|
|
60
|
-
district: "district";
|
|
61
|
-
state: "state";
|
|
62
|
-
national: "national";
|
|
63
|
-
global: "global";
|
|
64
|
-
}>>;
|
|
65
51
|
bio: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
66
52
|
notifications: z.ZodOptional<z.ZodObject<{
|
|
67
53
|
onFollow: z.ZodOptional<z.ZodBoolean>;
|
package/dist/settings.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"settings.d.ts","sourceRoot":"","sources":["../src/settings.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,eAAO,MAAM,2BAA2B
|
|
1
|
+
{"version":3,"file":"settings.d.ts","sourceRoot":"","sources":["../src/settings.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,eAAO,MAAM,2BAA2B;;;;;;;;;;;;;;;;;iBA4BtC,CAAC;AACH,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,2BAA2B,CAAC,CAAC;AAEhF;;;;;;;;GAQG;AACH,eAAO,MAAM,iCAAiC;;;;;;;;;;;;;;;;iBAe5C,CAAC;AACH,MAAM,MAAM,2BAA2B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iCAAiC,CAAC,CAAC;AAI5F;;;;GAIG;AACH,eAAO,MAAM,qBAAqB;;;;;;iBAMhC,CAAC;AACH,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAEpE,eAAO,MAAM,8BAA8B;;;;;;;;iBAEzC,CAAC;AACH,MAAM,MAAM,wBAAwB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,8BAA8B,CAAC,CAAC;AAItF,eAAO,MAAM,2BAA2B,EAAE,qBAczC,CAAC"}
|
package/dist/settings.js
CHANGED
|
@@ -16,12 +16,10 @@
|
|
|
16
16
|
*/
|
|
17
17
|
import { z } from 'zod';
|
|
18
18
|
import { PROFILE_MAX_BIO_CHARS } from './constants.js';
|
|
19
|
-
import { profilePrivacySchema
|
|
19
|
+
import { profilePrivacySchema } from './enums.js';
|
|
20
20
|
export const communitySettingsWireSchema = z.object({
|
|
21
21
|
/** Profile-level privacy toggle. */
|
|
22
22
|
privacy: profilePrivacySchema,
|
|
23
|
-
/** Default visibility level chosen in the post composer. */
|
|
24
|
-
defaultPostVisibility: visibilityLevelSchema,
|
|
25
23
|
/** Free-text bio shown on the profile (nullable so the user can clear it). */
|
|
26
24
|
bio: z.string().max(PROFILE_MAX_BIO_CHARS).nullable(),
|
|
27
25
|
/** How many users the caller has blocked. The full list lives behind
|
|
@@ -59,7 +57,6 @@ export const communitySettingsWireSchema = z.object({
|
|
|
59
57
|
*/
|
|
60
58
|
export const updateCommunitySettingsBodySchema = z.object({
|
|
61
59
|
privacy: profilePrivacySchema.optional(),
|
|
62
|
-
defaultPostVisibility: visibilityLevelSchema.optional(),
|
|
63
60
|
bio: z.string().max(PROFILE_MAX_BIO_CHARS).nullable().optional(),
|
|
64
61
|
notifications: z
|
|
65
62
|
.object({
|
|
@@ -93,7 +90,6 @@ export const blockedUsersListResponseSchema = z.object({
|
|
|
93
90
|
// ─── Defaults (used by the backend when a user has no settings doc yet) ────
|
|
94
91
|
export const COMMUNITY_SETTINGS_DEFAULTS = {
|
|
95
92
|
privacy: 'public',
|
|
96
|
-
defaultPostVisibility: 'local',
|
|
97
93
|
bio: null,
|
|
98
94
|
blockedCount: 0,
|
|
99
95
|
notifications: {
|
package/dist/settings.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"settings.js","sourceRoot":"","sources":["../src/settings.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AACvD,OAAO,EAAE,oBAAoB,EAAE,
|
|
1
|
+
{"version":3,"file":"settings.js","sourceRoot":"","sources":["../src/settings.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAA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E,IAAI;QACzB,oBAAoB,EAAE,IAAI;QAC1B,SAAS,EAAE,IAAI;QACf,OAAO,EAAE,IAAI;QACb,QAAQ,EAAE,KAAK;QACf,UAAU,EAAE,KAAK;QACjB,eAAe,EAAE,IAAI;KACtB;CACF,CAAC","sourcesContent":["/**\n * Community settings wire shape.\n *\n * Per-user preferences scoped to the community feature. Read from\n * `GET /api/v1/community/settings` and updated via\n * `PATCH /api/v1/community/settings`. Updates are partial — the client\n * sends only the fields it changes.\n *\n * Block list management has dedicated routes (POST / DELETE\n * `/settings/blocks/:userId`); only the COUNT is mirrored on the\n * settings shape so the Settings page can show \"N blocked users\"\n * without a second round-trip. The full list is read via\n * `GET /settings/blocks`.\n *\n * @module community-schema/settings\n */\n\nimport { z } from 'zod';\nimport { PROFILE_MAX_BIO_CHARS } from './constants.js';\nimport { profilePrivacySchema } from './enums.js';\n\nexport const communitySettingsWireSchema = z.object({\n /** Profile-level privacy toggle. */\n privacy: profilePrivacySchema,\n /** Free-text bio shown on the profile (nullable so the user can clear it). */\n bio: z.string().max(PROFILE_MAX_BIO_CHARS).nullable(),\n /** How many users the caller has blocked. The full list lives behind\n * `GET /settings/blocks` to keep this hot read small. */\n blockedCount: z.number().int().nonnegative(),\n /** Per-event notification toggles. The map is sparse: a missing key\n * means \"use the default\". */\n notifications: z.object({\n /** Notify me when someone follows me. */\n onFollow: z.boolean(),\n /** Notify me when someone sends me a connection request. */\n onConnectionRequest: z.boolean(),\n /** Notify me when someone accepts my connection request. */\n onConnectionAccepted: z.boolean(),\n /** Notify me when someone comments on my post / lost-found / voice-box. */\n onComment: z.boolean(),\n /** Notify me when someone replies to my comment. */\n onReply: z.boolean(),\n /** Notify me when someone upvotes my content. */\n onUpvote: z.boolean(),\n /** Notify me when someone reacts to my content. */\n onReaction: z.boolean(),\n /** Notify me about activity in groups I'm a member of. */\n onGroupActivity: z.boolean(),\n }),\n});\nexport type CommunitySettingsWire = z.infer<typeof communitySettingsWireSchema>;\n\n/**\n * PATCH body — every field optional. The server merges over the existing\n * settings. Notifications is a partial sub-shape so the client can\n * toggle one knob at a time.\n *\n * `bio` accepts `null` to clear; omit the key entirely to leave it\n * unchanged. Block list is NOT included here — see the dedicated\n * `/settings/blocks` routes.\n */\nexport const updateCommunitySettingsBodySchema = z.object({\n privacy: profilePrivacySchema.optional(),\n bio: z.string().max(PROFILE_MAX_BIO_CHARS).nullable().optional(),\n notifications: z\n .object({\n onFollow: z.boolean().optional(),\n onConnectionRequest: z.boolean().optional(),\n onConnectionAccepted: z.boolean().optional(),\n onComment: z.boolean().optional(),\n onReply: z.boolean().optional(),\n onUpvote: z.boolean().optional(),\n onReaction: z.boolean().optional(),\n onGroupActivity: z.boolean().optional(),\n })\n .optional(),\n});\nexport type UpdateCommunitySettingsBody = z.infer<typeof updateCommunitySettingsBodySchema>;\n\n// ─── Blocked users list ────────────────────────────────────────────────────\n\n/**\n * One row in `GET /settings/blocks`. Mirrors the PeopleListItem shape\n * minus the per-viewer social state (the caller's viewer state w.r.t.\n * a blocked user is always \"blocked\").\n */\nexport const blockedUserWireSchema = z.object({\n userId: z.string(),\n displayName: z.string(),\n avatarUrl: z.string().url().optional(),\n localName: z.string().optional(),\n blockedAt: z.string().datetime(),\n});\nexport type BlockedUserWire = z.infer<typeof blockedUserWireSchema>;\n\nexport const blockedUsersListResponseSchema = z.object({\n items: z.array(blockedUserWireSchema),\n});\nexport type BlockedUsersListResponse = z.infer<typeof blockedUsersListResponseSchema>;\n\n// ─── Defaults (used by the backend when a user has no settings doc yet) ────\n\nexport const COMMUNITY_SETTINGS_DEFAULTS: CommunitySettingsWire = {\n privacy: 'public',\n bio: null,\n blockedCount: 0,\n notifications: {\n onFollow: true,\n onConnectionRequest: true,\n onConnectionAccepted: true,\n onComment: true,\n onReply: true,\n onUpvote: false,\n onReaction: false,\n onGroupActivity: true,\n },\n};\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "jansathi-community-schema",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"description": "Shared Zod schemas + TypeScript types for the Jansathi hyperlocal community feature (feed, posts, engagement, social graph, groups, communities).",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|