core-3nweb-client-lib 0.25.6 → 0.27.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (215) hide show
  1. package/README.md +2 -2
  2. package/build/api-defs/asmail.d.ts +1 -1
  3. package/build/api-defs/files.d.ts +282 -70
  4. package/build/core/app-files.js +7 -7
  5. package/build/core/asmail/config/common.js +4 -4
  6. package/build/core/asmail/config/index.js +2 -2
  7. package/build/core/asmail/config/published-intro-key.js +1 -1
  8. package/build/core/asmail/delivery/common.js +7 -7
  9. package/build/core/asmail/delivery/index.js +7 -6
  10. package/build/core/asmail/delivery/msg.js +8 -7
  11. package/build/core/asmail/delivery/per-recipient-wip.js +3 -3
  12. package/build/core/asmail/inbox/attachments/fs.js +11 -1
  13. package/build/core/asmail/inbox/cached-msgs.js +3 -3
  14. package/build/core/asmail/inbox/inbox-events.js +5 -4
  15. package/build/core/asmail/inbox/index.js +12 -12
  16. package/build/core/asmail/inbox/msg-downloader.js +3 -3
  17. package/build/core/asmail/inbox/msg-indexing.js +4 -4
  18. package/build/core/asmail/inbox/msg-on-disk.js +7 -7
  19. package/build/core/asmail/index.d.ts +3 -3
  20. package/build/core/asmail/index.js +13 -8
  21. package/build/core/asmail/key-verification.js +5 -5
  22. package/build/core/asmail/keyring/common.js +7 -6
  23. package/build/core/asmail/keyring/correspondent-keys.js +8 -7
  24. package/build/core/asmail/keyring/id-to-email-map.js +2 -1
  25. package/build/core/asmail/keyring/index.d.ts +7 -8
  26. package/build/core/asmail/keyring/index.js +15 -14
  27. package/build/core/asmail/keyring/keyring-storage.js +4 -3
  28. package/build/core/asmail/msg/opener.js +3 -3
  29. package/build/core/asmail/msg/packer.js +13 -13
  30. package/build/core/asmail/sending-params/own-params.js +4 -4
  31. package/build/core/asmail/sending-params/params-from-others.js +3 -3
  32. package/build/core/id-manager.js +8 -5
  33. package/build/core/index.d.ts +2 -1
  34. package/build/core/index.js +14 -14
  35. package/build/core/sign-in.d.ts +5 -4
  36. package/build/core/sign-in.js +12 -14
  37. package/build/core/sign-up.d.ts +1 -0
  38. package/build/core/sign-up.js +15 -11
  39. package/build/core/storage/common/json-saving.d.ts +21 -0
  40. package/build/core/storage/common/json-saving.js +82 -0
  41. package/build/core/storage/common/obj-info-file.d.ts +51 -0
  42. package/build/core/storage/common/obj-info-file.js +153 -5
  43. package/build/core/storage/common/utils.d.ts +2 -0
  44. package/build/core/storage/common/utils.js +32 -0
  45. package/build/core/storage/index.d.ts +3 -17
  46. package/build/core/storage/index.js +57 -77
  47. package/build/core/storage/local/obj-files-gc.d.ts +2 -0
  48. package/build/core/storage/local/obj-files-gc.js +53 -39
  49. package/build/core/storage/local/obj-files.d.ts +6 -9
  50. package/build/core/storage/local/obj-files.js +16 -19
  51. package/build/core/storage/local/obj-status.d.ts +20 -30
  52. package/build/core/storage/local/obj-status.js +46 -113
  53. package/build/core/storage/local/storage.d.ts +15 -5
  54. package/build/core/storage/local/storage.js +37 -18
  55. package/build/core/storage/synced/downloader.js +7 -6
  56. package/build/core/storage/synced/obj-files-gc.d.ts +6 -1
  57. package/build/core/storage/synced/obj-files-gc.js +106 -13
  58. package/build/core/storage/synced/obj-files.d.ts +46 -47
  59. package/build/core/storage/synced/obj-files.js +207 -154
  60. package/build/core/storage/synced/obj-status.d.ts +103 -42
  61. package/build/core/storage/synced/obj-status.js +525 -137
  62. package/build/core/storage/synced/remote-events.d.ts +11 -12
  63. package/build/core/storage/synced/remote-events.js +80 -57
  64. package/build/core/storage/synced/storage.d.ts +24 -5
  65. package/build/core/storage/synced/storage.js +123 -38
  66. package/build/core/storage/synced/upload-header-file.d.ts +4 -0
  67. package/build/core/storage/synced/upload-header-file.js +64 -0
  68. package/build/core/storage/synced/upsyncer.d.ts +15 -9
  69. package/build/core/storage/synced/upsyncer.js +219 -246
  70. package/build/core/storage/system-folders/apps-data.d.ts +16 -0
  71. package/build/core/storage/system-folders/apps-data.js +110 -0
  72. package/build/core/storage/system-folders/index.d.ts +18 -0
  73. package/build/core/storage/system-folders/index.js +77 -0
  74. package/build/core-ipc/common-caps.js +3 -3
  75. package/build/core-ipc/generic.js +8 -8
  76. package/build/core-ipc/startup-caps.js +2 -2
  77. package/build/cryptors.js +6 -2
  78. package/build/ipc-via-protobuf/asmail-cap.js +67 -83
  79. package/build/ipc-via-protobuf/bytes.js +16 -17
  80. package/build/ipc-via-protobuf/connector-clients-side.d.ts +3 -0
  81. package/build/ipc-via-protobuf/connector-clients-side.js +62 -25
  82. package/build/ipc-via-protobuf/connector-services-side.js +10 -10
  83. package/build/ipc-via-protobuf/connector.js +4 -4
  84. package/build/ipc-via-protobuf/file.d.ts +48 -12
  85. package/build/ipc-via-protobuf/file.js +476 -120
  86. package/build/ipc-via-protobuf/fs.d.ts +8 -0
  87. package/build/ipc-via-protobuf/fs.js +592 -159
  88. package/build/ipc-via-protobuf/log-cap.js +2 -2
  89. package/build/ipc-via-protobuf/mailerid.js +3 -3
  90. package/build/ipc-via-protobuf/protobuf-msg.d.ts +1 -0
  91. package/build/ipc-via-protobuf/protobuf-msg.js +11 -7
  92. package/build/ipc-via-protobuf/startup-cap.js +23 -23
  93. package/build/ipc-via-protobuf/storage-cap.js +12 -12
  94. package/build/ipc.js +7 -2
  95. package/build/lib-client/3nstorage/exceptions.d.ts +12 -8
  96. package/build/lib-client/3nstorage/exceptions.js +31 -10
  97. package/build/lib-client/3nstorage/service.d.ts +16 -2
  98. package/build/lib-client/3nstorage/service.js +109 -39
  99. package/build/lib-client/3nstorage/util/file-based-json.d.ts +2 -1
  100. package/build/lib-client/3nstorage/util/file-based-json.js +1 -1
  101. package/build/lib-client/3nstorage/xsp-fs/attrs.js +17 -17
  102. package/build/lib-client/3nstorage/xsp-fs/common.d.ts +52 -14
  103. package/build/lib-client/3nstorage/xsp-fs/common.js +31 -16
  104. package/build/lib-client/3nstorage/xsp-fs/file-node.d.ts +1 -0
  105. package/build/lib-client/3nstorage/xsp-fs/file-node.js +18 -14
  106. package/build/lib-client/3nstorage/xsp-fs/file.d.ts +31 -6
  107. package/build/lib-client/3nstorage/xsp-fs/file.js +74 -23
  108. package/build/lib-client/3nstorage/xsp-fs/folder-node-serialization.js +4 -4
  109. package/build/lib-client/3nstorage/xsp-fs/folder-node.d.ts +24 -11
  110. package/build/lib-client/3nstorage/xsp-fs/folder-node.js +599 -189
  111. package/build/lib-client/3nstorage/xsp-fs/fs.d.ts +45 -9
  112. package/build/lib-client/3nstorage/xsp-fs/fs.js +326 -74
  113. package/build/lib-client/3nstorage/xsp-fs/link-node.d.ts +1 -0
  114. package/build/lib-client/3nstorage/xsp-fs/link-node.js +7 -2
  115. package/build/lib-client/3nstorage/xsp-fs/node-in-fs.d.ts +30 -20
  116. package/build/lib-client/3nstorage/xsp-fs/node-in-fs.js +239 -106
  117. package/build/lib-client/3nstorage/xsp-fs/node-persistence.d.ts +1 -1
  118. package/build/lib-client/3nstorage/xsp-fs/node-persistence.js +18 -19
  119. package/build/lib-client/3nstorage/xsp-fs/xsp-payload-v1.js +5 -5
  120. package/build/lib-client/3nstorage/xsp-fs/xsp-payload-v2.js +56 -56
  121. package/build/lib-client/3nweb-signup.js +4 -4
  122. package/build/lib-client/asmail/recipient.js +15 -15
  123. package/build/lib-client/asmail/sender.js +22 -22
  124. package/build/lib-client/asmail/service-config.js +3 -3
  125. package/build/lib-client/cryptor/cryptor-in-worker.js +19 -17
  126. package/build/lib-client/cryptor/cryptor-wasm.js +1 -1
  127. package/build/lib-client/cryptor/cryptor.js +4 -2
  128. package/build/lib-client/cryptor/cryptor.wasm +0 -0
  129. package/build/lib-client/cryptor/in-proc-js.js +1 -1
  130. package/build/lib-client/cryptor/in-proc-wasm.js +7 -7
  131. package/build/lib-client/cryptor/worker-js.js +2 -2
  132. package/build/lib-client/cryptor/worker-wasm.js +2 -2
  133. package/build/lib-client/files-select.js +1 -1
  134. package/build/lib-client/files.d.ts +1 -1
  135. package/build/lib-client/files.js +71 -4
  136. package/build/lib-client/fs-collection.js +3 -2
  137. package/build/lib-client/fs-sync-utils.d.ts +5 -0
  138. package/build/lib-client/fs-sync-utils.js +61 -0
  139. package/build/lib-client/fs-view.d.ts +14 -0
  140. package/build/lib-client/fs-view.js +33 -0
  141. package/build/lib-client/key-derivation.js +1 -1
  142. package/build/lib-client/local-files/dev-file-sink.js +9 -9
  143. package/build/lib-client/local-files/dev-file-src.js +2 -2
  144. package/build/lib-client/local-files/device-fs.d.ts +1 -1
  145. package/build/lib-client/local-files/device-fs.js +56 -54
  146. package/build/lib-client/logging/log-to-file.d.ts +1 -1
  147. package/build/lib-client/logging/log-to-file.js +11 -11
  148. package/build/lib-client/mailer-id/login.js +7 -7
  149. package/build/lib-client/mailer-id/provisioner.js +12 -12
  150. package/build/lib-client/objs-on-disk/file-writing-proc.js +5 -5
  151. package/build/lib-client/objs-on-disk/obj-folders.js +33 -33
  152. package/build/lib-client/objs-on-disk/obj-on-disk.d.ts +13 -2
  153. package/build/lib-client/objs-on-disk/obj-on-disk.js +24 -9
  154. package/build/lib-client/request-utils.d.ts +1 -0
  155. package/build/lib-client/request-utils.js +14 -14
  156. package/build/lib-client/server-events.d.ts +3 -3
  157. package/build/lib-client/server-events.js +12 -10
  158. package/build/lib-client/service-locator.js +10 -10
  159. package/build/lib-client/user-with-mid-session.js +7 -7
  160. package/build/lib-client/user-with-pkl-session.js +25 -25
  161. package/build/lib-client/ws-utils.js +3 -3
  162. package/build/lib-common/async-cryptor-wrap.js +4 -4
  163. package/build/lib-common/async-fs-node.d.ts +5 -3
  164. package/build/lib-common/async-fs-node.js +19 -18
  165. package/build/lib-common/byte-streaming/pipe.js +1 -1
  166. package/build/lib-common/byte-streaming/wrapping.js +17 -17
  167. package/build/lib-common/canonical-address.js +1 -1
  168. package/build/lib-common/exceptions/error.d.ts +1 -0
  169. package/build/lib-common/exceptions/error.js +7 -6
  170. package/build/lib-common/exceptions/file.js +10 -1
  171. package/build/lib-common/ipc/generic-ipc.js +2 -2
  172. package/build/lib-common/ipc/ws-ipc.js +2 -2
  173. package/build/lib-common/json-utils.js +2 -1
  174. package/build/lib-common/mid-sigs-NaCl-Ed.js +14 -14
  175. package/build/lib-common/objs-on-disk/file-layout.d.ts +19 -0
  176. package/build/lib-common/objs-on-disk/file-layout.js +130 -12
  177. package/build/lib-common/objs-on-disk/obj-file.d.ts +13 -2
  178. package/build/lib-common/objs-on-disk/obj-file.js +99 -37
  179. package/build/lib-common/objs-on-disk/utils.d.ts +1 -0
  180. package/build/lib-common/objs-on-disk/utils.js +4 -4
  181. package/build/lib-common/objs-on-disk/v1-obj-file-format.js +14 -14
  182. package/build/lib-common/processes/deferred.d.ts +6 -0
  183. package/build/lib-common/processes/deferred.js +30 -0
  184. package/build/lib-common/processes/labelled-exec-pools.d.ts +33 -0
  185. package/build/lib-common/processes/labelled-exec-pools.js +141 -0
  186. package/build/lib-common/processes/pressure.d.ts +7 -0
  187. package/build/lib-common/processes/pressure.js +56 -0
  188. package/build/lib-common/processes/sleep.d.ts +1 -0
  189. package/build/lib-common/processes/sleep.js +26 -0
  190. package/build/lib-common/{processes.d.ts → processes/synced.d.ts} +0 -40
  191. package/build/lib-common/{processes.js → processes/synced.js} +187 -204
  192. package/build/lib-common/processes/timeout.d.ts +1 -0
  193. package/build/lib-common/processes/timeout.js +51 -0
  194. package/build/lib-common/random-node.js +7 -7
  195. package/build/lib-common/service-api/3nstorage/owner.d.ts +100 -39
  196. package/build/lib-common/service-api/3nstorage/owner.js +85 -42
  197. package/build/lib-common/service-api/asmail/delivery.js +2 -2
  198. package/build/lib-common/service-api/asmail/retrieval.js +1 -1
  199. package/build/lib-common/timed-cache.d.ts +1 -0
  200. package/build/lib-common/timed-non-weak-cache.d.ts +1 -0
  201. package/build/lib-common/timed-non-weak-cache.js +11 -0
  202. package/build/lib-common/utils-for-observables.d.ts +15 -1
  203. package/build/lib-common/utils-for-observables.js +70 -19
  204. package/build/lib-common/weak-cache.d.ts +1 -0
  205. package/build/lib-common/weak-cache.js +12 -1
  206. package/build/lib-index.d.ts +2 -1
  207. package/build/lib-index.js +10 -7
  208. package/build/protos/asmail.proto.js +12912 -7127
  209. package/build/protos/file.proto.js +4848 -2399
  210. package/build/protos/fs.proto.js +9230 -3445
  211. package/package.json +8 -7
  212. package/protos/file.proto +91 -11
  213. package/protos/fs.proto +107 -8
  214. package/build/core/storage/synced/upsync-status.d.ts +0 -41
  215. package/build/core/storage/synced/upsync-status.js +0 -158
