@meith/import 0.16.0

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.
package/src/types.ts ADDED
@@ -0,0 +1,176 @@
1
+ export interface ImportedUser {
2
+ readonly legacyId: number
3
+ readonly username: string
4
+ readonly email: string
5
+ readonly legacyPasswordHash: string
6
+ readonly registeredAt: Date
7
+ readonly lastVisitAt: Date | null
8
+ readonly postCount: number
9
+ readonly legacyGroupId: number
10
+ }
11
+
12
+ export interface ImportedForum {
13
+ readonly legacyId: number
14
+ readonly type: 'category' | 'forum' | 'link'
15
+ readonly title: string
16
+ readonly description: string | null
17
+ readonly legacyParentId: number | null
18
+ readonly displayOrder: number
19
+ readonly linkUrl: string | null
20
+ }
21
+
22
+ export type Visibility = 'visible' | 'unapproved' | 'deleted'
23
+
24
+ export interface ImportedThread {
25
+ readonly legacyId: number
26
+ readonly legacyForumId: number
27
+ readonly title: string
28
+ readonly legacyAuthorId: number
29
+ readonly authorUsername: string
30
+ readonly createdAt: Date
31
+ readonly lastPostAt: Date
32
+ readonly replyCount: number
33
+ readonly viewCount: number
34
+ readonly isSticky: boolean
35
+ readonly isLocked: boolean
36
+ readonly visibility: Visibility
37
+ }
38
+
39
+ export interface ImportedPost {
40
+ readonly legacyId: number
41
+ readonly legacyThreadId: number
42
+ readonly legacyForumId: number
43
+ readonly legacyAuthorId: number
44
+ readonly authorUsername: string
45
+ readonly body: string
46
+ readonly createdAt: Date
47
+ readonly editedAt: Date | null
48
+ readonly visibility: Visibility
49
+ }
50
+
51
+ export type ImportedAvatarSource = 'upload' | 'gallery' | 'remote'
52
+
53
+ export interface ImportedAvatar {
54
+ readonly legacyUserId: number
55
+ readonly source: ImportedAvatarSource
56
+ readonly path: string
57
+ readonly width: number | null
58
+ readonly height: number | null
59
+ }
60
+
61
+ export interface ImportedAttachment {
62
+ readonly legacyId: number
63
+ readonly legacyPostId: number
64
+ readonly legacyUserId: number
65
+ readonly filename: string
66
+ readonly contentType: string | null
67
+ readonly sizeBytes: number
68
+ readonly path: string
69
+ readonly thumbnailPath: string | null
70
+ readonly downloadCount: number
71
+ readonly createdAt: Date
72
+ }
73
+
74
+ export interface ImportedPollOption {
75
+ readonly order: number
76
+ readonly label: string
77
+ readonly voteCount: number
78
+ }
79
+
80
+ export interface ImportedPoll {
81
+ readonly legacyId: number
82
+ readonly legacyThreadId: number
83
+ readonly question: string
84
+ readonly options: readonly ImportedPollOption[]
85
+ readonly closesAt: Date | null
86
+ readonly createdAt: Date
87
+ readonly maxOptions: number
88
+ readonly allowRevote: boolean
89
+ readonly publicVotes: boolean
90
+ }
91
+
92
+ export interface ImportedPollVote {
93
+ readonly legacyPollId: number
94
+ readonly legacyUserId: number
95
+ readonly optionOrder: number
96
+ readonly votedAt: Date | null
97
+ }
98
+
99
+ export type ImportedMessageFolder = 'inbox' | 'sent' | 'trash'
100
+
101
+ export interface ImportedPrivateMessageCopy {
102
+ readonly legacyOwnerId: number
103
+ readonly folder: ImportedMessageFolder
104
+ readonly readAt: Date | null
105
+ }
106
+
107
+ export interface ImportedPrivateMessage {
108
+ readonly legacyId: number
109
+ readonly legacyAuthorId: number
110
+ readonly subject: string
111
+ readonly body: string
112
+ readonly sentAt: Date
113
+ readonly copies: readonly ImportedPrivateMessageCopy[]
114
+ }
115
+
116
+ export type ImportedSubscriptionMode = 'instant' | 'none'
117
+
118
+ export interface ImportedSubscription {
119
+ readonly legacyId: number
120
+ readonly legacyUserId: number
121
+ readonly legacyTargetId: number
122
+ readonly mode: ImportedSubscriptionMode
123
+ }
124
+
125
+ export interface ImportedReputation {
126
+ readonly legacyId: number
127
+ readonly legacyUserId: number
128
+ readonly legacyGivenByUserId: number
129
+ readonly legacyPostId: number | null
130
+ readonly points: number
131
+ readonly comment: string
132
+ readonly createdAt: Date
133
+ }
134
+
135
+ export interface ImportedWarning {
136
+ readonly legacyId: number
137
+ readonly legacyUserId: number
138
+ readonly legacyIssuedByUserId: number
139
+ readonly legacyPostId: number | null
140
+ readonly title: string
141
+ readonly points: number
142
+ readonly notes: string
143
+ readonly issuedAt: Date
144
+ readonly expiresAt: Date | null
145
+ readonly revokedAt: Date | null
146
+ readonly revokeReason: string | null
147
+ }
148
+
149
+ export interface ImportedBan {
150
+ readonly legacyId: number
151
+ readonly legacyUserId: number
152
+ readonly legacyBannedByUserId: number
153
+ readonly reason: string
154
+ readonly publicReason: string | null
155
+ readonly createdAt: Date
156
+ readonly expiresAt: Date | null
157
+ }
158
+
159
+ export type ImportedRelationKind = 'buddy' | 'ignore'
160
+
161
+ export interface ImportedUserRelation {
162
+ readonly legacyUserId: number
163
+ readonly legacyOtherUserId: number
164
+ readonly kind: ImportedRelationKind
165
+ }
166
+
167
+ export function fromUnixSeconds(seconds: number): Date | null {
168
+ if (!Number.isFinite(seconds) || seconds <= 0) return null
169
+ return new Date(seconds * 1000)
170
+ }
171
+
172
+ export function visibilityOf(visible: number): Visibility {
173
+ if (visible === 1) return 'visible'
174
+ if (visible === -1) return 'deleted'
175
+ return 'unapproved'
176
+ }