jazz-tools 0.7.0-alpha.4 → 0.7.0-alpha.41
Sign up to get free protection for your applications and to get access to all the features.
- package/.eslintrc.cjs +3 -10
- package/.prettierrc.js +9 -0
- package/.turbo/turbo-build.log +3 -19
- package/.turbo/turbo-lint.log +4 -0
- package/.turbo/turbo-test.log +140 -0
- package/CHANGELOG.md +243 -0
- package/README.md +10 -2
- package/dist/coValues/account.js +104 -50
- package/dist/coValues/account.js.map +1 -1
- package/dist/coValues/coList.js +165 -112
- package/dist/coValues/coList.js.map +1 -1
- package/dist/coValues/coMap.js +243 -163
- package/dist/coValues/coMap.js.map +1 -1
- package/dist/coValues/coStream.js +256 -73
- package/dist/coValues/coStream.js.map +1 -1
- package/dist/coValues/deepLoading.js +57 -0
- package/dist/coValues/deepLoading.js.map +1 -0
- package/dist/coValues/extensions/imageDef.js +14 -8
- package/dist/coValues/extensions/imageDef.js.map +1 -1
- package/dist/coValues/group.js +49 -38
- package/dist/coValues/group.js.map +1 -1
- package/dist/coValues/interfaces.js +66 -26
- package/dist/coValues/interfaces.js.map +1 -1
- package/dist/implementation/devtoolsFormatters.js +114 -0
- package/dist/implementation/devtoolsFormatters.js.map +1 -0
- package/dist/implementation/refs.js +60 -19
- package/dist/implementation/refs.js.map +1 -1
- package/dist/implementation/schema.js +44 -1
- package/dist/implementation/schema.js.map +1 -1
- package/dist/implementation/subscriptionScope.js +19 -1
- package/dist/implementation/subscriptionScope.js.map +1 -1
- package/dist/implementation/symbols.js +5 -0
- package/dist/implementation/symbols.js.map +1 -0
- package/dist/index.js +4 -5
- package/dist/index.js.map +1 -1
- package/dist/internal.js +4 -1
- package/dist/internal.js.map +1 -1
- package/dist/tests/coList.test.js +51 -52
- package/dist/tests/coList.test.js.map +1 -1
- package/dist/tests/coMap.test.js +196 -75
- package/dist/tests/coMap.test.js.map +1 -1
- package/dist/tests/coStream.test.js +95 -85
- package/dist/tests/coStream.test.js.map +1 -1
- package/dist/tests/deepLoading.test.js +188 -0
- package/dist/tests/deepLoading.test.js.map +1 -0
- package/dist/tests/groupsAndAccounts.test.js +83 -0
- package/dist/tests/groupsAndAccounts.test.js.map +1 -0
- package/package.json +17 -9
- package/src/coValues/account.ts +183 -152
- package/src/coValues/coList.ts +220 -173
- package/src/coValues/coMap.ts +322 -312
- package/src/coValues/coStream.ts +397 -135
- package/src/coValues/deepLoading.ts +215 -0
- package/src/coValues/extensions/imageDef.ts +16 -17
- package/src/coValues/group.ts +95 -111
- package/src/coValues/interfaces.ts +217 -115
- package/src/implementation/devtoolsFormatters.ts +110 -0
- package/src/implementation/inspect.ts +1 -1
- package/src/implementation/refs.ts +91 -38
- package/src/implementation/schema.ts +87 -46
- package/src/implementation/subscriptionScope.ts +44 -12
- package/src/implementation/symbols.ts +11 -0
- package/src/index.ts +13 -9
- package/src/internal.ts +6 -2
- package/src/tests/coList.test.ts +67 -66
- package/src/tests/coMap.test.ts +226 -123
- package/src/tests/coStream.test.ts +141 -131
- package/src/tests/deepLoading.test.ts +301 -0
- package/src/tests/groupsAndAccounts.test.ts +91 -0
package/.eslintrc.cjs
CHANGED
@@ -3,6 +3,7 @@ module.exports = {
|
|
3
3
|
"eslint:recommended",
|
4
4
|
"plugin:@typescript-eslint/recommended",
|
5
5
|
"plugin:require-extensions/recommended",
|
6
|
+
"prettier"
|
6
7
|
],
|
7
8
|
parser: "@typescript-eslint/parser",
|
8
9
|
plugins: ["@typescript-eslint", "require-extensions"],
|
@@ -10,7 +11,7 @@ module.exports = {
|
|
10
11
|
project: "./tsconfig.json",
|
11
12
|
tsconfigRootDir: __dirname,
|
12
13
|
},
|
13
|
-
ignorePatterns: [".eslint.cjs"
|
14
|
+
ignorePatterns: [".eslint.cjs"],
|
14
15
|
root: true,
|
15
16
|
rules: {
|
16
17
|
"no-unused-vars": "off",
|
@@ -19,13 +20,5 @@ module.exports = {
|
|
19
20
|
{ argsIgnorePattern: "^_", varsIgnorePattern: "^_" },
|
20
21
|
],
|
21
22
|
"@typescript-eslint/no-floating-promises": "error",
|
22
|
-
"@typescript-eslint/no-explicit-any": "warn",
|
23
|
-
"@typescript-eslint/consistent-type-imports": [
|
24
|
-
"error",
|
25
|
-
{
|
26
|
-
prefer: "type-imports",
|
27
|
-
disallowTypeAnnotations: false,
|
28
|
-
},
|
29
|
-
],
|
30
23
|
},
|
31
|
-
}
|
24
|
+
}
|
package/.prettierrc.js
ADDED
package/.turbo/turbo-build.log
CHANGED
@@ -1,24 +1,8 @@
|
|
1
1
|
|
2
|
-
> jazz-
|
2
|
+
> jazz-tools@0.7.0-alpha.37 build /Users/anselm/jazz/jazz/packages/jazz-tools
|
3
3
|
> npm run lint && rm -rf ./dist && tsc --sourceMap --outDir dist
|
4
4
|
|
5
5
|
|
6
|
-
> jazz-
|
7
|
-
> eslint
|
6
|
+
> jazz-tools@0.7.0-alpha.37 lint
|
7
|
+
> eslint . --ext ts,tsx
|
8
8
|
|
9
|
-
|
10
|
-
/Users/anselm/jazz/jazz/packages/jazz-js/src/tests/binaryCoStream.test.ts
|
11
|
-
0:0 warning File ignored because of a matching ignore pattern. Use "--no-ignore" to override
|
12
|
-
|
13
|
-
/Users/anselm/jazz/jazz/packages/jazz-js/src/tests/coList.test.ts
|
14
|
-
0:0 warning File ignored because of a matching ignore pattern. Use "--no-ignore" to override
|
15
|
-
|
16
|
-
/Users/anselm/jazz/jazz/packages/jazz-js/src/tests/coMap.test.ts
|
17
|
-
0:0 warning File ignored because of a matching ignore pattern. Use "--no-ignore" to override
|
18
|
-
|
19
|
-
/Users/anselm/jazz/jazz/packages/jazz-js/src/tests/coStream.test.ts
|
20
|
-
0:0 warning File ignored because of a matching ignore pattern. Use "--no-ignore" to override
|
21
|
-
|
22
|
-
✖ 4 problems (0 errors, 4 warnings)
|
23
|
-
|
24
|
-
ELIFECYCLE Command failed.
|
@@ -0,0 +1,140 @@
|
|
1
|
+
|
2
|
+
> jazz-tools@0.7.0-alpha.37 test /Users/anselm/jazz/jazz/packages/jazz-tools
|
3
|
+
> vitest --run
|
4
|
+
|
5
|
+
|
6
|
+
RUN v0.34.6 /Users/anselm/jazz/jazz/packages/jazz-tools
|
7
|
+
|
8
|
+
✓ src/tests/groupsAndAccounts.test.ts (1 test) 41ms
|
9
|
+
stdout | unknown test
|
10
|
+
TestMap schema [90mundefined[39m
|
11
|
+
|
12
|
+
✓ src/tests/deepLoading.test.ts (3 tests) 86ms
|
13
|
+
✓ src/tests/coList.test.ts (10 tests) 160ms
|
14
|
+
stdout | src/tests/coList.test.ts > Simple CoList operations > Mutation > splice
|
15
|
+
[ [32m'bread'[39m, [32m'onion'[39m ] [33m0[39m
|
16
|
+
[ [32m'bread'[39m, [32m'salt'[39m, [32m'onion'[39m ] [33m1[39m
|
17
|
+
|
18
|
+
stdout | src/tests/coList.test.ts > CoList resolution > Subscription & auto-resolution
|
19
|
+
subscribedList?.[0]?.[0]?.[0] [90mundefined[39m
|
20
|
+
subscribedList?.[0]?.[0]?.[0] [90mundefined[39m
|
21
|
+
subscribedList?.[0]?.[0]?.[0] a
|
22
|
+
subscribedList?.[0]?.[0]?.[0] x
|
23
|
+
subscribedList?.[0]?.[0]?.[0] y
|
24
|
+
subscribedList?.[0]?.[0]?.[0] w
|
25
|
+
|
26
|
+
stdout | src/tests/coStream.test.ts > CoStream resolution > Subscription & auto-resolution
|
27
|
+
subscribedStream[me.id] {
|
28
|
+
value: [36m[Getter][39m,
|
29
|
+
ref: [36m[Getter][39m,
|
30
|
+
by: [36m[Getter][39m,
|
31
|
+
madeAt: [35m2024-05-24T20:46:44.463Z[39m,
|
32
|
+
tx: {
|
33
|
+
sessionID: [32m'co_zNCLRSU2cPfqfz9aEAA1vL2JsF5_session_z75hUWuWjTuX'[39m,
|
34
|
+
txIndex: [33m0[39m
|
35
|
+
}
|
36
|
+
}
|
37
|
+
subscribedStream[me.id]?.value?.[me.id]?.value [90mundefined[39m
|
38
|
+
subscribedStream[me.id]?.value?.[me.id]?.value?.[me.id]?.value [90mundefined[39m
|
39
|
+
subscribedStream[me.id] {
|
40
|
+
value: [36m[Getter][39m,
|
41
|
+
ref: [36m[Getter][39m,
|
42
|
+
by: [36m[Getter][39m,
|
43
|
+
madeAt: [35m2024-05-24T20:46:44.463Z[39m,
|
44
|
+
tx: {
|
45
|
+
sessionID: [32m'co_zNCLRSU2cPfqfz9aEAA1vL2JsF5_session_z75hUWuWjTuX'[39m,
|
46
|
+
txIndex: [33m0[39m
|
47
|
+
}
|
48
|
+
}
|
49
|
+
subscribedStream[me.id]?.value?.[me.id]?.value [1mnull[22m
|
50
|
+
subscribedStream[me.id]?.value?.[me.id]?.value?.[me.id]?.value [90mundefined[39m
|
51
|
+
subscribedStream[me.id] {
|
52
|
+
value: [36m[Getter][39m,
|
53
|
+
ref: [36m[Getter][39m,
|
54
|
+
by: [36m[Getter][39m,
|
55
|
+
madeAt: [35m2024-05-24T20:46:44.463Z[39m,
|
56
|
+
tx: {
|
57
|
+
sessionID: [32m'co_zNCLRSU2cPfqfz9aEAA1vL2JsF5_session_z75hUWuWjTuX'[39m,
|
58
|
+
txIndex: [33m0[39m
|
59
|
+
}
|
60
|
+
}
|
61
|
+
subscribedStream[me.id]?.value?.[me.id]?.value {
|
62
|
+
id: [32m'co_zGQiwntfLWcU3pybwp6nq8VhcEr'[39m,
|
63
|
+
_type: [32m'CoStream'[39m,
|
64
|
+
co_zNCLRSU2cPfqfz9aEAA1vL2JsF5: [32m'milk'[39m,
|
65
|
+
in: { co_zNCLRSU2cPfqfz9aEAA1vL2JsF5_session_z75hUWuWjTuX: [32m'milk'[39m }
|
66
|
+
}
|
67
|
+
subscribedStream[me.id]?.value?.[me.id]?.value?.[me.id]?.value milk
|
68
|
+
subscribedStream[me.id] {
|
69
|
+
value: [36m[Getter][39m,
|
70
|
+
ref: [36m[Getter][39m,
|
71
|
+
by: [36m[Getter][39m,
|
72
|
+
madeAt: [35m2024-05-24T20:46:44.463Z[39m,
|
73
|
+
tx: {
|
74
|
+
sessionID: [32m'co_zNCLRSU2cPfqfz9aEAA1vL2JsF5_session_z75hUWuWjTuX'[39m,
|
75
|
+
txIndex: [33m0[39m
|
76
|
+
}
|
77
|
+
}
|
78
|
+
subscribedStream[me.id]?.value?.[me.id]?.value {
|
79
|
+
id: [32m'co_zGQiwntfLWcU3pybwp6nq8VhcEr'[39m,
|
80
|
+
_type: [32m'CoStream'[39m,
|
81
|
+
co_zNCLRSU2cPfqfz9aEAA1vL2JsF5: [32m'bread'[39m,
|
82
|
+
in: {
|
83
|
+
co_zNCLRSU2cPfqfz9aEAA1vL2JsF5_session_z75hUWuWjTuX: [32m'milk'[39m,
|
84
|
+
co_zNCLRSU2cPfqfz9aEAA1vL2JsF5_session_zSWSUsvvX8KW: [32m'bread'[39m
|
85
|
+
}
|
86
|
+
}
|
87
|
+
subscribedStream[me.id]?.value?.[me.id]?.value?.[me.id]?.value bread
|
88
|
+
subscribedStream[me.id] {
|
89
|
+
value: [36m[Getter][39m,
|
90
|
+
ref: [36m[Getter][39m,
|
91
|
+
by: [36m[Getter][39m,
|
92
|
+
madeAt: [35m2024-05-24T20:46:44.481Z[39m,
|
93
|
+
tx: {
|
94
|
+
sessionID: [32m'co_zNCLRSU2cPfqfz9aEAA1vL2JsF5_session_zSWSUsvvX8KW'[39m,
|
95
|
+
txIndex: [33m0[39m
|
96
|
+
}
|
97
|
+
}
|
98
|
+
subscribedStream[me.id]?.value?.[me.id]?.value {
|
99
|
+
id: [32m'co_zhX5ZcvxQW4w2LJ99rBQ6NmBziS'[39m,
|
100
|
+
_type: [32m'CoStream'[39m,
|
101
|
+
co_zNCLRSU2cPfqfz9aEAA1vL2JsF5: [32m'butter'[39m,
|
102
|
+
in: { co_zNCLRSU2cPfqfz9aEAA1vL2JsF5_session_zSWSUsvvX8KW: [32m'butter'[39m }
|
103
|
+
}
|
104
|
+
subscribedStream[me.id]?.value?.[me.id]?.value?.[me.id]?.value butter
|
105
|
+
subscribedStream[me.id] {
|
106
|
+
value: [36m[Getter][39m,
|
107
|
+
ref: [36m[Getter][39m,
|
108
|
+
by: [36m[Getter][39m,
|
109
|
+
madeAt: [35m2024-05-24T20:46:44.481Z[39m,
|
110
|
+
tx: {
|
111
|
+
sessionID: [32m'co_zNCLRSU2cPfqfz9aEAA1vL2JsF5_session_zSWSUsvvX8KW'[39m,
|
112
|
+
txIndex: [33m0[39m
|
113
|
+
}
|
114
|
+
}
|
115
|
+
subscribedStream[me.id]?.value?.[me.id]?.value {
|
116
|
+
id: [32m'co_zhX5ZcvxQW4w2LJ99rBQ6NmBziS'[39m,
|
117
|
+
_type: [32m'CoStream'[39m,
|
118
|
+
co_zNCLRSU2cPfqfz9aEAA1vL2JsF5: [32m'jam'[39m,
|
119
|
+
in: { co_zNCLRSU2cPfqfz9aEAA1vL2JsF5_session_zSWSUsvvX8KW: [32m'jam'[39m }
|
120
|
+
}
|
121
|
+
subscribedStream[me.id]?.value?.[me.id]?.value?.[me.id]?.value jam
|
122
|
+
|
123
|
+
✓ src/tests/coStream.test.ts (10 tests) 181ms
|
124
|
+
✓ src/tests/coMap.test.ts (11 tests) 203ms
|
125
|
+
stdout | src/tests/coMap.test.ts > CoMap resolution > Subscription & auto-resolution
|
126
|
+
subscribedMap.nested?.twiceNested?.taste [90mundefined[39m
|
127
|
+
subscribedMap.nested?.twiceNested?.taste [90mundefined[39m
|
128
|
+
subscribedMap.nested?.twiceNested?.taste sour
|
129
|
+
subscribedMap.nested?.twiceNested?.taste sour
|
130
|
+
subscribedMap.nested?.twiceNested?.taste sweet
|
131
|
+
subscribedMap.nested?.twiceNested?.taste sweet
|
132
|
+
subscribedMap.nested?.twiceNested?.taste salty
|
133
|
+
subscribedMap.nested?.twiceNested?.taste umami
|
134
|
+
|
135
|
+
|
136
|
+
Test Files 5 passed (5)
|
137
|
+
Tests 35 passed (35)
|
138
|
+
Start at 21:46:43
|
139
|
+
Duration 805ms (transform 212ms, setup 0ms, collect 2.19s, tests 671ms, environment 0ms, prepare 225ms)
|
140
|
+
|
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,248 @@
|
|
1
1
|
# jazz-autosub
|
2
2
|
|
3
|
+
## 0.7.0-alpha.41
|
4
|
+
|
5
|
+
### Patch Changes
|
6
|
+
|
7
|
+
- Updated dependencies
|
8
|
+
- cojson-transport-nodejs-ws@0.7.0-alpha.41
|
9
|
+
|
10
|
+
## 0.7.0-alpha.39
|
11
|
+
|
12
|
+
### Patch Changes
|
13
|
+
|
14
|
+
- Updated dependencies
|
15
|
+
- cojson@0.7.0-alpha.39
|
16
|
+
- cojson-transport-nodejs-ws@0.7.0-alpha.39
|
17
|
+
|
18
|
+
## 0.7.0-alpha.38
|
19
|
+
|
20
|
+
### Patch Changes
|
21
|
+
|
22
|
+
- Fix infinite recursion in subscriptionScope
|
23
|
+
- Fix type of init param for CoMap.create
|
24
|
+
- Implement deep loading, simplify API
|
25
|
+
- Updated dependencies
|
26
|
+
- cojson@0.7.0-alpha.38
|
27
|
+
- cojson-transport-nodejs-ws@0.7.0-alpha.38
|
28
|
+
|
29
|
+
## 0.7.0-alpha.37
|
30
|
+
|
31
|
+
### Patch Changes
|
32
|
+
|
33
|
+
- Updated dependencies
|
34
|
+
- cojson@0.7.0-alpha.37
|
35
|
+
- cojson-transport-nodejs-ws@0.7.0-alpha.37
|
36
|
+
|
37
|
+
## 0.7.0-alpha.36
|
38
|
+
|
39
|
+
### Patch Changes
|
40
|
+
|
41
|
+
- 1a35307: Implement first devtools formatters
|
42
|
+
- 6b0418f: Fix image resolution loading
|
43
|
+
- 1a35307: Add ability to declare minimum required data in subscribe & Improve property access tracing
|
44
|
+
- Updated dependencies [1a35307]
|
45
|
+
- Updated dependencies [1a35307]
|
46
|
+
- cojson@0.7.0-alpha.36
|
47
|
+
- cojson-transport-nodejs-ws@0.7.0-alpha.36
|
48
|
+
|
49
|
+
## 0.7.0-alpha.35
|
50
|
+
|
51
|
+
### Patch Changes
|
52
|
+
|
53
|
+
- Cache CoValue proxies
|
54
|
+
- Updated dependencies
|
55
|
+
- cojson@0.7.0-alpha.35
|
56
|
+
- cojson-transport-nodejs-ws@0.7.0-alpha.35
|
57
|
+
|
58
|
+
## 0.7.0-alpha.34
|
59
|
+
|
60
|
+
### Patch Changes
|
61
|
+
|
62
|
+
- Extract jazz cli into jazz-run package
|
63
|
+
|
64
|
+
## 0.7.0-alpha.32
|
65
|
+
|
66
|
+
### Patch Changes
|
67
|
+
|
68
|
+
- Introduce jazz-tools CLI
|
69
|
+
- Clean up exports
|
70
|
+
|
71
|
+
## 0.7.0-alpha.31
|
72
|
+
|
73
|
+
### Patch Changes
|
74
|
+
|
75
|
+
- Get rid of self generics, new create syntax
|
76
|
+
|
77
|
+
## 0.7.0-alpha.30
|
78
|
+
|
79
|
+
### Patch Changes
|
80
|
+
|
81
|
+
- CoValue casting & auto-subbing \_owner
|
82
|
+
|
83
|
+
## 0.7.0-alpha.29
|
84
|
+
|
85
|
+
### Patch Changes
|
86
|
+
|
87
|
+
- Reintroduce changes from main
|
88
|
+
- Updated dependencies
|
89
|
+
- cojson@0.7.0-alpha.29
|
90
|
+
|
91
|
+
## 0.7.0-alpha.28
|
92
|
+
|
93
|
+
### Patch Changes
|
94
|
+
|
95
|
+
- Implement profile visibility based on groups & new migration signature
|
96
|
+
- Updated dependencies
|
97
|
+
- cojson@0.7.0-alpha.28
|
98
|
+
|
99
|
+
## 0.7.0-alpha.27
|
100
|
+
|
101
|
+
### Patch Changes
|
102
|
+
|
103
|
+
- Fix CoList.splice / RawCoList.append
|
104
|
+
- Fix Costream[...].all
|
105
|
+
- Updated dependencies
|
106
|
+
- cojson@0.7.0-alpha.27
|
107
|
+
|
108
|
+
## 0.7.0-alpha.26
|
109
|
+
|
110
|
+
### Patch Changes
|
111
|
+
|
112
|
+
- Fix CoMap.Record.toJSON()
|
113
|
+
|
114
|
+
## 0.7.0-alpha.25
|
115
|
+
|
116
|
+
### Patch Changes
|
117
|
+
|
118
|
+
- Make Account -> Profile a lazy ref schema
|
119
|
+
|
120
|
+
## 0.7.0-alpha.24
|
121
|
+
|
122
|
+
### Patch Changes
|
123
|
+
|
124
|
+
- Relax types of CoMap.\_schema
|
125
|
+
- Fix schema of Account & Group
|
126
|
+
- Make sure delete on CoMaps deletes keys
|
127
|
+
- Updated dependencies
|
128
|
+
- cojson@0.7.0-alpha.24
|
129
|
+
|
130
|
+
## 0.7.0-alpha.23
|
131
|
+
|
132
|
+
### Patch Changes
|
133
|
+
|
134
|
+
- CoMap fixes and improvements
|
135
|
+
|
136
|
+
## 0.7.0-alpha.22
|
137
|
+
|
138
|
+
### Patch Changes
|
139
|
+
|
140
|
+
- Fix CoMap \_refs for co.items
|
141
|
+
|
142
|
+
## 0.7.0-alpha.21
|
143
|
+
|
144
|
+
### Patch Changes
|
145
|
+
|
146
|
+
- Add maxWidth option for loading images
|
147
|
+
|
148
|
+
## 0.7.0-alpha.20
|
149
|
+
|
150
|
+
### Patch Changes
|
151
|
+
|
152
|
+
- Make fast-check a direct dependency to help dev time resolution
|
153
|
+
|
154
|
+
## 0.7.0-alpha.19
|
155
|
+
|
156
|
+
### Patch Changes
|
157
|
+
|
158
|
+
- More precise imports from @effect/schema
|
159
|
+
|
160
|
+
## 0.7.0-alpha.17
|
161
|
+
|
162
|
+
### Patch Changes
|
163
|
+
|
164
|
+
- Use effect 3.0
|
165
|
+
|
166
|
+
## 0.7.0-alpha.16
|
167
|
+
|
168
|
+
### Patch Changes
|
169
|
+
|
170
|
+
- Make CoMaps even more subclassable
|
171
|
+
|
172
|
+
## 0.7.0-alpha.15
|
173
|
+
|
174
|
+
### Patch Changes
|
175
|
+
|
176
|
+
- More superclass-compatible CoMaps
|
177
|
+
|
178
|
+
## 0.7.0-alpha.14
|
179
|
+
|
180
|
+
### Patch Changes
|
181
|
+
|
182
|
+
- Fix CoStream types
|
183
|
+
|
184
|
+
## 0.7.0-alpha.13
|
185
|
+
|
186
|
+
### Patch Changes
|
187
|
+
|
188
|
+
- Add .all to CoStreamEntry
|
189
|
+
|
190
|
+
## 0.7.0-alpha.12
|
191
|
+
|
192
|
+
### Patch Changes
|
193
|
+
|
194
|
+
- Fix variance of ID.\_\_type
|
195
|
+
|
196
|
+
## 0.7.0-alpha.11
|
197
|
+
|
198
|
+
### Patch Changes
|
199
|
+
|
200
|
+
- Support stricter TS lint rules
|
201
|
+
- Updated dependencies
|
202
|
+
- cojson@0.7.0-alpha.11
|
203
|
+
|
204
|
+
## 0.7.0-alpha.10
|
205
|
+
|
206
|
+
### Patch Changes
|
207
|
+
|
208
|
+
- Clean up API more & re-add jazz-nodejs
|
209
|
+
- Updated dependencies
|
210
|
+
- cojson@0.7.0-alpha.10
|
211
|
+
|
212
|
+
## 0.7.0-alpha.9
|
213
|
+
|
214
|
+
### Patch Changes
|
215
|
+
|
216
|
+
- Even friendlier for subclassing CoMap
|
217
|
+
|
218
|
+
## 0.7.0-alpha.8
|
219
|
+
|
220
|
+
### Patch Changes
|
221
|
+
|
222
|
+
- More subclass-friendly types in CoMap
|
223
|
+
|
224
|
+
## 0.7.0-alpha.7
|
225
|
+
|
226
|
+
### Patch Changes
|
227
|
+
|
228
|
+
- Consistent proxy based API
|
229
|
+
- Updated dependencies
|
230
|
+
- cojson@0.7.0-alpha.7
|
231
|
+
|
232
|
+
## 0.7.0-alpha.6
|
233
|
+
|
234
|
+
### Patch Changes
|
235
|
+
|
236
|
+
- CoMap fix
|
237
|
+
|
238
|
+
## 0.7.0-alpha.5
|
239
|
+
|
240
|
+
### Patch Changes
|
241
|
+
|
242
|
+
- Refactoring
|
243
|
+
- Updated dependencies
|
244
|
+
- cojson@0.7.0-alpha.5
|
245
|
+
|
3
246
|
## 0.7.0-alpha.4
|
4
247
|
|
5
248
|
### Patch Changes
|
package/README.md
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
-
#
|
1
|
+
# `jazz-tools`
|
2
2
|
|
3
|
-
|
3
|
+
The base implementation for Jazz (see [jazz.tools](https://jazz.tools)), a framework for distributed state.
|
4
|
+
|
5
|
+
Provides a high-level API around the CoJSON protocol.
|
6
|
+
|
7
|
+
## Environments and bindings
|
8
|
+
|
9
|
+
- `jazz-browser` (Vanilla JavaScript)
|
10
|
+
- `jazz-react` (React apps)
|
11
|
+
- `jazz-nodejs` (NodeJS or Bun server workers)
|
package/dist/coValues/account.js
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
var _a;
|
2
2
|
import { LocalNode } from "cojson";
|
3
3
|
import { Context } from "effect";
|
4
|
-
import { CoValueBase, Profile,
|
4
|
+
import { Group, CoValueBase, MembersSym, Profile, Ref, SchemaInit, inspect, subscriptionsScopes, } from "../internal.js";
|
5
|
+
/** @category Identity & Permissions */
|
5
6
|
export class Account extends CoValueBase {
|
6
|
-
get
|
7
|
-
return this.constructor.
|
7
|
+
get _schema() {
|
8
|
+
return this.constructor._schema;
|
8
9
|
}
|
9
10
|
get _owner() {
|
10
11
|
return this;
|
@@ -18,22 +19,14 @@ export class Account extends CoValueBase {
|
|
18
19
|
const profileID = this._raw.get("profile");
|
19
20
|
const rootID = this._raw.get("root");
|
20
21
|
return {
|
21
|
-
profile: profileID &&
|
22
|
+
profile: profileID &&
|
23
|
+
new Ref(profileID, this._loadedAs, this._schema.profile),
|
22
24
|
root: rootID &&
|
23
|
-
new
|
25
|
+
new Ref(rootID, this._loadedAs, this._schema.root),
|
24
26
|
};
|
25
27
|
}
|
26
|
-
constructor(
|
28
|
+
constructor(options) {
|
27
29
|
super();
|
28
|
-
this.acceptInvite = (async (valueID, inviteSecret, coValueClass) => {
|
29
|
-
if (!this.isMe) {
|
30
|
-
throw new Error("Only a controlled account can accept invites");
|
31
|
-
}
|
32
|
-
await this._raw.acceptInvite(valueID, inviteSecret);
|
33
|
-
return coValueClass.load(valueID, {
|
34
|
-
as: this,
|
35
|
-
});
|
36
|
-
});
|
37
30
|
if (!("fromRaw" in options)) {
|
38
31
|
throw new Error("Can only construct account from raw or with .create()");
|
39
32
|
}
|
@@ -44,47 +37,35 @@ export class Account extends CoValueBase {
|
|
44
37
|
enumerable: false,
|
45
38
|
},
|
46
39
|
_raw: { value: options.fromRaw, enumerable: false },
|
47
|
-
|
48
|
-
get: () => {
|
49
|
-
const ref = this._refs.profile;
|
50
|
-
return ref ? ref.accessFrom(this) : undefined;
|
51
|
-
},
|
52
|
-
set: (value) => {
|
53
|
-
if (value) {
|
54
|
-
this._raw.set("profile", value.id);
|
55
|
-
}
|
56
|
-
},
|
57
|
-
},
|
58
|
-
root: {
|
59
|
-
get: () => {
|
60
|
-
const ref = this._refs.root;
|
61
|
-
return ref ? ref.accessFrom(this) : undefined;
|
62
|
-
},
|
63
|
-
set: (value) => {
|
64
|
-
if (value) {
|
65
|
-
this._raw.set("root", value.id);
|
66
|
-
}
|
67
|
-
},
|
68
|
-
},
|
40
|
+
_type: { value: "Account", enumerable: false },
|
69
41
|
});
|
70
42
|
if (this.isMe) {
|
71
43
|
this.sessionID =
|
72
44
|
options.fromRaw.core.node.currentSessionID;
|
73
45
|
}
|
46
|
+
return new Proxy(this, AccountAndGroupProxyHandler);
|
74
47
|
}
|
75
48
|
myRole() {
|
76
49
|
if (this.isMe) {
|
77
50
|
return "admin";
|
78
51
|
}
|
79
52
|
}
|
53
|
+
async acceptInvite(valueID, inviteSecret, coValueClass) {
|
54
|
+
if (!this.isMe) {
|
55
|
+
throw new Error("Only a controlled account can accept invites");
|
56
|
+
}
|
57
|
+
await this._raw.acceptInvite(valueID, inviteSecret);
|
58
|
+
return coValueClass.load(valueID, this, []);
|
59
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
60
|
+
}
|
80
61
|
static async create(options) {
|
81
62
|
const { node } = await LocalNode.withNewlyCreatedAccount({
|
82
63
|
...options,
|
83
|
-
migration: async (rawAccount) => {
|
84
|
-
const account = new this(
|
64
|
+
migration: async (rawAccount, _node, creationProps) => {
|
65
|
+
const account = new this({
|
85
66
|
fromRaw: rawAccount,
|
86
67
|
});
|
87
|
-
await account.migrate?.();
|
68
|
+
await account.migrate?.(creationProps);
|
88
69
|
},
|
89
70
|
});
|
90
71
|
return this.fromNode(node);
|
@@ -95,20 +76,22 @@ export class Account extends CoValueBase {
|
|
95
76
|
accountSecret: options.accountSecret,
|
96
77
|
sessionID: options.sessionID,
|
97
78
|
peersToLoadFrom: options.peersToLoadFrom,
|
98
|
-
|
99
|
-
|
79
|
+
crypto: options.crypto,
|
80
|
+
migration: async (rawAccount, _node, creationProps) => {
|
81
|
+
const account = new this({
|
100
82
|
fromRaw: rawAccount,
|
101
83
|
});
|
102
|
-
await account.migrate?.();
|
84
|
+
await account.migrate?.(creationProps);
|
103
85
|
},
|
104
86
|
});
|
105
87
|
return this.fromNode(node);
|
106
88
|
}
|
107
89
|
static fromNode(node) {
|
108
|
-
return new this(
|
90
|
+
return new this({
|
109
91
|
fromRaw: node.account,
|
110
92
|
});
|
111
93
|
}
|
94
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
112
95
|
toJSON() {
|
113
96
|
return {
|
114
97
|
id: this.id,
|
@@ -118,20 +101,91 @@ export class Account extends CoValueBase {
|
|
118
101
|
[inspect]() {
|
119
102
|
return this.toJSON();
|
120
103
|
}
|
121
|
-
|
122
|
-
|
123
|
-
|
104
|
+
migrate(creationProps) {
|
105
|
+
if (creationProps) {
|
106
|
+
const profileGroup = Group.create({ owner: this });
|
107
|
+
profileGroup.addMember("everyone", "reader");
|
108
|
+
this.profile = Profile.create({ name: creationProps.name }, { owner: profileGroup });
|
109
|
+
}
|
124
110
|
}
|
125
111
|
}
|
126
112
|
_a = Account;
|
127
113
|
(() => {
|
128
|
-
_a.
|
129
|
-
profile:
|
130
|
-
root:
|
114
|
+
_a._schema = {
|
115
|
+
profile: () => Profile,
|
116
|
+
root: "json",
|
117
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
131
118
|
};
|
132
119
|
})();
|
120
|
+
export const AccountAndGroupProxyHandler = {
|
121
|
+
get(target, key, receiver) {
|
122
|
+
if (key === "profile") {
|
123
|
+
const ref = target._refs.profile;
|
124
|
+
return ref
|
125
|
+
? ref.accessFrom(receiver, "profile")
|
126
|
+
: // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
127
|
+
undefined;
|
128
|
+
}
|
129
|
+
else if (key === "root") {
|
130
|
+
const ref = target._refs.root;
|
131
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
132
|
+
return ref ? ref.accessFrom(receiver, "root") : undefined;
|
133
|
+
}
|
134
|
+
else {
|
135
|
+
return Reflect.get(target, key, receiver);
|
136
|
+
}
|
137
|
+
},
|
138
|
+
set(target, key, value, receiver) {
|
139
|
+
var _b;
|
140
|
+
if ((key === "profile" || key === "root" || key === MembersSym) &&
|
141
|
+
typeof value === "object" &&
|
142
|
+
SchemaInit in value) {
|
143
|
+
(_b = target.constructor)._schema || (_b._schema = {});
|
144
|
+
target.constructor._schema[key] =
|
145
|
+
value[SchemaInit];
|
146
|
+
return true;
|
147
|
+
}
|
148
|
+
else if (key === "profile") {
|
149
|
+
if (value) {
|
150
|
+
target._raw.set("profile", value.id, "trusting");
|
151
|
+
}
|
152
|
+
subscriptionsScopes
|
153
|
+
.get(receiver)
|
154
|
+
?.onRefAccessedOrSet(target.id, value.id);
|
155
|
+
return true;
|
156
|
+
}
|
157
|
+
else if (key === "root") {
|
158
|
+
if (value) {
|
159
|
+
target._raw.set("root", value.id);
|
160
|
+
}
|
161
|
+
subscriptionsScopes
|
162
|
+
.get(receiver)
|
163
|
+
?.onRefAccessedOrSet(target.id, value.id);
|
164
|
+
return true;
|
165
|
+
}
|
166
|
+
else {
|
167
|
+
return Reflect.set(target, key, value, receiver);
|
168
|
+
}
|
169
|
+
},
|
170
|
+
defineProperty(target, key, descriptor) {
|
171
|
+
var _b;
|
172
|
+
if ((key === "profile" || key === "root" || key === MembersSym) &&
|
173
|
+
typeof descriptor.value === "object" &&
|
174
|
+
SchemaInit in descriptor.value) {
|
175
|
+
(_b = target.constructor)._schema || (_b._schema = {});
|
176
|
+
target.constructor._schema[key] =
|
177
|
+
descriptor.value[SchemaInit];
|
178
|
+
return true;
|
179
|
+
}
|
180
|
+
else {
|
181
|
+
return Reflect.defineProperty(target, key, descriptor);
|
182
|
+
}
|
183
|
+
},
|
184
|
+
};
|
185
|
+
/** @category Identity & Permissions */
|
133
186
|
export class AccountCtx extends Context.Tag("Account")() {
|
134
187
|
}
|
188
|
+
/** @category Identity & Permissions */
|
135
189
|
export function isControlledAccount(account) {
|
136
190
|
return account.isMe;
|
137
191
|
}
|