@@ -16,7 +16,7 @@
16
16
  this program. If not, see <http://www.gnu.org/licenses/>.
17
17
  */
18
18
  Object.defineProperty(exports, "__esModule", { value: true });
19
- exports.vGetByteSink = exports.updateXAttrs = exports.vGetByteSource = exports.vReadJSON = exports.vReadTxt = exports.vReadBytes = exports.vListXAttrs = exports.vGetXAttr = exports.unpackFileEvent = exports.packFileEvent = exports.unpackJSON = exports.packJSON = exports.readBytes = exports.unpackXAttrValue = exports.packXAttrValue = exports.unpackStats = exports.packStats = exports.fileMsgType = exports.exposeFileService = exports.makeFileCaller = void 0;
19
+ exports.vListVersions = exports.remoteAdoptionOptsFromMsg = exports.remoteAdoptionOptsToMsg = exports.optionsToUploadLocalFromMsg = exports.optionsToUploadLocalToMsg = exports.vGetByteSink = exports.updateXAttrs = exports.xattrFromMsg = exports.xattrToMsg = exports.vGetByteSource = exports.vReadJSON = exports.vReadTxt = exports.vReadBytes = exports.vListXAttrs = exports.vGetXAttr = exports.unpackFileEvent = exports.packFileEvent = exports.unpackJSON = exports.packJSON = exports.readBytes = exports.unpackXAttrValue = exports.packXAttrValue = exports.unpackSyncStatus = exports.packSyncStatus = exports.unpackStats = exports.packStats = exports.fileMsgType = exports.exposeFileService = exports.makeFileCaller = void 0;
20
20
  const protobuf_msg_1 = require("./protobuf-msg");
