field_ios

In-the-field app for Radroots on iOS
git clone https://radroots.dev/git/field_ios.git
Log | Files | Refs | README | LICENSE

TeraGeneratedRevisionSource.swift (2023B)


      1 import TeraKitBindings
      2 
      3 extension TeraGeneratedRuntimeBackend {
      4   func saveRevisionIntent(
      5     requestID: String,
      6     target: TeraRevisionTarget,
      7     replacement: TeraAddRuntimeInput
      8   ) async throws -> TeraRevisionStatus {
      9     do {
     10       return try await runtime.phase1SaveRevisionIntent(
     11         input: FfiRevisionInputRecord(
     12           requestId: requestID,
     13           schemaVersion: 1,
     14           cardId: target.cardID,
     15           sourceEventId: target.sourceEventID,
     16           sourceAddress: target.sourceAddress,
     17           authorPublicKey: target.authorPublicKey,
     18           replacement: replacement.generatedValue
     19         )
     20       ).appValue
     21     } catch {
     22       throw TeraGeneratedRuntimeFailure.from(error)
     23     }
     24   }
     25 
     26   func revisionStatus(operationID: String) async throws -> TeraRevisionStatus {
     27     do {
     28       return try await runtime.phase1RevisionStatus(operationId: operationID).appValue
     29     } catch {
     30       throw TeraGeneratedRuntimeFailure.from(error)
     31     }
     32   }
     33 
     34   func advanceRevision(operationID: String) async throws -> TeraRevisionStatus {
     35     do {
     36       return try await runtime.phase1AdvanceRevision(operationId: operationID).appValue
     37     } catch {
     38       throw TeraGeneratedRuntimeFailure.from(error)
     39     }
     40   }
     41 
     42   func cancelRevision(operationID: String) async throws -> TeraRevisionStatus {
     43     do {
     44       return try await runtime.phase1CancelRevision(operationId: operationID).appValue
     45     } catch {
     46       throw TeraGeneratedRuntimeFailure.from(error)
     47     }
     48   }
     49 
     50   func revisionSourceForm(card: TeraTodayCard, sourceDraftID: String) async throws -> TeraAddForm {
     51     do {
     52       return try await runtime.revisionSourceForm(request: FfiRevisionSourceRequest(
     53         schemaVersion: 1, sourceDraftId: sourceDraftID, commandType: card.type.addCommandType.generatedValue,
     54         cardId: card.id, sourceEventId: card.sourceEventID, sourceAddress: card.sourceAddress,
     55         authorPublicKey: card.authorPublicKey
     56       )).appValue
     57     } catch {
     58       throw TeraGeneratedRuntimeFailure.from(error)
     59     }
     60   }
     61 }