Add governed public form intake
This commit is contained in:
@@ -5,6 +5,7 @@ from typing import Any
|
||||
import uuid
|
||||
|
||||
from sqlalchemy import (
|
||||
Boolean,
|
||||
DateTime,
|
||||
ForeignKey,
|
||||
Index,
|
||||
@@ -189,9 +190,155 @@ class FormHandoffEffect(Base, TimestampMixin):
|
||||
)
|
||||
|
||||
|
||||
class FormIntakeProfile(Base, TimestampMixin):
|
||||
__tablename__ = "form_intake_profiles"
|
||||
__table_args__ = (
|
||||
UniqueConstraint(
|
||||
"tenant_id",
|
||||
"profile_id",
|
||||
name="uq_form_intake_profile",
|
||||
),
|
||||
UniqueConstraint("public_id", name="uq_form_intake_public_id"),
|
||||
Index(
|
||||
"ix_form_intake_definition",
|
||||
"tenant_id",
|
||||
"definition_id",
|
||||
"definition_revision",
|
||||
),
|
||||
)
|
||||
|
||||
id: Mapped[str] = mapped_column(String(36), primary_key=True, default=new_uuid)
|
||||
tenant_id: Mapped[str] = mapped_column(String(36), nullable=False, index=True)
|
||||
profile_id: Mapped[str] = mapped_column(String(36), nullable=False, index=True)
|
||||
public_id: Mapped[str] = mapped_column(String(64), nullable=False, index=True)
|
||||
definition_id: Mapped[str] = mapped_column(String(255), nullable=False, index=True)
|
||||
definition_revision: Mapped[str] = mapped_column(
|
||||
String(255), nullable=False, index=True
|
||||
)
|
||||
mode: Mapped[str] = mapped_column(String(30), nullable=False, index=True)
|
||||
enabled: Mapped[bool] = mapped_column(Boolean, default=True, nullable=False)
|
||||
revision: Mapped[int] = mapped_column(Integer, default=1, nullable=False)
|
||||
custodian_ref: Mapped[str] = mapped_column(String(255), nullable=False)
|
||||
draft_ttl_seconds: Mapped[int] = mapped_column(Integer, nullable=False)
|
||||
invitation_ttl_seconds: Mapped[int] = mapped_column(Integer, nullable=False)
|
||||
rate_limit_per_minute: Mapped[int] = mapped_column(Integer, nullable=False)
|
||||
rate_window_started_at: Mapped[datetime | None] = mapped_column(
|
||||
DateTime(timezone=True), nullable=True
|
||||
)
|
||||
rate_window_count: Mapped[int] = mapped_column(Integer, default=0, nullable=False)
|
||||
created_by: Mapped[str] = mapped_column(String(255), nullable=False, index=True)
|
||||
updated_by: Mapped[str] = mapped_column(String(255), nullable=False, index=True)
|
||||
details: Mapped[dict[str, Any]] = mapped_column(
|
||||
"metadata", JSON, default=dict, nullable=False
|
||||
)
|
||||
|
||||
|
||||
class FormIntakeSession(Base, TimestampMixin):
|
||||
__tablename__ = "form_intake_sessions"
|
||||
__table_args__ = (
|
||||
UniqueConstraint(
|
||||
"tenant_id",
|
||||
"session_id",
|
||||
name="uq_form_intake_session",
|
||||
),
|
||||
UniqueConstraint("token_sha256", name="uq_form_intake_token"),
|
||||
UniqueConstraint(
|
||||
"tenant_id",
|
||||
"idempotency_key",
|
||||
name="uq_form_intake_session_idempotency",
|
||||
),
|
||||
Index(
|
||||
"ix_form_intake_session_state",
|
||||
"tenant_id",
|
||||
"profile_id",
|
||||
"status",
|
||||
"expires_at",
|
||||
),
|
||||
)
|
||||
|
||||
id: Mapped[str] = mapped_column(String(36), primary_key=True, default=new_uuid)
|
||||
tenant_id: Mapped[str] = mapped_column(String(36), nullable=False, index=True)
|
||||
session_id: Mapped[str] = mapped_column(String(36), nullable=False, index=True)
|
||||
profile_id: Mapped[str] = mapped_column(
|
||||
ForeignKey("form_intake_profiles.id", ondelete="RESTRICT"),
|
||||
nullable=False,
|
||||
index=True,
|
||||
)
|
||||
token_sha256: Mapped[str] = mapped_column(String(64), nullable=False, index=True)
|
||||
mode: Mapped[str] = mapped_column(String(30), nullable=False, index=True)
|
||||
status: Mapped[str] = mapped_column(String(30), nullable=False, index=True)
|
||||
instance_id: Mapped[str | None] = mapped_column(
|
||||
String(255), nullable=True, index=True
|
||||
)
|
||||
actor_id: Mapped[str] = mapped_column(String(255), nullable=False, index=True)
|
||||
idempotency_key: Mapped[str] = mapped_column(String(255), nullable=False)
|
||||
request_sha256: Mapped[str] = mapped_column(String(64), nullable=False)
|
||||
expires_at: Mapped[datetime] = mapped_column(
|
||||
DateTime(timezone=True), nullable=False, index=True
|
||||
)
|
||||
started_at: Mapped[datetime | None] = mapped_column(
|
||||
DateTime(timezone=True), nullable=True
|
||||
)
|
||||
submitted_at: Mapped[datetime | None] = mapped_column(
|
||||
DateTime(timezone=True), nullable=True
|
||||
)
|
||||
revoked_at: Mapped[datetime | None] = mapped_column(
|
||||
DateTime(timezone=True), nullable=True
|
||||
)
|
||||
created_by: Mapped[str] = mapped_column(String(255), nullable=False, index=True)
|
||||
details: Mapped[dict[str, Any]] = mapped_column(
|
||||
"metadata", JSON, default=dict, nullable=False
|
||||
)
|
||||
|
||||
|
||||
class FormAcknowledgement(Base, TimestampMixin):
|
||||
__tablename__ = "form_acknowledgements"
|
||||
__table_args__ = (
|
||||
UniqueConstraint(
|
||||
"tenant_id",
|
||||
"acknowledgement_id",
|
||||
name="uq_form_acknowledgement",
|
||||
),
|
||||
UniqueConstraint(
|
||||
"tenant_id",
|
||||
"idempotency_key",
|
||||
name="uq_form_acknowledgement_idempotency",
|
||||
),
|
||||
Index(
|
||||
"ix_form_acknowledgement_instance",
|
||||
"tenant_id",
|
||||
"instance_id",
|
||||
"instance_revision",
|
||||
),
|
||||
)
|
||||
|
||||
id: Mapped[str] = mapped_column(String(36), primary_key=True, default=new_uuid)
|
||||
tenant_id: Mapped[str] = mapped_column(String(36), nullable=False, index=True)
|
||||
acknowledgement_id: Mapped[str] = mapped_column(
|
||||
String(36), nullable=False, index=True
|
||||
)
|
||||
instance_id: Mapped[str] = mapped_column(String(255), nullable=False, index=True)
|
||||
instance_revision: Mapped[int] = mapped_column(Integer, nullable=False)
|
||||
statement_id: Mapped[str] = mapped_column(String(255), nullable=False)
|
||||
statement_version: Mapped[str] = mapped_column(String(255), nullable=False)
|
||||
actor_id: Mapped[str] = mapped_column(String(255), nullable=False, index=True)
|
||||
accepted_at: Mapped[datetime] = mapped_column(
|
||||
DateTime(timezone=True), nullable=False, index=True
|
||||
)
|
||||
payload_sha256: Mapped[str] = mapped_column(String(64), nullable=False)
|
||||
idempotency_key: Mapped[str] = mapped_column(String(255), nullable=False)
|
||||
request_sha256: Mapped[str] = mapped_column(String(64), nullable=False)
|
||||
details: Mapped[dict[str, Any]] = mapped_column(
|
||||
"metadata", JSON, default=dict, nullable=False
|
||||
)
|
||||
|
||||
|
||||
__all__ = [
|
||||
"FormAcknowledgement",
|
||||
"FormInstanceEvent",
|
||||
"FormHandoffEffect",
|
||||
"FormIntakeProfile",
|
||||
"FormIntakeSession",
|
||||
"FormInstanceIdentity",
|
||||
"FormInstanceRevision",
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user