21
21
  const protobuf_type_1 = require("../lib-client/protobuf-type");
22
22
  const file_proto_1 = require("../protos/file.proto");
@@ -25,8 +25,10 @@ const error_1 = require("../lib-common/exceptions/error");
25
25
  const bytes_1 = require("./bytes");
26
26
  const rxjs_1 = require("rxjs");
27
27
  const operators_1 = require("rxjs/operators");
28
+ const utils_for_observables_1 = require("../lib-common/utils-for-observables");
29
+ const buffer_utils_1 = require("../lib-common/buffer-utils");
28
30
  function makeFileCaller(caller, fileMsg) {
29
- connector_1.checkRefObjTypeIs('FileImpl', fileMsg.impl);
31
+ (0, connector_1.checkRefObjTypeIs)('FileImpl', fileMsg.impl);
30
32
  const objPath = fileMsg.impl.path;
31
33
  const file = {
32
34
  writable: fileMsg.writable,
@@ -58,6 +60,7 @@ function makeFileCaller(caller, fileMsg) {
58
60
  readBytes: vReadBytes.makeCaller(caller, vPath),
59
61
  readJSON: vReadJSON.makeCaller(caller, vPath),
60
62
  readTxt: vReadTxt.makeCaller(caller, vPath),
63
+ listVersions: vListVersions.makeCaller(caller, vPath)
61
64
  };
62
65
  if (file.writable) {
63
66
  file.v.copy = vCopy.makeCaller(caller, vPath);
@@ -66,6 +69,21 @@ function makeFileCaller(caller, fileMsg) {
66
69
  file.v.writeBytes = vWriteBytes.makeCaller(caller, vPath);
67
70
  file.v.writeJSON = vWriteJSON.makeCaller(caller, vPath);
68
71
  file.v.writeTxt = vWriteTxt.makeCaller(caller, vPath);
72
+ file.v.archiveCurrent = vArchiveCurrent.makeCaller(caller, vPath);
73
+ }
74
+ if (fileMsg.isSynced) {
75
+ const vsPath = objPath.concat('v', 'sync');
76
+ const vsConnectPath = objPath.concat('v', 'sync', 'connect');
77
+ file.v.sync = {
78
+ status: vsStatus.makeCaller(caller, vsPath),
79
+ updateStatusInfo: vsUpdateStatusInfo.makeCaller(caller, vsPath),
80
+ isRemoteVersionOnDisk: vsIsRemoteVersionOnDisk.makeCaller(caller, vsPath),
81
+ download: vsDownload.makeCaller(caller, vsPath),
82
+ adoptRemote: vsAdoptRemote.makeCaller(caller, vsPath),
83
+ };
84
+ if (file.writable) {
85
+ file.v.sync.upload = vsUpload.makeCaller(caller, vsPath);
86
+ }
69
87
  }
70
88
  }
71
89
  caller.registerClientDrop(file, fileMsg.impl);
@@ -98,15 +116,29 @@ function exposeFileService(file, expServices) {
98
116
  listXAttrs: vListXAttrs.wrapService(file.v.listXAttrs),
99
117
  readBytes: vReadBytes.wrapService(file.v.readBytes),
100
118
  readJSON: vReadJSON.wrapService(file.v.readJSON),
101
- readTxt: vReadTxt.wrapService(file.v.readTxt)
119
+ readTxt: vReadTxt.wrapService(file.v.readTxt),
120
+ listVersions: vListVersions.wrapService(file.v.listVersions)
102
121
  };
103
122
  if (file.writable) {
104
- implExp.copy = vCopy.wrapService(file.v.copy, expServices);
105
- implExp.getByteSink = vGetByteSink.wrapService(file.v.getByteSink, expServices);
106
- implExp.updateXAttrs = vUpdateXAttrs.wrapService(file.v.updateXAttrs);
107
- implExp.writeBytes = vWriteBytes.wrapService(file.v.writeBytes);
108
- implExp.writeJSON = vWriteJSON.wrapService(file.v.writeJSON);
109
- implExp.writeTxt = vWriteTxt.wrapService(file.v.writeTxt);
123
+ implExp.v.copy = vCopy.wrapService(file.v.copy, expServices);
124
+ implExp.v.getByteSink = vGetByteSink.wrapService(file.v.getByteSink, expServices);
125
+ implExp.v.updateXAttrs = vUpdateXAttrs.wrapService(file.v.updateXAttrs);
126
+ implExp.v.writeBytes = vWriteBytes.wrapService(file.v.writeBytes);
127
+ implExp.v.writeJSON = vWriteJSON.wrapService(file.v.writeJSON);
128
+ implExp.v.writeTxt = vWriteTxt.wrapService(file.v.writeTxt);
129
+ implExp.v.archiveCurrent = vArchiveCurrent.wrapService(file.v.archiveCurrent);
130
+ }
131
+ if (file.v.sync) {
132
+ implExp.v.sync = {
133
+ status: vsStatus.wrapService(file.v.sync.status),
134
+ updateStatusInfo: vsUpdateStatusInfo.wrapService(file.v.sync.updateStatusInfo),
135
+ isRemoteVersionOnDisk: vsIsRemoteVersionOnDisk.wrapService(file.v.sync.isRemoteVersionOnDisk),
136
+ download: vsDownload.wrapService(file.v.sync.download),
137
+ adoptRemote: vsAdoptRemote.wrapService(file.v.sync.adoptRemote),
138
+ };
139
+ if (file.writable) {
140
+ implExp.v.sync.upload = vsUpload.wrapService(file.v.sync.upload);
141
+ }
110
142
  }
111
143
  }
112
144
  const impl = expServices.exposeDroppableService('FileImpl', implExp, file);
@@ -115,7 +147,8 @@ function exposeFileService(file, expServices) {
115
147
  isNew: file.isNew,
116
148
  name: file.name,
117
149
  writable: file.writable,
118
- isVersioned: !!file.v
150
+ isVersioned: !!file.v,
151
+ isSynced: !!(file.v && file.v.sync)
119
152
  };
120
153
  return fileMsg;
121
154
  }
@@ -125,13 +158,13 @@ const statsMsgType = protobuf_type_1.ProtoType.for(file_proto_1.file.StatsMsg);
125
158
  function packStats(s) {
126
159
  const msg = {
127
160
  writable: s.writable,
128
- isFile: protobuf_msg_1.toOptVal(s.isFile),
129
- isFolder: protobuf_msg_1.toOptVal(s.isFolder),
130
- isLink: protobuf_msg_1.toOptVal(s.isLink),
131
- ctime: (s.ctime ? protobuf_msg_1.toVal(s.ctime.valueOf()) : undefined),
132
- mtime: (s.mtime ? protobuf_msg_1.toVal(s.mtime.valueOf()) : undefined),
133
- size: protobuf_msg_1.toOptVal(s.size),
134
- version: protobuf_msg_1.toOptVal(s.version)
161
+ isFile: (0, protobuf_msg_1.toOptVal)(s.isFile),
162
+ isFolder: (0, protobuf_msg_1.toOptVal)(s.isFolder),
163
+ isLink: (0, protobuf_msg_1.toOptVal)(s.isLink),
164
+ ctime: (s.ctime ? (0, protobuf_msg_1.toVal)(s.ctime.valueOf()) : undefined),
165
+ mtime: (s.mtime ? (0, protobuf_msg_1.toVal)(s.mtime.valueOf()) : undefined),
166
+ size: (0, protobuf_msg_1.toOptVal)(s.size),
167
+ version: (0, protobuf_msg_1.toOptVal)(s.version),
135
168
  };
136
169
  return statsMsgType.pack(msg);
137
170
  }
