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.
- package/dist/coValue.js +1 -1
- package/dist/coValue.js.map +1 -1
- package/dist/coValues/coList.js +1 -1
- package/dist/coValues/coList.js.map +1 -1
- package/dist/coValues/coMap.js +1 -1
- package/dist/coValues/coMap.js.map +1 -1
- package/dist/coValues/coStream.js +1 -1
- package/dist/coValues/coStream.js.map +1 -1
- package/dist/coValues/group.js.map +1 -1
- package/dist/index.js +2 -4
- package/dist/index.js.map +1 -1
- package/dist/localNode.js +1 -14
- package/dist/localNode.js.map +1 -1
- package/package.json +4 -4
- package/src/coValue.ts +10 -7
- package/src/coValues/coList.ts +1 -1
- package/src/coValues/coMap.ts +1 -1
- package/src/coValues/coStream.ts +1 -3
- package/src/coValues/group.ts +4 -4
- package/src/index.ts +16 -16
- package/src/localNode.ts +6 -47
- package/src/tests/coValue.test.ts +5 -5
- package/src/tests/group.test.ts +1 -1
- package/dist/base64url.d.ts +0 -2
- package/dist/coValue.d.ts +0 -38
- package/dist/coValueCore.d.ts +0 -103
- package/dist/coValues/account.d.ts +0 -62
- package/dist/coValues/coList.d.ts +0 -179
- package/dist/coValues/coMap.d.ts +0 -149
- package/dist/coValues/coStream.d.ts +0 -123
- package/dist/coValues/group.d.ts +0 -111
- package/dist/crypto.d.ts +0 -120
- package/dist/ids.d.ts +0 -11
- package/dist/index.d.ts +0 -67
- package/dist/jsonStringify.d.ts +0 -6
- package/dist/jsonValue.d.ts +0 -7
- package/dist/localNode.d.ts +0 -101
- package/dist/media.d.ts +0 -7
- package/dist/permissions.d.ts +0 -20
- package/dist/queriedCoValues/queriedAccount.d.ts +0 -13
- package/dist/queriedCoValues/queriedAccount.js +0 -24
- package/dist/queriedCoValues/queriedAccount.js.map +0 -1
- package/dist/queriedCoValues/queriedCoList.d.ts +0 -66
- package/dist/queriedCoValues/queriedCoList.js +0 -116
- package/dist/queriedCoValues/queriedCoList.js.map +0 -1
- package/dist/queriedCoValues/queriedCoMap.d.ts +0 -40
- package/dist/queriedCoValues/queriedCoMap.js +0 -82
- package/dist/queriedCoValues/queriedCoMap.js.map +0 -1
- package/dist/queriedCoValues/queriedCoStream.d.ts +0 -36
- package/dist/queriedCoValues/queriedCoStream.js +0 -97
- package/dist/queriedCoValues/queriedCoStream.js.map +0 -1
- package/dist/queriedCoValues/queriedGroup.d.ts +0 -29
- package/dist/queriedCoValues/queriedGroup.js +0 -54
- package/dist/queriedCoValues/queriedGroup.js.map +0 -1
- package/dist/queries.d.ts +0 -62
- package/dist/queries.js +0 -142
- package/dist/queries.js.map +0 -1
- package/dist/streamUtils.d.ts +0 -8
- package/dist/sync.d.ts +0 -80
- package/dist/tests/testUtils.d.ts +0 -37
- package/src/queriedCoValues/queriedAccount.ts +0 -40
- package/src/queriedCoValues/queriedCoList.ts +0 -240
- package/src/queriedCoValues/queriedCoMap.ts +0 -168
- package/src/queriedCoValues/queriedCoStream.ts +0 -151
- package/src/queriedCoValues/queriedGroup.ts +0 -90
- package/src/queries.ts +0 -263
- package/src/tests/queries.test.ts +0 -398
package/dist/localNode.d.ts
DELETED
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
import { AgentSecret } from "./crypto.js";
|
|
2
|
-
import { CoValueCore, CoValueHeader } from "./coValueCore.js";
|
|
3
|
-
import { InviteSecret, Group } from "./coValues/group.js";
|
|
4
|
-
import { Peer, SyncManager } from "./sync.js";
|
|
5
|
-
import { AgentID, RawCoID, SessionID } from "./ids.js";
|
|
6
|
-
import { CoID } from "./coValue.js";
|
|
7
|
-
import { Queried } from "./queries.js";
|
|
8
|
-
import { Account, AccountMeta, GeneralizedControlledAccount, ControlledAccount, AccountID, Profile, AccountMigration } from "./coValues/account.js";
|
|
9
|
-
import { CoMap } from "./coValues/coMap.js";
|
|
10
|
-
import { CoValue } from "./index.js";
|
|
11
|
-
import { QueriedAccount } from "./queriedCoValues/queriedAccount.js";
|
|
12
|
-
/** A `LocalNode` represents a local view of a set of loaded `CoValue`s, from the perspective of a particular account (or primitive cryptographic agent).
|
|
13
|
-
|
|
14
|
-
A `LocalNode` can have peers that it syncs to, for example some form of local persistence, or a sync server, such as `sync.jazz.tools` (Jazz Global Mesh).
|
|
15
|
-
|
|
16
|
-
@example
|
|
17
|
-
You typically get hold of a `LocalNode` using `jazz-react`'s `useJazz()`:
|
|
18
|
-
|
|
19
|
-
```typescript
|
|
20
|
-
const { localNode } = useJazz();
|
|
21
|
-
```
|
|
22
|
-
*/
|
|
23
|
-
export declare class LocalNode {
|
|
24
|
-
/** @internal */
|
|
25
|
-
coValues: {
|
|
26
|
-
[key: RawCoID]: CoValueState;
|
|
27
|
-
};
|
|
28
|
-
/** @category 3. Low-level */
|
|
29
|
-
account: GeneralizedControlledAccount;
|
|
30
|
-
/** @category 3. Low-level */
|
|
31
|
-
currentSessionID: SessionID;
|
|
32
|
-
/** @category 3. Low-level */
|
|
33
|
-
syncManager: SyncManager;
|
|
34
|
-
/** @category 3. Low-level */
|
|
35
|
-
constructor(account: GeneralizedControlledAccount, currentSessionID: SessionID);
|
|
36
|
-
/** @category 2. Node Creation */
|
|
37
|
-
static withNewlyCreatedAccount<P extends Profile = Profile, R extends CoMap = CoMap, Meta extends AccountMeta = AccountMeta>({ name, migration, initialAgentSecret, }: {
|
|
38
|
-
name: string;
|
|
39
|
-
migration?: AccountMigration<P, R, Meta>;
|
|
40
|
-
initialAgentSecret?: AgentSecret;
|
|
41
|
-
}): {
|
|
42
|
-
node: LocalNode;
|
|
43
|
-
accountID: AccountID;
|
|
44
|
-
accountSecret: AgentSecret;
|
|
45
|
-
sessionID: SessionID;
|
|
46
|
-
};
|
|
47
|
-
/** @category 2. Node Creation */
|
|
48
|
-
static withLoadedAccount<P extends Profile = Profile, R extends CoMap = CoMap, Meta extends AccountMeta = AccountMeta>({ accountID, accountSecret, sessionID, peersToLoadFrom, migration, }: {
|
|
49
|
-
accountID: AccountID;
|
|
50
|
-
accountSecret: AgentSecret;
|
|
51
|
-
sessionID: SessionID;
|
|
52
|
-
peersToLoadFrom: Peer[];
|
|
53
|
-
migration?: AccountMigration<P, R, Meta>;
|
|
54
|
-
}): Promise<LocalNode>;
|
|
55
|
-
/** @internal */
|
|
56
|
-
createCoValue(header: CoValueHeader): CoValueCore;
|
|
57
|
-
/** @internal */
|
|
58
|
-
loadCoValue(id: RawCoID): Promise<CoValueCore>;
|
|
59
|
-
/**
|
|
60
|
-
* Loads a CoValue's content, syncing from peers as necessary and resolving the returned
|
|
61
|
-
* promise once a first version has been loaded. See `coValue.subscribe()` and `node.useTelepathicData()`
|
|
62
|
-
* for listening to subsequent updates to the CoValue.
|
|
63
|
-
*
|
|
64
|
-
* @category 3. Low-level
|
|
65
|
-
*/
|
|
66
|
-
load<T extends CoValue>(id: CoID<T>): Promise<T>;
|
|
67
|
-
/** @category 3. Low-level */
|
|
68
|
-
subscribe<T extends CoValue>(id: CoID<T>, callback: (update: T) => void): () => void;
|
|
69
|
-
/** @category 1. High-level */
|
|
70
|
-
query<T extends CoValue>(id: CoID<T>, callback: (update: Queried<T> | undefined) => void): () => void;
|
|
71
|
-
query<P extends Profile = Profile, R extends CoMap = CoMap, Meta extends AccountMeta = AccountMeta>(id: "me", callback: (update: QueriedAccount<Account<P, R, Meta>> | undefined) => void): () => void;
|
|
72
|
-
query(id: CoID<CoValue> | "me", callback: (update: Queried<CoValue> | QueriedAccount | undefined) => void): () => void;
|
|
73
|
-
/** @deprecated Use Account.acceptInvite instead */
|
|
74
|
-
acceptInvite<T extends CoValue>(groupOrOwnedValueID: CoID<T>, inviteSecret: InviteSecret): Promise<void>;
|
|
75
|
-
/** @internal */
|
|
76
|
-
expectCoValueLoaded(id: RawCoID, expectation?: string): CoValueCore;
|
|
77
|
-
/** @internal */
|
|
78
|
-
expectProfileLoaded(id: AccountID, expectation?: string): Profile;
|
|
79
|
-
/** @internal */
|
|
80
|
-
createAccount(name: string, agentSecret?: `sealerSecret_z${string}/signerSecret_z${string}`): ControlledAccount;
|
|
81
|
-
/** @internal */
|
|
82
|
-
resolveAccountAgent(id: AccountID | AgentID, expectation?: string): AgentID;
|
|
83
|
-
/**
|
|
84
|
-
* @deprecated use Account.createGroup() instead
|
|
85
|
-
*/
|
|
86
|
-
createGroup(): Group;
|
|
87
|
-
/** @internal */
|
|
88
|
-
testWithDifferentAccount(account: GeneralizedControlledAccount, currentSessionID: SessionID): LocalNode;
|
|
89
|
-
}
|
|
90
|
-
/** @internal */
|
|
91
|
-
type CoValueState = {
|
|
92
|
-
state: "loading";
|
|
93
|
-
done: Promise<CoValueCore>;
|
|
94
|
-
resolve: (coValue: CoValueCore) => void;
|
|
95
|
-
} | {
|
|
96
|
-
state: "loaded";
|
|
97
|
-
coValue: CoValueCore;
|
|
98
|
-
};
|
|
99
|
-
/** @internal */
|
|
100
|
-
export declare function newLoadingState(): CoValueState;
|
|
101
|
-
export {};
|
package/dist/media.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { CoMap } from './coValues/coMap.js';
|
|
2
|
-
import { BinaryCoStream } from './coValues/coStream.js';
|
|
3
|
-
export type ImageDefinition = CoMap<{
|
|
4
|
-
originalSize: [number, number];
|
|
5
|
-
placeholderDataURL?: string;
|
|
6
|
-
[res: `${number}x${number}`]: BinaryCoStream["id"];
|
|
7
|
-
}>;
|
package/dist/permissions.d.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { KeyID } from "./crypto.js";
|
|
2
|
-
import { CoValueCore, Transaction } from "./coValueCore.js";
|
|
3
|
-
import { AgentID, RawCoID, TransactionID } from "./ids.js";
|
|
4
|
-
import { AccountID } from "./coValues/account.js";
|
|
5
|
-
export type PermissionsDef = {
|
|
6
|
-
type: "group";
|
|
7
|
-
initialAdmin: AccountID | AgentID;
|
|
8
|
-
} | {
|
|
9
|
-
type: "ownedByGroup";
|
|
10
|
-
group: RawCoID;
|
|
11
|
-
} | {
|
|
12
|
-
type: "unsafeAllowAll";
|
|
13
|
-
};
|
|
14
|
-
export type Role = "reader" | "writer" | "admin" | "revoked" | "adminInvite" | "writerInvite" | "readerInvite";
|
|
15
|
-
export declare function determineValidTransactions(coValue: CoValueCore): {
|
|
16
|
-
txID: TransactionID;
|
|
17
|
-
tx: Transaction;
|
|
18
|
-
}[];
|
|
19
|
-
export declare function isKeyForKeyField(field: string): field is `${KeyID}_for_${KeyID}`;
|
|
20
|
-
export declare function isKeyForAccountField(field: string): field is `${KeyID}_for_${AccountID | AgentID}`;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { Account } from "../coValues/account.js";
|
|
2
|
-
import { CoID, CoValue, InviteSecret } from "../index.js";
|
|
3
|
-
import { QueryContext } from "../queries.js";
|
|
4
|
-
import { QueriedGroup } from "./queriedGroup.js";
|
|
5
|
-
export declare class QueriedAccount<A extends Account = Account> extends QueriedGroup<A> {
|
|
6
|
-
id: CoID<A>;
|
|
7
|
-
isMe: boolean;
|
|
8
|
-
constructor(account: A, queryContext: QueryContext);
|
|
9
|
-
createGroup(): import("../index.js").Group<import("../index.js").Profile<import("../coValues/account.js").ProfileShape, import("../index.js").ProfileMeta>, import("../index.js").CoMap<{
|
|
10
|
-
[key: string]: import("../jsonValue.js").JsonValue | undefined;
|
|
11
|
-
}, import("../jsonValue.js").JsonObject | null>, import("../jsonValue.js").JsonObject | null>;
|
|
12
|
-
acceptInvite<T extends CoValue>(groupOrOwnedValueID: CoID<T>, inviteSecret: InviteSecret): Promise<void>;
|
|
13
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { QueriedGroup } from "./queriedGroup.js";
|
|
2
|
-
export class QueriedAccount extends QueriedGroup {
|
|
3
|
-
constructor(account, queryContext) {
|
|
4
|
-
super(account, queryContext);
|
|
5
|
-
Object.defineProperties(this, {
|
|
6
|
-
id: { value: account.id, enumerable: false },
|
|
7
|
-
isMe: {
|
|
8
|
-
value: account.core.node.account.id === account.id,
|
|
9
|
-
enumerable: false,
|
|
10
|
-
},
|
|
11
|
-
});
|
|
12
|
-
}
|
|
13
|
-
createGroup() {
|
|
14
|
-
if (!this.isMe)
|
|
15
|
-
throw new Error("Only the current user can create a group");
|
|
16
|
-
return this.group.core.node.account.createGroup();
|
|
17
|
-
}
|
|
18
|
-
acceptInvite(groupOrOwnedValueID, inviteSecret) {
|
|
19
|
-
if (!this.isMe)
|
|
20
|
-
throw new Error("Only the current user can accept an invite");
|
|
21
|
-
return this.group.core.node.account.acceptInvite(groupOrOwnedValueID, inviteSecret);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
//# sourceMappingURL=queriedAccount.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"queriedAccount.js","sourceRoot":"","sources":["../../src/queriedCoValues/queriedAccount.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD,MAAM,OAAO,cAA4C,SAAQ,YAAe;IAI5E,YAAY,OAAU,EAAE,YAA0B;QAC9C,KAAK,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;QAC7B,MAAM,CAAC,gBAAgB,CAAC,IAAI,EAAE;YAC1B,EAAE,EAAE,EAAE,KAAK,EAAE,OAAO,CAAC,EAAE,EAAE,UAAU,EAAE,KAAK,EAAE;YAC5C,IAAI,EAAE;gBACF,KAAK,EAAE,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,KAAK,OAAO,CAAC,EAAE;gBAClD,UAAU,EAAE,KAAK;aACpB;SACJ,CAAC,CAAC;IACP,CAAC;IAED,WAAW;QACP,IAAI,CAAC,IAAI,CAAC,IAAI;YACV,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAC;QAChE,OACI,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,OACxB,CAAC,WAAW,EAAE,CAAC;IACpB,CAAC;IAED,YAAY,CACR,mBAA4B,EAC5B,YAA0B;QAE1B,IAAI,CAAC,IAAI,CAAC,IAAI;YACV,MAAM,IAAI,KAAK,CAAC,4CAA4C,CAAC,CAAC;QAClE,OAAQ,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,OAA6B,CAAC,YAAY,CACnE,mBAAmB,EACnB,YAAY,CACf,CAAC;IACN,CAAC;CACJ"}
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { CoList, MutableCoList } from "../coValues/coList.js";
|
|
2
|
-
import { CoValueCore } from "../coValueCore.js";
|
|
3
|
-
import { Group } from "../coValues/group.js";
|
|
4
|
-
import { CoID, CoValue } from "../coValue.js";
|
|
5
|
-
import { TransactionID } from "../ids.js";
|
|
6
|
-
import { ValueOrSubQueried, QueryContext } from "../queries.js";
|
|
7
|
-
import { QueriedAccount } from "./queriedAccount.js";
|
|
8
|
-
export declare class QueriedCoList<L extends CoList> extends Array<ValueOrSubQueried<L["_item"]>> {
|
|
9
|
-
coList: L;
|
|
10
|
-
id: CoID<L>;
|
|
11
|
-
type: "colist";
|
|
12
|
-
/** @internal */
|
|
13
|
-
constructor(coList: L, queryContext: QueryContext);
|
|
14
|
-
get meta(): L["meta"];
|
|
15
|
-
get group(): Group;
|
|
16
|
-
get core(): CoValueCore;
|
|
17
|
-
append(item: L["_item"], after?: number, privacy?: "private" | "trusting"): L;
|
|
18
|
-
prepend(item: L["_item"], before?: number, privacy?: "private" | "trusting"): L;
|
|
19
|
-
delete(at: number, privacy?: "private" | "trusting"): L;
|
|
20
|
-
mutate(mutator: (mutable: MutableCoList<L["_item"], L["meta"]>) => void): L;
|
|
21
|
-
edits: {
|
|
22
|
-
by?: QueriedAccount;
|
|
23
|
-
tx: TransactionID;
|
|
24
|
-
at: Date;
|
|
25
|
-
value: L["_item"] extends CoValue ? CoID<L["_item"]> : Exclude<L["_item"], CoValue>;
|
|
26
|
-
}[];
|
|
27
|
-
deletions: {
|
|
28
|
-
by?: QueriedAccount;
|
|
29
|
-
tx: TransactionID;
|
|
30
|
-
at: Date;
|
|
31
|
-
}[];
|
|
32
|
-
/** @internal */
|
|
33
|
-
static isArray(arg: any): arg is any[];
|
|
34
|
-
/** @internal */
|
|
35
|
-
static from<T>(arrayLike: ArrayLike<T>): T[];
|
|
36
|
-
/** @internal */
|
|
37
|
-
static from<T, U>(arrayLike: ArrayLike<T>, mapfn: (v: T, k: number) => U, thisArg?: any): U[];
|
|
38
|
-
/** @internal */
|
|
39
|
-
static from<T>(iterable: Iterable<T> | ArrayLike<T>): T[];
|
|
40
|
-
/** @internal */
|
|
41
|
-
static from<T, U>(iterable: Iterable<T> | ArrayLike<T>, mapfn: (v: T, k: number) => U, thisArg?: any): U[];
|
|
42
|
-
/** @internal */
|
|
43
|
-
static of<T>(..._items: T[]): T[];
|
|
44
|
-
/** @internal */
|
|
45
|
-
pop(): ValueOrSubQueried<L["_item"]> | undefined;
|
|
46
|
-
/** @internal */
|
|
47
|
-
push(..._items: ValueOrSubQueried<L["_item"]>[]): number;
|
|
48
|
-
/** @internal */
|
|
49
|
-
concat(..._items: ConcatArray<ValueOrSubQueried<L["_item"]>>[]): ValueOrSubQueried<L["_item"]>[];
|
|
50
|
-
/** @internal */
|
|
51
|
-
concat(..._items: (ValueOrSubQueried<L["_item"]> | ConcatArray<ValueOrSubQueried<L["_item"]>>)[]): ValueOrSubQueried<L["_item"]>[];
|
|
52
|
-
/** @internal */
|
|
53
|
-
reverse(): ValueOrSubQueried<L["_item"]>[];
|
|
54
|
-
/** @internal */
|
|
55
|
-
shift(): ValueOrSubQueried<L["_item"]> | undefined;
|
|
56
|
-
/** @internal */
|
|
57
|
-
sort(_compareFn?: ((a: ValueOrSubQueried<L["_item"]>, b: ValueOrSubQueried<L["_item"]>) => number) | undefined): this;
|
|
58
|
-
/** @internal */
|
|
59
|
-
splice(_start: number, _deleteCount?: number | undefined): ValueOrSubQueried<L["_item"]>[];
|
|
60
|
-
/** @internal */
|
|
61
|
-
unshift(..._items: ValueOrSubQueried<L["_item"]>[]): number;
|
|
62
|
-
/** @internal */
|
|
63
|
-
fill(_value: ValueOrSubQueried<L["_item"]>, _start?: number | undefined, _end?: number | undefined): this;
|
|
64
|
-
/** @internal */
|
|
65
|
-
copyWithin(_target: number, _start: number, _end?: number | undefined): this;
|
|
66
|
-
}
|
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
import { CoList } from "../coValues/coList.js";
|
|
2
|
-
export class QueriedCoList extends Array {
|
|
3
|
-
/** @internal */
|
|
4
|
-
constructor(coList, queryContext) {
|
|
5
|
-
if (!(coList instanceof CoList)) {
|
|
6
|
-
// this might be called from an intrinsic, like map, trying to create an empty array
|
|
7
|
-
// passing `0` as the only parameter
|
|
8
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
9
|
-
return new Array(coList);
|
|
10
|
-
}
|
|
11
|
-
super(...coList
|
|
12
|
-
.asArray()
|
|
13
|
-
.map((item) => queryContext.queryIfCoID(item, [coList.id])));
|
|
14
|
-
Object.defineProperties(this, {
|
|
15
|
-
coList: { get() { return coList; } },
|
|
16
|
-
id: { value: coList.id },
|
|
17
|
-
type: { value: "colist" },
|
|
18
|
-
edits: {
|
|
19
|
-
value: [...this.keys()].map((i) => {
|
|
20
|
-
const edit = coList.editAt(i);
|
|
21
|
-
return queryContext.defineSubqueryPropertiesIn({
|
|
22
|
-
tx: edit.tx,
|
|
23
|
-
at: new Date(edit.at),
|
|
24
|
-
}, {
|
|
25
|
-
by: { value: edit.by, enumerable: true },
|
|
26
|
-
value: { value: edit.value, enumerable: true },
|
|
27
|
-
}, [coList.id]);
|
|
28
|
-
}),
|
|
29
|
-
},
|
|
30
|
-
deletions: {
|
|
31
|
-
value: coList.deletionEdits().map((deletion) => queryContext.defineSubqueryPropertiesIn({
|
|
32
|
-
tx: deletion.tx,
|
|
33
|
-
at: new Date(deletion.at),
|
|
34
|
-
}, {
|
|
35
|
-
by: { value: deletion.by, enumerable: true },
|
|
36
|
-
}, [coList.id])),
|
|
37
|
-
},
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
get meta() {
|
|
41
|
-
return this.coList.meta;
|
|
42
|
-
}
|
|
43
|
-
get group() {
|
|
44
|
-
return this.coList.group;
|
|
45
|
-
}
|
|
46
|
-
get core() {
|
|
47
|
-
return this.coList.core;
|
|
48
|
-
}
|
|
49
|
-
append(item, after, privacy) {
|
|
50
|
-
return this.coList.append(item, after, privacy);
|
|
51
|
-
}
|
|
52
|
-
prepend(item, before, privacy) {
|
|
53
|
-
return this.coList.prepend(item, before, privacy);
|
|
54
|
-
}
|
|
55
|
-
delete(at, privacy) {
|
|
56
|
-
return this.coList.delete(at, privacy);
|
|
57
|
-
}
|
|
58
|
-
mutate(mutator) {
|
|
59
|
-
return this.coList.mutate(mutator);
|
|
60
|
-
}
|
|
61
|
-
/** @internal */
|
|
62
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
63
|
-
static isArray(arg) {
|
|
64
|
-
return Array.isArray(arg);
|
|
65
|
-
}
|
|
66
|
-
/** @internal */
|
|
67
|
-
static from(_iterable, _mapfn, _thisArg) {
|
|
68
|
-
throw new Error("Array method 'from' not supported on QueriedCoList");
|
|
69
|
-
}
|
|
70
|
-
/** @internal */
|
|
71
|
-
static of(..._items) {
|
|
72
|
-
throw new Error("Array method 'of' not supported on QueriedCoList");
|
|
73
|
-
}
|
|
74
|
-
/** @internal */
|
|
75
|
-
pop() {
|
|
76
|
-
throw new Error("Array method 'pop' not supported on QueriedCoList");
|
|
77
|
-
}
|
|
78
|
-
/** @internal */
|
|
79
|
-
push(..._items) {
|
|
80
|
-
throw new Error("Array method 'push' not supported on QueriedCoList");
|
|
81
|
-
}
|
|
82
|
-
/** @internal */
|
|
83
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
84
|
-
concat(..._items) {
|
|
85
|
-
throw new Error("Array method 'concat' not supported on QueriedCoList");
|
|
86
|
-
}
|
|
87
|
-
/** @internal */
|
|
88
|
-
reverse() {
|
|
89
|
-
throw new Error("Array method 'reverse' not supported on QueriedCoList");
|
|
90
|
-
}
|
|
91
|
-
/** @internal */
|
|
92
|
-
shift() {
|
|
93
|
-
throw new Error("Array method 'shift' not supported on QueriedCoList");
|
|
94
|
-
}
|
|
95
|
-
/** @internal */
|
|
96
|
-
sort(_compareFn) {
|
|
97
|
-
throw new Error("Array method 'sort' not supported on QueriedCoList");
|
|
98
|
-
}
|
|
99
|
-
/** @internal */
|
|
100
|
-
splice(_start, _deleteCount) {
|
|
101
|
-
throw new Error("Array method 'splice' not supported on QueriedCoList");
|
|
102
|
-
}
|
|
103
|
-
/** @internal */
|
|
104
|
-
unshift(..._items) {
|
|
105
|
-
throw new Error("Array method 'unshift' not supported on QueriedCoList");
|
|
106
|
-
}
|
|
107
|
-
/** @internal */
|
|
108
|
-
fill(_value, _start, _end) {
|
|
109
|
-
throw new Error("Array method 'fill' not supported on QueriedCoList");
|
|
110
|
-
}
|
|
111
|
-
/** @internal */
|
|
112
|
-
copyWithin(_target, _start, _end) {
|
|
113
|
-
throw new Error("Array method 'copyWithin' not supported on QueriedCoList");
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
//# sourceMappingURL=queriedCoList.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"queriedCoList.js","sourceRoot":"","sources":["../../src/queriedCoValues/queriedCoList.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAiB,MAAM,uBAAuB,CAAC;AAQ9D,MAAM,OAAO,aAAgC,SAAQ,KAEpD;IAKG,gBAAgB;IAChB,YAAY,MAAS,EAAE,YAA0B;QAC7C,IAAI,CAAC,CAAC,MAAM,YAAY,MAAM,CAAC,EAAE;YAC7B,oFAAoF;YACpF,oCAAoC;YACpC,8DAA8D;YAC9D,OAAO,IAAI,KAAK,CAAC,MAAM,CAAQ,CAAC;SACnC;QACD,KAAK,CACD,GAAG,MAAM;aACJ,OAAO,EAAE;aACT,GAAG,CACA,CAAC,IAAI,EAAE,EAAE,CACL,YAAY,CAAC,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C,CAAC;IACxE,CAAC;IAED,gBAAgB;IAChB,GAAG;QACC,MAAM,IAAI,KAAK,CAAC,mDAAmD,CAAC,CAAC;IACzE,CAAC;IAED,gBAAgB;IAChB,IAAI,CAAC,GAAG,MAAuC;QAC3C,MAAM,IAAI,KAAK,CAAC,oDAAoD,CAAC,CAAC;IAC1E,CAAC;IAaD,gBAAgB;IAChB,8DAA8D;IAC9D,MAAM,CAAC,GAAG,MAAa;QACnB,MAAM,IAAI,KAAK,CAAC,sDAAsD,CAAC,CAAC;IAC5E,CAAC;IAED,gBAAgB;IAChB,OAAO;QACH,MAAM,IAAI,KAAK,CACX,uDAAuD,CAC1D,CAAC;IACN,CAAC;IAED,gBAAgB;IAChB,KAAK;QACD,MAAM,IAAI,KAAK,CAAC,qDAAqD,CAAC,CAAC;IAC3E,CAAC;IAED,gBAAgB;IAChB,IAAI,CACA,UAKe;QAEf,MAAM,IAAI,KAAK,CAAC,oDAAoD,CAAC,CAAC;IAC1E,CAAC;IAED,gBAAgB;IAChB,MAAM,CACF,MAAc,EACd,YAAiC;QAEjC,MAAM,IAAI,KAAK,CAAC,sDAAsD,CAAC,CAAC;IAC5E,CAAC;IAED,gBAAgB;IAChB,OAAO,CAAC,GAAG,MAAuC;QAC9C,MAAM,IAAI,KAAK,CACX,uDAAuD,CAC1D,CAAC;IACN,CAAC;IAED,gBAAgB;IAChB,IAAI,CACA,MAAqC,EACrC,MAA2B,EAC3B,IAAyB;QAEzB,MAAM,IAAI,KAAK,CAAC,oDAAoD,CAAC,CAAC;IAC1E,CAAC;IAED,gBAAgB;IAChB,UAAU,CACN,OAAe,EACf,MAAc,EACd,IAAyB;QAEzB,MAAM,IAAI,KAAK,CACX,0DAA0D,CAC7D,CAAC;IACN,CAAC;CACJ"}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { CoMap, MutableCoMap } from "../coValues/coMap.js";
|
|
2
|
-
import { CoValueCore } from "../coValueCore.js";
|
|
3
|
-
import { Group } from "../coValues/group.js";
|
|
4
|
-
import { CoID } from "../coValue.js";
|
|
5
|
-
import { TransactionID } from "../ids.js";
|
|
6
|
-
import { ValueOrSubQueried, QueryContext, QueryExtension } from "../queries.js";
|
|
7
|
-
import { QueriedAccount } from "./queriedAccount.js";
|
|
8
|
-
export type QueriedCoMap<M extends CoMap> = {
|
|
9
|
-
[K in keyof M["_shape"] & string]: ValueOrSubQueried<M["_shape"][K]>;
|
|
10
|
-
} & QueriedCoMapBase<M>;
|
|
11
|
-
export type QueriedCoMapEdit<M extends CoMap, K extends keyof M["_shape"]> = {
|
|
12
|
-
by?: QueriedAccount;
|
|
13
|
-
tx: TransactionID;
|
|
14
|
-
at: Date;
|
|
15
|
-
value: M["_shape"][K];
|
|
16
|
-
};
|
|
17
|
-
export declare class QueriedCoMapBase<M extends CoMap> {
|
|
18
|
-
coMap: M;
|
|
19
|
-
id: CoID<M>;
|
|
20
|
-
type: "comap";
|
|
21
|
-
/** @internal */
|
|
22
|
-
static newWithKVPairs<M extends CoMap>(coMap: M, queryContext: QueryContext): QueriedCoMap<M>;
|
|
23
|
-
/** @internal */
|
|
24
|
-
constructor(coMap: M, queryContext: QueryContext);
|
|
25
|
-
edits: {
|
|
26
|
-
[K in keyof M["_shape"] & string]: (QueriedCoMapEdit<M, K> & {
|
|
27
|
-
all: QueriedCoMapEdit<M, K>[];
|
|
28
|
-
}) | undefined;
|
|
29
|
-
};
|
|
30
|
-
get meta(): M["meta"];
|
|
31
|
-
get group(): Group;
|
|
32
|
-
get core(): CoValueCore;
|
|
33
|
-
set<K extends keyof M["_shape"] & string>(key: K, value: M["_shape"][K], privacy?: "private" | "trusting"): M;
|
|
34
|
-
set(kv: {
|
|
35
|
-
[K in keyof M["_shape"] & string]?: M["_shape"][K];
|
|
36
|
-
}, privacy?: "private" | "trusting"): M;
|
|
37
|
-
delete(key: keyof M["_shape"] & string, privacy?: "private" | "trusting"): M;
|
|
38
|
-
mutate(mutator: (mutable: MutableCoMap<M["_shape"], M["meta"]>) => void): M;
|
|
39
|
-
as: <O>(extension: QueryExtension<M, O>) => O | undefined;
|
|
40
|
-
}
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
export class QueriedCoMapBase {
|
|
2
|
-
/** @internal */
|
|
3
|
-
static newWithKVPairs(coMap, queryContext) {
|
|
4
|
-
const kv = {};
|
|
5
|
-
for (const key of coMap.keys()) {
|
|
6
|
-
const value = coMap.get(key);
|
|
7
|
-
if (value === undefined)
|
|
8
|
-
continue;
|
|
9
|
-
queryContext.defineSubqueryPropertiesIn(kv, {
|
|
10
|
-
[key]: { value, enumerable: true },
|
|
11
|
-
}, [coMap.id]);
|
|
12
|
-
}
|
|
13
|
-
return Object.assign(new QueriedCoMapBase(coMap, queryContext), kv);
|
|
14
|
-
}
|
|
15
|
-
/** @internal */
|
|
16
|
-
constructor(coMap, queryContext) {
|
|
17
|
-
Object.defineProperties(this, {
|
|
18
|
-
coMap: {
|
|
19
|
-
get() {
|
|
20
|
-
return coMap;
|
|
21
|
-
},
|
|
22
|
-
enumerable: false,
|
|
23
|
-
},
|
|
24
|
-
id: { value: coMap.id, enumerable: false },
|
|
25
|
-
type: { value: "comap", enumerable: false },
|
|
26
|
-
edits: {
|
|
27
|
-
value: Object.fromEntries(coMap.keys().flatMap((key) => {
|
|
28
|
-
const edits = [...coMap.editsAt(key)].map((edit) => queryContext.defineSubqueryPropertiesIn({
|
|
29
|
-
tx: edit.tx,
|
|
30
|
-
at: new Date(edit.at),
|
|
31
|
-
}, {
|
|
32
|
-
by: { value: edit.by, enumerable: true },
|
|
33
|
-
value: {
|
|
34
|
-
value: edit.value,
|
|
35
|
-
enumerable: true,
|
|
36
|
-
},
|
|
37
|
-
}, [coMap.id]));
|
|
38
|
-
const lastEdit = edits[edits.length - 1];
|
|
39
|
-
if (!lastEdit)
|
|
40
|
-
return [];
|
|
41
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
42
|
-
const editsAtKey = {
|
|
43
|
-
by: lastEdit.by,
|
|
44
|
-
tx: lastEdit.tx,
|
|
45
|
-
at: lastEdit.at,
|
|
46
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
47
|
-
value: lastEdit.value,
|
|
48
|
-
all: edits,
|
|
49
|
-
};
|
|
50
|
-
return [[key, editsAtKey]];
|
|
51
|
-
})),
|
|
52
|
-
enumerable: false,
|
|
53
|
-
},
|
|
54
|
-
as: {
|
|
55
|
-
value: (extension) => {
|
|
56
|
-
return queryContext.getOrCreateExtension(coMap.id, extension);
|
|
57
|
-
},
|
|
58
|
-
enumerable: false,
|
|
59
|
-
},
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
get meta() {
|
|
63
|
-
return this.coMap.meta;
|
|
64
|
-
}
|
|
65
|
-
get group() {
|
|
66
|
-
return this.coMap.group;
|
|
67
|
-
}
|
|
68
|
-
get core() {
|
|
69
|
-
return this.coMap.core;
|
|
70
|
-
}
|
|
71
|
-
set(...args) {
|
|
72
|
-
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
73
|
-
return this.coMap.set(...args);
|
|
74
|
-
}
|
|
75
|
-
delete(key, privacy) {
|
|
76
|
-
return this.coMap.delete(key, privacy);
|
|
77
|
-
}
|
|
78
|
-
mutate(mutator) {
|
|
79
|
-
return this.coMap.mutate(mutator);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
//# sourceMappingURL=queriedCoMap.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"queriedCoMap.js","sourceRoot":"","sources":["../../src/queriedCoValues/queriedCoMap.ts"],"names":[],"mappings":"AAmBA,MAAM,OAAO,gBAAgB;IAKzB,gBAAgB;IAChB,MAAM,CAAC,cAAc,CACjB,KAAQ,EACR,YAA0B;QAE1B,MAAM,EAAE,GAAG,EAIV,CAAC;QACF,KAAK,MAAM,GAAG,IAAI,KAAK,CAAC,IAAI,EAAE,EAAE;YAC5B,MAAM,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC,GAAG,C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M,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IAC3C,CAAC;IACD,MAAM,CACF,OAAgE;QAEhE,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IACtC,CAAC;CAGJ"}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { JsonValue } from "../jsonValue.js";
|
|
2
|
-
import { CoStream, MutableCoStream } from "../coValues/coStream.js";
|
|
3
|
-
import { CoValueCore } from "../coValueCore.js";
|
|
4
|
-
import { Group } from "../coValues/group.js";
|
|
5
|
-
import { AccountID } from "../coValues/account.js";
|
|
6
|
-
import { CoID, CoValue } from "../coValue.js";
|
|
7
|
-
import { SessionID, TransactionID } from "../ids.js";
|
|
8
|
-
import { ValueOrSubQueried, QueryContext } from "../queries.js";
|
|
9
|
-
import { QueriedAccount } from "./queriedAccount.js";
|
|
10
|
-
export type QueriedCoStreamEntry<Item extends JsonValue | CoValue> = {
|
|
11
|
-
last?: ValueOrSubQueried<Item>;
|
|
12
|
-
by?: QueriedAccount;
|
|
13
|
-
tx?: TransactionID;
|
|
14
|
-
at?: Date;
|
|
15
|
-
all: {
|
|
16
|
-
value: ValueOrSubQueried<Item>;
|
|
17
|
-
by?: QueriedAccount;
|
|
18
|
-
tx: TransactionID;
|
|
19
|
-
at: Date;
|
|
20
|
-
}[];
|
|
21
|
-
};
|
|
22
|
-
export declare class QueriedCoStream<S extends CoStream> {
|
|
23
|
-
coStream: S;
|
|
24
|
-
id: CoID<S>;
|
|
25
|
-
type: "costream";
|
|
26
|
-
/** @internal */
|
|
27
|
-
constructor(coStream: S, queryContext: QueryContext);
|
|
28
|
-
get meta(): S["meta"];
|
|
29
|
-
get group(): Group;
|
|
30
|
-
get core(): CoValueCore;
|
|
31
|
-
me?: QueriedCoStreamEntry<S["_item"]>;
|
|
32
|
-
perAccount: [account: AccountID, items: QueriedCoStreamEntry<S["_item"]>][];
|
|
33
|
-
perSession: [session: SessionID, items: QueriedCoStreamEntry<S["_item"]>][];
|
|
34
|
-
push(item: S["_item"], privacy?: "private" | "trusting"): S;
|
|
35
|
-
mutate(mutator: (mutable: MutableCoStream<S["_item"], S["meta"]>) => void): S;
|
|
36
|
-
}
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
import { isAccountID } from "../coValues/account.js";
|
|
2
|
-
export class QueriedCoStream {
|
|
3
|
-
/** @internal */
|
|
4
|
-
constructor(coStream, queryContext) {
|
|
5
|
-
this.type = "costream";
|
|
6
|
-
Object.defineProperty(this, "coStream", {
|
|
7
|
-
get() {
|
|
8
|
-
return coStream;
|
|
9
|
-
},
|
|
10
|
-
});
|
|
11
|
-
this.id = coStream.id;
|
|
12
|
-
this.perSession = coStream.sessions().map((sessionID) => {
|
|
13
|
-
const items = [...coStream.itemsIn(sessionID)].map((item) => queryContext.defineSubqueryPropertiesIn({
|
|
14
|
-
tx: item.tx,
|
|
15
|
-
at: new Date(item.at),
|
|
16
|
-
}, {
|
|
17
|
-
by: {
|
|
18
|
-
value: isAccountID(item.by)
|
|
19
|
-
? item.by
|
|
20
|
-
: undefined,
|
|
21
|
-
enumerable: true,
|
|
22
|
-
},
|
|
23
|
-
value: {
|
|
24
|
-
value: item.value,
|
|
25
|
-
enumerable: true,
|
|
26
|
-
},
|
|
27
|
-
}, [coStream.id]));
|
|
28
|
-
const lastItem = items[items.length - 1];
|
|
29
|
-
return [
|
|
30
|
-
sessionID,
|
|
31
|
-
{
|
|
32
|
-
get last() {
|
|
33
|
-
return lastItem?.value;
|
|
34
|
-
},
|
|
35
|
-
get by() {
|
|
36
|
-
return lastItem?.by;
|
|
37
|
-
},
|
|
38
|
-
tx: lastItem?.tx,
|
|
39
|
-
at: lastItem?.at,
|
|
40
|
-
all: items,
|
|
41
|
-
},
|
|
42
|
-
];
|
|
43
|
-
});
|
|
44
|
-
this.perAccount = [...coStream.accounts()].map((accountID) => {
|
|
45
|
-
const items = [...coStream.itemsBy(accountID)].map((item) => queryContext.defineSubqueryPropertiesIn({
|
|
46
|
-
tx: item.tx,
|
|
47
|
-
at: new Date(item.at),
|
|
48
|
-
}, {
|
|
49
|
-
by: {
|
|
50
|
-
value: isAccountID(item.by)
|
|
51
|
-
? item.by
|
|
52
|
-
: undefined,
|
|
53
|
-
enumerable: true,
|
|
54
|
-
},
|
|
55
|
-
value: {
|
|
56
|
-
value: item.value,
|
|
57
|
-
enumerable: true,
|
|
58
|
-
},
|
|
59
|
-
}, [coStream.id]));
|
|
60
|
-
const lastItem = items[items.length - 1];
|
|
61
|
-
const entry = {
|
|
62
|
-
get last() {
|
|
63
|
-
return lastItem?.value;
|
|
64
|
-
},
|
|
65
|
-
get by() {
|
|
66
|
-
return lastItem?.by;
|
|
67
|
-
},
|
|
68
|
-
tx: lastItem?.tx,
|
|
69
|
-
at: lastItem?.at,
|
|
70
|
-
all: items,
|
|
71
|
-
};
|
|
72
|
-
if (accountID === queryContext.node.account.id) {
|
|
73
|
-
this.me = entry;
|
|
74
|
-
}
|
|
75
|
-
return [
|
|
76
|
-
accountID,
|
|
77
|
-
entry
|
|
78
|
-
];
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
get meta() {
|
|
82
|
-
return this.coStream.meta;
|
|
83
|
-
}
|
|
84
|
-
get group() {
|
|
85
|
-
return this.coStream.group;
|
|
86
|
-
}
|
|
87
|
-
get core() {
|
|
88
|
-
return this.coStream.core;
|
|
89
|
-
}
|
|
90
|
-
push(item, privacy) {
|
|
91
|
-
return this.coStream.push(item, privacy);
|
|
92
|
-
}
|
|
93
|
-
mutate(mutator) {
|
|
94
|
-
return this.coStream.mutate(mutator);
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
//# sourceMappingURL=queriedCoStream.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"queriedCoStream.js","sourceRoot":"","sources":["../../src/queriedCoValues/queriedCoStream.ts"],"names":[],"mappings":"AAIA,OAAO,EAAa,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAmB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