datanautics 4.3.1 → 4.5.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.
@@ -0,0 +1,3 @@
1
+ github: databikers
2
+ patreon: databikers
3
+ custom: [ "https://dir.floss.fund/view/@databikers.com" ]
@@ -0,0 +1,31 @@
1
+ name: Bug Report
2
+ description: Report a reproducible bug or unexpected behavior
3
+ labels: [bug]
4
+ body:
5
+ - type: input
6
+ id: title
7
+ attributes:
8
+ label: Summary
9
+ placeholder: "Short description of the bug"
10
+ validations:
11
+ required: true
12
+
13
+ - type: textarea
14
+ id: steps
15
+ attributes:
16
+ label: Steps to Reproduce
17
+ description: "What did you do? What did you expect?"
18
+ placeholder: |
19
+ 1. Run npm start
20
+ 2. Observe crash
21
+ validations:
22
+ required: true
23
+
24
+ - type: textarea
25
+ id: logs
26
+ attributes:
27
+ label: Logs / Error Output
28
+ render: shell
29
+ placeholder: Paste any error messages here
30
+ validations:
31
+ required: false
@@ -0,0 +1,5 @@
1
+ blank_issues_enabled: false
2
+ contact_links:
3
+ - name: Ask a question
4
+ url: https://github.com/databikers/datanautics/discussions
5
+ about: Ask usage questions or request help
@@ -0,0 +1,27 @@
1
+ name: Feature Request
2
+ description: Propose a new feature for Datanautics
3
+ labels: [enhancement]
4
+ body:
5
+ - type: input
6
+ id: title
7
+ attributes:
8
+ label: Feature Title
9
+ placeholder: "e.g. add some feature"
10
+ validations:
11
+ required: true
12
+
13
+ - type: textarea
14
+ id: use-case
15
+ attributes:
16
+ label: Use Case / Motivation
17
+ placeholder: Why would this be helpful?
18
+ validations:
19
+ required: true
20
+
21
+ - type: textarea
22
+ id: implementation
23
+ attributes:
24
+ label: Optional implementation ideas
25
+ placeholder: How could it be done?
26
+ validations:
27
+ required: false
@@ -0,0 +1,52 @@
1
+ name: Question
2
+ description: Ask a general question about usage, implementation, or behavior.
3
+ title: "[Question]: "
4
+ labels: [question]
5
+ assignees: []
6
+
7
+ body:
8
+ - type: markdown
9
+ attributes:
10
+ value: |
11
+ ## Need Help?
12
+ If you have a general question about the project, please fill out the details below.
13
+
14
+ - type: input
15
+ id: context
16
+ attributes:
17
+ label: What are you trying to do?
18
+ description: Explain what you're working on or trying to achieve.
19
+ placeholder: e.g. I’m trying to add user using a CLI tool...
20
+ validations:
21
+ required: true
22
+
23
+ - type: textarea
24
+ id: what-happened
25
+ attributes:
26
+ label: What is confusing or unclear?
27
+ description: Describe what you don't understand or what needs more explanation.
28
+ placeholder: I expected it to work like this... but instead...
29
+ validations:
30
+ required: true
31
+
32
+ - type: dropdown
33
+ id: environment
34
+ attributes:
35
+ label: Environment
36
+ description: Where are you running this?
37
+ options:
38
+ - Local (Linux)
39
+ - Docker
40
+ - Other
41
+ multiple: false
42
+ validations:
43
+ required: false
44
+
45
+ - type: textarea
46
+ id: additional
47
+ attributes:
48
+ label: Anything else?
49
+ description: Add any other context or screenshots that might help.
50
+ placeholder: Logs, screenshots, error messages, etc.
51
+ validations:
52
+ required: false
package/CHANGELOG.md CHANGED
@@ -5,6 +5,18 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](http://keepachangelog.com/)
6
6
  and this project adheres to [Semantic Versioning](http://semver.org/).
7
7
 
8
+ ## [4.5.0] - 2025-08-11
9
+
10
+ ### Added
11
+
12
+ - timestamps in dumps, preparing for multi-instance synchronization
13
+
14
+ ## [4.4.0] - 2025-08-11
15
+
16
+ ### Fixed
17
+
18
+ - handle quoted property names correctly
19
+
8
20
  ## [4.3.1] - 2025-08-11
9
21
 
10
22
  ### Fixed
package/diff.js ADDED
@@ -0,0 +1,36 @@
1
+ // const { readFileSync } = require('fs');
2
+ // const SEPARATOR = /[\r|\n]/g;
3
+ //
4
+ // function diff(source, target) {
5
+ // const targetContent = readFileSync(target).toString('utf8').split(SEPARATOR);
6
+ // const sourceContent = readFileSync(source).toString('utf8').split(SEPARATOR);
7
+ // const tMap = new Map();
8
+ // const sMap = new Map();
9
+ // targetContent.forEach(line => {
10
+ // const [ key, ...valueArray] = line.split(' ');
11
+ // if (key) {
12
+ // tMap.set(key, valueArray?.join(' ') || undefined);
13
+ // }
14
+ // })
15
+ // sourceContent.forEach(line => {
16
+ // const [ key, ...valueArray] = line.split(' ');
17
+ // if (key) {
18
+ // sMap.set(key, valueArray.join(' '));
19
+ // }
20
+ // })
21
+ // const tKeys = tMap.keys();
22
+ // const sKeys = sMap.keys();
23
+ // const remove = tKeys.filter(tKey => !sMap.has(tKey));
24
+ // const set = sKeys.filter(sKey => !tMap.has(sKey) || tMap.get(sKey) !== sMap.get(sKey));
25
+ // const patch = {};
26
+ // remove.forEach(key => {
27
+ // patch[key] = undefined;
28
+ // })
29
+ // set.forEach(key => {
30
+ // patch[key] = sMap.get(key);
31
+ // })
32
+ // console.log(patch)
33
+ // }
34
+ //
35
+ // diff('./test/data2.txt', './test/data.txt')
36
+ console.log(/^\d{13}\s/.test(Date.now() + ' '))
@@ -3,3 +3,4 @@ export * from './events';
3
3
  export * from './falsy-values';
4
4
  export * from './interval';
5
5
  export * from './reg-exp';
6
+ export * from './separator';
@@ -19,4 +19,5 @@ __exportStar(require("./events"), exports);
19
19
  __exportStar(require("./falsy-values"), exports);
20
20
  __exportStar(require("./interval"), exports);
21
21
  __exportStar(require("./reg-exp"), exports);
22
+ __exportStar(require("./separator"), exports);
22
23
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/constants/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gEAA8C;AAC9C,2CAAyB;AACzB,iDAA+B;AAC/B,6CAA2B;AAC3B,4CAA0B"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/constants/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gEAA8C;AAC9C,2CAAyB;AACzB,iDAA+B;AAC/B,6CAA2B;AAC3B,4CAA0B;AAC1B,8CAA4B"}
@@ -0,0 +1 @@
1
+ export declare const SEPARATOR: RegExp;
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SEPARATOR = void 0;
4
+ exports.SEPARATOR = /[\r|\n]/g;
5
+ //# sourceMappingURL=separator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"separator.js","sourceRoot":"","sources":["../../src/constants/separator.ts"],"names":[],"mappings":";;;AAAa,QAAA,SAAS,GAAG,UAAU,CAAC"}
@@ -4,8 +4,10 @@ import { DatanauticsOptions } from './options';
4
4
  export declare class Datanautics {
5
5
  protected options: DatanauticsOptions;
6
6
  protected data: Record<string, any>;
7
+ protected updateTracking: Record<string, number>;
7
8
  protected eventEmitter: EventEmitter;
8
9
  constructor(options?: DatanauticsOptions);
10
+ normalizeDump(): void;
9
11
  store(): void;
10
12
  protected createDump(): void;
11
13
  protected useDump(): void;
@@ -5,13 +5,16 @@ const events_1 = require("events");
5
5
  const fs_1 = require("fs");
6
6
  const property_accessor_1 = require("property-accessor");
7
7
  const _const_1 = require("./constants");
8
+ const helpers_1 = require("./helpers");
8
9
  class Datanautics {
9
10
  options;
10
11
  data;
12
+ updateTracking;
11
13
  eventEmitter;
12
14
  constructor(options) {
13
15
  this.options = { ..._const_1.defaultDatanauticsOptions, ...(options || {}) };
14
16
  this.data = {};
17
+ this.updateTracking = {};
15
18
  this.eventEmitter = new events_1.EventEmitter();
16
19
  if ((0, fs_1.existsSync)(this.options.dumpPath)) {
17
20
  this.useDump();
@@ -34,17 +37,21 @@ class Datanautics {
34
37
  });
35
38
  }
36
39
  }
40
+ normalizeDump() {
41
+ return (0, helpers_1.normalizeDump)(this.options.dumpPath);
42
+ }
37
43
  store() {
38
44
  return this.createDump();
39
45
  }
40
46
  createDump() {
41
47
  try {
42
- const flat = property_accessor_1.PropertyAccessor.flat(this.data);
48
+ const flat = property_accessor_1.PropertyAccessor.flat(this.data, '␣');
43
49
  const data = [];
44
50
  for (const key in flat) {
45
- const value = property_accessor_1.PropertyAccessor.get(key, this.data);
51
+ const value = property_accessor_1.PropertyAccessor.get(key.replace(/␣/g, ' '), this.data);
52
+ const timestamp = property_accessor_1.PropertyAccessor.get(key, this.updateTracking) || Date.now();
46
53
  if (value || _const_1.falsyValues.includes(value)) {
47
- data.push(`${key} ${value.toString()}`);
54
+ data.push(`${timestamp} ${key} ${value.toString()}`);
48
55
  }
49
56
  }
50
57
  (0, fs_1.writeFileSync)(this.options.dumpPath, data.join('\n'), 'utf8');
@@ -59,10 +66,27 @@ class Datanautics {
59
66
  const data = (0, fs_1.readFileSync)(this.options.dumpPath).toString('utf8');
60
67
  const lines = data.split('\n');
61
68
  for (const line of lines) {
62
- const [k, ...rest] = line.split(' ');
69
+ if (!line) {
70
+ continue;
71
+ }
72
+ const lineData = line.split(' ');
73
+ let t;
74
+ let k;
75
+ let rest;
76
+ if (lineData.length > 2) {
77
+ [
78
+ t,
79
+ k,
80
+ ...rest
81
+ ] = lineData;
82
+ }
83
+ else {
84
+ t = Date.now().toString(10);
85
+ [k, ...rest] = lineData;
86
+ }
87
+ const key = k.trim().replace(/␣/g, ' ');
63
88
  const v = rest.join(' ');
64
- const key = k.trim();
65
- if (v !== undefined) {
89
+ if (key && v !== undefined) {
66
90
  let value = v.trim();
67
91
  if (_const_1.numberRegExp.test(value)) {
68
92
  if (_const_1.intRegExp.test(value)) {
@@ -82,10 +106,16 @@ class Datanautics {
82
106
  value = value === 'true';
83
107
  }
84
108
  property_accessor_1.PropertyAccessor.set(key, value, this.data);
109
+ property_accessor_1.PropertyAccessor.set(key, parseInt(t, 10), this.updateTracking);
110
+ }
111
+ else {
112
+ property_accessor_1.PropertyAccessor.delete(key, this.data);
113
+ property_accessor_1.PropertyAccessor.delete(key, this.updateTracking);
85
114
  }
86
115
  }
87
116
  }
88
117
  set(key, value) {
118
+ property_accessor_1.PropertyAccessor.set(key, Date.now(), this.updateTracking);
89
119
  return property_accessor_1.PropertyAccessor.set(key, value, this.data);
90
120
  }
91
121
  get(key) {
@@ -1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@ -0,0 +1,2 @@
1
+ export * from './two-files-diff';
2
+ export * from './normalize-dump';
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./two-files-diff"), exports);
18
+ __exportStar(require("./normalize-dump"), exports);
19
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/helpers/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,mDAAiC;AACjC,mDAAiC"}
@@ -0,0 +1 @@
1
+ export declare function normalizeDump(targetPath: string): void;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.normalizeDump = void 0;
4
+ const fs_1 = require("fs");
5
+ const _const_1 = require("../constants");
6
+ function normalizeDump(targetPath) {
7
+ const targetContent = (0, fs_1.readFileSync)(targetPath).toString('utf8').split(_const_1.SEPARATOR);
8
+ const normalizedLines = [];
9
+ targetContent.forEach(line => {
10
+ if (line) {
11
+ /^\d{13}\s/.test(line) ? normalizedLines.push(line) : normalizedLines.push(`${Date.now()} ${line}`);
12
+ }
13
+ });
14
+ (0, fs_1.writeFileSync)(targetPath, normalizedLines.join('\n'), 'utf8');
15
+ }
16
+ exports.normalizeDump = normalizeDump;
17
+ //# sourceMappingURL=normalize-dump.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"normalize-dump.js","sourceRoot":"","sources":["../../src/helpers/normalize-dump.ts"],"names":[],"mappings":";;;AAAA,2BAAiD;AACjD,mCAAmC;AAEnC,SAAgB,aAAa,CAAC,UAAkB;IAC9C,MAAM,aAAa,GAAG,IAAA,iBAAY,EAAC,UAAU,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,kBAAS,CAAC,CAAC;IACjF,MAAM,eAAe,GAAa,EAAE,CAAC;IACrC,aAAa,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;QAC3B,IAAI,IAAI,EAAE,CAAC;YACT,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,eAAe,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,GAAG,EAAE,IAAI,IAAI,EAAE,CAAC,CAAC;QACtG,CAAC;IACH,CAAC,CAAC,CAAC;IACH,IAAA,kBAAa,EAAC,UAAU,EAAE,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,CAAC;AAChE,CAAC;AATD,sCASC"}
@@ -0,0 +1 @@
1
+ export declare function twoFilesDiff(sourcePath: string, targetPath: string): Record<string, any>;
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.twoFilesDiff = void 0;
4
+ const fs_1 = require("fs");
5
+ const _const_1 = require("../constants");
6
+ function twoFilesDiff(sourcePath, targetPath) {
7
+ const targetContent = (0, fs_1.readFileSync)(targetPath).toString('utf8').split(_const_1.SEPARATOR);
8
+ const sourceContent = (0, fs_1.readFileSync)(sourcePath).toString('utf8').split(_const_1.SEPARATOR);
9
+ const tMap = new Map();
10
+ const ttMap = new Map();
11
+ const sMap = new Map();
12
+ const tsMap = new Map();
13
+ targetContent.forEach(line => {
14
+ const [timestamp, key, ...valueArray] = line.split(' ');
15
+ if (key) {
16
+ tMap.set(key, valueArray?.join(' ') || undefined);
17
+ ttMap.set(key, parseInt(timestamp, 10));
18
+ }
19
+ });
20
+ sourceContent.forEach(line => {
21
+ const [timestamp, key, ...valueArray] = line.split(' ');
22
+ if (key) {
23
+ sMap.set(key, valueArray.join(' '));
24
+ tsMap.set(key, parseInt(timestamp, 10));
25
+ }
26
+ });
27
+ const tKeys = Array.from(tMap.keys());
28
+ const sKeys = Array.from(sMap.keys());
29
+ const remove = tKeys.filter(tKey => !sMap.has(tKey));
30
+ const set = sKeys.filter(sKey => !tMap.has(sKey) || (tMap.get(sKey) !== sMap.get(sKey) && tsMap.get(sKey) > ttMap.get(sKey)));
31
+ const patch = {};
32
+ remove.forEach(key => {
33
+ patch[key] = undefined;
34
+ });
35
+ set.forEach(key => {
36
+ patch[key] = `${tMap.get(key)} ${sMap.get(key)}`;
37
+ });
38
+ return patch;
39
+ }
40
+ exports.twoFilesDiff = twoFilesDiff;
41
+ //# sourceMappingURL=two-files-diff.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"two-files-diff.js","sourceRoot":"","sources":["../../src/helpers/two-files-diff.ts"],"names":[],"mappings":";;;AAAA,2BAAkC;AAClC,mCAAkC;AAElC,SAAgB,YAAY,CAAC,UAAkB,EAAE,UAAkB;IACjE,MAAM,aAAa,GAAG,IAAA,iBAAY,EAAC,UAAU,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,kBAAS,CAAC,CAAC;IACjF,MAAM,aAAa,GAAG,IAAA,iBAAY,EAAC,UAAU,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,kBAAS,CAAC,CAAC;IACjF,MAAM,IAAI,GAAG,IAAI,GAAG,EAAE,CAAC;IACvB,MAAM,KAAK,GAAG,IAAI,GAAG,EAAE,CAAC;IACxB,MAAM,IAAI,GAA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AC,IAAI,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAE,CAAC,CAAC;IAC/H,MAAM,KAAK,GAAwB,EAAE,CAAC;IACtC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;QACnB,KAAK,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC;IACzB,CAAC,CAAC,CAAC;IACH,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;QAChB,KAAK,CAAC,GAAG,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;IACnD,CAAC,CAAC,CAAC;IACH,OAAO,KAAK,CAAC;AACf,CAAC;AAjCD,oCAiCC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "datanautics",
3
- "version": "4.3.1",
3
+ "version": "4.5.0",
4
4
  "description": "",
5
5
  "keywords": [
6
6
  "data store",
@@ -21,12 +21,12 @@
21
21
  "runtime": "node dist/index.js"
22
22
  },
23
23
  "dependencies": {
24
- "property-accessor": "^2.3.0"
24
+ "property-accessor": "^2.5.1"
25
25
  },
26
26
  "devDependencies": {
27
- "@types/node": "20.10.6",
27
+ "@types/node": "22.14.0",
28
28
  "@types/prettier": "2.6.0",
29
- "@types/uuid": "10.0.0",
29
+ "@types/uuid": "11.0.0",
30
30
  "@typescript-eslint/eslint-plugin": "6.17.0",
31
31
  "@typescript-eslint/parser": "6.17.0",
32
32
  "eslint": "8.47.0",
@@ -44,9 +44,9 @@
44
44
  },
45
45
  "repository": {
46
46
  "type": "git",
47
- "url": "git@github.com:Paul-Lazunko/datanautics.git"
47
+ "url": "git@github.com:databikers/datanautics.git"
48
48
  },
49
49
  "engines": {
50
- "node": ">=14.0.0"
50
+ "node": ">=18.0.0"
51
51
  }
52
52
  }
package/test/data.txt ADDED
@@ -0,0 +1,4 @@
1
+ 1770169858788 user.firstname John Junior Frost 11
2
+ 1770169858788 user.lastname Doe
3
+ 1770169859789 user.nested.key 1000000000000000000000
4
+ 1770169858788 score[0] 27
package/test/test.js CHANGED
@@ -6,7 +6,7 @@ const { setTimeout } = require('timers');
6
6
 
7
7
  const dumpPath = resolve(__dirname, './data.txt');
8
8
  const data = {
9
- user: { firstname: 'John Junior Frost', lastname: 'Doe' },
9
+ user: { firstname: 'John Junior Frost 11', lastname: 'Doe' },
10
10
  score: [27],
11
11
  nested: { key: BigInt('1000000000000000000000') },
12
12
  };
@@ -30,3 +30,4 @@ setTimeout(() => {
30
30
  console.log('tests passed');
31
31
  process.exit(0);
32
32
  }, 2000);
33
+