tpmkms_4wp 9.3.0-beta.25 → 9.3.0-beta.27

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.
@@ -42,12 +42,20 @@ class API {
42
42
  const reminder = this._objects.reminders.find((r) => r.id == this._objects.current)
43
43
  if (reminder) {
44
44
  if (Array.isArray(reminder.who)) {
45
+ reminder.who = [...reminder.who, user]
45
46
  } else {
46
47
  reminder.who = [reminder.who, user]
47
48
  }
48
49
  }
49
50
  }
50
51
 
52
+ removeUser(user) {
53
+ const reminder = this._objects.reminders.find((r) => r.id == this._objects.current)
54
+ if (reminder) {
55
+ reminder.who = reminder.who.filter((who) => who.remindee_id != user.remindee_id)
56
+ }
57
+ }
58
+
51
59
  addRemindable(id, text) {
52
60
  if (!text) {
53
61
  text = id
@@ -80,7 +88,7 @@ class API {
80
88
  const items = []
81
89
  for (const item of this._objects.reminders) {
82
90
  if (!item.dateTimeSelector) {
83
- items.push({ when: true, text: item.text, id: item.id })
91
+ items.push({ when: true, who: item.who, text: item.text, id: item.id })
84
92
  }
85
93
  }
86
94
  return items
@@ -127,20 +135,37 @@ const template = {
127
135
  operators: [
128
136
  "([remindable])",
129
137
  { pattern: "([addRemindable] (word)*)", development: true },
130
- "([remind] (remindable/*) (!@<= 'dateTimeSelector')*)",
131
- "([remind:withDateBridge] (remindable/*) (!@<= 'dateTimeSelector')* (dateTimeSelector))",
132
- "([remind:withDateAndTimeBridge] (remindable/*) (!@<= 'dateTimeSelector')* (dateTimeSelector) (atTime))",
138
+ "([remind:justWhoBridge] (remindable/*))",
139
+ "([remind] (remindable/*) (!@<= 'dateTimeSelector' && !@<= 'inAddition')*)",
140
+ "([remind:withDateBridge] (remindable/*) (!@<= 'dateTimeSelector' && !@<= 'inAddition')* (dateTimeSelector))",
141
+ "([remind:withDateAndTimeBridge] (remindable/*) (!@<= 'dateTimeSelector' && !@<= 'inAddition')* (dateTimeSelector) (atTime))",
133
142
  "([show] ([reminders]))",
134
143
  "([delete_reminders|delete,cancel] (number/*))",
135
144
  "([add] (remindable/*))",
145
+ "([remove|] (remindable/*))",
146
+ "((verb/*) [inAddition|also,too])",
136
147
  ],
137
148
  bridges: [
149
+ {
150
+ id: 'inAddition',
151
+ after: ['verb'],
152
+ bridge: "{ ...before[0], inAddition: true, verb: before[0], operator: operator, interpolate: '${verb} ${operator}' }",
153
+ },
138
154
  {
139
155
  id: 'add',
140
156
  isA: ['verb'],
141
157
  bridge: "{ ...next(operator), arg: after[0], operator: operator, interpolate: '${operator} ${arg}' }",
142
158
  semantic: ({api, context}) => {
143
- api.addUser(context.arg)
159
+ api.addUser(api.contextToWho(context.arg))
160
+ }
161
+ },
162
+ {
163
+ id: 'remove',
164
+ words: ['delete', 'remove'],
165
+ isA: ['verb'],
166
+ bridge: "{ ...next(operator), arg: after[0], operator: operator, interpolate: '${operator} ${arg}' }",
167
+ semantic: ({api, context}) => {
168
+ api.removeUser(api.contextToWho(context.arg))
144
169
  }
145
170
  },
146
171
  {
@@ -155,17 +180,30 @@ const template = {
155
180
  },
156
181
  {
157
182
  id: 'remindable',
183
+ isA: ['listable'],
158
184
  },
159
185
  {
160
186
  id: 'remind',
161
187
  isA: ['verb'],
162
188
  localHierarchy: [['self', 'remindable']],
163
189
  bridge: "{ ...next(operator), operator: operator, who: after[0], reminder: after[1], interpolate: '${operator} ${who} ${reminder}' }",
190
+ justWhoBridge: "{ ...next(operator), bridge: 'justWhoBridge', operator: operator, who: after[0], interpolate: '${operator} ${who}' }",
164
191
  withDateBridge: "{ ...next(operator), operator: operator, who: after[0], reminder: after[1], date: after[2], interpolate: '${operator} ${who} ${reminder} ${date}' }",
165
192
  withDateAndTimeBridge: "{ ...next(operator), operator: operator, who: after[0], reminder: after[1], date: after[2], time: after[3], interpolate: '${operator} ${who} ${reminder} ${date} ${time}' }",
193
+ semantics: [
194
+ {
195
+ match: ({context}) => context.marker == 'remind' && context.inAddition,
196
+ apply: ({context, api}) => {
197
+ api.addUser(api.contextToWho(context.who))
198
+ }
199
+ },
200
+ ],
166
201
  semantic: async ({api, gsp, gp, context}) => {
167
- const text = await gsp(context.reminder.slice(1));
168
202
  const who = api.contextToWho(context.who)
203
+ let text;
204
+ if (context.reminder) {
205
+ text = await gsp(context.reminder.slice(1));
206
+ }
169
207
  const reminder = { text, dateTimeSelector: context.date, who }
170
208
  if (context.date) {
171
209
  reminder.dateTimeSelector = context.date
@@ -216,11 +254,17 @@ const template = {
216
254
  },
217
255
 
218
256
  matchq: ({ api, context }) => api.askAbout().length > 0 && context.marker == 'controlEnd',
219
- applyq: ({ api, context }) => {
257
+ applyq: async ({ api, context, gs }) => {
220
258
  context.cascade = false
221
259
  const items = api.askAbout()
222
260
  const item = items[0]
223
- return 'When should I remind you to ' + item.text;
261
+ let who
262
+ if (item.who.id == 'me') {
263
+ who = 'you'
264
+ } else {
265
+ who = await gs(item.who.map((who) => who.text), ', ', ' and ')
266
+ }
267
+ return `When should I remind ${who} to ${item.text}`
224
268
  },
225
269
 
226
270
  matchr: ({ isA, api, context }) => {
@@ -250,7 +294,7 @@ knowledgeModule( {
250
294
  name: './reminders.test.json',
251
295
  contents: reminders_tests,
252
296
  checks: {
253
- context: defaultContextCheck(['who', 'reminder']),
297
+ context: defaultContextCheck(['who', 'reminder', 'verbatim']),
254
298
  objects: [
255
299
  {
256
300
  property: 'reminders',