Skip to content

Commit ccdad72

Browse files
committed
Refactor
Signed-off-by: Milen Pivchev <milen.pivchev@gmail.com>
1 parent adbe551 commit ccdad72

4 files changed

Lines changed: 19 additions & 57 deletions

File tree

Sources/NextcloudKit/Models/DeclarativeUI/NKDeclarativeUICapabilities.swift renamed to Sources/NextcloudKit/Models/DeclarativeUI/NKClientIntegration.swift

Lines changed: 6 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,11 @@
1-
//
2-
// File.swift
3-
// NextcloudKit
4-
//
5-
// Created by Milen Pivchev on 10.07.25.
6-
//
1+
// SPDX-FileCopyrightText: Nextcloud GmbH
2+
// SPDX-FileCopyrightText: 2025 Milen Pivchev
3+
// SPDX-License-Identifier: GPL-3.0-or-later
74

85
import Foundation
96
import Alamofire
10-
//
11-
//public struct NKDeclarativeUI {
12-
// public struct ContextMenu: Codable {
13-
// let title: String
14-
// let url: String
15-
// }
16-
//}
17-
//
18-
//public struct DeclarativeUI: Codable {
19-
// public let contextMenu: [ContextMenuItem]
20-
//
21-
// enum CodingKeys: String, CodingKey {
22-
// case contextMenu = "context-menu"
23-
// }
24-
//}
25-
//
26-
//public struct ContextMenuItem: Codable {
27-
// public let title: String
28-
// public let endpoint: String
29-
//
30-
// public init(from decoder: Decoder) throws {
31-
// var container = try decoder.unkeyedContainer()
32-
// title = try container.decode(String.self)
33-
// endpoint = try container.decode(String.self)
34-
// }
35-
//
36-
// public func encode(to encoder: Encoder) throws {
37-
// var container = encoder.unkeyedContainer()
38-
// try container.encode(title)
39-
// try container.encode(endpoint)
40-
// }
41-
//}
427

