xn-auth 0.2.41__py3-none-any.whl → 0.2.42__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.
x_auth/models.py CHANGED
@@ -18,16 +18,16 @@ from tortoise.fields import (
18
18
  OneToOneRelation,
19
19
  OneToOneNullableRelation,
20
20
  OneToOneField,
21
- SmallIntField,
22
21
  BackwardOneToOneRelation,
23
22
  BackwardFKRelation,
24
23
  ForeignKeyNullableRelation,
25
24
  JSONField,
25
+ CASCADE,
26
26
  )
27
27
  from tortoise.fields.data import CharEnumFieldInstance
28
28
 
29
29
  from x_auth import types
30
- from x_model.field import DatetimeSecField
30
+ from x_model.field import DatetimeSecField, UIntField, UInt8Field, UniqBinaryField, UInt1Field, UInt2Field
31
31
  from x_model.models import Model, TsTrait
32
32
  from tortoise import Model as TortModel
33
33
  from x_model.types import BaseUpd
@@ -35,14 +35,10 @@ from x_model.types import BaseUpd
35
35
  from x_auth.enums import Lang, Role, PeerType
36
36
 
37
37
 
38
- class UniqBinaryField(BinaryField):
39
- indexable = True
40
-
41
-
42
38
  class Username(TortModel):
43
- id: int = BigIntField(True, description="tg_id")
39
+ id: int = UIntField(True, description="tg_id")
44
40
  username: str = CharField(127, null=True)
45
- phone = BigIntField(null=True)
41
+ phone = UInt8Field(null=True)
46
42
 
47
43
  user: BackwardOneToOneRelation["User"]
48
44
  peers: BackwardFKRelation["Peer"]
@@ -50,7 +46,7 @@ class Username(TortModel):
50
46
 
51
47
 
52
48
  class User(Model):
53
- username: OneToOneRelation[Username] = OneToOneField("models.Username", "user")
49
+ username: OneToOneRelation[Username] = OneToOneField("models.Username", "user", on_update=CASCADE)
54
50
  username_id: int
55
51
  first_name: str | None = CharField(63)
56
52
  pic: str | None = CharField(127, null=True)
@@ -58,7 +54,6 @@ class User(Model):
58
54
  blocked: bool = BooleanField(default=False)
59
55
  lang: Lang | None = IntEnumField(Lang, default=Lang.ru, null=True)
60
56
  role: Role = IntEnumField(Role, default=Role.READER)
61
- # prv = BinaryField(null=True) # len=32
62
57
  pub = UniqBinaryField(unique=True, null=True) # len=32
63
58
 
64
59
  app: BackwardOneToOneRelation["App"]
@@ -94,8 +89,8 @@ class User(Model):
94
89
 
95
90
 
96
91
  class Country(Model):
97
- id = SmallIntField(True)
98
- code: int | None = IntField(null=True)
92
+ id = UInt1Field(True)
93
+ code: int | None = UInt2Field(null=True)
99
94
  short: str | None = CharField(3, null=True)
100
95
  name: str | None = CharField(63, unique=True, null=True)
101
96
 
@@ -105,11 +100,13 @@ class Country(Model):
105
100
  class Proxy(Model, TsTrait):
106
101
  id: int = CharField(63, primary_key=True)
107
102
  host: str = CharField(63)
108
- port: str = IntField()
103
+ port: str = UInt2Field()
109
104
  username: str = CharField(63)
110
105
  password: str = CharField(63)
111
106
  valid: bool = BooleanField(null=True)
112
- country: ForeignKeyRelation[Country] = ForeignKeyField("models.Country", "proxies", null=True) # todo rm nullable
107
+ country: ForeignKeyRelation[Country] = ForeignKeyField(
108
+ "models.Country", "proxies", on_update=CASCADE, null=True
109
+ ) # todo rm nullable
113
110
 
114
111
  class Meta:
115
112
  unique_together = (("host", "port"),)
