tpmkms_4wp 9.3.0-beta.50 → 9.3.0-beta.52
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/common/dateTimeSelectors.instance.json +42 -5
- package/common/dateTimeSelectors.js +17 -9
- package/common/dateTimeSelectors.test.json +5966 -0
- package/common/dates.instance.json +110 -7
- package/common/dates.js +72 -13
- package/common/dates.test.json +2064 -53
- package/common/dialogues.js +3 -3
- package/common/fastfood.instance.json +154 -594
- package/common/helpers/dateTimeSelectors.js +32 -17
- package/common/helpers/dialogues.js +10 -3
- package/common/helpers/properties.js +2 -2
- package/common/helpers.js +36 -28
- package/common/hierarchy.js +9 -9
- package/common/meta.js +2 -2
- package/common/people.instance.json +36 -0
- package/common/properties.js +4 -4
- package/common/reminders.instance.json +1 -1
- package/common/reminders.js +6 -4
- package/common/reminders.test.json +11119 -0
- package/common/reports.instance.json +1 -1
- package/common/temperature.instance.json +112 -0
- package/common/time.js +2 -2
- package/package.json +2 -2
@@ -3,16 +3,17 @@ const deepEqual = require('deep-equal')
|
|
3
3
|
const { chooseNumber, zip } = require('../helpers.js')
|
4
4
|
const { compose, translationMapping, translationMappingToInstantiatorMappings } = require('./meta.js')
|
5
5
|
|
6
|
+
const dayMap = {
|
7
|
+
'sunday_dates': 0,
|
8
|
+
'monday_dates': 1,
|
9
|
+
'tuesday_dates': 2,
|
10
|
+
'wednesday_dates': 3,
|
11
|
+
'thursday_dates': 4,
|
12
|
+
'friday_dates': 5,
|
13
|
+
'saturday_dates': 6
|
14
|
+
};
|
15
|
+
|
6
16
|
function getNextDayOfWeek(date, targetDay) {
|
7
|
-
const dayMap = {
|
8
|
-
'sunday_dates': 0,
|
9
|
-
'monday_dates': 1,
|
10
|
-
'tuesday_dates': 2,
|
11
|
-
'wednesday_dates': 3,
|
12
|
-
'thursday_dates': 4,
|
13
|
-
'friday_dates': 5,
|
14
|
-
'saturday_dates': 6
|
15
|
-
};
|
16
17
|
|
17
18
|
const targetDayNum = dayMap[targetDay.toLowerCase()]
|
18
19
|
if (!targetDayNum) {
|
@@ -96,7 +97,8 @@ instantiate = (isA, now, context) => {
|
|
96
97
|
let value
|
97
98
|
if (value = getType(context, 'monthDay_dates')) {
|
98
99
|
const day = value.day.value;
|
99
|
-
const month = toMonthNumber(value.month.value);
|
100
|
+
// const month = toMonthNumber(value.month.value);
|
101
|
+
const month = value.month.month_ordinal
|
100
102
|
const currentMonth = now.getMonth() + 1; // 1-based (January = 1)
|
101
103
|
const currentYear = now.getFullYear();
|
102
104
|
const year = currentMonth >= month ? currentYear + 1 : currentYear;
|
@@ -104,7 +106,8 @@ instantiate = (isA, now, context) => {
|
|
104
106
|
return date.toISOString()
|
105
107
|
} else if (value = getType(context, 'monthDayYear_dates')) {
|
106
108
|
const day = value.day.value;
|
107
|
-
const month = toMonthNumber(value.month.value);
|
109
|
+
// const month = toMonthNumber(value.month.value);
|
110
|
+
const month = value.month.month_ordinal
|
108
111
|
const year = value.year.value;
|
109
112
|
const date = new Date(year, month-1, day)
|
110
113
|
return date.toISOString()
|
@@ -138,10 +141,7 @@ instantiate = (isA, now, context) => {
|
|
138
141
|
function getNthDayOfMonth(dayName, ordinal, monthName, now) {
|
139
142
|
// Validate inputs
|
140
143
|
const days = ['sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday'];
|
141
|
-
const months = [
|
142
|
-
'january', 'february', 'march', 'april', 'may', 'june',
|
143
|
-
'july', 'august', 'september', 'october', 'november', 'december'
|
144
|
-
];
|
144
|
+
const months = [ 'january', 'february', 'march', 'april', 'may', 'june', 'july', 'august', 'september', 'october', 'november', 'december' ];
|
145
145
|
|
146
146
|
let year = now.getFullYear()
|
147
147
|
|
@@ -173,11 +173,26 @@ function getNthDayOfMonth(dayName, ordinal, monthName, now) {
|
|
173
173
|
return date.toISOString();
|
174
174
|
}
|
175
175
|
|
176
|
-
|
176
|
+
function getNthWeekdayAfterDate(startDate, weekday_ordinal, n) {
|
177
|
+
// Ensure startDate is a Date object
|
178
|
+
const date = new Date(startDate);
|
179
|
+
let weekday_index = weekday_ordinal - 1
|
180
|
+
// Normalize weekday_index (0 = Sunday, 1 = Monday, ..., 6 = Saturday)
|
181
|
+
weekday_index = (weekday_index % 7 + 7) % 7;
|
182
|
+
// Get current day of the week
|
183
|
+
const currentDay = date.getDay();
|
184
|
+
// Calculate days until the next desired weekday_index
|
185
|
+
let daysUntilNext = (weekday_index - currentDay + 7) % 7;
|
186
|
+
if (daysUntilNext === 0) daysUntilNext = 7; // Move to next occurrence if already on the desired weekday_index
|
187
|
+
// Calculate total days to add: days until next weekday_index + 7 days for each additional occurrence
|
188
|
+
const daysToAdd = daysUntilNext + (n - 1) * 7;
|
189
|
+
// Add days to the start date
|
190
|
+
date.setDate(date.getDate() + daysToAdd);
|
191
|
+
return date.toISOString();
|
177
192
|
}
|
178
193
|
|
179
194
|
module.exports = {
|
180
195
|
instantiate,
|
181
|
-
until,
|
182
196
|
getNthDayOfMonth,
|
197
|
+
getNthWeekdayAfterDate,
|
183
198
|
}
|
@@ -77,7 +77,7 @@ class API {
|
|
77
77
|
}
|
78
78
|
|
79
79
|
// word is for one or many
|
80
|
-
makeObject({config, context, types=[], source_value=undefined, doPluralize=true, initial=
|
80
|
+
async makeObject({config, context, types=[], source_value=undefined, doPluralize=true, initial={}} = {}) {
|
81
81
|
if (typeof context == 'string') {
|
82
82
|
context = { word: context, value: context }
|
83
83
|
}
|
@@ -98,11 +98,18 @@ class API {
|
|
98
98
|
}
|
99
99
|
return concept
|
100
100
|
}
|
101
|
+
|
102
|
+
initial.value = source_value || concept
|
103
|
+
await this.args.s({ value, makeObject: true, initial })
|
101
104
|
// config.addOperator({ pattern: `(["${fixUps(concept)}"])`, allowDups: true })
|
102
|
-
config.addOperator({ pattern: `(["${concept}"])`, allowDups: true })
|
105
|
+
config.addOperator({ pattern: `(["${concept}"|])`, allowDups: true })
|
103
106
|
config.addBridge({ id: concept, level: 0, bridge: `{ ...next(operator), value: or(operator.value, '${source_value || concept}') }` , allowDups: true })
|
107
|
+
|
104
108
|
const addConcept = (word, number) => {
|
105
|
-
|
109
|
+
if (number) {
|
110
|
+
initial.number = number
|
111
|
+
}
|
112
|
+
config.addWord(word, { id: concept, initial: JSON.stringify(initial) } )
|
106
113
|
const baseTypes = [
|
107
114
|
'theAble',
|
108
115
|
'queryable',
|
@@ -546,9 +546,9 @@ class API {
|
|
546
546
|
}
|
547
547
|
}
|
548
548
|
|
549
|
-
makeObject(args) {
|
549
|
+
async makeObject(args) {
|
550
550
|
const types = [ 'hierarchyAble', 'object', 'property' ];
|
551
|
-
return args.km("dialogues").api.makeObject({ ...args, types: (args.types || []).concat(types) });
|
551
|
+
return await args.km("dialogues").api.makeObject({ ...args, types: (args.types || []).concat(types) });
|
552
552
|
}
|
553
553
|
|
554
554
|
relation_add (relations) {
|
package/common/helpers.js
CHANGED
@@ -166,20 +166,23 @@ const defaultContextCheckValidify = (properties) => {
|
|
166
166
|
|
167
167
|
const defaultContextCheckProperties = ['marker', 'text', 'verbatim', 'isResponse', 'types', { property: 'response', filter: ['marker', 'text', 'verbatim'] }]
|
168
168
|
|
169
|
-
const expand_checks = (properties) => {
|
169
|
+
const expand_checks = (properties, variables = {}) => {
|
170
170
|
let expanded = []
|
171
171
|
if (properties == 'defaults') {
|
172
172
|
return defaultContextCheckProperties
|
173
173
|
}
|
174
|
+
if (properties.variable) {
|
175
|
+
return variables[properties.variable]
|
176
|
+
}
|
174
177
|
if (Array.isArray(properties)) {
|
175
178
|
for (const property of properties) {
|
176
179
|
defaultContextCheckValidify(properties)
|
177
180
|
if (typeof property == 'string') {
|
178
181
|
expanded.push({ property, filter: defaultContextCheckProperties })
|
179
182
|
} else if (property.property && property.filter) {
|
180
|
-
expanded.push({ property: property.property, filter: [defaultContextCheckProperties, ...expand_checks(property.filter)] })
|
183
|
+
expanded.push({ property: property.property, filter: [defaultContextCheckProperties, ...expand_checks(property.filter, variables)] })
|
181
184
|
} else {
|
182
|
-
expanded = [...expanded, ...expand_checks(property)]
|
185
|
+
expanded = [...expanded, ...expand_checks(property, variables)]
|
183
186
|
}
|
184
187
|
}
|
185
188
|
return expanded
|
@@ -188,38 +191,43 @@ const expand_checks = (properties) => {
|
|
188
191
|
if (key === '_') {
|
189
192
|
expanded = [...expanded, ...defaultContextCheckProperties]
|
190
193
|
} else {
|
191
|
-
expanded.push({ property: key, filter: [...expand_checks(properties[key])] })
|
194
|
+
expanded.push({ property: key, filter: [...expand_checks(properties[key], variables)] })
|
192
195
|
}
|
193
196
|
}
|
194
197
|
return expanded
|
195
198
|
|
196
199
|
}
|
197
200
|
|
198
|
-
const defaultContextCheck = (properties = []) => {
|
201
|
+
const defaultContextCheck = (properties = [], variables={}, minimal=false) => {
|
199
202
|
defaultContextCheckValidify(properties)
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
}
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
203
|
+
variables.defaults = defaultContextCheckProperties
|
204
|
+
if (minimal) {
|
205
|
+
return expand_checks(properties, variables)
|
206
|
+
} else {
|
207
|
+
return [
|
208
|
+
...defaultContextCheckProperties,
|
209
|
+
// ...properties.map((property) => { return { property, filter: defaultContextCheckProperties } }),
|
210
|
+
...expand_checks(properties, variables),
|
211
|
+
(object) => {
|
212
|
+
if (typeof object.value == 'object') {
|
213
|
+
return { property: 'value', filter: defaultContextCheckProperties }
|
214
|
+
} else {
|
215
|
+
return 'value'
|
216
|
+
}
|
217
|
+
},
|
218
|
+
(object) => {
|
219
|
+
if (!Array.isArray(object.modifiers)) {
|
220
|
+
return
|
221
|
+
}
|
222
|
+
if (typeof object.modifiers[0] == 'object') {
|
223
|
+
return { property: 'modifiers', filter: defaultContextCheckProperties }
|
224
|
+
} else {
|
225
|
+
return 'modifiers'
|
226
|
+
}
|
227
|
+
},
|
228
|
+
{ property: 'modifiers', isPropertyList: true, filter: defaultContextCheckProperties }
|
229
|
+
]
|
230
|
+
}
|
223
231
|
}
|
224
232
|
|
225
233
|
const isA = (hierarchy) => (child, parent, { strict=false } = {}) => {
|
package/common/hierarchy.js
CHANGED
@@ -164,15 +164,15 @@ const config = {
|
|
164
164
|
notes: 'c is a y',
|
165
165
|
where: where(),
|
166
166
|
match: ({context, listable}) => listable(context.marker, 'hierarchyAble') && !context.pullFromContext && !context.wantsValue && context.same && !context.same.pullFromContext && context.same.wantsValue,
|
167
|
-
apply: ({context, km, objects, asList, baseConfig : config}) => {
|
167
|
+
apply: async ({context, km, objects, asList, baseConfig : config}) => {
|
168
168
|
const api = km('properties').api
|
169
169
|
// mark c as an instance?
|
170
170
|
const oneConcepts = asList(context);
|
171
171
|
const twoConcepts = asList(context.same);
|
172
172
|
for (let oneConcept of oneConcepts.value) {
|
173
173
|
for (let twoConcept of twoConcepts.value) {
|
174
|
-
oneConcept = api.makeObject({config, context})
|
175
|
-
twoConcept = api.makeObject({config, context: context.same})
|
174
|
+
oneConcept = await api.makeObject({config, context})
|
175
|
+
twoConcept = await api.makeObject({config, context: context.same})
|
176
176
|
api.rememberIsA(oneConcept, twoConcept)
|
177
177
|
}
|
178
178
|
}
|
@@ -183,14 +183,14 @@ const config = {
|
|
183
183
|
notes: 'an x is a y',
|
184
184
|
where: where(),
|
185
185
|
match: ({context, listable}) => listable(context.marker, 'hierarchyAble') && !context.pullFromContext && context.wantsValue && context.same,
|
186
|
-
apply: ({context, km, objects, baseConfig : config, asList}) => {
|
186
|
+
apply: async ({context, km, objects, baseConfig : config, asList}) => {
|
187
187
|
const api = km('properties').api
|
188
188
|
const oneConcepts = asList(context);
|
189
189
|
const twoConcepts = asList(context.same);
|
190
190
|
for (let oneConcept of oneConcepts.value) {
|
191
191
|
for (let twoConcept of twoConcepts.value) {
|
192
|
-
oneConcept = api.makeObject({config, context})
|
193
|
-
twoConcept = api.makeObject({config, context: context.same})
|
192
|
+
oneConcept = await api.makeObject({config, context})
|
193
|
+
twoConcept = await api.makeObject({config, context: context.same})
|
194
194
|
api.rememberIsA(oneConcept, twoConcept)
|
195
195
|
context.sameWasProcessed = true
|
196
196
|
}
|
@@ -246,15 +246,15 @@ const config = {
|
|
246
246
|
|
247
247
|
return listable(context, 'hierarchyAble') && context.same && context.same.concept && !context.query
|
248
248
|
},
|
249
|
-
apply: (args) => {
|
249
|
+
apply: async (args) => {
|
250
250
|
const {callId, config, objects, km, context, asList, listable} = args
|
251
251
|
const api = km('properties').api
|
252
252
|
const oneConcepts = asList(context);
|
253
253
|
const twoConcepts = asList(context.same);
|
254
254
|
for (const oneConcept of oneConcepts.value) {
|
255
255
|
for (const twoConcept of twoConcepts.value) {
|
256
|
-
oneConceptId = api.makeObject({...args, context: oneConcept})
|
257
|
-
twoConceptId = api.makeObject({...args, context: twoConcept})
|
256
|
+
oneConceptId = await api.makeObject({...args, context: oneConcept})
|
257
|
+
twoConceptId = await api.makeObject({...args, context: twoConcept})
|
258
258
|
api.rememberIsA(oneConceptId, twoConceptId)
|
259
259
|
context.sameWasProcessed = true
|
260
260
|
}
|
package/common/meta.js
CHANGED
@@ -288,12 +288,12 @@ const config = {
|
|
288
288
|
if (kms.dialogues) {
|
289
289
|
if (context.from.unknown && !context.to.unknown) {
|
290
290
|
// kms.dialogues.api.makeObject({ context: context.from, types: [context.to.marker], source_value: context.to.value, config });
|
291
|
-
kms.dialogues.api.makeObject({ context: context.from, types: [context.to.marker], source_value: context.to.value, config });
|
291
|
+
await kms.dialogues.api.makeObject({ context: context.from, types: [context.to.marker], source_value: context.to.value, config });
|
292
292
|
}
|
293
293
|
if (context.to.value) {
|
294
294
|
kms.stm.api.setVariable(context.from.value, context.to.value)
|
295
295
|
} else {
|
296
|
-
kms.dialogues.api.makeObject({ context: context.from, types: context.to.types || [], config });
|
296
|
+
await kms.dialogues.api.makeObject({ context: context.from, types: context.to.types || [], config });
|
297
297
|
kms.stm.api.setVariable(context.from.value, context.to)
|
298
298
|
}
|
299
299
|
}
|
@@ -8430,6 +8430,24 @@
|
|
8430
8430
|
0
|
8431
8431
|
]
|
8432
8432
|
],
|
8433
|
+
[
|
8434
|
+
[
|
8435
|
+
"by",
|
8436
|
+
0
|
8437
|
+
],
|
8438
|
+
[
|
8439
|
+
"isEd",
|
8440
|
+
0
|
8441
|
+
],
|
8442
|
+
[
|
8443
|
+
"owned",
|
8444
|
+
0
|
8445
|
+
],
|
8446
|
+
[
|
8447
|
+
"unknown",
|
8448
|
+
0
|
8449
|
+
]
|
8450
|
+
],
|
8433
8451
|
[
|
8434
8452
|
[
|
8435
8453
|
"isEd",
|
@@ -8828,6 +8846,24 @@
|
|
8828
8846
|
0
|
8829
8847
|
]
|
8830
8848
|
],
|
8849
|
+
[
|
8850
|
+
[
|
8851
|
+
"by",
|
8852
|
+
0
|
8853
|
+
],
|
8854
|
+
[
|
8855
|
+
"isEd",
|
8856
|
+
0
|
8857
|
+
],
|
8858
|
+
[
|
8859
|
+
"owned",
|
8860
|
+
0
|
8861
|
+
],
|
8862
|
+
[
|
8863
|
+
"unknown",
|
8864
|
+
0
|
8865
|
+
]
|
8866
|
+
],
|
8831
8867
|
[
|
8832
8868
|
[
|
8833
8869
|
"first",
|
package/common/properties.js
CHANGED
@@ -432,9 +432,9 @@ const config = {
|
|
432
432
|
{
|
433
433
|
where: where(),
|
434
434
|
match: ({context}) => context.marker == 'concept' && context.same,
|
435
|
-
apply: (args) => {
|
435
|
+
apply: async (args) => {
|
436
436
|
const {context} = args
|
437
|
-
args.makeObject({ ...args, context: context.same })
|
437
|
+
await args.makeObject({ ...args, context: context.same })
|
438
438
|
context.sameWasProcessed = true
|
439
439
|
}
|
440
440
|
},
|
@@ -550,8 +550,8 @@ const config = {
|
|
550
550
|
const propertyContext = context;
|
551
551
|
const objectId = context.object.value
|
552
552
|
|
553
|
-
api.makeObject({ ...args, context: objectContext })
|
554
|
-
api.makeObject({ ...args, context: propertyContext })
|
553
|
+
await api.makeObject({ ...args, context: objectContext })
|
554
|
+
await api.makeObject({ ...args, context: propertyContext })
|
555
555
|
// const propertyId = context.value
|
556
556
|
/*
|
557
557
|
const propertyId = context.marker
|
@@ -53,7 +53,7 @@
|
|
53
53
|
],
|
54
54
|
"development": true,
|
55
55
|
"bridge": "{ ...next(operator), flatten: true, arg: after[0], operator: operator, interpolate: '${operator} ${arg}' }",
|
56
|
-
"semantic": "({api, context}) => {\n const name = context.arg.map( (word) => word.text ).join(' ')\n api.addRemindable(name)\n }"
|
56
|
+
"semantic": "async ({api, context}) => {\n const name = context.arg.map( (word) => word.text ).join(' ')\n await api.addRemindable(name)\n }"
|
57
57
|
},
|
58
58
|
{
|
59
59
|
"id": "remindable",
|
package/common/reminders.js
CHANGED
@@ -110,11 +110,11 @@ class API {
|
|
110
110
|
}
|
111
111
|
}
|
112
112
|
|
113
|
-
addRemindable(id, text) {
|
113
|
+
async addRemindable(id, text) {
|
114
114
|
if (!text) {
|
115
115
|
text = id
|
116
116
|
}
|
117
|
-
this.args.makeObject({ ...this.args, context: { word: text, value: id, number: 'one', remindee_id: id }, initial:
|
117
|
+
await this.args.makeObject({ ...this.args, context: { word: text, value: id, number: 'one', remindee_id: id }, initial: { remindee_id: `${id}` }, types: ['remindable'] })
|
118
118
|
}
|
119
119
|
|
120
120
|
async instantiate(reminder) {
|
@@ -222,6 +222,7 @@ const template = {
|
|
222
222
|
"([remind:justWhoBridge] (remindable/*))",
|
223
223
|
"([remind] (remindable/*) (!@<= 'dateTimeSelector' && !@<= 'inAddition')*)",
|
224
224
|
"([remind:withDateBridge] (remindable/*) (!@<= 'dateTimeSelector' && !@<= 'inAddition')* (dateTimeSelector))",
|
225
|
+
"([remind:withDateFirstBridge] (remindable/*) (dateTimeSelector) (!@<= 'dateTimeSelector' && !@<= 'inAddition')*)",
|
225
226
|
"([remind:withDateAndTimeBridge] (remindable/*) (!@<= 'dateTimeSelector' && !@<= 'inAddition')* (dateTimeSelector) (atTime))",
|
226
227
|
"([remindResponse] (!@<= 'remindResponse' && !@<= 'dateTimeSelector' && !@<= 'inAddition')+ (dateTimeSelector))",
|
227
228
|
"([show] ([reminders]))",
|
@@ -258,9 +259,9 @@ const template = {
|
|
258
259
|
isA: ['verb'],
|
259
260
|
development: true,
|
260
261
|
bridge: "{ ...next(operator), flatten: true, arg: after[0], operator: operator, interpolate: '${operator} ${arg}' }",
|
261
|
-
semantic: ({api, context}) => {
|
262
|
+
semantic: async ({api, context}) => {
|
262
263
|
const name = context.arg.map( (word) => word.text ).join(' ')
|
263
|
-
api.addRemindable(name)
|
264
|
+
await api.addRemindable(name)
|
264
265
|
}
|
265
266
|
},
|
266
267
|
{
|
@@ -290,6 +291,7 @@ const template = {
|
|
290
291
|
bridge: "{ ...next(operator), operator: operator, who: after[0], reminder: after[1], interpolate: '${operator} ${who} ${reminder}' }",
|
291
292
|
justWhoBridge: "{ ...next(operator), bridge: 'justWhoBridge', operator: operator, who: after[0], interpolate: '${operator} ${who}' }",
|
292
293
|
withDateBridge: "{ ...next(operator), operator: operator, who: after[0], reminder: after[1], date: after[2], interpolate: '${operator} ${who} ${reminder} ${date}' }",
|
294
|
+
withDateFirstBridge: "{ ...next(operator), operator: operator, who: after[0], reminder: after[2], date: after[1], interpolate: '${operator} ${who} ${date} ${reminder}' }",
|
293
295
|
withDateAndTimeBridge: "{ ...next(operator), operator: operator, who: after[0], reminder: after[1], date: after[2], time: after[3], interpolate: '${operator} ${who} ${reminder} ${date} ${time}' }",
|
294
296
|
semantics: [
|
295
297
|
{
|