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.
@@ -1,5 +1,5 @@
1
1
 
2
- > jazz-tools@0.9.19 build /home/runner/work/jazz/jazz/packages/jazz-tools
2
+ > jazz-tools@0.9.21 build /home/runner/work/jazz/jazz/packages/jazz-tools
3
3
  > tsup
4
4
 
5
5
  CLI Building entry: {"index.web":"src/index.web.ts","index.native":"src/index.native.ts","testing":"src/testing.ts"}
@@ -10,11 +10,11 @@
10
10
  CLI Cleaning output folder
11
11
  ESM Build start
12
12
  ESM dist/index.web.js 1.27 KB
13
- ESM dist/index.native.js 1.26 KB
14
13
  ESM dist/testing.js 3.43 KB
15
- ESM dist/chunk-LRDIS2Q2.js 96.73 KB
14
+ ESM dist/index.native.js 1.26 KB
15
+ ESM dist/chunk-OJIEP4WE.js 97.62 KB
16
16
  ESM dist/index.web.js.map 276.00 B
17
- ESM dist/index.native.js.map 286.00 B
18
17
  ESM dist/testing.js.map 6.94 KB
19
- ESM dist/chunk-LRDIS2Q2.js.map 239.73 KB
20
- ESM ⚡️ Build success in 78ms
18
+ ESM dist/index.native.js.map 286.00 B
19
+ ESM dist/chunk-OJIEP4WE.js.map 241.14 KB
20
+ ESM ⚡️ 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 = Symbol.for("SchemaInit");
44
- var ItemsSym = Symbol.for("items");
45
- var MembersSym = Symbol.for("members");
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.isMe) {
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.isMe) {
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.isMe) return 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.isMe = options.fromRaw.id == options.fromRaw.core.node.account.id;
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.isMe) {
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.isMe) {
1599
+ if (this.isLocalNodeOwner) {
1594
1600
  return "admin";
1595
1601
  }
1596
1602
  }
1597
1603
  async acceptInvite(valueID, inviteSecret, coValueClass) {
1598
- if (!this.isMe) {
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.isMe;
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-LRDIS2Q2.js.map
3470
+ //# sourceMappingURL=chunk-OJIEP4WE.js.map