cojson 0.3.6 → 0.4.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 (81) hide show
  1. package/dist/coValue.d.ts +7 -12
  2. package/dist/coValue.js.map +1 -1
  3. package/dist/coValueCore.d.ts +9 -4
  4. package/dist/coValueCore.js +69 -33
  5. package/dist/coValueCore.js.map +1 -1
  6. package/dist/coValues/account.d.ts +62 -0
  7. package/dist/{account.js → coValues/account.js} +19 -11
  8. package/dist/coValues/account.js.map +1 -0
  9. package/dist/coValues/coList.d.ts +19 -19
  10. package/dist/coValues/coList.js.map +1 -1
  11. package/dist/coValues/coMap.d.ts +31 -23
  12. package/dist/coValues/coMap.js +4 -6
  13. package/dist/coValues/coMap.js.map +1 -1
  14. package/dist/coValues/coStream.d.ts +19 -19
  15. package/dist/coValues/coStream.js.map +1 -1
  16. package/dist/{group.d.ts → coValues/group.d.ts} +27 -38
  17. package/dist/{group.js → coValues/group.js} +69 -73
  18. package/dist/coValues/group.js.map +1 -0
  19. package/dist/ids.d.ts +1 -1
  20. package/dist/index.d.ts +15 -11
  21. package/dist/index.js +10 -5
  22. package/dist/index.js.map +1 -1
  23. package/dist/localNode.d.ts +20 -7
  24. package/dist/localNode.js +74 -39
  25. package/dist/localNode.js.map +1 -1
  26. package/dist/media.d.ts +1 -1
  27. package/dist/permissions.d.ts +1 -1
  28. package/dist/permissions.js +43 -22
  29. package/dist/permissions.js.map +1 -1
  30. package/dist/queriedCoValues/queriedAccount.d.ts +13 -0
  31. package/dist/queriedCoValues/queriedAccount.js +24 -0
  32. package/dist/queriedCoValues/queriedAccount.js.map +1 -0
  33. package/dist/queriedCoValues/queriedCoList.d.ts +10 -10
  34. package/dist/queriedCoValues/queriedCoList.js +11 -15
  35. package/dist/queriedCoValues/queriedCoList.js.map +1 -1
  36. package/dist/queriedCoValues/queriedCoMap.d.ts +14 -21
  37. package/dist/queriedCoValues/queriedCoMap.js +27 -28
  38. package/dist/queriedCoValues/queriedCoMap.js.map +1 -1
  39. package/dist/queriedCoValues/queriedCoStream.d.ts +9 -9
  40. package/dist/queriedCoValues/queriedCoStream.js +44 -20
  41. package/dist/queriedCoValues/queriedCoStream.js.map +1 -1
  42. package/dist/queriedCoValues/queriedGroup.d.ts +29 -0
  43. package/dist/queriedCoValues/queriedGroup.js +54 -0
  44. package/dist/queriedCoValues/queriedGroup.js.map +1 -0
  45. package/dist/queries.d.ts +40 -9
  46. package/dist/queries.js +104 -39
  47. package/dist/queries.js.map +1 -1
  48. package/dist/sync.js +1 -0
  49. package/dist/sync.js.map +1 -1
  50. package/dist/tests/testUtils.d.ts +15 -7
  51. package/dist/tests/testUtils.js +16 -17
  52. package/dist/tests/testUtils.js.map +1 -1
  53. package/package.json +2 -2
  54. package/src/coValue.ts +12 -31
  55. package/src/coValueCore.ts +100 -40
  56. package/src/{account.ts → coValues/account.ts} +46 -27
  57. package/src/coValues/coList.ts +24 -28
  58. package/src/coValues/coMap.ts +42 -68
  59. package/src/coValues/coStream.ts +20 -26
  60. package/src/{group.ts → coValues/group.ts} +121 -141
  61. package/src/ids.ts +1 -1
  62. package/src/index.ts +25 -10
  63. package/src/localNode.ts +180 -77
  64. package/src/media.ts +1 -1
  65. package/src/permissions.ts +67 -36
  66. package/src/queriedCoValues/queriedAccount.ts +40 -0
  67. package/src/queriedCoValues/queriedCoList.ts +22 -30
  68. package/src/queriedCoValues/queriedCoMap.ts +60 -72
  69. package/src/queriedCoValues/queriedCoStream.ts +67 -37
  70. package/src/queriedCoValues/queriedGroup.ts +90 -0
  71. package/src/queries.ts +181 -60
  72. package/src/sync.ts +1 -0
  73. package/src/tests/account.test.ts +14 -9
  74. package/src/tests/coValueCore.test.ts +2 -2
  75. package/src/tests/permissions.test.ts +351 -242
  76. package/src/tests/queries.test.ts +98 -79
  77. package/src/tests/sync.test.ts +11 -11
  78. package/src/tests/testUtils.ts +16 -18
  79. package/dist/account.d.ts +0 -58
  80. package/dist/account.js.map +0 -1
  81. package/dist/group.js.map +0 -1
