jazz-tools 0.9.19 → 0.9.21
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 +6 -6
- package/CHANGELOG.md +12 -0
- package/dist/{chunk-LRDIS2Q2.js → chunk-OJIEP4WE.js} +41 -12
- package/dist/chunk-OJIEP4WE.js.map +1 -0
- package/dist/index.native.js +1 -1
- package/dist/index.web.js +1 -1
- package/dist/testing.js +1 -1
- package/package.json +1 -1
- package/src/coValues/account.ts +19 -8
- package/src/coValues/coFeed.ts +23 -0
- package/src/coValues/inbox.ts +2 -2
- package/src/implementation/schema.ts +4 -1
- package/src/implementation/symbols.ts +5 -3
- package/src/tests/account.test.ts +37 -2
- package/dist/chunk-LRDIS2Q2.js.map +0 -1
package/.turbo/turbo-build.log
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
|
2
|
-
> jazz-tools@0.9.
|
2
|
+
> jazz-tools@0.9.21 build /home/runner/work/jazz/jazz/packages/jazz-tools
|
3
3
|
> tsup
|
4
4
|
|
5
5
|
[34mCLI[39m Building entry: {"index.web":"src/index.web.ts","index.native":"src/index.native.ts","testing":"src/testing.ts"}
|
@@ -10,11 +10,11 @@
|
|
10
10
|
[34mCLI[39m Cleaning output folder
|
11
11
|
[34mESM[39m Build start
|
12
12
|
[32mESM[39m [1mdist/index.web.js [22m[32m1.27 KB[39m
|
13
|
-
[32mESM[39m [1mdist/index.native.js [22m[32m1.26 KB[39m
|
14
13
|
[32mESM[39m [1mdist/testing.js [22m[32m3.43 KB[39m
|
15
|
-
[32mESM[39m [1mdist/
|
14
|
+
[32mESM[39m [1mdist/index.native.js [22m[32m1.26 KB[39m
|
15
|
+
[32mESM[39m [1mdist/chunk-OJIEP4WE.js [22m[32m97.62 KB[39m
|
16
16
|
[32mESM[39m [1mdist/index.web.js.map [22m[32m276.00 B[39m
|
17
|
-
[32mESM[39m [1mdist/index.native.js.map [22m[32m286.00 B[39m
|
18
17
|
[32mESM[39m [1mdist/testing.js.map [22m[32m6.94 KB[39m
|
19
|
-
[32mESM[39m [1mdist/
|
20
|
-
[32mESM[39m
|
18
|
+
[32mESM[39m [1mdist/index.native.js.map [22m[32m286.00 B[39m
|
19
|
+
[32mESM[39m [1mdist/chunk-OJIEP4WE.js.map [22m[32m241.14 KB[39m
|
20
|
+
[32mESM[39m ⚡️ Build success in 103ms
|
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,17 @@
|
|
1
1
|
# jazz-tools
|
2
2
|
|
3
|
+
## 0.9.21
|
4
|
+
|
5
|
+
### Patch Changes
|
6
|
+
|
7
|
+
- 1be017d: Account.isMe now indicates whether an account is the currently active account. To check if an account is the owner of the local node use isLocalNodeOwner instead.
|
8
|
+
|
9
|
+
## 0.9.20
|
10
|
+
|
11
|
+
### Patch Changes
|
12
|
+
|
13
|
+
- b01cc1f: Switches from symbols to prefixes strings for private properties
|
14
|
+
|
3
15
|
## 0.9.19
|
4
16
|
|
5
17
|
### Patch Changes
|
@@ -40,9 +40,9 @@ import { RawAccount as RawAccount2 } from "cojson";
|
|
40
40
|
var inspect = Symbol.for("nodejs.util.inspect.custom");
|
41
41
|
|
42
42
|
// src/implementation/symbols.ts
|
43
|
-
var SchemaInit =
|
44
|
-
var ItemsSym =
|
45
|
-
var MembersSym =
|
43
|
+
var SchemaInit = "$SchemaInit$";
|
44
|
+
var ItemsSym = "$items$";
|
45
|
+
var MembersSym = "$members$";
|
46
46
|
|
47
47
|
// src/coValues/deepLoading.ts
|
48
48
|
function fulfillsDepth(depth, value) {
|
@@ -872,7 +872,7 @@ import {
|
|
872
872
|
RawAccount as RawAccount3
|
873
873
|
} from "cojson";
|
874
874
|
function createInboxRoot(account) {
|
875
|
-
if (!account.
|
875
|
+
if (!account.isLocalNodeOwner) {
|
876
876
|
throw new Error("Account is not controlled");
|
877
877
|
}
|
878
878
|
const rawAccount = account._raw;
|
@@ -1082,7 +1082,7 @@ async function acceptInvite(invite, account) {
|
|
1082
1082
|
if (!id?.startsWith("co_z") || !inviteSecret.startsWith("inviteSecret_")) {
|
1083
1083
|
throw new Error("Invalid inbox ticket");
|
1084
1084
|
}
|
1085
|
-
if (!account.
|
1085
|
+
if (!account.isLocalNodeOwner) {
|
1086
1086
|
throw new Error("Account is not controlled");
|
1087
1087
|
}
|
1088
1088
|
await account._raw.acceptInvite(id, inviteSecret);
|
@@ -1545,7 +1545,7 @@ var _Account = class _Account extends CoValueBase {
|
|
1545
1545
|
return this;
|
1546
1546
|
}
|
1547
1547
|
get _loadedAs() {
|
1548
|
-
if (this.
|
1548
|
+
if (this.isLocalNodeOwner) return this;
|
1549
1549
|
const rawAccount = this._raw.core.node.account;
|
1550
1550
|
if (rawAccount instanceof RawAccount4) {
|
1551
1551
|
return coValuesCache.get(rawAccount, () => _Account.fromRaw(rawAccount));
|
@@ -1570,12 +1570,18 @@ var _Account = class _Account extends CoValueBase {
|
|
1570
1570
|
)
|
1571
1571
|
};
|
1572
1572
|
}
|
1573
|
+
/**
|
1574
|
+
* Whether this account is the currently active account.
|
1575
|
+
*/
|
1576
|
+
get isMe() {
|
1577
|
+
return activeAccountContext.get().id === this.id;
|
1578
|
+
}
|
1573
1579
|
constructor(options) {
|
1574
1580
|
super();
|
1575
1581
|
if (!("fromRaw" in options)) {
|
1576
1582
|
throw new Error("Can only construct account from raw or with .create()");
|
1577
1583
|
}
|
1578
|
-
this.
|
1584
|
+
this.isLocalNodeOwner = options.fromRaw.id == options.fromRaw.core.node.account.id;
|
1579
1585
|
Object.defineProperties(this, {
|
1580
1586
|
id: {
|
1581
1587
|
value: options.fromRaw.id,
|
@@ -1584,18 +1590,18 @@ var _Account = class _Account extends CoValueBase {
|
|
1584
1590
|
_raw: { value: options.fromRaw, enumerable: false },
|
1585
1591
|
_type: { value: "Account", enumerable: false }
|
1586
1592
|
});
|
1587
|
-
if (this.
|
1593
|
+
if (this.isLocalNodeOwner) {
|
1588
1594
|
this.sessionID = options.fromRaw.core.node.currentSessionID;
|
1589
1595
|
}
|
1590
1596
|
return new Proxy(this, AccountAndGroupProxyHandler);
|
1591
1597
|
}
|
1592
1598
|
myRole() {
|
1593
|
-
if (this.
|
1599
|
+
if (this.isLocalNodeOwner) {
|
1594
1600
|
return "admin";
|
1595
1601
|
}
|
1596
1602
|
}
|
1597
1603
|
async acceptInvite(valueID, inviteSecret, coValueClass) {
|
1598
|
-
if (!this.
|
1604
|
+
if (!this.isLocalNodeOwner) {
|
1599
1605
|
throw new Error("Only a controlled account can accept invites");
|
1600
1606
|
}
|
1601
1607
|
await this._raw.acceptInvite(
|
@@ -1771,7 +1777,7 @@ var AccountAndGroupProxyHandler = {
|
|
1771
1777
|
}
|
1772
1778
|
};
|
1773
1779
|
function isControlledAccount(account) {
|
1774
|
-
return account.
|
1780
|
+
return account.isLocalNodeOwner;
|
1775
1781
|
}
|
1776
1782
|
RegisteredSchemas["Account"] = Account;
|
1777
1783
|
|
@@ -2156,6 +2162,29 @@ var FileStream = class extends CoValueBase {
|
|
2156
2162
|
_raw: { value: raw, enumerable: false }
|
2157
2163
|
});
|
2158
2164
|
}
|
2165
|
+
/**
|
2166
|
+
* Create a new empty `FileStream` instance.
|
2167
|
+
*
|
2168
|
+
* @param options - Configuration options for the new FileStream
|
2169
|
+
* @param options.owner - The Account or Group that will own this FileStream and control access rights
|
2170
|
+
*
|
2171
|
+
* @example
|
2172
|
+
* ```typescript
|
2173
|
+
* // Create owned by an account
|
2174
|
+
* const stream = FileStream.create({ owner: myAccount });
|
2175
|
+
*
|
2176
|
+
* // Create owned by a group
|
2177
|
+
* const stream = FileStream.create({ owner: teamGroup });
|
2178
|
+
*
|
2179
|
+
* // Create with implicit owner
|
2180
|
+
* const stream = FileStream.create(myAccount);
|
2181
|
+
* ```
|
2182
|
+
*
|
2183
|
+
* @remarks
|
2184
|
+
* For uploading an existing file or blob, use {@link FileStream.createFromBlob} instead.
|
2185
|
+
*
|
2186
|
+
* @category Creation
|
2187
|
+
*/
|
2159
2188
|
static create(options) {
|
2160
2189
|
return new this(parseCoValueCreateOptions(options));
|
2161
2190
|
}
|
@@ -3438,4 +3467,4 @@ export {
|
|
3438
3467
|
consumeInviteLink
|
3439
3468
|
};
|
3440
3469
|
/* istanbul ignore file -- @preserve */
|
3441
|
-
//# sourceMappingURL=chunk-
|
3470
|
+
//# sourceMappingURL=chunk-OJIEP4WE.js.map
|