@@ -140,17 +173,70 @@ function unpackStats(buf) {
140
173
  const m = statsMsgType.unpack(buf);
141
174
  return {
142
175
  writable: m.writable,
143
- isFile: protobuf_msg_1.valOfOpt(m.isFile),
144
- isFolder: protobuf_msg_1.valOfOpt(m.isFolder),
145
- isLink: protobuf_msg_1.valOfOpt(m.isLink),
146
- size: protobuf_msg_1.valOfOptInt(m.size),
147
- version: protobuf_msg_1.valOfOptInt(m.version),
148
- ctime: (m.ctime ? new Date(protobuf_msg_1.valOfOptInt(m.ctime)) : undefined),
149
- mtime: (m.mtime ? new Date(protobuf_msg_1.valOfOptInt(m.mtime)) : undefined),
176
+ isFile: (0, protobuf_msg_1.valOfOpt)(m.isFile),
177
+ isFolder: (0, protobuf_msg_1.valOfOpt)(m.isFolder),
178
+ isLink: (0, protobuf_msg_1.valOfOpt)(m.isLink),
179
+ size: (0, protobuf_msg_1.valOfOptInt)(m.size),
180
+ version: (0, protobuf_msg_1.valOfOptInt)(m.version),
181
+ ctime: (m.ctime ? new Date((0, protobuf_msg_1.valOfOptInt)(m.ctime)) : undefined),
182
+ mtime: (m.mtime ? new Date((0, protobuf_msg_1.valOfOptInt)(m.mtime)) : undefined),
150
183
  };
151
184
  }
152
185
  exports.unpackStats = unpackStats;
153
- const fileType = protobuf_type_1.ProtoType.for(file_proto_1.file.File);
186
+ function syncStatusToMsg(s) {
187
+ if (!s) {
188
+ return;
189
+ }
190
+ return {
191
+ state: s.state,
192
+ local: syncBranchToMsg(s.local),
193
+ synced: syncBranchToMsg(s.synced),
194
+ remote: syncBranchToMsg(s.remote),
195
+ existsInSyncedParent: (0, protobuf_msg_1.toOptVal)(s.existsInSyncedParent)
196
+ };
197
+ }
198
+ function msgToSyncStatus(m) {
199
+ if (!m) {
200
+ return;
201
+ }
202
+ return {
203
+ state: m.state,
204
+ local: msgToSyncBranch(m.local),
205
+ synced: msgToSyncBranch(m.synced),
206
+ remote: msgToSyncBranch(m.remote),
207
+ existsInSyncedParent: (0, protobuf_msg_1.valOfOpt)(m.existsInSyncedParent)
208
+ };
209
+ }
210
+ function syncBranchToMsg(b) {
211
+ if (!b) {
212
+ return;
213
+ }
214
+ return {
215
+ latest: (0, protobuf_msg_1.toOptVal)(b.latest),
216
+ archived: (b.archived ? b.archived : undefined),
217
+ isArchived: (0, protobuf_msg_1.toOptVal)(b.isArchived)
218
+ };
219
+ }
220
+ function msgToSyncBranch(m) {
221
+ if (!m) {
222
+ return;
223
+ }
224
+ return {
225
+ latest: (0, protobuf_msg_1.valOfOptInt)(m.latest),
226
+ archived: ((m.archived.length > 0) ?
227
+ m.archived.map(protobuf_msg_1.fixInt) : undefined),
228
+ isArchived: (0, protobuf_msg_1.valOfOpt)(m.isArchived)
229
+ };
230
+ }
231
+ const syncStatusMsgType = protobuf_type_1.ProtoType.for(file_proto_1.file.SyncStatusMsg);
232
+ function packSyncStatus(s) {
233
+ return syncStatusMsgType.pack(syncStatusToMsg(s));
234
+ }
235
+ exports.packSyncStatus = packSyncStatus;
236
+ function unpackSyncStatus(buf) {
237
+ return msgToSyncStatus(syncStatusMsgType.unpack(buf));
238
+ }
239
+ exports.unpackSyncStatus = unpackSyncStatus;
154
240
  var stat;
155
241
  (function (stat) {
156
242
  function wrapService(fn) {
@@ -173,29 +259,29 @@ Object.freeze(stat);
173
259
  const xattrValueType = protobuf_type_1.ProtoType.for(file_proto_1.file.XAttrValue);
174
260
  function packXAttrValue(val) {
175
261
  if (Buffer.isBuffer(val)) {
176
- return xattrValueType.pack({ bytes: protobuf_msg_1.toVal(val) });
262
+ return xattrValueType.pack({ bytes: (0, protobuf_msg_1.toVal)(val) });
177
263
  }
178
264
  else if (typeof val === 'string') {
179
- return xattrValueType.pack({ str: protobuf_msg_1.toVal(val) });
265
+ return xattrValueType.pack({ str: (0, protobuf_msg_1.toVal)(val) });
180
266
  }
181
267
  else if (val === undefined) {
182
268
  return xattrValueType.pack({});
183
269
  }
184
270
  else {
185
- return xattrValueType.pack({ json: protobuf_msg_1.toOptJson(val) });
271
+ return xattrValueType.pack({ json: (0, protobuf_msg_1.toOptJson)(val) });
186
272
  }
187
273
  }
188
274
  exports.packXAttrValue = packXAttrValue;
189
275
  function unpackXAttrValue(buf) {
190
276
  const { json, str, bytes } = xattrValueType.unpack(buf);
191
277
  if (bytes) {
192
- return protobuf_msg_1.valOf(bytes);
278
+ return (0, protobuf_msg_1.valOf)(bytes);
193
279
  }
194
280
  else if (str) {
195
- return protobuf_msg_1.valOf(str);
281
+ return (0, protobuf_msg_1.valOf)(str);
196
282
  }
197
283
  else {
198
- return protobuf_msg_1.valOfOptJson(json);
284
+ return (0, protobuf_msg_1.valOfOptJson)(json);
199
285
  }
200
286
  }
201
287
  exports.unpackXAttrValue = unpackXAttrValue;
@@ -234,7 +320,7 @@ var listXAttrs;
234
320
  const path = objPath.concat('listXAttrs');
235
321
  return () => caller
236
322
  .startPromiseCall(path, undefined)
237
- .then(buf => protobuf_msg_1.fixArray(protobuf_msg_1.strArrValType.unpack(buf).values));
323
+ .then(buf => (0, protobuf_msg_1.fixArray)(protobuf_msg_1.strArrValType.unpack(buf).values));
238
324
  }
239
325
  listXAttrs.makeCaller = makeCaller;
240
326
  })(listXAttrs || (listXAttrs = {}));
@@ -244,17 +330,17 @@ var readBytes;
244
330
  const requestType = protobuf_type_1.ProtoType.for(file_proto_1.file.ReadBytesRequestBody);
245
331
  const replyType = protobuf_type_1.ProtoType.for(file_proto_1.file.ReadBytesReplyBody);
246
332
  function packReply(bytes) {
247
- return replyType.pack({ bytes: protobuf_msg_1.toOptVal(bytes) });
333
+ return replyType.pack({ bytes: (0, protobuf_msg_1.toOptVal)(bytes) });
248
334
  }
249
335
  readBytes.packReply = packReply;
250
336
  function unpackReply(buf) {
251
- return protobuf_msg_1.valOfOpt(replyType.unpack(buf).bytes);
337
+ return (0, protobuf_msg_1.valOfOpt)(replyType.unpack(buf).bytes);
252
338
  }
253
339
  readBytes.unpackReply = unpackReply;
254
340
  function wrapService(fn) {
255
341
  return buf => {
256
342
  const { start, end } = requestType.unpack(buf);
257
- const promise = fn(protobuf_msg_1.valOfOptInt(start), protobuf_msg_1.valOfOptInt(end))
343
+ const promise = fn((0, protobuf_msg_1.valOfOptInt)(start), (0, protobuf_msg_1.valOfOptInt)(end))
258
344
  .then(packReply);
259
345
  return { promise };
260
346
  };
@@ -264,7 +350,7 @@ var readBytes;
264
350
  const path = objPath.concat('readBytes');
265
351
  return (start, end) => caller
266
352
  .startPromiseCall(path, requestType.pack({
267
- start: protobuf_msg_1.toOptVal(start), end: protobuf_msg_1.toOptVal(end)
353
+ start: (0, protobuf_msg_1.toOptVal)(start), end: (0, protobuf_msg_1.toOptVal)(end)
268
354
  }))
269
355
  .then(unpackReply);
270
356
  }
