@@ -3,7 +3,7 @@ import Haystack
33import Foundation
44
55@available ( macOS 13 . 0 , * )
6- public class HaystackClient {
6+ public class Client {
77 private let userAgentHeaderValue = " swift-haystack-client "
88
99 public let baseUrl : URL
@@ -407,59 +407,24 @@ public class HaystackClient {
407407 }
408408}
409409
410- public enum DataFormat : String {
411- case json
412- case zinc
413-
414- // See Content Negotiation: https://haxall.io/doc/docHaystack/HttpApi.html#contentNegotiation
415- var acceptHeaderValue : String {
416- switch self {
417- case . json: return " application/json "
418- case . zinc: return " text/zinc "
419- }
420- }
421-
422- var contentTypeHeaderValue : String {
423- switch self {
424- case . json: return " application/json "
425- case . zinc: return " text/zinc; charset=utf-8 "
426- }
427- }
428- }
429-
430410enum HaystackClientError : Error {
431411 case authHelloNoWwwAuthenticateHeader
432412 case authHelloHandshakeTokenNotPresent
433413 case authHelloHashFunctionNotPresent
434414 case authHashFunctionNotRecognized( String )
435415 case authMechanismNotRecognized( String )
436416 case authMechanismNotImplemented( AuthMechanism )
437- case notLoggedIn
438417 case baseUrlCannotBeFile
418+ case notLoggedIn
419+ case pointWriteLevelIsNotIntBetween1And17
439420 case responseIsNotZinc
440421 case requestFailed( httpCode: Int , message: String ? )
441- case pointWriteLevelIsNotIntBetween1And17
442422}
443423
444424enum AuthMechanism : String {
445425 case SCRAM
446426}
447427
448- @available ( macOS 10 . 15 , * )
449- enum AuthHash : String {
450- case SHA512 = " SHA-512 "
451- case SHA256 = " SHA-256 "
452-
453- var hash : any HashFunction . Type {
454- switch self {
455- case . SHA256:
456- return CryptoKit . SHA256. self
457- case . SHA512:
458- return CryptoKit . SHA512. self
459- }
460- }
461- }
462-
463428enum HTTPHeader {
464429 static let accept = " Accept "
465430 static let authenticationInfo = " Authentication-Info "
@@ -468,33 +433,3 @@ enum HTTPHeader {
468433 static let userAgent = " User-Agent "
469434 static let wwwAuthenticate = " Www-Authenticate "
470435}
471-
472- public enum HisReadRange {
473- case today
474- case yesterday
475- case date( Haystack . Date )
476- case dateRange( from: Haystack . Date , to: Haystack . Date )
477- case dateTimeRange( from: DateTime , to: DateTime )
478- case after( DateTime )
479-
480- func toRequestString( ) -> String {
481- switch self {
482- case . today: return " today "
483- case . yesterday: return " yesterday "
484- case let . date( date) : return " \( date. toZinc ( ) ) "
485- case let . dateRange( fromDate, toDate) : return " \( fromDate. toZinc ( ) ) , \( toDate. toZinc ( ) ) "
486- case let . dateTimeRange( fromDateTime, toDateTime) : return " \( fromDateTime. toZinc ( ) ) , \( toDateTime. toZinc ( ) ) "
487- case let . after( dateTime) : return " \( dateTime. toZinc ( ) ) "
488- }
489- }
490- }
491-
492- public struct HisItem {
493- let ts : DateTime
494- let val : any Val
495-
496- public init ( ts: DateTime , val: any Val ) {
497- self . ts = ts
498- self . val = val
499- }
500- }
0 commit comments