cojson 0.4.1 → 0.4.5

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 (67) hide show
  1. package/dist/coValue.js +1 -1
  2. package/dist/coValue.js.map +1 -1
  3. package/dist/coValues/coList.js +1 -1
  4. package/dist/coValues/coList.js.map +1 -1
  5. package/dist/coValues/coMap.js +1 -1
  6. package/dist/coValues/coMap.js.map +1 -1
  7. package/dist/coValues/coStream.js +1 -1
  8. package/dist/coValues/coStream.js.map +1 -1
  9. package/dist/coValues/group.js.map +1 -1
  10. package/dist/index.js +2 -4
  11. package/dist/index.js.map +1 -1
  12. package/dist/localNode.js +1 -14
  13. package/dist/localNode.js.map +1 -1
  14. package/package.json +4 -4
  15. package/src/coValue.ts +10 -7
  16. package/src/coValues/coList.ts +1 -1
  17. package/src/coValues/coMap.ts +1 -1
  18. package/src/coValues/coStream.ts +1 -3
  19. package/src/coValues/group.ts +4 -4
  20. package/src/index.ts +16 -16
  21. package/src/localNode.ts +6 -47
  22. package/src/tests/coValue.test.ts +5 -5
  23. package/src/tests/group.test.ts +1 -1
  24. package/dist/base64url.d.ts +0 -2
  25. package/dist/coValue.d.ts +0 -38
  26. package/dist/coValueCore.d.ts +0 -103
  27. package/dist/coValues/account.d.ts +0 -62
  28. package/dist/coValues/coList.d.ts +0 -179
  29. package/dist/coValues/coMap.d.ts +0 -149
  30. package/dist/coValues/coStream.d.ts +0 -123
  31. package/dist/coValues/group.d.ts +0 -111
  32. package/dist/crypto.d.ts +0 -120
  33. package/dist/ids.d.ts +0 -11
  34. package/dist/index.d.ts +0 -67
  35. package/dist/jsonStringify.d.ts +0 -6
  36. package/dist/jsonValue.d.ts +0 -7
  37. package/dist/localNode.d.ts +0 -101
  38. package/dist/media.d.ts +0 -7
  39. package/dist/permissions.d.ts +0 -20
  40. package/dist/queriedCoValues/queriedAccount.d.ts +0 -13
  41. package/dist/queriedCoValues/queriedAccount.js +0 -24
  42. package/dist/queriedCoValues/queriedAccount.js.map +0 -1
  43. package/dist/queriedCoValues/queriedCoList.d.ts +0 -66
  44. package/dist/queriedCoValues/queriedCoList.js +0 -116
  45. package/dist/queriedCoValues/queriedCoList.js.map +0 -1
  46. package/dist/queriedCoValues/queriedCoMap.d.ts +0 -40
  47. package/dist/queriedCoValues/queriedCoMap.js +0 -82
  48. package/dist/queriedCoValues/queriedCoMap.js.map +0 -1
  49. package/dist/queriedCoValues/queriedCoStream.d.ts +0 -36
  50. package/dist/queriedCoValues/queriedCoStream.js +0 -97
  51. package/dist/queriedCoValues/queriedCoStream.js.map +0 -1
  52. package/dist/queriedCoValues/queriedGroup.d.ts +0 -29
  53. package/dist/queriedCoValues/queriedGroup.js +0 -54
  54. package/dist/queriedCoValues/queriedGroup.js.map +0 -1
  55. package/dist/queries.d.ts +0 -62
  56. package/dist/queries.js +0 -142
  57. package/dist/queries.js.map +0 -1
  58. package/dist/streamUtils.d.ts +0 -8
  59. package/dist/sync.d.ts +0 -80
  60. package/dist/tests/testUtils.d.ts +0 -37
  61. package/src/queriedCoValues/queriedAccount.ts +0 -40
  62. package/src/queriedCoValues/queriedCoList.ts +0 -240
  63. package/src/queriedCoValues/queriedCoMap.ts +0 -168
  64. package/src/queriedCoValues/queriedCoStream.ts +0 -151
  65. package/src/queriedCoValues/queriedGroup.ts +0 -90
  66. package/src/queries.ts +0 -263
  67. package/src/tests/queries.test.ts +0 -398
