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 755f3fd
Show file tree
Hide file tree
Showing 2 changed files with 25 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
24 changes: 12 additions & 12 deletions Sources/Storage/FileObject.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,26 @@ 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 var bucket: 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,
bucket: Bucket? = nil
) {
self.name = name
self.bucketId = bucketId
Expand All @@ -31,7 +31,7 @@ public struct FileObject: Identifiable, Hashable, Codable, Sendable {
self.createdAt = createdAt
self.lastAccessedAt = lastAccessedAt
self.metadata = metadata
self.buckets = buckets
self.bucket = bucket
}

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

0 comments on commit 755f3fd

Please sign in to comment.