1 package expo.modules.updates.db.entity
2 
3 import android.net.Uri
4 import androidx.room.*
5 import expo.modules.updates.db.enums.HashType
6 import org.json.JSONObject
7 import java.util.*
8 
9 /**
10  * Data class that represents a (potential) row in the `assets` table in SQLite. The table schema is
11  * autogenerated from this file.
12  *
13  * The `id` field here only has meaning within an individual SQLite instance, as a foreign key;
14  * unlike [UpdateEntity.id], it does *not* uniquely identify an asset across multiple installations
15  * of an app. [AssetEntity.hash] should be used in most places where a unique identifier is needed.
16  */
17 @Entity(tableName = "assets", indices = [Index(value = ["key"], unique = true)])
18 class AssetEntity(@field:ColumnInfo(name = "key") var key: String?, var type: String?) {
19   @PrimaryKey(autoGenerate = true) // 0 is treated as unset while inserting the entity into the db
20   var id: Long = 0
21 
22   var url: Uri? = null
23 
24   var headers: JSONObject? = null
25 
26   @ColumnInfo(name = "extra_request_headers")
27   var extraRequestHeaders: JSONObject? = null
28 
29   var metadata: JSONObject? = null
30 
31   @ColumnInfo(name = "download_time")
32   var downloadTime: Date? = null
33 
34   @ColumnInfo(name = "relative_path")
35   var relativePath: String? = null
36 
37   /**
38    * Hex-encoded SHA-256
39    */
40   var hash: ByteArray? = null
41 
42   @ColumnInfo(name = "hash_type")
43   var hashType = HashType.SHA256
44 
45   /**
46    * Base64URL-encoded SHA-256
47    */
48   @ColumnInfo(name = "expected_hash")
49   var expectedHash: String? = null
50 
51   @ColumnInfo(name = "marked_for_deletion")
52   var markedForDeletion = false
53 
54   @Ignore
55   var isLaunchAsset = false
56 
57   @Ignore
58   var embeddedAssetFilename: String? = null
59 
60   @Ignore
61   var resourcesFilename: String? = null
62 
63   @Ignore
64   var resourcesFolder: String? = null
65 
66   @Ignore
67   var scale: Float? = null
68 
69   @Ignore
70   var scales: Array<Float>? = null
71 }
72