@@ -174,7 +171,7 @@ class Proxy(Model, TsTrait):
174
171
 
175
172
 
176
173
  class Dc(TortModel):
177
- id: int = SmallIntField(True)
174
+ id: int = UInt1Field(True)
178
175
  ip = CharField(15, unique=True)
179
176
  pub = CharField(495, null=True)
180
177
 
@@ -183,41 +180,42 @@ class Dc(TortModel):
183
180
 
184
181
 
185
182
  class Fcm(TortModel):
186
- id: int = SmallIntField(True)
183
+ id: int = UInt1Field(True)
187
184
  json: dict = JSONField(default={})
188
185
 
189
186
  apps: BackwardFKRelation["App"]
190
187
 
191
188
 
192
189
  class App(Model):
190
+ id: int = UInt1Field(True)
193
191
  hsh = CharField(32, unique=True)
194
- dc: ForeignKeyRelation[Dc] = ForeignKeyField("models.Dc", "apps", default=2)
192
+ dc: ForeignKeyRelation[Dc] = ForeignKeyField("models.Dc", "apps", on_update=CASCADE, default=2)
195
193
  dc_id: int
196
194
  title = CharField(127)
197
195
  short = CharField(76)
198
196
  ver = CharField(18, default="0.0.1")
199
- fcm: ForeignKeyNullableRelation[Fcm] = ForeignKeyField("models.Fcm", "apps", null=True)
197
+ fcm: ForeignKeyNullableRelation[Fcm] = ForeignKeyField("models.Fcm", "apps", on_update=CASCADE, null=True)
200
198
  fcm_id: int
201
199
  platform: ClientPlatform = CharEnumFieldInstance(ClientPlatform)
202
- owner: OneToOneNullableRelation["User"] = OneToOneField("models.User", "app", null=True)
200
+ owner: OneToOneNullableRelation["User"] = OneToOneField("models.User", "app", on_update=CASCADE, null=True)
203
201
 
204
202
  sessions: BackwardFKRelation["Session"]
205
203
 
206
204
 
207
205
  class Session(TortModel):
208
206
  id = BigIntField(True)
209
- api: ForeignKeyRelation[App] = ForeignKeyField("models.App", "sessions")
207
+ api: ForeignKeyRelation[App] = ForeignKeyField("models.App", "sessions", on_update=CASCADE)
210
208
  api_id: int
211
- dc: ForeignKeyRelation[Dc] = ForeignKeyField("models.Dc", "sessions", default=2)
209
+ dc: ForeignKeyRelation[Dc] = ForeignKeyField("models.Dc", "sessions", on_update=CASCADE, default=2)
212
210
  dc_id: int
213
211
  test_mode = BooleanField(default=False)
214
212
  auth_key = BinaryField(null=True)
215
213
  date = IntField(default=0) # todo: refact to datetime?
216
- user: OneToOneNullableRelation[Username] = OneToOneField("models.Username", "session", null=True)
214
+ user: OneToOneNullableRelation[Username] = OneToOneField("models.Username", "session", on_update=CASCADE, null=True)
217
215
  user_id: int
218
216
  is_bot = CharField(42, null=True)
219
217
  state: dict = JSONField(default={})
220
- proxy: ForeignKeyNullableRelation[Proxy] = ForeignKeyField("models.Proxy", "sessions", null=True)
218
+ proxy: ForeignKeyNullableRelation[Proxy] = ForeignKeyField("models.Proxy", "sessions", on_update=CASCADE, null=True)
221
219
 
222
220
  peers: BackwardFKRelation["Peer"]
223
221
  update_states: BackwardFKRelation["UpdateState"]
@@ -228,12 +226,12 @@ class Session(TortModel):
228
226
 
229
227
  class Peer(TortModel):
230
228
  id: int = BigIntField(True, description="access_hash")
231
- username: ForeignKeyRelation[Username] = ForeignKeyField("models.Username", "peers")
229
+ username: ForeignKeyRelation[Username] = ForeignKeyField("models.Username", "peers", on_update=CASCADE)
232
230
  username_id: int
