Coverage for functions \ flipdare \ generated \ model \ chat_comment_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.model.internal.image_model import ImageModel, ImageDict
31from flipdare.generated.model.internal.video_model import VideoModel, VideoDict
32from flipdare.generated.model.payment.pledge_model import PledgeModel, PledgeDict
35class ChatCommentKeys(StrEnum):
36 ID = "id"
37 UPDATED_AT = "updated_at"
38 CREATED_AT = "created_at"
39 FROM_UID = "from_uid"
40 TO_UID = "to_uid"
41 IS_ADMIN = "is_admin"
42 MESSAGE = "message"
43 IMAGE = "image"
44 VIDEO = "video"
45 PLEDGE = "pledge"
46 ADMIN_BLOCK_REASON = "admin_block_reason"
47 VERSION = "version"
48 PROCESSED = "processed"
49 ERROR_COUNT = "error_count"
52# !! IMPORTANT !!
53# !!
54# !! this should only be used in the database to query.
55# !!
56class ChatCommentInternalKeys(StrEnum):
57 UPDATED_AT = "updated_at"
58 CREATED_AT = "created_at"
59 VERSION = "VERSION"
60 PROCESSED = "INT_P"
61 ERROR_COUNT = "INT_E"
64class ChatCommentModel(AppBaseModel):
65 """Chat Comment Model"""
67 model_config = ConfigDict(populate_by_name=True, arbitrary_types_allowed=True)
69 id: str | None = Field(None, alias="id")
70 updated_at: FirestoreField = Field(
71 default_factory=cast("Any", lambda: FirestoreTime.server_timestamp())
72 )
73 created_at: FirestoreField = Field(
74 default_factory=cast("Any", lambda: FirestoreTime.server_timestamp())
75 )
76 from_uid: str
77 to_uid: str | None = None
78 is_admin: bool = Field(default=False)
79 message: str | None = None
80 image: ImageModel | None = None
81 video: VideoModel | None = None
82 pledge: PledgeModel | None = None
83 admin_block_reason: str | None = None
84 # Version (base internal field)
85 version: int = Field(default=1, alias="VERSION")
86 # Processed (base internal field)
87 processed: bool = Field(default=False, alias="INT_P")
88 # Error Count (base internal field)
89 error_count: int = Field(default=0, alias="INT_E")
91 @classmethod
92 def validate_partial(cls, **data: Unpack[ChatCommentDict]) -> dict[str, Any]:
93 """
94 Uses Unpack to give you autocomplete and static warnings
95 if you pass an invalid key or type in your code.
97 Returns a dict with Firestore field names (aliases) for use with batch.update().
98 """
99 result: dict[str, Any] = {}
100 for k, v in data.items():
101 if k in cls.__pydantic_fields__:
102 field_info = cls.__pydantic_fields__[k]
103 validated_value = cast(
104 "Any",
105 TypeAdapter(field_info.annotation).validate_python(v),
106 )
107 # Use alias if defined, otherwise use field name
108 output_key = field_info.alias or k
109 result[output_key] = validated_value
110 return result
113CHATCOMMENT_FIELD_NAMES: list[str] = list(ChatCommentModel.model_fields.keys())
116class ChatCommentDict(TypedDict, total=False):
117 id: str | None
118 updated_at: Sentinel | datetime | str
119 created_at: Sentinel | datetime | str
120 from_uid: str
121 to_uid: str | None
122 is_admin: bool | None
123 message: str | None
124 image: ImageDict | None
125 video: VideoDict | None
126 pledge: PledgeDict | None
127 admin_block_reason: str | None
128 VERSION: int | None
129 INT_P: bool | None
130 INT_E: int | None