43-
public struct NKDeclarativeUICapabilities: Codable {
8+
public struct NKClientIntegration: Codable {
449
public let apps: [String: AppContext]
4510

4611
public init(from decoder: Decoder) throws {
@@ -75,9 +40,11 @@ public struct NKDeclarativeUICapabilities: Codable {
7540
}
7641

7742
public struct AppContext: Codable {
43+
public let version: Double
7844
public let contextMenu: [ContextMenuAction]
7945

8046
enum CodingKeys: String, CodingKey {
47+
case version
8148
case contextMenu = "context-menu"
8249
}
8350
}
@@ -89,7 +56,6 @@ public struct ContextMenuAction: Codable {
8956
public let mimetypeFilters: String?
9057
public let params: [String: String]?
9158
public let icon: String?
92-
// public let filter: String?
9359

9460
enum CodingKeys: String, CodingKey {
9561
case name, url, method, icon, params

Sources/NextcloudKit/Models/DeclarativeUI/NKDeclarativeUIResponse.swift renamed to Sources/NextcloudKit/Models/DeclarativeUI/NKClientIntegrationUIResponse.swift

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
1-
//
2-
// NKDeclarativeUIResponse.swift
3-
// NextcloudKit
4-
//
5-
// Created by Milen Pivchev on 24.09.25.
6-
//
1+
// SPDX-FileCopyrightText: Nextcloud GmbH
2+
// SPDX-FileCopyrightText: 2025 Milen Pivchev
3+
// SPDX-License-Identifier: GPL-3.0-or-later
74

8-
9-
public struct NKDeclarativeUIResponse: Codable {
5+
public struct NKClientIntegrationUIResponse: Codable {
106
let version: Double
117
let root: RootContainer
128
}

Sources/NextcloudKit/NextcloudKit+Capabilities.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ public extension NextcloudKit {
132132
let assistant: Assistant?
133133
let recommendations: Recommendations?
134134
let termsOfService: TermsOfService?
135-
let declarativeUI: NKDeclarativeUICapabilities?
135+
let clientIntegration: NKClientIntegration?
136136

137137
enum CodingKeys: String, CodingKey {
138138
case downloadLimit = "downloadlimit"
@@ -146,7 +146,7 @@ public extension NextcloudKit {
146146
case assistant
147147
case recommendations
148148
case termsOfService = "terms_of_service"
149-
case declarativeUI = "declarativeui"
149+
case clientIntegration = "client_integration"
150150
}
151151

152152
struct DownloadLimit: Codable {
@@ -464,7 +464,7 @@ public extension NextcloudKit {
464464
capabilities.recommendations = json.recommendations?.enabled ?? false
465465
capabilities.termsOfService = json.termsOfService?.enabled ?? false
466466

467-
capabilities.declarativeUI = json.declarativeUI
467+
capabilities.clientIntegration = json.clientIntegration
468468

469469
// Persist capabilities in shared store
470470
await NKCapabilities.shared.setCapabilities(for: account, capabilities: capabilities)
@@ -562,7 +562,7 @@ final public class NKCapabilities: Sendable {
562562
public var termsOfService: Bool = false
563563
// public var declarativeUIEnabled: Bool = false
564564
// public var declarativeUIContextMenu: [ContextMenuItem] = []
565-
public var declarativeUI: NKDeclarativeUICapabilities? = nil
565+
public var clientIntegration: NKClientIntegration? = nil
566566
public var directEditingEditors: [NKEditorDetailsEditor] = []
567567
public var directEditingCreators: [NKEditorDetailsCreator] = []
568568
public var directEditingTemplates: [NKEditorTemplate] = []

Sources/NextcloudKit/NextcloudKit+DeclarativeUI.swift renamed to Sources/NextcloudKit/NextcloudKit+ClientIntegration.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public extension NextcloudKit {
2727
params: [String: String]? = nil,
2828
options: NKRequestOptions = NKRequestOptions(),
2929
taskHandler: @escaping (_ task: URLSessionTask) -> Void = { _ in },
30-
completion: @escaping (_ token: String?, _ uiResponse: NKDeclarativeUIResponse?, _ responseData: AFDataResponse<Data>?, _ error: NKError) -> Void) {
30+
completion: @escaping (_ token: String?, _ uiResponse: NKClientIntegrationUIResponse?, _ responseData: AFDataResponse<Data>?, _ error: NKError) -> Void) {
3131

3232
// guard let nkSession = nkCommonInstance.nksessions.session(forAccount: account),
3333
// let headers = nkCommonInstance.getStandardHeaders(account: account, options: options) else {
@@ -108,7 +108,7 @@ public extension NextcloudKit {
108108
taskHandler: @escaping (_ task: URLSessionTask) -> Void = { _ in }
109109
) async -> (
110110
account: String,
111-
uiResponse: NKDeclarativeUIResponse?,
111+
uiResponse: NKClientIntegrationUIResponse?,
112112
error: NKError
113113
) {
114114
guard let nkSession = nkCommonInstance.nksessions.session(forAccount: account),
@@ -123,9 +123,9 @@ public extension NextcloudKit {
123123
var qp: [String: Any] = [:]
124124
for (key, value) in params {
125125
switch key {
126-
case NKDeclarativeUICapabilities.Params.fileId.rawValue:
126+
case NKClientIntegration.Params.fileId.rawValue:
127127
qp[key] = fileId
128-
case NKDeclarativeUICapabilities.Params.filePath.rawValue:
128+
case NKClientIntegration.Params.filePath.rawValue:
129129
qp[key] = filePath
130130
default:
131131
qp[key] = value
@@ -160,7 +160,7 @@ public extension NextcloudKit {
160160
case .success(let data):
161161
do {
162162
let decoder = JSONDecoder()
163-
let ui = try decoder.decode(NKDeclarativeUIResponse.self, from: data)
163+
let ui = try decoder.decode(NKClientIntegrationUIResponse.self, from: data)
164164
return (account, ui, .success)
165165
} catch {
166166
nkLog(debug: "Declarative UI response decoding failed: \(error)")

0 commit comments

Comments
 (0)