theprogrammablemind_4wp 9.3.0-beta.53 → 9.3.0-beta.55

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
@@ -50,8 +50,8 @@ const getConfig_getContextCheck = (testConfig) => {
50
50
  return (testConfig.checks && testConfig.checks.context) || []
51
51
  }
52
52
 
53
- const pickContext = (testConfig) => (context) => {
54
- return project2(context, getConfig_getContextCheck(testConfig))
53
+ const pickContext = (contextChecks) => (context) => {
54
+ return project2(context, contextChecks)
55
55
  }
56
56
 
57
57
  const pickObjects = (config, testConfig, getObjects) => {
@@ -520,8 +520,9 @@ const runTest = async (config, expected, { args, verbose, testConfig, debug, tim
520
520
  failed_generatedParenthesized = false
521
521
  }
522
522
 
523
- const pickedResultContexts = result.contexts.map(pickContext(testConfig))
524
- const pickedExpectedContexts = expected.contexts.map(pickContext(testConfig))
523
+ const contextChecks = config.getContextChecks()
524
+ const pickedResultContexts = result.contexts.map(pickContext(contextChecks))
525
+ const pickedExpectedContexts = expected.contexts.map(pickContext(contextChecks))
525
526
  const failedCheckedContexts = !matching(pickedResultContexts, pickedExpectedContexts)
526
527
 
527
528
  const expectedGetObjects = (name) => {
@@ -885,7 +886,8 @@ const defaultInnerProcess = (config, errorHandler, responses) => {
885
886
  console.log(JSON.stringify(picked, null, 2))
886
887
  }
887
888
 
888
- const pickedResultContexts = responses.contexts.map(pickContext(config.testConfig))
889
+ const contextChecks = config.getContextChecks()
890
+ const pickedResultContexts = responses.contexts.map(pickContext(contextChecks))
889
891
  if (pickedResultContexts.some((context) => Object.keys(context).length > 0)) {
890
892
  console.log('--- Contexts showing only the checked values ---')
891
893
  console.log(JSON.stringify(pickedResultContexts, null, 2))
package/package.json CHANGED
@@ -53,6 +53,7 @@
53
53
  "src/digraph_internal.js",
54
54
  "src/generators.js",
55
55
  "src/project.js",
56
+ "src/project2.js",
56
57
  "src/semantics.js"
57
58
  ],
58
59
  "author": "dev@thinktelligence.com",
@@ -69,6 +70,6 @@
69
70
  "sort-json": "^2.0.0",
70
71
  "uuid": "^8.3.2"
71
72
  },
72
- "version": "9.3.0-beta.53",
73
+ "version": "9.3.0-beta.55",
73
74
  "license": "UNLICENSED"
74
75
  }
package/src/config.js CHANGED
@@ -878,6 +878,7 @@ class Config {
878
878
  getInfo () {
879
879
  const name = this.name
880
880
  const includes = this.configs.slice(1).map((km) => km.config.name)
881
+ includes.sort()
881
882
  const visibleExamples = []
882
883
  for (const test of this.tests) {
883
884
  if (!test.developerTest) {
@@ -2596,6 +2597,24 @@ class Config {
2596
2597
  })
2597
2598
  }
2598
2599
 
2600
+ getContextChecks() {
2601
+ const allChecks = []
2602
+ for (const name of this.loadOrdering) {
2603
+ const checks = this.kms[name].testConfig?.checks?.context || []
2604
+ for (const check of checks) {
2605
+ if (check.exported) {
2606
+ allChecks.push(check)
2607
+ }
2608
+ }
2609
+ }
2610
+ for (const check of this.testConfig?.checks?.context || []) {
2611
+ if (!check.exported) {
2612
+ allChecks.push(check)
2613
+ }
2614
+ }
2615
+ return allChecks
2616
+ }
2617
+
2599
2618
  // rebuild ({ isModule: mainIsModule = false } = {}) {
2600
2619
  async rebuild ({ isModule: mainIsModule } = {}) {
2601
2620
  if (this._stop_auto_rebuild) {
@@ -2623,6 +2642,7 @@ class Config {
2623
2642
  // reorder configs base on load ordering
2624
2643
  {
2625
2644
  const ordering = this.loadOrder.order(this.configs.map((km) => km.name || km.uuid))
2645
+ this.loadOrdering = ordering
2626
2646
  const oconfigs = []
2627
2647
  for (const nameOrUUID of ordering) {
2628
2648
  for (const km of this.configs) {
@@ -0,0 +1,54 @@
1
+ function project(source, filters) {
2
+ if (['string', 'number'].includes(typeof source)) {
3
+ return source
4
+ }
5
+
6
+ if (Object.keys(source).length === 0 && filters.length === 0) {
7
+ return {};
8
+ }
9
+
10
+ // Find the applicable filter for the current context
11
+ const filter = filters.find(f => f.match({ context: source }));
12
+ if (!filter) {
13
+ if (Array.isArray(source)) {
14
+ return source.map((element) => project(element, filters))
15
+ }
16
+ return {};
17
+ }
18
+
19
+ // Get the properties to include from the apply function
20
+ let properties = filter.apply();
21
+
22
+ // update
23
+ const updatedProperties = []
24
+ for (const property of properties) {
25
+ if (property.properties) {
26
+ for (const moreProperty of source[property.properties] || []) {
27
+ updatedProperties.push(moreProperty)
28
+ }
29
+ } else {
30
+ updatedProperties.push(property)
31
+ }
32
+ }
33
+ properties = updatedProperties
34
+
35
+ // Build the result object
36
+ const result = {};
37
+ properties.forEach(prop => {
38
+ if (source.hasOwnProperty(prop)) {
39
+ // If the property is an object and not null, recursively project it
40
+ if (typeof source[prop] === 'object' && source[prop] !== null) {
41
+ result[prop] = project(source[prop], filters);
42
+ } else {
43
+ // Copy primitive or null properties directly
44
+ result[prop] = source[prop];
45
+ }
46
+ }
47
+ });
48
+
49
+ return result;
50
+ }
51
+
52
+ module.exports = {
53
+ project
54
+ }