tpmkms_4wp 9.3.0-beta.6 → 9.3.0-beta.60

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 (111) hide show
  1. package/common/animals.instance.json +0 -65
  2. package/common/animals.js +2 -3
  3. package/common/animals.test.json +1607 -1
  4. package/common/articles.js +2 -4
  5. package/common/asking.js +21 -5
  6. package/common/avatar.js +2 -2
  7. package/common/characters.js +2 -2
  8. package/common/colors.instance.json +28 -70
  9. package/common/colors.js +2 -2
  10. package/common/comparable.instance.json +0 -15
  11. package/common/comparable.js +2 -2
  12. package/common/concept.js +1 -2
  13. package/common/concept.test.json +279 -193
  14. package/common/conjunction.js +3 -5
  15. package/common/countable.js +2 -14
  16. package/common/crew.instance.json +72 -130
  17. package/common/crew.js +2 -2
  18. package/common/currency.js +2 -3
  19. package/common/dateTimeSelectors.instance.json +175 -0
  20. package/common/dateTimeSelectors.js +168 -0
  21. package/common/dateTimeSelectors.test.json +85622 -0
  22. package/common/dates.instance.json +538 -506
  23. package/common/dates.js +112 -15
  24. package/common/dates.test.json +11021 -514
  25. package/common/dialogues.js +13 -49
  26. package/common/dimension.instance.json +0 -5
  27. package/common/dimension.js +4 -4
  28. package/common/edible.instance.json +56 -160
  29. package/common/edible.js +2 -2
  30. package/common/emotions.instance.json +0 -5
  31. package/common/emotions.js +2 -2
  32. package/common/errors.js +3 -0
  33. package/common/evaluate.js +2 -2
  34. package/common/events.js +1 -2
  35. package/common/fastfood.instance.json +172 -435
  36. package/common/fastfood.js +2 -4
  37. package/common/fastfood.test.json +16291 -6597
  38. package/common/formulas.instance.json +0 -5
  39. package/common/formulas.js +3 -1
  40. package/common/gdefaults.js +2 -3
  41. package/common/help.js +2 -2
  42. package/common/helpers/dateTimeSelectors.js +198 -0
  43. package/common/helpers/dialogues.js +11 -8
  44. package/common/helpers/properties.js +2 -2
  45. package/common/helpers.js +23 -47
  46. package/common/hierarchy.js +12 -13
  47. package/common/javascript.js +2 -3
  48. package/common/kirk.instance.json +0 -5
  49. package/common/kirk.js +2 -3
  50. package/common/length.instance.json +0 -75
  51. package/common/length.js +2 -3
  52. package/common/listener.js +3 -1
  53. package/common/math.instance.json +0 -5
  54. package/common/math.js +2 -3
  55. package/common/menus.instance.json +0 -35
  56. package/common/menus.js +3 -1
  57. package/common/meta.js +4 -5
  58. package/common/nameable.js +3 -1
  59. package/common/negation.js +2 -2
  60. package/common/numbers.js +7 -4
  61. package/common/numbers.test.json +89 -23
  62. package/common/ordering.instance.json +0 -10
  63. package/common/ordering.js +2 -3
  64. package/common/ordinals.js +2 -3
  65. package/common/people.instance.json +0 -40
  66. package/common/people.js +2 -3
  67. package/common/percentages.js +3 -4
  68. package/common/percentages.test.json +57 -11
  69. package/common/pipboy.instance.json +84 -85
  70. package/common/pipboy.js +1 -1
  71. package/common/pipboy.test.json +4377 -3386
  72. package/common/pokemon.instance.json +0 -65
  73. package/common/pokemon.js +1 -2
  74. package/common/pos.js +2 -2
  75. package/common/pressure.instance.json +0 -20
  76. package/common/pressure.js +2 -2
  77. package/common/properties.instance.json +0 -5
  78. package/common/properties.js +11 -13
  79. package/common/punctuation.js +2 -2
  80. package/common/reminders.instance.json +153 -23
  81. package/common/reminders.js +275 -82
  82. package/common/reminders.test.json +75654 -37
  83. package/common/reports.instance.json +1 -11
  84. package/common/reports.js +1 -1
  85. package/common/scorekeeper.js +2 -2
  86. package/common/scorekeeper.test.json +3565 -7550
  87. package/common/sdefaults.js +1 -1
  88. package/common/self.js +1 -1
  89. package/common/sizeable.js +2 -2
  90. package/common/spock.instance.json +0 -5
  91. package/common/spock.js +1 -1
  92. package/common/stgame.js +1 -1
  93. package/common/stm.js +1 -1
  94. package/common/tell.js +2 -2
  95. package/common/temperature.instance.json +84 -20
  96. package/common/temperature.js +2 -2
  97. package/common/tester.js +0 -1
  98. package/common/testing.js +0 -1
  99. package/common/time.js +57 -30
  100. package/common/time.test.json +4159 -205
  101. package/common/tokenize.js +1 -1
  102. package/common/ui.instance.json +0 -5
  103. package/common/ui.js +4 -2
  104. package/common/weight.instance.json +0 -112
  105. package/common/weight.js +2 -2
  106. package/common/wp.instance.json +56 -70
  107. package/common/wp.js +1 -3
  108. package/common/wp.test.json +8057 -3867
  109. package/common/yesno.js +2 -2
  110. package/main.js +2 -0
  111. package/package.json +8 -4