233
- session: ForeignKeyRelation[Session] = ForeignKeyField("models.Session", "peers")
231
+ session: ForeignKeyRelation[Session] = ForeignKeyField("models.Session", "peers", on_update=CASCADE)
234
232
  session_id: int
235
233
  type: PeerType = IntEnumField(PeerType)
236
- phone_number = BigIntField(null=True) # todo: rm (already moved to Username.phone)
234
+ phone_number = UInt8Field(null=True) # duplicated to Username.phone
237
235
  last_update_on: datetime | None = DatetimeSecField(auto_now=True)
238
236
 
239
237
  class Meta:
@@ -241,13 +239,13 @@ class Peer(TortModel):
241
239
 
242
240
 
243
241
  class UpdateState(TortModel):
244
- id = IntField(True)
245
- session: ForeignKeyRelation[Session] = ForeignKeyField("models.Session", "update_states")
246
- pts = IntField()
247
- qts = IntField()
248
- date = IntField()
249
- seq = IntField()
242
+ id = UInt2Field(True)
243
+ session: ForeignKeyRelation[Session] = ForeignKeyField("models.Session", "update_states", on_update=CASCADE)
244
+ pts = UInt2Field()
245
+ qts = UInt2Field()
246
+ date = UInt2Field()
247
+ seq = UInt2Field()
250
248
 
251
249
 
252
250
  class Version(TortModel):
253
- number = SmallIntField(True)
251
+ number = UInt2Field(True)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: xn-auth
3
- Version: 0.2.41
3
+ Version: 0.2.42
4
4
  Summary: Auth adapter for XN-Api framework
5
5
  Author-email: Artemiev <mixartemev@gmail.com>
6
6
  License: MIT
@@ -2,9 +2,9 @@ x_auth/controller.py,sha256=KGbXT-hX7Rp6eYZJGx_-ioAr3As73bbKjPhow41c1SE,2973
2
2
  x_auth/enums.py,sha256=l4NTYsA-h0gyOp4PUe40Lb8LKoA94zL6EDkCmoGmBL0,732
3
3
  x_auth/exceptions.py,sha256=2B4okJxhPyNqTJXlSTfblJUQJ60bLGXdgJIu6ue7S6w,162
4
4
  x_auth/middleware.py,sha256=JfssQomDv0J_69GfS2a_2_uyRzs26zSY6IW1Vk7m8K0,2900
5
- x_auth/models.py,sha256=kDk0je7f2TcfRrnCeTbB99ERBJmDaxGGjvIm53BIaYM,8996
5
+ x_auth/models.py,sha256=7HzcrTRGGeFs4MDqaGd0qh01tlepEtoUKxt1WHhpb34,9207
6
6
  x_auth/types.py,sha256=GTjNOm7XkyYDCdIaqByP2LzHnwCJRkWGOwdc4tVWFy0,1400
7
- xn_auth-0.2.41.dist-info/METADATA,sha256=lPj2C37gFR3GN2b1xvIMxBzWbyU6KtTurQfNc3QBcTU,823
8
- xn_auth-0.2.41.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
9
- xn_auth-0.2.41.dist-info/top_level.txt,sha256=ydMDkzxgQPtW-E_MNDfUAroAFZvWSqU-x_kZSA7NSFo,7
10
- xn_auth-0.2.41.dist-info/RECORD,,
7
+ xn_auth-0.2.42.dist-info/METADATA,sha256=W5-hz5uMWgop6Kbf_ls5gur4_iapZdlpS1NG9OW-jCk,823
8
+ xn_auth-0.2.42.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
9
+ xn_auth-0.2.42.dist-info/top_level.txt,sha256=ydMDkzxgQPtW-E_MNDfUAroAFZvWSqU-x_kZSA7NSFo,7
10
+ xn_auth-0.2.42.dist-info/RECORD,,