forked from InsurNiffy/niff-Stellar-shurance
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclaim.dto.ts
More file actions
192 lines (152 loc) · 4.74 KB
/
Copy pathclaim.dto.ts
File metadata and controls
192 lines (152 loc) · 4.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import { Expose } from 'class-transformer';
export class ClaimMetadataDto {
@ApiProperty({ description: 'Unique claim identifier' })
@Expose()
id!: number;
@ApiProperty({ description: 'Policy ID this claim belongs to' })
@Expose()
policyId!: string;
@ApiProperty({ description: 'Creator wallet address' })
@Expose()
creatorAddress!: string;
@ApiProperty({ description: 'Current claim status' })
@Expose()
status!: 'pending' | 'approved' | 'paid' | 'rejected';
@ApiProperty({ description: 'Claim amount requested' })
@Expose()
amount!: string;
@ApiPropertyOptional({ description: 'Claim description/reason' })
@Expose()
description?: string;
@ApiProperty({ description: 'IPFS hash for evidence' })
@Expose()
evidenceHash!: string;
@ApiProperty({ description: 'Stellar ledger number when created' })
@Expose()
createdAtLedger!: number;
@ApiProperty({ description: 'Creation timestamp' })
@Expose()
createdAt!: Date;
@ApiProperty({ description: 'Last update timestamp' })
@Expose()
updatedAt!: Date;
}
export class VoteTalliesDto {
@ApiProperty({ description: 'Number of yes votes' })
@Expose()
yesVotes!: number;
@ApiProperty({ description: 'Number of no votes' })
@Expose()
noVotes!: number;
@ApiProperty({ description: 'Total votes cast' })
@Expose()
totalVotes!: number;
}
export class QuorumProgressDto {
@ApiProperty({ description: 'Required votes for quorum' })
@Expose()
required!: number;
@ApiProperty({ description: 'Current vote count' })
@Expose()
current!: number;
@ApiProperty({ description: 'Progress percentage toward quorum (0-100)' })
@Expose()
percentage!: number;
@ApiProperty({ description: 'Whether quorum has been reached' })
@Expose()
reached!: boolean;
}
export class DeadlineDto {
@ApiProperty({ description: 'Voting deadline ledger number' })
@Expose()
votingDeadlineLedger!: number;
@ApiProperty({ description: 'Voting deadline timestamp' })
@Expose()
votingDeadlineTime!: Date;
@ApiProperty({ description: 'Is voting still open' })
@Expose()
isOpen!: boolean;
@ApiPropertyOptional({ description: 'Time remaining in seconds (null if closed)' })
@Expose()
remainingSeconds?: number;
}
export class SanitizedEvidenceDto {
@ApiProperty({ description: 'IPFS gateway URL' })
@Expose()
gatewayUrl!: string;
@ApiProperty({ description: 'Sanitized IPFS hash' })
@Expose()
hash!: string;
@ApiPropertyOptional({ description: 'Cached content URL (if available)' })
@Expose()
cachedUrl?: string;
}
export class ConsistencyMetadataDto {
@ApiProperty({ description: 'Whether claim is finalized on-chain' })
@Expose()
isFinalized!: boolean;
@ApiPropertyOptional({ description: 'Indexer lag in ledgers (null if synced)' })
@Expose()
indexerLag?: number;
@ApiPropertyOptional({ description: 'Last indexed ledger number' })
@Expose()
lastIndexedLedger?: number;
@ApiProperty({ description: 'Whether data is potentially stale' })
@Expose()
isStale!: boolean;
}
export class ClaimListItemDto {
@ApiProperty({ description: 'Claim metadata' })
@Expose()
metadata!: ClaimMetadataDto;
@ApiProperty({ description: 'Vote tallies' })
@Expose()
votes!: VoteTalliesDto;
@ApiProperty({ description: 'Quorum progress' })
@Expose()
quorum!: QuorumProgressDto;
@ApiProperty({ description: 'Voting deadline information' })
@Expose()
deadline!: DeadlineDto;
@ApiProperty({ description: 'Sanitized evidence URL' })
@Expose()
evidence!: SanitizedEvidenceDto;
@ApiProperty({ description: 'Consistency metadata' })
@Expose()
consistency!: ConsistencyMetadataDto;
}
export class CursorPageDto {
@ApiProperty({
description:
'Opaque cursor to pass as `after` for the next page. Null when this is the last page.',
nullable: true,
example: 'eyJjcmVhdGVkQXQiOiIyMDI0LTAxLTAxVDAwOjAwOjAwLjAwMFoiLCJpZCI6NDJ9',
})
@Expose()
next_cursor!: string | null;
@ApiProperty({
description:
'Total rows matching the filter before pagination. ' +
'Eventually consistent — may differ by ±1 under concurrent inserts.',
example: 42,
})
@Expose()
total!: number;
}
export class ClaimsListResponseDto {
@ApiProperty({ description: 'Array of claims', type: [ClaimListItemDto] })
@Expose()
data!: ClaimListItemDto[];
@ApiProperty({ description: 'Cursor pagination metadata', type: CursorPageDto })
@Expose()
pagination!: CursorPageDto;
}
export class ClaimDetailResponseDto extends ClaimListItemDto {
@ApiPropertyOptional({ description: 'User has voted on this claim' })
@Expose()
userHasVoted?: boolean;
@ApiPropertyOptional({ description: 'User vote (if voted)' })
@Expose()
userVote?: 'yes' | 'no';
}