jazz-tools 0.18.29 → 0.18.31

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.
Files changed (107) hide show
  1. package/.svelte-kit/__package__/media/image.svelte +7 -4
  2. package/.svelte-kit/__package__/media/image.svelte.d.ts.map +1 -1
  3. package/.svelte-kit/__package__/media/image.types.d.ts +1 -0
  4. package/.svelte-kit/__package__/media/image.types.d.ts.map +1 -1
  5. package/.svelte-kit/__package__/tests/media/image.svelte.test.js +63 -0
  6. package/.turbo/turbo-build.log +60 -60
  7. package/CHANGELOG.md +26 -0
  8. package/dist/better-auth/auth/client.d.ts +1 -1
  9. package/dist/better-auth/auth/server.d.ts +1 -1
  10. package/dist/better-auth/auth/server.d.ts.map +1 -1
  11. package/dist/better-auth/auth/server.js.map +1 -1
  12. package/dist/better-auth/database-adapter/index.d.ts +3 -3
  13. package/dist/better-auth/database-adapter/index.d.ts.map +1 -1
  14. package/dist/better-auth/database-adapter/index.js +6 -2
  15. package/dist/better-auth/database-adapter/index.js.map +1 -1
  16. package/dist/better-auth/database-adapter/utils.d.ts.map +1 -1
  17. package/dist/browser/index.d.ts +2 -1
  18. package/dist/browser/index.d.ts.map +1 -1
  19. package/dist/browser/index.js.map +1 -1
  20. package/dist/{chunk-F55R554M.js → chunk-6BIYT3KH.js} +51 -30
  21. package/dist/chunk-6BIYT3KH.js.map +1 -0
  22. package/dist/index.js +1 -1
  23. package/dist/index.js.map +1 -1
  24. package/dist/inspector/{custom-element-35MDW4SW.js → custom-element-RQTLPAPJ.js} +584 -298
  25. package/dist/inspector/custom-element-RQTLPAPJ.js.map +1 -0
  26. package/dist/inspector/index.js +570 -338
  27. package/dist/inspector/index.js.map +1 -1
  28. package/dist/inspector/register-custom-element.js +1 -1
  29. package/dist/inspector/ui/index.d.ts +6 -0
  30. package/dist/inspector/ui/index.d.ts.map +1 -0
  31. package/dist/inspector/viewer/group-view.d.ts +3 -2
  32. package/dist/inspector/viewer/group-view.d.ts.map +1 -1
  33. package/dist/inspector/viewer/page.d.ts.map +1 -1
  34. package/dist/react/index.js +2 -2
  35. package/dist/react/index.js.map +1 -1
  36. package/dist/react/media/image.d.ts +8 -0
  37. package/dist/react/media/image.d.ts.map +1 -1
  38. package/dist/react-native-core/index.js +3 -3
  39. package/dist/react-native-core/index.js.map +1 -1
  40. package/dist/react-native-core/media/image.d.ts +15 -0
  41. package/dist/react-native-core/media/image.d.ts.map +1 -1
  42. package/dist/svelte/media/image.svelte +7 -4
  43. package/dist/svelte/media/image.svelte.d.ts.map +1 -1
  44. package/dist/svelte/media/image.types.d.ts +1 -0
  45. package/dist/svelte/media/image.types.d.ts.map +1 -1
  46. package/dist/svelte/tests/media/image.svelte.test.js +63 -0
  47. package/dist/testing.js +8 -1
  48. package/dist/testing.js.map +1 -1
  49. package/dist/tools/coValues/account.d.ts +1 -0
  50. package/dist/tools/coValues/account.d.ts.map +1 -1
  51. package/dist/tools/coValues/group.d.ts +3 -3
  52. package/dist/tools/coValues/group.d.ts.map +1 -1
  53. package/dist/tools/implementation/invites.d.ts +2 -2
  54. package/dist/tools/implementation/invites.d.ts.map +1 -1
  55. package/dist/tools/implementation/zodSchema/runtimeConverters/schemaFieldToCoFieldDef.d.ts +1 -1
  56. package/dist/tools/implementation/zodSchema/runtimeConverters/schemaFieldToCoFieldDef.d.ts.map +1 -1
  57. package/dist/tools/implementation/zodSchema/schemaTypes/AccountSchema.d.ts.map +1 -1
  58. package/dist/tools/implementation/zodSchema/typeConverters/TypeOfZodSchema.d.ts +3 -1
  59. package/dist/tools/implementation/zodSchema/typeConverters/TypeOfZodSchema.d.ts.map +1 -1
  60. package/dist/tools/implementation/zodSchema/zodCo.d.ts.map +1 -1
  61. package/dist/tools/implementation/zodSchema/zodReExport.d.ts +1 -1
  62. package/dist/tools/implementation/zodSchema/zodReExport.d.ts.map +1 -1
  63. package/dist/tools/subscribe/CoValueCoreSubscription.d.ts.map +1 -1
  64. package/dist/tools/subscribe/SubscriptionScope.d.ts +0 -2
  65. package/dist/tools/subscribe/SubscriptionScope.d.ts.map +1 -1
  66. package/dist/tools/testing.d.ts +1 -0
  67. package/dist/tools/testing.d.ts.map +1 -1
  68. package/dist/tools/tests/CoValueCoreSubscription.test.d.ts.map +1 -0
  69. package/package.json +4 -4
  70. package/src/better-auth/auth/server.ts +7 -2
  71. package/src/better-auth/auth/tests/server.test.ts +39 -17
  72. package/src/better-auth/database-adapter/index.ts +8 -5
  73. package/src/better-auth/database-adapter/utils.ts +4 -0
  74. package/src/browser/index.ts +2 -1
  75. package/src/inspector/ui/index.ts +5 -0
  76. package/src/inspector/viewer/group-view.tsx +304 -20
  77. package/src/inspector/viewer/new-app.tsx +4 -4
  78. package/src/inspector/viewer/page.tsx +16 -2
  79. package/src/react/media/image.tsx +11 -2
  80. package/src/react/tests/media/image.test.tsx +94 -0
  81. package/src/react-native-core/media/image.tsx +11 -3
  82. package/src/svelte/media/image.svelte +7 -4
  83. package/src/svelte/media/image.types.ts +1 -0
  84. package/src/svelte/tests/media/image.svelte.test.ts +85 -0
  85. package/src/tools/coValues/account.ts +30 -5
  86. package/src/tools/coValues/group.ts +13 -12
  87. package/src/tools/coValues/inbox.ts +5 -5
  88. package/src/tools/implementation/invites.ts +3 -8
  89. package/src/tools/implementation/zodSchema/runtimeConverters/schemaFieldToCoFieldDef.ts +5 -1
  90. package/src/tools/implementation/zodSchema/schemaTypes/AccountSchema.ts +2 -0
  91. package/src/tools/implementation/zodSchema/typeConverters/TypeOfZodSchema.ts +63 -50
  92. package/src/tools/implementation/zodSchema/zodReExport.ts +2 -2
  93. package/src/tools/subscribe/CoValueCoreSubscription.ts +17 -0
  94. package/src/tools/subscribe/SubscriptionScope.ts +1 -27
  95. package/src/tools/testing.ts +7 -0
  96. package/src/tools/{subscribe → tests}/CoValueCoreSubscription.test.ts +233 -3
  97. package/src/tools/tests/coFeed.branch.test.ts +14 -5
  98. package/src/tools/tests/coMap.test.ts +139 -42
  99. package/src/tools/tests/coOptional.test.ts +9 -1
  100. package/src/tools/tests/groupsAndAccounts.test.ts +156 -1
  101. package/src/tools/tests/load.test.ts +198 -1
  102. package/src/tools/tests/zod.test-d.ts +0 -2
  103. package/src/tools/tests/zod.test.ts +43 -40
  104. package/dist/chunk-F55R554M.js.map +0 -1
  105. package/dist/inspector/custom-element-35MDW4SW.js.map +0 -1
  106. package/dist/tools/subscribe/CoValueCoreSubscription.test.d.ts.map +0 -1
  107. /package/dist/tools/{subscribe → tests}/CoValueCoreSubscription.test.d.ts +0 -0
