tpmkms_4wp 9.3.0-beta.7 → 9.3.0-beta.9

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.
@@ -0,0 +1,48 @@
1
+ const pluralize = require('pluralize')
2
+ const deepEqual = require('deep-equal')
3
+ const { chooseNumber, zip } = require('../helpers.js')
4
+ const { compose, translationMapping, translationMappingToInstantiatorMappings } = require('./meta.js')
5
+
6
+ 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
+ const targetDayNum = dayMap[targetDay.toLowerCase()]
18
+ if (!targetDayNum) {
19
+ return
20
+ }
21
+ const currentDay = date.getDay();
22
+
23
+ let daysUntilNext = targetDayNum - currentDay;
24
+ if (daysUntilNext <= 0) {
25
+ daysUntilNext += 7; // If target day is today or past, get next week's occurrence
26
+ }
27
+
28
+ const nextDate = new Date(date);
29
+ nextDate.setDate(date.getDate() + daysUntilNext);
30
+ return nextDate;
31
+ }
32
+
33
+ instantiate = (now, context) => {
34
+ if (context.date) {
35
+ const date = getNextDayOfWeek(now, context.date?.date?.value)
36
+ if (date) {
37
+ return date.toISOString()
38
+ }
39
+ }
40
+ }
41
+
42
+ until = (time) => {
43
+ }
44
+
45
+ module.exports = {
46
+ instantiate,
47
+ until,
48
+ }
@@ -5,6 +5,7 @@ const reminders_instance = require('./reminders.instance.json')
5
5
  const selfKM = require('./self')
6
6
  const dates = require('./dates')
7
7
  const time = require('./time')
8
+ const reminders_helpers = require('./helpers/reminders')
8
9
  const helpers = require('./helpers')
9
10
 
