Skip to content

Commit

Permalink
fix(storage): optional fields
Browse files Browse the repository at this point in the history
  • Loading branch information
grdsdev committed Jul 10, 2024
1 parent bcf2230 commit fe87fd5
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 20 deletions.
21 changes: 13 additions & 8 deletions Sources/Storage/Bucket.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,22 @@ import Foundation
public struct Bucket: Identifiable, Hashable, Codable, Sendable {
public var id: String
public var name: String
public var owner: String
public var isPublic: Bool
public var createdAt: Date
public var updatedAt: Date
public var owner: String?
public var isPublic: Bool?
public var createdAt: Date?
public var updatedAt: Date?
public var allowedMimeTypes: [String]?
public var fileSizeLimit: Int?
public var fileSizeLimit: Int64?

public init(
id: String, name: String, owner: String, isPublic: Bool, createdAt: Date, updatedAt: Date,
allowedMimeTypes: [String]?,
fileSizeLimit: Int?
id: String,
name: String,
owner: String? = nil,
isPublic: Bool? = nil,
createdAt: Date? = nil,
updatedAt: Date? = nil,
allowedMimeTypes: [String]? = nil,
fileSizeLimit: Int64? = nil
) {
self.id = id
self.name = name
Expand Down
20 changes: 8 additions & 12 deletions Sources/Storage/FileObject.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,24 @@ import Foundation
import Helpers

public struct FileObject: Identifiable, Hashable, Codable, Sendable {
public var name: String
public var name: String?
public var bucketId: String?
public var owner: String?
public var id: String?
public var id: UUID
public var updatedAt: Date?
public var createdAt: Date?
public var lastAccessedAt: Date?
public var metadata: [String: AnyJSON]?
public var buckets: Bucket?

public init(
name: String,
name: String? = nil,
bucketId: String? = nil,
owner: String? = nil,
id: String,
updatedAt: Date,
createdAt: Date,
lastAccessedAt: Date,
metadata: [String: AnyJSON],
buckets: Bucket? = nil
id: UUID,
updatedAt: Date? = nil,
createdAt: Date? = nil,
lastAccessedAt: Date? = nil,
metadata: [String: AnyJSON]? = nil
) {
self.name = name
self.bucketId = bucketId
Expand All @@ -31,7 +29,6 @@ public struct FileObject: Identifiable, Hashable, Codable, Sendable {
self.createdAt = createdAt
self.lastAccessedAt = lastAccessedAt
self.metadata = metadata
self.buckets = buckets
}

enum CodingKeys: String, CodingKey {
Expand All @@ -43,6 +40,5 @@ public struct FileObject: Identifiable, Hashable, Codable, Sendable {
case createdAt = "created_at"
case lastAccessedAt = "last_accessed_at"
case metadata
case buckets
}
}

0 comments on commit fe87fd5

Please sign in to comment.