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
@@ -67,10 +67,11 @@ export interface GetObjQueryOpts {
67
67
  }
68
68
  export interface PutObjFirstQueryOpts {
69
69
  /**
70
- * This is a new object version parameter. When it is 1 (one), new object
71
- * should be created. If it is greater than one, changes are accepted only
72
- * when a current version on the server is (ver-1), ensuring that a client
73
- * knows current version on server to advance it.
70
+ * This is a flag to indicate that new object should be created.
71
+ */
72
+ create?: boolean;
73
+ /**
74
+ * This parameter is object's new version.
74
75
  */
75
76
  ver: number;
76
77
  /**
@@ -108,6 +109,7 @@ export interface PutObjSecondQueryOpts {
108
109
  export declare namespace currentObj {
109
110
  const EXPRESS_URL_END = "obj/:objId/current";
110
111
  function getReqUrlEnd(objId: string, opts?: GetObjQueryOpts): string;
112
+ function delReqUrlEnd(objId: string, ver?: number): string;
111
113
  function firstPutReqUrlEnd(objId: string, opts: PutObjFirstQueryOpts): string;
112
114
  function secondPutReqUrlEnd(objId: string, opts: PutObjSecondQueryOpts): string;
113
115
  interface ReplyToPut {
@@ -156,24 +158,20 @@ export declare namespace currentRootObj {
156
158
  }
157
159
  export declare namespace archivedObjVersion {
158
160
  const EXPRESS_URL_END = "/obj/:objId/archived";
159
- function getReqUrlEnd(objId: string, version: number, opts?: GetObjQueryOpts): string;
161
+ function getReqUrlEnd(objId: string, opts: GetObjQueryOpts): string;
160
162
  const SC: {
161
163
  okGet: number;
162
- okDelete: number;
163
- missing: number;
164
- concurrentTransaction: number;
165
- incompatibleObjState: number;
164
+ unknownObj: number;
165
+ unknownObjVer: number;
166
166
  };
167
167
  }
168
168
  export declare namespace archivedRootVersion {
169
169
  const EXPRESS_URL_END = "root/archived";
170
- function getReqUrlEnd(version: number, opts?: GetObjQueryOpts): string;
170
+ function getReqUrlEnd(opts: GetObjQueryOpts): string;
171
171
  const SC: {
172
172
  okGet: number;
173
- okDelete: number;
174
- missing: number;
175
- concurrentTransaction: number;
176
- incompatibleObjState: number;
173
+ unknownObj: number;
174
+ unknownObjVer: number;
177
175
  };
178
176
  }
179
177
  export interface DiffInfo {
@@ -217,21 +215,48 @@ export declare namespace cancelRootTransaction {
217
215
  missing: number;
218
216
  };
219
217
  }
218
+ export interface ObjStatus {
219
+ current?: number;
220
+ archived?: number[];
221
+ }
222
+ export declare namespace objStatus {
223
+ const EXPRESS_URL_END = "obj/:objId/status";
224
+ function getReqUrlEnd(objId: string): string;
225
+ type Reply = ObjStatus;
226
+ const SC: {
227
+ ok: number;
228
+ unknownObj: number;
229
+ };
230
+ }
231
+ export declare namespace rootStatus {
232
+ const EXPRESS_URL_END = "root/status";
233
+ function getReqUrlEnd(): string;
234
+ type Reply = ObjStatus;
235
+ const SC: {
236
+ ok: number;
237
+ unknownObj: number;
238
+ };
239
+ }
220
240
  export declare namespace archiveObj {
221
241
  const EXPRESS_URL_END = "obj/:objId/archive";
222
- function getReqUrlEnd(objId: string): string;
242
+ function postAndDelReqUrlEnd(objId: string, version: number): string;
243
+ type VersionsList = number[];
223
244
  const SC: {
224
- okGet: number;
225
- okPut: number;
226
- missing: number;
245
+ okPost: number;
246
+ okDelete: number;
247
+ unknownObj: number;
248
+ unknownObjVer: number;
227
249
  };
228
250
  }
229
251
  export declare namespace archiveRoot {
230
- const URL_END = "root/archive";
252
+ const EXPRESS_URL_END = "root/archive";
253
+ function postAndDelReqUrlEnd(version: number): string;
254
+ type VersionsList = archiveObj.VersionsList;
231
255
  const SC: {
232
- okGet: number;
233
- okPut: number;
234
- missing: number;
256
+ okPost: number;
257
+ okDelete: number;
258
+ unknownObj: number;
259
+ unknownObjVer: number;
235
260
  };
236
261
  }
237
262
  export interface ErrorReply {
@@ -243,23 +268,59 @@ export declare namespace wsEventChannel {
243
268
  ok: number;
244
269
  };
245
270
  }
246
- export declare namespace objChanged {
247
- const EVENT_NAME = "obj-changed";
248
- interface Event {
249
- /**
250
- * This indentifies a non-root object by its string id, while null value
251
- * identifies root object.
252
- */
253
- objId: string | null;
254
- newVer: number;
271
+ export declare namespace events {
272
+ namespace objChanged {
273
+ const EVENT_NAME = "obj-changed";
274
+ interface Event {
275
+ /**
276
+ * This indentifies a non-root object by its string id, while null
277
+ * value identifies root object.
278
+ */
279
+ objId: string | null;
280
+ /**
281
+ * New current version on the server.
282
+ */
283
+ newVer: number;
284
+ }
255
285
  }
256
- }
257
- export declare namespace objRemoved {
258
- const EVENT_NAME = "obj-removed";
259
- interface Event {
260
- /**
261
- * This indentifies a removed non-root object by its string id.
262
- */
263
- objId: string;
286
+ namespace objRemoved {
287
+ const EVENT_NAME = "obj-removed";
288
+ interface Event {
289
+ /**
290
+ * This indentifies a removed non-root object by its string id.
291
+ */
292
+ objId: string;
293
+ }
294
+ }
295
+ namespace objVersionArchived {
296
+ const EVENT_NAME = "obj-ver-archived";
297
+ interface Event {
298
+ /**
299
+ * This indentifies a non-root object by its string id, while null
300
+ * value identifies root object.
301
+ */
302
+ objId: string | null;
303
+ /**
304
+ * Version that was set archived on the server.
305
+ */
306
+ archivedVer: number;
307
+ }
308
+ }
309
+ namespace objArchivedVersionRemoved {
310
+ const EVENT_NAME = "obj-ver-removed";
311
+ interface Event {
312
+ /**
313
+ * This indentifies a non-root object by its string id, while null
314
+ * value identifies root object.
315
+ */
316
+ objId: string | null;
317
+ /**
318
+ * Archived version that was removed on the server.
319
+ */
320
+ archivedVer: number;
321
+ }
264
322
  }
323
+ const all: string[];
324
+ type EventNameType = (typeof objChanged.EVENT_NAME) | (typeof objRemoved.EVENT_NAME) | (typeof objVersionArchived.EVENT_NAME) | (typeof objArchivedVersionRemoved.EVENT_NAME);
325
+ type AllTypes = objChanged.Event | objRemoved.Event | objVersionArchived.Event | objArchivedVersionRemoved.Event;
265
326
  }
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  /*
3
- Copyright (C) 2015 - 2017, 2019 3NSoft Inc.
3
+ Copyright (C) 2015 - 2017, 2019, 2022 3NSoft Inc.
4
4
 
5
5
  This program is free software: you can redistribute it and/or modify it under
6
6
  the terms of the GNU General Public License as published by the Free Software
@@ -13,9 +13,10 @@
13
13
  See the GNU General Public License for more details.
14
14
 
15
15
  You should have received a copy of the GNU General Public License along with
16
- this program. If not, see <http://www.gnu.org/licenses/>. */
16
+ this program. If not, see <http://www.gnu.org/licenses/>.
17
+ */
17
18
  Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.objRemoved = exports.objChanged = exports.wsEventChannel = exports.archiveRoot = exports.archiveObj = exports.cancelRootTransaction = exports.cancelTransaction = exports.addDiffSectionTo = exports.sanitizedDiff = exports.archivedRootVersion = exports.archivedObjVersion = exports.currentRootObj = exports.currentObj = exports.keyDerivParams = exports.PARAM_SC = exports.sessionParams = exports.closeSession = exports.midLogin = exports.BIN_TYPE = exports.HTTP_HEADER = exports.ERR_SC = void 0;
19
+ exports.events = exports.wsEventChannel = exports.archiveRoot = exports.archiveObj = exports.rootStatus = exports.objStatus = exports.cancelRootTransaction = exports.cancelTransaction = exports.addDiffSectionTo = exports.sanitizedDiff = exports.archivedRootVersion = exports.archivedObjVersion = exports.currentRootObj = exports.currentObj = exports.keyDerivParams = exports.PARAM_SC = exports.sessionParams = exports.closeSession = exports.midLogin = exports.BIN_TYPE = exports.HTTP_HEADER = exports.ERR_SC = void 0;
19
20
  /**
20
21
  * This defines interfaces for 3nstorage owner's requests.
21
22
  */
@@ -75,15 +76,19 @@ var currentObj;
75
76
  (function (currentObj) {
76
77
  currentObj.EXPRESS_URL_END = 'obj/:objId/current';
77
78
  function getReqUrlEnd(objId, opts) {
78
- return `obj/${objId}/current${opts ? `?${querystring_1.stringify(opts)}` : ''}`;
79
+ return `obj/${objId}/current${opts ? `?${(0, querystring_1.stringify)(opts)}` : ''}`;
79
80
  }
80
81
  currentObj.getReqUrlEnd = getReqUrlEnd;
82
+ function delReqUrlEnd(objId, ver) {
83
+ return `obj/${objId}/current${ver ? `?${(0, querystring_1.stringify)({ ver })}` : ''}`;
84
+ }
85
+ currentObj.delReqUrlEnd = delReqUrlEnd;
81
86
  function firstPutReqUrlEnd(objId, opts) {
82
- return `obj/${objId}/current?${querystring_1.stringify(opts)}`;
87
+ return `obj/${objId}/current?${(0, querystring_1.stringify)(opts)}`;
83
88
  }
84
89
  currentObj.firstPutReqUrlEnd = firstPutReqUrlEnd;
85
90
  function secondPutReqUrlEnd(objId, opts) {
86
- return `obj/${objId}/current?${querystring_1.stringify(opts)}`;
91
+ return `obj/${objId}/current?${(0, querystring_1.stringify)(opts)}`;
87
92
  }
88
93
  currentObj.secondPutReqUrlEnd = secondPutReqUrlEnd;
89
94
  currentObj.SC = {
@@ -105,15 +110,15 @@ var currentRootObj;
105
110
  (function (currentRootObj) {
106
111
  currentRootObj.EXPRESS_URL_END = 'root/current';
107
112
  function getReqUrlEnd(opts) {
108
- return `root/current${opts ? `?${querystring_1.stringify(opts)}` : ''}`;
113
+ return `root/current${opts ? `?${(0, querystring_1.stringify)(opts)}` : ''}`;
109
114
  }
110
115
  currentRootObj.getReqUrlEnd = getReqUrlEnd;
111
116
  function firstPutReqUrlEnd(opts) {
112
- return `root/current?${querystring_1.stringify(opts)}`;
117
+ return `root/current?${(0, querystring_1.stringify)(opts)}`;
113
118
  }
114
119
  currentRootObj.firstPutReqUrlEnd = firstPutReqUrlEnd;
115
120
  function secondPutReqUrlEnd(opts) {
116
- return `root/current?${querystring_1.stringify(opts)}`;
121
+ return `root/current?${(0, querystring_1.stringify)(opts)}`;
117
122
  }
118
123
  currentRootObj.secondPutReqUrlEnd = secondPutReqUrlEnd;
119
124
  currentRootObj.SC = currentObj.SC;
@@ -122,32 +127,22 @@ Object.freeze(currentRootObj);
122
127
  var archivedObjVersion;
123
128
  (function (archivedObjVersion) {
124
129
  archivedObjVersion.EXPRESS_URL_END = '/obj/:objId/archived';
125
- function getReqUrlEnd(objId, version, opts) {
126
- if (opts) {
127
- opts.ver = version;
128
- }
129
- const query = (opts ? `?${querystring_1.stringify(opts)}` : '');
130
- return `/obj/${objId}/archived${query}`;
130
+ function getReqUrlEnd(objId, opts) {
131
+ return `/obj/${objId}/archived?${(0, querystring_1.stringify)(opts)}`;
131
132
  }
132
133
  archivedObjVersion.getReqUrlEnd = getReqUrlEnd;
133
134
  archivedObjVersion.SC = {
134
135
  okGet: 200,
135
- okDelete: 200,
136
- missing: 474,
137
- concurrentTransaction: 483,
138
- incompatibleObjState: 484
136
+ unknownObj: 474,
137
+ unknownObjVer: 494
139
138
  };
140
139
  })(archivedObjVersion = exports.archivedObjVersion || (exports.archivedObjVersion = {}));
141
140
  Object.freeze(archivedObjVersion);
142
141
  var archivedRootVersion;
143
142
  (function (archivedRootVersion) {
144
143
  archivedRootVersion.EXPRESS_URL_END = 'root/archived';
145
- function getReqUrlEnd(version, opts) {
146
- if (opts) {
147
- opts.ver = version;
148
- }
149
- const query = (opts ? `?${querystring_1.stringify(opts)}` : '');
150
- return `root/archived${query}`;
144
+ function getReqUrlEnd(opts) {
145
+ return `root/archived?${(0, querystring_1.stringify)(opts)}`;
151
146
  }
152
147
  archivedRootVersion.getReqUrlEnd = getReqUrlEnd;
153
148
  archivedRootVersion.SC = archivedObjVersion.SC;
@@ -229,23 +224,51 @@ var cancelRootTransaction;
229
224
  cancelRootTransaction.SC = cancelTransaction.SC;
230
225
  })(cancelRootTransaction = exports.cancelRootTransaction || (exports.cancelRootTransaction = {}));
231
226
  Object.freeze(cancelRootTransaction);
227
+ var objStatus;
228
+ (function (objStatus) {
229
+ objStatus.EXPRESS_URL_END = 'obj/:objId/status';
230
+ function getReqUrlEnd(objId) {
231
+ return `obj/${objId}/status`;
232
+ }
233
+ objStatus.getReqUrlEnd = getReqUrlEnd;
234
+ objStatus.SC = {
235
+ ok: 200,
236
+ unknownObj: 474,
237
+ };
238
+ })(objStatus = exports.objStatus || (exports.objStatus = {}));
239
+ Object.freeze(objStatus);
240
+ var rootStatus;
241
+ (function (rootStatus) {
242
+ rootStatus.EXPRESS_URL_END = 'root/status';
243
+ function getReqUrlEnd() {
244
+ return 'root/status';
245
+ }
246
+ rootStatus.getReqUrlEnd = getReqUrlEnd;
247
+ rootStatus.SC = objStatus.SC;
248
+ })(rootStatus = exports.rootStatus || (exports.rootStatus = {}));
249
+ Object.freeze(rootStatus);
232
250
  var archiveObj;
233
251
  (function (archiveObj) {
234
252
  archiveObj.EXPRESS_URL_END = 'obj/:objId/archive';
235
- function getReqUrlEnd(objId) {
236
- return `obj/${objId}/archive`;
253
+ function postAndDelReqUrlEnd(objId, version) {
254
+ return `obj/${objId}/archive?ver=${version}`;
237
255
  }
238
- archiveObj.getReqUrlEnd = getReqUrlEnd;
256
+ archiveObj.postAndDelReqUrlEnd = postAndDelReqUrlEnd;
239
257
  archiveObj.SC = {
240
- okGet: 200,
241
- okPut: 201,
242
- missing: 474
258
+ okPost: 200,
259
+ okDelete: 200,
260
+ unknownObj: 474,
261
+ unknownObjVer: 494
243
262
  };
244
263
  })(archiveObj = exports.archiveObj || (exports.archiveObj = {}));
245
264
  Object.freeze(archiveObj);
246
265
  var archiveRoot;
247
266
  (function (archiveRoot) {
248
- archiveRoot.URL_END = 'root/archive';
267
+ archiveRoot.EXPRESS_URL_END = 'root/archive';
268
+ function postAndDelReqUrlEnd(version) {
269
+ return `root/archive?ver=${version}`;
270
+ }
271
+ archiveRoot.postAndDelReqUrlEnd = postAndDelReqUrlEnd;
249
272
  archiveRoot.SC = archiveObj.SC;
250
273
  })(archiveRoot = exports.archiveRoot || (exports.archiveRoot = {}));
251
274
  Object.freeze(archiveRoot);
@@ -258,14 +281,34 @@ var wsEventChannel;
258
281
  Object.freeze(wsEventChannel.SC);
259
282
  })(wsEventChannel = exports.wsEventChannel || (exports.wsEventChannel = {}));
260
283
  Object.freeze(wsEventChannel);
261
- var objChanged;
262
- (function (objChanged) {
263
- objChanged.EVENT_NAME = 'obj-changed';
264
- })(objChanged = exports.objChanged || (exports.objChanged = {}));
265
- Object.freeze(objChanged);
266
- var objRemoved;
267
- (function (objRemoved) {
268
- objRemoved.EVENT_NAME = 'obj-removed';
269
- })(objRemoved = exports.objRemoved || (exports.objRemoved = {}));
270
- Object.freeze(objChanged);
284
+ var events;
285
+ (function (events) {
286
+ let objChanged;
287
+ (function (objChanged) {
288
+ objChanged.EVENT_NAME = 'obj-changed';
289
+ })(objChanged = events.objChanged || (events.objChanged = {}));
290
+ Object.freeze(objChanged);
291
+ let objRemoved;
292
+ (function (objRemoved) {
293
+ objRemoved.EVENT_NAME = 'obj-removed';
294
+ })(objRemoved = events.objRemoved || (events.objRemoved = {}));
295
+ Object.freeze(objRemoved);
296
+ let objVersionArchived;
297
+ (function (objVersionArchived) {
298
+ objVersionArchived.EVENT_NAME = 'obj-ver-archived';
299
+ })(objVersionArchived = events.objVersionArchived || (events.objVersionArchived = {}));
300
+ Object.freeze(objVersionArchived);
301
+ let objArchivedVersionRemoved;
302
+ (function (objArchivedVersionRemoved) {
303
+ objArchivedVersionRemoved.EVENT_NAME = 'obj-ver-removed';
304
+ })(objArchivedVersionRemoved = events.objArchivedVersionRemoved || (events.objArchivedVersionRemoved = {}));
305
+ Object.freeze(objArchivedVersionRemoved);
306
+ events.all = [
307
+ objChanged.EVENT_NAME,
308
+ objRemoved.EVENT_NAME,
309
+ objVersionArchived.EVENT_NAME,
310
+ objArchivedVersionRemoved.EVENT_NAME,
311
+ ];
312
+ })(events = exports.events || (exports.events = {}));
313
+ Object.freeze(events);
271
314
  Object.freeze(exports);
@@ -97,11 +97,11 @@ var msgObj;
97
97
  (function (msgObj) {
98
98
  msgObj.EXPRESS_URL_END = 'msg/obj/:objId';
99
99
  function firstPutReqUrlEnd(objId, opts) {
100
- return `msg/obj/${objId}?${querystring_1.stringify(opts)}`;
100
+ return `msg/obj/${objId}?${(0, querystring_1.stringify)(opts)}`;
101
101
  }
102
102
  msgObj.firstPutReqUrlEnd = firstPutReqUrlEnd;
103
103
  function secondPutReqUrlEnd(objId, opts) {
104
- return `msg/obj/${objId}?${querystring_1.stringify(opts)}`;
104
+ return `msg/obj/${objId}?${(0, querystring_1.stringify)(opts)}`;
105
105
  }
106
106
  msgObj.secondPutReqUrlEnd = secondPutReqUrlEnd;
107
107
  msgObj.SC = {
@@ -114,7 +114,7 @@ var msgObj;
114
114
  (function (msgObj) {
115
115
  msgObj.EXPRESS_URL_END = 'msg/:msgId/obj/:objId';
116
116
  function genUrlEnd(msgId, objId, opts) {
117
- let optStr = (opts ? '?' + querystring_1.stringify(opts) : '');
117
+ let optStr = (opts ? '?' + (0, querystring_1.stringify)(opts) : '');
118
118
  return `msg/${msgId}/obj/${objId}${optStr}`;
119
119
  }
120
120
  msgObj.genUrlEnd = genUrlEnd;
@@ -4,6 +4,7 @@ export interface TimedCache<TKey, TVal> {
4
4
  resetLifeTimeOf(key: TKey): boolean;
5
5
  set(key: TKey, val: TVal): void;
6
6
  delete(key: TKey): void;
7
+ keys(): TKey[];
7
8
  clear(): void;
8
9
  destroy(): void;
9
10
  }
@@ -10,6 +10,7 @@ export declare class TimeWindowCache<TKey, TVal> implements TimedCache<TKey, TVa
10
10
  has(key: TKey): boolean;
11
11
  set(key: TKey, val: TVal): void;
12
12
  delete(key: TKey): void;
13
+ keys(): TKey[];
13
14
  clear(): void;
14
15
  destroy(): void;
15
16
  }
@@ -43,6 +43,7 @@ class TimeWindowCache {
43
43
  }
44
44
  v = this.waiting.get(key);
45
45
  if (v !== undefined) {
46
+ this.waiting.delete(key);
46
47
  this.filling.set(key, v);
47
48
  }
48
49
  return v;
@@ -57,6 +58,16 @@ class TimeWindowCache {
57
58
  this.filling.delete(key);
58
59
  this.waiting.delete(key);
59
60
  }
61
+ keys() {
62
+ const allKeys = [];
63
+ for (const key of this.filling.keys()) {
64
+ allKeys.push(key);
65
+ }
66
+ for (const key of this.waiting.keys()) {
67
+ allKeys.push(key);
68
+ }
69
+ return allKeys;
70
+ }
60
71
  clear() {
61
72
  this.filling.clear();
62
73
  this.waiting.clear();
@@ -1,4 +1,4 @@
1
- import { Observable } from 'rxjs';
1
+ import { Observable, PartialObserver } from 'rxjs';
2
2
  /**
3
3
  * This is a pipeable operator that runs given async process on completion and
4
4
  * sends result downstream, followed by complete signal.
@@ -22,3 +22,17 @@ export declare function allowOnlySingleStart<T>(): (src: Observable<T>) => Obser
22
22
  * @param onComplete
23
23
  */
24
24
  export declare function flatTap<T>(onNext: ((x: T) => Promise<void>) | undefined | null, onError?: ((err: any) => Promise<void>) | undefined | null, onComplete?: (() => Promise<void>) | undefined | null): (src: Observable<T>) => Observable<T>;
25
+ /**
26
+ * @param obs
27
+ * @return given observer, or one with noop's in place of missing functions
28
+ */
29
+ export declare function toRxObserver<T>(obs: web3n.Observer<T>): PartialObserver<T>;
30
+ export declare class Broadcast<T> {
31
+ private readonly src;
32
+ readonly event$: Observable<T>;
33
+ private sub;
34
+ constructor();
35
+ next(ev: T): void;
36
+ done(err?: any): void;
37
+ isON(): boolean;
38
+ }
@@ -1,14 +1,15 @@
1
1
  "use strict";
2
2
  /*
3
- Copyright (C) 2017, 2019 - 2020 3NSoft Inc.
3
+ Copyright (C) 2017, 2019 - 2020, 2022 3NSoft Inc.
4
4
 
5
5
  This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
6
6
 
7
7
  This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
8
8
 
9
- You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */
9
+ You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
10
+ */
10
11
  Object.defineProperty(exports, "__esModule", { value: true });
11
- exports.flatTap = exports.allowOnlySingleStart = exports.flatMapComplete = void 0;
12
+ exports.Broadcast = exports.toRxObserver = exports.flatTap = exports.allowOnlySingleStart = exports.flatMapComplete = void 0;
12
13
  const rxjs_1 = require("rxjs");
13
14
  const operators_1 = require("rxjs/operators");
14
15
  /**
@@ -18,14 +19,12 @@ const operators_1 = require("rxjs/operators");
18
19
  */
19
20
  function flatMapComplete(mapCompletion) {
20
21
  return src => new rxjs_1.Observable(downstream => src.subscribe({
21
- next(x) { downstream.next(x); },
22
- error(err) { downstream.error(err); },
23
- complete() {
24
- mapCompletion().then(mapped => {
25
- downstream.next(mapped);
26
- downstream.complete();
27
- }, err => downstream.error(err));
28
- }
22
+ next: x => downstream.next(x),
23
+ error: err => downstream.error(err),
24
+ complete: () => mapCompletion().then(mapped => {
25
+ downstream.next(mapped);
26
+ downstream.complete();
27
+ }, err => downstream.error(err))
29
28
  }));
30
29
  }
31
30
  exports.flatMapComplete = flatMapComplete;
@@ -47,20 +46,23 @@ function allowOnlySingleStart() {
47
46
  throw new Error(`Attempt to subscribe, when process hasn't completed indicates that functional closure is captured and called somewhere else, not in accordance with expected rxjs processing.`);
48
47
  }
49
48
  if (okCompletion) {
50
- return rxjs_1.of().subscribe(downstream);
49
+ return (0, rxjs_1.of)().subscribe(downstream);
51
50
  }
52
51
  else {
53
- return rxjs_1.throwError(err).subscribe(downstream);
52
+ return (0, rxjs_1.throwError)(err).subscribe(downstream);
54
53
  }
55
54
  }
56
55
  else {
57
56
  wasStarted = true;
58
- return src.pipe(operators_1.tap(undefined, e => {
59
- isComplete = true;
60
- err = e;
61
- }, () => {
62
- isComplete = true;
63
- okCompletion = true;
57
+ return src.pipe((0, operators_1.tap)({
58
+ error: e => {
59
+ isComplete = true;
60
+ err = e;
61
+ },
62
+ complete: () => {
63
+ isComplete = true;
64
+ okCompletion = true;
65
+ }
64
66
  })).subscribe(downstream);
65
67
  }
66
68
  });
@@ -91,3 +93,52 @@ function flatTap(onNext, onError, onComplete) {
91
93
  }));
92
94
  }
93
95
  exports.flatTap = flatTap;
96
+ /**
97
+ * @param obs
98
+ * @return given observer, or one with noop's in place of missing functions
99
+ */
100
+ function toRxObserver(obs) {
101
+ if (obs.next && obs.error && obs.complete) {
102
+ return obs;
103
+ }
104
+ else {
105
+ const next = (obs.next ? obs.next.bind(obs) : noop);
106
+ const complete = (obs.complete ? obs.complete.bind(obs) : noop);
107
+ const error = (obs.error ? obs.error.bind(obs) : noop);
108
+ return { next, complete, error };
109
+ }
110
+ }
111
+ exports.toRxObserver = toRxObserver;
112
+ function noop() { }
113
+ class Broadcast {
114
+ constructor() {
115
+ this.src = new rxjs_1.Subject();
116
+ this.event$ = this.src.asObservable().pipe((0, operators_1.share)());
117
+ this.sub = this.event$.subscribe(toRxObserver({}));
118
+ Object.seal(this);
119
+ }
120
+ next(ev) {
121
+ if (!this.sub) {
122
+ return;
123
+ }
124
+ this.src.next(ev);
125
+ }
126
+ done(err) {
127
+ if (!this.sub) {
128
+ return;
129
+ }
130
+ if (err) {
131
+ this.src.error(err);
132
+ }
133
+ else {
134
+ this.src.complete();
135
+ }
136
+ this.sub = undefined;
137
+ }
138
+ isON() {
139
+ return !!this.sub;
140
+ }
141
+ }
142
+ exports.Broadcast = Broadcast;
143
+ Object.freeze(Broadcast.prototype);
144
+ Object.freeze(Broadcast);
@@ -21,6 +21,7 @@ export declare class WeakCacheWithMinLifeTime<TKey, TVal> implements TimedCache<
21
21
  resetLifeTimeOf(key: TKey): boolean;
22
22
  set(key: TKey, val: TVal): void;
23
23
  delete(key: TKey): void;
24
+ keys(): TKey[];
24
25
  clear(): void;
25
26
  destroy(): void;
26
27
  }
@@ -48,7 +48,7 @@ class WeakCache {
48
48
  return (this.get(key) !== undefined);
49
49
  }
50
50
  set(key, val) {
51
- const wRef = weakref_1.makeWeakRefFor(val);
51
+ const wRef = (0, weakref_1.makeWeakRefFor)(val);
52
52
  wRef.addCallback(this.makeCB(key, wRef));
53
53
  this.wRefs.set(key, wRef);
54
54
  }
@@ -91,6 +91,7 @@ class WeakCacheWithMinLifeTime {
91
91
  }
92
92
  v = this.waiting.get(key);
93
93
  if (v !== undefined) {
94
+ this.waiting.delete(key);
94
95
  this.filling.set(key, v);
95
96
  return v;
96
97
  }
@@ -117,6 +118,16 @@ class WeakCacheWithMinLifeTime {
117
118
  this.waiting.delete(key);
118
119
  this.wCache.delete(key);
119
120
  }
121
+ keys() {
122
+ const allKeys = [];
123
+ for (const key of this.filling.keys()) {
124
+ allKeys.push(key);
125
+ }
126
+ for (const key of this.waiting.keys()) {
127
+ allKeys.push(key);
128
+ }
129
+ return allKeys;
130
+ }
120
131
  clear() {
121
132
  this.filling.clear();
122
133
  this.waiting.clear();
@@ -2,7 +2,8 @@
2
2
  export * from "./core";
3
3
  export { makeServiceLocator, ServiceLocatorMaker } from "./lib-client/service-locator";
4
4
  export { makeNetClient } from "./lib-client/request-utils";
5
- export { sysFolders, initSysFolders, FactoryOfFSs, PerAppStorage, sysFilesOnDevice, userFilesOnDevice, reverseDomain } from "./core/storage";
5
+ export { FactoryOfFSs, PerAppStorage, reverseDomain } from "./core/storage";
6
+ export { sysFolders } from "./core/storage/system-folders";
6
7
  export { DeviceFS } from './lib-client/local-files/device-fs';
7
8
  export { appDirs } from './core/app-files';
8
9
  export { makeLogger } from './lib-client/logging/log-to-file';