Generate SSD JSON line appends from typed Jerboa

ober

3d438879e73529b75516a644f61a23820ce8eff9

diff --git a/templates/ssd-review.ss b/templates/ssd-review.ss
index 26a0012..fbb8dda 100644
--- a/templates/ssd-review.ss
+++ b/templates/ssd-review.ss
@@ -15557,7 +15557,8 @@
                 truthStoreSeedBundledTruthLocal
                 truthStoreContainedImportPathLocal
                 truthStoreValidateImportedTextLocal
-                truthStoreValidateImportedFileLocal)
+                truthStoreValidateImportedFileLocal
+                truthStoreAppendJsonLineLocal)
         (type AssetManager)
         (type Context)
         (type Exception)
@@ -15640,6 +15641,9 @@
                   (json : JSONObject)
                   (indent : Int32)) : String
           (kotlin-member-call toString))
+        (extern (truthStoreJsonToString
+                  (json : JSONObject)) : String
+          (kotlin-member-call toString))
         (extern (truthStoreConnectionInputStream
                   (connection : HttpsURLConnection)) : InputStream
           (kotlin-member-get inputStream))
@@ -16212,7 +16216,28 @@
                   (readBoundedBytes
                     input
                     (truthStoreMaxZipEntryBytes))))
-              (truthStoreInputStreamClose input))))))
+              (truthStoreInputStreamClose input))))
+        (def (truthStoreAppendJsonLineLocal
+               (store : TruthStore)
+               (file : File)
+               (json : JSONObject)) : Unit
+          (let ((previous
+                  (if (fileExists file)
+                    (truthStoreReadLocalText file)
+                    "")))
+            (let ((next
+                    (string-append
+                      (string-append
+                        previous
+                        (truthStoreJsonToString json))
+                      "\n")))
+              (begin
+                (truthStoreRequired
+                  (textUtf8BytesWithinLimit
+                    next
+                    (truthStoreMaxZipEntryBytes))
+                  "Event log quota exceeded")
+                (truthStoreAtomicWriteTextRaw store file next)))))))
 
     (kotlin-file-lines "com/sfb/ssdreview/TruthStore.kt"
       (
@@ -16862,12 +16887,8 @@
        "        else -> null"
        "    }"
        ""
-       "    internal fun appendJsonLine(file: File, json: JSONObject) {"
-       "        val previous = if (fileExists(file)) readLocalText(file) else \"\""
-       "        val next = previous + json.toString() + \"\\n\""
-       "        require(textUtf8BytesWithinLimit(next, MAX_ZIP_ENTRY_BYTES)) { \"Event log quota exceeded\" }"
-       "        atomicWriteText(file, next)"
-       "    }"
+       "    internal fun appendJsonLine(file: File, json: JSONObject) ="
+       "        truthStoreAppendJsonLineLocal(this, file, json)"
        ""
        "    private fun pushTruthAsync(truth: JSONObject) {"
        "        val payload = autosaveTruthPayloadJson(truth).toString()"