From fe87fd52089c083bb6c67c6da1e1875c5a794ca4 Mon Sep 17 00:00:00 2001 From: Guilherme Souza Date: Wed, 10 Jul 2024 11:10:22 -0300 Subject: [PATCH] fix(storage): optional fields --- Sources/Storage/Bucket.swift | 21 +++++++++++++-------- Sources/Storage/FileObject.swift | 20 ++++++++------------ 2 files changed, 21 insertions(+), 20 deletions(-) diff --git a/Sources/Storage/Bucket.swift b/Sources/Storage/Bucket.swift index ccdd29e4..3437d254 100644 --- a/Sources/Storage/Bucket.swift +++ b/Sources/Storage/Bucket.swift @@ -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 diff --git a/Sources/Storage/FileObject.swift b/Sources/Storage/FileObject.swift index 86775a0c..00e35894 100644 --- a/Sources/Storage/FileObject.swift +++ b/Sources/Storage/FileObject.swift @@ -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 @@ -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 { @@ -43,6 +40,5 @@ public struct FileObject: Identifiable, Hashable, Codable, Sendable { case createdAt = "created_at" case lastAccessedAt = "last_accessed_at" case metadata - case buckets } }