jinaga-server 3.5.2 → 3.5.4

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.
Files changed (57) hide show
  1. package/dist/authorization/authorization-keystore.js +2 -2
  2. package/dist/authorization/authorization-keystore.js.map +1 -1
  3. package/dist/http/csv-metadata.d.ts +24 -0
  4. package/dist/http/csv-metadata.js +3 -0
  5. package/dist/http/csv-metadata.js.map +1 -0
  6. package/dist/http/csv-validator.d.ts +23 -0
  7. package/dist/http/csv-validator.js +83 -0
  8. package/dist/http/csv-validator.js.map +1 -0
  9. package/dist/http/output-formatters.d.ts +28 -0
  10. package/dist/http/output-formatters.js +197 -0
  11. package/dist/http/output-formatters.js.map +1 -0
  12. package/dist/http/result-stream.d.ts +35 -0
  13. package/dist/http/result-stream.js +78 -0
  14. package/dist/http/result-stream.js.map +1 -0
  15. package/dist/http/router.d.ts +7 -1
  16. package/dist/http/router.js +98 -47
  17. package/dist/http/router.js.map +1 -1
  18. package/dist/postgres/postgres-store.js +7 -5
  19. package/dist/postgres/postgres-store.js.map +1 -1
  20. package/dist/postgres/purge-sql.js +15 -2
  21. package/dist/postgres/purge-sql.js.map +1 -1
  22. package/dist/postgres/specification-result-sql.d.ts +2 -0
  23. package/dist/postgres/specification-result-sql.js +49 -5
  24. package/dist/postgres/specification-result-sql.js.map +1 -1
  25. package/dist/postgres/specification-sql.js +28 -6
  26. package/dist/postgres/specification-sql.js.map +1 -1
  27. package/docs/design/feeds-persistent-proxy-plan.md +294 -0
  28. package/integration-test/integration-test/jinaga-test/package-lock.json +6 -0
  29. package/integration-test/jinaga-test/Dockerfile +1 -6
  30. package/integration-test/jinaga-test/http-test-helpers.js +77 -0
  31. package/integration-test/jinaga-test/jinaga.test.js +9 -9
  32. package/integration-test/jinaga-test/package-lock.json +329 -32
  33. package/integration-test/jinaga-test/package.json +5 -1
  34. package/integration-test/jinaga-test/read-csv.test.js +350 -0
  35. package/integration-test/jinaga-test/read-endpoint.test.js +442 -0
  36. package/integration-test/jinaga-test/read-performance.test.js +221 -0
  37. package/integration-test/jinaga-test/read-streaming.test.js +199 -0
  38. package/integration-test/jinaga-test/specification-conditions.test.js +147 -0
  39. package/integration-test/jinaga-test/test-helpers.js +12 -0
  40. package/integration-test/jinaga-test/time-projection.test.js +235 -0
  41. package/package.json +3 -2
  42. package/src/authorization/authorization-keystore.ts +4 -4
  43. package/src/http/csv-metadata.ts +34 -0
  44. package/src/http/csv-validator.ts +90 -0
  45. package/src/http/output-formatters.ts +196 -0
  46. package/src/http/result-stream.ts +69 -0
  47. package/src/http/router.ts +117 -34
  48. package/src/postgres/postgres-store.ts +13 -6
  49. package/src/postgres/purge-sql.ts +18 -2
  50. package/src/postgres/specification-result-sql.ts +70 -8
  51. package/src/postgres/specification-sql.ts +36 -8
  52. package/test/http/csv-validatorSpec.ts +205 -0
  53. package/test/http/result-streamSpec.ts +151 -0
  54. package/test/postgres/postgresReadSpec.ts +192 -14
  55. package/test/postgres/postgresSpecificationSpec.ts +3 -3
  56. package/test/postgres/specificationConditionsSpec.ts +268 -0
  57. package/documentation/streaming-feeds-full-results-solution.md +0 -230
