Cap feedback at 10 per user with clustered admin views, and redesign /social/team as a denser job board. Co-authored-by: Cursor <cursoragent@cursor.com>
575 lines
12 KiB
Python
575 lines
12 KiB
Python
"""PocketBase collection schemas for Nomadro verticals (admin API create)."""
|
|
from __future__ import annotations
|
|
|
|
from typing import Any
|
|
|
|
|
|
def _text(name: str, required: bool = False, max_len: int | None = None) -> dict[str, Any]:
|
|
f: dict[str, Any] = {"name": name, "type": "text", "required": required}
|
|
if max_len:
|
|
f["max"] = max_len
|
|
return f
|
|
|
|
|
|
def _num(name: str, required: bool = False) -> dict[str, Any]:
|
|
return {"name": name, "type": "number", "required": required}
|
|
|
|
|
|
def _bool(name: str, required: bool = False) -> dict[str, Any]:
|
|
return {"name": name, "type": "bool", "required": required}
|
|
|
|
|
|
def _json(name: str, required: bool = False, max_size: int = 2_000_000) -> dict[str, Any]:
|
|
# PB ≥0.22 requires options.maxSize for json fields
|
|
return {
|
|
"name": name,
|
|
"type": "json",
|
|
"required": required,
|
|
"options": {"maxSize": max_size},
|
|
"maxSize": max_size,
|
|
}
|
|
|
|
|
|
def _base(name: str, fields: list[dict[str, Any]], indexes: list[str] | None = None) -> dict[str, Any]:
|
|
body: dict[str, Any] = {
|
|
"name": name,
|
|
"type": "base",
|
|
"listRule": "",
|
|
"viewRule": "",
|
|
"createRule": "",
|
|
"updateRule": "",
|
|
"deleteRule": "",
|
|
"fields": fields,
|
|
}
|
|
if indexes:
|
|
body["indexes"] = indexes
|
|
return body
|
|
|
|
|
|
# —— Social ——
|
|
SOCIAL_ROSTER = _base(
|
|
"social_roster",
|
|
[
|
|
_text("guest_id", True),
|
|
_text("name", True),
|
|
_text("title"),
|
|
_text("city"),
|
|
_text("phone"),
|
|
_text("linktree"),
|
|
_text("skills"),
|
|
_text("bio"),
|
|
_text("avatar"),
|
|
_text("gender"),
|
|
_text("intents"),
|
|
_text("availability"),
|
|
_text("status"),
|
|
_text("looking_for"),
|
|
_text("relationship"),
|
|
_text("education"),
|
|
_text("graduation"),
|
|
_text("wechat"),
|
|
_bool("discoverable"),
|
|
_bool("face_ok"),
|
|
_text("liveness_status"),
|
|
_text("liveness_at"),
|
|
_text("liveness_video_url"),
|
|
_text("liveness_front_url"),
|
|
_text("liveness_turn_url"),
|
|
_text("onboarded_at"),
|
|
_text("updated_at", True),
|
|
],
|
|
indexes=[
|
|
"CREATE UNIQUE INDEX idx_social_roster_guest ON social_roster (guest_id)",
|
|
"CREATE INDEX idx_social_roster_city ON social_roster (city)",
|
|
],
|
|
)
|
|
|
|
SOCIAL_LIVENESS = _base(
|
|
"social_liveness_audits",
|
|
[
|
|
_text("guest_id", True),
|
|
_text("avatar_url"),
|
|
_text("front_url"),
|
|
_text("turn_url"),
|
|
_text("video_url"),
|
|
_num("video_size"),
|
|
_num("similarity"),
|
|
_num("yaw_delta"),
|
|
_text("status"),
|
|
_json("meta"),
|
|
_text("created_at", True),
|
|
],
|
|
indexes=["CREATE INDEX idx_social_live_guest ON social_liveness_audits (guest_id)"],
|
|
)
|
|
|
|
SOCIAL_SKILLS = _base(
|
|
"social_skill_posts",
|
|
[
|
|
_text("guest_id", True),
|
|
_text("author", True),
|
|
_text("city"),
|
|
_text("offer", True),
|
|
_text("want", True),
|
|
_text("note"),
|
|
_text("status"),
|
|
_text("created_at", True),
|
|
],
|
|
indexes=["CREATE INDEX idx_social_skill_city ON social_skill_posts (city)"],
|
|
)
|
|
|
|
SOCIAL_REVIEWS = _base(
|
|
"social_meetup_reviews",
|
|
[
|
|
_text("booking_id"),
|
|
_text("from_guest", True),
|
|
_text("to_guest", True),
|
|
_text("to_name"),
|
|
_num("punctuality", True),
|
|
_num("chemistry", True),
|
|
_num("professionalism", True),
|
|
_text("text"),
|
|
_text("created_at", True),
|
|
],
|
|
indexes=["CREATE INDEX idx_social_rev_to ON social_meetup_reviews (to_guest)"],
|
|
)
|
|
|
|
SOCIAL_BLOCKS = _base(
|
|
"social_blocks",
|
|
[
|
|
_text("guest_id", True),
|
|
_text("blocked_guest", True),
|
|
_text("reason"),
|
|
_text("created_at", True),
|
|
],
|
|
)
|
|
|
|
SOCIAL_REPORTS = _base(
|
|
"social_reports",
|
|
[
|
|
_text("guest_id", True),
|
|
_text("target_guest", True),
|
|
_text("target_name"),
|
|
_text("reason", True),
|
|
_text("detail"),
|
|
_text("status"),
|
|
_text("result_note"),
|
|
_text("created_at", True),
|
|
_text("resolved_at"),
|
|
],
|
|
)
|
|
|
|
SOCIAL_MESSAGES = _base(
|
|
"social_messages",
|
|
[
|
|
_text("channel_id", True),
|
|
_num("seq", True),
|
|
_text("guest_id", True),
|
|
_text("nick"),
|
|
_text("text"),
|
|
_text("kind"),
|
|
_json("meta"),
|
|
_json("attachments"),
|
|
_json("reply_to"),
|
|
_json("reactions"),
|
|
_bool("pinned"),
|
|
_bool("recalled"),
|
|
_text("created_at", True),
|
|
_text("edited_at"),
|
|
],
|
|
indexes=[
|
|
"CREATE INDEX idx_social_msg_ch ON social_messages (channel_id)",
|
|
"CREATE INDEX idx_social_msg_seq ON social_messages (channel_id, seq)",
|
|
],
|
|
)
|
|
|
|
SOCIAL_CHANNEL_META = _base(
|
|
"social_channel_meta",
|
|
[
|
|
_text("channel_id", True),
|
|
_num("seq"),
|
|
_json("pins"),
|
|
_json("presence"),
|
|
_json("reads"),
|
|
_text("updated_at"),
|
|
],
|
|
indexes=["CREATE UNIQUE INDEX idx_social_chmeta ON social_channel_meta (channel_id)"],
|
|
)
|
|
|
|
SOCIAL_CHANNEL_READS = _base(
|
|
"social_channel_reads",
|
|
[
|
|
_text("guest_id", True),
|
|
_text("channel_id", True),
|
|
_num("recv_seq"),
|
|
_num("read_seq"),
|
|
_text("updated_at"),
|
|
],
|
|
indexes=[
|
|
"CREATE UNIQUE INDEX idx_social_chread ON social_channel_reads (guest_id, channel_id)",
|
|
],
|
|
)
|
|
|
|
SOCIAL_FILES = _base(
|
|
"social_files",
|
|
[
|
|
_text("file_id", True),
|
|
_text("channel_id", True),
|
|
_text("guest_id"),
|
|
_text("kind"),
|
|
_text("name"),
|
|
_text("mime"),
|
|
_num("size"),
|
|
_text("path"),
|
|
_text("created_at", True),
|
|
],
|
|
indexes=["CREATE UNIQUE INDEX idx_social_files ON social_files (file_id)"],
|
|
)
|
|
|
|
SOCIAL_TRIPS = _base(
|
|
"social_trips",
|
|
[
|
|
_text("guest_id", True),
|
|
_text("city_id"),
|
|
_text("city", True),
|
|
_text("country"),
|
|
_num("lat"),
|
|
_num("lng"),
|
|
_text("h3_cell"),
|
|
_text("arrival_date"),
|
|
_text("departure_date"),
|
|
_text("visibility"),
|
|
_text("status"),
|
|
_text("updated_at", True),
|
|
],
|
|
indexes=[
|
|
"CREATE INDEX idx_social_trips_guest ON social_trips (guest_id)",
|
|
"CREATE INDEX idx_social_trips_city ON social_trips (city_id)",
|
|
],
|
|
)
|
|
|
|
SOCIAL_CAFE_REVIEWS = _base(
|
|
"social_cafe_reviews",
|
|
[
|
|
_text("cafe_id", True),
|
|
_text("guest_id"),
|
|
_text("author"),
|
|
_num("score"),
|
|
_text("text"),
|
|
_text("photo_note"),
|
|
_text("created_at", True),
|
|
],
|
|
)
|
|
|
|
SOCIAL_FEEDBACK = _base(
|
|
"social_feedback",
|
|
[
|
|
_text("guest_id"),
|
|
_text("user_key"),
|
|
_text("kind"),
|
|
_text("text"),
|
|
_text("contact"),
|
|
_json("images"),
|
|
_json("meta"),
|
|
_text("created_at", True),
|
|
],
|
|
indexes=[
|
|
"CREATE INDEX idx_social_feedback_user ON social_feedback (user_key)",
|
|
"CREATE INDEX idx_social_feedback_guest ON social_feedback (guest_id)",
|
|
],
|
|
)
|
|
|
|
# Join funnel leads — email click onwards (test-phase archive for admin)
|
|
SOCIAL_JOIN_LEADS = _base(
|
|
"social_join_leads",
|
|
[
|
|
_text("email", True),
|
|
_text("guest_id"),
|
|
_text("stage"),
|
|
_text("name"),
|
|
_json("payload"),
|
|
_text("ua"),
|
|
_text("paid"),
|
|
_text("face_ok"),
|
|
_text("liveness_status"),
|
|
_text("created_at", True),
|
|
_text("updated_at", True),
|
|
],
|
|
indexes=[
|
|
"CREATE UNIQUE INDEX idx_social_join_email ON social_join_leads (email)",
|
|
"CREATE INDEX idx_social_join_guest ON social_join_leads (guest_id)",
|
|
"CREATE INDEX idx_social_join_at ON social_join_leads (updated_at)",
|
|
],
|
|
)
|
|
|
|
SOCIAL_GIG_APPS = _base(
|
|
"social_gig_apps",
|
|
[
|
|
_text("gig_id", True),
|
|
_text("guest_id"),
|
|
_text("name"),
|
|
_text("contact"),
|
|
_text("note"),
|
|
_text("request_id"),
|
|
_text("created_at", True),
|
|
],
|
|
)
|
|
|
|
# Immutable audit trail — never hard-delete user content without a snapshot here.
|
|
SOCIAL_ARCHIVES = _base(
|
|
"social_archives",
|
|
[
|
|
_text("entity", True),
|
|
_text("entity_id", True),
|
|
_text("guest_id"),
|
|
_text("action", True),
|
|
_json("payload"),
|
|
_text("note"),
|
|
_text("created_at", True),
|
|
],
|
|
indexes=[
|
|
"CREATE INDEX idx_social_arch_entity ON social_archives (entity, entity_id)",
|
|
"CREATE INDEX idx_social_arch_guest ON social_archives (guest_id)",
|
|
"CREATE INDEX idx_social_arch_at ON social_archives (created_at)",
|
|
],
|
|
)
|
|
|
|
# —— Coffee ——
|
|
COFFEE_HOSTS = _base(
|
|
"coffee_hosts",
|
|
[
|
|
_text("username", True),
|
|
_text("owner_key_hash"),
|
|
_text("name", True),
|
|
_text("bio"),
|
|
_text("avatar"),
|
|
_text("city"),
|
|
_text("timezone"),
|
|
_text("created_at", True),
|
|
],
|
|
indexes=["CREATE UNIQUE INDEX idx_coffee_host_user ON coffee_hosts (username)"],
|
|
)
|
|
|
|
COFFEE_SCHEDULES = _base(
|
|
"coffee_schedules",
|
|
[
|
|
_text("host_id", True),
|
|
_text("name"),
|
|
_text("timezone"),
|
|
_json("availability"),
|
|
_text("created_at", True),
|
|
],
|
|
)
|
|
|
|
COFFEE_EVENT_TYPES = _base(
|
|
"coffee_event_types",
|
|
[
|
|
_text("host_id", True),
|
|
_text("schedule_id"),
|
|
_text("slug", True),
|
|
_text("title", True),
|
|
_text("description"),
|
|
_num("length_minutes"),
|
|
_num("slot_interval"),
|
|
_num("buffer_before"),
|
|
_num("buffer_after"),
|
|
_json("locations"),
|
|
_bool("active"),
|
|
_text("created_at", True),
|
|
],
|
|
)
|
|
|
|
COFFEE_BOOKINGS = _base(
|
|
"coffee_bookings",
|
|
[
|
|
_text("uid", True),
|
|
_text("event_type_id"),
|
|
_text("host_id", True),
|
|
_text("title"),
|
|
_text("status"),
|
|
_text("start_utc"),
|
|
_text("end_utc"),
|
|
_text("location"),
|
|
_text("notes"),
|
|
_text("attendee_name"),
|
|
_text("attendee_email"),
|
|
_text("attendee_device"),
|
|
_text("attendee_key_hash"),
|
|
_text("created_at", True),
|
|
_text("cancelled_at"),
|
|
],
|
|
)
|
|
|
|
# —— Notify ——
|
|
NOTIFY_SUBSCRIBERS = _base(
|
|
"notify_subscribers",
|
|
[
|
|
_text("subscriber_id", True),
|
|
_text("email"),
|
|
_text("phone"),
|
|
_text("first_name"),
|
|
_text("last_name"),
|
|
_text("avatar"),
|
|
_text("locale"),
|
|
_json("data"),
|
|
_text("created_at", True),
|
|
_text("updated_at"),
|
|
],
|
|
indexes=["CREATE UNIQUE INDEX idx_notify_sub ON notify_subscribers (subscriber_id)"],
|
|
)
|
|
|
|
NOTIFY_TOPICS = _base(
|
|
"notify_topics",
|
|
[
|
|
_text("key", True),
|
|
_text("name", True),
|
|
_json("subscribers"),
|
|
_text("created_at", True),
|
|
],
|
|
indexes=["CREATE UNIQUE INDEX idx_notify_topic ON notify_topics (key)"],
|
|
)
|
|
|
|
NOTIFY_WORKFLOWS = _base(
|
|
"notify_workflows",
|
|
[
|
|
_text("workflow_id", True),
|
|
_text("name", True),
|
|
_text("description"),
|
|
_bool("active"),
|
|
_json("tags"),
|
|
_json("steps"),
|
|
_text("created_at", True),
|
|
_text("updated_at"),
|
|
],
|
|
indexes=["CREATE UNIQUE INDEX idx_notify_wf ON notify_workflows (workflow_id)"],
|
|
)
|
|
|
|
NOTIFY_PREFS = _base(
|
|
"notify_preferences",
|
|
[
|
|
_text("subscriber_id", True),
|
|
_json("channels"),
|
|
_text("updated_at"),
|
|
],
|
|
indexes=["CREATE UNIQUE INDEX idx_notify_prefs ON notify_preferences (subscriber_id)"],
|
|
)
|
|
|
|
NOTIFY_MESSAGES = _base(
|
|
"notify_messages",
|
|
[
|
|
_text("subscriber_id", True),
|
|
_text("notification_id"),
|
|
_text("channel"),
|
|
_text("category"),
|
|
_text("subject"),
|
|
_text("body"),
|
|
_text("cta_label"),
|
|
_text("cta_url"),
|
|
_text("href"),
|
|
_json("payload"),
|
|
_bool("read"),
|
|
_bool("archived"),
|
|
_bool("deleted"),
|
|
_text("created_at", True),
|
|
],
|
|
indexes=["CREATE INDEX idx_notify_inbox ON notify_messages (subscriber_id)"],
|
|
)
|
|
|
|
NOTIFY_ACTIVITY = _base(
|
|
"notify_activity",
|
|
[
|
|
_text("status"),
|
|
_text("subscriber_id"),
|
|
_text("workflow_id"),
|
|
_text("workflow_name"),
|
|
_text("transaction_id"),
|
|
_json("payload"),
|
|
_json("jobs"),
|
|
_text("created_at", True),
|
|
],
|
|
)
|
|
|
|
NOTIFY_INTEGRATIONS = _base(
|
|
"notify_integrations",
|
|
[
|
|
_text("channel", True),
|
|
_text("provider"),
|
|
_bool("active"),
|
|
_json("config"),
|
|
_text("created_at", True),
|
|
],
|
|
)
|
|
|
|
# —— Work (document-oriented board blob + pads) ——
|
|
WORK_PROJECTS = _base(
|
|
"work_projects",
|
|
[
|
|
_text("name", True),
|
|
_text("description"),
|
|
_text("background_type"),
|
|
_text("background_gradient"),
|
|
_text("board_id"),
|
|
_text("created_at", True),
|
|
_text("updated_at"),
|
|
],
|
|
)
|
|
|
|
WORK_BOARDS = _base(
|
|
"work_boards",
|
|
[
|
|
_text("project_id", True),
|
|
_text("name", True),
|
|
_num("position"),
|
|
_text("default_view"),
|
|
_text("background_gradient"),
|
|
_bool("show_card_counter"),
|
|
_json("doc"),
|
|
_text("created_at", True),
|
|
_text("updated_at"),
|
|
],
|
|
)
|
|
|
|
WORK_PADS = _base(
|
|
"work_pads",
|
|
[
|
|
_text("title", True),
|
|
_text("text"),
|
|
_json("authors"),
|
|
_json("revisions"),
|
|
_text("created_at", True),
|
|
_text("updated_at"),
|
|
],
|
|
)
|
|
|
|
ALL_COLLECTIONS: list[dict[str, Any]] = [
|
|
SOCIAL_ROSTER,
|
|
SOCIAL_LIVENESS,
|
|
SOCIAL_SKILLS,
|
|
SOCIAL_REVIEWS,
|
|
SOCIAL_BLOCKS,
|
|
SOCIAL_REPORTS,
|
|
SOCIAL_MESSAGES,
|
|
SOCIAL_CHANNEL_META,
|
|
SOCIAL_CHANNEL_READS,
|
|
SOCIAL_FILES,
|
|
SOCIAL_TRIPS,
|
|
SOCIAL_CAFE_REVIEWS,
|
|
SOCIAL_FEEDBACK,
|
|
SOCIAL_JOIN_LEADS,
|
|
SOCIAL_GIG_APPS,
|
|
SOCIAL_ARCHIVES,
|
|
COFFEE_HOSTS,
|
|
COFFEE_SCHEDULES,
|
|
COFFEE_EVENT_TYPES,
|
|
COFFEE_BOOKINGS,
|
|
NOTIFY_SUBSCRIBERS,
|
|
NOTIFY_TOPICS,
|
|
NOTIFY_WORKFLOWS,
|
|
NOTIFY_PREFS,
|
|
NOTIFY_MESSAGES,
|
|
NOTIFY_ACTIVITY,
|
|
NOTIFY_INTEGRATIONS,
|
|
WORK_PROJECTS,
|
|
WORK_BOARDS,
|
|
WORK_PADS,
|
|
]
|