xync-schema 0.6.25.dev3__py3-none-any.whl → 0.6.28__py3-none-any.whl

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.
@@ -1,10 +1,9 @@
1
1
  from datetime import datetime
2
2
  from enum import IntEnum
3
-
4
- from pydantic import create_model
5
3
  from tortoise import fields
6
- from tortoise.contrib.pydantic import PydanticModel
7
- from tortoise_api_model import Model, TsModel, DatetimeSecField, User as BaseUser
4
+ from x_auth.model import Model
5
+ from x_model.model import TsTrait, DatetimeSecField
6
+ from tg_auth.models import UserRefTrait, UserInfoTrait, User as BaseUser, UserStatus
8
7
 
9
8
 
10
9
  class AdvStatus(IntEnum):
@@ -66,20 +65,6 @@ class TaskType(IntEnum):
66
65
  invite_approve = 1
67
66
 
68
67
 
69
- class UserStatus(IntEnum):
70
- CREATOR = 5
71
- ADMINISTRATOR = 4
72
- MEMBER = 3
73
- RESTRICTED = 2
74
- LEFT = 1
75
- KICKED = 0
76
-
77
-
78
- class Lang(IntEnum):
79
- ru = 1
80
- en = 2
81
-
82
-
83
68
  class ExAction(IntEnum):
84
69
  """Public"""
85
70
 
@@ -122,7 +107,7 @@ class ExAction(IntEnum):
122
107
 
123
108
 
124
109
  class Country(Model):
125
- id = fields.SmallIntField(pk=True)
110
+ id = fields.SmallIntField(True)
126
111
  code: int | None = fields.IntField(null=True)
127
112
  short: str | None = fields.CharField(3, unique=True, null=True)
128
113
  name: str | None = fields.CharField(63, unique=True, null=True)
@@ -134,7 +119,7 @@ class Country(Model):
134
119
 
135
120
 
136
121
  class Cur(Model):
137
- id = fields.SmallIntField(pk=True)
122
+ id = fields.SmallIntField(True)
138
123
  ticker: str = fields.CharField(3, unique=True)
139
124
  rate: float | None = fields.FloatField(null=True)
140
125
  country: str | None = fields.CharField(63, null=True)
@@ -152,7 +137,7 @@ class Cur(Model):
152
137
 
153
138
 
154
139
  class Coin(Model):
155
- id: int = fields.SmallIntField(pk=True)
140
+ id: int = fields.SmallIntField(True)
156
141
  ticker: str = fields.CharField(15, unique=True)
157
142
  rate: float | None = fields.FloatField(null=True)
158
143
  is_fiat: bool = fields.BooleanField(default=False)
@@ -175,7 +160,7 @@ class Coin(Model):
175
160
 
176
161
 
177
162
  class Ex(Model):
178
- id: int = fields.SmallIntField(pk=True)
163
+ id: int = fields.SmallIntField(True)
179
164
  name: str = fields.CharField(31)
180
165
  host: str | None = fields.CharField(31, null=True)
181
166
  url: str | None = fields.CharField(63, null=True)
@@ -211,8 +196,8 @@ class Curex(Model):
211
196
  _name = {"cur__ticker", "ex__name"}
212
197
 
213
198
 
214
- class Pair(TsModel):
215
- id = fields.SmallIntField(pk=True)
199
+ class Pair(Model, TsTrait):
200
+ id = fields.SmallIntField(True)
216
201
  coin: fields.ForeignKeyRelation[Coin] = fields.ForeignKeyField("models.Coin", related_name="pairs")
217
202
  cur: fields.ForeignKeyRelation[Cur] = fields.ForeignKeyField("models.Cur", related_name="pairs")
218
203
  fee: float = fields.FloatField()
@@ -231,7 +216,7 @@ class Pair(TsModel):
231
216
 
232
217
 
233
218
  class Direction(Model):
234
- id = fields.SmallIntField(pk=True)
219
+ id = fields.SmallIntField(True)
235
220
  pair: fields.ForeignKeyRelation[Pair] = fields.ForeignKeyField("models.Pair", related_name="directions")
236
221
  sell: bool = fields.BooleanField()
237
222
  total: int = fields.IntField()
@@ -248,20 +233,9 @@ class Direction(Model):
248
233
  return f"{self.pair.coin.ticker}/{self.pair.cur.ticker} {'SELL' if self.sell else 'BUY'}"
249
234
 