@@ -276,7 +362,7 @@ var readTxt;
276
362
  function wrapService(fn) {
277
363
  return () => {
278
364
  const promise = fn()
279
- .then(txt => protobuf_msg_1.encodeToUtf8(txt));
365
+ .then(txt => (0, protobuf_msg_1.encodeToUtf8)(txt));
280
366
  return { promise };
281
367
  };
282
368
  }
@@ -285,24 +371,24 @@ var readTxt;
285
371
  const path = objPath.concat('readTxt');
286
372
  return () => caller
287
373
  .startPromiseCall(path, undefined)
288
- .then(buf => (buf ? protobuf_msg_1.decodeFromUtf8(buf) : ''));
374
+ .then(buf => (buf ? (0, protobuf_msg_1.decodeFromUtf8)(buf) : ''));
289
375
  }
290
376
  readTxt.makeCaller = makeCaller;
291
377
  })(readTxt || (readTxt = {}));
292
378
  Object.freeze(readTxt);
293
379
  function packJSON(json) {
294
- return protobuf_msg_1.encodeToUtf8(JSON.stringify(json));
380
+ return (0, protobuf_msg_1.encodeToUtf8)(JSON.stringify(json));
295
381
  }
296
382
  exports.packJSON = packJSON;
297
383
  function unpackJSON(buf) {
298
384
  if (!buf) {
299
- throw connector_1.makeIPCException({ missingBodyBytes: true });
385
+ throw (0, connector_1.makeIPCException)({ missingBodyBytes: true });
300
386
  }
301
387
  try {
302
- return JSON.parse(protobuf_msg_1.decodeFromUtf8(buf));
388
+ return JSON.parse((0, protobuf_msg_1.decodeFromUtf8)(buf));
303
389
  }
304
390
  catch (err) {
305
- throw error_1.errWithCause(err, `Can't parse ipc reply as json`);
391
+ throw (0, error_1.errWithCause)(err, `Can't parse ipc reply as json`);
306
392
  }
307
393
  }
308
394
  exports.unpackJSON = unpackJSON;
@@ -331,7 +417,7 @@ var getByteSource;
331
417
  return () => {
332
418
  const promise = fn()
333
419
  .then(src => {
334
- const ref = bytes_1.exposeSrcService(src, expServices);
420
+ const ref = (0, bytes_1.exposeSrcService)(src, expServices);
335
421
  return protobuf_msg_1.objRefType.pack(ref);
336
422
  });
337
423
  return { promise };
@@ -344,7 +430,7 @@ var getByteSource;
344
430
  .startPromiseCall(path, undefined)
345
431
  .then(buf => {
346
432
  const ref = protobuf_msg_1.objRefType.unpack(buf);
347
- return bytes_1.makeSrcCaller(caller, ref);
433
+ return (0, bytes_1.makeSrcCaller)(caller, ref);
348
434
  });
349
435
  }
350
436
  getByteSource.makeCaller = makeCaller;
@@ -352,29 +438,74 @@ var getByteSource;
352
438
  Object.freeze(getByteSource);
353
439
  const fileEventType = protobuf_type_1.ProtoType.for(file_proto_1.file.FileEventMsg);
354
440
  function packFileEvent(e) {
355
- const msg = {
356
- type: e.type,
357
- path: e.path,
358
- isRemote: protobuf_msg_1.toOptVal(e.isRemote),
359
- newVersion: protobuf_msg_1.toOptVal(e.newVersion),
360
- current: protobuf_msg_1.toOptVal(e.current),
361
- lastSynced: protobuf_msg_1.toOptVal(e.lastSynced),
362
- remoteVersion: protobuf_msg_1.toOptVal(e.remoteVersion)
363
- };
364
- return fileEventType.pack(msg);
441
+ const { type, path } = e;
442
+ switch (type) {
443
+ case 'file-change':
444
+ return fileEventType.pack({
445
+ type, path,
446
+ src: (0, protobuf_msg_1.toVal)(e.src),
447
+ newVersion: (0, protobuf_msg_1.toOptVal)(e.newVersion)
448
+ });
449
+ case 'removed':
450
+ return fileEventType.pack({
451
+ type, path,
452
+ src: (0, protobuf_msg_1.toVal)(e.src)
453
+ });
454
+ case 'remote-change':
455
+ return fileEventType.pack({
456
+ type, path, newVersion: (0, protobuf_msg_1.toOptVal)(e.newVersion)
457
+ });
458
+ case 'remote-removal':
459
+ return fileEventType.pack({
460
+ type, path
461
+ });
462
+ case 'remote-arch-ver-removal':
463
+ return fileEventType.pack({
464
+ type, path, removedArchVer: (0, protobuf_msg_1.toOptVal)(e.removedArchVer)
465
+ });
466
+ case 'remote-version-archival':
467
+ return fileEventType.pack({
468
+ type, path, archivedVersion: (0, protobuf_msg_1.toOptVal)(e.archivedVersion)
469
+ });
470
+ default:
471
+ throw new Error(`Unknown event type ${type}`);
472
+ }
365
473
  }
366
474
  exports.packFileEvent = packFileEvent;
367
475
  function unpackFileEvent(buf) {
368
476
  const m = fileEventType.unpack(buf);
369
- return {
370
- type: m.type,
371
- path: m.path,
372
- isRemote: protobuf_msg_1.valOfOpt(m.isRemote),
373
- newVersion: protobuf_msg_1.valOfOptInt(m.newVersion),
374
- current: protobuf_msg_1.valOfOptInt(m.current),
375
- lastSynced: protobuf_msg_1.valOfOptInt(m.lastSynced),
376
- remoteVersion: protobuf_msg_1.valOfOptInt(m.remoteVersion)
377
- };
477
+ const { type, path } = m;
478
+ switch (type) {
479
+ case 'file-change':
480
+ return {
481
+ type, path,
482
+ src: (0, protobuf_msg_1.valOf)(m.src),
483
+ newVersion: (0, protobuf_msg_1.valOfOptInt)(m.newVersion)
484
+ };
485
+ case 'removed':
486
+ return {
487
+ type, path,
488
+ src: (0, protobuf_msg_1.valOf)(m.src)
489
+ };
490
+ case 'remote-removal':
491
+ return {
492
+ type, path
493
+ };
494
+ case 'remote-change':
495
+ return {
496
+ type, path, newVersion: (0, protobuf_msg_1.intValOf)(m.newVersion)
497
+ };
498
+ case 'remote-arch-ver-removal':
499
+ return {
500
+ type, path, removedArchVer: (0, protobuf_msg_1.intValOf)(m.removedArchVer)
501
+ };
502
+ case 'remote-version-archival':
503
+ return {
504
+ type, path, archivedVersion: (0, protobuf_msg_1.intValOf)(m.archivedVersion)
505
+ };
506
+ default:
507
+ throw new Error(`Unknown event type ${type}`);
508
+ }
378
509
  }
379
510
  exports.unpackFileEvent = unpackFileEvent;
380
511
  var watch;
@@ -382,7 +513,7 @@ var watch;
382
513
  function wrapService(fn) {
383
514
  return buf => {
384
515
  const s = new rxjs_1.Subject();
385
- const obs = s.asObservable().pipe(operators_1.map(packFileEvent));
516
+ const obs = s.asObservable().pipe((0, operators_1.map)(packFileEvent));
386
517
  const onCancel = fn(s);
387
518
  return { obs, onCancel };
388
519
  };
@@ -393,15 +524,9 @@ var watch;
393
524
  return obs => {
394
525
  const s = new rxjs_1.Subject();
395
526
  const unsub = caller.startObservableCall(path, undefined, s);
396
- s.subscribe({
397
- next: buf => {
398
- if (obs.next) {
399
- obs.next(unpackFileEvent(buf));
400
- }
401
- },
402
- complete: obs.complete,
403
- error: obs.error
404
- });
527
+ s.asObservable()
528
+ .pipe((0, operators_1.map)(unpackFileEvent))
529
+ .subscribe((0, utils_for_observables_1.toRxObserver)(obs));
405
530
  return unsub;
406
531
  };
407
532
  }
