Coverage for functions \ flipdare \ app_types.py: 100%
46 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# Copyright (c) 2026 Flipdare Pty Ltd. All rights reserved.
3#
4# This file is part of Flipdare's proprietary software and contains
5# confidential and copyrighted material. Unauthorised copying,
6# modification, distribution, or use of this file is strictly
7# prohibited without prior written permission from Flipdare Pty Ltd.
8#
9# This software includes third-party components licensed under MIT,
10# BSD, and Apache 2.0 licences. See THIRD_PARTY_NOTICES for details.
11#
13from __future__ import annotations
14from typing import TYPE_CHECKING, Any
15from collections.abc import Mapping
16from datetime import datetime
17import numpy as np
18import numpy.typing as npt
19from google.api_core.datetime_helpers import DatetimeWithNanoseconds
20from google.cloud.firestore_v1.transforms import Sentinel
21from google.cloud.firestore_v1.base_document import DocumentSnapshot
22from firebase_functions.core import Change
23from firebase_functions.firestore_fn import Event
25if TYPE_CHECKING:
26 from flipdare.generated.shared.backend.app_job_type import AppJobType
27 from flipdare.generated.shared.firestore_collections import FirestoreCollections
28 from flipdare.firestore.invite_db import InviteDb
29 from flipdare.result.output_result import OutputResult
30 from flipdare.result.job_result import JobResult
31 from flipdare.firestore.backend.compliance_db import ComplianceDb
32 from flipdare.firestore.chat_db import ChatDb
33 from flipdare.firestore.content_db import ContentDb
34 from flipdare.firestore.context.group_context import GroupContext
35 from flipdare.firestore.dare_db import DareDb
36 from flipdare.firestore.db_bridge import DbBridge
37 from flipdare.firestore.flag_db import FlagDb
38 from flipdare.firestore.friend_db import FriendDb
39 from flipdare.firestore.group_db import GroupDb
40 from flipdare.firestore.pledge_db import PledgeDb
41 from flipdare.firestore.restriction_db import RestrictionDb
42 from flipdare.firestore.user_db import UserDb
43 from flipdare.generated.model.backend.metric.count_metric import CountMetric
44 from flipdare.generated.model.backend.metric.outcome_metric import OutcomeMetric
45 from flipdare.wrapper.backend.compliance_wrapper import ComplianceWrapper
46 from flipdare.wrapper.chat_wrapper import ChatWrapper
47 from flipdare.wrapper.content_wrapper import ContentWrapper
48 from flipdare.wrapper.dare_wrapper import DareWrapper
49 from flipdare.wrapper.friend_wrapper import FriendWrapper
50 from flipdare.wrapper.group_wrapper import GroupWrapper
51 from flipdare.wrapper.invite_wrapper import InviteWrapper
52 from flipdare.wrapper.issue.flag_wrapper import FlagWrapper
53 from flipdare.wrapper.issue.restriction_wrapper import RestrictionWrapper
54 from flipdare.wrapper.payment.pledge_wrapper import PledgeWrapper
55 from flipdare.wrapper.user_wrapper import UserWrapper
57__all__ = [
58 "DatabaseDict",
59 "JsonDict",
60 "DatabaseTimeType",
61 "ReportListType",
62 "GroupObjectType",
63 "SearchDict",
64 "TypesenseDict",
65 "SchemaDict",
66 "BaseEventType",
67 "UpdateEventType",
68 "EventType",
69 "EventDataType",
70 "UserBridge",
71 "FriendBridge",
72 "GroupBridge",
73 "InviteBridge",
74 "DareBridge",
75 "RestrictionBridge",
76 "FlagBridge",
77 "ContentBridge",
78 "ComplianceBridge",
79 "PledgeBridge",
80 "ChatBridge",
81 "JinjaDataType",
82 "NdFloatArrayType",
83 "AnalysisArrayType",
84 "AnalysisDataType",
85 "LabelledSeriesType",
86 "StatSource",
87 "CronResult",
88 "TriggerResult",
89 "StatMetric",
90]
93#
94# firestore
95#
96type DatabaseDict = dict[str, Any]
97type JsonDict = dict[str, Any]
98type CallableDict = Mapping[str, Any]
99type DatabaseTimeType = Sentinel | datetime | str | DatetimeWithNanoseconds | None
100type GroupObjectType = GroupContext | GroupWrapper | DatabaseDict | str
102#
103# for typesense, read only
104#
105type SearchDict = dict[str, Any]
106type TypesenseDict = Mapping[str, Any]
107type SchemaDict = Mapping[str, Any]
109#
110# event types
111#
112type BaseEventType = Event[DocumentSnapshot | None]
113type UpdateEventType = Event[Change[DocumentSnapshot | None]]
114type EventType = BaseEventType | UpdateEventType
115type EventDataType = dict[Any, Any] | DocumentSnapshot | Change[DocumentSnapshot | None] | None
117#
118# bridges
119#
120type UserBridge = DbBridge[UserWrapper, UserDb]
121type FriendBridge = DbBridge[FriendWrapper, FriendDb]
122type GroupBridge = DbBridge[GroupWrapper, GroupDb]
123type InviteBridge = DbBridge[InviteWrapper, InviteDb]
124type DareBridge = DbBridge[DareWrapper, DareDb]
125type RestrictionBridge = DbBridge[RestrictionWrapper, RestrictionDb]
126type FlagBridge = DbBridge[FlagWrapper, FlagDb]
127type ContentBridge = DbBridge[ContentWrapper, ContentDb]
128type ComplianceBridge = DbBridge[ComplianceWrapper, ComplianceDb]
129type PledgeBridge = DbBridge[PledgeWrapper, PledgeDb]
130type ChatBridge = DbBridge[ChatWrapper, ChatDb]
132#
133# email
134#
135type JinjaDataType = dict[str, Any] | list[dict[str, Any]]
137#
138# cron / trigger
139#
140type CronResult = CountMetric | OutcomeMetric | OutputResult
141type TriggerResult = JobResult[Any]
143#
144# data anaysis
145#
146type NdFloatArrayType = npt.NDArray[np.floating[Any]]
147type ReportListType = list[list[Any]]
149type AnalysisArrayType = list[float | None]
150type AnalysisDataType = list[AnalysisArrayType]
151type LabelledSeriesType = list[tuple[str, AnalysisArrayType]]
153type StatSource = AppJobType | FirestoreCollections
155type StatMetric = OutcomeMetric | CountMetric
157#
158# currency
159#
160ExchangeRateDict = dict[str, float]