@@ -0,0 +1,168 @@
1
+ const { knowledgeModule, where } = require('./runtime').theprogrammablemind
2
+ const { defaultContextCheck } = require('./helpers')
3
+ const dateTimeSelectors_tests = require('./dateTimeSelectors.test.json')
4
+ const dateTimeSelectors_instance = require('./dateTimeSelectors.instance.json')
5
+ const dates = require('./dates')
6
+ const time = require('./time')
7
+ const dateTimeSelectors_helpers = require('./helpers/dateTimeSelectors')
8
+
9
+ /*
10
+ friday instead
11
+ change it to friday
12
+ delete it
13
+ make it friday instead
14
+ 2 sundays from now
15
+ 2 sundays from last tuesday
16
+ the sunday after july 1st
17
+ the first tuesday after july 1st
18
+ the first tuesday on or after july 1st
19
+ the last tuesday of every month
20
+ the last tuesday of every third month
21
+ monday at 10 am
22
+ 10 am
23
+ first monday after jan 1
24
+ */
25
+
26
+ function instantiate(kms, isA, isProcessOrTest, dateTimeSelector) {
27
+ try {
28
+ const now = kms.time.api.now()
29
+ return dateTimeSelectors_helpers.instantiate(isA, now, dateTimeSelector)
30
+ } catch ( e ) {
31
+ return `Implement instatiate for this type of date. See the dateTimeSelectors KM ${where()}`
32
+ }
33
+ }
34
+
35
+ function removeDatesSuffix(str) {
36
+ if (str.endsWith('_dates')) {
37
+ return str.slice(0, -6); // Removes last 6 characters
38
+ }
39
+ return str;
40
+ }
41
+
42
+ function onOrIs(marker, context) {
43
+ if (context.marker === marker) {
44
+ return context
45
+ }
46
+ if (context.marker === 'onDate_dates' && context.date?.marker == marker) {
47
+ return context.date
48
+ }
49
+ }
50
+
51
+ function afterOrIs(marker, context) {
52
+ if (context.marker === marker) {
53
+ return context
54
+ }
55
+ if (context.marker === 'onDate_dates' && context.date?.marker == marker) {
56
+ return context.date
57
+ }
58
+ }
59
+
60
+ const template = {
61
+ configs: [
62
+ {
63
+ operators: [
64
+ "([dateTimeSelector] (onDate) (atTime))",
65
+ "((day_dates/*) [dayOfMonth|of] (month_dates/*))",
66
+ "((day_dates/*) [dayAfterDate|after] (afterDateValue_dates/*))",
67
+ ],
68
+ bridges: [
69
+ {
70
+ id: 'dayOfMonth',
71
+ after: ['article'],
72
+ isA: ['onDateValue_dates'],
73
+ before: ['verb', 'onDate_dates'],
74
+ bridge: "{ ...next(operator), day: before[0], month: after[0], operator: operator, interpolate: '${day} ${operator} ${month}' }",
75
+ check: ['day', 'month'],
76
+ },
77
+ {
78
+ id: 'dayAfterDate',
79
+ after: ['article', 'monthDayYear_dates'],
80
+ isA: ['onDateValue_dates'],
81
+ before: ['verb', 'afterDate_dates'],
82
+ bridge: "{ ...next(operator), day: before[0], after: after[0], operator: operator, interpolate: '${day} ${operator} ${after}' }",
83
+ check: ['day', 'after'],
84
+ },
85
+ {
86
+ id: 'dateTimeSelector',
87
+ after: ['preposition'],
88
+ before: ['verb'],
89
+ convolution: true,
90
+ children: ['onDate_dates', 'atTime', 'date_dates'],
91
+ bridge: "{ ...next(operator), date: after[0], time: after[1], interpolate: '${date} ${time}' }",
92
+ check: ['time', 'date'],
93
+ },
94
+ ],
95
+ semantics: [
96
+ {
97
+ match: ({context, isA}) => context.evaluate && onOrIs('dayAfterDate', context),
98
+ apply: async ({context, isProcess, isTest, kms, isA, e}) => {
99
+ try {
100
+ const now = kms.time.api.now()
101
+ const date = afterOrIs('dayAfterDate', context)
102
+ const afterISO = (await e(date.after)).evalue
103
+ const day_ordinal = date.day.day_ordinal
104
+ const ordinal = date.day.ordinal.value
105
+ context.evalue = dateTimeSelectors_helpers.getNthWeekdayAfterDate(afterISO, day_ordinal, ordinal)
106
+ } catch ( e ) {
107
+ context.evalue = `Implement instatiate for this type of date. See the dateTimeSelectors KM ${where()}. ${e}`
108
+ }
109
+ },
110
+ },
111
+ {
112
+ match: ({context, isA}) => context.evaluate && onOrIs('dayOfMonth', context),
113
+ apply: ({context, isProcess, isTest, kms, isA}) => {
114
+ try {
115
+ const now = kms.time.api.now()
116
+ const date = onOrIs('dayOfMonth', context)
117
+ context.evalue = dateTimeSelectors_helpers.getNthDayOfMonth(removeDatesSuffix(date.day.value), date.day.ordinal.value || 1, removeDatesSuffix(date.month.value), now)
118
+ } catch ( e ) {
119
+ context.evalue = `Implement instatiate for this type of date. See the dateTimeSelectors KM ${where()}. ${e}`
120
+ }
121
+ },
122
+ },
123
+ {
124
+ match: ({context, isA}) => {
125
+ if (!context.evaluate) {
126
+ return false
127
+ }
128
+ if (isA(context.marker, 'onDateValue_dates')) {
129
+ return true
130
+ }
131
+ if (isA(context.marker, 'dateTimeSelector')) {
132
+ return true
133
+ }
134
+ },
135
+ apply: ({context, isProcess, isTest, kms, isA}) => {
136
+ context.evalue = instantiate(kms, isA, isProcess || isTest || context.isTest, context)
137
+ },
138
+ }
139
+ ],
140
+ hierarchy: [
141
+ ['day_dates', 'orderable'],
142
+ ],
143
+ },
144
+ ],
145
+ }
146
+
147
+ knowledgeModule( {
148
+ config: { name: 'dateTimeSelectors' },
149
+ includes: [time, dates],
150
+
151
+ module,
152
+ description: 'talking about date and time selectors',
153
+ test: {
154
+ name: './dateTimeSelectors.test.json',
155
+ contents: dateTimeSelectors_tests,
156
+ checks: {
157
+ context: [
158
+ // defaultContextCheck({ extra: ['date', 'time', 'response', 'after', 'day', 'month', 'year', 'evalue'] }),
159
+ defaultContextCheck({ extra: ['date', 'time', 'response', 'after', 'evalue'] }),
160
+ ],
161
+ }
162
+ },
163
+ template: {
164
+ template,
165
+ instance: dateTimeSelectors_instance,
166
+ },
167
+
168
+ })