jazz-tools 0.7.0-alpha.3 → 0.7.0-alpha.30
Sign up to get free protection for your applications and to get access to all the features.
- package/.turbo/turbo-build.log +80 -8
- package/CHANGELOG.md +175 -0
- package/dist/coValues/account.js +78 -38
- package/dist/coValues/account.js.map +1 -1
- package/dist/coValues/coList.js +150 -99
- package/dist/coValues/coList.js.map +1 -1
- package/dist/coValues/coMap.js +178 -162
- package/dist/coValues/coMap.js.map +1 -1
- package/dist/coValues/coStream.js +195 -70
- package/dist/coValues/coStream.js.map +1 -1
- package/dist/coValues/extensions/imageDef.js +13 -8
- package/dist/coValues/extensions/imageDef.js.map +1 -1
- package/dist/coValues/group.js +40 -36
- package/dist/coValues/group.js.map +1 -1
- package/dist/coValues/interfaces.js +22 -4
- package/dist/coValues/interfaces.js.map +1 -1
- package/dist/implementation/refs.js +26 -12
- package/dist/implementation/refs.js.map +1 -1
- package/dist/implementation/schema.js +38 -1
- package/dist/implementation/schema.js.map +1 -1
- package/dist/implementation/symbols.js +5 -0
- package/dist/implementation/symbols.js.map +1 -0
- package/dist/index.js +4 -3
- package/dist/index.js.map +1 -1
- package/dist/internal.js +1 -0
- package/dist/internal.js.map +1 -1
- package/dist/tests/coList.test.js +20 -24
- package/dist/tests/coList.test.js.map +1 -1
- package/dist/tests/coMap.test.js +154 -43
- package/dist/tests/coMap.test.js.map +1 -1
- package/dist/tests/coStream.test.js +50 -55
- package/dist/tests/coStream.test.js.map +1 -1
- package/dist/tests/groupsAndAccounts.test.js +86 -0
- package/dist/tests/groupsAndAccounts.test.js.map +1 -0
- package/package.json +5 -4
- package/src/coValues/account.ts +116 -75
- package/src/coValues/coList.ts +189 -125
- package/src/coValues/coMap.ts +238 -295
- package/src/coValues/coStream.ts +282 -124
- package/src/coValues/extensions/imageDef.ts +13 -15
- package/src/coValues/group.ts +85 -85
- package/src/coValues/interfaces.ts +32 -11
- package/src/implementation/refs.ts +42 -25
- package/src/implementation/schema.ts +68 -46
- package/src/implementation/symbols.ts +12 -0
- package/src/index.ts +10 -8
- package/src/internal.ts +1 -0
- package/src/tests/coList.test.ts +20 -24
- package/src/tests/coMap.test.ts +153 -58
- package/src/tests/coStream.test.ts +65 -70
- package/src/tests/groupsAndAccounts.test.ts +96 -0
@@ -1,10 +1,13 @@
|
|
1
1
|
import { Effect } from "effect";
|
2
|
-
import { subscriptionsScopes } from "../internal.js";
|
3
|
-
export class
|
4
|
-
constructor(id, controlledAccount,
|
2
|
+
import { instantiateRefEncoded, isRefEncoded, subscriptionsScopes, } from "../internal.js";
|
3
|
+
export class Ref {
|
4
|
+
constructor(id, controlledAccount, schema) {
|
5
5
|
this.id = id;
|
6
6
|
this.controlledAccount = controlledAccount;
|
7
|
-
this.
|
7
|
+
this.schema = schema;
|
8
|
+
if (!isRefEncoded(schema)) {
|
9
|
+
throw new Error("Ref must be constructed with a ref schema");
|
10
|
+
}
|
8
11
|
}
|
9
12
|
get value() {
|
10
13
|
if (this.cachedValue)
|
@@ -12,9 +15,7 @@ export class ValueRef {
|
|
12
15
|
// TODO: cache it for object identity!!!
|
13
16
|
const raw = this.controlledAccount._raw.core.node.getLoaded(this.id);
|
14
17
|
if (raw) {
|
15
|
-
const value =
|
16
|
-
fromRaw: raw,
|
17
|
-
});
|
18
|
+
const value = instantiateRefEncoded(this.schema, raw);
|
18
19
|
this.cachedValue = value;
|
19
20
|
return value;
|
20
21
|
}
|
@@ -44,7 +45,7 @@ export class ValueRef {
|
|
44
45
|
return "unavailable";
|
45
46
|
}
|
46
47
|
else {
|
47
|
-
return new
|
48
|
+
return new Ref(this.id, this.controlledAccount, this.schema).value;
|
48
49
|
}
|
49
50
|
}
|
50
51
|
async load(options) {
|
@@ -65,14 +66,14 @@ export class ValueRef {
|
|
65
66
|
return this.value;
|
66
67
|
}
|
67
68
|
}
|
68
|
-
export function makeRefs(getIdForKey, getKeysWithIds, controlledAccount,
|
69
|
+
export function makeRefs(getIdForKey, getKeysWithIds, controlledAccount, refSchemaForKey) {
|
69
70
|
const refs = {};
|
70
71
|
return new Proxy(refs, {
|
71
|
-
get(
|
72
|
+
get(_target, key) {
|
72
73
|
if (key === Symbol.iterator) {
|
73
74
|
return function* () {
|
74
75
|
for (const key of getKeysWithIds()) {
|
75
|
-
yield new
|
76
|
+
yield new Ref(getIdForKey(key), controlledAccount, refSchemaForKey(key));
|
76
77
|
}
|
77
78
|
};
|
78
79
|
}
|
@@ -84,11 +85,24 @@ export function makeRefs(getIdForKey, getKeysWithIds, controlledAccount, valueCo
|
|
84
85
|
const id = getIdForKey(key);
|
85
86
|
if (!id)
|
86
87
|
return undefined;
|
87
|
-
return new
|
88
|
+
return new Ref(id, controlledAccount, refSchemaForKey(key));
|
88
89
|
},
|
89
90
|
ownKeys() {
|
90
91
|
return getKeysWithIds().map((key) => key.toString());
|
91
92
|
},
|
93
|
+
getOwnPropertyDescriptor(target, key) {
|
94
|
+
const id = getIdForKey(key);
|
95
|
+
if (id) {
|
96
|
+
return {
|
97
|
+
enumerable: true,
|
98
|
+
configurable: true,
|
99
|
+
writable: true,
|
100
|
+
};
|
101
|
+
}
|
102
|
+
else {
|
103
|
+
return Reflect.getOwnPropertyDescriptor(target, key);
|
104
|
+
}
|
105
|
+
},
|
92
106
|
});
|
93
107
|
}
|
94
108
|
//# sourceMappingURL=refs.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"refs.js","sourceRoot":"","sources":["../../src/implementation/refs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;
|
1
|
+
{"version":3,"file":"refs.js","sourceRoot":"","sources":["../../src/implementation/refs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAUhC,OAAO,EACH,qBAAqB,EACrB,YAAY,EACZ,mBAAmB,GACtB,MAAM,gBAAgB,CAAC;AAExB,MAAM,OAAO,GAAG;IAGZ,YACa,EAAS,EACT,iBAA+B,EAC/B,MAAqB;QAFrB,OAAE,GAAF,EAAE,CAAO;QAC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
|
+
[SchemaInit]: "json",
|
5
|
+
},
|
6
|
+
number: {
|
7
|
+
[SchemaInit]: "json",
|
8
|
+
},
|
9
|
+
boolean: {
|
10
|
+
[SchemaInit]: "json",
|
11
|
+
},
|
12
|
+
null: {
|
13
|
+
[SchemaInit]: "json",
|
14
|
+
},
|
15
|
+
literal: (_lit) => {
|
16
|
+
return { [SchemaInit]: "json" };
|
17
|
+
},
|
18
|
+
json: () => {
|
19
|
+
return { [SchemaInit]: "json" };
|
20
|
+
},
|
21
|
+
encoded: (arg) => {
|
22
|
+
return { [SchemaInit]: { encoded: arg } };
|
23
|
+
},
|
24
|
+
ref: (arg) => {
|
25
|
+
return { [SchemaInit]: arg };
|
26
|
+
},
|
27
|
+
items: ItemsSym,
|
28
|
+
members: MembersSym,
|
29
|
+
};
|
30
|
+
export function isRefEncoded(schema) {
|
31
|
+
return typeof schema === "function";
|
32
|
+
}
|
33
|
+
export function instantiateRefEncoded(schema, raw) {
|
34
|
+
return isCoValueClass(schema)
|
35
|
+
? schema.fromRaw(raw)
|
36
|
+
: schema(raw).fromRaw(raw);
|
37
|
+
}
|
1
38
|
import { Date } from "@effect/schema/Schema";
|
39
|
+
import { SchemaInit, ItemsSym, MembersSym } from "./symbols.js";
|
2
40
|
export const Encoders = {
|
3
41
|
Date,
|
4
42
|
};
|
5
|
-
export const indexSignature = Symbol.for("indexSignature");
|
6
43
|
//# sourceMappingURL=schema.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../src/implementation/schema.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../src/implementation/schema.ts"],"names":[],"mappings":"AACA,OAAO,EAAmC,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAWjF,MAAM,CAAC,MAAM,EAAE,GAAG;IACd,MAAM,EAAE;QACJ,CAAC,UAAU,CAAC,EAAE,MAAuB;KACf;IAC1B,MAAM,EAAE;QACJ,CAAC,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|
+
{"version":3,"file":"symbols.js","sourceRoot":"","sources":["../../src/implementation/symbols.ts"],"names":[],"mappings":"AACA,MAAM,CAAC,MAAM,UAAU,GAAG,MAAM,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;AAGnD,MAAM,CAAC,MAAM,UAAU,GAAG,MAAM,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;AAGnD,MAAM,CAAC,MAAM,QAAQ,GAAG,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;AAG5C,MAAM,CAAC,MAAM,UAAU,GAAG,MAAM,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC"}
|
package/dist/index.js
CHANGED
@@ -1,7 +1,8 @@
|
|
1
|
+
export {
|
1
2
|
/** @category Internal types */
|
2
|
-
|
3
|
-
export { Encoders } from "./internal.js";
|
4
|
-
export { CoMap
|
3
|
+
cojsonReady as jazzReady, cojsonInternals, MAX_RECOMMENDED_TX_SIZE, } from "cojson";
|
4
|
+
export { Encoders, co } from "./internal.js";
|
5
|
+
export { CoMap } from "./internal.js";
|
5
6
|
export { CoList } from "./internal.js";
|
6
7
|
export { CoStream, BinaryCoStream } from "./internal.js";
|
7
8
|
export { Group, Profile } from "./internal.js";
|
package/dist/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO;AACH,+BAA+B;AAC/B,WAAW,IAAI,SAAS,EACxB,eAAe,EACf,uBAAuB,GAC1B,MAAM,QAAQ,CAAC;AAWhB,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,eAAe,CAAC;AAE7C,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AACzD,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,OAAO,EAAW,MAAM,eAAe,CAAC;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,WAAW,EAAqB,MAAM,eAAe,CAAC"}
|
package/dist/internal.js
CHANGED
package/dist/internal.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"internal.js","sourceRoot":"","sources":["../src/internal.ts"],"names":[],"mappings":"AAAA,cAAc,6BAA6B,CAAC;AAC5C,cAAc,0BAA0B,CAAC;AAEzC,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AACvC,cAAc,qBAAqB,CAAC;AAEpC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,0BAA0B,CAAC;AACzC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,uCAAuC,CAAC;AAEtD,cAAc,mCAAmC,CAAC"}
|
1
|
+
{"version":3,"file":"internal.js","sourceRoot":"","sources":["../src/internal.ts"],"names":[],"mappings":"AAAA,cAAc,6BAA6B,CAAC;AAC5C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,0BAA0B,CAAC;AAEzC,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AACvC,cAAc,qBAAqB,CAAC;AAEpC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,0BAA0B,CAAC;AACzC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,uCAAuC,CAAC;AAEtD,cAAc,mCAAmC,CAAC"}
|
@@ -3,7 +3,7 @@ import { webcrypto } from "node:crypto";
|
|
3
3
|
import { connectedPeers } from "cojson/src/streamUtils.js";
|
4
4
|
import { newRandomSessionID } from "cojson/src/coValueCore.js";
|
5
5
|
import { Effect, Queue } from "effect";
|
6
|
-
import { Account, CoList, jazzReady } from "..";
|
6
|
+
import { Account, CoList, co, jazzReady } from "..";
|
7
7
|
if (!("crypto" in globalThis)) {
|
8
8
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
9
9
|
globalThis.crypto = webcrypto;
|
@@ -13,11 +13,10 @@ beforeEach(async () => {
|
|
13
13
|
});
|
14
14
|
describe("Simple CoList operations", async () => {
|
15
15
|
const me = await Account.create({
|
16
|
-
name: "Hermes Puggington",
|
16
|
+
creationProps: { name: "Hermes Puggington" },
|
17
17
|
});
|
18
|
-
class TestList extends CoList {
|
18
|
+
class TestList extends CoList.Of(co.string) {
|
19
19
|
}
|
20
|
-
TestList.encoding({ _item: "json" });
|
21
20
|
const list = new TestList(["bread", "butter", "onion"], { owner: me });
|
22
21
|
test("Construction", () => {
|
23
22
|
expect(list[0]).toBe("bread");
|
@@ -86,37 +85,34 @@ describe("Simple CoList operations", async () => {
|
|
86
85
|
expect(list.length).toBe(2);
|
87
86
|
expect(list._raw.asArray()).toEqual(["butter", "onion"]);
|
88
87
|
});
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
88
|
+
test("splice", () => {
|
89
|
+
const list = new TestList(["bread", "butter", "onion"], {
|
90
|
+
owner: me,
|
91
|
+
});
|
92
|
+
list.splice(1, 1, "salt", "pepper");
|
93
|
+
expect(list.length).toBe(4);
|
94
|
+
expect(list._raw.asArray()).toEqual([
|
95
|
+
"bread",
|
96
|
+
"salt",
|
97
|
+
"pepper",
|
98
|
+
"onion",
|
99
|
+
]);
|
100
|
+
});
|
102
101
|
});
|
103
102
|
});
|
104
103
|
describe("CoList resolution", async () => {
|
105
|
-
class TwiceNestedList extends CoList {
|
104
|
+
class TwiceNestedList extends CoList.Of(co.string) {
|
106
105
|
joined() {
|
107
106
|
return this.join(",");
|
108
107
|
}
|
109
108
|
}
|
110
|
-
|
111
|
-
class NestedList extends CoList {
|
109
|
+
class NestedList extends CoList.Of(co.ref(TwiceNestedList)) {
|
112
110
|
}
|
113
|
-
|
114
|
-
class TestList extends CoList {
|
111
|
+
class TestList extends CoList.Of(co.ref(NestedList)) {
|
115
112
|
}
|
116
|
-
TestList.encoding({ _item: { ref: () => NestedList } });
|
117
113
|
const initNodeAndList = async () => {
|
118
114
|
const me = await Account.create({
|
119
|
-
name: "Hermes Puggington",
|
115
|
+
creationProps: { name: "Hermes Puggington" },
|
120
116
|
});
|
121
117
|
const list = new TestList([
|
122
118
|
new NestedList([new TwiceNestedList(["a", "b"], { owner: me })], { owner: me }),
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"coList.test.js","sourceRoot":"","sources":["../../src/tests/coList.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAE5D,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,IAAI,CAAC;AAEhD,IAAI,CAAC,CAAC,QAAQ,IAAI,UAAU,CAAC,EAAE,CAAC;IAC5B,8DAA8D;IAC7D,UAAkB,CAAC,MAAM,GAAG,SAAS,CAAC;AAC3C,CAAC;AAED,UAAU,CAAC,KAAK,IAAI,EAAE;IAClB,MAAM,SAAS,CAAC;AACpB,CAAC,CAAC,CAAC;AAEH,QAAQ,CAAC,0BAA0B,EAAE,KAAK,IAAI,EAAE;IAC5C,MAAM,EAAE,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AO,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;YAC5C,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAC7C,CAAC,CAAC,CACL,CAAC;IACN,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
|
package/dist/tests/coMap.test.js
CHANGED
@@ -3,7 +3,7 @@ import { webcrypto } from "node:crypto";
|
|
3
3
|
import { connectedPeers } from "cojson/src/streamUtils.js";
|
4
4
|
import { newRandomSessionID } from "cojson/src/coValueCore.js";
|
5
5
|
import { Effect, Queue } from "effect";
|
6
|
-
import { Account, jazzReady, Encoders,
|
6
|
+
import { Account, jazzReady, Encoders, CoMap, co } from "..";
|
7
7
|
if (!("crypto" in globalThis)) {
|
8
8
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
9
9
|
globalThis.crypto = webcrypto;
|
@@ -13,35 +13,37 @@ beforeEach(async () => {
|
|
13
13
|
});
|
14
14
|
describe("Simple CoMap operations", async () => {
|
15
15
|
const me = await Account.create({
|
16
|
-
name: "Hermes Puggington",
|
16
|
+
creationProps: { name: "Hermes Puggington" },
|
17
17
|
});
|
18
18
|
class TestMap extends CoMap {
|
19
|
-
|
19
|
+
constructor() {
|
20
|
+
super(...arguments);
|
21
|
+
this.color = co.string;
|
22
|
+
this._height = co.number;
|
23
|
+
this.birthday = co.encoded(Encoders.Date);
|
24
|
+
this.name = co.string;
|
25
|
+
}
|
26
|
+
get roughColor() {
|
20
27
|
return this.color + "ish";
|
21
28
|
}
|
22
29
|
}
|
23
|
-
TestMap.
|
24
|
-
color: "json",
|
25
|
-
height: "json",
|
26
|
-
birthday: { encoded: Encoders.Date },
|
27
|
-
name: "json",
|
28
|
-
});
|
29
|
-
console.log("TestMap schema", TestMap.prototype._encoding);
|
30
|
+
console.log("TestMap schema", TestMap.prototype._schema);
|
30
31
|
const birthday = new Date();
|
31
32
|
const map = new TestMap({
|
32
33
|
color: "red",
|
33
|
-
|
34
|
+
_height: 10,
|
34
35
|
birthday: birthday,
|
35
36
|
}, { owner: me });
|
36
37
|
test("Construction", () => {
|
37
38
|
expect(map.color).toEqual("red");
|
38
|
-
expect(map.
|
39
|
-
expect(map.
|
39
|
+
expect(map.roughColor).toEqual("redish");
|
40
|
+
expect(map._height).toEqual(10);
|
40
41
|
expect(map.birthday).toEqual(birthday);
|
41
42
|
expect(map._raw.get("birthday")).toEqual(birthday.toISOString());
|
43
|
+
expect(Object.keys(map)).toEqual(["color", "_height", "birthday"]);
|
42
44
|
});
|
43
45
|
describe("Mutation", () => {
|
44
|
-
test("assignment", () => {
|
46
|
+
test("assignment & deletion", () => {
|
45
47
|
map.color = "blue";
|
46
48
|
expect(map.color).toEqual("blue");
|
47
49
|
expect(map._raw.get("color")).toEqual("blue");
|
@@ -49,23 +51,28 @@ describe("Simple CoMap operations", async () => {
|
|
49
51
|
map.birthday = newBirthday;
|
50
52
|
expect(map.birthday).toEqual(newBirthday);
|
51
53
|
expect(map._raw.get("birthday")).toEqual(newBirthday.toISOString());
|
52
|
-
Object.assign(map, { color: "green",
|
54
|
+
Object.assign(map, { color: "green", _height: 20 });
|
53
55
|
expect(map.color).toEqual("green");
|
54
56
|
expect(map._raw.get("color")).toEqual("green");
|
55
|
-
expect(map.
|
56
|
-
expect(map._raw.get("
|
57
|
+
expect(map._height).toEqual(20);
|
58
|
+
expect(map._raw.get("_height")).toEqual(20);
|
57
59
|
map.name = "Secret name";
|
58
60
|
expect(map.name).toEqual("Secret name");
|
59
61
|
map.name = undefined;
|
60
62
|
expect(map.name).toEqual(undefined);
|
63
|
+
expect(Object.keys(map)).toContain("name");
|
64
|
+
delete map.name;
|
65
|
+
expect(map.name).toEqual(undefined);
|
66
|
+
expect(Object.keys(map)).not.toContain("name");
|
61
67
|
});
|
62
68
|
});
|
63
69
|
class RecursiveMap extends CoMap {
|
70
|
+
constructor() {
|
71
|
+
super(...arguments);
|
72
|
+
this.name = co.string;
|
73
|
+
this.next = co.ref(RecursiveMap);
|
74
|
+
}
|
64
75
|
}
|
65
|
-
RecursiveMap.encoding({
|
66
|
-
name: "json",
|
67
|
-
next: { ref: () => RecursiveMap },
|
68
|
-
});
|
69
76
|
const recursiveMap = new RecursiveMap({
|
70
77
|
name: "first",
|
71
78
|
next: new RecursiveMap({
|
@@ -82,35 +89,94 @@ describe("Simple CoMap operations", async () => {
|
|
82
89
|
expect(recursiveMap.next?.next?.name).toEqual("third");
|
83
90
|
});
|
84
91
|
});
|
92
|
+
class MapWithEnumOfMaps extends CoMap {
|
93
|
+
constructor() {
|
94
|
+
super(...arguments);
|
95
|
+
this.name = co.string;
|
96
|
+
this.child = co.ref((raw) => raw.get("type") === "a" ? ChildA : ChildB);
|
97
|
+
}
|
98
|
+
}
|
99
|
+
class ChildA extends CoMap {
|
100
|
+
constructor() {
|
101
|
+
super(...arguments);
|
102
|
+
this.type = co.literal("a");
|
103
|
+
this.value = co.number;
|
104
|
+
}
|
105
|
+
}
|
106
|
+
class ChildB extends CoMap {
|
107
|
+
constructor() {
|
108
|
+
super(...arguments);
|
109
|
+
this.type = co.literal("b");
|
110
|
+
this.value = co.string;
|
111
|
+
}
|
112
|
+
}
|
113
|
+
const mapWithEnum = new MapWithEnumOfMaps({
|
114
|
+
name: "enum",
|
115
|
+
child: new ChildA({
|
116
|
+
type: "a",
|
117
|
+
value: 5,
|
118
|
+
}, { owner: me }),
|
119
|
+
}, { owner: me });
|
120
|
+
test("Enum of maps", () => {
|
121
|
+
expect(mapWithEnum.name).toEqual("enum");
|
122
|
+
expect(mapWithEnum.child?.type).toEqual("a");
|
123
|
+
expect(mapWithEnum.child?.value).toEqual(5);
|
124
|
+
expect(mapWithEnum.child?.id).toBeDefined();
|
125
|
+
});
|
126
|
+
class SuperClassMap extends CoMap {
|
127
|
+
constructor() {
|
128
|
+
super(...arguments);
|
129
|
+
this.name = co.string;
|
130
|
+
}
|
131
|
+
}
|
132
|
+
class SubClassMap extends SuperClassMap {
|
133
|
+
constructor() {
|
134
|
+
super(...arguments);
|
135
|
+
this.name = co.literal("specificString");
|
136
|
+
this.value = co.number;
|
137
|
+
this.extra = co.ref(TestMap);
|
138
|
+
}
|
139
|
+
}
|
140
|
+
class GenericMapWithLoose extends CoMap {
|
141
|
+
constructor() {
|
142
|
+
super(...arguments);
|
143
|
+
this.name = co.json();
|
144
|
+
}
|
145
|
+
}
|
146
|
+
const loose = {};
|
85
147
|
});
|
86
148
|
describe("CoMap resolution", async () => {
|
149
|
+
var _a;
|
87
150
|
class TwiceNestedMap extends CoMap {
|
151
|
+
constructor() {
|
152
|
+
super(...arguments);
|
153
|
+
this.taste = co.string;
|
154
|
+
}
|
88
155
|
}
|
89
|
-
TwiceNestedMap.encoding({
|
90
|
-
taste: "json",
|
91
|
-
});
|
92
156
|
class NestedMap extends CoMap {
|
157
|
+
constructor() {
|
158
|
+
super(...arguments);
|
159
|
+
this.name = co.string;
|
160
|
+
this.twiceNested = co.ref(TwiceNestedMap);
|
161
|
+
}
|
93
162
|
get _fancyName() {
|
94
163
|
return "Sir " + this.name;
|
95
164
|
}
|
96
165
|
}
|
97
|
-
NestedMap.encoding({
|
98
|
-
name: "json",
|
99
|
-
twiceNested: { ref: () => TwiceNestedMap },
|
100
|
-
});
|
101
166
|
class TestMap extends CoMap {
|
167
|
+
constructor() {
|
168
|
+
super(...arguments);
|
169
|
+
this.color = co.string;
|
170
|
+
this.height = co.number;
|
171
|
+
this.nested = co.ref(NestedMap);
|
172
|
+
}
|
102
173
|
get _roughColor() {
|
103
174
|
return this.color + "ish";
|
104
175
|
}
|
105
176
|
}
|
106
|
-
TestMap.encoding({
|
107
|
-
color: "json",
|
108
|
-
height: "json",
|
109
|
-
nested: { ref: () => NestedMap },
|
110
|
-
});
|
111
177
|
const initNodeAndMap = async () => {
|
112
178
|
const me = await Account.create({
|
113
|
-
name: "Hermes Puggington",
|
179
|
+
creationProps: { name: "Hermes Puggington" },
|
114
180
|
});
|
115
181
|
const map = new TestMap({
|
116
182
|
color: "red",
|
@@ -220,14 +286,15 @@ describe("CoMap resolution", async () => {
|
|
220
286
|
}));
|
221
287
|
});
|
222
288
|
class TestMapWithOptionalRef extends CoMap {
|
289
|
+
constructor() {
|
290
|
+
super(...arguments);
|
291
|
+
this.color = co.string;
|
292
|
+
this.nested = co.ref(NestedMap);
|
293
|
+
}
|
223
294
|
}
|
224
|
-
TestMapWithOptionalRef.encoding({
|
225
|
-
color: "json",
|
226
|
-
nested: { ref: () => NestedMap },
|
227
|
-
});
|
228
295
|
test("Construction with optional", async () => {
|
229
296
|
const me = await Account.create({
|
230
|
-
name: "Hermes Puggington",
|
297
|
+
creationProps: { name: "Hermes Puggington" },
|
231
298
|
});
|
232
299
|
const mapWithout = new TestMapWithOptionalRef({
|
233
300
|
color: "red",
|
@@ -247,13 +314,15 @@ describe("CoMap resolution", async () => {
|
|
247
314
|
expect(mapWith.nested?._raw).toBeDefined();
|
248
315
|
});
|
249
316
|
class TestRecord extends CoMap {
|
317
|
+
constructor() {
|
318
|
+
super(...arguments);
|
319
|
+
this[_a] = co.number;
|
320
|
+
}
|
250
321
|
}
|
251
|
-
|
252
|
-
[indexSignature]: "json",
|
253
|
-
});
|
322
|
+
_a = co.items;
|
254
323
|
test("Construction with index signature", async () => {
|
255
324
|
const me = await Account.create({
|
256
|
-
name: "Hermes Puggington",
|
325
|
+
creationProps: { name: "Hermes Puggington" },
|
257
326
|
});
|
258
327
|
const record = new TestRecord({
|
259
328
|
height: 5,
|
@@ -264,6 +333,48 @@ describe("CoMap resolution", async () => {
|
|
264
333
|
expect(record.other).toEqual(3);
|
265
334
|
expect(record._raw.get("other")).toEqual(3);
|
266
335
|
expect(Object.keys(record)).toEqual(["height", "other"]);
|
336
|
+
expect(record.toJSON()).toMatchObject({
|
337
|
+
_type: "CoMap",
|
338
|
+
height: 5,
|
339
|
+
id: expect.any(String),
|
340
|
+
other: 3,
|
341
|
+
});
|
342
|
+
});
|
343
|
+
class TestRecord2 extends CoMap.Record(co.number) {
|
344
|
+
}
|
345
|
+
test("Construction with index signature (shorthand)", async () => {
|
346
|
+
const me = await Account.create({
|
347
|
+
creationProps: { name: "Hermes Puggington" },
|
348
|
+
});
|
349
|
+
const record = new TestRecord2({
|
350
|
+
height: 5,
|
351
|
+
other: 3,
|
352
|
+
}, { owner: me });
|
353
|
+
expect(record.height).toEqual(5);
|
354
|
+
expect(record._raw.get("height")).toEqual(5);
|
355
|
+
expect(record.other).toEqual(3);
|
356
|
+
expect(record._raw.get("other")).toEqual(3);
|
357
|
+
expect(Object.keys(record)).toEqual(["height", "other"]);
|
358
|
+
});
|
359
|
+
class TestRecordRef extends CoMap.Record(co.ref(TwiceNestedMap)) {
|
360
|
+
}
|
361
|
+
test("Construction with index signature ref", async () => {
|
362
|
+
const me = await Account.create({
|
363
|
+
creationProps: { name: "Hermes Puggington" },
|
364
|
+
});
|
365
|
+
const record = new TestRecordRef({
|
366
|
+
firstNested: new TwiceNestedMap({ taste: "sour" }, { owner: me }),
|
367
|
+
secondNested: new TwiceNestedMap({ taste: "sweet" }, { owner: me }),
|
368
|
+
}, { owner: me });
|
369
|
+
expect(record.firstNested?.taste).toEqual("sour");
|
370
|
+
expect(record.firstNested?.id).toBeDefined();
|
371
|
+
expect(record.secondNested?.taste).toEqual("sweet");
|
372
|
+
expect(record.secondNested?.id).toBeDefined();
|
373
|
+
expect(Object.keys(record)).toEqual(["firstNested", "secondNested"]);
|
374
|
+
expect(Object.keys(record._refs)).toEqual([
|
375
|
+
"firstNested",
|
376
|
+
"secondNested",
|
377
|
+
]);
|
267
378
|
});
|
268
379
|
});
|
269
380
|
//# sourceMappingURL=coMap.test.js.map
|