@verdant-web/common 1.13.0 → 1.13.1

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.
package/src/oids.test.ts CHANGED
@@ -9,6 +9,7 @@ import {
9
9
  decomposeOid,
10
10
  getOid,
11
11
  getOidRange,
12
+ getOidRoot,
12
13
  hasOid,
13
14
  maybeGetOidProperty,
14
15
  normalize,
@@ -404,3 +405,9 @@ describe('assigning OIDs to sub-objects', () => {
404
405
  expect(hasOid(obj.bar[0])).toBe(false);
405
406
  });
406
407
  });
408
+
409
+ it('should get the root OID for a legacy OID', () => [
410
+ expect(getOidRoot('items/clabgyjfh00003968qycsq3ld.inputs.#')).toEqual(
411
+ 'items/clabgyjfh00003968qycsq3ld',
412
+ ),
413
+ ]);
package/src/oids.ts CHANGED
@@ -426,7 +426,7 @@ export function normalizeFirstLevel(obj: any) {
426
426
  }
427
427
 
428
428
  export function getOidRoot(oid: ObjectIdentifier) {
429
- return oid.split(RANDOM_SEPARATOR)[0];
429
+ return oid.split('.')[0].split(RANDOM_SEPARATOR)[0];
430
430
  }
431
431
 
432
432
  /**
@@ -37,7 +37,12 @@ export type StorageMapFieldSchema<V extends NestedStorageFieldSchema> = {
37
37
  export type StorageFileFieldSchema = {
38
38
  type: 'file';
39
39
  nullable?: boolean;
40
- // downloadRemote?: boolean; TODO: is this a good feature? maybe later.
40
+ /**
41
+ * Instructs the client to download synced files to local storage on first request for offline use.
42
+ * Leave this false to save storage space on the client, at the cost of requiring a network
43
+ * connection to use files created by other devices.
44
+ */
45
+ downloadRemote?: boolean;
41
46
  };
42
47
 
43
48
  export type StorageFieldSchema =
@@ -2,6 +2,7 @@ import { describe, expect, it, vitest } from 'vitest';
2
2
  import {
3
3
  convertOldHlcTimestamp,
4
4
  deserializeHlcTimestamp,
5
+ encodeVersion,
5
6
  HybridLogicalClockTimestampProvider,
6
7
  OLD_encodeVersion,
7
8
  OLD_serializeHlcTimestamp,
@@ -111,3 +112,15 @@ describe('the hybrid logical clock', () => {
111
112
  expect(clock.getWallClockTime(now)).toEqual(time.getTime());
112
113
  });
113
114
  });
115
+
116
+ describe('version encoding', () => {
117
+ it('orders 1 before 2', () => {
118
+ expect(encodeVersion(1) < encodeVersion(2)).toBe(true);
119
+ });
120
+ it('orders 32 before 33', () => {
121
+ expect(encodeVersion(32) < encodeVersion(33)).toBe(true);
122
+ });
123
+ it('orders 34 before 35', () => {
124
+ expect(encodeVersion(34) < encodeVersion(35)).toBe(true);
125
+ });
126
+ });