@@ -414,15 +539,15 @@ var vGetXAttr;
414
539
  vGetXAttr.replyType = protobuf_type_1.ProtoType.for(file_proto_1.file.VersionedGetXAttrReplyBody);
415
540
  function unpackReply(buf) {
416
541
  const { json, str, bytes, version: v } = vGetXAttr.replyType.unpack(buf);
417
- const version = protobuf_msg_1.fixInt(v);
542
+ const version = (0, protobuf_msg_1.fixInt)(v);
418
543
  if (bytes) {
419
- return { version, attr: protobuf_msg_1.valOf(bytes) };
544
+ return { version, attr: (0, protobuf_msg_1.valOf)(bytes) };
420
545
  }
421
546
  else if (str) {
422
- return { version, attr: protobuf_msg_1.valOf(str) };
547
+ return { version, attr: (0, protobuf_msg_1.valOf)(str) };
423
548
  }
424
549
  else {
425
- return { version, attr: protobuf_msg_1.valOfOptJson(json) };
550
+ return { version, attr: (0, protobuf_msg_1.valOfOptJson)(json) };
426
551
  }
427
552
  }
428
553
  vGetXAttr.unpackReply = unpackReply;
@@ -432,13 +557,13 @@ var vGetXAttr;
432
557
  const promise = fn(xaName)
433
558
  .then(({ attr, version }) => {
434
559
  if (Buffer.isBuffer(attr)) {
435
- return vGetXAttr.replyType.pack({ version, bytes: protobuf_msg_1.toVal(attr) });
560
+ return vGetXAttr.replyType.pack({ version, bytes: (0, protobuf_msg_1.toVal)(attr) });
436
561
  }
437
562
  else if (typeof attr === 'string') {
438
- return vGetXAttr.replyType.pack({ version, str: protobuf_msg_1.toVal(attr) });
563
+ return vGetXAttr.replyType.pack({ version, str: (0, protobuf_msg_1.toVal)(attr) });
439
564
  }
440
565
  else {
441
- return vGetXAttr.replyType.pack({ version, json: protobuf_msg_1.toOptJson(attr) });
566
+ return vGetXAttr.replyType.pack({ version, json: (0, protobuf_msg_1.toOptJson)(attr) });
442
567
  }
443
568
  });
444
569
  return { promise };
@@ -471,7 +596,7 @@ var vListXAttrs;
471
596
  .startPromiseCall(path, undefined)
472
597
  .then(buf => {
473
598
  const { xaNames, version: v } = vListXAttrs.replyType.unpack(buf);
474
- return { version: protobuf_msg_1.fixInt(v), lst: (xaNames ? xaNames : []) };
599
+ return { version: (0, protobuf_msg_1.fixInt)(v), lst: (xaNames ? xaNames : []) };
475
600
  });
476
601
  }
477
602
  vListXAttrs.makeCaller = makeCaller;
@@ -483,19 +608,19 @@ var vReadBytes;
483
608
  const replyType = protobuf_type_1.ProtoType.for(file_proto_1.file.VersionedReadBytesReplyBody);
484
609
  function packReply(r) {
485
610
  return replyType.pack({
486
- version: r.version, bytes: protobuf_msg_1.toOptVal(r.bytes)
611
+ version: r.version, bytes: (0, protobuf_msg_1.toOptVal)(r.bytes)
487
612
  });
488
613
  }
489
614
  vReadBytes.packReply = packReply;
490
615
  function unpackReply(buf) {
491
616
  const { version: v, bytes: b } = replyType.unpack(buf);
492
- return { version: protobuf_msg_1.fixInt(v), bytes: protobuf_msg_1.valOfOpt(b) };
617
+ return { version: (0, protobuf_msg_1.fixInt)(v), bytes: (0, protobuf_msg_1.valOfOpt)(b) };
493
618
  }
494
619
  vReadBytes.unpackReply = unpackReply;
495
620
  function wrapService(fn) {
496
621
  return buf => {
497
622
  const { start, end } = requestType.unpack(buf);
498
- const promise = fn(protobuf_msg_1.valOfOptInt(start), protobuf_msg_1.valOfOptInt(end))
623
+ const promise = fn((0, protobuf_msg_1.valOfOptInt)(start), (0, protobuf_msg_1.valOfOptInt)(end))
499
624
  .then(packReply);
500
625
  return { promise };
501
626
  };
@@ -505,7 +630,7 @@ var vReadBytes;
505
630
  const path = objPath.concat('readBytes');
506
631
  return (start, end) => caller
507
632
  .startPromiseCall(path, requestType.pack({
508
- start: protobuf_msg_1.toOptVal(start), end: protobuf_msg_1.toOptVal(end)
633
+ start: (0, protobuf_msg_1.toOptVal)(start), end: (0, protobuf_msg_1.toOptVal)(end)
509
634
  }))
510
635
  .then(unpackReply);
511
636
  }
@@ -529,7 +654,7 @@ var vReadTxt;
529
654
  .startPromiseCall(path, undefined)
530
655
  .then(buf => {
531
656
  const { version: v, txt } = vReadTxt.replyType.unpack(buf);
532
- return { version: protobuf_msg_1.fixInt(v), txt };
657
+ return { version: (0, protobuf_msg_1.fixInt)(v), txt };
533
658
  });
534
659
  }
535
660
  vReadTxt.makeCaller = makeCaller;
@@ -555,10 +680,10 @@ var vReadJSON;
555
680
  .then(buf => {
556
681
  const { version: v, json } = vReadJSON.replyType.unpack(buf);
557
682
  try {
558
- return { version: protobuf_msg_1.fixInt(v), json: JSON.parse(json) };
683
+ return { version: (0, protobuf_msg_1.fixInt)(v), json: JSON.parse(json) };
559
684
  }
560
685
  catch (err) {
561
- throw error_1.errWithCause(err, `Can't parse ipc reply as json`);
686
+ throw (0, error_1.errWithCause)(err, `Can't parse ipc reply as json`);
562
687
  }
563
688
  });
564
689
  }
@@ -572,7 +697,7 @@ var vGetByteSource;
572
697
  return () => {
573
698
  const promise = fn()
574
699
  .then(({ version, src }) => {
575
- const ref = bytes_1.exposeSrcService(src, expServices);
700
+ const ref = (0, bytes_1.exposeSrcService)(src, expServices);
576
701
  return vGetByteSource.replyType.pack({ version, src: ref });
577
702
  });
578
703
  return { promise };
@@ -585,12 +710,42 @@ var vGetByteSource;
585
710
  .startPromiseCall(path, undefined)
586
711
  .then(buf => {
587
712
  const { version: v, src: ref } = vGetByteSource.replyType.unpack(buf);
588
- return { version: protobuf_msg_1.fixInt(v), src: bytes_1.makeSrcCaller(caller, ref) };
713
+ return { version: (0, protobuf_msg_1.fixInt)(v), src: (0, bytes_1.makeSrcCaller)(caller, ref) };
589
714
  });
590
715
  }
591
716
  vGetByteSource.makeCaller = makeCaller;
592
717
  })(vGetByteSource = exports.vGetByteSource || (exports.vGetByteSource = {}));
593
718
  Object.freeze(vGetByteSource);
719
+ function xattrToMsg(xaName, val) {
720
+ const msg = { xaName };
721
+ if (Buffer.isBuffer(val)) {
722
+ msg.bytes = (0, protobuf_msg_1.toVal)(val);
723
+ }
724
+ else if (ArrayBuffer.isView(val)) {
725
+ msg.bytes = (0, protobuf_msg_1.toVal)((0, buffer_utils_1.toBuffer)(val));
726
+ }
727
+ else if (typeof val === 'string') {
728
+ msg.str = (0, protobuf_msg_1.toVal)(val);
729
+ }
730
+ else {
731
+ msg.json = (0, protobuf_msg_1.toOptJson)(val);
732
+ }
733
+ return msg;
734
+ }
735
+ exports.xattrToMsg = xattrToMsg;
736
+ function xattrFromMsg(msg) {
737
+ const { xaName: name } = msg;
738
+ if (msg.bytes) {
739
+ return { name, value: (0, protobuf_msg_1.valOf)(msg.bytes) };
740
+ }
741
+ else if (msg.str) {
742
+ return { name, value: (0, protobuf_msg_1.valOf)(msg.str) };
743
+ }
744
+ else {
745
+ return { name, value: (0, protobuf_msg_1.valOfOptJson)(msg.json) };
746
+ }
747
+ }
748
+ exports.xattrFromMsg = xattrFromMsg;
594
749
  var updateXAttrs;
