jinaga-server 3.0.0 → 3.1.0
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/dist/http/router.js +27 -9
- package/dist/http/router.js.map +1 -1
- package/dist/http/serializer.d.ts +11 -0
- package/dist/http/serializer.js +68 -0
- package/dist/http/serializer.js.map +1 -0
- package/dist/postgres/query-description.js +5 -1
- package/dist/postgres/query-description.js.map +1 -1
- package/http/sans-auth/Load json.http +64 -0
- package/integration-test/jinaga-test/Dockerfile +1 -1
- package/integration-test/jinaga-test/package-lock.json +143 -55
- package/integration-test/jinaga-test/package.json +2 -2
- package/package.json +3 -3
- package/replicator/index.ts +1 -1
- package/replicator/package-lock.json +149 -47
- package/replicator/package.json +1 -1
- package/replicator/tsconfig.json +1 -0
- package/src/http/router.ts +36 -11
- package/src/http/serializer.ts +81 -0
- package/src/postgres/query-description.ts +6 -2
- package/test/http/serializerSpec.ts +140 -0
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { GraphSerializer } from "../../src/http/serializer";
|
|
2
|
+
|
|
3
|
+
describe("GraphSerializer", () => {
|
|
4
|
+
it("should write an empty graph", () => {
|
|
5
|
+
let output = "";
|
|
6
|
+
const serializer = new GraphSerializer(chunk => {
|
|
7
|
+
output += chunk;
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
serializer.serialize([]);
|
|
11
|
+
|
|
12
|
+
expect(output).toBe("");
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
it("should write a graph with one fact without signatures", () => {
|
|
16
|
+
let output = "";
|
|
17
|
+
const serializer = new GraphSerializer(chunk => {
|
|
18
|
+
output += chunk;
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
serializer.serialize([{
|
|
22
|
+
fact: {
|
|
23
|
+
type: "MyApp.Root",
|
|
24
|
+
hash: "roothash",
|
|
25
|
+
fields: {
|
|
26
|
+
identifier: "root"
|
|
27
|
+
},
|
|
28
|
+
predecessors: {}
|
|
29
|
+
},
|
|
30
|
+
signatures: []
|
|
31
|
+
}]);
|
|
32
|
+
|
|
33
|
+
expect(output).toBe("\"MyApp.Root\"\n{}\n{\"identifier\":\"root\"}\n\n");
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it("should write a graph with two facts without signatures", () => {
|
|
37
|
+
let output = "";
|
|
38
|
+
const serializer = new GraphSerializer(chunk => {
|
|
39
|
+
output += chunk;
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
serializer.serialize([{
|
|
43
|
+
fact: {
|
|
44
|
+
type: "MyApp.Root",
|
|
45
|
+
hash: "roothash",
|
|
46
|
+
fields: {},
|
|
47
|
+
predecessors: {}
|
|
48
|
+
},
|
|
49
|
+
signatures: []
|
|
50
|
+
}, {
|
|
51
|
+
fact: {
|
|
52
|
+
type: "MyApp.Child",
|
|
53
|
+
hash: "childhash",
|
|
54
|
+
fields: {},
|
|
55
|
+
predecessors: {
|
|
56
|
+
root: {
|
|
57
|
+
type: "MyApp.Root",
|
|
58
|
+
hash: "roothash"
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
signatures: []
|
|
63
|
+
}]);
|
|
64
|
+
|
|
65
|
+
expect(output).toBe("\"MyApp.Root\"\n{}\n{}\n\n\"MyApp.Child\"\n{\"root\":0}\n{}\n\n");
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
it("should not repeat a fact", () => {
|
|
69
|
+
let output = "";
|
|
70
|
+
const serializer = new GraphSerializer(chunk => {
|
|
71
|
+
output += chunk;
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
serializer.serialize([{
|
|
75
|
+
fact: {
|
|
76
|
+
type: "MyApp.Root",
|
|
77
|
+
hash: "roothash",
|
|
78
|
+
fields: {},
|
|
79
|
+
predecessors: {}
|
|
80
|
+
},
|
|
81
|
+
signatures: []
|
|
82
|
+
}, {
|
|
83
|
+
fact: {
|
|
84
|
+
type: "MyApp.Root",
|
|
85
|
+
hash: "roothash",
|
|
86
|
+
fields: {},
|
|
87
|
+
predecessors: {}
|
|
88
|
+
},
|
|
89
|
+
signatures: []
|
|
90
|
+
}]);
|
|
91
|
+
|
|
92
|
+
expect(output).toBe("\"MyApp.Root\"\n{}\n{}\n\n");
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
it("should write a graph with two facts with signatures", () => {
|
|
96
|
+
let output = "";
|
|
97
|
+
const serializer = new GraphSerializer(chunk => {
|
|
98
|
+
output += chunk;
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
serializer.serialize([{
|
|
102
|
+
fact: {
|
|
103
|
+
type: "MyApp.Root",
|
|
104
|
+
hash: "roothash",
|
|
105
|
+
fields: {},
|
|
106
|
+
predecessors: {}
|
|
107
|
+
},
|
|
108
|
+
signatures: [{
|
|
109
|
+
publicKey: "public",
|
|
110
|
+
signature: "signature"
|
|
111
|
+
}]
|
|
112
|
+
}, {
|
|
113
|
+
fact: {
|
|
114
|
+
type: "MyApp.Child",
|
|
115
|
+
hash: "childhash",
|
|
116
|
+
fields: {},
|
|
117
|
+
predecessors: {
|
|
118
|
+
root: {
|
|
119
|
+
type: "MyApp.Root",
|
|
120
|
+
hash: "roothash"
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
},
|
|
124
|
+
signatures: [{
|
|
125
|
+
publicKey: "public",
|
|
126
|
+
signature: "signature1"
|
|
127
|
+
}, {
|
|
128
|
+
publicKey: "public2",
|
|
129
|
+
signature: "signature2"
|
|
130
|
+
}]
|
|
131
|
+
}]);
|
|
132
|
+
|
|
133
|
+
expect(output).toBe(
|
|
134
|
+
"PK0\n\"public\"\n\n" +
|
|
135
|
+
"\"MyApp.Root\"\n{}\n{}\nPK0\n\"signature\"\n\n" +
|
|
136
|
+
"PK1\n\"public2\"\n\n" +
|
|
137
|
+
"\"MyApp.Child\"\n{\"root\":0}\n{}\nPK0\n\"signature1\"\nPK1\n\"signature2\"\n\n"
|
|
138
|
+
);
|
|
139
|
+
});
|
|
140
|
+
});
|