| |
| |
|
|
| export interface Profile { |
| id: string |
| display_name: string |
| email: string | null |
| region: string |
| role: 'citizen' | 'admin' |
| created_at: string |
| updated_at: string |
| } |
|
|
| export interface Submission { |
| id: string |
| user_id: string |
| image_url: string |
| image_sha256: string |
| ocr_result: OcrResult | null |
| status: 'pending' | 'approved' | 'rejected' | 'duplicate' |
| reject_reason: string | null |
| reviewed_by: string | null |
| reviewed_at: string | null |
| campaign_id: string | null |
| mission_id: string | null |
| created_at: string |
| } |
|
|
| export interface OcrResult { |
| raw_text: string |
| cafe_name: string | null |
| receipt_date: string | null |
| has_tumbler_discount: boolean |
| discount_amount: number | null |
| confidence: number |
| } |
|
|
| export interface Activity { |
| id: string |
| submission_id: string |
| user_id: string |
| activity_type: string |
| cup_count: number |
| co2_grams_saved: number |
| cafe_name: string | null |
| receipt_date: string | null |
| mission_id: string | null |
| verified_at: string |
| is_koc_registered: boolean |
| } |
|
|
| export interface MyStats { |
| user_id: string |
| total_cups: number |
| total_co2_grams: number |
| total_co2_kg: number |
| first_activity: string | null |
| last_activity: string | null |
| } |
|
|
| export interface AdminTotals { |
| total_citizens: number |
| total_cups: number |
| total_co2_grams: number |
| total_co2_kg: number |
| cups_this_week: number |
| cups_this_month: number |
| } |
|
|
| export interface WeeklyActivity { |
| week_start: string |
| cups: number |
| co2_grams: number |
| co2_kg: number |
| active_citizens: number |
| } |
|
|
| export type CampaignStatus = 'draft' | 'pending_review' | 'active' | 'paused' | 'completed' |
| export type CampaignType = 'citizen_activity' | 'industrial_koc' | 'sme_support' | 'finance_trade' |
|
|
| export interface Campaign { |
| id: string |
| title: string |
| description: string | null |
| sponsor_id: string | null |
| campaign_type?: CampaignType |
| status: CampaignStatus |
| start_date: string |
| end_date: string | null |
| budget_krw: number |
| target_co2_kg: number |
| target_participants: number |
| methodology: string | null |
| platform_fee_rate: number |
| reward_pool_rate: number |
| region: string |
| nature_beneficiary_id: string | null |
| nature_beneficiary_name: string | null |
| created_at: string |
| updated_at: string |
| } |
|
|
| export interface CampaignStats { |
| campaign_id: string |
| unique_participants: number |
| total_submissions: number |
| approved_count: number |
| pending_count: number |
| rejected_count: number |
| total_co2_grams: number |
| total_co2_kg: number |
| } |
|
|
| |
|
|
| export type MissionProofType = 'receipt' | 'photo' | 'gps' | 'combo' | 'supply_cert' |
| export type MissionVerification = 'ocr' | 'ai_photo' | 'gps_fence' | 'manual' | 'supplier_data' |
| export type MissionStatus = 'active' | 'paused' | 'completed' |
|
|
| export interface GpsConfig { |
| lat: number |
| lng: number |
| radius_meters: number |
| } |
|
|
| export interface Mission { |
| id: string |
| campaign_id: string |
| title: string |
| description: string | null |
| proof_type: MissionProofType |
| verification_method: MissionVerification |
| co2_per_action_grams: number |
| daily_limit_per_user: number | null |
| total_limit_per_user: number | null |
| sort_order: number |
| status: MissionStatus |
| gps_config: GpsConfig | null |
| ai_config: unknown |
| created_at: string |
| updated_at: string |
| } |
|
|
| export interface CampaignParticipant { |
| id: string |
| campaign_id: string |
| user_id: string |
| join_method: 'self' | 'auto' | 'invite' |
| status: 'active' | 'withdrawn' | 'banned' |
| joined_at: string |
| updated_at: string |
| } |
|
|
| export interface MyMission { |
| user_id: string |
| campaign_id: string |
| joined_at: string |
| campaign_title: string |
| campaign_status: CampaignStatus |
| start_date: string |
| end_date: string | null |
| mission_id: string |
| mission_title: string |
| mission_description: string | null |
| proof_type: MissionProofType |
| verification_method: MissionVerification |
| co2_per_action_grams: number |
| daily_limit_per_user: number | null |
| total_limit_per_user: number | null |
| mission_status: MissionStatus |
| sort_order: number |
| gps_config: GpsConfig | null |
| total_completed: number |
| completed_today: number |
| is_daily_limit_reached: boolean |
| my_co2_grams: number |
| } |
|
|
| |
|
|
| export type ApprovalType = |
| | 'campaign_review' |
| | 'sme_application' |
| | 'sme_selection' |
| | 'trade_request' |
| | 'point_conversion' |
| | 'finance_registration' |
|
|
| export type ApprovalStatus = 'pending' | 'approved' | 'rejected' | 'cancelled' |
|
|
| export interface DbApprovalItem { |
| id: string |
| type: ApprovalType |
| status: ApprovalStatus |
| requester_id: string | null |
| requester_name: string |
| title: string |
| description: string | null |
| payload: Record<string, unknown> |
| reviewer_id: string | null |
| reviewer_name: string | null |
| reviewed_at: string | null |
| reject_reason: string | null |
| created_at: string |
| updated_at: string |
| } |
|
|
| export type NotificationType = 'approval_result' | 'new_request' | 'status_change' | 'system' |
|
|
| export interface DbNotification { |
| id: string |
| user_id: string |
| type: NotificationType |
| title: string |
| body: string |
| link_to: string | null |
| related_approval_id: string | null |
| read: boolean |
| created_at: string |
| } |
|
|
| export interface DbPointConversion { |
| id: string |
| user_id: string |
| co2_kg_converted: number |
| credit_ton_received: number |
| conversion_rate: number |
| approval_id: string | null |
| created_at: string |
| } |
|
|
| |
|
|
| export type FinanceOrgType = 'bank' | 'insurance' | 'securities' | 'individual' | 'public' |
| export type DbFinanceRegStatus = 'pending' | 'approved' | 'rejected' |
| export type DbTradeStatus = 'pending' | 'approved' | 'contracted' | 'rejected' | 'cancelled' |
|
|
| export interface DbFinanceRegistration { |
| id: string |
| user_id: string |
| org_name: string |
| org_type: FinanceOrgType |
| contact_name: string |
| contact_email: string |
| contact_phone: string |
| business_number: string | null |
| purpose: string |
| status: DbFinanceRegStatus |
| submitted_at: string |
| reviewed_at: string | null |
| updated_at: string |
| } |
|
|
| export interface DbFinanceTrade { |
| id: string |
| user_id: string |
| listing_id: string |
| project_name: string |
| tons: number |
| price_per_ton: number |
| total_krw: number |
| buyer_org: string |
| status: DbTradeStatus |
| admin_note: string | null |
| contract_url: string | null |
| requested_at: string |
| reviewed_at: string | null |
| contracted_at: string | null |
| approval_id: string | null |
| } |
|
|
| |
|
|
| export type DbTransactionCategory = |
| | 'BUDGET_DEPOSIT' |
| | 'FEE_DEDUCTION' |
| | 'POINT_REWARD' |
| | 'CREDIT_ISSUANCE' |
| | 'CREDIT_DONATION' |
| | 'CREDIT_RETIRE' |
|
|
| export type DbAssetType = 'KRW' | 'POINT' | 'TON' |
|
|
| export interface DbSettlementLedger { |
| id: string |
| transaction_id: string |
| campaign_id: string | null |
| sender_id: string |
| sender_name: string |
| receiver_id: string |
| receiver_name: string |
| category: DbTransactionCategory |
| asset: DbAssetType |
| amount: number |
| idempotency_key: string |
| previous_hash: string | null |
| entry_hash: string |
| description: string | null |
| reference_data: Record<string, unknown> | null |
| created_at: string |
| } |
|
|
| |
|
|
| export interface DbPointBalance { |
| user_id: string |
| campaign_id: string |
| total_earned: number |
| total_used: number |
| available: number |
| updated_at: string |
| } |
|
|
| export interface DbPointTransaction { |
| id: string |
| user_id: string |
| campaign_id: string | null |
| type: 'earn' | 'convert' | 'use' | 'refund' |
| amount: number |
| submission_id: string | null |
| description: string | null |
| created_at: string |
| } |
|
|
| |
|
|
| export interface DbCampaignEscrow { |
| campaign_id: string |
| deposited_krw: number |
| fee_deducted: number |
| reward_disbursed: number |
| available_krw: number |
| updated_at: string |
| } |
|
|
| export type DbDepositStatus = 'pending' | 'confirmed' | 'failed' | 'refunded' |
|
|
| |
| export type PointTxType = 'earn' | 'convert' | 'use' | 'refund' |
|
|
| export interface DbEscrowDeposit { |
| id: string |
| campaign_id: string |
| depositor_id: string | null |
| amount_krw: number |
| payment_method: string | null |
| payment_ref: string | null |
| status: DbDepositStatus |
| confirmed_at: string | null |
| created_at: string |
| } |
|
|
| |
|
|
| export interface DbSmeAllocationRule { |
| id: string |
| campaign_id: string |
| sme_org_id: string |
| sme_org_name: string |
| allocation_pct: number |
| is_scope3_eligible: boolean |
| created_at: string |
| updated_at: string |
| } |
|
|
| export interface DbSmeCreditDistribution { |
| id: string |
| campaign_id: string |
| rule_id: string |
| sme_org_id: string |
| sme_org_name: string |
| credit_ton: number |
| allocation_pct: number |
| is_scope3_eligible: boolean |
| ledger_txn_id: string | null |
| distributed_at: string |
| } |
|
|
| |
|
|
| export interface DbMethodologyVector { |
| id: string |
| methodology_code: string |
| registry: string |
| name_ko: string |
| name_en: string | null |
| applicability: string |
| emission_factors: Record<string, unknown> | null |
| required_params: string[] |
| embedding: number[] |
| created_at: string |
| updated_at: string |
| } |
|
|