jazz-tools 0.13.25 → 0.13.26
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 +5 -5
- package/CHANGELOG.md +6 -0
- package/dist/{chunk-Z6IXFGH3.js → chunk-E4PALNK7.js} +4 -5
- package/dist/chunk-E4PALNK7.js.map +1 -0
- package/dist/index.js +1 -1
- package/dist/subscribe/utils.d.ts.map +1 -1
- package/dist/testing.js +1 -1
- package/package.json +1 -1
- package/src/subscribe/SubscriptionScope.ts +3 -3
- package/src/subscribe/utils.ts +3 -3
- package/src/tests/account.test.ts +42 -1
- package/dist/chunk-Z6IXFGH3.js.map +0 -1
package/dist/index.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/subscribe/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,UAAU,
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/subscribe/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,UAAU,EAAE,MAAM,QAAQ,CAAC;AAEhD,OAAO,EAAE,OAAO,EAAE,UAAU,EAAyB,MAAM,gBAAgB,CAAC;AAE5E,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAE3D,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,UAAU,mEAQnD;AAED,wBAAgB,aAAa,CAAC,CAAC,SAAS,OAAO,EAC7C,GAAG,EAAE,UAAU,CAAC,CAAC,CAAC,EAClB,GAAG,EAAE,UAAU,EACf,iBAAiB,EAAE,iBAAiB,CAAC,CAAC,CAAC;;;;EAgBxC"}
|
package/dist/testing.js
CHANGED
package/package.json
CHANGED
@@ -72,12 +72,12 @@ export class SubscriptionScope<D extends CoValue> {
|
|
72
72
|
return;
|
73
73
|
}
|
74
74
|
|
75
|
-
const owner = getOwnerFromRawValue(update);
|
76
|
-
|
77
75
|
const ruleset = update.core.verified.header.ruleset;
|
78
76
|
|
79
77
|
// Groups and accounts are accessible by everyone, for the other coValues we use the role to check access
|
80
|
-
const hasAccess =
|
78
|
+
const hasAccess =
|
79
|
+
ruleset.type !== "ownedByGroup" ||
|
80
|
+
getOwnerFromRawValue(update).myRole() !== undefined;
|
81
81
|
|
82
82
|
if (!hasAccess) {
|
83
83
|
if (this.value.type !== "unauthorized") {
|
package/src/subscribe/utils.ts
CHANGED
@@ -1,13 +1,13 @@
|
|
1
|
-
import { RawAccount, RawCoValue
|
1
|
+
import { RawAccount, RawCoValue } from "cojson";
|
2
2
|
import { RegisteredSchemas } from "../coValues/registeredSchemas.js";
|
3
3
|
import { CoValue, RefEncoded, instantiateRefEncoded } from "../internal.js";
|
4
4
|
import { coValuesCache } from "../lib/cache.js";
|
5
5
|
import { SubscriptionScope } from "./SubscriptionScope.js";
|
6
6
|
|
7
7
|
export function getOwnerFromRawValue(raw: RawCoValue) {
|
8
|
-
|
8
|
+
const owner = raw.group;
|
9
9
|
|
10
|
-
return coValuesCache.get(owner
|
10
|
+
return coValuesCache.get(owner, () =>
|
11
11
|
owner instanceof RawAccount
|
12
12
|
? RegisteredSchemas["Account"].fromRaw(owner)
|
13
13
|
: RegisteredSchemas["Group"].fromRaw(owner as any),
|
@@ -1,12 +1,18 @@
|
|
1
|
-
import {
|
1
|
+
import { LocalNode } from "cojson";
|
2
|
+
import { assert, beforeEach, expect, test } from "vitest";
|
2
3
|
import { Account, CoMap, Group, co } from "../exports.js";
|
3
4
|
import {
|
4
5
|
createJazzTestAccount,
|
5
6
|
linkAccounts,
|
6
7
|
setActiveAccount,
|
8
|
+
setupJazzTestSync,
|
7
9
|
} from "../testing.js";
|
8
10
|
import { setupTwoNodes } from "./utils.js";
|
9
11
|
|
12
|
+
beforeEach(async () => {
|
13
|
+
await setupJazzTestSync();
|
14
|
+
});
|
15
|
+
|
10
16
|
test("waitForAllCoValuesSync should resolve when all the values are synced", async () => {
|
11
17
|
class TestMap extends CoMap {
|
12
18
|
name = co.string;
|
@@ -98,3 +104,38 @@ test("accounts should sync correctly", async () => {
|
|
98
104
|
expect(members[0]?.account.profile!.name).toBe("test 1");
|
99
105
|
expect(members[1]?.account.profile!.name).toBe("test 2");
|
100
106
|
});
|
107
|
+
|
108
|
+
test("loading accounts should work", async () => {
|
109
|
+
const account = await createJazzTestAccount({
|
110
|
+
creationProps: {
|
111
|
+
name: "test 1",
|
112
|
+
},
|
113
|
+
});
|
114
|
+
|
115
|
+
const otherAccount = await createJazzTestAccount();
|
116
|
+
|
117
|
+
const loadedAccount = await Account.load(account.id, {
|
118
|
+
loadAs: otherAccount,
|
119
|
+
resolve: {
|
120
|
+
profile: true,
|
121
|
+
},
|
122
|
+
});
|
123
|
+
|
124
|
+
assert(loadedAccount);
|
125
|
+
expect(loadedAccount.profile.name).toBe("test 1");
|
126
|
+
});
|
127
|
+
|
128
|
+
test("loading raw accounts should work", async () => {
|
129
|
+
const account = await createJazzTestAccount({
|
130
|
+
creationProps: {
|
131
|
+
name: "test 1",
|
132
|
+
},
|
133
|
+
});
|
134
|
+
|
135
|
+
const loadedAccount = await Account.load(account.id, {
|
136
|
+
loadAs: account,
|
137
|
+
});
|
138
|
+
|
139
|
+
assert(loadedAccount);
|
140
|
+
expect(loadedAccount.profile!.name).toBe("test 1");
|
141
|
+
});
|