10
11
  class API {
@@ -16,7 +17,24 @@ class API {
16
17
 
17
18
  add(reminder) {
18
19
  const id = ++this._objects.id
19
- this._objects.reminders.push({ ...reminder, id })
20
+ reminder.id = id
21
+ this._objects.reminders.push(reminder)
22
+ this.args.mentioned({ context: reminder })
23
+ }
24
+
25
+ instantiate(reminder) {
26
+ let now;
27
+ if (this.args.isProcess) {
28
+ // so the unit tests work consistently
29
+ now = new Date(2025, 6, 29, 14, 52, 0)
30
+ } else {
31
+ now = new Date()
32
+ }
33
+ reminder.nextISODate = reminders_helpers.instantiate(now, reminder)
34
+ }
35
+
36
+ // the user of the KM can override this. this can be used to sync the GUI and the LUI
37
+ getCurrent() {
20
38
  }
21
39
 
22
40
  askAbout() {
@@ -85,7 +103,9 @@ const template = {
85
103
  withDateAndTimeBridge: "{ ...next(operator), operator: operator, who: after[0], reminder: after[1], date: after[2], time: after[3], interpolate: '${operator} ${who} ${reminder} ${date} ${time}' }",
86
104
  semantic: async ({api, gsp, context}) => {
87
105
  const text = await gsp(context.reminder.slice(1));
88
- api.add({ text, date: context.date, time: context.time });
106
+ const reminder = { text, date: context.date, time: context.time }
107
+ api.instantiate(reminder)
108
+ api.add(reminder)
89
109
  },
90
110
  },
91
111
  {
@@ -179,7 +199,7 @@ knowledgeModule( {
179
199
  objects: [
180
200
  {
181
201
  property: 'reminders',
182
- filter: [ 'text', 'date', 'time' ],
202
+ filter: [ 'text', 'date', 'time', 'nextISODate', 'stm' ],
183
203
  }
184
204
  ],
185
205
  },
@@ -966,7 +966,12 @@
966
966
  "km": "reminders1",
967
967
  "reminders": [
968
968
  {
969
+ "fromSTM": true,
969
970
  "id": 1,
971
+ "pullFromContext": false,
972
+ "stm": {
973
+ "id": 1
974
+ },
970
975
  "text": "go to the store"
971
976
  }
972
977
  ]
@@ -980,6 +985,15 @@
980
985
  "stm2": {
981
986
  "km": "stm2",
982
987
  "mentioned": [
988
+ {
989
+ "fromSTM": true,
990
+ "id": 1,
991
+ "pullFromContext": false,
992
+ "stm": {
993
+ "id": 1
994
+ },
995
+ "text": "go to the store"
996
+ }
983
997
  ],
984
998
  "variables": {
985
999
  }
@@ -3509,7 +3523,12 @@
3509
3523
  "km": "reminders1",
3510
3524
  "reminders": [
3511
3525
  {
3526
+ "fromSTM": true,
3512
3527
  "id": 1,
3528
+ "pullFromContext": false,
3529
+ "stm": {
3530
+ "id": 1
3531
+ },
3513
3532
  "text": "go to the store"
3514
3533
  }
3515
3534
  ]
@@ -3523,6 +3542,15 @@
3523
3542
  "stm2": {
3524
3543
  "km": "stm2",
3525
3544
  "mentioned": [
3545
+ {
3546
+ "fromSTM": true,
3547
+ "id": 1,
3548
+ "pullFromContext": false,
3549
+ "stm": {
3550
+ "id": 1
3551
+ },
3552
+ "text": "go to the store"
3553
+ }
3526
3554
  ],
3527
3555
  "variables": {
3528
3556
  }
@@ -5307,7 +5335,12 @@
5307
5335
  "value": "monday_dates",
5308
5336
  "word": "monday"
5309
5337
  },
5338
+ "fromSTM": true,
5310
5339
  "id": 1,
5340
+ "pullFromContext": false,
5341
+ "stm": {
5342
+ "id": 1
5343
+ },
5311
5344
  "text": "go to regina"
5312
5345
  }
5313
5346
  ]
@@ -5321,6 +5354,34 @@
5321
5354
  "stm2": {
5322
5355
  "km": "stm2",
5323
5356
  "mentioned": [
5357
+ {
5358
+ "date": {
5359
+ "context_id": 2,
5360
+ "context_index": 1,
5361
+ "dead": true,
5362
+ "level": 1,
5363
+ "marker": "monday_dates",
5364
+ "number": "one",
5365
+ "range": {
5366
+ "end": 5,
5367
+ "start": 0
5368
+ },
5369
+ "text": "monday",
5370
+ "topLevel": true,
5371
+ "touchedBy": [
5372
+ "reminders#call2"
5373
+ ],
5374
+ "value": "monday_dates",
5375
+ "word": "monday"
5376
+ },
5377
+ "fromSTM": true,
5378
+ "id": 1,
5379
+ "pullFromContext": false,
5380
+ "stm": {
5381
+ "id": 1
5382
+ },
5383
+ "text": "go to regina"
5384
+ }
5324
5385
  ],
5325
5386
  "variables": {
5326
5387
  }
@@ -7528,7 +7589,13 @@
7528
7589
  ],
7529
7590
  "word": "on"
7530
7591
  },
7592
+ "fromSTM": true,
7531
7593
  "id": 1,
7594
+ "nextISODate": "2025-08-04T21:52:00.000Z",
7595
+ "pullFromContext": false,
7596
+ "stm": {
7597
+ "id": 1
7598
+ },
7532
7599
  "text": "go to the store"
7533
7600
  }
7534
7601
  ]
@@ -7542,6 +7609,59 @@
7542
7609
  "stm2": {
7543
7610
  "km": "stm2",
7544
7611
  "mentioned": [
7612
+ {
7613
+ "date": {
7614
+ "date": {
7615
+ "dead": true,
7616
+ "level": 1,
7617
+ "marker": "monday_dates",
7618
+ "number": "one",
7619
+ "range": {
7620
+ "end": 37,
7621
+ "start": 32
7622
+ },
7623
+ "text": "monday",
7624
+ "types": [
7625
+ "monday_dates"
7626
+ ],
7627
+ "value": "monday_dates",
7628
+ "word": "monday"
7629
+ },
7630
+ "dead": true,
7631
+ "default": true,
7632
+ "interpolate": "${onDate} ${date}",
7633
+ "level": 1,
7634
+ "marker": "onDate",
7635
+ "onDate": {
7636
+ "default": true,
7637
+ "level": 0,
7638
+ "marker": "onDate",
7639
+ "range": {
7640
+ "end": 30,
7641
+ "start": 29
7642
+ },
7643
+ "text": "on",
7644
+ "word": "on"
7645
+ },
7646
+ "range": {
7647
+ "end": 37,
7648
+ "start": 29
7649
+ },
7650
+ "text": "on monday",
7651
+ "types": [
7652
+ "onDate"
7653
+ ],
7654
+ "word": "on"
7655
+ },
7656
+ "fromSTM": true,
7657
+ "id": 1,
7658
+ "nextISODate": "2025-08-04T21:52:00.000Z",
7659
+ "pullFromContext": false,
7660
+ "stm": {
7661
+ "id": 1
7662
+ },
7663
+ "text": "go to the store"
7664
+ }
7545
7665
  ],
7546
7666
  "variables": {
7547
7667
  }
@@ -9773,7 +9893,6 @@
9773
9893
  "word": "remind"
9774
9894
  }
9775
9895
  ],
9776
- "developerTest": false,
9777
9896
  "generatedParenthesized": [
9778
9897
  ""
9779
9898
  ],
@@ -10787,7 +10906,13 @@
10787
10906
  ],
10788
10907
  "word": "on"
10789
10908
  },
10909
+ "fromSTM": true,
10790
10910
  "id": 1,
10911
+ "nextISODate": "2025-08-04T21:52:00.000Z",
10912
+ "pullFromContext": false,
10913
+ "stm": {
10914
+ "id": 1
10915
+ },
10791
10916
  "text": "go to regina",