595
750
  (function (updateXAttrs) {
596
751
  const requestType = protobuf_type_1.ProtoType.for(file_proto_1.file.UpdateXAttrsRequestBody);
@@ -598,16 +753,9 @@ var updateXAttrs;
598
753
  const attrs = {};
599
754
  if (r.set) {
600
755
  attrs.set = {};
601
- for (const attr of r.set) {
602
- if (attr.bytes) {
603
- attrs.set[attr.xaName] = protobuf_msg_1.valOf(attr.bytes);
604
- }
605
- else if (attr.str) {
606
- attrs.set[attr.xaName] = protobuf_msg_1.valOf(attr.str);
607
- }
608
- else {
609
- attrs.set[attr.xaName] = protobuf_msg_1.valOfOptJson(attr.json);
610
- }
756
+ for (const xattr of r.set) {
757
+ const { name, value } = xattrFromMsg(xattr);
758
+ attrs.set[name] = value;
611
759
  }
612
760
  }
613
761
  if (r.remove) {
@@ -636,17 +784,7 @@ var updateXAttrs;
636
784
  };
637
785
  if (changes.set) {
638
786
  for (const [xaName, val] of Object.entries(changes.set)) {
639
- const attr = { xaName };
640
- if (Buffer.isBuffer(val)) {
641
- attr.bytes = protobuf_msg_1.toVal(val);
642
- }
643
- else if (typeof val === 'string') {
644
- attr.str = protobuf_msg_1.toVal(val);
645
- }
646
- else {
647
- attr.json = protobuf_msg_1.toOptJson(val);
648
- }
649
- r.set.push(attr);
787
+ r.set.push(xattrToMsg(xaName, val));
650
788
  }
651
789
  }
652
790
  return r;
@@ -732,9 +870,9 @@ var getByteSink;
732
870
  function wrapService(fn, expServices) {
733
871
  return buf => {
734
872
  const { truncateFile } = requestType.unpack(buf);
735
- const promise = fn(protobuf_msg_1.valOfOpt(truncateFile))
873
+ const promise = fn((0, protobuf_msg_1.valOfOpt)(truncateFile))
736
874
  .then(sink => {
737
- const ref = bytes_1.exposeSinkService(sink, expServices);
875
+ const ref = (0, bytes_1.exposeSinkService)(sink, expServices);
738
876
  return protobuf_msg_1.objRefType.pack(ref);
739
877
  });
740
878
  return { promise };
@@ -745,11 +883,11 @@ var getByteSink;
745
883
  const path = objPath.concat('getByteSink');
746
884
  return truncateFile => caller
747
885
  .startPromiseCall(path, requestType.pack({
748
- truncateFile: protobuf_msg_1.toOptVal(truncateFile)
886
+ truncateFile: (0, protobuf_msg_1.toOptVal)(truncateFile)
749
887
  }))
750
888
  .then(buf => {
751
889
  const ref = protobuf_msg_1.objRefType.unpack(buf);
752
- return bytes_1.makeSinkCaller(caller, ref);
890
+ return (0, bytes_1.makeSinkCaller)(caller, ref);
753
891
  });
754
892
  }
755
893
  getByteSink.makeCaller = makeCaller;
@@ -894,9 +1032,9 @@ var vGetByteSink;
894
1032
  function wrapService(fn, expServices) {
895
1033
  return buf => {
896
1034
  const { truncateFile, currentVersion } = requestType.unpack(buf);
897
- const promise = fn(protobuf_msg_1.valOfOpt(truncateFile), protobuf_msg_1.valOfOptInt(currentVersion))
1035
+ const promise = fn((0, protobuf_msg_1.valOfOpt)(truncateFile), (0, protobuf_msg_1.valOfOptInt)(currentVersion))
898
1036
  .then(({ sink, version }) => {
899
- const ref = bytes_1.exposeSinkService(sink, expServices);
1037
+ const ref = (0, bytes_1.exposeSinkService)(sink, expServices);
900
1038
  return vGetByteSink.replyType.pack({ version, sink: ref });
901
1039
  });
902
1040
  return { promise };
@@ -907,15 +1045,233 @@ var vGetByteSink;
907
1045
  const path = objPath.concat('getByteSink');
908
1046
  return (truncateFile, currentVersion) => caller
909
1047
  .startPromiseCall(path, requestType.pack({
910
- truncateFile: protobuf_msg_1.toOptVal(truncateFile),
911
- currentVersion: protobuf_msg_1.toOptVal(currentVersion)
1048
+ truncateFile: (0, protobuf_msg_1.toOptVal)(truncateFile),
1049
+ currentVersion: (0, protobuf_msg_1.toOptVal)(currentVersion)
912
1050
  }))
913
1051
  .then(buf => {
914
1052
  const { version: v, sink: ref } = vGetByteSink.replyType.unpack(buf);
915
- return { version: protobuf_msg_1.fixInt(v), sink: bytes_1.makeSinkCaller(caller, ref) };
1053
+ return { version: (0, protobuf_msg_1.fixInt)(v), sink: (0, bytes_1.makeSinkCaller)(caller, ref) };
916
1054
  });
917
1055
  }
918
1056
  vGetByteSink.makeCaller = makeCaller;
919
1057
  })(vGetByteSink = exports.vGetByteSink || (exports.vGetByteSink = {}));
920
1058
  Object.freeze(vGetByteSink);
1059
+ var vsStatus;
1060
+ (function (vsStatus) {
1061
+ function wrapService(fn) {
1062
+ return () => {
1063
+ const promise = fn()
1064
+ .then(packSyncStatus);
1065
+ return { promise };
1066
+ };
1067
+ }
1068
+ vsStatus.wrapService = wrapService;
1069
+ function makeCaller(caller, objPath) {
1070
+ const path = objPath.concat('status');
1071
+ return () => caller
1072
+ .startPromiseCall(path, undefined)
1073
+ .then(unpackSyncStatus);
1074
+ }
1075
+ vsStatus.makeCaller = makeCaller;
1076
+ })(vsStatus || (vsStatus = {}));
1077
+ Object.freeze(vsStatus);
1078
+ var vsUpdateStatusInfo;
1079
+ (function (vsUpdateStatusInfo) {
1080
+ function wrapService(fn) {
1081
+ return () => {
1082
+ const promise = fn()
1083
+ .then(packSyncStatus);
1084
+ return { promise };
1085
+ };
1086
+ }
1087
+ vsUpdateStatusInfo.wrapService = wrapService;
1088
+ function makeCaller(caller, objPath) {
1089
+ const path = objPath.concat('updateStatusInfo');
1090
+ return () => caller
1091
+ .startPromiseCall(path, undefined)
1092
+ .then(unpackSyncStatus);
1093
+ }
1094
+ vsUpdateStatusInfo.makeCaller = makeCaller;
1095
+ })(vsUpdateStatusInfo || (vsUpdateStatusInfo = {}));
1096
+ Object.freeze(vsUpdateStatusInfo);
1097
+ var vsIsRemoteVersionOnDisk;
1098
+ (function (vsIsRemoteVersionOnDisk) {
1099
+ const requestType = protobuf_type_1.ProtoType.for(file_proto_1.file.FileSyncIsOnDiskRequestBody);
1100
+ const replyType = protobuf_type_1.ProtoType.for(file_proto_1.file.FileSyncIsOnDiskReplyBody);
1101
+ function wrapService(fn) {
1102
+ return buf => {
1103
+ const { version } = requestType.unpack(buf);
1104
+ const promise = fn((0, protobuf_msg_1.fixInt)(version))
1105
+ .then(status => replyType.pack({ status }));
1106
+ return { promise };
1107
+ };
1108
+ }
1109
+ vsIsRemoteVersionOnDisk.wrapService = wrapService;
1110
+ function makeCaller(caller, objPath) {
1111
+ const path = objPath.concat('isRemoteVersionOnDisk');
1112
+ return version => caller
1113
+ .startPromiseCall(path, requestType.pack({ version }))
1114
+ .then(buf => replyType.unpack(buf).status);
1115
+ }
1116
+ vsIsRemoteVersionOnDisk.makeCaller = makeCaller;
1117
+ })(vsIsRemoteVersionOnDisk || (vsIsRemoteVersionOnDisk = {}));
1118
+ Object.freeze(vsIsRemoteVersionOnDisk);
1119
+ var vsDownload;
1120
+ (function (vsDownload) {
1121
+ const requestType = protobuf_type_1.ProtoType.for(file_proto_1.file.FileSyncDownloadRequestBody);
1122
+ function wrapService(fn) {
1123
+ return buf => {
1124
+ const { version } = requestType.unpack(buf);
1125
+ const promise = fn((0, protobuf_msg_1.fixInt)(version));
1126
+ return { promise };
1127
+ };
1128
+ }
1129
+ vsDownload.wrapService = wrapService;
1130
+ function makeCaller(caller, objPath) {
1131
+ const path = objPath.concat('download');
1132
+ return version => caller
1133
+ .startPromiseCall(path, requestType.pack({ version }));
1134
+ }
1135
+ vsDownload.makeCaller = makeCaller;
1136
+ })(vsDownload || (vsDownload = {}));
1137
+ Object.freeze(vsDownload);
1138
+ function optionsToUploadLocalToMsg(opts) {
1139
+ if (!opts) {
1140
+ return;
1141
+ }
1142
+ return {
1143
+ localVersion: (0, protobuf_msg_1.toOptVal)(opts.localVersion),
1144
+ uploadVersion: (0, protobuf_msg_1.toOptVal)(opts.uploadVersion)
1145
+ };
1146
+ }
1147
+ exports.optionsToUploadLocalToMsg = optionsToUploadLocalToMsg;
1148
+ function optionsToUploadLocalFromMsg(opts) {
1149
+ if (!opts) {
1150
+ return;
1151
+ }
1152
+ return {
1153
+ localVersion: (0, protobuf_msg_1.valOfOptInt)(opts.localVersion),
1154
+ uploadVersion: (0, protobuf_msg_1.valOfOptInt)(opts.uploadVersion)
1155
+ };
1156
+ }
1157
+ exports.optionsToUploadLocalFromMsg = optionsToUploadLocalFromMsg;
1158
+ var vsUpload;
1159
+ (function (vsUpload) {
1160
+ const requestType = protobuf_type_1.ProtoType.for(file_proto_1.file.FileSyncUploadRequestBody);
1161
+ function wrapService(fn) {
1162
+ return buf => {
1163
+ const { opts } = requestType.unpack(buf);
1164
+ const promise = fn(optionsToUploadLocalFromMsg(opts));
1165
+ return { promise };
1166
+ };
1167
+ }
1168
+ vsUpload.wrapService = wrapService;
1169
+ function makeCaller(caller, objPath) {
1170
+ const path = objPath.concat('upload');
1171
+ return opts => caller
1172
+ .startPromiseCall(path, requestType.pack({
1173
+ opts: optionsToUploadLocalToMsg(opts)
1174
+ }));
1175
+ }
1176
+ vsUpload.makeCaller = makeCaller;
1177
+ })(vsUpload || (vsUpload = {}));
1178
+ Object.freeze(vsUpload);
1179
+ function remoteAdoptionOptsToMsg(opts) {
1180
+ if (!opts) {
1181
+ return;
1182
+ }
1183
+ return {
1184
+ dropLocalVer: (0, protobuf_msg_1.toOptVal)(opts.dropLocalVer),
1185
+ remoteVersion: (0, protobuf_msg_1.toOptVal)(opts.remoteVersion)
1186
+ };
1187
+ }
1188
+ exports.remoteAdoptionOptsToMsg = remoteAdoptionOptsToMsg;
1189
+ function remoteAdoptionOptsFromMsg(msg) {
1190
+ if (!msg) {
1191
+ return;
1192
+ }
1193
+ return {
1194
+ dropLocalVer: (0, protobuf_msg_1.valOfOpt)(msg.dropLocalVer),
1195
+ remoteVersion: (0, protobuf_msg_1.valOfOptInt)(msg.remoteVersion)
1196
+ };
1197
+ }
1198
+ exports.remoteAdoptionOptsFromMsg = remoteAdoptionOptsFromMsg;
1199
+ var vsAdoptRemote;
1200
+ (function (vsAdoptRemote) {
1201
+ const requestType = protobuf_type_1.ProtoType.for(file_proto_1.file.AdoptRemoteRequestBody);
1202
+ function wrapService(fn) {
1203
+ return buf => {
1204
+ const { opts } = requestType.unpack(buf);
1205
+ const promise = fn(remoteAdoptionOptsFromMsg(opts));
1206
+ return { promise };
1207
+ };
1208
+ }
1209
+ vsAdoptRemote.wrapService = wrapService;
1210
+ function makeCaller(caller, objPath) {
1211
+ const path = objPath.concat('adoptRemote');
1212
+ return opts => caller
1213
+ .startPromiseCall(path, requestType.pack({
1214
+ opts: remoteAdoptionOptsToMsg(opts)
1215
+ }));
1216
+ }
1217
+ vsAdoptRemote.makeCaller = makeCaller;
1218
+ })(vsAdoptRemote || (vsAdoptRemote = {}));
1219
+ Object.freeze(vsAdoptRemote);
1220
+ var vListVersions;
1221
+ (function (vListVersions) {
1222
+ const replyType = protobuf_type_1.ProtoType.for(file_proto_1.file.ListVersionsReplyBody);
1223
+ function packReply(v) {
1224
+ return replyType.pack({
1225
+ current: (0, protobuf_msg_1.toOptVal)(v.current),
1226
+ archived: v.archived
1227
+ });
1228
+ }
1229
+ vListVersions.packReply = packReply;
1230
+ function unpackReply(b) {
1231
+ const r = replyType.unpack(b);
1232
+ return {
1233
+ current: (0, protobuf_msg_1.valOfOptInt)(r.current),
1234
+ archived: ((r.archived.length > 0) ?
1235
+ r.archived.map(protobuf_msg_1.fixInt) : undefined)
1236
+ };
1237
+ }
1238
+ vListVersions.unpackReply = unpackReply;
1239
+ function wrapService(fn) {
1240
+ return () => {
1241
+ const promise = fn()
1242
+ .then(packReply);
1243
+ return { promise };
1244
+ };
1245
+ }
1246
+ vListVersions.wrapService = wrapService;
1247
+ function makeCaller(caller, objPath) {
1248
+ const path = objPath.concat('listVersions');
1249
+ return () => caller
1250
+ .startPromiseCall(path)
1251
+ .then(unpackReply);
1252
+ }
1253
+ vListVersions.makeCaller = makeCaller;
1254
+ })(vListVersions = exports.vListVersions || (exports.vListVersions = {}));
1255
+ Object.freeze(vListVersions);
1256
+ var vArchiveCurrent;
1257
+ (function (vArchiveCurrent) {
1258
+ const requestType = protobuf_type_1.ProtoType.for(file_proto_1.file.ArchiveCurrentRequestBody);
1259
+ function wrapService(fn) {
1260
+ return buf => {
1261
+ const { version } = requestType.unpack(buf);
1262
+ const promise = fn((0, protobuf_msg_1.valOfOptInt)(version))
1263
+ .then(protobuf_msg_1.packInt);
1264
+ return { promise };
1265
+ };
1266
+ }
1267
+ vArchiveCurrent.wrapService = wrapService;
1268
+ function makeCaller(caller, objPath) {
1269
+ const path = objPath.concat('archiveCurrent');
1270
+ return version => caller
1271
+ .startPromiseCall(path, requestType.pack({ version: (0, protobuf_msg_1.toOptVal)(version) }))
1272
+ .then(protobuf_msg_1.unpackInt);
1273
+ }
1274
+ vArchiveCurrent.makeCaller = makeCaller;
1275
+ })(vArchiveCurrent || (vArchiveCurrent = {}));
1276
+ Object.freeze(vArchiveCurrent);
921
1277
  Object.freeze(exports);