250
235
 
251
- class User(BaseUser): # tg user
252
- id: int = fields.BigIntField(True)
253
- status: UserStatus = fields.IntEnumField(UserStatus, default=UserStatus.RESTRICTED)
254
- username: str | None = fields.CharField(95, unique=True, null=True)
236
+ class User(BaseUser, UserRefTrait, UserInfoTrait): # tg user
255
237
  chat_status: UserStatus = fields.IntEnumField(UserStatus, default=UserStatus.LEFT)
256
238
  in_channel: bool | None = fields.BooleanField(default=False, null=True)
257
- first_name: str | None = fields.CharField(95, null=True)
258
- last_name: str | None = fields.CharField(95, null=True)
259
- pic: str | None = fields.CharField(95, null=True)
260
- lang: Lang | None = fields.IntEnumField(Lang, default=Lang.ru, null=True)
261
- ref: fields.ForeignKeyNullableRelation["User"] = fields.ForeignKeyField(
262
- "models.User", related_name="proteges", null=True
263
- )
264
- ref_id: int | None
265
239
 
266
240
  agents: fields.BackwardFKRelation["Agent"]
267
241
  fiats: fields.BackwardFKRelation["Fiat"]
@@ -274,13 +248,8 @@ class User(BaseUser): # tg user
274
248
  borrows: fields.BackwardFKRelation["Credit"]
275
249
  investments: fields.BackwardFKRelation["Investment"]
276
250
 
277
- _icon = "user"
278
251
 
279
- class Meta:
280
- table_description = "Users"
281
-
282
-
283
- class Agent(TsModel):
252
+ class Agent(Model, TsTrait):
284
253
  id: int
285
254
  ex: fields.ForeignKeyRelation[Ex] = fields.ForeignKeyField("models.Ex", related_name="agents")
286
255
  # ex_id: int
@@ -297,18 +266,9 @@ class Agent(TsModel):
297
266
  def repr(self):
298
267
  return f"{self.ex.name}-{self.user.username}"
299
268
 
300
- @property
301
269
  def balance(self) -> float:
302
270
  return sum(asset.free * (asset.coin.rate or 0) for asset in self.assets)
303
271
 
304
- @classmethod
305
- def pydListItem(cls) -> type[PydanticModel]:
306
- return create_model(
307
- cls.__name__ + "ListItem",
308
- balance=(int, 0),
309
- __base__=super().pydListItem(),
310
- )
311
-
312
272
  class Meta:
313
273
  table_description = "Agents"
314
274
  unique_together = (("ex", "user"),)
@@ -319,9 +279,8 @@ class Agent(TsModel):
319
279
  class PydanticMetaListItem:
320
280
  max_recursion = 1
321
281
  backward_relations: bool = True
322
- exclude = "user",
323
- # include = "balance",
324
- # computed = ["balance"]
282
+ exclude = ("user",)
283
+ computed = ["balance"]
325
284
 
326
285
 
327
286
  class Adpm(Model):
@@ -335,8 +294,8 @@ class Adpm(Model):
335
294
  table_description = "P2P Advertisements - Payment methods"
336
295
 
337
296
 
338
- class Ad(TsModel):
339
- id: int = fields.BigIntField(pk=True)
297
+ class Ad(Model, TsTrait):
298
+ id: int = fields.BigIntField(True)
340
299
  direction: fields.ForeignKeyRelation[Direction] = fields.ForeignKeyField("models.Direction", related_name="ads")
341
300
  price: float = fields.FloatField()
342
301
  pms: fields.ManyToManyRelation["Pm"] = fields.ManyToManyField("models.Pm", through="adpm") # only root pms
@@ -539,8 +498,8 @@ class Asset(Model):
539
498
  exclude_raw_fields: bool = False
540
499
 
541
500
 
542
- class Order(TsModel):
543
- id: int = fields.BigIntField(pk=True)
501
+ class Order(Model, TsTrait):
502
+ id: int = fields.BigIntField(True)
544
503
  ad: fields.ForeignKeyRelation[Ad] = fields.ForeignKeyField("models.Ad", related_name="ads")
545
504
  ad_id: int
546
505
  amount: float = fields.FloatField()
@@ -564,7 +523,7 @@ class Order(TsModel):
564
523
  table_description = "P2P Orders"
565
524
 
566
525
 
567
- class Dep(TsModel):
526
+ class Dep(Model, TsTrait):
568
527
  pid: str = fields.CharField(31) # product_id
