jazz-tools 0.10.15 → 0.11.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.
- package/.turbo/turbo-build.log +9 -5
- package/CHANGELOG.md +23 -0
- package/dist/auth/AuthSecretStorage.d.ts +25 -0
- package/dist/auth/AuthSecretStorage.d.ts.map +1 -0
- package/dist/auth/DemoAuth.d.ts +27 -0
- package/dist/auth/DemoAuth.d.ts.map +1 -0
- package/dist/auth/InMemoryKVStore.d.ts +9 -0
- package/dist/auth/InMemoryKVStore.d.ts.map +1 -0
- package/dist/auth/KvStoreContext.d.ts +17 -0
- package/dist/auth/KvStoreContext.d.ts.map +1 -0
- package/dist/auth/PassphraseAuth.d.ts +35 -0
- package/dist/auth/PassphraseAuth.d.ts.map +1 -0
- package/dist/{chunk-5USJBXLW.js → chunk-RTRX7HIO.js} +153 -69
- package/dist/chunk-RTRX7HIO.js.map +1 -0
- package/dist/coValues/account.d.ts +120 -0
- package/dist/coValues/account.d.ts.map +1 -0
- package/dist/coValues/coFeed.d.ts +361 -0
- package/dist/coValues/coFeed.d.ts.map +1 -0
- package/dist/coValues/coList.d.ts +221 -0
- package/dist/coValues/coList.d.ts.map +1 -0
- package/dist/coValues/coMap.d.ts +500 -0
- package/dist/coValues/coMap.d.ts.map +1 -0
- package/dist/coValues/coPlainText.d.ts +69 -0
- package/dist/coValues/coPlainText.d.ts.map +1 -0
- package/dist/coValues/coRichText.d.ts +259 -0
- package/dist/coValues/coRichText.d.ts.map +1 -0
- package/dist/coValues/deepLoading.d.ts +81 -0
- package/dist/coValues/deepLoading.d.ts.map +1 -0
- package/dist/coValues/extensions/imageDef.d.ts +17 -0
- package/dist/coValues/extensions/imageDef.d.ts.map +1 -0
- package/dist/coValues/group.d.ts +67 -0
- package/dist/coValues/group.d.ts.map +1 -0
- package/dist/coValues/inbox.d.ts +52 -0
- package/dist/coValues/inbox.d.ts.map +1 -0
- package/dist/coValues/interfaces.d.ts +97 -0
- package/dist/coValues/interfaces.d.ts.map +1 -0
- package/dist/coValues/profile.d.ts +28 -0
- package/dist/coValues/profile.d.ts.map +1 -0
- package/dist/coValues/registeredSchemas.d.ts +12 -0
- package/dist/coValues/registeredSchemas.d.ts.map +1 -0
- package/dist/coValues/schemaUnion.d.ts +79 -0
- package/dist/coValues/schemaUnion.d.ts.map +1 -0
- package/dist/exports.d.ts +27 -0
- package/dist/exports.d.ts.map +1 -0
- package/dist/implementation/ContextManager.d.ts +65 -0
- package/dist/implementation/ContextManager.d.ts.map +1 -0
- package/dist/implementation/activeAccountContext.d.ts +12 -0
- package/dist/implementation/activeAccountContext.d.ts.map +1 -0
- package/dist/implementation/anonymousJazzAgent.d.ts +7 -0
- package/dist/implementation/anonymousJazzAgent.d.ts.map +1 -0
- package/dist/implementation/createContext.d.ts +91 -0
- package/dist/implementation/createContext.d.ts.map +1 -0
- package/dist/implementation/devtoolsFormatters.d.ts +2 -0
- package/dist/implementation/devtoolsFormatters.d.ts.map +1 -0
- package/dist/implementation/errors.d.ts +2 -0
- package/dist/implementation/errors.d.ts.map +1 -0
- package/dist/implementation/inspect.d.ts +3 -0
- package/dist/implementation/inspect.d.ts.map +1 -0
- package/dist/implementation/invites.d.ts +23 -0
- package/dist/implementation/invites.d.ts.map +1 -0
- package/dist/implementation/refs.d.ts +21 -0
- package/dist/implementation/refs.d.ts.map +1 -0
- package/dist/implementation/schema.d.ts +72 -0
- package/dist/implementation/schema.d.ts.map +1 -0
- package/dist/implementation/subscriptionScope.d.ts +33 -0
- package/dist/implementation/subscriptionScope.d.ts.map +1 -0
- package/dist/implementation/symbols.d.ts +8 -0
- package/dist/implementation/symbols.d.ts.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1 -1
- package/dist/internal.d.ts +12 -0
- package/dist/internal.d.ts.map +1 -0
- package/dist/lib/cache.d.ts +6 -0
- package/dist/lib/cache.d.ts.map +1 -0
- package/dist/lib/cache.test.d.ts +2 -0
- package/dist/lib/cache.test.d.ts.map +1 -0
- package/dist/testing.d.ts +41 -0
- package/dist/testing.d.ts.map +1 -0
- package/dist/testing.js +1 -1
- package/dist/tests/AuthSecretStorage.test.d.ts +2 -0
- package/dist/tests/AuthSecretStorage.test.d.ts.map +1 -0
- package/dist/tests/ContextManager.test.d.ts +2 -0
- package/dist/tests/ContextManager.test.d.ts.map +1 -0
- package/dist/tests/DemoAuth.test.d.ts +2 -0
- package/dist/tests/DemoAuth.test.d.ts.map +1 -0
- package/dist/tests/PassphraseAuth.test.d.ts +2 -0
- package/dist/tests/PassphraseAuth.test.d.ts.map +1 -0
- package/dist/tests/account.test.d.ts +2 -0
- package/dist/tests/account.test.d.ts.map +1 -0
- package/dist/tests/coFeed.test.d.ts +2 -0
- package/dist/tests/coFeed.test.d.ts.map +1 -0
- package/dist/tests/coList.test.d.ts +2 -0
- package/dist/tests/coList.test.d.ts.map +1 -0
- package/dist/tests/coMap.test.d.ts +2 -0
- package/dist/tests/coMap.test.d.ts.map +1 -0
- package/dist/tests/coPlainText.test.d.ts +2 -0
- package/dist/tests/coPlainText.test.d.ts.map +1 -0
- package/dist/tests/coRichText.test.d.ts +2 -0
- package/dist/tests/coRichText.test.d.ts.map +1 -0
- package/dist/tests/createContext.test.d.ts +2 -0
- package/dist/tests/createContext.test.d.ts.map +1 -0
- package/dist/tests/deepLoading.test.d.ts +2 -0
- package/dist/tests/deepLoading.test.d.ts.map +1 -0
- package/dist/tests/fixtures.d.ts +2 -0
- package/dist/tests/fixtures.d.ts.map +1 -0
- package/dist/tests/groupsAndAccounts.test.d.ts +2 -0
- package/dist/tests/groupsAndAccounts.test.d.ts.map +1 -0
- package/dist/tests/inbox.test.d.ts +2 -0
- package/dist/tests/inbox.test.d.ts.map +1 -0
- package/dist/tests/interfaces.test.d.ts +2 -0
- package/dist/tests/interfaces.test.d.ts.map +1 -0
- package/dist/tests/invites.test.d.ts +2 -0
- package/dist/tests/invites.test.d.ts.map +1 -0
- package/dist/tests/schema.test.d.ts +2 -0
- package/dist/tests/schema.test.d.ts.map +1 -0
- package/dist/tests/schemaUnion.test.d.ts +2 -0
- package/dist/tests/schemaUnion.test.d.ts.map +1 -0
- package/dist/tests/subscribe.test.d.ts +2 -0
- package/dist/tests/subscribe.test.d.ts.map +1 -0
- package/dist/tests/testing.test.d.ts +2 -0
- package/dist/tests/testing.test.d.ts.map +1 -0
- package/dist/tests/utils.d.ts +21 -0
- package/dist/tests/utils.d.ts.map +1 -0
- package/dist/types.d.ts +52 -0
- package/dist/types.d.ts.map +1 -0
- package/package.json +8 -7
- package/src/coValues/account.ts +69 -11
- package/src/coValues/coMap.ts +2 -2
- package/src/coValues/coRichText.ts +42 -17
- package/src/coValues/group.ts +76 -31
- package/src/coValues/inbox.ts +10 -0
- package/src/coValues/interfaces.ts +1 -1
- package/src/coValues/profile.ts +35 -2
- package/src/implementation/schema.ts +1 -3
- package/src/tests/AuthSecretStorage.test.ts +1 -2
- package/src/tests/PassphraseAuth.test.ts +3 -3
- package/src/tests/coMap.test.ts +20 -21
- package/src/tests/deepLoading.test.ts +8 -17
- package/src/tests/groupsAndAccounts.test.ts +429 -89
- package/src/tests/inbox.test.ts +24 -0
- package/src/tests/schema.test.ts +45 -5
- package/src/tests/utils.ts +7 -3
- package/src/types.ts +6 -0
- package/tsconfig.json +4 -1
- package/dist/chunk-5USJBXLW.js.map +0 -1
@@ -0,0 +1,41 @@
|
|
1
|
+
import { LocalNode, Peer } from "cojson";
|
2
|
+
import { PureJSCrypto } from "cojson/dist/crypto/PureJSCrypto";
|
3
|
+
import { Account, AccountClass, JazzContextManagerAuthProps } from "./exports.js";
|
4
|
+
import { JazzContextManager, JazzContextManagerBaseProps } from "./implementation/ContextManager.js";
|
5
|
+
import { type AnonymousJazzAgent, type CoValueClass } from "./internal.js";
|
6
|
+
export declare class TestJSCrypto extends PureJSCrypto {
|
7
|
+
static create(): Promise<PureJSCrypto>;
|
8
|
+
}
|
9
|
+
export declare function getPeerConnectedToTestSyncServer(): Peer;
|
10
|
+
export declare function createJazzTestAccount<Acc extends Account>(options?: {
|
11
|
+
isCurrentActiveAccount?: boolean;
|
12
|
+
AccountSchema?: CoValueClass<Acc>;
|
13
|
+
creationProps?: Record<string, unknown>;
|
14
|
+
}): Promise<Acc>;
|
15
|
+
export declare function setActiveAccount(account: Account): void;
|
16
|
+
export declare function createJazzTestGuest(): Promise<{
|
17
|
+
guest: AnonymousJazzAgent;
|
18
|
+
}>;
|
19
|
+
export type TestJazzContextManagerProps<Acc extends Account> = JazzContextManagerBaseProps<Acc> & {
|
20
|
+
defaultProfileName?: string;
|
21
|
+
AccountSchema?: AccountClass<Acc>;
|
22
|
+
isAuthenticated?: boolean;
|
23
|
+
};
|
24
|
+
export declare class TestJazzContextManager<Acc extends Account> extends JazzContextManager<Acc, TestJazzContextManagerProps<Acc>> {
|
25
|
+
static fromAccountOrGuest<Acc extends Account>(account?: Acc | {
|
26
|
+
guest: AnonymousJazzAgent;
|
27
|
+
}, props?: TestJazzContextManagerProps<Acc>): TestJazzContextManager<Acc>;
|
28
|
+
static fromAccount<Acc extends Account>(account: Acc, props?: TestJazzContextManagerProps<Acc>): TestJazzContextManager<Acc>;
|
29
|
+
static fromGuest<Acc extends Account>({ guest }: {
|
30
|
+
guest: AnonymousJazzAgent;
|
31
|
+
}, props?: TestJazzContextManagerProps<Acc>): TestJazzContextManager<Acc>;
|
32
|
+
getNewContext(props: TestJazzContextManagerProps<Acc>, authProps?: JazzContextManagerAuthProps): Promise<{
|
33
|
+
me: Acc;
|
34
|
+
node: LocalNode;
|
35
|
+
done: () => void;
|
36
|
+
logOut: () => Promise<void>;
|
37
|
+
}>;
|
38
|
+
}
|
39
|
+
export declare function linkAccounts(a: Account, b: Account, aRole?: "server" | "client", bRole?: "server" | "client"): void;
|
40
|
+
export declare function setupJazzTestSync(): Promise<Account>;
|
41
|
+
//# sourceMappingURL=testing.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"testing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AO,CAAC,EAAE,GAAG,GAAG;QAAE,KAAK,EAAE,kBAAkB,CAAA;KAAE,EAC7C,KAAK,CAAC,EAAE,2BAA2B,CAAC,GAAG,CAAC;IAS1C,MAAM,CAAC,WAAW,CAAC,GAAG,SAAS,OAAO,EACpC,OAAO,EAAE,GAAG,EACZ,KAAK,CAAC,EAAE,2BAA2B,CAAC,GAAG,CAAC;IAyC1C,MAAM,CAAC,SAAS,CAAC,GAAG,SAAS,OAAO,EAClC,EAAE,KAAK,EAAE,EAAE;QAAE,KAAK,EAAE,kBAAkB,CAAA;KAAE,EACxC,KAAK,GAAE,2BAA2B,CAAC,GAAG,CAAM;IAmBxC,aAAa,CACjB,KAAK,EAAE,2BAA2B,CAAC,GAAG,CAAC,EACvC,SAAS,CAAC,EAAE,2BAA2B;;;;;;CA8B1C;AAED,wBAAgB,YAAY,CAC1B,CAAC,EAAE,OAAO,EACV,CAAC,EAAE,OAAO,EACV,KAAK,GAAE,QAAQ,GAAG,QAAmB,EACrC,KAAK,GAAE,QAAQ,GAAG,QAAmB,QAStC;AAED,wBAAsB,iBAAiB,qBAetC"}
|
package/dist/testing.js
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"AuthSecretStorage.test.d.ts","sourceRoot":"","sources":["../../src/tests/AuthSecretStorage.test.ts"],"names":[],"mappings":""}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"ContextManager.test.d.ts","sourceRoot":"","sources":["../../src/tests/ContextManager.test.ts"],"names":[],"mappings":""}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"DemoAuth.test.d.ts","sourceRoot":"","sources":["../../src/tests/DemoAuth.test.ts"],"names":[],"mappings":""}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"PassphraseAuth.test.d.ts","sourceRoot":"","sources":["../../src/tests/PassphraseAuth.test.ts"],"names":[],"mappings":""}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"account.test.d.ts","sourceRoot":"","sources":["../../src/tests/account.test.ts"],"names":[],"mappings":""}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"coFeed.test.d.ts","sourceRoot":"","sources":["../../src/tests/coFeed.test.ts"],"names":[],"mappings":""}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"coList.test.d.ts","sourceRoot":"","sources":["../../src/tests/coList.test.ts"],"names":[],"mappings":""}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"coMap.test.d.ts","sourceRoot":"","sources":["../../src/tests/coMap.test.ts"],"names":[],"mappings":""}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"coPlainText.test.d.ts","sourceRoot":"","sources":["../../src/tests/coPlainText.test.ts"],"names":[],"mappings":""}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"coRichText.test.d.ts","sourceRoot":"","sources":["../../src/tests/coRichText.test.ts"],"names":[],"mappings":""}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"createContext.test.d.ts","sourceRoot":"","sources":["../../src/tests/createContext.test.ts"],"names":[],"mappings":""}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"deepLoading.test.d.ts","sourceRoot":"","sources":["../../src/tests/deepLoading.test.ts"],"names":[],"mappings":""}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"fixtures.d.ts","sourceRoot":"","sources":["../../src/tests/fixtures.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,YAAY,UAigExB,CAAC"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"groupsAndAccounts.test.d.ts","sourceRoot":"","sources":["../../src/tests/groupsAndAccounts.test.ts"],"names":[],"mappings":""}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"inbox.test.d.ts","sourceRoot":"","sources":["../../src/tests/inbox.test.ts"],"names":[],"mappings":""}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"interfaces.test.d.ts","sourceRoot":"","sources":["../../src/tests/interfaces.test.ts"],"names":[],"mappings":""}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"invites.test.d.ts","sourceRoot":"","sources":["../../src/tests/invites.test.ts"],"names":[],"mappings":""}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"schema.test.d.ts","sourceRoot":"","sources":["../../src/tests/schema.test.ts"],"names":[],"mappings":""}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"schemaUnion.test.d.ts","sourceRoot":"","sources":["../../src/tests/schemaUnion.test.ts"],"names":[],"mappings":""}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"subscribe.test.d.ts","sourceRoot":"","sources":["../../src/tests/subscribe.test.ts"],"names":[],"mappings":""}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"testing.test.d.ts","sourceRoot":"","sources":["../../src/tests/testing.test.ts"],"names":[],"mappings":""}
|
@@ -0,0 +1,21 @@
|
|
1
|
+
import { CoID, LocalNode, RawCoValue } from "cojson";
|
2
|
+
import { Account } from "../index";
|
3
|
+
export declare function setupAccount(): Promise<{
|
4
|
+
me: Account & {
|
5
|
+
isLocalNodeOwner: true;
|
6
|
+
sessionID: import("cojson").SessionID;
|
7
|
+
_raw: import("cojson").RawControlledAccount;
|
8
|
+
};
|
9
|
+
meOnSecondPeer: Account;
|
10
|
+
}>;
|
11
|
+
export declare function setupTwoNodes(options?: {
|
12
|
+
ServerAccountSchema?: typeof Account;
|
13
|
+
}): Promise<{
|
14
|
+
clientNode: LocalNode;
|
15
|
+
serverNode: LocalNode;
|
16
|
+
clientAccount: Account;
|
17
|
+
serverAccount: Account;
|
18
|
+
}>;
|
19
|
+
export declare function waitFor(callback: () => boolean | void): Promise<void>;
|
20
|
+
export declare function loadCoValueOrFail<V extends RawCoValue>(node: LocalNode, id: CoID<V>): Promise<V>;
|
21
|
+
//# sourceMappingURL=utils.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/tests/utils.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAGrD,OAAO,EACL,OAAO,EAGR,MAAM,UAAU,CAAC;AAIlB,wBAAsB,YAAY;;;;;;;GA+BjC;AAED,wBAAsB,aAAa,CAAC,OAAO,CAAC,EAAE;IAC5C,mBAAmB,CAAC,EAAE,OAAO,OAAO,CAAC;CACtC;;;;;GAgDA;AAED,wBAAgB,OAAO,CAAC,QAAQ,EAAE,MAAM,OAAO,GAAG,IAAI,iBA0BrD;AAED,wBAAsB,iBAAiB,CAAC,CAAC,SAAS,UAAU,EAC1D,IAAI,EAAE,SAAS,EACf,EAAE,EAAE,IAAI,CAAC,CAAC,CAAC,GACV,OAAO,CAAC,CAAC,CAAC,CAMZ"}
|
package/dist/types.d.ts
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
import type { AgentSecret, LocalNode } from "cojson";
|
2
|
+
import type { Account } from "./exports.js";
|
3
|
+
import type { AnonymousJazzAgent, ID } from "./internal.js";
|
4
|
+
export type AuthCredentials = {
|
5
|
+
accountID: ID<Account>;
|
6
|
+
secretSeed?: Uint8Array;
|
7
|
+
accountSecret: AgentSecret;
|
8
|
+
provider?: "anonymous" | "clerk" | "demo" | "passkey" | "passphrase" | string;
|
9
|
+
};
|
10
|
+
export type AuthenticateAccountFunction = (credentials: AuthCredentials) => Promise<void>;
|
11
|
+
export type RegisterAccountFunction = (accountSecret: AgentSecret, creationProps: {
|
12
|
+
name: string;
|
13
|
+
}) => Promise<ID<Account>>;
|
14
|
+
/** @category Context Creation */
|
15
|
+
export type JazzAuthContext<Acc extends Account> = {
|
16
|
+
me: Acc;
|
17
|
+
node: LocalNode;
|
18
|
+
authenticate: AuthenticateAccountFunction;
|
19
|
+
register: RegisterAccountFunction;
|
20
|
+
logOut: () => Promise<void>;
|
21
|
+
done: () => void;
|
22
|
+
isAuthenticated?: boolean;
|
23
|
+
};
|
24
|
+
export type JazzGuestContext = {
|
25
|
+
guest: AnonymousJazzAgent;
|
26
|
+
node: LocalNode;
|
27
|
+
authenticate: AuthenticateAccountFunction;
|
28
|
+
register: RegisterAccountFunction;
|
29
|
+
logOut: () => void;
|
30
|
+
done: () => void;
|
31
|
+
isAuthenticated?: boolean;
|
32
|
+
};
|
33
|
+
export type JazzContextType<Acc extends Account> = JazzAuthContext<Acc> | JazzGuestContext;
|
34
|
+
export type NewAccountProps = {
|
35
|
+
secret?: AgentSecret;
|
36
|
+
creationProps?: {
|
37
|
+
name: string;
|
38
|
+
};
|
39
|
+
};
|
40
|
+
export type SyncConfig = {
|
41
|
+
peer: `wss://${string}` | `ws://${string}`;
|
42
|
+
when?: "always" | "signedUp";
|
43
|
+
} | {
|
44
|
+
peer?: `wss://${string}` | `ws://${string}`;
|
45
|
+
when: "never";
|
46
|
+
};
|
47
|
+
export interface Register {
|
48
|
+
}
|
49
|
+
export type RegisteredAccount = Register extends {
|
50
|
+
Account: infer Acc;
|
51
|
+
} ? Acc : Account;
|
52
|
+
//# sourceMappingURL=types.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AACrD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,KAAK,EAAE,kBAAkB,EAAE,EAAE,EAAE,MAAM,eAAe,CAAC;AAE5D,MAAM,MAAM,eAAe,GAAG;IAC5B,SAAS,EAAE,EAAE,CAAC,OAAO,CAAC,CAAC;IACvB,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,aAAa,EAAE,WAAW,CAAC;IAC3B,QAAQ,CAAC,EAAE,WAAW,GAAG,OAAO,GAAG,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EAAE,SAAS,MAAM,EAAE,GAAG,QAAQ,MAAM,EAAE,CAAC;IAC3C,IAAI,CAAC,EAAE,QAAQ,GAAG,UAAU,CAAC;CAC9B,GACD;IACE,IAAI,CAAC,EAAE,SAAS,MAAM,EAAE,GAAG,QAAQ,MAAM,EAAE,CAAC;IAC5C,IAAI,EAAE,OAAO,CAAC;CACf,CAAC;AAEN,MAAM,WAAW,QAAQ;CAAG;AAE5B,MAAM,MAAM,iBAAiB,GAAG,QAAQ,SAAS;IAAE,OAAO,EAAE,MAAM,GAAG,CAAA;CAAE,GACnE,GAAG,GACH,OAAO,CAAC"}
|
package/package.json
CHANGED
@@ -2,14 +2,14 @@
|
|
2
2
|
"name": "jazz-tools",
|
3
3
|
"module": "dist/index.js",
|
4
4
|
"main": "dist/index.js",
|
5
|
-
"types": "
|
5
|
+
"types": "dist/index.d.ts",
|
6
6
|
"exports": {
|
7
7
|
".": {
|
8
|
-
"types": "./
|
8
|
+
"types": "./dist/index.d.ts",
|
9
9
|
"default": "./dist/index.js"
|
10
10
|
},
|
11
11
|
"./testing": {
|
12
|
-
"types": "./
|
12
|
+
"types": "./dist/testing.d.ts",
|
13
13
|
"default": "./dist/testing.js"
|
14
14
|
},
|
15
15
|
"./dist/*": "./dist/*",
|
@@ -17,10 +17,10 @@
|
|
17
17
|
},
|
18
18
|
"type": "module",
|
19
19
|
"license": "MIT",
|
20
|
-
"version": "0.
|
20
|
+
"version": "0.11.0",
|
21
21
|
"dependencies": {
|
22
22
|
"@scure/bip39": "^1.3.0",
|
23
|
-
"cojson": "0.
|
23
|
+
"cojson": "0.11.0"
|
24
24
|
},
|
25
25
|
"devDependencies": {
|
26
26
|
"tsup": "8.3.5",
|
@@ -38,9 +38,10 @@
|
|
38
38
|
"scripts": {
|
39
39
|
"format-and-lint": "biome check .",
|
40
40
|
"format-and-lint:fix": "biome check . --write",
|
41
|
-
"dev": "tsup --watch",
|
41
|
+
"dev": "tsup --watch --dts",
|
42
42
|
"test": "vitest --run --root ../../ --project jazz-tools",
|
43
43
|
"test:watch": "vitest --watch --root ../../ --project jazz-tools",
|
44
|
-
"
|
44
|
+
"types": "tsc --outDir dist",
|
45
|
+
"build": "tsup && pnpm types"
|
45
46
|
}
|
46
47
|
}
|
package/src/coValues/account.ts
CHANGED
@@ -2,6 +2,7 @@ import {
|
|
2
2
|
AgentSecret,
|
3
3
|
CoID,
|
4
4
|
CryptoProvider,
|
5
|
+
Everyone,
|
5
6
|
InviteSecret,
|
6
7
|
LocalNode,
|
7
8
|
Peer,
|
@@ -9,6 +10,7 @@ import {
|
|
9
10
|
RawCoMap,
|
10
11
|
RawCoValue,
|
11
12
|
RawControlledAccount,
|
13
|
+
Role,
|
12
14
|
SessionID,
|
13
15
|
cojsonInternals,
|
14
16
|
} from "cojson";
|
@@ -21,7 +23,6 @@ import {
|
|
21
23
|
DeeplyLoaded,
|
22
24
|
DepthsIn,
|
23
25
|
ID,
|
24
|
-
MembersSym,
|
25
26
|
Ref,
|
26
27
|
type RefEncoded,
|
27
28
|
RefIfCoValue,
|
@@ -36,6 +37,7 @@ import {
|
|
36
37
|
subscriptionsScopes,
|
37
38
|
} from "../internal.js";
|
38
39
|
import { coValuesCache } from "../lib/cache.js";
|
40
|
+
import { RegisteredAccount } from "../types.js";
|
39
41
|
import { type CoMap } from "./coMap.js";
|
40
42
|
import { type Group } from "./group.js";
|
41
43
|
import { createInboxRoot } from "./inbox.js";
|
@@ -168,6 +170,57 @@ export class Account extends CoValueBase implements CoValue {
|
|
168
170
|
}
|
169
171
|
}
|
170
172
|
|
173
|
+
getRoleOf(member: Everyone | ID<Account> | "me") {
|
174
|
+
if (member === "me") {
|
175
|
+
return this.isMe ? "admin" : undefined;
|
176
|
+
}
|
177
|
+
|
178
|
+
if (member === this.id) {
|
179
|
+
return "admin";
|
180
|
+
}
|
181
|
+
|
182
|
+
return undefined;
|
183
|
+
}
|
184
|
+
|
185
|
+
getParentGroups(): Array<Group> {
|
186
|
+
return [];
|
187
|
+
}
|
188
|
+
|
189
|
+
get members(): Array<{
|
190
|
+
id: ID<RegisteredAccount> | "everyone";
|
191
|
+
role: Role;
|
192
|
+
ref: Ref<RegisteredAccount> | undefined;
|
193
|
+
account: RegisteredAccount | null | undefined;
|
194
|
+
}> {
|
195
|
+
const ref = new Ref<RegisteredAccount>(this.id, this._loadedAs, {
|
196
|
+
ref: () => this.constructor as typeof Account,
|
197
|
+
optional: false,
|
198
|
+
});
|
199
|
+
|
200
|
+
return [{ id: this.id, role: "admin", ref, account: this }];
|
201
|
+
}
|
202
|
+
|
203
|
+
canRead(value: CoValue) {
|
204
|
+
const role = value._owner.getRoleOf(this.id);
|
205
|
+
|
206
|
+
return (
|
207
|
+
role === "admin" ||
|
208
|
+
role === "writer" ||
|
209
|
+
role === "reader" ||
|
210
|
+
role === "writeOnly"
|
211
|
+
);
|
212
|
+
}
|
213
|
+
|
214
|
+
canWrite(value: CoValue) {
|
215
|
+
const role = value._owner.getRoleOf(this.id);
|
216
|
+
|
217
|
+
return role === "admin" || role === "writer" || role === "writeOnly";
|
218
|
+
}
|
219
|
+
|
220
|
+
canAdmin(value: CoValue) {
|
221
|
+
return value._owner.getRoleOf(this.id) === "admin";
|
222
|
+
}
|
223
|
+
|
171
224
|
async acceptInvite<V extends CoValue>(
|
172
225
|
valueID: ID<V>,
|
173
226
|
inviteSecret: InviteSecret,
|
@@ -259,13 +312,20 @@ export class Account extends CoValueBase implements CoValue {
|
|
259
312
|
}
|
260
313
|
|
261
314
|
async applyMigration(creationProps?: AccountCreationProps) {
|
262
|
-
|
315
|
+
await this.migrate(creationProps);
|
316
|
+
|
317
|
+
// if the user has not defined a profile themselves, we create one
|
318
|
+
if (this.profile === undefined && creationProps) {
|
263
319
|
const profileGroup = RegisteredSchemas["Group"].create({ owner: this });
|
264
|
-
|
265
|
-
this.profile = Profile.create(
|
266
|
-
|
267
|
-
|
268
|
-
)
|
320
|
+
|
321
|
+
this.profile = Profile.create({ name: creationProps.name }, profileGroup);
|
322
|
+
this.profile._owner.addMember("everyone", "reader");
|
323
|
+
} else if (this.profile && creationProps) {
|
324
|
+
if (this.profile._owner._type !== "Group") {
|
325
|
+
throw new Error("Profile must be owned by a Group", {
|
326
|
+
cause: `The profile of the account "${this.id}" was created with an Account as owner, which is not allowed.`,
|
327
|
+
});
|
328
|
+
}
|
269
329
|
}
|
270
330
|
|
271
331
|
const node = this._raw.core.node;
|
@@ -278,8 +338,6 @@ export class Account extends CoValueBase implements CoValue {
|
|
278
338
|
profile.set("inbox", inboxRoot.id);
|
279
339
|
profile.set("inboxInvite", inboxRoot.inviteLink);
|
280
340
|
}
|
281
|
-
|
282
|
-
await this.migrate(creationProps);
|
283
341
|
}
|
284
342
|
|
285
343
|
// Placeholder method for subclasses to override
|
@@ -400,7 +458,7 @@ export const AccountAndGroupProxyHandler: ProxyHandler<Account | Group> = {
|
|
400
458
|
},
|
401
459
|
set(target, key, value, receiver) {
|
402
460
|
if (
|
403
|
-
(key === "profile" || key === "root"
|
461
|
+
(key === "profile" || key === "root") &&
|
404
462
|
typeof value === "object" &&
|
405
463
|
SchemaInit in value
|
406
464
|
) {
|
@@ -433,7 +491,7 @@ export const AccountAndGroupProxyHandler: ProxyHandler<Account | Group> = {
|
|
433
491
|
},
|
434
492
|
defineProperty(target, key, descriptor) {
|
435
493
|
if (
|
436
|
-
(key === "profile" || key === "root"
|
494
|
+
(key === "profile" || key === "root") &&
|
437
495
|
typeof descriptor.value === "object" &&
|
438
496
|
SchemaInit in descriptor.value
|
439
497
|
) {
|
package/src/coValues/coMap.ts
CHANGED
@@ -151,7 +151,7 @@ export class CoMap extends CoValueBase implements CoValue {
|
|
151
151
|
}
|
152
152
|
|
153
153
|
/** @internal */
|
154
|
-
|
154
|
+
public getEditFromRaw(
|
155
155
|
target: CoMap,
|
156
156
|
rawEdit: {
|
157
157
|
by: RawAccountID | AgentID;
|
@@ -309,7 +309,7 @@ export class CoMap extends CoValueBase implements CoValue {
|
|
309
309
|
const descriptor = (this._schema[tKey] ||
|
310
310
|
this._schema[ItemsSym]) as Schema;
|
311
311
|
|
312
|
-
if (descriptor == "json" || "
|
312
|
+
if (descriptor == "json" || "encoded" in descriptor) {
|
313
313
|
return [key, this._raw.get(key)];
|
314
314
|
} else if (isRefEncoded(descriptor)) {
|
315
315
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
@@ -611,26 +611,51 @@ export function splitNode(
|
|
611
611
|
}
|
612
612
|
}
|
613
613
|
|
614
|
+
/**
|
615
|
+
* Heading mark for rich text formatting.
|
616
|
+
*/
|
617
|
+
export class Heading extends Mark {
|
618
|
+
tag = co.literal("heading");
|
619
|
+
level = co.number;
|
620
|
+
}
|
621
|
+
|
622
|
+
/**
|
623
|
+
* Paragraph mark for rich text formatting.
|
624
|
+
*/
|
625
|
+
export class Paragraph extends Mark {
|
626
|
+
tag = co.literal("paragraph");
|
627
|
+
}
|
628
|
+
|
629
|
+
/**
|
630
|
+
* Link mark for rich text formatting.
|
631
|
+
*/
|
632
|
+
export class Link extends Mark {
|
633
|
+
tag = co.literal("link");
|
634
|
+
url = co.string;
|
635
|
+
}
|
636
|
+
|
637
|
+
/**
|
638
|
+
* Strong (bold) mark for rich text formatting.
|
639
|
+
*/
|
640
|
+
export class Strong extends Mark {
|
641
|
+
tag = co.literal("strong");
|
642
|
+
}
|
643
|
+
|
644
|
+
/**
|
645
|
+
* Emphasis (italic) mark for rich text formatting.
|
646
|
+
*/
|
647
|
+
export class Em extends Mark {
|
648
|
+
tag = co.literal("em");
|
649
|
+
}
|
650
|
+
|
614
651
|
/**
|
615
652
|
* Collection of predefined mark types for common text formatting.
|
616
653
|
* Includes marks for headings, paragraphs, links, and text styling.
|
617
654
|
*/
|
618
655
|
export const Marks = {
|
619
|
-
Heading
|
620
|
-
|
621
|
-
|
622
|
-
|
623
|
-
|
624
|
-
tag = co.literal("paragraph");
|
625
|
-
},
|
626
|
-
Link: class Link extends Mark {
|
627
|
-
tag = co.literal("link");
|
628
|
-
url = co.string;
|
629
|
-
},
|
630
|
-
Strong: class Strong extends Mark {
|
631
|
-
tag = co.literal("strong");
|
632
|
-
},
|
633
|
-
Em: class Italic extends Mark {
|
634
|
-
tag = co.literal("em");
|
635
|
-
},
|
656
|
+
Heading,
|
657
|
+
Paragraph,
|
658
|
+
Link,
|
659
|
+
Strong,
|
660
|
+
Em,
|
636
661
|
};
|