svc-infra 0.1.595__py3-none-any.whl → 0.1.706__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.
Potentially problematic release.
This version of svc-infra might be problematic. Click here for more details.
- svc_infra/__init__.py +58 -2
- svc_infra/apf_payments/models.py +133 -42
- svc_infra/apf_payments/provider/aiydan.py +121 -47
- svc_infra/apf_payments/provider/base.py +30 -9
- svc_infra/apf_payments/provider/stripe.py +156 -62
- svc_infra/apf_payments/schemas.py +18 -9
- svc_infra/apf_payments/service.py +98 -41
- svc_infra/apf_payments/settings.py +5 -1
- svc_infra/api/__init__.py +61 -0
- svc_infra/api/fastapi/__init__.py +15 -0
- svc_infra/api/fastapi/admin/__init__.py +3 -0
- svc_infra/api/fastapi/admin/add.py +245 -0
- svc_infra/api/fastapi/apf_payments/router.py +128 -70
- svc_infra/api/fastapi/apf_payments/setup.py +13 -6
- svc_infra/api/fastapi/auth/__init__.py +65 -0
- svc_infra/api/fastapi/auth/_cookies.py +6 -2
- svc_infra/api/fastapi/auth/add.py +17 -14
- svc_infra/api/fastapi/auth/gaurd.py +45 -16
- svc_infra/api/fastapi/auth/mfa/models.py +3 -1
- svc_infra/api/fastapi/auth/mfa/pre_auth.py +10 -6
- svc_infra/api/fastapi/auth/mfa/router.py +15 -8
- svc_infra/api/fastapi/auth/mfa/security.py +1 -2
- svc_infra/api/fastapi/auth/mfa/utils.py +2 -1
- svc_infra/api/fastapi/auth/mfa/verify.py +9 -2
- svc_infra/api/fastapi/auth/policy.py +0 -1
- svc_infra/api/fastapi/auth/providers.py +3 -1
- svc_infra/api/fastapi/auth/routers/apikey_router.py +6 -6
- svc_infra/api/fastapi/auth/routers/oauth_router.py +146 -52
- svc_infra/api/fastapi/auth/routers/session_router.py +6 -2
- svc_infra/api/fastapi/auth/security.py +31 -10
- svc_infra/api/fastapi/auth/sender.py +8 -1
- svc_infra/api/fastapi/auth/state.py +3 -1
- svc_infra/api/fastapi/auth/ws_security.py +275 -0
- svc_infra/api/fastapi/billing/router.py +73 -0
- svc_infra/api/fastapi/billing/setup.py +19 -0
- svc_infra/api/fastapi/cache/add.py +9 -5
- svc_infra/api/fastapi/db/__init__.py +5 -1
- svc_infra/api/fastapi/db/http.py +3 -1
- svc_infra/api/fastapi/db/nosql/__init__.py +39 -1
- svc_infra/api/fastapi/db/nosql/mongo/add.py +47 -32
- svc_infra/api/fastapi/db/nosql/mongo/crud_router.py +30 -11
- svc_infra/api/fastapi/db/sql/__init__.py +5 -1
- svc_infra/api/fastapi/db/sql/add.py +71 -26
- svc_infra/api/fastapi/db/sql/crud_router.py +210 -22
- svc_infra/api/fastapi/db/sql/health.py +3 -1
- svc_infra/api/fastapi/db/sql/session.py +18 -0
- svc_infra/api/fastapi/db/sql/users.py +18 -6
- svc_infra/api/fastapi/dependencies/ratelimit.py +78 -14
- svc_infra/api/fastapi/docs/add.py +173 -0
- svc_infra/api/fastapi/docs/landing.py +4 -2
- svc_infra/api/fastapi/docs/scoped.py +62 -15
- svc_infra/api/fastapi/dual/__init__.py +12 -2
- svc_infra/api/fastapi/dual/dualize.py +1 -1
- svc_infra/api/fastapi/dual/protected.py +126 -4
- svc_infra/api/fastapi/dual/public.py +25 -0
- svc_infra/api/fastapi/dual/router.py +40 -13
- svc_infra/api/fastapi/dx.py +33 -2
- svc_infra/api/fastapi/ease.py +10 -2
- svc_infra/api/fastapi/http/concurrency.py +2 -1
- svc_infra/api/fastapi/http/conditional.py +3 -1
- svc_infra/api/fastapi/middleware/debug.py +4 -1
- svc_infra/api/fastapi/middleware/errors/catchall.py +6 -2
- svc_infra/api/fastapi/middleware/errors/exceptions.py +1 -1
- svc_infra/api/fastapi/middleware/errors/handlers.py +54 -8
- svc_infra/api/fastapi/middleware/graceful_shutdown.py +104 -0
- svc_infra/api/fastapi/middleware/idempotency.py +197 -70
- svc_infra/api/fastapi/middleware/idempotency_store.py +187 -0
- svc_infra/api/fastapi/middleware/optimistic_lock.py +42 -0
- svc_infra/api/fastapi/middleware/ratelimit.py +125 -28
- svc_infra/api/fastapi/middleware/ratelimit_store.py +43 -10
- svc_infra/api/fastapi/middleware/request_id.py +27 -11
- svc_infra/api/fastapi/middleware/request_size_limit.py +3 -3
- svc_infra/api/fastapi/middleware/timeout.py +177 -0
- svc_infra/api/fastapi/openapi/apply.py +5 -3
- svc_infra/api/fastapi/openapi/conventions.py +9 -2
- svc_infra/api/fastapi/openapi/mutators.py +165 -20
- svc_infra/api/fastapi/openapi/pipeline.py +1 -1
- svc_infra/api/fastapi/openapi/security.py +3 -1
- svc_infra/api/fastapi/ops/add.py +75 -0
- svc_infra/api/fastapi/pagination.py +47 -20
- svc_infra/api/fastapi/routers/__init__.py +43 -15
- svc_infra/api/fastapi/routers/ping.py +1 -0
- svc_infra/api/fastapi/setup.py +188 -57
- svc_infra/api/fastapi/tenancy/add.py +19 -0
- svc_infra/api/fastapi/tenancy/context.py +112 -0
- svc_infra/api/fastapi/versioned.py +101 -0
- svc_infra/app/README.md +5 -5
- svc_infra/app/__init__.py +3 -1
- svc_infra/app/env.py +69 -1
- svc_infra/app/logging/add.py +9 -2
- svc_infra/app/logging/formats.py +12 -5
- svc_infra/billing/__init__.py +23 -0
- svc_infra/billing/async_service.py +147 -0
- svc_infra/billing/jobs.py +241 -0
- svc_infra/billing/models.py +177 -0
- svc_infra/billing/quotas.py +103 -0
- svc_infra/billing/schemas.py +36 -0
- svc_infra/billing/service.py +123 -0
- svc_infra/bundled_docs/README.md +5 -0
- svc_infra/bundled_docs/__init__.py +1 -0
- svc_infra/bundled_docs/getting-started.md +6 -0
- svc_infra/cache/__init__.py +9 -0
- svc_infra/cache/add.py +170 -0
- svc_infra/cache/backend.py +7 -6
- svc_infra/cache/decorators.py +81 -15
- svc_infra/cache/demo.py +2 -2
- svc_infra/cache/keys.py +24 -4
- svc_infra/cache/recache.py +26 -14
- svc_infra/cache/resources.py +14 -5
- svc_infra/cache/tags.py +19 -44
- svc_infra/cache/utils.py +3 -1
- svc_infra/cli/__init__.py +52 -8
- svc_infra/cli/__main__.py +4 -0
- svc_infra/cli/cmds/__init__.py +39 -2
- svc_infra/cli/cmds/db/nosql/mongo/mongo_cmds.py +7 -4
- svc_infra/cli/cmds/db/nosql/mongo/mongo_scaffold_cmds.py +7 -5
- svc_infra/cli/cmds/db/ops_cmds.py +270 -0
- svc_infra/cli/cmds/db/sql/alembic_cmds.py +103 -18
- svc_infra/cli/cmds/db/sql/sql_export_cmds.py +88 -0
- svc_infra/cli/cmds/db/sql/sql_scaffold_cmds.py +3 -3
- svc_infra/cli/cmds/docs/docs_cmds.py +142 -0
- svc_infra/cli/cmds/dx/__init__.py +12 -0
- svc_infra/cli/cmds/dx/dx_cmds.py +116 -0
- svc_infra/cli/cmds/health/__init__.py +179 -0
- svc_infra/cli/cmds/health/health_cmds.py +8 -0
- svc_infra/cli/cmds/help.py +4 -0
- svc_infra/cli/cmds/jobs/__init__.py +1 -0
- svc_infra/cli/cmds/jobs/jobs_cmds.py +47 -0
- svc_infra/cli/cmds/obs/obs_cmds.py +36 -15
- svc_infra/cli/cmds/sdk/__init__.py +0 -0
- svc_infra/cli/cmds/sdk/sdk_cmds.py +112 -0
- svc_infra/cli/foundation/runner.py +6 -2
- svc_infra/data/add.py +61 -0
- svc_infra/data/backup.py +58 -0
- svc_infra/data/erasure.py +45 -0
- svc_infra/data/fixtures.py +42 -0
- svc_infra/data/retention.py +61 -0
- svc_infra/db/__init__.py +15 -0
- svc_infra/db/crud_schema.py +9 -9
- svc_infra/db/inbox.py +67 -0
- svc_infra/db/nosql/__init__.py +3 -0
- svc_infra/db/nosql/core.py +30 -9
- svc_infra/db/nosql/indexes.py +3 -1
- svc_infra/db/nosql/management.py +1 -1
- svc_infra/db/nosql/mongo/README.md +13 -13
- svc_infra/db/nosql/mongo/client.py +19 -2
- svc_infra/db/nosql/mongo/settings.py +6 -2
- svc_infra/db/nosql/repository.py +35 -15
- svc_infra/db/nosql/resource.py +20 -3
- svc_infra/db/nosql/scaffold.py +9 -3
- svc_infra/db/nosql/service.py +3 -1
- svc_infra/db/nosql/types.py +6 -2
- svc_infra/db/ops.py +384 -0
- svc_infra/db/outbox.py +108 -0
- svc_infra/db/sql/apikey.py +37 -9
- svc_infra/db/sql/authref.py +9 -3
- svc_infra/db/sql/constants.py +12 -8
- svc_infra/db/sql/core.py +2 -2
- svc_infra/db/sql/management.py +11 -8
- svc_infra/db/sql/repository.py +99 -26
- svc_infra/db/sql/resource.py +5 -0
- svc_infra/db/sql/scaffold.py +6 -2
- svc_infra/db/sql/service.py +15 -5
- svc_infra/db/sql/templates/models_schemas/auth/models.py.tmpl +7 -56
- svc_infra/db/sql/templates/setup/env_async.py.tmpl +34 -12
- svc_infra/db/sql/templates/setup/env_sync.py.tmpl +29 -7
- svc_infra/db/sql/tenant.py +88 -0
- svc_infra/db/sql/uniq_hooks.py +9 -3
- svc_infra/db/sql/utils.py +138 -51
- svc_infra/db/sql/versioning.py +14 -0
- svc_infra/deploy/__init__.py +538 -0
- svc_infra/documents/__init__.py +100 -0
- svc_infra/documents/add.py +264 -0
- svc_infra/documents/ease.py +233 -0
- svc_infra/documents/models.py +114 -0
- svc_infra/documents/storage.py +264 -0
- svc_infra/dx/add.py +65 -0
- svc_infra/dx/changelog.py +74 -0
- svc_infra/dx/checks.py +68 -0
- svc_infra/exceptions.py +141 -0
- svc_infra/health/__init__.py +864 -0
- svc_infra/http/__init__.py +13 -0
- svc_infra/http/client.py +105 -0
- svc_infra/jobs/builtins/outbox_processor.py +40 -0
- svc_infra/jobs/builtins/webhook_delivery.py +95 -0
- svc_infra/jobs/easy.py +33 -0
- svc_infra/jobs/loader.py +50 -0
- svc_infra/jobs/queue.py +116 -0
- svc_infra/jobs/redis_queue.py +256 -0
- svc_infra/jobs/runner.py +79 -0
- svc_infra/jobs/scheduler.py +53 -0
- svc_infra/jobs/worker.py +40 -0
- svc_infra/loaders/__init__.py +186 -0
- svc_infra/loaders/base.py +142 -0
- svc_infra/loaders/github.py +311 -0
- svc_infra/loaders/models.py +147 -0
- svc_infra/loaders/url.py +235 -0
- svc_infra/logging/__init__.py +374 -0
- svc_infra/mcp/svc_infra_mcp.py +91 -33
- svc_infra/obs/README.md +2 -0
- svc_infra/obs/add.py +65 -9
- svc_infra/obs/cloud_dash.py +2 -1
- svc_infra/obs/grafana/dashboards/http-overview.json +45 -0
- svc_infra/obs/metrics/__init__.py +3 -4
- svc_infra/obs/metrics/asgi.py +13 -7
- svc_infra/obs/metrics/http.py +9 -5
- svc_infra/obs/metrics/sqlalchemy.py +13 -9
- svc_infra/obs/metrics.py +6 -5
- svc_infra/obs/settings.py +6 -2
- svc_infra/security/add.py +217 -0
- svc_infra/security/audit.py +92 -10
- svc_infra/security/audit_service.py +4 -3
- svc_infra/security/headers.py +15 -2
- svc_infra/security/hibp.py +14 -4
- svc_infra/security/jwt_rotation.py +74 -22
- svc_infra/security/lockout.py +11 -5
- svc_infra/security/models.py +54 -12
- svc_infra/security/oauth_models.py +73 -0
- svc_infra/security/org_invites.py +5 -3
- svc_infra/security/passwords.py +3 -1
- svc_infra/security/permissions.py +25 -2
- svc_infra/security/session.py +1 -1
- svc_infra/security/signed_cookies.py +21 -1
- svc_infra/storage/__init__.py +93 -0
- svc_infra/storage/add.py +253 -0
- svc_infra/storage/backends/__init__.py +11 -0
- svc_infra/storage/backends/local.py +339 -0
- svc_infra/storage/backends/memory.py +216 -0
- svc_infra/storage/backends/s3.py +353 -0
- svc_infra/storage/base.py +239 -0
- svc_infra/storage/easy.py +185 -0
- svc_infra/storage/settings.py +195 -0
- svc_infra/testing/__init__.py +685 -0
- svc_infra/utils.py +7 -3
- svc_infra/webhooks/__init__.py +69 -0
- svc_infra/webhooks/add.py +339 -0
- svc_infra/webhooks/encryption.py +115 -0
- svc_infra/webhooks/fastapi.py +39 -0
- svc_infra/webhooks/router.py +55 -0
- svc_infra/webhooks/service.py +70 -0
- svc_infra/webhooks/signing.py +34 -0
- svc_infra/websocket/__init__.py +79 -0
- svc_infra/websocket/add.py +140 -0
- svc_infra/websocket/client.py +282 -0
- svc_infra/websocket/config.py +69 -0
- svc_infra/websocket/easy.py +76 -0
- svc_infra/websocket/exceptions.py +61 -0
- svc_infra/websocket/manager.py +344 -0
- svc_infra/websocket/models.py +49 -0
- svc_infra-0.1.706.dist-info/LICENSE +21 -0
- svc_infra-0.1.706.dist-info/METADATA +356 -0
- svc_infra-0.1.706.dist-info/RECORD +357 -0
- svc_infra-0.1.595.dist-info/METADATA +0 -80
- svc_infra-0.1.595.dist-info/RECORD +0 -253
- {svc_infra-0.1.595.dist-info → svc_infra-0.1.706.dist-info}/WHEEL +0 -0
- {svc_infra-0.1.595.dist-info → svc_infra-0.1.706.dist-info}/entry_points.txt +0 -0
svc_infra/__init__.py
CHANGED
|
@@ -1,3 +1,59 @@
|
|
|
1
|
-
|
|
1
|
+
"""svc-infra: Service Infrastructure Toolkit.
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A comprehensive backend infrastructure library providing:
|
|
4
|
+
- API framework (FastAPI scaffolding, dual routers, auth)
|
|
5
|
+
- Database (SQL/Mongo, migrations, repositories)
|
|
6
|
+
- Caching (Redis, decorators)
|
|
7
|
+
- Jobs (background tasks, queues)
|
|
8
|
+
- Webhooks (delivery, subscriptions)
|
|
9
|
+
- Billing (Stripe/Adyen integration)
|
|
10
|
+
- Observability (logging, metrics)
|
|
11
|
+
|
|
12
|
+
Example:
|
|
13
|
+
from svc_infra.api.fastapi import easy_service_app
|
|
14
|
+
from svc_infra.api.fastapi.auth import add_auth_users
|
|
15
|
+
|
|
16
|
+
app = easy_service_app(name="MyAPI")
|
|
17
|
+
add_auth_users(app)
|
|
18
|
+
"""
|
|
19
|
+
|
|
20
|
+
from __future__ import annotations
|
|
21
|
+
|
|
22
|
+
# Core modules (lazy import pattern for optional dependencies)
|
|
23
|
+
from . import api, app, cache, db, jobs, webhooks
|
|
24
|
+
|
|
25
|
+
# Base exception
|
|
26
|
+
from .exceptions import SvcInfraError
|
|
27
|
+
|
|
28
|
+
# Content Loaders
|
|
29
|
+
from .loaders import (
|
|
30
|
+
BaseLoader,
|
|
31
|
+
GitHubLoader,
|
|
32
|
+
LoadedContent,
|
|
33
|
+
URLLoader,
|
|
34
|
+
load_github,
|
|
35
|
+
load_github_sync,
|
|
36
|
+
load_url,
|
|
37
|
+
load_url_sync,
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
__all__ = [
|
|
41
|
+
# Core modules
|
|
42
|
+
"api",
|
|
43
|
+
"app",
|
|
44
|
+
"cache",
|
|
45
|
+
"db",
|
|
46
|
+
"jobs",
|
|
47
|
+
"webhooks",
|
|
48
|
+
# Base exception
|
|
49
|
+
"SvcInfraError",
|
|
50
|
+
# Loaders
|
|
51
|
+
"BaseLoader",
|
|
52
|
+
"GitHubLoader",
|
|
53
|
+
"LoadedContent",
|
|
54
|
+
"URLLoader",
|
|
55
|
+
"load_github",
|
|
56
|
+
"load_github_sync",
|
|
57
|
+
"load_url",
|
|
58
|
+
"load_url_sync",
|
|
59
|
+
]
|
svc_infra/apf_payments/models.py
CHANGED
|
@@ -3,7 +3,16 @@ from __future__ import annotations
|
|
|
3
3
|
from datetime import datetime
|
|
4
4
|
from typing import Optional
|
|
5
5
|
|
|
6
|
-
from sqlalchemy import
|
|
6
|
+
from sqlalchemy import (
|
|
7
|
+
JSON,
|
|
8
|
+
Boolean,
|
|
9
|
+
DateTime,
|
|
10
|
+
Index,
|
|
11
|
+
Numeric,
|
|
12
|
+
String,
|
|
13
|
+
UniqueConstraint,
|
|
14
|
+
text,
|
|
15
|
+
)
|
|
7
16
|
from sqlalchemy.orm import Mapped, mapped_column
|
|
8
17
|
|
|
9
18
|
from svc_infra.db.sql.authref import user_fk_constraint, user_id_type
|
|
@@ -18,10 +27,14 @@ class PayCustomer(ModelBase):
|
|
|
18
27
|
id: Mapped[str] = mapped_column(String(64), primary_key=True)
|
|
19
28
|
|
|
20
29
|
# Tenant scoping
|
|
21
|
-
tenant_id: Mapped[str] = mapped_column(
|
|
30
|
+
tenant_id: Mapped[str] = mapped_column(
|
|
31
|
+
String(TENANT_ID_LEN), index=True, nullable=False
|
|
32
|
+
)
|
|
22
33
|
|
|
23
34
|
# Always typed to match the actual auth PK; FK is enforced at table level
|
|
24
|
-
user_id: Mapped[Optional[str]] = mapped_column(
|
|
35
|
+
user_id: Mapped[Optional[str]] = mapped_column(
|
|
36
|
+
user_id_type(), index=True, nullable=True
|
|
37
|
+
)
|
|
25
38
|
|
|
26
39
|
provider: Mapped[str] = mapped_column(String(32), index=True, nullable=False)
|
|
27
40
|
provider_customer_id: Mapped[str] = mapped_column(
|
|
@@ -29,7 +42,9 @@ class PayCustomer(ModelBase):
|
|
|
29
42
|
)
|
|
30
43
|
|
|
31
44
|
created_at: Mapped[datetime] = mapped_column(
|
|
32
|
-
DateTime(timezone=True),
|
|
45
|
+
DateTime(timezone=True),
|
|
46
|
+
server_default=text("CURRENT_TIMESTAMP"),
|
|
47
|
+
nullable=False,
|
|
33
48
|
)
|
|
34
49
|
|
|
35
50
|
__table_args__ = (
|
|
@@ -44,9 +59,13 @@ class PayIntent(ModelBase):
|
|
|
44
59
|
|
|
45
60
|
id: Mapped[str] = mapped_column(String(64), primary_key=True)
|
|
46
61
|
|
|
47
|
-
tenant_id: Mapped[str] = mapped_column(
|
|
62
|
+
tenant_id: Mapped[str] = mapped_column(
|
|
63
|
+
String(TENANT_ID_LEN), index=True, nullable=False
|
|
64
|
+
)
|
|
48
65
|
|
|
49
|
-
user_id: Mapped[Optional[str]] = mapped_column(
|
|
66
|
+
user_id: Mapped[Optional[str]] = mapped_column(
|
|
67
|
+
user_id_type(), index=True, nullable=True
|
|
68
|
+
)
|
|
50
69
|
|
|
51
70
|
provider: Mapped[str] = mapped_column(String(32), index=True, nullable=False)
|
|
52
71
|
provider_intent_id: Mapped[str] = mapped_column(
|
|
@@ -57,7 +76,9 @@ class PayIntent(ModelBase):
|
|
|
57
76
|
status: Mapped[str] = mapped_column(String(32), index=True, nullable=False)
|
|
58
77
|
client_secret: Mapped[Optional[str]] = mapped_column(String(255))
|
|
59
78
|
created_at: Mapped[datetime] = mapped_column(
|
|
60
|
-
DateTime(timezone=True),
|
|
79
|
+
DateTime(timezone=True),
|
|
80
|
+
server_default=text("CURRENT_TIMESTAMP"),
|
|
81
|
+
nullable=False,
|
|
61
82
|
)
|
|
62
83
|
confirmed_at: Mapped[Optional[datetime]] = mapped_column(DateTime(timezone=True))
|
|
63
84
|
captured: Mapped[bool] = mapped_column(Boolean, default=False, nullable=False)
|
|
@@ -74,7 +95,9 @@ class PayEvent(ModelBase):
|
|
|
74
95
|
|
|
75
96
|
id: Mapped[str] = mapped_column(String(64), primary_key=True)
|
|
76
97
|
|
|
77
|
-
tenant_id: Mapped[str] = mapped_column(
|
|
98
|
+
tenant_id: Mapped[str] = mapped_column(
|
|
99
|
+
String(TENANT_ID_LEN), index=True, nullable=False
|
|
100
|
+
)
|
|
78
101
|
|
|
79
102
|
provider: Mapped[str] = mapped_column(String(32), index=True, nullable=False)
|
|
80
103
|
provider_event_id: Mapped[str] = mapped_column(
|
|
@@ -82,9 +105,13 @@ class PayEvent(ModelBase):
|
|
|
82
105
|
)
|
|
83
106
|
type: Mapped[str] = mapped_column(String(64), index=True, nullable=False)
|
|
84
107
|
received_at: Mapped[datetime] = mapped_column(
|
|
85
|
-
DateTime(timezone=True),
|
|
108
|
+
DateTime(timezone=True),
|
|
109
|
+
server_default=text("CURRENT_TIMESTAMP"),
|
|
110
|
+
nullable=False,
|
|
86
111
|
)
|
|
87
|
-
payload_json: Mapped[dict] = mapped_column(
|
|
112
|
+
payload_json: Mapped[dict] = mapped_column(
|
|
113
|
+
JSON, nullable=False
|
|
114
|
+
) # compact JSON string
|
|
88
115
|
|
|
89
116
|
|
|
90
117
|
class LedgerEntry(ModelBase):
|
|
@@ -92,7 +119,9 @@ class LedgerEntry(ModelBase):
|
|
|
92
119
|
|
|
93
120
|
id: Mapped[str] = mapped_column(String(64), primary_key=True)
|
|
94
121
|
|
|
95
|
-
tenant_id: Mapped[str] = mapped_column(
|
|
122
|
+
tenant_id: Mapped[str] = mapped_column(
|
|
123
|
+
String(TENANT_ID_LEN), index=True, nullable=False
|
|
124
|
+
)
|
|
96
125
|
|
|
97
126
|
ts: Mapped[datetime] = mapped_column(
|
|
98
127
|
DateTime(timezone=True),
|
|
@@ -103,11 +132,17 @@ class LedgerEntry(ModelBase):
|
|
|
103
132
|
|
|
104
133
|
provider: Mapped[str] = mapped_column(String(32), index=True, nullable=False)
|
|
105
134
|
provider_ref: Mapped[Optional[str]] = mapped_column(String(128), index=True)
|
|
106
|
-
user_id: Mapped[Optional[str]] = mapped_column(
|
|
135
|
+
user_id: Mapped[Optional[str]] = mapped_column(
|
|
136
|
+
user_id_type(), index=True, nullable=True
|
|
137
|
+
)
|
|
107
138
|
amount: Mapped[int] = mapped_column(Numeric(18, 0), nullable=False)
|
|
108
139
|
currency: Mapped[str] = mapped_column(String(8), nullable=False)
|
|
109
|
-
kind: Mapped[str] = mapped_column(
|
|
110
|
-
|
|
140
|
+
kind: Mapped[str] = mapped_column(
|
|
141
|
+
String(24), nullable=False
|
|
142
|
+
) # payment|refund|fee|payout...
|
|
143
|
+
status: Mapped[str] = mapped_column(
|
|
144
|
+
String(24), nullable=False
|
|
145
|
+
) # pending|posted|void
|
|
111
146
|
|
|
112
147
|
__table_args__ = (
|
|
113
148
|
user_fk_constraint("user_id", ondelete="SET NULL"),
|
|
@@ -128,11 +163,17 @@ class PayPaymentMethod(ModelBase):
|
|
|
128
163
|
|
|
129
164
|
id: Mapped[str] = mapped_column(String(64), primary_key=True)
|
|
130
165
|
|
|
131
|
-
tenant_id: Mapped[str] = mapped_column(
|
|
166
|
+
tenant_id: Mapped[str] = mapped_column(
|
|
167
|
+
String(TENANT_ID_LEN), index=True, nullable=False
|
|
168
|
+
)
|
|
132
169
|
|
|
133
|
-
user_id: Mapped[Optional[str]] = mapped_column(
|
|
170
|
+
user_id: Mapped[Optional[str]] = mapped_column(
|
|
171
|
+
user_id_type(), index=True, nullable=True
|
|
172
|
+
)
|
|
134
173
|
provider: Mapped[str] = mapped_column(String(32), index=True, nullable=False)
|
|
135
|
-
provider_customer_id: Mapped[str] = mapped_column(
|
|
174
|
+
provider_customer_id: Mapped[str] = mapped_column(
|
|
175
|
+
String(128), index=True, nullable=False
|
|
176
|
+
)
|
|
136
177
|
provider_method_id: Mapped[str] = mapped_column(
|
|
137
178
|
String(128), unique=True, index=True, nullable=False
|
|
138
179
|
)
|
|
@@ -142,7 +183,9 @@ class PayPaymentMethod(ModelBase):
|
|
|
142
183
|
exp_year: Mapped[Optional[int]] = mapped_column(Numeric(4, 0))
|
|
143
184
|
is_default: Mapped[bool] = mapped_column(Boolean, default=False, nullable=False)
|
|
144
185
|
created_at: Mapped[datetime] = mapped_column(
|
|
145
|
-
DateTime(timezone=True),
|
|
186
|
+
DateTime(timezone=True),
|
|
187
|
+
server_default=text("CURRENT_TIMESTAMP"),
|
|
188
|
+
nullable=False,
|
|
146
189
|
)
|
|
147
190
|
|
|
148
191
|
__table_args__ = (
|
|
@@ -161,7 +204,9 @@ class PayProduct(ModelBase):
|
|
|
161
204
|
|
|
162
205
|
id: Mapped[str] = mapped_column(String(64), primary_key=True)
|
|
163
206
|
|
|
164
|
-
tenant_id: Mapped[str] = mapped_column(
|
|
207
|
+
tenant_id: Mapped[str] = mapped_column(
|
|
208
|
+
String(TENANT_ID_LEN), index=True, nullable=False
|
|
209
|
+
)
|
|
165
210
|
|
|
166
211
|
provider: Mapped[str] = mapped_column(String(32), index=True, nullable=False)
|
|
167
212
|
provider_product_id: Mapped[str] = mapped_column(
|
|
@@ -170,7 +215,9 @@ class PayProduct(ModelBase):
|
|
|
170
215
|
name: Mapped[str] = mapped_column(String(128), nullable=False)
|
|
171
216
|
active: Mapped[bool] = mapped_column(Boolean, default=True, nullable=False)
|
|
172
217
|
created_at: Mapped[datetime] = mapped_column(
|
|
173
|
-
DateTime(timezone=True),
|
|
218
|
+
DateTime(timezone=True),
|
|
219
|
+
server_default=text("CURRENT_TIMESTAMP"),
|
|
220
|
+
nullable=False,
|
|
174
221
|
)
|
|
175
222
|
|
|
176
223
|
|
|
@@ -179,20 +226,28 @@ class PayPrice(ModelBase):
|
|
|
179
226
|
|
|
180
227
|
id: Mapped[str] = mapped_column(String(64), primary_key=True)
|
|
181
228
|
|
|
182
|
-
tenant_id: Mapped[str] = mapped_column(
|
|
229
|
+
tenant_id: Mapped[str] = mapped_column(
|
|
230
|
+
String(TENANT_ID_LEN), index=True, nullable=False
|
|
231
|
+
)
|
|
183
232
|
|
|
184
233
|
provider: Mapped[str] = mapped_column(String(32), index=True, nullable=False)
|
|
185
234
|
provider_price_id: Mapped[str] = mapped_column(
|
|
186
235
|
String(128), unique=True, index=True, nullable=False
|
|
187
236
|
)
|
|
188
|
-
provider_product_id: Mapped[str] = mapped_column(
|
|
237
|
+
provider_product_id: Mapped[str] = mapped_column(
|
|
238
|
+
String(128), index=True, nullable=False
|
|
239
|
+
)
|
|
189
240
|
currency: Mapped[str] = mapped_column(String(8), nullable=False)
|
|
190
|
-
unit_amount: Mapped[int] = mapped_column(
|
|
241
|
+
unit_amount: Mapped[int] = mapped_column(
|
|
242
|
+
Numeric(18, 0), nullable=False
|
|
243
|
+
) # minor units
|
|
191
244
|
interval: Mapped[Optional[str]] = mapped_column(String(16)) # month|year|week|day
|
|
192
245
|
trial_days: Mapped[Optional[int]] = mapped_column(Numeric(5, 0))
|
|
193
246
|
active: Mapped[bool] = mapped_column(Boolean, default=True, nullable=False)
|
|
194
247
|
created_at: Mapped[datetime] = mapped_column(
|
|
195
|
-
DateTime(timezone=True),
|
|
248
|
+
DateTime(timezone=True),
|
|
249
|
+
server_default=text("CURRENT_TIMESTAMP"),
|
|
250
|
+
nullable=False,
|
|
196
251
|
)
|
|
197
252
|
|
|
198
253
|
|
|
@@ -201,23 +256,37 @@ class PaySubscription(ModelBase):
|
|
|
201
256
|
|
|
202
257
|
id: Mapped[str] = mapped_column(String(64), primary_key=True)
|
|
203
258
|
|
|
204
|
-
tenant_id: Mapped[str] = mapped_column(
|
|
259
|
+
tenant_id: Mapped[str] = mapped_column(
|
|
260
|
+
String(TENANT_ID_LEN), index=True, nullable=False
|
|
261
|
+
)
|
|
205
262
|
|
|
206
|
-
user_id: Mapped[Optional[str]] = mapped_column(
|
|
263
|
+
user_id: Mapped[Optional[str]] = mapped_column(
|
|
264
|
+
user_id_type(), index=True, nullable=True
|
|
265
|
+
)
|
|
207
266
|
provider: Mapped[str] = mapped_column(String(32), index=True, nullable=False)
|
|
208
|
-
provider_customer_id: Mapped[str] = mapped_column(
|
|
267
|
+
provider_customer_id: Mapped[str] = mapped_column(
|
|
268
|
+
String(128), index=True, nullable=False
|
|
269
|
+
)
|
|
209
270
|
provider_subscription_id: Mapped[str] = mapped_column(
|
|
210
271
|
String(128), unique=True, index=True, nullable=False
|
|
211
272
|
)
|
|
212
|
-
provider_price_id: Mapped[str] = mapped_column(
|
|
273
|
+
provider_price_id: Mapped[str] = mapped_column(
|
|
274
|
+
String(128), index=True, nullable=False
|
|
275
|
+
)
|
|
213
276
|
status: Mapped[str] = mapped_column(
|
|
214
277
|
String(32), index=True, nullable=False
|
|
215
278
|
) # active|trialing|canceled|past_due|incomplete
|
|
216
279
|
quantity: Mapped[int] = mapped_column(Numeric(10, 0), default=1, nullable=False)
|
|
217
|
-
cancel_at_period_end: Mapped[bool] = mapped_column(
|
|
218
|
-
|
|
280
|
+
cancel_at_period_end: Mapped[bool] = mapped_column(
|
|
281
|
+
Boolean, default=False, nullable=False
|
|
282
|
+
)
|
|
283
|
+
current_period_end: Mapped[Optional[datetime]] = mapped_column(
|
|
284
|
+
DateTime(timezone=True)
|
|
285
|
+
)
|
|
219
286
|
created_at: Mapped[datetime] = mapped_column(
|
|
220
|
-
DateTime(timezone=True),
|
|
287
|
+
DateTime(timezone=True),
|
|
288
|
+
server_default=text("CURRENT_TIMESTAMP"),
|
|
289
|
+
nullable=False,
|
|
221
290
|
)
|
|
222
291
|
|
|
223
292
|
__table_args__ = (
|
|
@@ -236,14 +305,20 @@ class PayInvoice(ModelBase):
|
|
|
236
305
|
|
|
237
306
|
id: Mapped[str] = mapped_column(String(64), primary_key=True)
|
|
238
307
|
|
|
239
|
-
tenant_id: Mapped[str] = mapped_column(
|
|
308
|
+
tenant_id: Mapped[str] = mapped_column(
|
|
309
|
+
String(TENANT_ID_LEN), index=True, nullable=False
|
|
310
|
+
)
|
|
240
311
|
|
|
241
|
-
user_id: Mapped[Optional[str]] = mapped_column(
|
|
312
|
+
user_id: Mapped[Optional[str]] = mapped_column(
|
|
313
|
+
user_id_type(), index=True, nullable=True
|
|
314
|
+
)
|
|
242
315
|
provider: Mapped[str] = mapped_column(String(32), index=True, nullable=False)
|
|
243
316
|
provider_invoice_id: Mapped[str] = mapped_column(
|
|
244
317
|
String(128), unique=True, index=True, nullable=False
|
|
245
318
|
)
|
|
246
|
-
provider_customer_id: Mapped[str] = mapped_column(
|
|
319
|
+
provider_customer_id: Mapped[str] = mapped_column(
|
|
320
|
+
String(128), index=True, nullable=False
|
|
321
|
+
)
|
|
247
322
|
status: Mapped[str] = mapped_column(
|
|
248
323
|
String(24), index=True, nullable=False
|
|
249
324
|
) # draft|open|paid|void|uncollectible
|
|
@@ -252,7 +327,9 @@ class PayInvoice(ModelBase):
|
|
|
252
327
|
hosted_invoice_url: Mapped[Optional[str]] = mapped_column(String(255))
|
|
253
328
|
pdf_url: Mapped[Optional[str]] = mapped_column(String(255))
|
|
254
329
|
created_at: Mapped[datetime] = mapped_column(
|
|
255
|
-
DateTime(timezone=True),
|
|
330
|
+
DateTime(timezone=True),
|
|
331
|
+
server_default=text("CURRENT_TIMESTAMP"),
|
|
332
|
+
nullable=False,
|
|
256
333
|
)
|
|
257
334
|
|
|
258
335
|
__table_args__ = (
|
|
@@ -271,9 +348,13 @@ class PaySetupIntent(ModelBase):
|
|
|
271
348
|
|
|
272
349
|
id: Mapped[str] = mapped_column(String(64), primary_key=True)
|
|
273
350
|
|
|
274
|
-
tenant_id: Mapped[str] = mapped_column(
|
|
351
|
+
tenant_id: Mapped[str] = mapped_column(
|
|
352
|
+
String(TENANT_ID_LEN), index=True, nullable=False
|
|
353
|
+
)
|
|
275
354
|
|
|
276
|
-
user_id: Mapped[Optional[str]] = mapped_column(
|
|
355
|
+
user_id: Mapped[Optional[str]] = mapped_column(
|
|
356
|
+
user_id_type(), index=True, nullable=True
|
|
357
|
+
)
|
|
277
358
|
provider: Mapped[str] = mapped_column(String(32), index=True, nullable=False)
|
|
278
359
|
provider_setup_intent_id: Mapped[str] = mapped_column(
|
|
279
360
|
String(128), unique=True, index=True, nullable=False
|
|
@@ -283,7 +364,9 @@ class PaySetupIntent(ModelBase):
|
|
|
283
364
|
) # requires_action|succeeded|canceled|processing
|
|
284
365
|
client_secret: Mapped[Optional[str]] = mapped_column(String(255))
|
|
285
366
|
created_at: Mapped[datetime] = mapped_column(
|
|
286
|
-
DateTime(timezone=True),
|
|
367
|
+
DateTime(timezone=True),
|
|
368
|
+
server_default=text("CURRENT_TIMESTAMP"),
|
|
369
|
+
nullable=False,
|
|
287
370
|
)
|
|
288
371
|
|
|
289
372
|
__table_args__ = (
|
|
@@ -297,7 +380,9 @@ class PayDispute(ModelBase):
|
|
|
297
380
|
|
|
298
381
|
id: Mapped[str] = mapped_column(String(64), primary_key=True)
|
|
299
382
|
|
|
300
|
-
tenant_id: Mapped[str] = mapped_column(
|
|
383
|
+
tenant_id: Mapped[str] = mapped_column(
|
|
384
|
+
String(TENANT_ID_LEN), index=True, nullable=False
|
|
385
|
+
)
|
|
301
386
|
|
|
302
387
|
provider: Mapped[str] = mapped_column(String(32), index=True, nullable=False)
|
|
303
388
|
provider_dispute_id: Mapped[str] = mapped_column(
|
|
@@ -312,7 +397,9 @@ class PayDispute(ModelBase):
|
|
|
312
397
|
) # needs_response|under_review|won|lost|warning_closed
|
|
313
398
|
evidence_due_by: Mapped[Optional[datetime]] = mapped_column(DateTime(timezone=True))
|
|
314
399
|
created_at: Mapped[datetime] = mapped_column(
|
|
315
|
-
DateTime(timezone=True),
|
|
400
|
+
DateTime(timezone=True),
|
|
401
|
+
server_default=text("CURRENT_TIMESTAMP"),
|
|
402
|
+
nullable=False,
|
|
316
403
|
)
|
|
317
404
|
|
|
318
405
|
|
|
@@ -321,7 +408,9 @@ class PayPayout(ModelBase):
|
|
|
321
408
|
|
|
322
409
|
id: Mapped[str] = mapped_column(String(64), primary_key=True)
|
|
323
410
|
|
|
324
|
-
tenant_id: Mapped[str] = mapped_column(
|
|
411
|
+
tenant_id: Mapped[str] = mapped_column(
|
|
412
|
+
String(TENANT_ID_LEN), index=True, nullable=False
|
|
413
|
+
)
|
|
325
414
|
|
|
326
415
|
provider: Mapped[str] = mapped_column(String(32), index=True, nullable=False)
|
|
327
416
|
provider_payout_id: Mapped[str] = mapped_column(
|
|
@@ -335,5 +424,7 @@ class PayPayout(ModelBase):
|
|
|
335
424
|
arrival_date: Mapped[Optional[datetime]] = mapped_column(DateTime(timezone=True))
|
|
336
425
|
type: Mapped[Optional[str]] = mapped_column(String(32)) # bank_account|card|...
|
|
337
426
|
created_at: Mapped[datetime] = mapped_column(
|
|
338
|
-
DateTime(timezone=True),
|
|
427
|
+
DateTime(timezone=True),
|
|
428
|
+
server_default=text("CURRENT_TIMESTAMP"),
|
|
429
|
+
nullable=False,
|
|
339
430
|
)
|