@@ -0,0 +1,77 @@
1
+ const express = require('express');
2
+ const { JinagaServer } = require('./jinaga-server');
3
+
4
+ const host = "db";
5
+ const connectionString = `postgresql://dev:devpw@${host}:5432/integrationtest`;
6
+
7
+ /**
8
+ * Creates an Express app with HTTP router for testing
9
+ * @returns {Promise<{app: express.Application, close: Function}>}
10
+ */
11
+ async function createTestApp() {
12
+ const { handler, close } = JinagaServer.create({
13
+ pgKeystore: connectionString,
14
+ pgStore: connectionString
15
+ });
16
+
17
+ const app = express();
18
+ app.use(express.json());
19
+ app.use(express.text());
20
+ app.use(handler);
21
+
22
+ return { app, close };
23
+ }
24
+
25
+ /**
26
+ * Creates test data with a Root and specified number of Successors
27
+ * @param {Object} j - Jinaga instance
28
+ * @param {Object} Root - Root class
29
+ * @param {Object} Successor - Successor class
30
+ * @param {number} count - Number of successors to create
31
+ * @returns {Promise<{root: Object, successors: Array}>}
32
+ */
33
+ async function createTestData(j, Root, Successor, count) {
34
+ const root = await j.fact(new Root(Math.random().toString(36).substring(2, 10)));
35
+ const successors = [];
36
+
37
+ for (let i = 0; i < count; i++) {
38
+ const successor = await j.fact(new Successor(`successor-${i}`, root));
39
+ successors.push(successor);
40
+ }
41
+
42
+ return { root, successors };
43
+ }
44
+
45
+ /**
46
+ * Parses NDJSON response text
47
+ * @param {string} text - Response text in NDJSON format
48
+ * @returns {Array} Array of parsed JSON objects
49
+ */
50
+ function parseNDJSON(text) {
51
+ return text
52
+ .trim()
53
+ .split('\n')
54
+ .filter(line => line.trim() !== '')
55
+ .map(line => JSON.parse(line));
56
+ }
57
+
58
+ /**
59
+ * Measures memory usage during function execution
60
+ * @param {Function} fn - Async function to execute
61
+ * @returns {Promise<{result: any, heapUsed: number}>}
62
+ */
63
+ async function measureMemory(fn) {
64
+ const startMemory = process.memoryUsage().heapUsed;
65
+ const result = await fn();
66
+ const endMemory = process.memoryUsage().heapUsed;
67
+ const heapUsed = endMemory - startMemory;
68
+
69
+ return { result, heapUsed };
70
+ }
71
+
72
+ module.exports = {
73
+ createTestApp,
74
+ createTestData,
75
+ parseNDJSON,
76
+ measureMemory
77
+ };
@@ -21,7 +21,7 @@ class Successor {
21
21
 
22
22
  constructor(identifier, predecessor) {
23
23
  this.identifier = identifier;
24
- this.predecessor = predecessor;
24
+ this.pred = predecessor;
25
25
  }
26
26
  }
27
27
 
@@ -30,7 +30,7 @@ class UnknownType {
30
30
  type = UnknownType.Type;
31
31
 
32
32
  constructor(predecessor) {
33
- this.predecessor = predecessor;
33
+ this.pred = predecessor;
34
34
  }
35
35
  }
36
36
 
@@ -95,10 +95,10 @@ class MembershipRestored {
95
95
  const model = buildModel(b => b
96
96
  .type(Root)
97
97
  .type(Successor, m => m
98
- .predecessor("predecessor", Root)
98
+ .predecessor("pred", Root)
99
99
  )
100
100
  .type(UnknownType, m => m
101
- .predecessor("predecessor", Root)
101
+ .predecessor("pred", Root)
102
102
  )
103
103
  .type(User)
104
104
  .type(UserName, m => m
@@ -147,12 +147,12 @@ function randomTenant(creator) {
147
147
 
148
148
  const successorsOfRoot = model.given(Root).match((root, facts) =>
149
149
  facts.ofType(Successor)
150
- .join(s => s.predecessor, root)
150
+ .join(s => s.pred, root)
151
151
  );
152
152
 
153
153
  const unknownOfRoot = model.given(Root).match((root, facts) =>
154
154
  facts.ofType(UnknownType)
155
- .join(s => s.predecessor, root)
155
+ .join(s => s.pred, root)
156
156
  );
157
157
 
158
158
  const configurationFromDevice = model.given(Device).match((device, facts) =>
@@ -248,7 +248,7 @@ describe("Jinaga as a device", () => {
248
248
  const successor = await j.fact(new Successor("test-successor", root));
249
249
 
250
250
  expect(successor.identifier).toEqual("test-successor");
251
- expect(successor.predecessor).toEqual(root);
251
+ expect(successor.pred).toEqual(root);
252
252
  });
253
253
 
254
254
  it("should query a successor fact", async () => {
@@ -274,7 +274,7 @@ describe("Jinaga as a device", () => {
274
274
  const successor = await j.fact(new Successor("test-successor", root));
275
275
 
276
276
  expect(successor.identifier).toEqual("test-successor");
277
- expect(successor.predecessor).toEqual(root);
277
+ expect(successor.pred).toEqual(root);
278
278
  });
279
279
 
280
280
 
@@ -282,7 +282,7 @@ describe("Jinaga as a device", () => {
282
282
  const successor = await j.fact(new Successor("test-successor", randomRoot()));
283
283
 
284
284
  expect(successor.identifier).toEqual("test-successor");
285
- expect(successor.predecessor.type).toEqual("IntegrationTest.Root");
285
+ expect(successor.pred.type).toEqual("IntegrationTest.Root");
286
286
  });
287
287
 
288
288
  it("should get the device identity", async () => {