chickinfry 0.5.0.dev1__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.
@@ -0,0 +1,765 @@
1
+ # Code generated by Chickinfry. DO NOT EDIT.
2
+
3
+ from __future__ import annotations
4
+
5
+ import builtins as _builtins
6
+ from collections.abc import Mapping
7
+ from dataclasses import dataclass
8
+
9
+ from chickinfry.auth import AuthDatabase
10
+ from chickinfry.orm import (
11
+ Column,
12
+ DatabasePort,
13
+ Repository,
14
+ Table,
15
+ )
16
+
17
+
18
+ def _read_string(value: object) -> _builtins.str:
19
+ if not isinstance(value, _builtins.str):
20
+ raise ValueError("A string column is required.")
21
+ return value
22
+
23
+
24
+ def _read_integer(value: object) -> _builtins.int:
25
+ if not isinstance(value, _builtins.int) or isinstance(value, _builtins.bool):
26
+ raise ValueError("An integer column is required.")
27
+ return value
28
+
29
+
30
+ def _read_string_nullable(value: object) -> _builtins.str | None:
31
+ return None if value is None else _read_string(value)
32
+
33
+
34
+ def _read_integer_nullable(value: object) -> _builtins.int | None:
35
+ return None if value is None else _read_integer(value)
36
+
37
+
38
+ @dataclass(frozen=True, slots=True, kw_only=True, repr=False)
39
+ class AppAuthActionTokensRow:
40
+ attempts: _builtins.int
41
+ consumed_at: _builtins.str | None
42
+ created_at: _builtins.str
43
+ expires_at: _builtins.str
44
+ id: _builtins.str
45
+ kind: _builtins.str
46
+ token_hash: _builtins.str
47
+ user_id: _builtins.str
48
+
49
+
50
+ _app_auth_action_tokens_table = Table(
51
+ "app_auth_action_tokens",
52
+ {
53
+ "attempts": Column[_builtins.int](
54
+ "attempts",
55
+ "integer",
56
+ False,
57
+ ),
58
+ "consumed_at": Column[_builtins.str | None](
59
+ "consumed_at",
60
+ "timestamp",
61
+ True,
62
+ ),
63
+ "created_at": Column[_builtins.str](
64
+ "created_at",
65
+ "timestamp",
66
+ False,
67
+ ),
68
+ "expires_at": Column[_builtins.str](
69
+ "expires_at",
70
+ "timestamp",
71
+ False,
72
+ ),
73
+ "id": Column[_builtins.str](
74
+ "id",
75
+ "id",
76
+ False,
77
+ ),
78
+ "kind": Column[_builtins.str](
79
+ "kind",
80
+ "string",
81
+ False,
82
+ ),
83
+ "token_hash": Column[_builtins.str](
84
+ "token_hash",
85
+ "string",
86
+ False,
87
+ ),
88
+ "user_id": Column[_builtins.str](
89
+ "user_id",
90
+ "id",
91
+ False,
92
+ ),
93
+ },
94
+ ("id",),
95
+ (
96
+ "expires_at",
97
+ "kind",
98
+ "token_hash",
99
+ "user_id",
100
+ ),
101
+ )
102
+
103
+
104
+ def _decode_app_auth_action_tokens(
105
+ row: Mapping[_builtins.str, object],
106
+ ) -> AppAuthActionTokensRow:
107
+ return AppAuthActionTokensRow(
108
+ attempts=_read_integer(row["attempts"]),
109
+ consumed_at=_read_string_nullable(row["consumed_at"]),
110
+ created_at=_read_string(row["created_at"]),
111
+ expires_at=_read_string(row["expires_at"]),
112
+ id=_read_string(row["id"]),
113
+ kind=_read_string(row["kind"]),
114
+ token_hash=_read_string(row["token_hash"]),
115
+ user_id=_read_string(row["user_id"]),
116
+ )
117
+
118
+
119
+ @dataclass(frozen=True, slots=True, kw_only=True, repr=False)
120
+ class AppAuthIdentitiesRow:
121
+ created_at: _builtins.str
122
+ provider: _builtins.str
123
+ subject: _builtins.str
124
+ user_id: _builtins.str
125
+
126
+
127
+ _app_auth_identities_table = Table(
128
+ "app_auth_identities",
129
+ {
130
+ "created_at": Column[_builtins.str](
131
+ "created_at",
132
+ "timestamp",
133
+ False,
134
+ ),
135
+ "provider": Column[_builtins.str](
136
+ "provider",
137
+ "string",
138
+ False,
139
+ ),
140
+ "subject": Column[_builtins.str](
141
+ "subject",
142
+ "string",
143
+ False,
144
+ ),
145
+ "user_id": Column[_builtins.str](
146
+ "user_id",
147
+ "id",
148
+ False,
149
+ ),
150
+ },
151
+ (
152
+ "provider",
153
+ "subject",
154
+ ),
155
+ (
156
+ "provider",
157
+ "subject",
158
+ "user_id",
159
+ ),
160
+ )
161
+
162
+
163
+ def _decode_app_auth_identities(
164
+ row: Mapping[_builtins.str, object],
165
+ ) -> AppAuthIdentitiesRow:
166
+ return AppAuthIdentitiesRow(
167
+ created_at=_read_string(row["created_at"]),
168
+ provider=_read_string(row["provider"]),
169
+ subject=_read_string(row["subject"]),
170
+ user_id=_read_string(row["user_id"]),
171
+ )
172
+
173
+
174
+ @dataclass(frozen=True, slots=True, kw_only=True, repr=False)
175
+ class AppAuthInvitesRow:
176
+ code_hash: _builtins.str
177
+ created_at: _builtins.str
178
+ email: _builtins.str
179
+ expires_at: _builtins.str
180
+ id: _builtins.str
181
+ issued_by: _builtins.str
182
+ redeemed_at: _builtins.str | None
183
+ redeemed_by: _builtins.str | None
184
+ revoked_at: _builtins.str | None
185
+
186
+
187
+ _app_auth_invites_table = Table(
188
+ "app_auth_invites",
189
+ {
190
+ "code_hash": Column[_builtins.str](
191
+ "code_hash",
192
+ "string",
193
+ False,
194
+ ),
195
+ "created_at": Column[_builtins.str](
196
+ "created_at",
197
+ "timestamp",
198
+ False,
199
+ ),
200
+ "email": Column[_builtins.str](
201
+ "email",
202
+ "string",
203
+ False,
204
+ ),
205
+ "expires_at": Column[_builtins.str](
206
+ "expires_at",
207
+ "timestamp",
208
+ False,
209
+ ),
210
+ "id": Column[_builtins.str](
211
+ "id",
212
+ "id",
213
+ False,
214
+ ),
215
+ "issued_by": Column[_builtins.str](
216
+ "issued_by",
217
+ "id",
218
+ False,
219
+ ),
220
+ "redeemed_at": Column[_builtins.str | None](
221
+ "redeemed_at",
222
+ "timestamp",
223
+ True,
224
+ ),
225
+ "redeemed_by": Column[_builtins.str | None](
226
+ "redeemed_by",
227
+ "id",
228
+ True,
229
+ ),
230
+ "revoked_at": Column[_builtins.str | None](
231
+ "revoked_at",
232
+ "timestamp",
233
+ True,
234
+ ),
235
+ },
236
+ ("id",),
237
+ (
238
+ "code_hash",
239
+ "email",
240
+ "expires_at",
241
+ "issued_by",
242
+ ),
243
+ )
244
+
245
+
246
+ def _decode_app_auth_invites(
247
+ row: Mapping[_builtins.str, object],
248
+ ) -> AppAuthInvitesRow:
249
+ return AppAuthInvitesRow(
250
+ code_hash=_read_string(row["code_hash"]),
251
+ created_at=_read_string(row["created_at"]),
252
+ email=_read_string(row["email"]),
253
+ expires_at=_read_string(row["expires_at"]),
254
+ id=_read_string(row["id"]),
255
+ issued_by=_read_string(row["issued_by"]),
256
+ redeemed_at=_read_string_nullable(row["redeemed_at"]),
257
+ redeemed_by=_read_string_nullable(row["redeemed_by"]),
258
+ revoked_at=_read_string_nullable(row["revoked_at"]),
259
+ )
260
+
261
+
262
+ @dataclass(frozen=True, slots=True, kw_only=True, repr=False)
263
+ class AppAuthMigrationsRow:
264
+ applied_at: _builtins.str
265
+ digest: _builtins.str
266
+ feature: _builtins.str
267
+ name: _builtins.str
268
+ phase: _builtins.str
269
+ version: _builtins.int
270
+
271
+
272
+ _app_auth_migrations_table = Table(
273
+ "app_auth_migrations",
274
+ {
275
+ "applied_at": Column[_builtins.str](
276
+ "applied_at",
277
+ "timestamp",
278
+ False,
279
+ ),
280
+ "digest": Column[_builtins.str](
281
+ "digest",
282
+ "string",
283
+ False,
284
+ ),
285
+ "feature": Column[_builtins.str](
286
+ "feature",
287
+ "string",
288
+ False,
289
+ ),
290
+ "name": Column[_builtins.str](
291
+ "name",
292
+ "string",
293
+ False,
294
+ ),
295
+ "phase": Column[_builtins.str](
296
+ "phase",
297
+ "string",
298
+ False,
299
+ ),
300
+ "version": Column[_builtins.int](
301
+ "version",
302
+ "integer",
303
+ False,
304
+ ),
305
+ },
306
+ (
307
+ "feature",
308
+ "version",
309
+ ),
310
+ (
311
+ "digest",
312
+ "feature",
313
+ "name",
314
+ "phase",
315
+ "version",
316
+ ),
317
+ )
318
+
319
+
320
+ def _decode_app_auth_migrations(
321
+ row: Mapping[_builtins.str, object],
322
+ ) -> AppAuthMigrationsRow:
323
+ return AppAuthMigrationsRow(
324
+ applied_at=_read_string(row["applied_at"]),
325
+ digest=_read_string(row["digest"]),
326
+ feature=_read_string(row["feature"]),
327
+ name=_read_string(row["name"]),
328
+ phase=_read_string(row["phase"]),
329
+ version=_read_integer(row["version"]),
330
+ )
331
+
332
+
333
+ @dataclass(frozen=True, slots=True, kw_only=True, repr=False)
334
+ class AppAuthRateLimitsRow:
335
+ action: _builtins.str
336
+ attempt_count: _builtins.int
337
+ expires_at: _builtins.str
338
+ key_hash: _builtins.str
339
+
340
+
341
+ _app_auth_rate_limits_table = Table(
342
+ "app_auth_rate_limits",
343
+ {
344
+ "action": Column[_builtins.str](
345
+ "action",
346
+ "string",
347
+ False,
348
+ ),
349
+ "attempt_count": Column[_builtins.int](
350
+ "attempt_count",
351
+ "integer",
352
+ False,
353
+ ),
354
+ "expires_at": Column[_builtins.str](
355
+ "expires_at",
356
+ "timestamp",
357
+ False,
358
+ ),
359
+ "key_hash": Column[_builtins.str](
360
+ "key_hash",
361
+ "string",
362
+ False,
363
+ ),
364
+ },
365
+ (
366
+ "action",
367
+ "key_hash",
368
+ ),
369
+ (
370
+ "action",
371
+ "attempt_count",
372
+ "expires_at",
373
+ "key_hash",
374
+ ),
375
+ )
376
+
377
+
378
+ def _decode_app_auth_rate_limits(
379
+ row: Mapping[_builtins.str, object],
380
+ ) -> AppAuthRateLimitsRow:
381
+ return AppAuthRateLimitsRow(
382
+ action=_read_string(row["action"]),
383
+ attempt_count=_read_integer(row["attempt_count"]),
384
+ expires_at=_read_string(row["expires_at"]),
385
+ key_hash=_read_string(row["key_hash"]),
386
+ )
387
+
388
+
389
+ @dataclass(frozen=True, slots=True, kw_only=True, repr=False)
390
+ class AppAuthRefreshTokensRow:
391
+ consumed_at: _builtins.str | None
392
+ created_at: _builtins.str
393
+ expires_at: _builtins.str
394
+ id: _builtins.str
395
+ session_id: _builtins.str
396
+ token_hash: _builtins.str
397
+
398
+
399
+ _app_auth_refresh_tokens_table = Table(
400
+ "app_auth_refresh_tokens",
401
+ {
402
+ "consumed_at": Column[_builtins.str | None](
403
+ "consumed_at",
404
+ "timestamp",
405
+ True,
406
+ ),
407
+ "created_at": Column[_builtins.str](
408
+ "created_at",
409
+ "timestamp",
410
+ False,
411
+ ),
412
+ "expires_at": Column[_builtins.str](
413
+ "expires_at",
414
+ "timestamp",
415
+ False,
416
+ ),
417
+ "id": Column[_builtins.str](
418
+ "id",
419
+ "id",
420
+ False,
421
+ ),
422
+ "session_id": Column[_builtins.str](
423
+ "session_id",
424
+ "id",
425
+ False,
426
+ ),
427
+ "token_hash": Column[_builtins.str](
428
+ "token_hash",
429
+ "string",
430
+ False,
431
+ ),
432
+ },
433
+ ("id",),
434
+ (
435
+ "expires_at",
436
+ "session_id",
437
+ "token_hash",
438
+ ),
439
+ )
440
+
441
+
442
+ def _decode_app_auth_refresh_tokens(
443
+ row: Mapping[_builtins.str, object],
444
+ ) -> AppAuthRefreshTokensRow:
445
+ return AppAuthRefreshTokensRow(
446
+ consumed_at=_read_string_nullable(row["consumed_at"]),
447
+ created_at=_read_string(row["created_at"]),
448
+ expires_at=_read_string(row["expires_at"]),
449
+ id=_read_string(row["id"]),
450
+ session_id=_read_string(row["session_id"]),
451
+ token_hash=_read_string(row["token_hash"]),
452
+ )
453
+
454
+
455
+ @dataclass(frozen=True, slots=True, kw_only=True, repr=False)
456
+ class AppAuthSessionsRow:
457
+ created_at: _builtins.str
458
+ expires_at: _builtins.str
459
+ first_login_at: _builtins.str | None
460
+ id: _builtins.str
461
+ last_renewed_at: _builtins.str | None
462
+ revoked_at: _builtins.str | None
463
+ token_hash: _builtins.str
464
+ transport: _builtins.str
465
+ user_id: _builtins.str
466
+ user_session_version: _builtins.int
467
+
468
+
469
+ _app_auth_sessions_table = Table(
470
+ "app_auth_sessions",
471
+ {
472
+ "created_at": Column[_builtins.str](
473
+ "created_at",
474
+ "timestamp",
475
+ False,
476
+ ),
477
+ "expires_at": Column[_builtins.str](
478
+ "expires_at",
479
+ "timestamp",
480
+ False,
481
+ ),
482
+ "first_login_at": Column[_builtins.str | None](
483
+ "first_login_at",
484
+ "timestamp",
485
+ True,
486
+ ),
487
+ "id": Column[_builtins.str](
488
+ "id",
489
+ "id",
490
+ False,
491
+ ),
492
+ "last_renewed_at": Column[_builtins.str | None](
493
+ "last_renewed_at",
494
+ "timestamp",
495
+ True,
496
+ ),
497
+ "revoked_at": Column[_builtins.str | None](
498
+ "revoked_at",
499
+ "timestamp",
500
+ True,
501
+ ),
502
+ "token_hash": Column[_builtins.str](
503
+ "token_hash",
504
+ "string",
505
+ False,
506
+ ),
507
+ "transport": Column[_builtins.str](
508
+ "transport",
509
+ "string",
510
+ False,
511
+ ),
512
+ "user_id": Column[_builtins.str](
513
+ "user_id",
514
+ "id",
515
+ False,
516
+ ),
517
+ "user_session_version": Column[_builtins.int](
518
+ "user_session_version",
519
+ "integer",
520
+ False,
521
+ ),
522
+ },
523
+ ("id",),
524
+ (
525
+ "expires_at",
526
+ "token_hash",
527
+ "user_id",
528
+ "user_session_version",
529
+ ),
530
+ )
531
+
532
+
533
+ def _decode_app_auth_sessions(
534
+ row: Mapping[_builtins.str, object],
535
+ ) -> AppAuthSessionsRow:
536
+ return AppAuthSessionsRow(
537
+ created_at=_read_string(row["created_at"]),
538
+ expires_at=_read_string(row["expires_at"]),
539
+ first_login_at=_read_string_nullable(row["first_login_at"]),
540
+ id=_read_string(row["id"]),
541
+ last_renewed_at=_read_string_nullable(row["last_renewed_at"]),
542
+ revoked_at=_read_string_nullable(row["revoked_at"]),
543
+ token_hash=_read_string(row["token_hash"]),
544
+ transport=_read_string(row["transport"]),
545
+ user_id=_read_string(row["user_id"]),
546
+ user_session_version=_read_integer(row["user_session_version"]),
547
+ )
548
+
549
+
550
+ @dataclass(frozen=True, slots=True, kw_only=True, repr=False)
551
+ class AppAuthSignupRequestsRow:
552
+ attempts: _builtins.int
553
+ code_expires_at: _builtins.str
554
+ code_hash: _builtins.str
555
+ created_at: _builtins.str
556
+ email: _builtins.str
557
+ expires_at: _builtins.str
558
+ id: _builtins.str
559
+ invite_id: _builtins.str | None
560
+ password_hash: _builtins.str
561
+ updated_at: _builtins.str
562
+
563
+
564
+ _app_auth_signup_requests_table = Table(
565
+ "app_auth_signup_requests",
566
+ {
567
+ "attempts": Column[_builtins.int](
568
+ "attempts",
569
+ "integer",
570
+ False,
571
+ ),
572
+ "code_expires_at": Column[_builtins.str](
573
+ "code_expires_at",
574
+ "timestamp",
575
+ False,
576
+ ),
577
+ "code_hash": Column[_builtins.str](
578
+ "code_hash",
579
+ "string",
580
+ False,
581
+ ),
582
+ "created_at": Column[_builtins.str](
583
+ "created_at",
584
+ "timestamp",
585
+ False,
586
+ ),
587
+ "email": Column[_builtins.str](
588
+ "email",
589
+ "string",
590
+ False,
591
+ ),
592
+ "expires_at": Column[_builtins.str](
593
+ "expires_at",
594
+ "timestamp",
595
+ False,
596
+ ),
597
+ "id": Column[_builtins.str](
598
+ "id",
599
+ "id",
600
+ False,
601
+ ),
602
+ "invite_id": Column[_builtins.str | None](
603
+ "invite_id",
604
+ "id",
605
+ True,
606
+ ),
607
+ "password_hash": Column[_builtins.str](
608
+ "password_hash",
609
+ "string",
610
+ False,
611
+ ),
612
+ "updated_at": Column[_builtins.str](
613
+ "updated_at",
614
+ "timestamp",
615
+ False,
616
+ ),
617
+ },
618
+ ("id",),
619
+ (
620
+ "code_expires_at",
621
+ "code_hash",
622
+ "email",
623
+ "expires_at",
624
+ "password_hash",
625
+ ),
626
+ )
627
+
628
+
629
+ def _decode_app_auth_signup_requests(
630
+ row: Mapping[_builtins.str, object],
631
+ ) -> AppAuthSignupRequestsRow:
632
+ return AppAuthSignupRequestsRow(
633
+ attempts=_read_integer(row["attempts"]),
634
+ code_expires_at=_read_string(row["code_expires_at"]),
635
+ code_hash=_read_string(row["code_hash"]),
636
+ created_at=_read_string(row["created_at"]),
637
+ email=_read_string(row["email"]),
638
+ expires_at=_read_string(row["expires_at"]),
639
+ id=_read_string(row["id"]),
640
+ invite_id=_read_string_nullable(row["invite_id"]),
641
+ password_hash=_read_string(row["password_hash"]),
642
+ updated_at=_read_string(row["updated_at"]),
643
+ )
644
+
645
+
646
+ @dataclass(frozen=True, slots=True, kw_only=True, repr=False)
647
+ class AppAuthUsersRow:
648
+ created_at: _builtins.str
649
+ disabled_at: _builtins.str | None
650
+ email: _builtins.str
651
+ email_verified_at: _builtins.str | None
652
+ id: _builtins.str
653
+ password_hash: _builtins.str | None
654
+ session_version: _builtins.int
655
+
656
+
657
+ _app_auth_users_table = Table(
658
+ "app_auth_users",
659
+ {
660
+ "created_at": Column[_builtins.str](
661
+ "created_at",
662
+ "timestamp",
663
+ False,
664
+ ),
665
+ "disabled_at": Column[_builtins.str | None](
666
+ "disabled_at",
667
+ "timestamp",
668
+ True,
669
+ ),
670
+ "email": Column[_builtins.str](
671
+ "email",
672
+ "string",
673
+ False,
674
+ ),
675
+ "email_verified_at": Column[_builtins.str | None](
676
+ "email_verified_at",
677
+ "timestamp",
678
+ True,
679
+ ),
680
+ "id": Column[_builtins.str](
681
+ "id",
682
+ "id",
683
+ False,
684
+ ),
685
+ "password_hash": Column[_builtins.str | None](
686
+ "password_hash",
687
+ "string",
688
+ True,
689
+ ),
690
+ "session_version": Column[_builtins.int](
691
+ "session_version",
692
+ "integer",
693
+ False,
694
+ ),
695
+ },
696
+ ("id",),
697
+ ("email",),
698
+ )
699
+
700
+
701
+ def _decode_app_auth_users(
702
+ row: Mapping[_builtins.str, object],
703
+ ) -> AppAuthUsersRow:
704
+ return AppAuthUsersRow(
705
+ created_at=_read_string(row["created_at"]),
706
+ disabled_at=_read_string_nullable(row["disabled_at"]),
707
+ email=_read_string(row["email"]),
708
+ email_verified_at=_read_string_nullable(row["email_verified_at"]),
709
+ id=_read_string(row["id"]),
710
+ password_hash=_read_string_nullable(row["password_hash"]),
711
+ session_version=_read_integer(row["session_version"]),
712
+ )
713
+
714
+
715
+ class Database:
716
+ def __init__(self, port: DatabasePort) -> None:
717
+ self.action_tokens = Repository(
718
+ port,
719
+ _app_auth_action_tokens_table,
720
+ _decode_app_auth_action_tokens,
721
+ )
722
+ self.identities = Repository(
723
+ port,
724
+ _app_auth_identities_table,
725
+ _decode_app_auth_identities,
726
+ )
727
+ self.invites = Repository(
728
+ port,
729
+ _app_auth_invites_table,
730
+ _decode_app_auth_invites,
731
+ )
732
+ self.migrations = Repository(
733
+ port,
734
+ _app_auth_migrations_table,
735
+ _decode_app_auth_migrations,
736
+ )
737
+ self.rate_limits = Repository(
738
+ port,
739
+ _app_auth_rate_limits_table,
740
+ _decode_app_auth_rate_limits,
741
+ )
742
+ self.refresh_tokens = Repository(
743
+ port,
744
+ _app_auth_refresh_tokens_table,
745
+ _decode_app_auth_refresh_tokens,
746
+ )
747
+ self.sessions = Repository(
748
+ port,
749
+ _app_auth_sessions_table,
750
+ _decode_app_auth_sessions,
751
+ )
752
+ self.signup_requests = Repository(
753
+ port,
754
+ _app_auth_signup_requests_table,
755
+ _decode_app_auth_signup_requests,
756
+ )
757
+ self.users = Repository(
758
+ port,
759
+ _app_auth_users_table,
760
+ _decode_app_auth_users,
761
+ )
762
+
763
+
764
+ def create_database(port: DatabasePort) -> AuthDatabase:
765
+ return Database(port)