package/src/localNode.ts CHANGED
@@ -17,14 +17,12 @@ import {
17
17
  import {
18
18
  InviteSecret,
19
19
  Group,
20
- GroupShape,
21
20
  expectGroup,
22
21
  secretSeedFromInviteSecret,
23
22
  } from "./coValues/group.js";
24
23
  import { Peer, SyncManager } from "./sync.js";
25
24
  import { AgentID, RawCoID, SessionID, isAgentID } from "./ids.js";
26
25
  import { CoID } from "./coValue.js";
27
- import { Queried, query } from "./queries.js";
28
26
  import {
29
27
  Account,
30
28
  AccountMeta,
@@ -34,12 +32,10 @@ import {
34
32
  AnonymousControlledAccount,
35
33
  AccountID,
36
34
  Profile,
37
- isAccountID,
38
35
  AccountMigration,
39
36
  } from "./coValues/account.js";
40
37
  import { CoMap } from "./coValues/coMap.js";
41
38
  import { CoValue } from "./index.js";
42
- import { QueriedAccount } from "./queriedCoValues/queriedAccount.js";
43
39
 
44
40
  /** A `LocalNode` represents a local view of a set of loaded `CoValue`s, from the perspective of a particular account (or primitive cryptographic agent).
45
41
 
@@ -103,7 +99,8 @@ export class LocalNode {
103
99
  newRandomSessionID(account.id)
104
100
  );
105
101
 
106
- const accountOnNodeWithAccount = nodeWithAccount.account as ControlledAccount<P, R, Meta>;
102
+ const accountOnNodeWithAccount =
103
+ nodeWithAccount.account as ControlledAccount<P, R, Meta>;
107
104
 
108
105
  const profile = nodeWithAccount.expectProfileLoaded(
109
106
  accountOnNodeWithAccount.id,
@@ -256,47 +253,6 @@ export class LocalNode {
256
253
  };
257
254
  }
258
255
 
259
- /** @category 1. High-level */
260
-
261
- query<T extends CoValue>(
262
- id: CoID<T>,
263
- callback: (update: Queried<T> | undefined) => void
264
- ): () => void;
265
- query<
266
- P extends Profile = Profile,
267
- R extends CoMap = CoMap,
268
- Meta extends AccountMeta = AccountMeta
269
- >(
270
- id: "me",
271
- callback: (
272
- update: QueriedAccount<Account<P, R, Meta>> | undefined
273
- ) => void
274
- ): () => void;
275
- query(
276
- id: CoID<CoValue> | "me",
277
- callback: (
278
- update: Queried<CoValue> | QueriedAccount | undefined
279
- ) => void
280
- ): () => void;
281
- query(
282
- id: CoID<CoValue> | "me",
283
- callback: (
284
- // TODO: sort this out
285
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
286
- update: any
287
- ) => void
288
- ): () => void {
289
- if (id === "me") {
290
- const meId = this.account.id;
291
- if (!isAccountID(meId)) {
292
- throw new Error("Can only query 'me' for accounts");
293
- }
294
- return query(meId, this, callback);
295
- } else {
296
- return query(id, this, callback);
297
- }
298
- }
299
-
300
256
  /** @deprecated Use Account.acceptInvite instead */
301
257
  async acceptInvite<T extends CoValue>(
302
258
  groupOrOwnedValueID: CoID<T>,
@@ -601,7 +557,10 @@ export class LocalNode {
601
557
 
602
558
  if (account instanceof ControlledAccount) {
603
559
  // To make sure that when we edit the account, we're modifying the correct sessions
604
- const accountInNode = new ControlledAccount(newNode.expectCoValueLoaded(account.id), account.agentSecret);
560
+ const accountInNode = new ControlledAccount(
561
+ newNode.expectCoValueLoaded(account.id),
562
+ account.agentSecret
563
+ );
605
564
  if (accountInNode.core.node !== newNode) {
606
565
  throw new Error("Account's node is not the new node");
607
566
  }
@@ -315,14 +315,14 @@ test("Empty BinaryCoStream works", () => {
315
315
 
316
316
  if (
317
317
  content.type !== "costream" ||
318
- content.meta?.type !== "binary" ||
318
+ content.headerMeta?.type !== "binary" ||
319
319
  !(content instanceof BinaryCoStream)
320
320
  ) {
321
321
  throw new Error("Expected binary stream");
322
322
  }
323
323
 
324
324
  expect(content.type).toEqual("costream");
325
- expect(content.meta.type).toEqual("binary");
325
+ expect(content.headerMeta.type).toEqual("binary");
326
326
  expect(content.toJSON()).toEqual({});
327
327
  expect(content.getBinaryChunks()).toEqual(undefined);
328
328
  });
@@ -341,7 +341,7 @@ test("Can push into BinaryCoStream", () => {
341
341
 
342
342
  if (
343
343
  content.type !== "costream" ||
344
- content.meta?.type !== "binary" ||
344
+ content.headerMeta?.type !== "binary" ||
345
345
  !(content instanceof BinaryCoStream)
346
346
  ) {
347
347
  throw new Error("Expected binary stream");
@@ -398,7 +398,7 @@ test("When adding large transactions (small fraction of MAX_RECOMMENDED_TX_SIZE)
398
398
 
399
399
  if (
400
400
  content.type !== "costream" ||
401
- content.meta?.type !== "binary" ||
401
+ content.headerMeta?.type !== "binary" ||
402
402
  !(content instanceof BinaryCoStream)
403
403
  ) {
404
404
  throw new Error("Expected binary stream");
@@ -474,7 +474,7 @@ test("When adding large transactions (bigger than MAX_RECOMMENDED_TX_SIZE), we s
474
474
 
475
475
  if (
476
476
  content.type !== "costream" ||
477
- content.meta?.type !== "binary" ||
477
+ content.headerMeta?.type !== "binary" ||
478
478
  !(content instanceof BinaryCoStream)
479
479
  ) {
480
480
  throw new Error("Expected binary stream");
@@ -46,6 +46,6 @@ test("Can create a BinaryCoStream in a group", () => {
46
46
  const stream = group.createBinaryStream();
47
47
 
48
48
  expect(stream.core.getCurrentContent().type).toEqual("costream");
49
- expect(stream.meta.type).toEqual("binary");
49
+ expect(stream.headerMeta.type).toEqual("binary");
50
50
  expect(stream instanceof BinaryCoStream).toEqual(true);
51
51
  })
@@ -1,2 +0,0 @@
1
- export declare function base64URLtoBytes(base64: string): Uint8Array;
2
- export declare function bytesToBase64url(bytes: Uint8Array): string;
package/dist/coValue.d.ts DELETED
@@ -1,38 +0,0 @@
1
- import { JsonObject, JsonValue } from "./jsonValue.js";
2
- import { RawCoID } from "./ids.js";
3
- import { CoMap } from "./coValues/coMap.js";
4
- import { BinaryCoStream, CoStream } from "./coValues/coStream.js";
5
- import { CoList } from "./coValues/coList.js";
6
- import { CoValueCore } from "./coValueCore.js";
7
- import { Group } from "./coValues/group.js";
8
- import { Account, Profile } from "./index.js";
9
- export type CoID<T extends CoValue> = RawCoID & {
10
- readonly __type: T;
11
- };
12
- export interface CoValue {
13
- /** The `CoValue`'s (precisely typed) `CoID` */
14
- id: CoID<this>;
15
- core: CoValueCore;
16
- /** Specifies which kind of `CoValue` this is */
17
- type: string;
18
- /** The `CoValue`'s (precisely typed) static metadata */
19
- meta: JsonObject | null;
20
- /** The `Group` this `CoValue` belongs to (determining permissions) */
21
- group: Group;
22
- /** Returns an immutable JSON presentation of this `CoValue` */
23
- toJSON(): JsonValue;
24
- atTime(time: number): this;
25
- /** Lets you subscribe to future updates to this CoValue (whether made locally or by other users).
26
- *
27
- * Takes a listener function that will be called with the current state for each update.
28
- *
29
- * Returns an unsubscribe function.
30
- *
31
- * Used internally by `useTelepathicData()` for reactive updates on changes to a `CoValue`. */
32
- subscribe(listener: (coValue: this) => void): () => void;
33
- }
34
- export type AnyCoValue = CoMap | Group | Account | Profile | CoList | CoStream | BinaryCoStream;
35
- export declare function expectMap(content: CoValue): CoMap;
36
- export declare function expectList(content: CoValue): CoList;
37
- export declare function expectStream(content: CoValue): CoStream;
38
- export declare function isCoValue(value: JsonValue | CoValue | undefined): value is CoValue;
@@ -1,103 +0,0 @@
1
- import { AnyCoValue, CoValue } from "./coValue.js";
2
- import { Encrypted, Hash, KeySecret, Signature, StreamingHash, KeyID } from "./crypto.js";
3
- import { JsonObject, JsonValue } from "./jsonValue.js";
4
- import { PermissionsDef as RulesetDef } from "./permissions.js";
5
- import { Group } from "./coValues/group.js";
6
- import { LocalNode } from "./localNode.js";
7
- import { CoValueKnownState, NewContentMessage } from "./sync.js";
8
- import { AgentID, RawCoID, SessionID, TransactionID } from "./ids.js";
9
- import { AccountID, GeneralizedControlledAccount } from "./coValues/account.js";
10
- import { Stringified } from "./jsonStringify.js";
11
- export declare const MAX_RECOMMENDED_TX_SIZE: number;
12
- export type CoValueHeader = {
13
- type: AnyCoValue["type"];
14
- ruleset: RulesetDef;
15
- meta: JsonObject | null;
16
- createdAt: `2${string}` | null;
17
- uniqueness: `z${string}` | null;
18
- };
19
- export declare function idforHeader(header: CoValueHeader): RawCoID;
20
- export declare function accountOrAgentIDfromSessionID(sessionID: SessionID): AccountID | AgentID;
21
- export declare function newRandomSessionID(accountID: AccountID | AgentID): SessionID;
22
- type SessionLog = {
23
- transactions: Transaction[];
24
- lastHash?: Hash;
25
- streamingHash: StreamingHash;
26
- signatureAfter: {
27
- [txIdx: number]: Signature | undefined;
28
- };
29
- lastSignature: Signature;
30
- };
31
- export type PrivateTransaction = {
32
- privacy: "private";
33
- madeAt: number;
34
- keyUsed: KeyID;
35
- encryptedChanges: Encrypted<JsonValue[], {
36
- in: RawCoID;
37
- tx: TransactionID;
38
- }>;
39
- };
40
- export type TrustingTransaction = {
41
- privacy: "trusting";
42
- madeAt: number;
43
- changes: Stringified<JsonValue[]>;
44
- };
45
- export type Transaction = PrivateTransaction | TrustingTransaction;
46
- export type DecryptedTransaction = {
47
- txID: TransactionID;
48
- changes: Stringified<JsonValue[]>;
49
- madeAt: number;
50
- };
51
- export declare class CoValueCore {
52
- id: RawCoID;
53
- node: LocalNode;
54
- header: CoValueHeader;
55
- _sessions: {
56
- [key: SessionID]: SessionLog;
57
- };
58
- _cachedContent?: CoValue;
59
- listeners: Set<(content?: CoValue) => void>;
60
- _decryptionCache: {
61
- [key: Encrypted<JsonValue[], JsonValue>]: Stringified<JsonValue[]> | undefined;
62
- };
63
- constructor(header: CoValueHeader, node: LocalNode, internalInitSessions?: {
64
- [key: SessionID]: SessionLog;
65
- });
66
- get sessions(): Readonly<{
67
- [key: SessionID]: SessionLog;
68
- }>;
69
- testWithDifferentAccount(account: GeneralizedControlledAccount, currentSessionID: SessionID): CoValueCore;
70
- knownState(): CoValueKnownState;
71
- get meta(): JsonValue;
72
- nextTransactionID(): TransactionID;
73
- tryAddTransactions(sessionID: SessionID, newTransactions: Transaction[], givenExpectedNewHash: Hash | undefined, newSignature: Signature): boolean;
74
- tryAddTransactionsAsync(sessionID: SessionID, newTransactions: Transaction[], givenExpectedNewHash: Hash | undefined, newSignature: Signature): Promise<boolean>;
75
- private doAddTransactions;
76
- subscribe(listener: (content?: CoValue) => void): () => void;
77
- expectedNewHashAfter(sessionID: SessionID, newTransactions: Transaction[]): {
78
- expectedNewHash: Hash;
79
- newStreamingHash: StreamingHash;
80
- };
81
- expectedNewHashAfterAsync(sessionID: SessionID, newTransactions: Transaction[]): Promise<{
82
- expectedNewHash: Hash;
83
- newStreamingHash: StreamingHash;
84
- }>;
85
- makeTransaction(changes: JsonValue[], privacy: "private" | "trusting"): boolean;
86
- getCurrentContent(options?: {
87
- ignorePrivateTransactions: true;
88
- }): CoValue;
89
- getValidSortedTransactions(options?: {
90
- ignorePrivateTransactions: true;
91
- }): DecryptedTransaction[];
92
- getCurrentReadKey(): {
93
- secret: KeySecret | undefined;
94
- id: KeyID;
95
- };
96
- getReadKey(keyID: KeyID): KeySecret | undefined;
97
- getUncachedReadKey(keyID: KeyID): KeySecret | undefined;
98
- getGroup(): Group;
99
- getTx(txID: TransactionID): Transaction | undefined;
100
- newContentSince(knownState: CoValueKnownState | undefined): NewContentMessage[] | undefined;
101
- getDependedOnCoValues(): RawCoID[];
102
- }
103
- export {};
@@ -1,62 +0,0 @@
1
- import { CoValueCore, CoValueHeader } from "../coValueCore.js";
2
- import { CoID, CoValue } from "../coValue.js";
3
- import { AgentSecret, SealerID, SealerSecret, SignerID, SignerSecret } from "../crypto.js";
4
- import { AgentID } from "../ids.js";
5
- import { CoMap } from "./coMap.js";
6
- import { Group, InviteSecret } from "./group.js";
7
- export declare function accountHeaderForInitialAgentSecret(agentSecret: AgentSecret): CoValueHeader;
8
- export declare class Account<P extends Profile = Profile, R extends CoMap = CoMap, Meta extends AccountMeta = AccountMeta> extends Group<P, R, Meta> {
9
- getCurrentAgentID(): AgentID;
10
- }
11
- export interface GeneralizedControlledAccount {
12
- id: AccountID | AgentID;
13
- agentSecret: AgentSecret;
14
- currentAgentID: () => AgentID;
15
- currentSignerID: () => SignerID;
16
- currentSignerSecret: () => SignerSecret;
17
- currentSealerID: () => SealerID;
18
- currentSealerSecret: () => SealerSecret;
19
- }
20
- /** @hidden */
21
- export declare class ControlledAccount<P extends Profile = Profile, R extends CoMap = CoMap, Meta extends AccountMeta = AccountMeta> extends Account<P, R, Meta> implements GeneralizedControlledAccount {
22
- agentSecret: AgentSecret;
23
- constructor(core: CoValueCore, agentSecret: AgentSecret);
24
- /**
25
- * Creates a new group (with the current account as the group's first admin).
26
- * @category 1. High-level
27
- */
28
- createGroup(): Group<Profile<ProfileShape, ProfileMeta>, CoMap<{
29
- [key: string]: import("../jsonValue.js").JsonValue | undefined;
30
- }, import("../jsonValue.js").JsonObject | null>, import("../jsonValue.js").JsonObject | null>;
31
- acceptInvite<T extends CoValue>(groupOrOwnedValueID: CoID<T>, inviteSecret: InviteSecret): Promise<void>;
32
- currentAgentID(): AgentID;
33
- currentSignerID(): SignerID;
34
- currentSignerSecret(): SignerSecret;
35
- currentSealerID(): SealerID;
36
- currentSealerSecret(): SealerSecret;
37
- }
38
- /** @hidden */
39
- export declare class AnonymousControlledAccount implements GeneralizedControlledAccount {
40
- agentSecret: AgentSecret;
41
- constructor(agentSecret: AgentSecret);
42
- get id(): AgentID;
43
- currentAgentID(): AgentID;
44
- currentSignerID(): SignerID;
45
- currentSignerSecret(): SignerSecret;
46
- currentSealerID(): SealerID;
47
- currentSealerSecret(): SealerSecret;
48
- }
49
- export type AccountMeta = {
50
- type: "account";
51
- };
52
- export type AccountID = CoID<Account>;
53
- export declare function isAccountID(id: AccountID | AgentID): id is AccountID;
54
- export type ProfileShape = {
55
- name: string;
56
- };
57
- export type ProfileMeta = {
58
- type: "profile";
59
- };
60
- export declare class Profile<Shape extends ProfileShape = ProfileShape, Meta extends ProfileMeta = ProfileMeta> extends CoMap<Shape, Meta> {
61
- }
62
- export type AccountMigration<P extends Profile = Profile, R extends CoMap = CoMap, Meta extends AccountMeta = AccountMeta> = (account: ControlledAccount<P, R, Meta>, profile: P) => void;
@@ -1,179 +0,0 @@
1
- import { JsonObject, JsonValue } from "../jsonValue.js";
2
- import { CoID, CoValue } from "../coValue.js";
3
- import { CoValueCore } from "../coValueCore.js";
4
- import { AgentID, SessionID, TransactionID } from "../ids.js";
5
- import { AccountID } from "./account.js";
6
- import { Group } from "./group.js";
7
- type OpID = TransactionID & {
8
- changeIdx: number;
9
- };
10
- type InsertionOpPayload<T extends JsonValue> = {
11
- op: "pre";
12
- value: T;
13
- before: OpID | "end";
14
- } | {
15
- op: "app";
16
- value: T;
17
- after: OpID | "start";
18
- };
19
- type DeletionOpPayload = {
20
- op: "del";
21
- insertion: OpID;
22
- };
23
- export type ListOpPayload<T extends JsonValue> = InsertionOpPayload<T> | DeletionOpPayload;
24
- type InsertionEntry<T extends JsonValue> = {
25
- madeAt: number;
26
- predecessors: OpID[];
27
- successors: OpID[];
28
- } & InsertionOpPayload<T>;
29
- type DeletionEntry = {
30
- madeAt: number;
31
- deletionID: OpID;
32
- } & DeletionOpPayload;
33
- export declare class CoListView<Item extends JsonValue = JsonValue, Meta extends JsonObject | null = null> implements CoValue {
34
- /** @category 6. Meta */
35
- id: CoID<this>;
36
- /** @category 6. Meta */
37
- type: "colist";
38
- /** @category 6. Meta */
39
- core: CoValueCore;
40
- /** @internal */
41
- afterStart: OpID[];
42
- /** @internal */
43
- beforeEnd: OpID[];
44
- /** @internal */
45
- insertions: {
46
- [sessionID: SessionID]: {
47
- [txIdx: number]: {
48
- [changeIdx: number]: InsertionEntry<Item>;
49
- };
50
- };
51
- };
52
- /** @internal */
53
- deletionsByInsertion: {
54
- [deletedSessionID: SessionID]: {
55
- [deletedTxIdx: number]: {
56
- [deletedChangeIdx: number]: DeletionEntry[];
57
- };
58
- };
59
- };
60
- /** @category 6. Meta */
61
- readonly _item: Item;
62
- /** @internal */
63
- constructor(core: CoValueCore);
64
- /** @category 6. Meta */
65
- get meta(): Meta;
66
- /** @category 6. Meta */
67
- get group(): Group;
68
- /**
69
- * Not yet implemented
70
- *
71
- * @category 4. Time travel
72
- */
73
- atTime(_time: number): this;
74
- /**
75
- * Get the item currently at `idx`.
76
- *
77
- * @category 1. Reading
78
- */
79
- get(idx: number): Item | undefined;
80
- /**
81
- * Returns the current items in the CoList as an array.
82
- *
83
- * @category 1. Reading
84
- **/
85
- asArray(): Item[];
86
- /** @internal */
87
- entries(): {
88
- value: Item;
89
- madeAt: number;
90
- opID: OpID;
91
- }[];
92
- /** @internal */
93
- private fillArrayFromOpID;
94
- /**
95
- * Returns the current items in the CoList as an array. (alias of `asArray`)
96
- *
97
- * @category 1. Reading
98
- */
99
- toJSON(): Item[];
100
- /** @category 5. Edit history */
101
- editAt(idx: number): {
102
- by: AccountID | AgentID;
103
- tx: TransactionID;
104
- at: Date;
105
- value: Item;
106
- } | undefined;
107
- /** @category 5. Edit history */
108
- deletionEdits(): {
109
- by: AccountID | AgentID;
110
- tx: TransactionID;
111
- at: Date;
112
- }[];
113
- /** @category 3. Subscription */
114
- subscribe(listener: (coList: this) => void): () => void;
115
- }
116
- export declare class CoList<Item extends JsonValue = JsonValue, Meta extends JsonObject | null = JsonObject | null> extends CoListView<Item, Meta> implements CoValue {
117
- /** Returns a new version of this CoList with `item` appended after the item currently at index `after`.
118
- *
119
- * If `privacy` is `"private"` **(default)**, `item` is encrypted in the transaction, only readable by other members of the group this `CoList` belongs to. Not even sync servers can see the content in plaintext.
120
- *
121
- * If `privacy` is `"trusting"`, `item` is stored in plaintext in the transaction, visible to everyone who gets a hold of it, including sync servers.
122
- *
123
- * @category 2. Editing
124
- **/
125
- append(item: Item, after?: number, privacy?: "private" | "trusting"): this;
126
- /**
127
- * Returns a new version of this CoList with `item` prepended before the item currently at index `before`.
128
- *
129
- * If `privacy` is `"private"` **(default)**, `item` is encrypted in the transaction, only readable by other members of the group this `CoList` belongs to. Not even sync servers can see the content in plaintext.
130
- *
131
- * If `privacy` is `"trusting"`, `item` is stored in plaintext in the transaction, visible to everyone who gets a hold of it, including sync servers.
132
- *
133
- * @category 2. Editing
134
- */
135
- prepend(item: Item, before?: number, privacy?: "private" | "trusting"): this;
136
- /** Returns a new version of this CoList with the item at index `at` deleted from the list.
137
- *
138
- * If `privacy` is `"private"` **(default)**, the fact of this deletion is encrypted in the transaction, only readable by other members of the group this `CoList` belongs to. Not even sync servers can see the content in plaintext.
139
- *
140
- * If `privacy` is `"trusting"`, the fact of this deletion is stored in plaintext in the transaction, visible to everyone who gets a hold of it, including sync servers.
141
- *
142
- * @category 2. Editing
143
- **/
144
- delete(at: number, privacy?: "private" | "trusting"): this;
145
- /** @category 2. Editing */
146
- mutate(mutator: (mutable: MutableCoList<Item, Meta>) => void): this;
147
- /** @deprecated Use `mutate` instead. */
148
- edit(mutator: (mutable: MutableCoList<Item, Meta>) => void): this;
149
- }
150
- export declare class MutableCoList<Item extends JsonValue = JsonValue, Meta extends JsonObject | null = JsonObject | null> extends CoListView<Item, Meta> implements CoValue {
151
- /** Appends `item` after the item currently at index `after`.
152
- *
153
- * If `privacy` is `"private"` **(default)**, `item` is encrypted in the transaction, only readable by other members of the group this `CoList` belongs to. Not even sync servers can see the content in plaintext.
154
- *
155
- * If `privacy` is `"trusting"`, `item` is stored in plaintext in the transaction, visible to everyone who gets a hold of it, including sync servers.
156
- *
157
- * @category 2. Mutating
158
- **/
159
- append(item: Item, after?: number, privacy?: "private" | "trusting"): void;
160
- /** Prepends `item` before the item currently at index `before`.
161
- *
162
- * If `privacy` is `"private"` **(default)**, `item` is encrypted in the transaction, only readable by other members of the group this `CoList` belongs to. Not even sync servers can see the content in plaintext.
163
- *
164
- * If `privacy` is `"trusting"`, `item` is stored in plaintext in the transaction, visible to everyone who gets a hold of it, including sync servers.
165
- *
166
- * * @category 2. Mutating
167
- **/
168
- prepend(item: Item, before?: number, privacy?: "private" | "trusting"): void;
169
- /** Deletes the item at index `at` from the list.
170
- *
171
- * If `privacy` is `"private"` **(default)**, the fact of this deletion is encrypted in the transaction, only readable by other members of the group this `CoList` belongs to. Not even sync servers can see the content in plaintext.
172
- *
173
- * If `privacy` is `"trusting"`, the fact of this deletion is stored in plaintext in the transaction, visible to everyone who gets a hold of it, including sync servers.
174
- *
175
- * * @category 2. Mutating
176
- **/
177
- delete(at: number, privacy?: "private" | "trusting"): void;
178
- }
179
- export {};