Compare commits

...

4 Commits

Author SHA1 Message Date
Guido D'Orsi
937284f7e9 Merge pull request #2666 from garden-co/changeset-release/main
Version Packages
2025-07-24 17:16:01 +02:00
github-actions[bot]
e999727c70 Version Packages 2025-07-24 14:58:34 +00:00
Guido D'Orsi
2197766624 Merge pull request #2665 from garden-co/fix/optional-ref-assign
fix: property update when assigning an optional reference on CoMap
2025-07-24 16:56:05 +02:00
Guido D'Orsi
3fe53a3a4a fix: property update when assigning an optional reference on CoMap 2025-07-24 12:19:48 +02:00
29 changed files with 262 additions and 30 deletions

View File

@@ -1,5 +1,12 @@
# passkey-svelte
## 0.0.104
### Patch Changes
- Updated dependencies [3fe53a3]
- jazz-tools@0.15.15
## 0.0.103
### Patch Changes

View File

@@ -1,6 +1,6 @@
{
"name": "chat-svelte",
"version": "0.0.103",
"version": "0.0.104",
"type": "module",
"private": true,
"scripts": {

View File

@@ -1,5 +1,11 @@
# cojson-storage-indexeddb
## 0.15.15
### Patch Changes
- cojson@0.15.15
## 0.15.14
### Patch Changes

View File

@@ -1,6 +1,6 @@
{
"name": "cojson-storage-indexeddb",
"version": "0.15.14",
"version": "0.15.15",
"main": "dist/index.js",
"type": "module",
"types": "dist/index.d.ts",

View File

@@ -1,5 +1,11 @@
# cojson-storage-sqlite
## 0.15.15
### Patch Changes
- cojson@0.15.15
## 0.15.14
### Patch Changes

View File

@@ -1,7 +1,7 @@
{
"name": "cojson-storage-sqlite",
"type": "module",
"version": "0.15.14",
"version": "0.15.15",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"license": "MIT",

View File

@@ -1,5 +1,11 @@
# cojson-transport-nodejs-ws
## 0.15.15
### Patch Changes
- cojson@0.15.15
## 0.15.14
### Patch Changes

View File

@@ -1,7 +1,7 @@
{
"name": "cojson-transport-ws",
"type": "module",
"version": "0.15.14",
"version": "0.15.15",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"license": "MIT",

View File

@@ -1,5 +1,7 @@
# cojson
## 0.15.15
## 0.15.14
### Patch Changes

View File

@@ -25,7 +25,7 @@
},
"type": "module",
"license": "MIT",
"version": "0.15.14",
"version": "0.15.15",
"devDependencies": {
"@opentelemetry/sdk-metrics": "^2.0.0",
"libsql": "^0.5.13",

View File

@@ -1,5 +1,14 @@
# jazz-auth-betterauth
## 0.15.15
### Patch Changes
- Updated dependencies [3fe53a3]
- jazz-tools@0.15.15
- jazz-betterauth-client-plugin@0.15.15
- cojson@0.15.15
## 0.15.14
### Patch Changes

View File

@@ -1,6 +1,6 @@
{
"name": "jazz-auth-betterauth",
"version": "0.15.14",
"version": "0.15.15",
"type": "module",
"main": "dist/index.js",
"types": "src/index.ts",

View File

@@ -1,5 +1,11 @@
# jazz-betterauth-client-plugin
## 0.15.15
### Patch Changes
- jazz-betterauth-server-plugin@0.15.15
## 0.15.14
### Patch Changes

View File

@@ -1,6 +1,6 @@
{
"name": "jazz-betterauth-client-plugin",
"version": "0.15.14",
"version": "0.15.15",
"type": "module",
"main": "dist/index.js",
"types": "src/index.ts",

View File

@@ -1,5 +1,13 @@
# jazz-betterauth-server-plugin
## 0.15.15
### Patch Changes
- Updated dependencies [3fe53a3]
- jazz-tools@0.15.15
- cojson@0.15.15
## 0.15.14
### Patch Changes

View File

@@ -1,6 +1,6 @@
{
"name": "jazz-betterauth-server-plugin",
"version": "0.15.14",
"version": "0.15.15",
"type": "module",
"main": "dist/index.js",
"types": "src/index.ts",

View File

@@ -1,5 +1,15 @@
# jazz-react-auth-betterauth
## 0.15.15
### Patch Changes
- Updated dependencies [3fe53a3]
- jazz-tools@0.15.15
- jazz-auth-betterauth@0.15.15
- jazz-betterauth-client-plugin@0.15.15
- cojson@0.15.15
## 0.15.14
### Patch Changes

View File

@@ -1,6 +1,6 @@
{
"name": "jazz-react-auth-betterauth",
"version": "0.15.14",
"version": "0.15.15",
"type": "module",
"main": "dist/index.js",
"types": "src/index.tsx",

View File

@@ -1,5 +1,15 @@
# jazz-run
## 0.15.15
### Patch Changes
- Updated dependencies [3fe53a3]
- jazz-tools@0.15.15
- cojson@0.15.15
- cojson-storage-sqlite@0.15.15
- cojson-transport-ws@0.15.15
## 0.15.14
### Patch Changes

View File

@@ -3,7 +3,7 @@
"bin": "./dist/index.js",
"type": "module",
"license": "MIT",
"version": "0.15.14",
"version": "0.15.15",
"exports": {
"./startSyncServer": {
"import": "./dist/startSyncServer.js",
@@ -28,11 +28,11 @@
"@effect/printer-ansi": "^0.34.5",
"@effect/schema": "^0.71.1",
"@effect/typeclass": "^0.25.5",
"cojson": "workspace:0.15.14",
"cojson-storage-sqlite": "workspace:0.15.14",
"cojson-transport-ws": "workspace:0.15.14",
"cojson": "workspace:0.15.15",
"cojson-storage-sqlite": "workspace:0.15.15",
"cojson-transport-ws": "workspace:0.15.15",
"effect": "^3.6.5",
"jazz-tools": "workspace:0.15.14",
"jazz-tools": "workspace:0.15.15",
"ws": "^8.14.2"
},
"devDependencies": {

View File

@@ -1,5 +1,14 @@
# jazz-tools
## 0.15.15
### Patch Changes
- 3fe53a3: Fix property update when assigning an optional reference on CoMap
- cojson@0.15.15
- cojson-storage-indexeddb@0.15.15
- cojson-transport-ws@0.15.15
## 0.15.14
### Patch Changes

View File

@@ -139,7 +139,7 @@
},
"type": "module",
"license": "MIT",
"version": "0.15.14",
"version": "0.15.15",
"dependencies": {
"@manuscripts/prosemirror-recreate-steps": "^0.1.4",
"@scure/base": "1.2.1",

View File

@@ -341,17 +341,15 @@ export class SubscriptionScope<D extends CoValue> {
this.resolve = {};
}
if (this.resolve.$each || key in this.resolve) {
return;
if (!this.resolve.$each && !(key in this.resolve)) {
const resolve = this.resolve as Record<string, any>;
// Adding the key to the resolve object to resolve the key when calling loadChildren
resolve[key] = true;
// Track the keys that are autoloaded to flag any id on that key as autoloaded
this.autoloadedKeys.add(key);
}
const resolve = this.resolve as Record<string, any>;
// Adding the key to the resolve object to resolve the key when calling loadChildren
resolve[key] = true;
// Track the keys that are autoloaded to flag any id on that key as autoloaded
this.autoloadedKeys.add(key);
if (this.value.type !== "loaded") {
return;
}

View File

@@ -2103,3 +2103,144 @@ describe("CoMap migration", () => {
});
});
});
describe("Updating a nested reference", () => {
test("should assign a resolved optional reference and expect value is not null", async () => {
// Define the schema similar to the server-worker-http example
const PlaySelection = co.map({
value: z.literal(["rock", "paper", "scissors"]),
group: Group,
});
const Player = co.map({
account: co.account(),
playSelection: PlaySelection.optional(),
});
const Game = co.map({
player1: Player,
player2: Player,
outcome: z.literal(["player1", "player2", "draw"]).optional(),
player1Score: z.number(),
player2Score: z.number(),
});
// Create accounts for the players
const player1Account = await createJazzTestAccount({
creationProps: { name: "Player 1" },
});
const player2Account = await createJazzTestAccount({
creationProps: { name: "Player 2" },
});
// Create a game
const game = Game.create({
player1: Player.create({
account: player1Account,
}),
player2: Player.create({
account: player2Account,
}),
player1Score: 0,
player2Score: 0,
});
// Create a group for the play selection (similar to the route logic)
const group = Group.create({ owner: Account.getMe() });
group.addMember(player1Account, "reader");
// Load the game to verify the assignment worked
const loadedGame = await Game.load(game.id, {
resolve: {
player1: {
account: true,
playSelection: true,
},
player2: {
account: true,
playSelection: true,
},
},
});
assert(loadedGame);
// Create a play selection
const playSelection = PlaySelection.create({ value: "rock", group }, group);
// Assign the play selection to player1 (similar to the route logic)
loadedGame.player1.playSelection = playSelection;
// Verify that the playSelection is not null and has the expected value
expect(loadedGame.player1.playSelection).not.toBeNull();
expect(loadedGame.player1.playSelection).toBeDefined();
});
test("should assign a resolved reference and expect value to update", async () => {
// Define the schema similar to the server-worker-http example
const PlaySelection = co.map({
value: z.literal(["rock", "paper", "scissors"]),
});
const Player = co.map({
account: co.account(),
playSelection: PlaySelection,
});
const Game = co.map({
player1: Player,
player2: Player,
outcome: z.literal(["player1", "player2", "draw"]).optional(),
player1Score: z.number(),
player2Score: z.number(),
});
// Create accounts for the players
const player1Account = await createJazzTestAccount({
creationProps: { name: "Player 1" },
});
const player2Account = await createJazzTestAccount({
creationProps: { name: "Player 2" },
});
// Create a game
const game = Game.create({
player1: Player.create({
account: player1Account,
playSelection: PlaySelection.create({ value: "rock" }),
}),
player2: Player.create({
account: player2Account,
playSelection: PlaySelection.create({ value: "paper" }),
}),
player1Score: 0,
player2Score: 0,
});
// Load the game to verify the assignment worked
const loadedGame = await Game.load(game.id, {
resolve: {
player1: {
account: true,
playSelection: true,
},
player2: {
account: true,
playSelection: true,
},
},
});
assert(loadedGame);
// Create a play selection
const playSelection = PlaySelection.create({ value: "scissors" });
// Assign the play selection to player1 (similar to the route logic)
loadedGame.player1.playSelection = playSelection;
// Verify that the playSelection is not null and has the expected value
expect(loadedGame.player1.playSelection.id).toBe(playSelection.id);
expect(loadedGame.player1.playSelection.value).toEqual("scissors");
});
});

8
pnpm-lock.yaml generated
View File

@@ -1772,19 +1772,19 @@ importers:
specifier: ^0.25.5
version: 0.25.8(effect@3.11.9)
cojson:
specifier: workspace:0.15.14
specifier: workspace:0.15.15
version: link:../cojson
cojson-storage-sqlite:
specifier: workspace:0.15.14
specifier: workspace:0.15.15
version: link:../cojson-storage-sqlite
cojson-transport-ws:
specifier: workspace:0.15.14
specifier: workspace:0.15.15
version: link:../cojson-transport-ws
effect:
specifier: ^3.6.5
version: 3.11.9
jazz-tools:
specifier: workspace:0.15.14
specifier: workspace:0.15.15
version: link:../jazz-tools
ws:
specifier: ^8.14.2

View File

@@ -1,5 +1,12 @@
# jazz-react-tailwind-starter
## 0.0.135
### Patch Changes
- Updated dependencies [3fe53a3]
- jazz-tools@0.15.15
## 0.0.134
### Patch Changes

View File

@@ -1,7 +1,7 @@
{
"name": "jazz-react-passkey-auth-starter",
"private": true,
"version": "0.0.134",
"version": "0.0.135",
"type": "module",
"scripts": {
"dev": "vite",

View File

@@ -1,5 +1,12 @@
# svelte-passkey-auth
## 0.0.109
### Patch Changes
- Updated dependencies [3fe53a3]
- jazz-tools@0.15.15
## 0.0.108
### Patch Changes

View File

@@ -1,6 +1,6 @@
{
"name": "svelte-passkey-auth",
"version": "0.0.108",
"version": "0.0.109",
"type": "module",
"private": true,
"scripts": {