@tftt/airfin-core 0.0.0-stage → 0.1.2

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.
@@ -0,0 +1,273 @@
1
+ // src/schema.ts
2
+ import {
3
+ index,
4
+ integer,
5
+ primaryKey,
6
+ real,
7
+ sqliteTable,
8
+ text,
9
+ uniqueIndex
10
+ } from "drizzle-orm/sqlite-core";
11
+ var libraries = sqliteTable("jf_libraries", {
12
+ id: text("id").primaryKey(),
13
+ name: text("name").notNull(),
14
+ collectionType: text("collection_type").notNull(),
15
+ // 'movies' | 'tvshows'
16
+ storageId: text("storage_id").notNull(),
17
+ rootFolderId: text("root_folder_id").notNull().default("root"),
18
+ createdAt: text("created_at").notNull(),
19
+ updatedAt: text("updated_at").notNull()
20
+ });
21
+ var mediaItems = sqliteTable(
22
+ "jf_media_items",
23
+ {
24
+ id: text("id").primaryKey(),
25
+ libraryId: text("library_id").notNull().references(() => libraries.id, { onDelete: "cascade" }),
26
+ parentId: text("parent_id"),
27
+ seriesId: text("series_id"),
28
+ seasonId: text("season_id"),
29
+ type: text("type").notNull(),
30
+ // 'CollectionFolder' | 'Movie' | 'Series' | 'Season' | 'Episode'
31
+ title: text("title").notNull(),
32
+ originalTitle: text("original_title"),
33
+ sortTitle: text("sort_title").notNull(),
34
+ overview: text("overview"),
35
+ year: integer("year"),
36
+ premiereDate: text("premiere_date"),
37
+ tmdbId: integer("tmdb_id"),
38
+ imdbId: text("imdb_id"),
39
+ communityRating: real("community_rating"),
40
+ genresJson: text("genres_json"),
41
+ peopleJson: text("people_json"),
42
+ studiosJson: text("studios_json"),
43
+ posterPath: text("poster_path"),
44
+ backdropPath: text("backdrop_path"),
45
+ stillPath: text("still_path"),
46
+ seasonNumber: integer("season_number"),
47
+ episodeNumber: integer("episode_number"),
48
+ runtimeTicks: integer("runtime_ticks"),
49
+ dateAdded: text("date_added").notNull(),
50
+ updatedAt: text("updated_at").notNull(),
51
+ tmdbCollectionId: integer("tmdb_collection_id")
52
+ },
53
+ (table) => [
54
+ index("idx_jf_media_items_library_type").on(table.libraryId, table.type),
55
+ index("idx_jf_media_items_parent").on(table.parentId),
56
+ index("idx_jf_media_items_series").on(table.seriesId),
57
+ index("idx_jf_media_items_season").on(table.seasonId),
58
+ index("idx_jf_media_items_tmdb").on(table.libraryId, table.type, table.tmdbId),
59
+ index("idx_jf_media_items_tmdb_collection").on(table.tmdbCollectionId)
60
+ ]
61
+ );
62
+ var mediaFiles = sqliteTable(
63
+ "jf_media_files",
64
+ {
65
+ id: text("id").primaryKey(),
66
+ mediaItemId: text("media_item_id").notNull().references(() => mediaItems.id, { onDelete: "cascade" }),
67
+ storageId: text("storage_id").notNull(),
68
+ remoteId: text("remote_id").notNull(),
69
+ remotePath: text("remote_path").notNull(),
70
+ fileName: text("file_name").notNull(),
71
+ size: integer("size").notNull().default(0),
72
+ container: text("container").notNull(),
73
+ mediaInfoJson: text("media_info_json"),
74
+ createdAt: text("created_at").notNull(),
75
+ updatedAt: text("updated_at").notNull()
76
+ },
77
+ (table) => [
78
+ uniqueIndex("uq_jf_media_files_storage_remote").on(table.storageId, table.remoteId),
79
+ index("idx_jf_media_files_item").on(table.mediaItemId),
80
+ index("idx_jf_media_files_path").on(table.storageId, table.remotePath)
81
+ ]
82
+ );
83
+ var mediaSubtitles = sqliteTable(
84
+ "jf_media_subtitles",
85
+ {
86
+ id: text("id").primaryKey(),
87
+ mediaItemId: text("media_item_id").references(() => mediaItems.id, {
88
+ onDelete: "set null"
89
+ }),
90
+ mediaFileId: text("media_file_id").references(() => mediaFiles.id, {
91
+ onDelete: "cascade"
92
+ }),
93
+ storageId: text("storage_id").notNull(),
94
+ remoteId: text("remote_id").notNull(),
95
+ remotePath: text("remote_path").notNull(),
96
+ fileName: text("file_name").notNull(),
97
+ language: text("language").notNull().default("und"),
98
+ displayTitle: text("display_title").notNull(),
99
+ codec: text("codec").notNull(),
100
+ isDefault: integer("is_default", { mode: "boolean" }).notNull().default(false),
101
+ isForced: integer("is_forced", { mode: "boolean" }).notNull().default(false),
102
+ createdAt: text("created_at").notNull(),
103
+ updatedAt: text("updated_at").notNull()
104
+ },
105
+ (table) => [
106
+ uniqueIndex("uq_jf_media_subtitles_storage_remote").on(table.storageId, table.remoteId),
107
+ index("idx_jf_media_subtitles_item").on(table.mediaItemId),
108
+ index("idx_jf_media_subtitles_file").on(table.mediaFileId)
109
+ ]
110
+ );
111
+ var userPlayback = sqliteTable(
112
+ "jf_user_playback",
113
+ {
114
+ userId: text("user_id").notNull(),
115
+ itemId: text("item_id").notNull().references(() => mediaItems.id, { onDelete: "cascade" }),
116
+ positionTicks: integer("position_ticks").notNull().default(0),
117
+ isPlayed: integer("is_played", { mode: "boolean" }).notNull().default(false),
118
+ isFavorite: integer("is_favorite", { mode: "boolean" }).notNull().default(false),
119
+ playCount: integer("play_count").notNull().default(0),
120
+ lastPlayedAt: text("last_played_at"),
121
+ updatedAt: text("updated_at").notNull()
122
+ },
123
+ (table) => [
124
+ primaryKey({ columns: [table.userId, table.itemId] }),
125
+ index("idx_jf_user_playback_user").on(table.userId)
126
+ ]
127
+ );
128
+ var userPreferences = sqliteTable(
129
+ "jf_user_preferences",
130
+ {
131
+ userId: text("user_id").notNull(),
132
+ prefKey: text("pref_key").notNull(),
133
+ // e.g. 'display:usersettings' or 'config'
134
+ dataJson: text("data_json").notNull(),
135
+ updatedAt: text("updated_at").notNull()
136
+ },
137
+ (table) => [primaryKey({ columns: [table.userId, table.prefKey] })]
138
+ );
139
+ var customLists = sqliteTable(
140
+ "jf_custom_lists",
141
+ {
142
+ id: text("id").primaryKey(),
143
+ kind: text("kind").notNull(),
144
+ // 'Playlist' | 'BoxSet'
145
+ ownerUserId: text("owner_user_id"),
146
+ name: text("name").notNull(),
147
+ overview: text("overview"),
148
+ createdAt: text("created_at").notNull(),
149
+ updatedAt: text("updated_at").notNull(),
150
+ tmdbCollectionId: integer("tmdb_collection_id"),
151
+ posterPath: text("poster_path"),
152
+ backdropPath: text("backdrop_path"),
153
+ source: text("source").notNull().default("manual")
154
+ // 'manual' | 'tmdb'
155
+ },
156
+ (table) => [
157
+ index("idx_jf_custom_lists_kind").on(table.kind),
158
+ uniqueIndex("uq_jf_custom_lists_tmdb_collection").on(table.tmdbCollectionId)
159
+ ]
160
+ );
161
+ var customListItems = sqliteTable(
162
+ "jf_custom_list_items",
163
+ {
164
+ id: text("id").primaryKey(),
165
+ // EntryId used by Jellyfin PlaylistItemId
166
+ listId: text("list_id").notNull().references(() => customLists.id, { onDelete: "cascade" }),
167
+ itemId: text("item_id").notNull().references(() => mediaItems.id, { onDelete: "cascade" }),
168
+ position: integer("position").notNull().default(0),
169
+ addedAt: text("added_at").notNull()
170
+ },
171
+ (table) => [
172
+ index("idx_jf_custom_list_items_list").on(table.listId),
173
+ index("idx_jf_custom_list_items_item").on(table.itemId)
174
+ ]
175
+ );
176
+ var playbackHistory = sqliteTable(
177
+ "jf_playback_history",
178
+ {
179
+ id: text("id").primaryKey(),
180
+ userId: text("user_id").notNull(),
181
+ itemId: text("item_id").notNull().references(() => mediaItems.id, { onDelete: "cascade" }),
182
+ itemTitle: text("item_title").notNull(),
183
+ itemType: text("item_type").notNull(),
184
+ client: text("client"),
185
+ deviceName: text("device_name"),
186
+ playedSeconds: integer("played_seconds").notNull().default(0),
187
+ completed: integer("completed", { mode: "boolean" }).notNull().default(false),
188
+ stoppedAt: text("stopped_at").notNull()
189
+ },
190
+ (table) => [
191
+ index("idx_jf_playback_history_user").on(table.userId),
192
+ index("idx_jf_playback_history_stopped").on(table.stoppedAt)
193
+ ]
194
+ );
195
+ var liveTvSources = sqliteTable("jf_live_tv_sources", {
196
+ id: text("id").primaryKey(),
197
+ kind: text("kind").notNull(),
198
+ // 'm3u' | 'xmltv'
199
+ name: text("name").notNull(),
200
+ url: text("url").notNull(),
201
+ userAgent: text("user_agent"),
202
+ enabled: integer("enabled", { mode: "boolean" }).notNull().default(true),
203
+ lastSyncedAt: text("last_synced_at"),
204
+ lastError: text("last_error"),
205
+ createdAt: text("created_at").notNull(),
206
+ updatedAt: text("updated_at").notNull()
207
+ });
208
+ var liveTvChannels = sqliteTable(
209
+ "jf_live_tv_channels",
210
+ {
211
+ id: text("id").primaryKey(),
212
+ sourceId: text("source_id").notNull().references(() => liveTvSources.id, { onDelete: "cascade" }),
213
+ tvgId: text("tvg_id"),
214
+ number: text("number"),
215
+ name: text("name").notNull(),
216
+ groupName: text("group_name"),
217
+ logoUrl: text("logo_url"),
218
+ streamUrl: text("stream_url").notNull(),
219
+ sortOrder: integer("sort_order").notNull().default(0),
220
+ createdAt: text("created_at").notNull(),
221
+ updatedAt: text("updated_at").notNull()
222
+ },
223
+ (table) => [
224
+ index("idx_jf_live_tv_channels_source").on(table.sourceId),
225
+ index("idx_jf_live_tv_channels_tvg").on(table.tvgId)
226
+ ]
227
+ );
228
+ var liveTvPrograms = sqliteTable(
229
+ "jf_live_tv_programs",
230
+ {
231
+ id: text("id").primaryKey(),
232
+ sourceId: text("source_id").notNull().references(() => liveTvSources.id, { onDelete: "cascade" }),
233
+ channelTvgId: text("channel_tvg_id").notNull(),
234
+ title: text("title").notNull(),
235
+ overview: text("overview"),
236
+ startDate: text("start_date").notNull(),
237
+ endDate: text("end_date").notNull(),
238
+ category: text("category"),
239
+ iconUrl: text("icon_url")
240
+ },
241
+ (table) => [
242
+ index("idx_jf_live_tv_programs_source").on(table.sourceId),
243
+ index("idx_jf_live_tv_programs_channel_time").on(
244
+ table.channelTvgId,
245
+ table.startDate,
246
+ table.endDate
247
+ )
248
+ ]
249
+ );
250
+ var plugins = sqliteTable("jf_plugins", {
251
+ pluginId: text("plugin_id").primaryKey(),
252
+ isInstalled: integer("is_installed", { mode: "boolean" }),
253
+ isEnabled: integer("is_enabled", { mode: "boolean" }),
254
+ configJson: text("config_json"),
255
+ createdAt: integer("created_at").notNull(),
256
+ updatedAt: integer("updated_at").notNull()
257
+ });
258
+
259
+ export {
260
+ libraries,
261
+ mediaItems,
262
+ mediaFiles,
263
+ mediaSubtitles,
264
+ userPlayback,
265
+ userPreferences,
266
+ customLists,
267
+ customListItems,
268
+ playbackHistory,
269
+ liveTvSources,
270
+ liveTvChannels,
271
+ liveTvPrograms,
272
+ plugins
273
+ };