simple-data-ingester-adapter-memory 0.1.0-alpha.1 → 0.1.0-alpha.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "simple-data-ingester-adapter-memory",
3
- "version": "0.1.0-alpha.1",
3
+ "version": "0.1.0-alpha.2",
4
4
  "description": "An in-memory ingester registry for simple-data-ingester: one process, or tests",
5
5
  "license": "MIT",
6
6
  "author": "John Murphy-Teixidor",
@@ -23,7 +23,7 @@
23
23
  "node": ">=20"
24
24
  },
25
25
  "peerDependencies": {
26
- "simple-data-ingester": "^0.1.0-alpha.1"
26
+ "simple-data-ingester": "^0.1.0-alpha.3"
27
27
  },
28
28
  "devDependencies": {
29
29
  "simple-data-ingester": "file:../../core"
@@ -7,6 +7,8 @@ const sameJSON = (a, b) => JSON.stringify(a ?? null) === JSON.stringify(b ?? nul
7
7
 
8
8
  const later = (a, b) => (!a ? b : !b ? a : (a > b ? a : b));
9
9
 
10
+ const text = value => (typeof value === "string" && value.trim()) || null;
11
+
10
12
  /**
11
13
  * The registry in this process's memory: for an app that runs its API and its worker together
12
14
  * without a database, and for tests. Notifications are delivered asynchronously, as the other
@@ -22,14 +24,15 @@ class MemoryIngesterStore extends IngesterStore {
22
24
  this._now = now;
23
25
  }
24
26
 
25
- async request({id, config, worker, lease, count = true}) {
27
+ async request({id, name = null, description = null, config, worker, lease, count = true}) {
26
28
  const now = this._now();
27
29
  const leaseUntil = new Date(now.getTime() + lease);
28
30
  const existing = this._rows.get(id);
29
31
 
30
32
  if(!existing) {
31
33
  const row = {
32
- id, config, mode: ON_DEMAND, active: true, worker,
34
+ id, name: text(name) ?? id, description: text(description),
35
+ config, mode: ON_DEMAND, active: true, worker,
33
36
  status: "UNKNOWN", state: null, error: null,
34
37
  lease_until: leaseUntil, requested_at: now, request_count: count ? 1 : 0,
35
38
  ready_at: null, cycled_at: null, reported_at: null, created: now, modified: now
@@ -56,7 +59,7 @@ class MemoryIngesterStore extends IngesterStore {
56
59
  return {...this._rows.get(id), isNew: false};
57
60
  }
58
61
 
59
- async put({id, config, worker, mode = CONTINUOUS, active = true, lease = undefined}) {
62
+ async put({id, name = undefined, description = undefined, config, worker, mode = CONTINUOUS, active = true, lease = undefined}) {
60
63
  const now = this._now();
61
64
  const existing = this._rows.get(id);
62
65
 
@@ -69,6 +72,8 @@ class MemoryIngesterStore extends IngesterStore {
69
72
  requested_at: null, request_count: 0, ready_at: null, cycled_at: null, reported_at: null, created: now,
70
73
  ...existing,
71
74
  id, config, worker, mode, active,
75
+ name: name !== undefined || !existing ? text(name) ?? id : existing.name,
76
+ description: description !== undefined || !existing ? text(description) : existing.description,
72
77
  lease_until: leaseUntil
73
78
  };
74
79