Coverage for functions \ flipdare \ generated \ model \ chat_model.py: 100%
0 statements
« prev ^ index » next coverage.py v7.13.0, created at 2026-05-08 12:22 +1000
« prev ^ index » next coverage.py v7.13.0, created at 2026-05-08 12:22 +1000
1#!/usr/bin/env python
2#
3# Copyright (c) 2026 Flipdare Pty Ltd. All rights reserved.
4#
5# This file is part of Flipdare's proprietary software and contains
6# confidential and copyrighted material. Unauthorised copying,
7# modification, distribution, or use of this file is strictly
8# prohibited without prior written permission from Flipdare Pty Ltd.
9#
10# This software includes third-party components licensed under MIT,
11# BSD, and Apache 2.0 licences. See THIRD_PARTY_NOTICES for details.
12#
13# NOTE: THIS FILE IS AUTO GENERATED. DO NOT EDIT.
14#
15# Generated by codegen_models.py
16#
17# Modify 'codegen_models.py'
18# and re-run the script above to update.
19#
20# pragma: no cover
21from __future__ import annotations
22from datetime import datetime
23from google.cloud.firestore_v1.transforms import Sentinel
24from flipdare.core.firestore_field import FirestoreField
25from flipdare.util.time_util import FirestoreTime
26from typing import Any, TypedDict, cast, Unpack
27from enum import StrEnum
28from pydantic import Field, ConfigDict, TypeAdapter
29from flipdare.firestore.core.app_base_model import AppBaseModel
30from flipdare.generated.shared.model.model_obj_type import ModelObjType
33class ChatKeys(StrEnum):
34 ID = "id"
35 CREATED_AT = "created_at"
36 UPDATED_AT = "updated_at"
37 UID = "uid"
38 OBJ_ID = "obj_id"
39 OBJ_TYPE = "obj_type"
40 SLUG_CODE = "slug_code"
41 COMMENT_COUNT = "comment_count"
42 VERSION = "version"
43 PROCESSED = "processed"
44 ERROR_COUNT = "error_count"
47# !! IMPORTANT !!
48# !!
49# !! this should only be used in the database to query.
50# !!
51class ChatInternalKeys(StrEnum):
52 CREATED_AT = "created_at"
53 UPDATED_AT = "updated_at"
54 VERSION = "VERSION"
55 PROCESSED = "INT_P"
56 ERROR_COUNT = "INT_E"
59class ChatModel(AppBaseModel):
60 """Represents a chat message in the system, which can be associated with various objects such as dares, groups, or events."""
62 model_config = ConfigDict(populate_by_name=True, arbitrary_types_allowed=True)
64 id: str | None = Field(None, alias="id")
65 created_at: FirestoreField = Field(
66 default_factory=cast("Any", lambda: FirestoreTime.server_timestamp())
67 )
68 updated_at: FirestoreField = Field(
69 default_factory=cast("Any", lambda: FirestoreTime.server_timestamp())
70 )
71 uid: str
72 obj_id: str
73 obj_type: ModelObjType
74 slug_code: str
75 comment_count: int = Field(default=0)
76 # Version (base internal field)
77 version: int = Field(default=1, alias="VERSION")
78 # Processed (base internal field)
79 processed: bool = Field(default=False, alias="INT_P")
80 # Error Count (base internal field)
81 error_count: int = Field(default=0, alias="INT_E")
83 @classmethod
84 def validate_partial(cls, **data: Unpack[ChatDict]) -> dict[str, Any]:
85 """
86 Uses Unpack to give you autocomplete and static warnings
87 if you pass an invalid key or type in your code.
89 Returns a dict with Firestore field names (aliases) for use with batch.update().
90 """
91 result: dict[str, Any] = {}
92 for k, v in data.items():
93 if k in cls.__pydantic_fields__:
94 field_info = cls.__pydantic_fields__[k]
95 validated_value = cast(
96 "Any",
97 TypeAdapter(field_info.annotation).validate_python(v),
98 )
99 # Use alias if defined, otherwise use field name
100 output_key = field_info.alias or k
101 result[output_key] = validated_value
102 return result
105CHAT_FIELD_NAMES: list[str] = list(ChatModel.model_fields.keys())
108class ChatDict(TypedDict, total=False):
109 id: str | None
110 created_at: Sentinel | datetime | str
111 updated_at: Sentinel | datetime | str
112 uid: str
113 obj_id: str
114 obj_type: ModelObjType
115 slug_code: str
116 comment_count: int | None
117 VERSION: int | None
118 INT_P: bool | None
119 INT_E: int | None