tpmkms_4wp 9.3.0-beta.14 → 9.3.0-beta.16
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.
@@ -25,7 +25,7 @@
|
|
25
25
|
"semantics": [
|
26
26
|
{
|
27
27
|
"match": "({context, isA}) => isA(context.marker, 'dateTimeSelector') && !!context.evaluate",
|
28
|
-
"apply": "({context, isProcess, isTest}) => {\n context.evalue = instantiate(isProcess || isTest, context)\n }"
|
28
|
+
"apply": "({context, isProcess, isTest, kms}) => {\n context.evalue = instantiate(kms, isProcess || isTest || context.isTest, context)\n }"
|
29
29
|
}
|
30
30
|
]
|
31
31
|
}
|
@@ -12,6 +12,7 @@ const dateTimeSelectors_helpers = require('./helpers/dateTimeSelectors')
|
|
12
12
|
delete it
|
13
13
|
make it friday instead
|
14
14
|
2 sundays from now
|
15
|
+
2 sundays from last tuesday
|
15
16
|
the sunday after july 1st
|
16
17
|
the first tuesday after july 1st
|
17
18
|
the first tuesday on or after july 1st
|
@@ -21,14 +22,8 @@ const dateTimeSelectors_helpers = require('./helpers/dateTimeSelectors')
|
|
21
22
|
10 am
|
22
23
|
*/
|
23
24
|
|
24
|
-
function instantiate(isProcessOrTest, dateTimeSelector) {
|
25
|
-
|
26
|
-
if (isProcessOrTest) {
|
27
|
-
// so the unit tests work consistently. the month is zero based so 5 is june
|
28
|
-
now = new Date(2025, 5, 29, 14, 52, 0)
|
29
|
-
} else {
|
30
|
-
now = new Date()
|
31
|
-
}
|
25
|
+
function instantiate(kms, isProcessOrTest, dateTimeSelector) {
|
26
|
+
const now = kms.time.api.now()
|
32
27
|
return dateTimeSelectors_helpers.instantiate(now, dateTimeSelector)
|
33
28
|
}
|
34
29
|
|
@@ -51,8 +46,8 @@ const template = {
|
|
51
46
|
semantics: [
|
52
47
|
{
|
53
48
|
match: ({context, isA}) => isA(context.marker, 'dateTimeSelector') && !!context.evaluate,
|
54
|
-
apply: ({context, isProcess, isTest}) => {
|
55
|
-
context.evalue = instantiate(isProcess || isTest || context.isTest, context)
|
49
|
+
apply: ({context, isProcess, isTest, kms}) => {
|
50
|
+
context.evalue = instantiate(kms, isProcess || isTest || context.isTest, context)
|
56
51
|
},
|
57
52
|
}
|
58
53
|
],
|
@@ -78,11 +78,6 @@ class API {
|
|
78
78
|
|
79
79
|
// word is for one or many
|
80
80
|
makeObject({config, context, types=[], source_value=undefined, doPluralize=true} = {}) {
|
81
|
-
/*
|
82
|
-
if (!context.unknown) {
|
83
|
-
return context.value
|
84
|
-
}
|
85
|
-
*/
|
86
81
|
if (typeof context == 'string') {
|
87
82
|
context = { word: context, value: context }
|
88
83
|
}
|
@@ -119,6 +114,12 @@ class API {
|
|
119
114
|
this.setupObjectHierarchy(config, concept, {types: allTypes});
|
120
115
|
}
|
121
116
|
|
117
|
+
try {
|
118
|
+
pluralize.isSingular(word)
|
119
|
+
} catch ( e ) {
|
120
|
+
debugger
|
121
|
+
return
|
122
|
+
}
|
122
123
|
if (pluralize.isSingular(word)) {
|
123
124
|
addConcept(word, 'one')
|
124
125
|
doPluralize && addConcept(pluralize.plural(word), 'many')
|
package/common/reminders.js
CHANGED
@@ -13,6 +13,9 @@ const helpers = require('./helpers')
|
|
13
13
|
make it friday instead
|
14
14
|
2 sundays from now
|
15
15
|
the sunday after july 1st
|
16
|
+
remind greg to go to regina
|
17
|
+
remind every truck driver to whatever tomorrow at 8 am
|
18
|
+
remind greg and bob to go to bolivia and see the xyz corporation
|
16
19
|
*/
|
17
20
|
|
18
21
|
class API {
|
@@ -29,6 +32,13 @@ class API {
|
|
29
32
|
this.args.mentioned({ context: reminder })
|
30
33
|
}
|
31
34
|
|
35
|
+
addRemindable(id, text) {
|
36
|
+
if (!text) {
|
37
|
+
text = id
|
38
|
+
}
|
39
|
+
this.args.makeObject({ ...this.args, context: { word: text, value: id, number: 'one' }, types: ['remindable'] })
|
40
|
+
}
|
41
|
+
|
32
42
|
async instantiate(reminder) {
|
33
43
|
const value = await this.args.e(reminder.dateTimeSelector)
|
34
44
|
reminder.nextISODate = value?.evalue
|
@@ -87,16 +97,32 @@ const template = {
|
|
87
97
|
configs: [
|
88
98
|
{
|
89
99
|
operators: [
|
90
|
-
"([
|
91
|
-
"([
|
92
|
-
"([remind
|
100
|
+
"([remindable])",
|
101
|
+
{ pattern: "([addRemindable] (word)*)", development: true },
|
102
|
+
"([remind] (remindable/*) (!@<= 'dateTimeSelector')*)",
|
103
|
+
"([remind:withDateBridge] (remindable/*) (!@<= 'dateTimeSelector')* (dateTimeSelector))",
|
104
|
+
"([remind:withDateAndTimeBridge] (remindable/*) (!@<= 'dateTimeSelector')* (dateTimeSelector) (atTime))",
|
93
105
|
"([show] ([reminders]))",
|
94
106
|
"([delete_reminders|delete,cancel] (number/*))",
|
95
107
|
],
|
96
108
|
bridges: [
|
109
|
+
{
|
110
|
+
id: 'addRemindable',
|
111
|
+
isA: ['verb'],
|
112
|
+
development: true,
|
113
|
+
bridge: "{ ...next(operator), arg: after[0], operator: operator, interpolate: '${operator} ${arg}' }",
|
114
|
+
semantic: ({api, context}) => {
|
115
|
+
const name = context.arg.map( (word) => word.text ).join(' ')
|
116
|
+
api.addRemindable(name)
|
117
|
+
}
|
118
|
+
},
|
119
|
+
{
|
120
|
+
id: 'remindable',
|
121
|
+
},
|
97
122
|
{
|
98
123
|
id: 'remind',
|
99
124
|
isA: ['verb'],
|
125
|
+
localHierarchy: [['self', 'remindable']],
|
100
126
|
bridge: "{ ...next(operator), operator: operator, who: after[0], reminder: after[1], interpolate: '${operator} ${who} ${reminder}' }",
|
101
127
|
withDateBridge: "{ ...next(operator), operator: operator, who: after[0], reminder: after[1], date: after[2], interpolate: '${operator} ${who} ${reminder} ${date}' }",
|
102
128
|
withDateAndTimeBridge: "{ ...next(operator), operator: operator, who: after[0], reminder: after[1], date: after[2], time: after[3], interpolate: '${operator} ${who} ${reminder} ${date} ${time}' }",
|