jazz-tools 0.17.14 → 0.18.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.svelte-kit/__package__/jazz.class.svelte.js +1 -1
- package/.svelte-kit/__package__/media/image.svelte +3 -9
- package/.svelte-kit/__package__/media/image.svelte.d.ts +1 -6
- package/.svelte-kit/__package__/media/image.svelte.d.ts.map +1 -1
- package/.svelte-kit/__package__/media/image.types.d.ts +7 -0
- package/.svelte-kit/__package__/media/image.types.d.ts.map +1 -0
- package/.svelte-kit/__package__/media/image.types.js +1 -0
- package/.svelte-kit/__package__/tests/media/image.svelte.test.js +31 -31
- package/.turbo/turbo-build.log +60 -46
- package/CHANGELOG.md +41 -0
- package/dist/better-auth/auth/client.d.ts +29 -0
- package/dist/better-auth/auth/client.d.ts.map +1 -0
- package/dist/better-auth/auth/client.js +127 -0
- package/dist/better-auth/auth/client.js.map +1 -0
- package/dist/better-auth/auth/react.d.ts +2170 -0
- package/dist/better-auth/auth/react.d.ts.map +1 -0
- package/dist/better-auth/auth/react.js +40 -0
- package/dist/better-auth/auth/react.js.map +1 -0
- package/dist/better-auth/auth/server.d.ts +14 -0
- package/dist/better-auth/auth/server.d.ts.map +1 -0
- package/dist/better-auth/auth/server.js +198 -0
- package/dist/better-auth/auth/server.js.map +1 -0
- package/dist/better-auth/auth/tests/client.test.d.ts +2 -0
- package/dist/better-auth/auth/tests/client.test.d.ts.map +1 -0
- package/dist/better-auth/auth/tests/server.test.d.ts +2 -0
- package/dist/better-auth/auth/tests/server.test.d.ts.map +1 -0
- package/dist/browser/index.js +2 -2
- package/dist/browser/index.js.map +1 -1
- package/dist/{chunk-LZOF6WP5.js → chunk-IERUTUXB.js} +1336 -1017
- package/dist/chunk-IERUTUXB.js.map +1 -0
- package/dist/index.js +18 -18
- package/dist/index.js.map +1 -1
- package/dist/inspector/{custom-element-ZSNTCECD.js → custom-element-WCY6D3QJ.js} +3 -3
- package/dist/inspector/{custom-element-ZSNTCECD.js.map → custom-element-WCY6D3QJ.js.map} +1 -1
- package/dist/inspector/index.js +1 -1
- package/dist/inspector/index.js.map +1 -1
- package/dist/inspector/register-custom-element.js +1 -1
- package/dist/media/{chunk-E5J3WLQW.js → chunk-KR2V6X2N.js} +14 -9
- package/dist/media/chunk-KR2V6X2N.js.map +1 -0
- package/dist/media/create-image.d.ts +6 -6
- package/dist/media/index.browser.d.ts +6 -6
- package/dist/media/index.browser.js +1 -1
- package/dist/media/index.d.ts +1 -1
- package/dist/media/index.js +1 -1
- package/dist/media/index.native.d.ts +6 -6
- package/dist/media/index.native.js +1 -1
- package/dist/media/utils.d.ts.map +1 -1
- package/dist/prosemirror/index.js +2 -2
- package/dist/prosemirror/index.js.map +1 -1
- package/dist/react/index.js +7 -5
- package/dist/react/index.js.map +1 -1
- package/dist/react-core/hooks.d.ts.map +1 -1
- package/dist/react-core/index.js +4675 -23
- package/dist/react-core/index.js.map +1 -1
- package/dist/react-native-core/index.js +1 -1
- package/dist/react-native-core/index.js.map +1 -1
- package/dist/svelte/jazz.class.svelte.js +1 -1
- package/dist/svelte/media/image.svelte +3 -9
- package/dist/svelte/media/image.svelte.d.ts +1 -6
- package/dist/svelte/media/image.svelte.d.ts.map +1 -1
- package/dist/svelte/media/image.types.d.ts +7 -0
- package/dist/svelte/media/image.types.d.ts.map +1 -0
- package/dist/svelte/media/image.types.js +1 -0
- package/dist/svelte/tests/media/image.svelte.test.js +31 -31
- package/dist/testing.js +18 -14
- package/dist/testing.js.map +1 -1
- package/dist/tools/coValues/CoFieldInit.d.ts +13 -0
- package/dist/tools/coValues/CoFieldInit.d.ts.map +1 -0
- package/dist/tools/coValues/CoValueBase.d.ts +18 -15
- package/dist/tools/coValues/CoValueBase.d.ts.map +1 -1
- package/dist/tools/coValues/account.d.ts +101 -46
- package/dist/tools/coValues/account.d.ts.map +1 -1
- package/dist/tools/coValues/coFeed.d.ts +78 -62
- package/dist/tools/coValues/coFeed.d.ts.map +1 -1
- package/dist/tools/coValues/coList.d.ts +212 -99
- package/dist/tools/coValues/coList.d.ts.map +1 -1
- package/dist/tools/coValues/coMap.d.ts +210 -192
- package/dist/tools/coValues/coMap.d.ts.map +1 -1
- package/dist/tools/coValues/coPlainText.d.ts +30 -22
- package/dist/tools/coValues/coPlainText.d.ts.map +1 -1
- package/dist/tools/coValues/deepLoading.d.ts +13 -13
- package/dist/tools/coValues/deepLoading.d.ts.map +1 -1
- package/dist/tools/coValues/extensions/imageDef.d.ts +1 -1
- package/dist/tools/coValues/group.d.ts +32 -32
- package/dist/tools/coValues/group.d.ts.map +1 -1
- package/dist/tools/coValues/inbox.d.ts.map +1 -1
- package/dist/tools/coValues/interfaces.d.ts +18 -17
- package/dist/tools/coValues/interfaces.d.ts.map +1 -1
- package/dist/tools/coValues/profile.d.ts +6 -5
- package/dist/tools/coValues/profile.d.ts.map +1 -1
- package/dist/tools/coValues/schemaUnion.d.ts +3 -3
- package/dist/tools/coValues/schemaUnion.d.ts.map +1 -1
- package/dist/tools/exports.d.ts +1 -1
- package/dist/tools/exports.d.ts.map +1 -1
- package/dist/tools/implementation/anonymousJazzAgent.d.ts +2 -1
- package/dist/tools/implementation/anonymousJazzAgent.d.ts.map +1 -1
- package/dist/tools/implementation/schema.d.ts +5 -5
- package/dist/tools/implementation/schema.d.ts.map +1 -1
- package/dist/tools/implementation/symbols.d.ts +2 -0
- package/dist/tools/implementation/symbols.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/schemaTypes/AccountSchema.d.ts +2 -2
- package/dist/tools/implementation/zodSchema/schemaTypes/AccountSchema.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/schemaTypes/CoFeedSchema.d.ts +6 -2
- package/dist/tools/implementation/zodSchema/schemaTypes/CoFeedSchema.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/schemaTypes/CoListSchema.d.ts +8 -3
- package/dist/tools/implementation/zodSchema/schemaTypes/CoListSchema.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/schemaTypes/CoMapSchema.d.ts +12 -7
- package/dist/tools/implementation/zodSchema/schemaTypes/CoMapSchema.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/schemaTypes/CoRecordSchema.d.ts +13 -7
- package/dist/tools/implementation/zodSchema/schemaTypes/CoRecordSchema.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/schemaTypes/FileStreamSchema.d.ts +11 -2
- package/dist/tools/implementation/zodSchema/schemaTypes/FileStreamSchema.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/schemaTypes/PlainTextSchema.d.ts +4 -0
- package/dist/tools/implementation/zodSchema/schemaTypes/PlainTextSchema.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/schemaTypes/RichTextSchema.d.ts +4 -0
- package/dist/tools/implementation/zodSchema/schemaTypes/RichTextSchema.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/typeConverters/{CoFieldInit.d.ts → CoFieldSchemaInit.d.ts} +7 -7
- package/dist/tools/implementation/zodSchema/typeConverters/CoFieldSchemaInit.d.ts.map +1 -0
- package/dist/tools/implementation/zodSchema/typeConverters/InstanceOfSchema.d.ts +4 -4
- package/dist/tools/implementation/zodSchema/typeConverters/InstanceOfSchema.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/typeConverters/InstanceOfSchemaCoValuesNullable.d.ts +4 -4
- package/dist/tools/implementation/zodSchema/typeConverters/InstanceOfSchemaCoValuesNullable.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/zodCo.d.ts +3 -3
- package/dist/tools/implementation/zodSchema/zodCo.d.ts.map +1 -1
- package/dist/tools/internal.d.ts +2 -1
- package/dist/tools/internal.d.ts.map +1 -1
- package/dist/tools/lib/migration.d.ts +1 -1
- package/dist/tools/lib/migration.d.ts.map +1 -1
- package/dist/tools/subscribe/SubscriptionScope.d.ts.map +1 -1
- package/dist/tools/subscribe/index.d.ts +1 -1
- package/dist/tools/subscribe/index.d.ts.map +1 -1
- package/dist/tools/subscribe/utils.d.ts +2 -2
- package/dist/tools/subscribe/utils.d.ts.map +1 -1
- package/dist/tools/testing.d.ts.map +1 -1
- package/dist/tools/tests/utils.d.ts +2 -6
- package/dist/tools/tests/utils.d.ts.map +1 -1
- package/dist/worker/index.js +3 -3
- package/dist/worker/index.js.map +1 -1
- package/package.json +23 -4
- package/src/better-auth/auth/client.ts +169 -0
- package/src/better-auth/auth/react.tsx +105 -0
- package/src/better-auth/auth/server.ts +250 -0
- package/src/better-auth/auth/tests/client.test.ts +249 -0
- package/src/better-auth/auth/tests/server.test.ts +226 -0
- package/src/browser/auth/PasskeyAuth.ts +2 -2
- package/src/browser/createBrowserContext.ts +2 -2
- package/src/browser/tests/PasskeyAuth.test.ts +2 -2
- package/src/inspector/custom-element.tsx +2 -2
- package/src/inspector/viewer/new-app.tsx +1 -1
- package/src/media/create-image.test.ts +7 -7
- package/src/media/create-image.ts +5 -3
- package/src/media/index.ts +1 -1
- package/src/media/utils.test.ts +72 -66
- package/src/media/utils.ts +9 -6
- package/src/prosemirror/lib/plugin.ts +1 -1
- package/src/prosemirror/lib/sync.ts +1 -1
- package/src/prosemirror/tests/plugin.test.ts +4 -4
- package/src/react/media/image.tsx +2 -2
- package/src/react/tests/media/image.test.tsx +52 -32
- package/src/react-core/hooks.ts +11 -5
- package/src/react-core/tests/useAccount.test.ts +16 -22
- package/src/react-core/tests/useCoState.test.ts +19 -19
- package/src/react-core/tests/useInboxSender.test.ts +5 -2
- package/src/react-core/tests/usePassPhraseAuth.test.ts +6 -6
- package/src/react-native-core/media/image.tsx +1 -1
- package/src/svelte/jazz.class.svelte.ts +1 -1
- package/src/svelte/media/image.svelte +3 -9
- package/src/svelte/media/image.types.ts +7 -0
- package/src/svelte/tests/media/image.svelte.test.ts +34 -32
- package/src/tools/auth/DemoAuth.ts +2 -2
- package/src/tools/auth/PassphraseAuth.ts +2 -2
- package/src/tools/auth/clerk/index.ts +2 -2
- package/src/tools/auth/clerk/tests/JazzClerkAuth.test.ts +1 -1
- package/src/tools/coValues/CoFieldInit.ts +20 -0
- package/src/tools/coValues/CoValueBase.ts +40 -60
- package/src/tools/coValues/account.ts +311 -232
- package/src/tools/coValues/coFeed.ts +185 -153
- package/src/tools/coValues/coList.ts +507 -334
- package/src/tools/coValues/coMap.ts +434 -286
- package/src/tools/coValues/coPlainText.ts +94 -110
- package/src/tools/coValues/deepLoading.ts +13 -13
- package/src/tools/coValues/group.ts +100 -114
- package/src/tools/coValues/inbox.ts +16 -14
- package/src/tools/coValues/interfaces.ts +49 -31
- package/src/tools/coValues/profile.ts +8 -6
- package/src/tools/coValues/request.ts +9 -9
- package/src/tools/coValues/schemaUnion.ts +11 -5
- package/src/tools/exports.ts +1 -1
- package/src/tools/implementation/ContextManager.ts +4 -4
- package/src/tools/implementation/anonymousJazzAgent.ts +2 -1
- package/src/tools/implementation/createContext.ts +1 -1
- package/src/tools/implementation/devtoolsFormatters.ts +9 -9
- package/src/tools/implementation/invites.ts +2 -2
- package/src/tools/implementation/schema.ts +7 -7
- package/src/tools/implementation/symbols.ts +3 -0
- package/src/tools/implementation/zodSchema/schemaTypes/AccountSchema.ts +2 -2
- package/src/tools/implementation/zodSchema/schemaTypes/CoFeedSchema.ts +11 -2
- package/src/tools/implementation/zodSchema/schemaTypes/CoListSchema.ts +18 -7
- package/src/tools/implementation/zodSchema/schemaTypes/CoMapSchema.ts +17 -7
- package/src/tools/implementation/zodSchema/schemaTypes/CoRecordSchema.ts +20 -11
- package/src/tools/implementation/zodSchema/schemaTypes/FileStreamSchema.ts +19 -2
- package/src/tools/implementation/zodSchema/schemaTypes/PlainTextSchema.ts +6 -0
- package/src/tools/implementation/zodSchema/schemaTypes/RichTextSchema.ts +6 -0
- package/src/tools/implementation/zodSchema/typeConverters/{CoFieldInit.ts → CoFieldSchemaInit.ts} +11 -11
- package/src/tools/implementation/zodSchema/typeConverters/InstanceOfSchema.ts +4 -4
- package/src/tools/implementation/zodSchema/typeConverters/InstanceOfSchemaCoValuesNullable.ts +4 -4
- package/src/tools/implementation/zodSchema/zodCo.ts +3 -3
- package/src/tools/internal.ts +2 -1
- package/src/tools/lib/migration.ts +5 -5
- package/src/tools/subscribe/SubscriptionScope.ts +32 -24
- package/src/tools/subscribe/index.ts +4 -4
- package/src/tools/subscribe/utils.ts +11 -11
- package/src/tools/testing.ts +17 -13
- package/src/tools/tests/ContextManager.test.ts +70 -59
- package/src/tools/tests/PassphraseAuth.test.ts +2 -2
- package/src/tools/tests/account.test.ts +188 -67
- package/src/tools/tests/coDiscriminatedUnion.test-d.ts +12 -6
- package/src/tools/tests/coDiscriminatedUnion.test.ts +26 -17
- package/src/tools/tests/coFeed.test-d.ts +18 -17
- package/src/tools/tests/coFeed.test.ts +108 -97
- package/src/tools/tests/coList.test-d.ts +18 -23
- package/src/tools/tests/coList.test.ts +350 -165
- package/src/tools/tests/coMap.record.test-d.ts +9 -13
- package/src/tools/tests/coMap.record.test.ts +37 -23
- package/src/tools/tests/coMap.test-d.ts +43 -21
- package/src/tools/tests/coMap.test.ts +459 -182
- package/src/tools/tests/coOptional.test.ts +28 -13
- package/src/tools/tests/coPlainText.test.ts +15 -15
- package/src/tools/tests/createContext.test.ts +14 -14
- package/src/tools/tests/deepLoading.test.ts +95 -94
- package/src/tools/tests/exportImport.test.ts +61 -41
- package/src/tools/tests/groupsAndAccounts.test.ts +333 -116
- package/src/tools/tests/inbox.test.ts +22 -17
- package/src/tools/tests/interfaces.test.ts +12 -11
- package/src/tools/tests/invites.test.ts +6 -4
- package/src/tools/tests/load.test.ts +20 -18
- package/src/tools/tests/patterns/notifications.test.ts +7 -7
- package/src/tools/tests/patterns/quest.test.ts +3 -3
- package/src/tools/tests/patterns/requestToJoin.test.ts +22 -22
- package/src/tools/tests/request.test.ts +38 -39
- package/src/tools/tests/schemaUnion.test.ts +64 -10
- package/src/tools/tests/subscribe.test.ts +64 -64
- package/src/tools/tests/testing.test.ts +7 -11
- package/src/tools/tests/utils.ts +3 -3
- package/src/tools/tests/zod.test.ts +3 -3
- package/src/worker/index.ts +3 -3
- package/tsup.config.ts +9 -0
- package/dist/chunk-LZOF6WP5.js.map +0 -1
- package/dist/media/chunk-E5J3WLQW.js.map +0 -1
- package/dist/tools/implementation/zodSchema/typeConverters/CoFieldInit.d.ts.map +0 -1
@@ -6,8 +6,7 @@ import type {
|
|
6
6
|
RawGroup,
|
7
7
|
Role,
|
8
8
|
} from "cojson";
|
9
|
-
import
|
10
|
-
CoMap,
|
9
|
+
import {
|
11
10
|
CoValue,
|
12
11
|
CoValueClass,
|
13
12
|
ID,
|
@@ -15,15 +14,15 @@ import type {
|
|
15
14
|
RefsToResolve,
|
16
15
|
RefsToResolveStrict,
|
17
16
|
Resolved,
|
18
|
-
Schema,
|
19
17
|
SubscribeListenerOptions,
|
20
18
|
SubscribeRestArgs,
|
19
|
+
TypeSym,
|
21
20
|
} from "../internal.js";
|
22
21
|
import {
|
23
22
|
Account,
|
24
23
|
AccountAndGroupProxyHandler,
|
25
24
|
CoValueBase,
|
26
|
-
|
25
|
+
CoValueJazzApi,
|
27
26
|
Ref,
|
28
27
|
RegisteredSchemas,
|
29
28
|
accessChildById,
|
@@ -37,73 +36,23 @@ import {
|
|
37
36
|
subscribeToExistingCoValue,
|
38
37
|
} from "../internal.js";
|
39
38
|
|
39
|
+
type GroupMember = {
|
40
|
+
id: string;
|
41
|
+
role: AccountRole;
|
42
|
+
ref: Ref<Account>;
|
43
|
+
account: Account;
|
44
|
+
};
|
45
|
+
|
40
46
|
/** @category Identity & Permissions */
|
41
47
|
export class Group extends CoValueBase implements CoValue {
|
42
|
-
declare
|
43
|
-
declare _type: "Group";
|
44
|
-
static {
|
45
|
-
this.prototype._type = "Group";
|
46
|
-
}
|
47
|
-
declare _raw: RawGroup;
|
48
|
-
|
49
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
50
|
-
static _schema: any;
|
51
|
-
get _schema(): {
|
52
|
-
profile: Schema;
|
53
|
-
root: Schema;
|
54
|
-
} {
|
55
|
-
return (this.constructor as typeof Group)._schema;
|
56
|
-
}
|
48
|
+
declare [TypeSym]: "Group";
|
57
49
|
static {
|
58
|
-
this.
|
59
|
-
profile: "json" satisfies Schema,
|
60
|
-
root: "json" satisfies Schema,
|
61
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
62
|
-
} as any;
|
63
|
-
Object.defineProperty(this.prototype, "_schema", {
|
64
|
-
get: () => this._schema,
|
65
|
-
});
|
66
|
-
}
|
67
|
-
|
68
|
-
declare profile: Profile | null;
|
69
|
-
declare root: CoMap | null;
|
70
|
-
|
71
|
-
get _refs(): {
|
72
|
-
profile: Ref<Profile> | undefined;
|
73
|
-
root: Ref<CoMap> | undefined;
|
74
|
-
} {
|
75
|
-
const profileID = this._raw.get("profile") as unknown as
|
76
|
-
| ID<NonNullable<this["profile"]>>
|
77
|
-
| undefined;
|
78
|
-
const rootID = this._raw.get("root") as unknown as
|
79
|
-
| ID<NonNullable<this["root"]>>
|
80
|
-
| undefined;
|
81
|
-
return {
|
82
|
-
profile: profileID
|
83
|
-
? (new Ref(
|
84
|
-
profileID,
|
85
|
-
this._loadedAs,
|
86
|
-
this._schema.profile as RefEncoded<NonNullable<this["profile"]>>,
|
87
|
-
this,
|
88
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
89
|
-
) as any as this["profile"] extends Profile
|
90
|
-
? Ref<this["profile"]>
|
91
|
-
: never)
|
92
|
-
: undefined,
|
93
|
-
root: rootID
|
94
|
-
? (new Ref(
|
95
|
-
rootID,
|
96
|
-
this._loadedAs,
|
97
|
-
this._schema.root as RefEncoded<NonNullable<this["root"]>>,
|
98
|
-
this,
|
99
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
100
|
-
) as any as this["root"] extends CoMap ? Ref<this["root"]> : never)
|
101
|
-
: undefined,
|
102
|
-
};
|
50
|
+
this.prototype[TypeSym] = "Group";
|
103
51
|
}
|
52
|
+
declare $jazz: GroupJazzApi<this>;
|
104
53
|
|
105
54
|
/** @deprecated Don't use constructor directly, use .create */
|
106
|
-
constructor(options: { fromRaw: RawGroup } | { owner: Account
|
55
|
+
constructor(options: { fromRaw: RawGroup } | { owner: Account }) {
|
107
56
|
super();
|
108
57
|
let raw: RawGroup;
|
109
58
|
|
@@ -112,23 +61,27 @@ export class Group extends CoValueBase implements CoValue {
|
|
112
61
|
} else {
|
113
62
|
const initOwner = options.owner;
|
114
63
|
if (!initOwner) throw new Error("No owner provided");
|
115
|
-
if (initOwner
|
116
|
-
const rawOwner = initOwner.
|
64
|
+
if (initOwner[TypeSym] === "Account" && isControlledAccount(initOwner)) {
|
65
|
+
const rawOwner = initOwner.$jazz.raw;
|
117
66
|
raw = rawOwner.core.node.createGroup();
|
118
67
|
} else {
|
119
68
|
throw new Error("Can only construct group as a controlled account");
|
120
69
|
}
|
121
70
|
}
|
122
71
|
|
72
|
+
const proxy = new Proxy(
|
73
|
+
this,
|
74
|
+
AccountAndGroupProxyHandler as ProxyHandler<this>,
|
75
|
+
);
|
76
|
+
|
123
77
|
Object.defineProperties(this, {
|
124
|
-
|
125
|
-
value: raw
|
78
|
+
$jazz: {
|
79
|
+
value: new GroupJazzApi(proxy, raw),
|
126
80
|
enumerable: false,
|
127
81
|
},
|
128
|
-
_raw: { value: raw, enumerable: false },
|
129
82
|
});
|
130
83
|
|
131
|
-
return
|
84
|
+
return proxy;
|
132
85
|
}
|
133
86
|
|
134
87
|
static create<G extends Group>(
|
@@ -139,7 +92,7 @@ export class Group extends CoValueBase implements CoValue {
|
|
139
92
|
}
|
140
93
|
|
141
94
|
myRole(): Role | undefined {
|
142
|
-
return this.
|
95
|
+
return this.$jazz.raw.myRole();
|
143
96
|
}
|
144
97
|
|
145
98
|
addMember(member: Everyone, role: "writer" | "reader" | "writeOnly"): void;
|
@@ -158,12 +111,15 @@ export class Group extends CoValueBase implements CoValue {
|
|
158
111
|
member: Group | Everyone | Account,
|
159
112
|
role?: AccountRole | "inherit",
|
160
113
|
) {
|
161
|
-
if (member !== "everyone" && member
|
114
|
+
if (member !== "everyone" && member[TypeSym] === "Group") {
|
162
115
|
if (role === "writeOnly")
|
163
116
|
throw new Error("Cannot add group as member with write-only role");
|
164
|
-
this.
|
117
|
+
this.$jazz.raw.extend(member.$jazz.raw, role);
|
165
118
|
} else if (role !== undefined && role !== "inherit") {
|
166
|
-
this.
|
119
|
+
this.$jazz.raw.addMember(
|
120
|
+
member === "everyone" ? member : member.$jazz.raw,
|
121
|
+
role,
|
122
|
+
);
|
167
123
|
}
|
168
124
|
}
|
169
125
|
|
@@ -174,23 +130,18 @@ export class Group extends CoValueBase implements CoValue {
|
|
174
130
|
*/
|
175
131
|
removeMember(member: Group): void;
|
176
132
|
removeMember(member: Group | Everyone | Account) {
|
177
|
-
if (member !== "everyone" && member
|
178
|
-
this.
|
133
|
+
if (member !== "everyone" && member[TypeSym] === "Group") {
|
134
|
+
this.$jazz.raw.revokeExtend(member.$jazz.raw);
|
179
135
|
} else {
|
180
|
-
return this.
|
181
|
-
member === "everyone" ? member : member.
|
136
|
+
return this.$jazz.raw.removeMember(
|
137
|
+
member === "everyone" ? member : member.$jazz.raw,
|
182
138
|
);
|
183
139
|
}
|
184
140
|
}
|
185
141
|
|
186
142
|
private getMembersFromKeys(
|
187
143
|
accountIDs: Iterable<RawAccountID | AgentID>,
|
188
|
-
):
|
189
|
-
id: string;
|
190
|
-
role: AccountRole;
|
191
|
-
ref: Ref<Account>;
|
192
|
-
account: Account;
|
193
|
-
}> {
|
144
|
+
): GroupMember[] {
|
194
145
|
const members = [];
|
195
146
|
|
196
147
|
const refEncodedAccountSchema = {
|
@@ -201,7 +152,7 @@ export class Group extends CoValueBase implements CoValue {
|
|
201
152
|
for (const accountID of accountIDs) {
|
202
153
|
if (!isAccountID(accountID)) continue;
|
203
154
|
|
204
|
-
const role = this.
|
155
|
+
const role = this.$jazz.raw.roleOf(accountID);
|
205
156
|
|
206
157
|
if (
|
207
158
|
role === "admin" ||
|
@@ -211,7 +162,7 @@ export class Group extends CoValueBase implements CoValue {
|
|
211
162
|
) {
|
212
163
|
const ref = new Ref<Account>(
|
213
164
|
accountID,
|
214
|
-
this.
|
165
|
+
this.$jazz.loadedAs,
|
215
166
|
refEncodedAccountSchema,
|
216
167
|
this,
|
217
168
|
);
|
@@ -242,8 +193,8 @@ export class Group extends CoValueBase implements CoValue {
|
|
242
193
|
*
|
243
194
|
* @returns The members of the group.
|
244
195
|
*/
|
245
|
-
get members() {
|
246
|
-
return this.getMembersFromKeys(this.
|
196
|
+
get members(): GroupMember[] {
|
197
|
+
return this.getMembersFromKeys(this.$jazz.raw.getAllMemberKeysSet());
|
247
198
|
}
|
248
199
|
|
249
200
|
/**
|
@@ -253,20 +204,18 @@ export class Group extends CoValueBase implements CoValue {
|
|
253
204
|
* parent groups, use {@link Group.members|members} instead.
|
254
205
|
* @returns The direct members of the group.
|
255
206
|
*/
|
256
|
-
getDirectMembers() {
|
257
|
-
return this.getMembersFromKeys(this.
|
207
|
+
getDirectMembers(): GroupMember[] {
|
208
|
+
return this.getMembersFromKeys(this.$jazz.raw.getMemberKeys());
|
258
209
|
}
|
259
210
|
|
260
|
-
getRoleOf(member: Everyone | ID<Account> | "me") {
|
261
|
-
|
262
|
-
|
263
|
-
activeAccountContext.get().id as
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
return this.
|
268
|
-
member === "everyone" ? member : (member as unknown as RawAccountID),
|
269
|
-
);
|
211
|
+
getRoleOf(member: Everyone | ID<Account> | "me"): Role | undefined {
|
212
|
+
const accountId =
|
213
|
+
member === "me"
|
214
|
+
? (activeAccountContext.get().$jazz.id as RawAccountID)
|
215
|
+
: member === "everyone"
|
216
|
+
? member
|
217
|
+
: (member as RawAccountID);
|
218
|
+
return this.$jazz.raw.roleOf(accountId);
|
270
219
|
}
|
271
220
|
|
272
221
|
/**
|
@@ -276,13 +225,15 @@ export class Group extends CoValueBase implements CoValue {
|
|
276
225
|
* @param role - Optional: the role to grant to everyone. Defaults to "reader".
|
277
226
|
* @returns The group itself.
|
278
227
|
*/
|
279
|
-
makePublic(role: "reader" | "writer" = "reader") {
|
228
|
+
makePublic(role: "reader" | "writer" = "reader"): this {
|
280
229
|
this.addMember("everyone", role);
|
281
230
|
return this;
|
282
231
|
}
|
283
232
|
|
284
233
|
getParentGroups(): Array<Group> {
|
285
|
-
return this.
|
234
|
+
return this.$jazz.raw
|
235
|
+
.getParentGroups()
|
236
|
+
.map((group) => Group.fromRaw(group));
|
286
237
|
}
|
287
238
|
|
288
239
|
/** @category Identity & Permissions
|
@@ -295,8 +246,8 @@ export class Group extends CoValueBase implements CoValue {
|
|
295
246
|
extend(
|
296
247
|
parent: Group,
|
297
248
|
roleMapping?: "reader" | "writer" | "admin" | "inherit",
|
298
|
-
) {
|
299
|
-
this.
|
249
|
+
): this {
|
250
|
+
this.$jazz.raw.extend(parent.$jazz.raw, roleMapping);
|
300
251
|
return this;
|
301
252
|
}
|
302
253
|
|
@@ -306,8 +257,8 @@ export class Group extends CoValueBase implements CoValue {
|
|
306
257
|
* @param parent The group that will lose access to this group.
|
307
258
|
* @returns This group.
|
308
259
|
*/
|
309
|
-
async revokeExtend(parent: Group) {
|
310
|
-
await this.
|
260
|
+
async revokeExtend(parent: Group): Promise<this> {
|
261
|
+
await this.$jazz.raw.revokeExtend(parent.$jazz.raw);
|
311
262
|
return this;
|
312
263
|
}
|
313
264
|
|
@@ -340,31 +291,55 @@ export class Group extends CoValueBase implements CoValue {
|
|
340
291
|
const { options, listener } = parseSubscribeRestArgs(args);
|
341
292
|
return subscribeToCoValueWithoutMe<G, R>(this, id, options, listener);
|
342
293
|
}
|
294
|
+
}
|
295
|
+
|
296
|
+
export class GroupJazzApi<G extends Group> extends CoValueJazzApi<G> {
|
297
|
+
constructor(
|
298
|
+
private group: G,
|
299
|
+
public raw: RawGroup,
|
300
|
+
) {
|
301
|
+
super(group);
|
302
|
+
}
|
303
|
+
|
304
|
+
/**
|
305
|
+
* The ID of this `Group`
|
306
|
+
* @category Content
|
307
|
+
*/
|
308
|
+
get id(): ID<G> {
|
309
|
+
return this.raw.id;
|
310
|
+
}
|
311
|
+
|
312
|
+
/**
|
313
|
+
* Groups have no owner. They can be accessed by everyone.
|
314
|
+
*/
|
315
|
+
get owner(): undefined {
|
316
|
+
return undefined;
|
317
|
+
}
|
343
318
|
|
344
319
|
/** @category Subscription & Loading */
|
345
320
|
ensureLoaded<G extends Group, const R extends RefsToResolve<G>>(
|
346
|
-
this: G
|
321
|
+
this: GroupJazzApi<G>,
|
347
322
|
options?: { resolve?: RefsToResolveStrict<G, R> },
|
348
323
|
): Promise<Resolved<G, R>> {
|
349
|
-
return ensureCoValueLoaded(this, options);
|
324
|
+
return ensureCoValueLoaded(this.group, options);
|
350
325
|
}
|
351
326
|
|
352
327
|
/** @category Subscription & Loading */
|
353
328
|
subscribe<G extends Group, const R extends RefsToResolve<G>>(
|
354
|
-
this: G
|
329
|
+
this: GroupJazzApi<G>,
|
355
330
|
listener: (value: Resolved<G, R>, unsubscribe: () => void) => void,
|
356
331
|
): () => void;
|
357
332
|
subscribe<G extends Group, const R extends RefsToResolve<G>>(
|
358
|
-
this: G
|
333
|
+
this: GroupJazzApi<G>,
|
359
334
|
options: { resolve?: RefsToResolveStrict<G, R> },
|
360
335
|
listener: (value: Resolved<G, R>, unsubscribe: () => void) => void,
|
361
336
|
): () => void;
|
362
337
|
subscribe<G extends Group, const R extends RefsToResolve<G>>(
|
363
|
-
this: G
|
338
|
+
this: GroupJazzApi<G>,
|
364
339
|
...args: SubscribeRestArgs<G, R>
|
365
340
|
): () => void {
|
366
341
|
const { options, listener } = parseSubscribeRestArgs(args);
|
367
|
-
return subscribeToExistingCoValue(this, options, listener);
|
342
|
+
return subscribeToExistingCoValue(this.group, options, listener);
|
368
343
|
}
|
369
344
|
|
370
345
|
/**
|
@@ -373,7 +348,7 @@ export class Group extends CoValueBase implements CoValue {
|
|
373
348
|
* @category Subscription & Loading
|
374
349
|
*/
|
375
350
|
waitForSync(options?: { timeout?: number }) {
|
376
|
-
return this.
|
351
|
+
return this.raw.core.waitForSync(options);
|
377
352
|
}
|
378
353
|
}
|
379
354
|
|
@@ -382,3 +357,14 @@ RegisteredSchemas["Group"] = Group;
|
|
382
357
|
export function isAccountID(id: RawAccountID | AgentID): id is RawAccountID {
|
383
358
|
return id.startsWith("co_");
|
384
359
|
}
|
360
|
+
|
361
|
+
export function getCoValueOwner(coValue: CoValue): Group {
|
362
|
+
const group = accessChildById(coValue, coValue.$jazz.raw.group.id, {
|
363
|
+
ref: RegisteredSchemas["Group"],
|
364
|
+
optional: false,
|
365
|
+
});
|
366
|
+
if (!group) {
|
367
|
+
throw new Error("CoValue has no owner");
|
368
|
+
}
|
369
|
+
return group;
|
370
|
+
}
|
@@ -29,11 +29,11 @@ export type InboxRoot = RawCoMap<{
|
|
29
29
|
}>;
|
30
30
|
|
31
31
|
export function createInboxRoot(account: Account) {
|
32
|
-
if (!account.isLocalNodeOwner) {
|
32
|
+
if (!account.$jazz.isLocalNodeOwner) {
|
33
33
|
throw new Error("Account is not controlled");
|
34
34
|
}
|
35
35
|
|
36
|
-
const rawAccount = account.
|
36
|
+
const rawAccount = account.$jazz.raw;
|
37
37
|
|
38
38
|
const group = rawAccount.core.node.createGroup();
|
39
39
|
const messagesFeed = group.createStream<MessagesStream>();
|
@@ -66,7 +66,7 @@ async function createInboxMessage<
|
|
66
66
|
I extends CoValue,
|
67
67
|
O extends CoValue | undefined,
|
68
68
|
>(payload: I, inboxOwner: RawAccount) {
|
69
|
-
const group = payload.
|
69
|
+
const group = payload.$jazz.raw.group;
|
70
70
|
|
71
71
|
if (group instanceof RawAccount) {
|
72
72
|
throw new Error("Inbox messages should be owned by a group");
|
@@ -75,13 +75,13 @@ async function createInboxMessage<
|
|
75
75
|
group.addMember(inboxOwner, "writer");
|
76
76
|
|
77
77
|
const message = group.createMap<InboxMessage<I, O>>({
|
78
|
-
payload: payload.id,
|
78
|
+
payload: payload.$jazz.id,
|
79
79
|
result: undefined,
|
80
80
|
processed: false,
|
81
81
|
error: undefined,
|
82
82
|
});
|
83
83
|
|
84
|
-
await payload.
|
84
|
+
await payload.$jazz.raw.core.waitForSync();
|
85
85
|
await message.core.waitForSync();
|
86
86
|
|
87
87
|
return message;
|
@@ -119,7 +119,7 @@ export class Inbox {
|
|
119
119
|
) {
|
120
120
|
const processed = new Set<`${SessionID}/${number}`>();
|
121
121
|
const failed = new Map<`${SessionID}/${number}`, string[]>();
|
122
|
-
const node = this.account.
|
122
|
+
const node = this.account.$jazz.localNode;
|
123
123
|
|
124
124
|
this.processed.subscribe((stream) => {
|
125
125
|
for (const items of Object.values(stream.items)) {
|
@@ -194,7 +194,7 @@ export class Inbox {
|
|
194
194
|
.getCurrentContent() as RawCoMap;
|
195
195
|
|
196
196
|
if (result) {
|
197
|
-
inboxMessage.set("result", result.id);
|
197
|
+
inboxMessage.set("result", result.$jazz.id);
|
198
198
|
}
|
199
199
|
|
200
200
|
inboxMessage.set("processed", true);
|
@@ -258,7 +258,7 @@ export class Inbox {
|
|
258
258
|
throw new Error("The account has not set up their inbox");
|
259
259
|
}
|
260
260
|
|
261
|
-
const node = account.
|
261
|
+
const node = account.$jazz.localNode;
|
262
262
|
|
263
263
|
const root = await node.load(profile.inbox as CoID<InboxRoot>);
|
264
264
|
|
@@ -332,7 +332,7 @@ export class InboxSender<I extends CoValue, O extends CoValue | undefined> {
|
|
332
332
|
>(inboxOwnerID: ID<Account>, currentAccount?: Account) {
|
333
333
|
currentAccount ||= activeAccountContext.get();
|
334
334
|
|
335
|
-
const node = currentAccount.
|
335
|
+
const node = currentAccount.$jazz.localNode;
|
336
336
|
|
337
337
|
const inboxOwnerRaw = await node.load(
|
338
338
|
inboxOwnerID as unknown as CoID<RawAccount>,
|
@@ -349,9 +349,11 @@ export class InboxSender<I extends CoValue, O extends CoValue | undefined> {
|
|
349
349
|
}
|
350
350
|
|
351
351
|
if (
|
352
|
-
inboxOwnerProfileRaw.group.roleOf(currentAccount.
|
353
|
-
|
354
|
-
inboxOwnerProfileRaw.group.roleOf(currentAccount.
|
352
|
+
inboxOwnerProfileRaw.group.roleOf(currentAccount.$jazz.raw.id) !==
|
353
|
+
"reader" &&
|
354
|
+
inboxOwnerProfileRaw.group.roleOf(currentAccount.$jazz.raw.id) !==
|
355
|
+
"writer" &&
|
356
|
+
inboxOwnerProfileRaw.group.roleOf(currentAccount.$jazz.raw.id) !== "admin"
|
355
357
|
) {
|
356
358
|
throw new Error(
|
357
359
|
"Insufficient permissions to access the inbox, make sure its user profile is publicly readable.",
|
@@ -387,11 +389,11 @@ async function acceptInvite(invite: string, account?: Account) {
|
|
387
389
|
throw new Error("Invalid inbox ticket");
|
388
390
|
}
|
389
391
|
|
390
|
-
if (!account.isLocalNodeOwner) {
|
392
|
+
if (!account.$jazz.isLocalNodeOwner) {
|
391
393
|
throw new Error("Account is not controlled");
|
392
394
|
}
|
393
395
|
|
394
|
-
await account.
|
396
|
+
await account.$jazz.localNode.acceptInvite(id, inviteSecret);
|
395
397
|
|
396
398
|
return id;
|
397
399
|
}
|
@@ -18,6 +18,7 @@ import {
|
|
18
18
|
Resolved,
|
19
19
|
SubscriptionScope,
|
20
20
|
type SubscriptionValue,
|
21
|
+
TypeSym,
|
21
22
|
activeAccountContext,
|
22
23
|
coValueClassFromCoValueClassOrSchema,
|
23
24
|
inspect,
|
@@ -32,26 +33,28 @@ export interface CoValueClass<Value extends CoValue = CoValue> {
|
|
32
33
|
}
|
33
34
|
|
34
35
|
export interface CoValueFromRaw<V extends CoValue> {
|
35
|
-
fromRaw(raw: V["
|
36
|
+
fromRaw(raw: V["$jazz"]["raw"]): V;
|
36
37
|
}
|
37
38
|
|
38
39
|
/** @category Abstract interfaces */
|
39
40
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
40
41
|
export interface CoValue {
|
41
|
-
/** @category Content */
|
42
|
-
readonly id: ID<this>;
|
43
42
|
/** @category Type Helpers */
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
43
|
+
[TypeSym]: string;
|
44
|
+
|
45
|
+
$jazz: {
|
46
|
+
/** @category Content */
|
47
|
+
readonly id: ID<CoValue>;
|
48
|
+
/** @category Collaboration */
|
49
|
+
owner?: Group;
|
50
|
+
/** @internal */
|
51
|
+
readonly loadedAs: Account | AnonymousJazzAgent;
|
52
|
+
/** @category Internals */
|
53
|
+
raw: RawCoValue;
|
54
|
+
/** @internal */
|
55
|
+
_subscriptionScope?: SubscriptionScope<CoValue>;
|
56
|
+
};
|
52
57
|
|
53
|
-
/** @internal */
|
54
|
-
readonly _loadedAs: Account | AnonymousJazzAgent;
|
55
58
|
/** @category Stringifying & Inspection */
|
56
59
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
57
60
|
toJSON(key?: string, seenAbove?: ID<CoValue>[]): any[] | object | string;
|
@@ -62,7 +65,7 @@ export interface CoValue {
|
|
62
65
|
|
63
66
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
64
67
|
export function isCoValue(value: any): value is CoValue {
|
65
|
-
return value && value
|
68
|
+
return value && value[TypeSym] !== undefined;
|
66
69
|
}
|
67
70
|
|
68
71
|
export function isCoValueClass<V extends CoValue>(
|
@@ -149,15 +152,15 @@ export async function ensureCoValueLoaded<
|
|
149
152
|
): Promise<Resolved<V, R>> {
|
150
153
|
const response = await loadCoValue(
|
151
154
|
existing.constructor as CoValueClass<V>,
|
152
|
-
existing.id,
|
155
|
+
existing.$jazz.id,
|
153
156
|
{
|
154
|
-
loadAs: existing.
|
157
|
+
loadAs: existing.$jazz.loadedAs,
|
155
158
|
resolve: options?.resolve,
|
156
159
|
},
|
157
160
|
);
|
158
161
|
|
159
162
|
if (!response) {
|
160
|
-
throw new Error("Failed to deeply load CoValue " + existing.id);
|
163
|
+
throw new Error("Failed to deeply load CoValue " + existing.$jazz.id);
|
161
164
|
}
|
162
165
|
|
163
166
|
return response;
|
@@ -255,7 +258,7 @@ export function subscribeToCoValue<
|
|
255
258
|
listener: SubscribeListener<V, R>,
|
256
259
|
): () => void {
|
257
260
|
const loadAs = options.loadAs ?? activeAccountContext.get();
|
258
|
-
const node = "node" in loadAs ? loadAs.node : loadAs.
|
261
|
+
const node = "node" in loadAs ? loadAs.node : loadAs.$jazz.localNode;
|
259
262
|
|
260
263
|
const resolve = options.resolve ?? true;
|
261
264
|
|
@@ -325,9 +328,9 @@ export function subscribeToExistingCoValue<
|
|
325
328
|
): () => void {
|
326
329
|
return subscribeToCoValue(
|
327
330
|
existing.constructor as CoValueClass<V>,
|
328
|
-
existing.id,
|
331
|
+
existing.$jazz.id,
|
329
332
|
{
|
330
|
-
loadAs: existing.
|
333
|
+
loadAs: existing.$jazz.loadedAs,
|
331
334
|
resolve: options?.resolve,
|
332
335
|
onUnavailable: options?.onUnavailable,
|
333
336
|
onUnauthorized: options?.onUnauthorized,
|
@@ -341,7 +344,7 @@ export function isAccountInstance(instance: unknown): instance is Account {
|
|
341
344
|
return false;
|
342
345
|
}
|
343
346
|
|
344
|
-
return
|
347
|
+
return TypeSym in instance && instance[TypeSym] === "Account";
|
345
348
|
}
|
346
349
|
|
347
350
|
export function isAnonymousAgentInstance(
|
@@ -351,7 +354,7 @@ export function isAnonymousAgentInstance(
|
|
351
354
|
return false;
|
352
355
|
}
|
353
356
|
|
354
|
-
return
|
357
|
+
return TypeSym in instance && instance[TypeSym] === "Anonymous";
|
355
358
|
}
|
356
359
|
|
357
360
|
export function parseCoValueCreateOptions(
|
@@ -363,15 +366,20 @@ export function parseCoValueCreateOptions(
|
|
363
366
|
| Account
|
364
367
|
| Group
|
365
368
|
| undefined,
|
366
|
-
) {
|
369
|
+
): {
|
370
|
+
owner: Group;
|
371
|
+
uniqueness?: CoValueUniqueness;
|
372
|
+
} {
|
367
373
|
const Group = RegisteredSchemas["Group"];
|
368
374
|
|
369
375
|
if (!options) {
|
370
376
|
return { owner: Group.create(), uniqueness: undefined };
|
371
377
|
}
|
372
378
|
|
373
|
-
if (
|
374
|
-
if (options
|
379
|
+
if (TypeSym in options) {
|
380
|
+
if (options[TypeSym] === "Account") {
|
381
|
+
return { owner: accountOrGroupToGroup(options), uniqueness: undefined };
|
382
|
+
} else if (options[TypeSym] === "Group") {
|
375
383
|
return { owner: options, uniqueness: undefined };
|
376
384
|
}
|
377
385
|
}
|
@@ -380,10 +388,20 @@ export function parseCoValueCreateOptions(
|
|
380
388
|
? { uniqueness: options.unique }
|
381
389
|
: undefined;
|
382
390
|
|
383
|
-
|
384
|
-
owner: options.owner
|
391
|
+
const opts = {
|
392
|
+
owner: options.owner
|
393
|
+
? accountOrGroupToGroup(options.owner)
|
394
|
+
: Group.create(),
|
385
395
|
uniqueness,
|
386
396
|
};
|
397
|
+
return opts;
|
398
|
+
}
|
399
|
+
|
400
|
+
export function accountOrGroupToGroup(accountOrGroup: Account | Group): Group {
|
401
|
+
if (accountOrGroup[TypeSym] === "Group") {
|
402
|
+
return accountOrGroup;
|
403
|
+
}
|
404
|
+
return RegisteredSchemas["Group"].fromRaw(accountOrGroup.$jazz.raw);
|
387
405
|
}
|
388
406
|
|
389
407
|
export function parseGroupCreateOptions(
|
@@ -398,7 +416,7 @@ export function parseGroupCreateOptions(
|
|
398
416
|
return { owner: activeAccountContext.get() };
|
399
417
|
}
|
400
418
|
|
401
|
-
return
|
419
|
+
return TypeSym in options && isAccountInstance(options)
|
402
420
|
? { owner: options }
|
403
421
|
: { owner: options.owner ?? activeAccountContext.get() };
|
404
422
|
}
|
@@ -460,7 +478,7 @@ export async function exportCoValue<
|
|
460
478
|
},
|
461
479
|
) {
|
462
480
|
const loadAs = options.loadAs ?? activeAccountContext.get();
|
463
|
-
const node = "node" in loadAs ? loadAs.node : loadAs.
|
481
|
+
const node = "node" in loadAs ? loadAs.node : loadAs.$jazz.localNode;
|
464
482
|
|
465
483
|
const resolve = options.resolve ?? true;
|
466
484
|
|
@@ -515,7 +533,7 @@ function loadContentPiecesFromSubscription(
|
|
515
533
|
|
516
534
|
valuesExported.add(subscription.id);
|
517
535
|
|
518
|
-
const core = subscription.getCurrentValue()
|
536
|
+
const core = subscription.getCurrentValue()?.$jazz.raw
|
519
537
|
.core as AvailableCoValueCore;
|
520
538
|
|
521
539
|
if (core) {
|
@@ -563,7 +581,7 @@ export function importContentPieces(
|
|
563
581
|
loadAs?: Account | AnonymousJazzAgent,
|
564
582
|
) {
|
565
583
|
const account = loadAs ?? Account.getMe();
|
566
|
-
const node = "node" in account ? account.node : account.
|
584
|
+
const node = "node" in account ? account.node : account.$jazz.localNode;
|
567
585
|
|
568
586
|
for (const piece of contentPieces) {
|
569
587
|
node.syncManager.handleNewContent(piece, "import");
|