@@ -26,12 +26,17 @@ import {
26
26
  determineValidTransactions,
27
27
  isKeyForKeyField,
28
28
  } from "./permissions.js";
29
- import { Group, expectGroupContent } from "./group.js";
29
+ import { Group, expectGroup } from "./coValues/group.js";
30
30
  import { LocalNode } from "./localNode.js";
31
31
  import { CoValueKnownState, NewContentMessage } from "./sync.js";
32
32
  import { AgentID, RawCoID, SessionID, TransactionID } from "./ids.js";
33
33
  import { CoList } from "./coValues/coList.js";
34
- import { AccountID, GeneralizedControlledAccount } from "./account.js";
34
+ import {
35
+ Account,
36
+ AccountID,
37
+ GeneralizedControlledAccount,
38
+ isAccountID,
39
+ } from "./coValues/account.js";
35
40
  import { Stringified, stableStringify } from "./jsonStringify.js";
36
41
 
37
42
  export const MAX_RECOMMENDED_TX_SIZE = 100 * 1024;
@@ -163,7 +168,15 @@ export class CoValueCore {
163
168
  }
164
169
 
165
170
  nextTransactionID(): TransactionID {
166
- const sessionID = this.node.currentSessionID;
171
+ // This is an ugly hack to get a unique but stable session ID for editing the current account
172
+ const sessionID =
173
+ this.header.meta?.type === "account"
174
+ ? (this.node.currentSessionID.replace(
175
+ this.node.account.id,
176
+ this.node.account.currentAgentID()
177
+ ) as SessionID)
178
+ : this.node.currentSessionID;
179
+
167
180
  return {
168
181
  sessionID,
169
182
  txIndex: this.sessions[sessionID]?.transactions.length || 0,
@@ -467,7 +480,14 @@ export class CoValueCore {
467
480
  };
468
481
  }
469
482
 
470
- const sessionID = this.node.currentSessionID;
483
+ // This is an ugly hack to get a unique but stable session ID for editing the current account
484
+ const sessionID =
485
+ this.header.meta?.type === "account"
486
+ ? (this.node.currentSessionID.replace(
487
+ this.node.account.id,
488
+ this.node.account.currentAgentID()
489
+ ) as SessionID)
490
+ : this.node.currentSessionID;
471
491
 
472
492
  const { expectedNewHash } = this.expectedNewHashAfter(sessionID, [
473
493
  transaction,
@@ -492,33 +512,51 @@ export class CoValueCore {
492
512
  return success;
493
513
  }
494
514
 
495
- getCurrentContent(): CoValue {
496
- if (this._cachedContent) {
515
+ getCurrentContent(options?: { ignorePrivateTransactions: true }): CoValue {
516
+ if (!options?.ignorePrivateTransactions && this._cachedContent) {
497
517
  return this._cachedContent;
498
518
  }
499
519
 
520
+ let newContent;
500
521
  if (this.header.type === "comap") {
501
- this._cachedContent = new CoMap(this);
522
+ if (this.header.ruleset.type === "group") {
523
+ if (
524
+ this.header.meta?.type === "account" &&
525
+ !options?.ignorePrivateTransactions
526
+ ) {
527
+ newContent = new Account(this);
528
+ } else {
529
+ newContent = new Group(this, options);
530
+ }
531
+ } else {
532
+ newContent = new CoMap(this);
533
+ }
502
534
  } else if (this.header.type === "colist") {
503
- this._cachedContent = new CoList(this);
535
+ newContent = new CoList(this);
504
536
  } else if (this.header.type === "costream") {
505
537
  if (this.header.meta && this.header.meta.type === "binary") {
506
- this._cachedContent = new BinaryCoStream(this);
538
+ newContent = new BinaryCoStream(this);
507
539
  } else {
508
- this._cachedContent = new CoStream(this);
540
+ newContent = new CoStream(this);
509
541
  }
510
542
  } else {
511
543
  throw new Error(`Unknown coValue type ${this.header.type}`);
512
544
  }
513
545
 
514
- return this._cachedContent;
546
+ if (!options?.ignorePrivateTransactions) {
547
+ this._cachedContent = newContent;
548
+ }
549
+
550
+ return newContent;
515
551
  }
516
552
 
517
- getValidSortedTransactions(): DecryptedTransaction[] {
553
+ getValidSortedTransactions(options?: {
554
+ ignorePrivateTransactions: true;
555
+ }): DecryptedTransaction[] {
518
556
  const validTransactions = determineValidTransactions(this);
519
557
 
520
558
  const allTransactions: DecryptedTransaction[] = validTransactions
521
- .map(({ txID, tx }) => {
559
+ .flatMap(({ txID, tx }) => {
522
560
  if (tx.privacy === "trusting") {
523
561
  return {
524
562
  txID,
@@ -526,6 +564,9 @@ export class CoValueCore {
526
564
  changes: tx.changes,
527
565
  };
528
566
  } else {
567
+ if (options?.ignorePrivateTransactions) {
568
+ return undefined;
569
+ }
529
570
  const readKey = this.getReadKey(tx.keyUsed);
530
571
 
531
572
  if (!readKey) {
@@ -574,7 +615,7 @@ export class CoValueCore {
574
615
 
575
616
  getCurrentReadKey(): { secret: KeySecret | undefined; id: KeyID } {
576
617
  if (this.header.ruleset.type === "group") {
577
- const content = expectGroupContent(this.getCurrentContent());
618
+ const content = expectGroup(this.getCurrentContent());
578
619
 
579
620
  const currentKeyId = content.get("readKey");
580
621
 
@@ -600,16 +641,38 @@ export class CoValueCore {
600
641
  }
601
642
 
602
643
  getReadKey(keyID: KeyID): KeySecret | undefined {
603
- if (readKeyCache.get(this)?.[keyID]) {
604
- return readKeyCache.get(this)?.[keyID];
644
+ let key = readKeyCache.get(this)?.[keyID];
645
+ if (!key) {
646
+ key = this.getUncachedReadKey(keyID);
647
+ if (key) {
648
+ let cache = readKeyCache.get(this);
649
+ if (!cache) {
650
+ cache = {};
651
+ readKeyCache.set(this, cache);
652
+ }
653
+ cache[keyID] = key;
654
+ }
605
655
  }
656
+ return key;
657
+ }
658
+
659
+ getUncachedReadKey(keyID: KeyID): KeySecret | undefined {
606
660
  if (this.header.ruleset.type === "group") {
607
- const content = expectGroupContent(this.getCurrentContent());
661
+ const content = expectGroup(
662
+ this.getCurrentContent({ ignorePrivateTransactions: true })
663
+ );
664
+
665
+ const keyForEveryone = content.get(`${keyID}_for_everyone`);
666
+ if (keyForEveryone) return keyForEveryone;
608
667
 
609
668
  // Try to find key revelation for us
669
+ const lookupAccountOrAgentID =
670
+ this.header.meta?.type === "account"
671
+ ? this.node.account.currentAgentID()
672
+ : this.node.account.id;
610
673
 
611
674
  const lastReadyKeyEdit = content.lastEditAt(
612
- `${keyID}_for_${this.node.account.id}`
675
+ `${keyID}_for_${lookupAccountOrAgentID}`
613
676
  );
614
677
 
615
678
  if (lastReadyKeyEdit?.value) {
@@ -630,13 +693,6 @@ export class CoValueCore {
630
693
  );
631
694
 
632
695
  if (secret) {
633
- let cache = readKeyCache.get(this);
634
- if (!cache) {
635
- cache = {};
636
- readKeyCache.set(this, cache);
637
- }
638
- cache[keyID] = secret;
639
-
640
696
  return secret as KeySecret;
641
697
  }
642
698
  }
@@ -665,13 +721,6 @@ export class CoValueCore {
665
721
  );
666
722
 
667
723
  if (secret) {
668
- let cache = readKeyCache.get(this);
669
- if (!cache) {
670
- cache = {};
671
- readKeyCache.set(this, cache);
672
- }
673
- cache[keyID] = secret;
674
-
675
724
  return secret as KeySecret;
676
725
  } else {
677
726
  console.error(
@@ -698,13 +747,10 @@ export class CoValueCore {
698
747
  throw new Error("Only values owned by groups have groups");
699
748
  }
700
749
 
701
- return new Group(
702
- expectGroupContent(
703
- this.node
704
- .expectCoValueLoaded(this.header.ruleset.group)
705
- .getCurrentContent()
706
- ),
750
+ return expectGroup(
707
751
  this.node
752
+ .expectCoValueLoaded(this.header.ruleset.group)
753
+ .getCurrentContent()
708
754
  );
709
755
  }
710
756
 
@@ -808,11 +854,25 @@ export class CoValueCore {
808
854
 
809
855
  getDependedOnCoValues(): RawCoID[] {
810
856
  return this.header.ruleset.type === "group"
811
- ? expectGroupContent(this.getCurrentContent())
857
+ ? expectGroup(this.getCurrentContent())
812
858
  .keys()
813
859
  .filter((k): k is AccountID => k.startsWith("co_"))
814
860
  : this.header.ruleset.type === "ownedByGroup"
815
- ? [this.header.ruleset.group]
861
+ ? [
862
+ this.header.ruleset.group,
863
+ ...new Set(
864
+ Object.keys(this._sessions)
865
+ .map((sessionID) =>
866
+ accountOrAgentIDfromSessionID(
867
+ sessionID as SessionID
868
+ )
869
+ )
870
+ .filter(
871
+ (session): session is AccountID =>
872
+ isAccountID(session) && session !== this.id
873
+ )
874
+ ),
875
+ ]
816
876
  : [];
817
877
  }
818
878
  }
@@ -1,5 +1,5 @@
1
- import { CoValueHeader } from "./coValueCore.js";
2
- import { CoID } from "./coValue.js";
1
+ import { CoValueCore, CoValueHeader } from "../coValueCore.js";
2
+ import { CoID, CoValue } from "../coValue.js";
3
3
  import {
4
4
  AgentSecret,
5
5
  SealerID,
@@ -11,11 +11,10 @@ import {
11
11
  getAgentSealerSecret,
12
12
  getAgentSignerID,
13
13
  getAgentSignerSecret,
14
- } from "./crypto.js";
15
- import { AgentID } from "./ids.js";
16
- import { CoMap } from "./coValues/coMap.js";
17
- import { LocalNode } from "./localNode.js";
18
- import { Group, GroupContent } from "./group.js";
14
+ } from "../crypto.js";
15
+ import { AgentID } from "../ids.js";
16
+ import { CoMap } from "./coMap.js";
17
+ import { Group, InviteSecret } from "./group.js";
19
18
 
20
19
  export function accountHeaderForInitialAgentSecret(
21
20
  agentSecret: AgentSecret
@@ -32,15 +31,15 @@ export function accountHeaderForInitialAgentSecret(
32
31
  };
33
32
  }
34
33
 
35
- export class AccountGroup extends Group {
36
- get id(): AccountID {
37
- return this.underlyingMap.id as AccountID;
38
- }
39
-
34
+ export class Account<
35
+ P extends Profile = Profile,
36
+ R extends CoMap = CoMap,
37
+ Meta extends AccountMeta = AccountMeta
38
+ > extends Group<P, R, Meta> {
40
39
  getCurrentAgentID(): AgentID {
41
- const agents = this.underlyingMap
42
- .keys()
43
- .filter((k): k is AgentID => k.startsWith("sealer_"));
40
+ const agents = this.keys().filter((k): k is AgentID =>
41
+ k.startsWith("sealer_")
42
+ );
44
43
 
45
44
  if (agents.length !== 1) {
46
45
  throw new Error(
@@ -64,22 +63,37 @@ export interface GeneralizedControlledAccount {
64
63
  }
65
64
 
66
65
  /** @hidden */
67
- export class ControlledAccount
68
- extends AccountGroup
66
+ export class ControlledAccount<
67
+ P extends Profile = Profile,
68
+ R extends CoMap = CoMap,
69
+ Meta extends AccountMeta = AccountMeta
70
+ >
71
+ extends Account<P, R, Meta>
69
72
  implements GeneralizedControlledAccount
70
73
  {
71
74
  agentSecret: AgentSecret;
72
75
 
73
- constructor(
74
- agentSecret: AgentSecret,
75
- groupMap: CoMap<AccountContent, AccountMeta>,
76
- node: LocalNode
77
- ) {
78
- super(groupMap, node);
76
+ constructor(core: CoValueCore, agentSecret: AgentSecret) {
77
+ super(core);
79
78
 
80
79
  this.agentSecret = agentSecret;
81
80
  }
82
81
 
82
+ /**
83
+ * Creates a new group (with the current account as the group's first admin).
84
+ * @category 1. High-level
85
+ */
86
+ createGroup() {
87
+ return this.core.node.createGroup();
88
+ }
89
+
90
+ async acceptInvite<T extends CoValue>(
91
+ groupOrOwnedValueID: CoID<T>,
92
+ inviteSecret: InviteSecret
93
+ ): Promise<void> {
94
+ return this.core.node.acceptInvite(groupOrOwnedValueID, inviteSecret);
95
+ }
96
+
83
97
  currentAgentID(): AgentID {
84
98
  return getAgentID(this.agentSecret);
85
99
  }
@@ -136,17 +150,22 @@ export class AnonymousControlledAccount
136
150
  }
137
151
  }
138
152
 
139
- export type AccountContent = { profile: Profile } & GroupContent;
140
153
  export type AccountMeta = { type: "account" };
141
- export type Account = CoMap<AccountContent, AccountMeta>;
142
154
  export type AccountID = CoID<Account>;
143
155
 
144
156
  export function isAccountID(id: AccountID | AgentID): id is AccountID {
145
157
  return id.startsWith("co_");
146
158
  }
147
159
 
148
- export type ProfileContent = {
160
+ export type ProfileShape = {
149
161
  name: string;
150
162
  };
151
163
  export type ProfileMeta = { type: "profile" };
152
- export type Profile = CoMap<ProfileContent, ProfileMeta>;
164
+
165
+ export class Profile<Shape extends ProfileShape = ProfileShape, Meta extends ProfileMeta = ProfileMeta> extends CoMap<Shape, Meta> {
166
+
167
+ }
168
+
169
+ export type AccountMigration< P extends Profile = Profile,
170
+ R extends CoMap = CoMap,
171
+ Meta extends AccountMeta = AccountMeta> = (account: ControlledAccount<P, R, Meta>, profile: P) => void;
@@ -2,21 +2,21 @@ import { JsonObject, JsonValue } from "../jsonValue.js";
2
2
  import { CoID, CoValue, isCoValue } from "../coValue.js";
3
3
  import { CoValueCore, accountOrAgentIDfromSessionID } from "../coValueCore.js";
4
4
  import { AgentID, SessionID, TransactionID } from "../ids.js";
5
- import { Group } from "../group.js";
6
- import { AccountID } from "../account.js";
5
+ import { AccountID } from "./account.js";
7
6
  import { parseJSON } from "../jsonStringify.js";
7
+ import { Group } from "./group.js";
8
8
 
9
9
  type OpID = TransactionID & { changeIdx: number };
10
10
 
11
- type InsertionOpPayload<T extends JsonValue | CoValue> =
11
+ type InsertionOpPayload<T extends JsonValue> =
12
12
  | {
13
13
  op: "pre";
14
- value: T extends CoValue ? CoID<T> : Exclude<T, CoValue>;
14
+ value: T;
15
15
  before: OpID | "end";
16
16
  }
17
17
  | {
18
18
  op: "app";
19
- value: T extends CoValue ? CoID<T> : Exclude<T, CoValue>;
19
+ value: T;
20
20
  after: OpID | "start";
21
21
  };
22
22
 
@@ -25,11 +25,11 @@ type DeletionOpPayload = {
25
25
  insertion: OpID;
26
26
  };
27
27
 
28
- export type ListOpPayload<T extends JsonValue | CoValue> =
28
+ export type ListOpPayload<T extends JsonValue> =
29
29
  | InsertionOpPayload<T>
30
30
  | DeletionOpPayload;
31
31
 
32
- type InsertionEntry<T extends JsonValue | CoValue> = {
32
+ type InsertionEntry<T extends JsonValue> = {
33
33
  madeAt: number;
34
34
  predecessors: OpID[];
35
35
  successors: OpID[];
@@ -41,7 +41,7 @@ type DeletionEntry = {
41
41
  } & DeletionOpPayload;
42
42
 
43
43
  export class CoListView<
44
- Item extends JsonValue | CoValue,
44
+ Item extends JsonValue = JsonValue,
45
45
  Meta extends JsonObject | null = null
46
46
  > implements CoValue
47
47
  {
@@ -220,11 +220,7 @@ export class CoListView<
220
220
  *
221
221
  * @category 1. Reading
222
222
  */
223
- get(
224
- idx: number
225
- ):
226
- | (Item extends CoValue ? CoID<Item> : Exclude<Item, CoValue>)
227
- | undefined {
223
+ get(idx: number): Item | undefined {
228
224
  const entry = this.entries()[idx];
229
225
  if (!entry) {
230
226
  return undefined;
@@ -237,18 +233,18 @@ export class CoListView<
237
233
  *
238
234
  * @category 1. Reading
239
235
  **/
240
- asArray(): (Item extends CoValue ? CoID<Item> : Exclude<Item, CoValue>)[] {
236
+ asArray(): Item[] {
241
237
  return this.entries().map((entry) => entry.value);
242
238
  }
243
239
 
244
240
  /** @internal */
245
- entries(): {
246
- value: Item extends CoValue ? CoID<Item> : Exclude<Item, CoValue>;
241
+ entries(): {
242
+ value: Item;
247
243
  madeAt: number;
248
244
  opID: OpID;
249
245
  }[] {
250
246
  const arr: {
251
- value: Item extends CoValue ? CoID<Item> : Exclude<Item, CoValue>;
247
+ value: Item;
252
248
  madeAt: number;
253
249
  opID: OpID;
254
250
  }[] = [];
@@ -265,7 +261,7 @@ export class CoListView<
265
261
  private fillArrayFromOpID(
266
262
  opID: OpID,
267
263
  arr: {
268
- value: Item extends CoValue ? CoID<Item> : Exclude<Item, CoValue>;
264
+ value: Item;
269
265
  madeAt: number;
270
266
  opID: OpID;
271
267
  }[]
@@ -299,7 +295,7 @@ export class CoListView<
299
295
  *
300
296
  * @category 1. Reading
301
297
  */
302
- toJSON(): (Item extends CoValue ? CoID<Item> : Exclude<Item, CoValue>)[] {
298
+ toJSON(): Item[] {
303
299
  return this.asArray();
304
300
  }
305
301
 
@@ -309,7 +305,7 @@ export class CoListView<
309
305
  by: AccountID | AgentID;
310
306
  tx: TransactionID;
311
307
  at: Date;
312
- value: Item extends CoValue ? CoID<Item> : Exclude<Item, CoValue>;
308
+ value: Item;
313
309
  }
314
310
  | undefined {
315
311
  const entry = this.entries()[idx];
@@ -377,8 +373,8 @@ export class CoListView<
377
373
  }
378
374
 
379
375
  export class CoList<
380
- Item extends JsonValue | CoValue,
381
- Meta extends JsonObject | null = null
376
+ Item extends JsonValue = JsonValue,
377
+ Meta extends JsonObject | null = JsonObject | null
382
378
  >
383
379
  extends CoListView<Item, Meta>
384
380
  implements CoValue
@@ -392,7 +388,7 @@ export class CoList<
392
388
  * @category 2. Editing
393
389
  **/
394
390
  append(
395
- item: Item extends CoValue ? Item | CoID<Item> : Item,
391
+ item: Item,
396
392
  after?: number,
397
393
  privacy: "private" | "trusting" = "private"
398
394
  ): this {
@@ -440,7 +436,7 @@ export class CoList<
440
436
  * @category 2. Editing
441
437
  */
442
438
  prepend(
443
- item: Item extends CoValue ? Item | CoID<Item> : Item,
439
+ item: Item,
444
440
  before?: number,
445
441
  privacy: "private" | "trusting" = "private"
446
442
  ): this {
@@ -518,8 +514,8 @@ export class CoList<
518
514
  }
519
515
 
520
516
  export class MutableCoList<
521
- Item extends JsonValue | CoValue,
522
- Meta extends JsonObject | null = null
517
+ Item extends JsonValue = JsonValue,
518
+ Meta extends JsonObject | null = JsonObject | null
523
519
  >
524
520
  extends CoListView<Item, Meta>
525
521
  implements CoValue
@@ -533,7 +529,7 @@ export class MutableCoList<
533
529
  * @category 2. Mutating
534
530
  **/
535
531
  append(
536
- item: Item extends CoValue ? Item | CoID<Item> : Item,
532
+ item: Item,
537
533
  after?: number,
538
534
  privacy: "private" | "trusting" = "private"
539
535
  ): void {
@@ -558,7 +554,7 @@ export class MutableCoList<
558
554
  * * @category 2. Mutating
559
555
  **/
560
556
  prepend(
561
- item: Item extends CoValue ? Item | CoID<Item> : Item,
557
+ item: Item,
562
558
  before?: number,
563
559
  privacy: "private" | "trusting" = "private"
564
560
  ): void {