jazz-tools 0.18.37 → 0.18.38
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 +46 -46
- package/CHANGELOG.md +11 -0
- package/dist/inspector/{custom-element-SUVJ7CPN.js → custom-element-QESCMFY7.js} +13 -3
- package/dist/inspector/{custom-element-SUVJ7CPN.js.map → custom-element-QESCMFY7.js.map} +1 -1
- package/dist/inspector/index.js +12 -2
- package/dist/inspector/index.js.map +1 -1
- package/dist/inspector/register-custom-element.js +1 -1
- package/dist/inspector/viewer/history-view.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/inspector/tests/viewer/history-view.test.tsx +69 -9
- package/src/inspector/viewer/history-view.tsx +14 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"history-view.d.ts","sourceRoot":"","sources":["../../../src/inspector/viewer/history-view.tsx"],"names":[],"mappings":"AAAA,OAAO,EAKL,SAAS,EAET,UAAU,EAEX,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"history-view.d.ts","sourceRoot":"","sources":["../../../src/inspector/viewer/history-view.tsx"],"names":[],"mappings":"AAAA,OAAO,EAKL,SAAS,EAET,UAAU,EAEX,MAAM,QAAQ,CAAC;AA2BhB,wBAAgB,WAAW,CAAC,EAC1B,OAAO,EACP,IAAI,GACL,EAAE;IACD,OAAO,EAAE,UAAU,CAAC;IACpB,IAAI,EAAE,SAAS,CAAC;CACjB,2CAoFA"}
|
package/package.json
CHANGED
|
@@ -187,7 +187,7 @@
|
|
|
187
187
|
},
|
|
188
188
|
"type": "module",
|
|
189
189
|
"license": "MIT",
|
|
190
|
-
"version": "0.18.
|
|
190
|
+
"version": "0.18.38",
|
|
191
191
|
"dependencies": {
|
|
192
192
|
"@manuscripts/prosemirror-recreate-steps": "^0.1.4",
|
|
193
193
|
"@scure/base": "1.2.1",
|
|
@@ -204,9 +204,9 @@
|
|
|
204
204
|
"prosemirror-transform": "^1.9.0",
|
|
205
205
|
"use-sync-external-store": "^1.5.0",
|
|
206
206
|
"zod": "4.1.11",
|
|
207
|
-
"cojson": "0.18.
|
|
208
|
-
"cojson-storage-indexeddb": "0.18.
|
|
209
|
-
"cojson-transport-ws": "0.18.
|
|
207
|
+
"cojson": "0.18.38",
|
|
208
|
+
"cojson-storage-indexeddb": "0.18.38",
|
|
209
|
+
"cojson-transport-ws": "0.18.38"
|
|
210
210
|
},
|
|
211
211
|
"devDependencies": {
|
|
212
212
|
"@scure/bip39": "^1.3.0",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @vitest-environment happy-dom
|
|
2
|
-
import { afterEach, beforeAll, describe, expect, it } from "vitest";
|
|
2
|
+
import { afterEach, assert, beforeAll, describe, expect, it } from "vitest";
|
|
3
3
|
import { createJazzTestAccount, setupJazzTestSync } from "jazz-tools/testing";
|
|
4
4
|
import { co, z } from "jazz-tools";
|
|
5
5
|
import {
|
|
@@ -45,7 +45,7 @@ describe("HistoryView", async () => {
|
|
|
45
45
|
.create({ foo: "bar" }, account);
|
|
46
46
|
|
|
47
47
|
render(
|
|
48
|
-
<HistoryView coValue={value.$jazz.raw} node={
|
|
48
|
+
<HistoryView coValue={value.$jazz.raw} node={account.$jazz.localNode} />,
|
|
49
49
|
);
|
|
50
50
|
|
|
51
51
|
expect(
|
|
@@ -69,7 +69,10 @@ describe("HistoryView", async () => {
|
|
|
69
69
|
value.$jazz.delete("certified");
|
|
70
70
|
|
|
71
71
|
render(
|
|
72
|
-
<HistoryView
|
|
72
|
+
<HistoryView
|
|
73
|
+
coValue={value.$jazz.raw}
|
|
74
|
+
node={account.$jazz.localNode}
|
|
75
|
+
/>,
|
|
73
76
|
);
|
|
74
77
|
|
|
75
78
|
const history = [
|
|
@@ -82,8 +85,6 @@ describe("HistoryView", async () => {
|
|
|
82
85
|
'Property "certified" has been deleted',
|
|
83
86
|
].toReversed(); // Default sort is descending
|
|
84
87
|
|
|
85
|
-
expect(screen.getAllByRole("row")).toHaveLength(history.length + 2);
|
|
86
|
-
|
|
87
88
|
await waitFor(() => {
|
|
88
89
|
expect(screen.getAllByRole("row")[2]?.textContent).toContain(
|
|
89
90
|
account.$jazz.id,
|
|
@@ -92,6 +93,56 @@ describe("HistoryView", async () => {
|
|
|
92
93
|
|
|
93
94
|
expect(extractActions()).toEqual(history);
|
|
94
95
|
});
|
|
96
|
+
|
|
97
|
+
it("should render invalid changes", async () => {
|
|
98
|
+
const account2 = await createJazzTestAccount();
|
|
99
|
+
const group = co.group().create(account);
|
|
100
|
+
group.addMember(account2, "reader");
|
|
101
|
+
|
|
102
|
+
const Schema = co.map({
|
|
103
|
+
pet: z.string(),
|
|
104
|
+
age: z.number(),
|
|
105
|
+
certified: z.boolean().optional(),
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
const value = Schema.create(
|
|
109
|
+
{ pet: "dog", age: 10, certified: false },
|
|
110
|
+
group,
|
|
111
|
+
);
|
|
112
|
+
|
|
113
|
+
const valueOnAccount2 = await Schema.load(value.$jazz.id, {
|
|
114
|
+
loadAs: account2,
|
|
115
|
+
});
|
|
116
|
+
assert(valueOnAccount2);
|
|
117
|
+
|
|
118
|
+
// This is invalid, since account2 is a reader
|
|
119
|
+
valueOnAccount2.$jazz.set("pet", "cat");
|
|
120
|
+
|
|
121
|
+
render(
|
|
122
|
+
<HistoryView
|
|
123
|
+
coValue={valueOnAccount2.$jazz.raw}
|
|
124
|
+
node={account2.$jazz.localNode}
|
|
125
|
+
/>,
|
|
126
|
+
);
|
|
127
|
+
|
|
128
|
+
const history = [
|
|
129
|
+
'Property "pet" has been set to "dog"',
|
|
130
|
+
'Property "age" has been set to 10',
|
|
131
|
+
'Property "certified" has been set to false',
|
|
132
|
+
|
|
133
|
+
// Account2 can't write to the value
|
|
134
|
+
'Property "pet" has been set to "cat"Invalid transaction: Transactor has no write permissions',
|
|
135
|
+
].toReversed(); // Default sort is descending
|
|
136
|
+
|
|
137
|
+
await waitFor(() => {
|
|
138
|
+
expect(screen.getAllByRole("row")[2]?.textContent).toContain(
|
|
139
|
+
account2.$jazz.id,
|
|
140
|
+
);
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
expect(extractActions()).toEqual(history);
|
|
144
|
+
});
|
|
145
|
+
|
|
95
146
|
it("should render co.map changes with json", async () => {
|
|
96
147
|
const d = new Date();
|
|
97
148
|
const value = co
|
|
@@ -147,7 +198,10 @@ describe("HistoryView", async () => {
|
|
|
147
198
|
value.$jazz.shift();
|
|
148
199
|
|
|
149
200
|
render(
|
|
150
|
-
<HistoryView
|
|
201
|
+
<HistoryView
|
|
202
|
+
coValue={value.$jazz.raw}
|
|
203
|
+
node={account.$jazz.localNode}
|
|
204
|
+
/>,
|
|
151
205
|
);
|
|
152
206
|
|
|
153
207
|
const history = [
|
|
@@ -194,7 +248,10 @@ describe("HistoryView", async () => {
|
|
|
194
248
|
value.$jazz.shift();
|
|
195
249
|
|
|
196
250
|
render(
|
|
197
|
-
<HistoryView
|
|
251
|
+
<HistoryView
|
|
252
|
+
coValue={value.$jazz.raw}
|
|
253
|
+
node={account.$jazz.localNode}
|
|
254
|
+
/>,
|
|
198
255
|
);
|
|
199
256
|
|
|
200
257
|
const history = [
|
|
@@ -223,8 +280,11 @@ describe("HistoryView", async () => {
|
|
|
223
280
|
const group3 = co.group().create(account);
|
|
224
281
|
group3.addMember(group, "inherit");
|
|
225
282
|
|
|
226
|
-
|
|
227
|
-
<HistoryView
|
|
283
|
+
render(
|
|
284
|
+
<HistoryView
|
|
285
|
+
coValue={group.$jazz.raw}
|
|
286
|
+
node={account.$jazz.localNode}
|
|
287
|
+
/>,
|
|
228
288
|
);
|
|
229
289
|
|
|
230
290
|
const history = [
|
|
@@ -31,6 +31,7 @@ type HistoryEntry = {
|
|
|
31
31
|
action: string;
|
|
32
32
|
timestamp: Date;
|
|
33
33
|
isValid: boolean;
|
|
34
|
+
validationErrorMessage: string | undefined;
|
|
34
35
|
};
|
|
35
36
|
|
|
36
37
|
export function HistoryView({
|
|
@@ -85,7 +86,18 @@ export function HistoryView({
|
|
|
85
86
|
{
|
|
86
87
|
id: "action",
|
|
87
88
|
header: "Action",
|
|
88
|
-
accessor: (row) =>
|
|
89
|
+
accessor: (row) => {
|
|
90
|
+
if (row.isValid) return row.action;
|
|
91
|
+
|
|
92
|
+
return (
|
|
93
|
+
<>
|
|
94
|
+
{row.action}
|
|
95
|
+
<span style={{ color: "red", display: "block" }}>
|
|
96
|
+
Invalid transaction: {row.validationErrorMessage}
|
|
97
|
+
</span>
|
|
98
|
+
</>
|
|
99
|
+
);
|
|
100
|
+
},
|
|
89
101
|
sortable: false,
|
|
90
102
|
filterable: true,
|
|
91
103
|
sortFn: (a, b) => a.action.localeCompare(b.action),
|
|
@@ -131,10 +143,6 @@ function getTransactionChanges(
|
|
|
131
143
|
readKey,
|
|
132
144
|
) ?? []
|
|
133
145
|
);
|
|
134
|
-
|
|
135
|
-
// const decryptedString = coValue.core.verified.sessions.get(tx.txID.sessionID)?.impl.decryptNextTransactionChangesJson(tx.txID.txIndex, readKey);
|
|
136
|
-
|
|
137
|
-
// return decryptedString ? [decryptedString] : [];
|
|
138
146
|
}
|
|
139
147
|
|
|
140
148
|
return tx.changes ?? (tx.tx as any).changes ?? [];
|
|
@@ -150,6 +158,7 @@ function getHistory(coValue: RawCoValue): HistoryEntry[] {
|
|
|
150
158
|
action: mapTransactionToAction(change, coValue),
|
|
151
159
|
timestamp: new Date(tx.currentMadeAt),
|
|
152
160
|
isValid: tx.isValid,
|
|
161
|
+
validationErrorMessage: tx.validationErrorMessage,
|
|
153
162
|
}));
|
|
154
163
|
});
|
|
155
164
|
}
|