theprogrammablemind 7.3.2 → 7.3.3

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/client.js CHANGED
@@ -19,9 +19,18 @@ const isJest = () => {
19
19
 
20
20
  let fs
21
21
  let ArgumentParser
22
- if (typeof window === 'undefined' || isJest()) {
23
- fs = require('fs')
24
- ArgumentParser = require('argparse').ArgumentParser
22
+
23
+ const setupLibs = () => {
24
+ if (!fs) {
25
+ fs = require('fs')
26
+ }
27
+ if (!ArgumentParser) {
28
+ ArgumentParser = require('argparse').ArgumentParser
29
+ }
30
+ }
31
+
32
+ if (isJest()) {
33
+ setupLibs()
25
34
  }
26
35
 
27
36
  const ask = (config) => (asks) => {
@@ -1179,6 +1188,7 @@ const knowledgeModule = async ({
1179
1188
 
1180
1189
  if (isProcess) {
1181
1190
  // setup();
1191
+ setupLibs()
1182
1192
  const parser = new ArgumentParser({
1183
1193
  description: 'Entodicton knowledge module'
1184
1194
  })
@@ -1485,6 +1495,7 @@ const test = (name) => {
1485
1495
  */
1486
1496
 
1487
1497
  const ensureTestFile = (module, name, type) => {
1498
+ setupLibs()
1488
1499
  const isProcess = require.main === module
1489
1500
  if (isProcess) {
1490
1501
  const fn = `./${name}.${type}.json`
package/package.json CHANGED
@@ -1,42 +1,14 @@
1
1
  {
2
- "dependencies": {
3
- "base-64": "^1.0.0",
4
- "sort-json": "^2.0.0",
5
- "json-stable-stringify": "^1.0.1",
6
- "lodash": "^4.17.20",
7
- "json-diff": "^1.0.3",
8
- "uuid": "^8.3.2",
9
- "readline": "^1.3.0",
10
- "scriptjs": "^2.5.9",
11
- "deep-equal": "^2.0.4",
12
- "underscore": "^1.13.1",
13
- "node-fetch": "^2.6.1",
14
- "fs": "0.0.1-security"
15
- },
16
- "author": "dev@thinktelligence.com",
17
- "devDependencies": {
18
- "eslint-plugin-promise": "^5.1.0",
19
- "eslint-config-standard": "^16.0.3",
20
- "eslint-plugin-import": "^2.23.4",
21
- "@typescript-eslint/eslint-plugin": "^4.28.4",
22
- "eslint-plugin-node": "^11.1.0",
23
- "@typescript-eslint/parser": "^4.28.4",
24
- "jest": "^26.6.3",
25
- "eslint": "^7.31.0"
26
- },
27
- "version": "7.3.2",
28
2
  "scripts": {
29
- "to:debug": "node inspect node_modules/.bin/jest --runInBand -t NEO",
30
- "to": "node node_modules/.bin/jest --runInBand -t NEO",
31
- "test": "jest --config ./jest.config.json",
32
- "tod": "node inspect node_modules/.bin/jest --runInBand -t NEO",
33
3
  "lint": "eslint \"**/*.js\"",
4
+ "to": "node node_modules/.bin/jest --runInBand -t NEO",
34
5
  "test:debug": "node inspect node_modules/.bin/jest --runInBand --config ./jest.config.json",
6
+ "tod": "node inspect node_modules/.bin/jest --runInBand -t NEO",
35
7
  "test:watch": "npm run test -- --watch",
36
- "lint:fix": "eslint \"**/*.js\" --fix"
8
+ "to:debug": "node inspect node_modules/.bin/jest --runInBand -t NEO",
9
+ "lint:fix": "eslint \"**/*.js\" --fix",
10
+ "test": "jest --config ./jest.config.json"
37
11
  },
38
- "license": "ISC",
39
- "name": "theprogrammablemind",
40
12
  "keywords": [
41
13
  "NLP",
42
14
  "NLU",
@@ -46,6 +18,19 @@
46
18
  "natural language understanding",
47
19
  "chatbot"
48
20
  ],
21
+ "name": "theprogrammablemind",
22
+ "license": "ISC",
23
+ "author": "dev@thinktelligence.com",
24
+ "devDependencies": {
25
+ "eslint-plugin-import": "^2.23.4",
26
+ "eslint": "^7.31.0",
27
+ "eslint-plugin-node": "^11.1.0",
28
+ "@typescript-eslint/parser": "^4.28.4",
29
+ "jest": "^26.6.3",
30
+ "@typescript-eslint/eslint-plugin": "^4.28.4",
31
+ "eslint-plugin-promise": "^5.1.0",
32
+ "eslint-config-standard": "^16.0.3"
33
+ },
49
34
  "files": [
50
35
  "client.js",
51
36
  "index.js",
@@ -61,5 +46,20 @@
61
46
  "src/generators.js",
62
47
  "src/semantics.js"
63
48
  ],
49
+ "dependencies": {
50
+ "underscore": "^1.13.1",
51
+ "fs": "0.0.1-security",
52
+ "uuid": "^8.3.2",
53
+ "scriptjs": "^2.5.9",
54
+ "lodash": "^4.17.20",
55
+ "json-diff": "^1.0.3",
56
+ "deep-equal": "^2.0.4",
57
+ "json-stable-stringify": "^1.0.1",
58
+ "readline": "^1.3.0",
59
+ "base-64": "^1.0.0",
60
+ "node-fetch": "^2.6.1",
61
+ "sort-json": "^2.0.0"
62
+ },
63
+ "version": "7.3.3",
64
64
  "main": "index.js"
65
65
  }
package/src/config.js CHANGED
@@ -1230,10 +1230,12 @@ class Config {
1230
1230
  return true
1231
1231
  }
1232
1232
 
1233
+ /*
1233
1234
  dump(fn) {
1234
1235
  const fs = require('fs')
1235
1236
  fs.writeFileSync(fn, JSON.stringify(this.config, 0, 2))
1236
1237
  }
1238
+ */
1237
1239
 
1238
1240
  copy (options = {}) {
1239
1241
  this.valid()
package/src/generators.js CHANGED
@@ -1,6 +1,5 @@
1
1
  const { args: contextArgs, normalizeGenerator } = require('./helpers')
2
2
  const Lines = require('../lines')
3
- const sortJson = require('sort-json')
4
3
  const helpers = require('./helpers')
5
4
 
6
5
  class Generator {
@@ -212,8 +211,8 @@ class Generators {
212
211
  lines.setElement(0, 2, generator.toString())
213
212
  lines.newRow()
214
213
  lines.setElement(0, 1, 'TO')
215
- lines.setElement(0, 2, `(HASHCODE ${helpers.hashCode(JSON.stringify(sortJson(context, { depth: 25 })))})`)
216
- lines.setElement(1, 2, JSON.stringify(sortJson(context, { depth: 25 }), null, 2))
214
+ lines.setElement(0, 2, `(HASHCODE ${helpers.hashCode(JSON.stringify(helpers.sortJson(context, { depth: 25 })))})`)
215
+ lines.setElement(1, 2, JSON.stringify(helpers.sortJson(context, { depth: 25 }), null, 2))
217
216
  lines.newRow()
218
217
  lines.setElement(0, 1, 'STACK')
219
218
  lines.setElement(0, 2, stack)
@@ -254,8 +253,8 @@ class Generators {
254
253
  lines.setElement(0, 1, 'DEBUG')
255
254
  lines.setElement(0, 2, `To debug this use args.callId == '${args.calls.current()}'`)
256
255
  lines.setElement(0, 1, 'TO')
257
- lines.setElement(0, 2, `(HASHCODE ${helpers.hashCode(JSON.stringify(sortJson(context, { depth: 25 })))})`)
258
- lines.setElement(1, 2, JSON.stringify(sortJson(context, { depth: 25 }), null, 2))
256
+ lines.setElement(0, 2, `(HASHCODE ${helpers.hashCode(JSON.stringify(helpers.sortJson(context, { depth: 25 })))})`)
257
+ lines.setElement(1, 2, JSON.stringify(helpers.sortJson(context, { depth: 25 }), null, 2))
259
258
  this.logs.push(lines.toString())
260
259
  }
261
260
  applied = true
package/src/helpers.js CHANGED
@@ -213,4 +213,8 @@ const hashCode = (str) => {
213
213
  return hash;
214
214
  };
215
215
 
216
- module.exports = { args, safeEquals, appendNoDups, hashIndexesGet, hashIndexesSet, translationMapping, normalizeGenerator, normalizeSemantic, isArray, isObject, isCompound, InitCalls, hashCode }
216
+ const sortJson = (json) => {
217
+ return json
218
+ }
219
+
220
+ module.exports = { args, safeEquals, appendNoDups, hashIndexesGet, hashIndexesSet, translationMapping, normalizeGenerator, normalizeSemantic, isArray, isObject, isCompound, InitCalls, hashCode, sortJson }
package/src/semantics.js CHANGED
@@ -1,6 +1,5 @@
1
1
  const { args: contextArgs, normalizeGenerator, normalizeSemantic } = require('./helpers')
2
2
  const Lines = require('../lines')
3
- const sortJson = require('sort-json')
4
3
  const helpers = require('./helpers')
5
4
 
6
5
  class Semantic {
@@ -198,8 +197,8 @@ class Semantics {
198
197
  lines.setElement(0, 2, semantic.toString())
199
198
  lines.newRow()
200
199
  lines.setElement(0, 1, 'TO')
201
- lines.setElement(0, 2, `(HASHCODE ${helpers.hashCode(JSON.stringify(sortJson(context, { depth: 25 })))})`)
202
- lines.setElement(1, 2, JSON.stringify(sortJson(context, { depth: 25 }), null, 2))
200
+ lines.setElement(0, 2, `(HASHCODE ${helpers.hashCode(JSON.stringify(helpers.sortJson(context, { depth: 25 })))})`)
201
+ lines.setElement(1, 2, JSON.stringify(helpers.sortJson(context, { depth: 25 }), null, 2))
203
202
  lines.newRow()
204
203
  lines.setElement(0, 1, 'STACK')
205
204
  lines.setElement(0, 2, stack)
@@ -233,8 +232,8 @@ class Semantics {
233
232
  lines.setElement(0, 2, semantic.toString())
234
233
  lines.newRow()
235
234
  lines.setElement(0, 1, 'TO')
236
- lines.setElement(0, 2, `(HASHCODE ${helpers.hashCode(JSON.stringify(sortJson(context, { depth: 25 })))})`)
237
- lines.setElement(1, 2, JSON.stringify(sortJson(context, { depth: 25 }), null, 2))
235
+ lines.setElement(0, 2, `(HASHCODE ${helpers.hashCode(JSON.stringify(helpers.sortJson(context, { depth: 25 })))})`)
236
+ lines.setElement(1, 2, JSON.stringify(helpers.sortJson(context, { depth: 25 }), null, 2))
238
237
  lines.newRow()
239
238
  lines.setElement(0, 1, 'STACK')
240
239
  lines.setElement(0, 2, stack)
@@ -243,7 +242,7 @@ class Semantics {
243
242
  lines.setElement(0, 2, `To debug this use args.callId == '${args.calls.current()}'`)
244
243
  lines.newRow()
245
244
  lines.setElement(0, 1, 'RESULT')
246
- lines.setElement(0, 2, `(HASHCODE ${helpers.hashCode(JSON.stringify(sortJson(contextPrime, { depth: 25 })))})`)
245
+ lines.setElement(0, 2, `(HASHCODE ${helpers.hashCode(JSON.stringify(helpers.sortJson(contextPrime, { depth: 25 })))})`)
247
246
  lines.setElement(1, 2, JSON.stringify(contextPrime, null, 2))
248
247
  this.logs.push(lines.toString())
249
248
  }
@@ -267,8 +266,8 @@ class Semantics {
267
266
  lines.setElement(0, 2, stack)
268
267
  lines.newRow()
269
268
  lines.setElement(0, 1, 'TO')
270
- lines.setElement(0, 2, `(HASHCODE ${helpers.hashCode(JSON.stringify(sortJson(context, { depth: 25 })))})`)
271
- lines.setElement(1, 2, JSON.stringify(sortJson(context, { depth: 25 }), null, 2))
269
+ lines.setElement(0, 2, `(HASHCODE ${helpers.hashCode(JSON.stringify(helpers.sortJson(context, { depth: 25 })))})`)
270
+ lines.setElement(1, 2, JSON.stringify(helpers.sortJson(context, { depth: 25 }), null, 2))
272
271
  this.logs.push(lines.toString())
273
272
  }
274
273
  return contextPrime