10792
10917
  "time": {
10793
10918
  "dead": true,
@@ -10874,6 +10999,132 @@
10874
10999
  "stm2": {
10875
11000
  "km": "stm2",
10876
11001
  "mentioned": [
11002
+ {
11003
+ "date": {
11004
+ "date": {
11005
+ "dead": true,
11006
+ "level": 1,
11007
+ "marker": "monday_dates",
11008
+ "number": "one",
11009
+ "range": {
11010
+ "end": 34,
11011
+ "start": 29
11012
+ },
11013
+ "text": "monday",
11014
+ "types": [
11015
+ "monday_dates"
11016
+ ],
11017
+ "value": "monday_dates",
11018
+ "word": "monday"
11019
+ },
11020
+ "dead": true,
11021
+ "default": true,
11022
+ "interpolate": "${onDate} ${date}",
11023
+ "level": 1,
11024
+ "marker": "onDate",
11025
+ "onDate": {
11026
+ "default": true,
11027
+ "level": 0,
11028
+ "marker": "onDate",
11029
+ "range": {
11030
+ "end": 27,
11031
+ "start": 26
11032
+ },
11033
+ "text": "on",
11034
+ "word": "on"
11035
+ },
11036
+ "range": {
11037
+ "end": 34,
11038
+ "start": 26
11039
+ },
11040
+ "text": "on monday",
11041
+ "types": [
11042
+ "onDate"
11043
+ ],
11044
+ "word": "on"
11045
+ },
11046
+ "fromSTM": true,
11047
+ "id": 1,
11048
+ "nextISODate": "2025-08-04T21:52:00.000Z",
11049
+ "pullFromContext": false,
11050
+ "stm": {
11051
+ "id": 1
11052
+ },
11053
+ "text": "go to regina",
11054
+ "time": {
11055
+ "dead": true,
11056
+ "default": true,
11057
+ "interpolate": "${operator} ${time}",
11058
+ "level": 1,
11059
+ "marker": "atTime",
11060
+ "operator": {
11061
+ "default": true,
11062
+ "level": 0,
11063
+ "marker": "atTime",
11064
+ "range": {
11065
+ "end": 37,
11066
+ "start": 36
11067
+ },
11068
+ "text": "at",
11069
+ "word": "at"
11070
+ },
11071
+ "range": {
11072
+ "end": 43,
11073
+ "start": 36
11074
+ },
11075
+ "text": "at 10 am",
11076
+ "time": {
11077
+ "ampm": {
11078
+ "ampm": "am",
11079
+ "determined": true,
11080
+ "level": 0,
11081
+ "marker": "ampm",
11082
+ "range": {
11083
+ "end": 43,
11084
+ "start": 42
11085
+ },
11086
+ "text": "am",
11087
+ "word": "am"
11088
+ },
11089
+ "dead": true,
11090
+ "instance": true,
11091
+ "interpolate": "${time} ${ampm}",
11092
+ "level": 0,
11093
+ "marker": "time",
11094
+ "range": {
11095
+ "end": 43,
11096
+ "start": 39
11097
+ },
11098
+ "text": "10 am",
11099
+ "time": {
11100
+ "dead": true,
11101
+ "instance": true,
11102
+ "level": 1,
11103
+ "marker": "integer",
11104
+ "range": {
11105
+ "end": 40,
11106
+ "start": 39
11107
+ },
11108
+ "text": "10",
11109
+ "types": [
11110
+ "integer",
11111
+ "time"
11112
+ ],
11113
+ "value": 10,
11114
+ "word": "10"
11115
+ },
11116
+ "types": [
11117
+ "time"
11118
+ ],
11119
+ "value": 10,
11120
+ "word": "10"
11121
+ },
11122
+ "types": [
11123
+ "atTime"
11124
+ ],
11125
+ "word": "at"
11126
+ }
11127
+ }
10877
11128
  ],
10878
11129
  "variables": {
10879
11130
  }
package/common/time.js CHANGED
@@ -201,19 +201,6 @@ const initializer = ({api, config, objects, kms, isModule}) => {
201
201
  })
202
202
  }
203
203
 
204
- console.log('greg23 ssssssssssssss')
205
- console.log(JSON.stringify(defaultContextCheck([
206
- //{ 'event': { , 'target', 'one', 'two']
207
- {
208
- event: {
209
- one: 'defaults',
210
- two: 'defaults',
211
- info: 'defaults',
212
- target: 'defaults'
213
- }
214
- },
215
- ]), null, 2))
216
-
217
204
  knowledgeModule({
218
205
  config,
219
206
  includes: [tell, numbers, countable],
package/package.json CHANGED
@@ -216,7 +216,7 @@
216
216
  "common/helpers/meta.js",
217
217
  "common/helpers/ordering.js",
218
218
  "common/helpers/properties.js",
219
- "common/helpers/properties.js",
219
+ "common/helpers/reminders.js",
220
220
  "common/hierarchy.js",
221
221
  "common/hierarchy.test.json",
222
222
  "common/javascript.js",
@@ -337,8 +337,8 @@
337
337
  "scriptjs": "^2.5.9",
338
338
  "table": "^6.7.1",
339
339
  "uuid": "^9.0.0",
340
- "theprogrammablemind_4wp": "9.3.0-beta.7"
340
+ "theprogrammablemind_4wp": "9.3.0-beta.9"
341
341
  },
342
- "version": "9.3.0-beta.7",
342
+ "version": "9.3.0-beta.9",
343
343
  "license": "UNLICENSED"
344
344
  }