Laurent 1 month ago
commit 92516f135f
  1. 9
      LeStorage/Services.swift
  2. 27
      LeStorage/Store.swift
  3. 2
      LeStorage/StoreCenter.swift
  4. 1
      LeStorage/SyncedCollection.swift

@ -55,6 +55,15 @@ public class Services {
// MARK: - Base
/// Runs a request on the API and returns the appropriate response
/// - Parameters:
/// - path: the path of the service in the api, ie. "create-users/"
/// - method: the HTTP method to call
/// - requiresToken: whether the token must be included in the request
public func run<U: Decodable>(path: String, method: HTTPMethod, requiresToken: Bool) async throws -> U {
return try await self._runRequest(serviceCall: ServiceCall(path: path, method: method, requiresToken: requiresToken))
}
/// Runs a request using a configuration object
/// - Parameters:
/// - serviceConf: A instance of ServiceConf

@ -21,6 +21,33 @@ public enum StoreError: Error, LocalizedError {
case castIssue(type: String)
case invalidStoreLookup(from: any Storable.Type, to: any Storable.Type)
public var localizedDescription: String {
switch self {
case .missingService:
return "L'instance des services est nulle"
case .missingUsername:
return "Le nom d'utilisateur est manquant"
case .missingUserId:
return "L'identifiant utilisateur est manquant"
case .missingToken:
return "Aucun token n'est stocké"
case .missingKeychainStore:
return "Aucun magasin de trousseau n'est disponible"
case .collectionNotRegistered(let type):
return "La collection \(type) n'est pas enregistrée"
case .apiCallCollectionNotRegistered(let type):
return "La collection d'appels API n'a pas été enregistrée pour \(type)"
case .synchronizationInactive:
return "La synchronisation n'est pas active sur ce StoreCenter"
case .storeNotRegistered(let id):
return "Le magasin avec l'identifiant \(id) n'est pas enregistré"
case .castIssue(let type):
return "Problème de typage: \(type)"
case .invalidStoreLookup(let from, let to):
return "Mauvaise recherche dans le magasin de \(from) à \(to)"
}
}
public var errorDescription: String? {
switch self {
case .missingService:

@ -581,7 +581,7 @@ public class StoreCenter {
/// Basically asks the server for new content
public func synchronizeLastUpdates() async throws {
guard self.isAuthenticated else {
guard self.isAuthenticated, self.useSynchronization else {
return
}
guard !self.synchronizesData else {

@ -331,7 +331,6 @@ public class SyncedCollection<T : SyncedStorable>: SomeSyncedCollection, Collect
// self.collection.delete(instance: instance)
// }
/// Deletes the instance in the collection without synchronization
public func deleteNoSync(contentOfs sequence: any RandomAccessCollection<T>) {
self.collection.delete(contentOfs: sequence)
}

Loading…
Cancel
Save