569
528
  apr: float = fields.FloatField()
570
529
  fee: float | None = fields.FloatField(null=True)
@@ -602,7 +561,7 @@ class Dep(TsModel):
602
561
  unique_together = (("pid", "type", "ex"),)
603
562
 
604
563
 
605
- class Investment(TsModel):
564
+ class Investment(Model, TsTrait):
606
565
  dep: fields.ForeignKeyRelation[Dep] = fields.ForeignKeyField("models.Dep", related_name="investments")
607
566
  dep_id: int
608
567
  amount: float = fields.FloatField()
@@ -654,7 +613,7 @@ class Vpn(Model):
654
613
  table_description = "VPNs"
655
614
 
656
615
 
657
- class Invite(TsModel):
616
+ class Invite(Model, TsTrait):
658
617
  ref: fields.ForeignKeyRelation[User] = fields.ForeignKeyField("models.User", related_name="invite_approvals")
659
618
  ref_id: int
660
619
  protege: fields.ForeignKeyRelation[User] = fields.ForeignKeyField("models.User", related_name="invite_requests")
@@ -671,7 +630,7 @@ class Invite(TsModel):
671
630
  table_description = "Invites"
672
631
 
673
632
 
674
- class Credit(TsModel):
633
+ class Credit(Model, TsTrait):
675
634
  lender: fields.ForeignKeyRelation[User] = fields.ForeignKeyField("models.User", related_name="lends")
676
635
  lender_id: int
677
636
  borrower: fields.ForeignKeyRelation[User] = fields.ForeignKeyField("models.User", related_name="borrows")
@@ -1,20 +1,18 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: xync-schema
3
- Version: 0.6.25.dev3
3
+ Version: 0.6.28
4
4
  Summary: XyncNet project database model schema
5
5
  Author-email: Mike Artemiev <mixartemev@gmail.com>
6
6
  License: EULA
7
7
  Project-URL: Homepage, https://gitlab.com/xync/back/schema
8
8
  Project-URL: Repository, https://gitlab.com/xync/back/schema
9
- Requires-Python: >=3.11
9
+ Requires-Python: >=3.12
10
10
  Description-Content-Type: text/markdown
11
- Requires-Dist: tortoise-api-model
12
- Requires-Dist: aiogram
11
+ Requires-Dist: xtg-auth
13
12
  Provides-Extra: dev
14
13
  Requires-Dist: pytest ; extra == 'dev'
15
14
  Requires-Dist: build ; extra == 'dev'
16
15
  Requires-Dist: twine ; extra == 'dev'
17
- Requires-Dist: setuptools-scm ; extra == 'dev'
18
16
 
19
17
  ## INSTALL
20
18
  ```bash
@@ -0,0 +1,6 @@
1
+ xync_schema/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
+ xync_schema/model.py,sha256=EsjxApW0tIT7Ho2ak1d89f3JHtRllsSwzvpHRExC7lQ,23663
3
+ xync_schema-0.6.28.dist-info/METADATA,sha256=BJtj28PGUcJpTF1M8YTRbgJZNT_U99Pn39ua_NCIrLo,1086
4
+ xync_schema-0.6.28.dist-info/WHEEL,sha256=OVMc5UfuAQiSplgO0_WdW7vXVGAt9Hdd6qtN4HotdyA,91
5
+ xync_schema-0.6.28.dist-info/top_level.txt,sha256=jN8IBDfVY8b85Byyk8v0Gyj_0yLB8FO56WV4EvcXWY4,12
6
+ xync_schema-0.6.28.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (75.1.0)
2
+ Generator: setuptools (75.2.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,6 +0,0 @@
1
- xync_schema/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- xync_schema/models.py,sha256=sfg4ftJ5gf2P96ZsPl6Vn9fEcT_1bGIFF0yb77QdUWg,24730
3
- xync_schema-0.6.25.dev3.dist-info/METADATA,sha256=uppTgZLst_v8RIo068fhCFL_2MyptPe5Z8UGAi6bXJk,1171
4
- xync_schema-0.6.25.dev3.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
5
- xync_schema-0.6.25.dev3.dist-info/top_level.txt,sha256=jN8IBDfVY8b85Byyk8v0Gyj_0yLB8FO56WV4EvcXWY4,12
6
- xync_schema-0.6.25.dev3.dist-info/RECORD,,