xync-schema 0.6.91__tar.gz → 0.6.92.dev2__tar.gz
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.
- {xync_schema-0.6.91/xync_schema.egg-info → xync_schema-0.6.92.dev2}/PKG-INFO +1 -1
- {xync_schema-0.6.91 → xync_schema-0.6.92.dev2}/tests/test_db.py +6 -7
- xync_schema-0.6.92.dev2/xync_schema/__init__.py +17 -0
- {xync_schema-0.6.91 → xync_schema-0.6.92.dev2}/xync_schema/models.py +36 -19
- {xync_schema-0.6.91 → xync_schema-0.6.92.dev2/xync_schema.egg-info}/PKG-INFO +1 -1
- xync_schema-0.6.91/xync_schema/__init__.py +0 -0
- {xync_schema-0.6.91 → xync_schema-0.6.92.dev2}/.env.sample +0 -0
- {xync_schema-0.6.91 → xync_schema-0.6.92.dev2}/.gitignore +0 -0
- {xync_schema-0.6.91 → xync_schema-0.6.92.dev2}/.pre-commit-config.yaml +0 -0
- {xync_schema-0.6.91 → xync_schema-0.6.92.dev2}/README.md +0 -0
- {xync_schema-0.6.91 → xync_schema-0.6.92.dev2}/makefile +0 -0
- {xync_schema-0.6.91 → xync_schema-0.6.92.dev2}/pyproject.toml +0 -0
- {xync_schema-0.6.91 → xync_schema-0.6.92.dev2}/setup.cfg +0 -0
- {xync_schema-0.6.91 → xync_schema-0.6.92.dev2}/tests/__init__.py +0 -0
- {xync_schema-0.6.91 → xync_schema-0.6.92.dev2}/xync_schema/enums.py +0 -0
- {xync_schema-0.6.91 → xync_schema-0.6.92.dev2}/xync_schema/types.py +0 -0
- {xync_schema-0.6.91 → xync_schema-0.6.92.dev2}/xync_schema.egg-info/SOURCES.txt +0 -0
- {xync_schema-0.6.91 → xync_schema-0.6.92.dev2}/xync_schema.egg-info/dependency_links.txt +0 -0
- {xync_schema-0.6.91 → xync_schema-0.6.92.dev2}/xync_schema.egg-info/requires.txt +0 -0
- {xync_schema-0.6.91 → xync_schema-0.6.92.dev2}/xync_schema.egg-info/top_level.txt +0 -0
|
@@ -7,23 +7,22 @@ from tortoise.backends.asyncpg import AsyncpgDBClient
|
|
|
7
7
|
from x_model import init_db
|
|
8
8
|
|
|
9
9
|
from xync_schema import models
|
|
10
|
-
from xync_schema.models import Ex
|
|
11
10
|
|
|
12
11
|
load_dotenv()
|
|
13
12
|
|
|
14
13
|
|
|
15
14
|
@pytest.fixture
|
|
16
|
-
async def
|
|
15
|
+
async def _dbc() -> AsyncpgDBClient:
|
|
17
16
|
await init_db(env("DB_URL"), models, True)
|
|
18
17
|
cn: AsyncpgDBClient = connections.get("default")
|
|
19
18
|
yield cn
|
|
20
19
|
await cn.close()
|
|
21
20
|
|
|
22
21
|
|
|
23
|
-
async def test_init_db(
|
|
24
|
-
assert isinstance(
|
|
22
|
+
async def test_init_db(_dbc):
|
|
23
|
+
assert isinstance(_dbc, AsyncpgDBClient), "DB corrupt"
|
|
25
24
|
|
|
26
25
|
|
|
27
|
-
async def test_models(
|
|
28
|
-
|
|
29
|
-
|
|
26
|
+
# async def test_models(_dbc):
|
|
27
|
+
# c = await models.Ex.first()
|
|
28
|
+
# assert isinstance(c, models.Ex), "No exs"
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
async def main():
|
|
2
|
+
from os import getenv as env
|
|
3
|
+
from dotenv import load_dotenv
|
|
4
|
+
import logging
|
|
5
|
+
from x_model import init_db
|
|
6
|
+
from xync_schema import models
|
|
7
|
+
from logging import DEBUG
|
|
8
|
+
|
|
9
|
+
load_dotenv()
|
|
10
|
+
logging.basicConfig(level=DEBUG)
|
|
11
|
+
await init_db(env("DB_URL"), models, True)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
if __name__ == "__main__":
|
|
15
|
+
from asyncio import run
|
|
16
|
+
|
|
17
|
+
run(main())
|
|
@@ -4,7 +4,20 @@ from datetime import datetime
|
|
|
4
4
|
from tortoise import fields
|
|
5
5
|
from tortoise.queryset import QuerySet
|
|
6
6
|
from tortoise import Model as BaseModel
|
|
7
|
-
from x_auth.models import
|
|
7
|
+
from x_auth.models import (
|
|
8
|
+
Model,
|
|
9
|
+
Username as Username,
|
|
10
|
+
User as TgUser,
|
|
11
|
+
Proxy as Proxy,
|
|
12
|
+
Dc as Dc,
|
|
13
|
+
Fcm as Fcm,
|
|
14
|
+
App as App,
|
|
15
|
+
Session as Session,
|
|
16
|
+
Peer as Peer,
|
|
17
|
+
UpdateState as UpdateState,
|
|
18
|
+
Version as Version,
|
|
19
|
+
Country as BaseCountry,
|
|
20
|
+
)
|
|
8
21
|
from x_model.models import TsTrait, DatetimeSecField
|
|
9
22
|
|
|
10
23
|
from xync_schema.enums import (
|
|
@@ -21,11 +34,7 @@ from xync_schema.enums import (
|
|
|
21
34
|
)
|
|
22
35
|
|
|
23
36
|
|
|
24
|
-
class Country(
|
|
25
|
-
id = fields.SmallIntField(True)
|
|
26
|
-
code: int | None = fields.IntField(null=True)
|
|
27
|
-
short: str | None = fields.CharField(3, null=True)
|
|
28
|
-
name: str | None = fields.CharField(63, unique=True, null=True)
|
|
37
|
+
class Country(BaseCountry):
|
|
29
38
|
cur: fields.ForeignKeyRelation["Cur"] = fields.ForeignKeyField("models.Cur", related_name="countries")
|
|
30
39
|
curexs: fields.ManyToManyRelation["Curex"]
|
|
31
40
|
fiats: fields.BackwardFKRelation["Fiat"]
|
|
@@ -117,6 +126,7 @@ class Curex(BaseModel):
|
|
|
117
126
|
|
|
118
127
|
class Coinex(BaseModel):
|
|
119
128
|
coin: fields.ForeignKeyRelation[Coin] = fields.ForeignKeyField("models.Coin")
|
|
129
|
+
coin_id: int
|
|
120
130
|
ex: fields.ForeignKeyRelation[Ex] = fields.ForeignKeyField("models.Ex")
|
|
121
131
|
minimum: float = fields.FloatField(null=True)
|
|
122
132
|
|
|
@@ -180,10 +190,8 @@ class Person(Model, TsTrait):
|
|
|
180
190
|
pm_agents: fields.BackwardFKRelation["PmAgent"]
|
|
181
191
|
|
|
182
192
|
|
|
183
|
-
class User(
|
|
193
|
+
class User(TgUser, TsTrait):
|
|
184
194
|
status: UserStatus = fields.IntEnumField(UserStatus, default=UserStatus.SLEEP)
|
|
185
|
-
gmail_auth: dict = fields.JSONField(default={})
|
|
186
|
-
|
|
187
195
|
person: fields.OneToOneRelation[Person] = fields.OneToOneField("models.Person", related_name="user")
|
|
188
196
|
person_id: int
|
|
189
197
|
ref: fields.ForeignKeyNullableRelation["User"] = fields.ForeignKeyField(
|
|
@@ -195,15 +203,17 @@ class User(UserTg, TsTrait):
|
|
|
195
203
|
) # who can texts this user
|
|
196
204
|
contacted_with_id: int | None
|
|
197
205
|
|
|
198
|
-
|
|
206
|
+
actors: fields.BackwardFKRelation["Actor"]
|
|
207
|
+
contacts: fields.BackwardFKRelation["User"]
|
|
199
208
|
created_forums: fields.BackwardFKRelation["Forum"]
|
|
200
|
-
proteges: fields.BackwardFKRelation["User"]
|
|
201
209
|
creds: fields.BackwardFKRelation["Cred"]
|
|
202
|
-
actors: fields.BackwardFKRelation["Actor"]
|
|
203
210
|
# fiats: fields.BackwardFKRelation["Fiat"]
|
|
211
|
+
gmail: fields.BackwardOneToOneRelation["Gmail"]
|
|
212
|
+
forum: fields.BackwardOneToOneRelation["Forum"]
|
|
204
213
|
limits: fields.BackwardFKRelation["Limit"]
|
|
205
214
|
msgs: fields.BackwardFKRelation["Msg"]
|
|
206
|
-
|
|
215
|
+
proteges: fields.BackwardFKRelation["User"]
|
|
216
|
+
|
|
207
217
|
# vpn: fields.BackwardOneToOneRelation["Vpn"]
|
|
208
218
|
# invite_requests: fields.BackwardFKRelation["Invite"]
|
|
209
219
|
# invite_approvals: fields.BackwardFKRelation["Invite"]
|
|
@@ -231,6 +241,15 @@ class User(UserTg, TsTrait):
|
|
|
231
241
|
# computed = ["balance"]
|
|
232
242
|
|
|
233
243
|
|
|
244
|
+
class Gmail(Model):
|
|
245
|
+
login: str = fields.CharField(127)
|
|
246
|
+
password: str = fields.CharField(127)
|
|
247
|
+
auth: dict = fields.JSONField(default={})
|
|
248
|
+
updated_at: datetime | None = DatetimeSecField(auto_now=True)
|
|
249
|
+
|
|
250
|
+
user: fields.OneToOneRelation[User] = fields.OneToOneField("models.User", "gmail")
|
|
251
|
+
|
|
252
|
+
|
|
234
253
|
class Forum(Model, TsTrait):
|
|
235
254
|
id: int = fields.BigIntField(True)
|
|
236
255
|
joined: bool = fields.BooleanField(default=False)
|
|
@@ -258,9 +277,7 @@ class Actor(Model):
|
|
|
258
277
|
return client(self, headers=self.agent.auth.get("headers"), cookies=self.agent.auth.get("cookies"))
|
|
259
278
|
|
|
260
279
|
def in_client(self):
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
module_name = f"xync_client.{self.ex.name}.inAgent"
|
|
280
|
+
module_name = f"xync_client.{self.ex.name}.InAgent"
|
|
264
281
|
__import__(module_name)
|
|
265
282
|
client = sys.modules[module_name].InAgentClient
|
|
266
283
|
return client(self)
|
|
@@ -729,7 +746,7 @@ class Msg(Model):
|
|
|
729
746
|
|
|
730
747
|
class TestEx(Model):
|
|
731
748
|
ex: fields.ForeignKeyRelation[Ex] = fields.ForeignKeyField("models.Ex", related_name="tests")
|
|
732
|
-
|
|
749
|
+
ex_id: int
|
|
733
750
|
action: ExAction = fields.IntEnumField(ExAction)
|
|
734
751
|
ok: bool | None = fields.BooleanField(default=False, null=True)
|
|
735
752
|
updated_at: datetime | None = DatetimeSecField(auto_now=True)
|
|
@@ -737,7 +754,7 @@ class TestEx(Model):
|
|
|
737
754
|
_icon = "test-pipe"
|
|
738
755
|
_name = {"ex_id", "action", "ok"}
|
|
739
756
|
|
|
740
|
-
def repr(self
|
|
757
|
+
def repr(self):
|
|
741
758
|
return f"{self.ex_id} {self.action.name} {self.ok}"
|
|
742
759
|
|
|
743
760
|
class Meta:
|
|
@@ -758,7 +775,7 @@ class Vpn(Model):
|
|
|
758
775
|
_icon = "vpn"
|
|
759
776
|
_name = {"pub"}
|
|
760
777
|
|
|
761
|
-
def repr(self
|
|
778
|
+
def repr(self):
|
|
762
779
|
return self.user.username
|
|
763
780
|
|
|
764
781
|
class Meta:
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|