@@ -21,6 +21,7 @@ __export(zodReExport_exports, {
21
21
  enum: () => enum2,
22
22
  int: () => int,
23
23
  int32: () => int32,
24
+ intersection: () => intersection,
24
25
  ipv4: () => ipv4,
25
26
  ipv6: () => ipv6,
26
27
  iso: () => iso,
@@ -30,6 +31,7 @@ __export(zodReExport_exports, {
30
31
  number: () => number,
31
32
  object: () => object,
32
33
  optional: () => optional,
34
+ record: () => record,
33
35
  strictObject: () => strictObject,
34
36
  string: () => string,
35
37
  templateLiteral: () => templateLiteral,
@@ -85,6 +87,8 @@ import {
85
87
  int32,
86
88
  union,
87
89
  discriminatedUnion,
90
+ record,
91
+ intersection,
88
92
  int,
89
93
  codec,
90
94
  optional,
@@ -2126,7 +2130,8 @@ var FileStreamJazzApi = class extends CoValueJazzApi {
2126
2130
  import {
2127
2131
  ControlledAccount as RawControlledAccount,
2128
2132
  LocalNode as LocalNode2,
2129
- cojsonInternals as cojsonInternals2
2133
+ cojsonInternals as cojsonInternals2,
2134
+ isAccountRole
2130
2135
  } from "cojson";
2131
2136
  var Account = class extends CoValueBase {
2132
2137
  constructor(options) {
@@ -2192,14 +2197,14 @@ var Account = class extends CoValueBase {
2192
2197
  return true;
2193
2198
  }
2194
2199
  const role = valueOwner.getRoleOf(this.$jazz.id);
2195
- return role === "admin" || role === "writer" || role === "reader" || role === "writeOnly";
2200
+ return isAccountRole(role);
2196
2201
  }
2197
2202
  canWrite(value) {
2198
2203
  const valueOwner = value.$jazz.owner;
2199
2204
  if (!valueOwner) {
2200
2205
  if (value[TypeSym] === "Group") {
2201
2206
  const roleInGroup = value.getRoleOf(this.$jazz.id);
2202
- return roleInGroup === "admin" || roleInGroup === "writer";
2207
+ return roleInGroup === "admin" || roleInGroup === "manager" || roleInGroup === "writer";
2203
2208
  }
2204
2209
  if (value[TypeSym] === "Account") {
2205
2210
  return value.$jazz.id === this.$jazz.id;
@@ -2207,7 +2212,21 @@ var Account = class extends CoValueBase {
2207
2212
  return false;
2208
2213
  }
2209
2214
  const role = valueOwner.getRoleOf(this.$jazz.id);
2210
- return role === "admin" || role === "writer" || role === "writeOnly";
2215
+ return role === "admin" || role === "manager" || role === "writer" || role === "writeOnly";
2216
+ }
2217
+ canManage(value) {
2218
+ const valueOwner = value.$jazz.owner;
2219
+ if (!valueOwner) {
2220
+ if (value[TypeSym] === "Group") {
2221
+ const roleInGroup = value.getRoleOf(this.$jazz.id);
2222
+ return roleInGroup === "manager" || roleInGroup === "admin";
2223
+ }
2224
+ if (value[TypeSym] === "Account") {
2225
+ return value.$jazz.id === this.$jazz.id;
2226
+ }
2227
+ return false;
2228
+ }
2229
+ return valueOwner.getRoleOf(this.$jazz.id) === "admin" || valueOwner.getRoleOf(this.$jazz.id) === "manager";
2211
2230
  }
2212
2231
  canAdmin(value) {
2213
2232
  const valueOwner = value.$jazz.owner;
@@ -2481,7 +2500,8 @@ RegisteredSchemas["Account"] = Account;
2481
2500
 
2482
2501
  // src/tools/coValues/group.ts
2483
2502
  import {
2484
- RawAccount as RawAccount2
2503
+ RawAccount as RawAccount2,
2504
+ isAccountRole as isAccountRole2
2485
2505
  } from "cojson";
2486
2506
  var _Group = class _Group extends CoValueBase {
2487
2507
  /** @deprecated Don't use constructor directly, use .create */
@@ -2548,7 +2568,7 @@ var _Group = class _Group extends CoValueBase {
2548
2568
  for (const accountID of accountIDs) {
2549
2569
  if (!isAccountID(accountID)) continue;
2550
2570
  const role = this.$jazz.raw.roleOf(accountID);
2551
- if (role === "admin" || role === "writer" || role === "reader" || role === "writeOnly") {
2571
+ if (isAccountRole2(role)) {
2552
2572
  const ref2 = new Ref(
2553
2573
  accountID,
2554
2574
  this.$jazz.loadedAs,
@@ -2616,7 +2636,10 @@ var _Group = class _Group extends CoValueBase {
2616
2636
  * @returns This group.
2617
2637
  */
2618
2638
  extend(parent, roleMapping) {
2619
- this.$jazz.raw.extend(parent.$jazz.raw, roleMapping);
2639
+ this.$jazz.raw.extend(
2640
+ parent.$jazz.raw,
2641
+ roleMapping
2642
+ );
2620
2643
  return this;
2621
2644
  }
2622
2645
  /** @category Identity & Permissions
@@ -3002,7 +3025,10 @@ var InboxSender = class _InboxSender {
3002
3025
  if (inboxOwnerProfileRaw === "unavailable") {
3003
3026
  throw new Error("Failed to load the inbox owner profile");
3004
3027
  }
3005
- if (inboxOwnerProfileRaw.group.roleOf(currentAccount.$jazz.raw.id) !== "reader" && inboxOwnerProfileRaw.group.roleOf(currentAccount.$jazz.raw.id) !== "writer" && inboxOwnerProfileRaw.group.roleOf(currentAccount.$jazz.raw.id) !== "admin") {
3028
+ const inboxOwnerRole = inboxOwnerProfileRaw.group.roleOf(
3029
+ currentAccount.$jazz.raw.id
3030
+ );
3031
+ if (!["reader", "writer", "admin", "manager"].includes(inboxOwnerRole ?? "")) {
3006
3032
  throw new Error(
3007
3033
  "Insufficient permissions to access the inbox, make sure its user profile is publicly readable."
3008
3034
  );
@@ -3967,6 +3993,9 @@ var CoValueCoreSubscription = class {
3967
3993
  }
3968
3994
  emit(value) {
3969
3995
  if (this.unsubscribed) return;
3996
+ if (!isReadyForEmit(value)) {
3997
+ return;
3998
+ }
3970
3999
  this.listener(value);
3971
4000
  }
3972
4001
  /**
@@ -3979,6 +4008,12 @@ var CoValueCoreSubscription = class {
3979
4008
  this._unsubscribe();
3980
4009
  }
3981
4010
  };
4011
+ function isReadyForEmit(value) {
4012
+ if (value === "unavailable") {
4013
+ return true;
4014
+ }
4015
+ return value.core.verified?.header.meta?.type === "binary" || value.core.isCompletelyDownloaded();
4016
+ }
3982
4017
 
3983
4018
  // src/tools/subscribe/JazzError.ts
3984
4019
  var JazzError = class _JazzError {
@@ -4121,7 +4156,7 @@ var SubscriptionScope = class _SubscriptionScope {
4121
4156
  this.handleUpdate(value);
4122
4157
  return;
4123
4158
  }
4124
- if (!this.migrated && value !== "unavailable" && !value.core.verified.isStreaming()) {
4159
+ if (!this.migrated && value !== "unavailable") {
4125
4160
  if (this.migrating) {
4126
4161
  return;
4127
4162
  }
@@ -4238,9 +4273,6 @@ var SubscriptionScope = class _SubscriptionScope {
4238
4273
  shouldSendUpdates() {
4239
4274
  if (this.value.type === "unloaded") return false;
4240
4275
  if (this.value.type !== "loaded") return true;
4241
- if (this.isStreaming() && !this.isFileStream()) {
4242
- return false;
4243
- }
4244
4276
  return this.pendingLoadedChildren.size === 0;
4245
4277
  }
4246
4278
  getCurrentValue() {
@@ -4260,18 +4292,6 @@ var SubscriptionScope = class _SubscriptionScope {
4260
4292
  }
4261
4293
  return void 0;
4262
4294
  }
4263
- isStreaming() {
4264
- if (this.value.type !== "loaded") {
4265
- return false;
4266
- }
4267
- return this.value.value.$jazz.raw.core.verified.isStreaming();
4268
- }
4269
- isFileStream() {
4270
- if (this.value.type !== "loaded") {
4271
- return false;
4272
- }
4273
- return this.value.value.$jazz.raw.core.verified.header.meta?.type === "binary";
4274
- }
4275
4295
  triggerUpdate() {
4276
4296
  if (!this.shouldSendUpdates()) return;
4277
4297
  if (!this.dirty) return;
@@ -5404,7 +5424,8 @@ function enrichAccountSchema(schema, coValueClass) {
5404
5424
  },
5405
5425
  getCoValueClass: () => {
5406
5426
  return coValueClass;
5407
- }
5427
+ },
5428
+ optional: () => coOptionalDefiner(enrichedSchema)
5408
5429
  });
5409
5430
  return enrichedSchema;
5410
5431
  }
@@ -5585,7 +5606,7 @@ function schemaFieldToCoFieldDef(schema) {
5585
5606
  return coField.literal(
5586
5607
  ...zodSchemaDef.values
5587
5608
  );
5588
- } else if (zodSchemaDef.type === "object" || zodSchemaDef.type === "array" || zodSchemaDef.type === "tuple") {
5609
+ } else if (zodSchemaDef.type === "object" || zodSchemaDef.type === "record" || zodSchemaDef.type === "array" || zodSchemaDef.type === "tuple" || zodSchemaDef.type === "intersection") {
5589
5610
  return coField.json();
5590
5611
  } else if (zodSchemaDef.type === "union") {
5591
5612
  if (isUnionOfPrimitivesDeeply(schema)) {
@@ -6366,9 +6387,9 @@ function isAccountInstance(instance) {
6366
6387
  return TypeSym in instance && instance[TypeSym] === "Account";
6367
6388
  }
6368
6389
  function parseCoValueCreateOptions(options) {
6369
- const Group16 = RegisteredSchemas["Group"];
6390
+ const Group17 = RegisteredSchemas["Group"];
6370
6391
  if (!options) {
6371
- return { owner: Group16.create(), uniqueness: void 0 };
6392
+ return { owner: Group17.create(), uniqueness: void 0 };
6372
6393
  }
6373
6394
  if (TypeSym in options) {
6374
6395
  if (options[TypeSym] === "Account") {
@@ -6379,7 +6400,7 @@ function parseCoValueCreateOptions(options) {
6379
6400
  }
6380
6401
  const uniqueness = options.unique ? { uniqueness: options.unique } : void 0;
6381
6402
  const opts = {
6382
- owner: options.owner ? accountOrGroupToGroup(options.owner) : Group16.create(),
6403
+ owner: options.owner ? accountOrGroupToGroup(options.owner) : Group17.create(),
6383
6404
  uniqueness
6384
6405
  };
6385
6406
  return opts;
@@ -6614,4 +6635,4 @@ export {
6614
6635
  JazzContextManager
6615
6636
  };
6616
6637
  /* istanbul ignore file -- @preserve */
6617
- //# sourceMappingURL=chunk-F55R554M.js.map
6638
+ //# sourceMappingURL=chunk-6BIYT3KH.js.map