@noteplanco/noteplan-mcp 1.1.1
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/README.md +257 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -0
- package/dist/noteplan/embeddings.d.ts +170 -0
- package/dist/noteplan/embeddings.d.ts.map +1 -0
- package/dist/noteplan/embeddings.js +684 -0
- package/dist/noteplan/embeddings.js.map +1 -0
- package/dist/noteplan/file-reader.d.ts +77 -0
- package/dist/noteplan/file-reader.d.ts.map +1 -0
- package/dist/noteplan/file-reader.js +488 -0
- package/dist/noteplan/file-reader.js.map +1 -0
- package/dist/noteplan/file-writer.d.ts +108 -0
- package/dist/noteplan/file-writer.d.ts.map +1 -0
- package/dist/noteplan/file-writer.js +621 -0
- package/dist/noteplan/file-writer.js.map +1 -0
- package/dist/noteplan/filter-store.d.ts +28 -0
- package/dist/noteplan/filter-store.d.ts.map +1 -0
- package/dist/noteplan/filter-store.js +180 -0
- package/dist/noteplan/filter-store.js.map +1 -0
- package/dist/noteplan/frontmatter-parser.d.ts +45 -0
- package/dist/noteplan/frontmatter-parser.d.ts.map +1 -0
- package/dist/noteplan/frontmatter-parser.js +259 -0
- package/dist/noteplan/frontmatter-parser.js.map +1 -0
- package/dist/noteplan/fuzzy-search.d.ts +7 -0
- package/dist/noteplan/fuzzy-search.d.ts.map +1 -0
- package/dist/noteplan/fuzzy-search.js +66 -0
- package/dist/noteplan/fuzzy-search.js.map +1 -0
- package/dist/noteplan/markdown-parser.d.ts +87 -0
- package/dist/noteplan/markdown-parser.d.ts.map +1 -0
- package/dist/noteplan/markdown-parser.js +519 -0
- package/dist/noteplan/markdown-parser.js.map +1 -0
- package/dist/noteplan/preferences.d.ts +44 -0
- package/dist/noteplan/preferences.d.ts.map +1 -0
- package/dist/noteplan/preferences.js +156 -0
- package/dist/noteplan/preferences.js.map +1 -0
- package/dist/noteplan/ripgrep-search.d.ts +29 -0
- package/dist/noteplan/ripgrep-search.d.ts.map +1 -0
- package/dist/noteplan/ripgrep-search.js +110 -0
- package/dist/noteplan/ripgrep-search.js.map +1 -0
- package/dist/noteplan/sqlite-reader.d.ts +77 -0
- package/dist/noteplan/sqlite-reader.d.ts.map +1 -0
- package/dist/noteplan/sqlite-reader.js +605 -0
- package/dist/noteplan/sqlite-reader.js.map +1 -0
- package/dist/noteplan/sqlite-writer.d.ts +63 -0
- package/dist/noteplan/sqlite-writer.d.ts.map +1 -0
- package/dist/noteplan/sqlite-writer.js +574 -0
- package/dist/noteplan/sqlite-writer.js.map +1 -0
- package/dist/noteplan/types.d.ts +97 -0
- package/dist/noteplan/types.d.ts.map +1 -0
- package/dist/noteplan/types.js +33 -0
- package/dist/noteplan/types.js.map +1 -0
- package/dist/noteplan/unified-store.d.ts +289 -0
- package/dist/noteplan/unified-store.d.ts.map +1 -0
- package/dist/noteplan/unified-store.js +1308 -0
- package/dist/noteplan/unified-store.js.map +1 -0
- package/dist/server.d.ts +4 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +2468 -0
- package/dist/server.js.map +1 -0
- package/dist/tools/calendar.d.ts +311 -0
- package/dist/tools/calendar.d.ts.map +1 -0
- package/dist/tools/calendar.js +504 -0
- package/dist/tools/calendar.js.map +1 -0
- package/dist/tools/embeddings.d.ts +244 -0
- package/dist/tools/embeddings.d.ts.map +1 -0
- package/dist/tools/embeddings.js +226 -0
- package/dist/tools/embeddings.js.map +1 -0
- package/dist/tools/events.d.ts +176 -0
- package/dist/tools/events.d.ts.map +1 -0
- package/dist/tools/events.js +326 -0
- package/dist/tools/events.js.map +1 -0
- package/dist/tools/filters.d.ts +205 -0
- package/dist/tools/filters.d.ts.map +1 -0
- package/dist/tools/filters.js +347 -0
- package/dist/tools/filters.js.map +1 -0
- package/dist/tools/memory.d.ts +6 -0
- package/dist/tools/memory.d.ts.map +1 -0
- package/dist/tools/memory.js +161 -0
- package/dist/tools/memory.js.map +1 -0
- package/dist/tools/notes.d.ts +1221 -0
- package/dist/tools/notes.d.ts.map +1 -0
- package/dist/tools/notes.js +1868 -0
- package/dist/tools/notes.js.map +1 -0
- package/dist/tools/plugins.d.ts +140 -0
- package/dist/tools/plugins.d.ts.map +1 -0
- package/dist/tools/plugins.js +782 -0
- package/dist/tools/plugins.js.map +1 -0
- package/dist/tools/reminders.d.ts +207 -0
- package/dist/tools/reminders.d.ts.map +1 -0
- package/dist/tools/reminders.js +323 -0
- package/dist/tools/reminders.js.map +1 -0
- package/dist/tools/search.d.ts +58 -0
- package/dist/tools/search.d.ts.map +1 -0
- package/dist/tools/search.js +373 -0
- package/dist/tools/search.js.map +1 -0
- package/dist/tools/spaces.d.ts +484 -0
- package/dist/tools/spaces.d.ts.map +1 -0
- package/dist/tools/spaces.js +870 -0
- package/dist/tools/spaces.js.map +1 -0
- package/dist/tools/tasks.d.ts +313 -0
- package/dist/tools/tasks.d.ts.map +1 -0
- package/dist/tools/tasks.js +690 -0
- package/dist/tools/tasks.js.map +1 -0
- package/dist/tools/themes.d.ts +91 -0
- package/dist/tools/themes.d.ts.map +1 -0
- package/dist/tools/themes.js +294 -0
- package/dist/tools/themes.js.map +1 -0
- package/dist/tools/ui.d.ts +89 -0
- package/dist/tools/ui.d.ts.map +1 -0
- package/dist/tools/ui.js +137 -0
- package/dist/tools/ui.js.map +1 -0
- package/dist/utils/applescript.d.ts +5 -0
- package/dist/utils/applescript.d.ts.map +1 -0
- package/dist/utils/applescript.js +27 -0
- package/dist/utils/applescript.js.map +1 -0
- package/dist/utils/confirmation-tokens.d.ts +19 -0
- package/dist/utils/confirmation-tokens.d.ts.map +1 -0
- package/dist/utils/confirmation-tokens.js +58 -0
- package/dist/utils/confirmation-tokens.js.map +1 -0
- package/dist/utils/date-filters.d.ts +15 -0
- package/dist/utils/date-filters.d.ts.map +1 -0
- package/dist/utils/date-filters.js +129 -0
- package/dist/utils/date-filters.js.map +1 -0
- package/dist/utils/date-utils.d.ts +113 -0
- package/dist/utils/date-utils.d.ts.map +1 -0
- package/dist/utils/date-utils.js +341 -0
- package/dist/utils/date-utils.js.map +1 -0
- package/dist/utils/folder-matcher.d.ts +14 -0
- package/dist/utils/folder-matcher.d.ts.map +1 -0
- package/dist/utils/folder-matcher.js +191 -0
- package/dist/utils/folder-matcher.js.map +1 -0
- package/dist/utils/version.d.ts +10 -0
- package/dist/utils/version.d.ts.map +1 -0
- package/dist/utils/version.js +88 -0
- package/dist/utils/version.js.map +1 -0
- package/docs/plugin-api/Calendar.md +448 -0
- package/docs/plugin-api/CalendarItem.md +198 -0
- package/docs/plugin-api/Clipboard.md +101 -0
- package/docs/plugin-api/CommandBar.md +251 -0
- package/docs/plugin-api/DataStore.md +700 -0
- package/docs/plugin-api/Editor.md +982 -0
- package/docs/plugin-api/HTMLView.md +337 -0
- package/docs/plugin-api/NoteObject.md +588 -0
- package/docs/plugin-api/NotePlan.md +398 -0
- package/docs/plugin-api/ParagraphObject.md +242 -0
- package/docs/plugin-api/RangeObject.md +56 -0
- package/docs/plugin-api/getting-started.md +545 -0
- package/docs/plugin-api/plugin-api-condensed.md +526 -0
- package/docs/plugin-api/plugin.json +26 -0
- package/docs/plugin-api/script.js +542 -0
- package/package.json +60 -0
- package/scripts/calendar-helper +0 -0
- package/scripts/reminders-helper +0 -0
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
// Version detection and feature gating for NotePlan MCP server
|
|
2
|
+
import { execFileSync } from 'child_process';
|
|
3
|
+
import * as fs from 'fs';
|
|
4
|
+
import * as path from 'path';
|
|
5
|
+
// Placeholder — set to the first build that ships themes/plugins/ui/space-writes
|
|
6
|
+
export const MIN_BUILD_ADVANCED_FEATURES = 1300;
|
|
7
|
+
const CACHE_TTL_MS = 60_000;
|
|
8
|
+
let cachedVersion = null;
|
|
9
|
+
let cachedAt = 0;
|
|
10
|
+
function detectViaAppleScript() {
|
|
11
|
+
try {
|
|
12
|
+
// Check if NotePlan is running first to avoid launching it as a side effect
|
|
13
|
+
const isRunning = execFileSync('osascript', ['-e', 'application "NotePlan" is running'], {
|
|
14
|
+
encoding: 'utf-8',
|
|
15
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
16
|
+
timeout: 3_000,
|
|
17
|
+
}).trim();
|
|
18
|
+
if (isRunning !== 'true')
|
|
19
|
+
return null;
|
|
20
|
+
const raw = execFileSync('osascript', ['-e', 'tell application "NotePlan" to getVersion'], {
|
|
21
|
+
encoding: 'utf-8',
|
|
22
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
23
|
+
timeout: 5_000,
|
|
24
|
+
}).trim();
|
|
25
|
+
const parsed = JSON.parse(raw);
|
|
26
|
+
if (typeof parsed.version === 'string' && typeof parsed.build === 'number') {
|
|
27
|
+
return { version: parsed.version, build: parsed.build, source: 'applescript' };
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
catch {
|
|
31
|
+
// App not running or command not available
|
|
32
|
+
}
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
const KNOWN_APP_PATHS = [
|
|
36
|
+
'/Applications/NotePlan 3.app',
|
|
37
|
+
'/Applications/NotePlan.app',
|
|
38
|
+
path.join(process.env.HOME ?? '', 'Applications/NotePlan 3.app'),
|
|
39
|
+
path.join(process.env.HOME ?? '', 'Applications/NotePlan.app'),
|
|
40
|
+
// Setapp
|
|
41
|
+
'/Applications/Setapp/NotePlan 3.app',
|
|
42
|
+
'/Applications/Setapp/NotePlan.app',
|
|
43
|
+
];
|
|
44
|
+
function detectViaPlist() {
|
|
45
|
+
for (const appPath of KNOWN_APP_PATHS) {
|
|
46
|
+
const plistPath = path.join(appPath, 'Contents/Info.plist');
|
|
47
|
+
if (!fs.existsSync(plistPath))
|
|
48
|
+
continue;
|
|
49
|
+
try {
|
|
50
|
+
const version = execFileSync('defaults', ['read', path.join(appPath, 'Contents/Info'), 'CFBundleShortVersionString'], {
|
|
51
|
+
encoding: 'utf-8',
|
|
52
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
53
|
+
timeout: 3_000,
|
|
54
|
+
}).trim();
|
|
55
|
+
const buildStr = execFileSync('defaults', ['read', path.join(appPath, 'Contents/Info'), 'CFBundleVersion'], {
|
|
56
|
+
encoding: 'utf-8',
|
|
57
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
58
|
+
timeout: 3_000,
|
|
59
|
+
}).trim();
|
|
60
|
+
const build = parseInt(buildStr, 10) || 0;
|
|
61
|
+
if (version) {
|
|
62
|
+
return { version, build, source: 'plist' };
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
catch {
|
|
66
|
+
// plist read failed for this path, try next
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
71
|
+
export function getNotePlanVersion(forceRefresh = false) {
|
|
72
|
+
const now = Date.now();
|
|
73
|
+
if (!forceRefresh && cachedVersion && (now - cachedAt) < CACHE_TTL_MS) {
|
|
74
|
+
return cachedVersion;
|
|
75
|
+
}
|
|
76
|
+
const version = detectViaAppleScript() ?? detectViaPlist() ?? { version: '0.0.0', build: 0, source: 'unknown' };
|
|
77
|
+
cachedVersion = version;
|
|
78
|
+
cachedAt = now;
|
|
79
|
+
return version;
|
|
80
|
+
}
|
|
81
|
+
export function isAdvancedFeaturesAvailable(forceRefresh = false) {
|
|
82
|
+
const { build } = getNotePlanVersion(forceRefresh);
|
|
83
|
+
return build >= MIN_BUILD_ADVANCED_FEATURES;
|
|
84
|
+
}
|
|
85
|
+
export function upgradeMessage(feature) {
|
|
86
|
+
return `"${feature}" requires a newer version of NotePlan (build ${MIN_BUILD_ADVANCED_FEATURES}+). Please update NotePlan to use this feature.`;
|
|
87
|
+
}
|
|
88
|
+
//# sourceMappingURL=version.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/utils/version.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAE/D,OAAO,EAAE,YAAY,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E,CAAC;gBACZ,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC;YAC7C,CAAC;QACH,CAAC;QAAC,MAAM,CAAC;YACP,4CAA4C;QAC9C,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,YAAY,GAAG,KAAK;IACrD,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IACvB,IAAI,CAAC,YAAY,IAAI,aAAa,IAAI,CAAC,GAAG,GAAG,QAAQ,CAAC,GAAG,YAAY,EAAE,CAAC;QACtE,OAAO,aAAa,CAAC;IACvB,CAAC;IAED,MAAM,OAAO,GAAG,oBAAoB,EAAE,IAAI,cAAc,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,SAAkB,EAAE,CAAC;IACzH,aAAa,GAAG,OAAO,CAAC;IACxB,QAAQ,GAAG,GAAG,CAAC;IACf,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,MAAM,UAAU,2BAA2B,CAAC,YAAY,GAAG,KAAK;IAC9D,MAAM,EAAE,KAAK,EAAE,GAAG,kBAAkB,CAAC,YAAY,CAAC,CAAC;IACnD,OAAO,KAAK,IAAI,2BAA2B,CAAC;AAC9C,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,OAAe;IAC5C,OAAO,IAAI,OAAO,iDAAiD,2BAA2B,iDAAiD,CAAC;AAClJ,CAAC"}
|
|
@@ -0,0 +1,448 @@
|
|
|
1
|
+
<details>
|
|
2
|
+
<summary>API</summary>
|
|
3
|
+
<p>
|
|
4
|
+
|
|
5
|
+
```javascript
|
|
6
|
+
Calendar
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Get all available date units: "year", "month", "day", "hour", "minute", "second"
|
|
10
|
+
* @type {[String]}
|
|
11
|
+
*/
|
|
12
|
+
.dateUnits
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Adds an event or reminder based on the given CalendarItem. Use `CalendarItem.create(...)` to create the event or reminder first.
|
|
16
|
+
* Returns the created CalendarItem with the assigned id, so you can reference it later. If it failed, undefined is returned.
|
|
17
|
+
* @param {CalendarItem}
|
|
18
|
+
* @return {CalendarItem}
|
|
19
|
+
*/
|
|
20
|
+
.add(calendarItem)
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Note: Available from v3.0.26
|
|
24
|
+
* Updates an event or reminder based on the given CalendarItem, which needs to have an ID. A CalendarItem has an ID, when you have used `.add(...)` and saved the return value or when you query the event using `eventsBetween(...)`, `remindersBetween(...)`, `eventByID(...)`, `reminderByID(...)`, etc.
|
|
25
|
+
* Returns a promise, because it needs to fetch the original event objects first in the background, then updates it. Use it with `await`.
|
|
26
|
+
* @param {CalendarItem}
|
|
27
|
+
* @return {Promise}
|
|
28
|
+
*/
|
|
29
|
+
.update(calendarItem)
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Note: Available from v3.0.26
|
|
33
|
+
* Removes an event or reminder based on the given CalendarItem, which needs to have an ID. A CalendarItem has an ID, when you have used `.add(...)` and saved the return value or when you query the event using `eventsBetween(...)`, `remindersBetween(...)`, `eventByID(...)`, `reminderByID(...)`, etc.
|
|
34
|
+
* Returns a promise, because it needs to fetch the original event objects first in the background, then updates it. Use it with `await`.
|
|
35
|
+
* @param {CalendarItem}
|
|
36
|
+
* @return {Promise}
|
|
37
|
+
*/
|
|
38
|
+
.remove(calendarItem)
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Note: Available from v3.0.25
|
|
42
|
+
* Returns all events between the `startDate` and `endDate`. Use `filter` to search for specific events (keyword in the title).
|
|
43
|
+
* This function fetches events asynchronously, so use async/await.
|
|
44
|
+
* @param {Date}
|
|
45
|
+
* @param {Date}
|
|
46
|
+
* @param {String?}
|
|
47
|
+
* @return {Promise([CalendarItem])}
|
|
48
|
+
*/
|
|
49
|
+
.eventsBetween(startDate, endDate, filter)
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Note: Available from v3.0.25
|
|
53
|
+
* Returns all reminders between the `startDate` and `endDate`. Use `filter` to search for specific reminders (keyword in the title).
|
|
54
|
+
* This function fetches reminders asynchronously, so use async/await.
|
|
55
|
+
* @param {Date}
|
|
56
|
+
* @param {Date}
|
|
57
|
+
* @param {String?}
|
|
58
|
+
* @return {Promise([CalendarItem])}
|
|
59
|
+
*/
|
|
60
|
+
.remindersBetween(startDate, endDate, filter)
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Note: Available from v3.0.26
|
|
64
|
+
* Returns the event by the given ID. You can get the ID from a CalendarItem, which you got from using `.add(...)` (the return value is a CalendarItem with ID) or when you query the event using `eventsBetween(...)`, `eventByID(...)`, etc.
|
|
65
|
+
* This function fetches the event asynchronously, so use async/await.
|
|
66
|
+
* @param {String}
|
|
67
|
+
* @return {Promise(CalendarItem)}
|
|
68
|
+
*/
|
|
69
|
+
.eventByID(id)
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Note: Available from v3.0.26
|
|
73
|
+
* Returns the reminder by the given ID. You can get the ID from a CalendarItem, which you got from using `.add(...)` (the return value is a CalendarItem with ID) or when you query the event using `remindersBetween(...)`, `reminderByID(...)`, etc.
|
|
74
|
+
* This function fetches reminders asynchronously, so use async/await.
|
|
75
|
+
* @param {String}
|
|
76
|
+
* @return {Promise(CalendarItem)}
|
|
77
|
+
*/
|
|
78
|
+
.reminderByID(id)
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Note: Available from v3.0.25
|
|
82
|
+
* Returns all events for today. Use `filter` to search for specific events (keyword in the title).
|
|
83
|
+
* This function fetches events asynchronously, so use async/await. The returned promise contains an array of events.
|
|
84
|
+
* @param {String?}
|
|
85
|
+
* @return {Promise}
|
|
86
|
+
*/
|
|
87
|
+
.eventsToday(filter)
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Note: Available from v3.0.25
|
|
91
|
+
* Returns all reminders between for today. Use `filter` to search for specific reminders (keyword in the title).
|
|
92
|
+
* This function fetches reminders asynchronously, so use async/await.
|
|
93
|
+
* @param {String?}
|
|
94
|
+
* @return {Promise}
|
|
95
|
+
*/
|
|
96
|
+
.remindersToday(filter)
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Note: Available from v3.5.2
|
|
100
|
+
* Returns all reminders (completed and incompleted) for the given lists (array of strings).
|
|
101
|
+
* If you keep the lists variable empty, NotePlan will return all reminders from all lists. You can get all Reminders lists calling `Calendar.availableReminderListTitles()`
|
|
102
|
+
* This function fetches reminders asynchronously, so use async/await.
|
|
103
|
+
* @param {[String]?}
|
|
104
|
+
* @return {Promise}
|
|
105
|
+
*/
|
|
106
|
+
.remindersByLists(lists)
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Parses a text describing a text as natural language input into a date. Such as "today", "next week", "1st May", "at 5pm to 6pm", etc.
|
|
110
|
+
* Returns and array of objects with possible results (usually one), the most likely at the top.
|
|
111
|
+
* Access the dates in this array using ".start" and ".end". And access information of the matched date text using ".text" and ".index". You can see the full info by looking up "DateRangeObject" further below.
|
|
112
|
+
* @param {String}
|
|
113
|
+
* @return {[DateRangeObject]}
|
|
114
|
+
*/
|
|
115
|
+
.parseDateText(text)
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Create a date object from parts. Like year could be 2021 as a number.
|
|
119
|
+
* The month parameter starts with 1 = January, 2 = February...
|
|
120
|
+
* @param {Int}
|
|
121
|
+
* @param {Int}
|
|
122
|
+
* @param {Int}
|
|
123
|
+
* @param {Int}
|
|
124
|
+
* @param {Int}
|
|
125
|
+
* @param {Int}
|
|
126
|
+
* @return {Date}
|
|
127
|
+
*/
|
|
128
|
+
.dateFrom(year, month, day, hour, minute, second)
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Add a unit to an existing date. Look up all unit types using `dateUnits`.
|
|
132
|
+
* For example, to add 10 days, use num = 10 and type = "day"
|
|
133
|
+
* @param {Date}
|
|
134
|
+
* @param {String}
|
|
135
|
+
* @param {Int}
|
|
136
|
+
* @return {Date}
|
|
137
|
+
*/
|
|
138
|
+
.addUnitToDate(date, type, num)
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Returns the integer of a unit like "year" (should be this year's number). Look up all unit types using `dateUnits`.
|
|
142
|
+
* @param {Date}
|
|
143
|
+
* @param {String}
|
|
144
|
+
* @return {Int}
|
|
145
|
+
*/
|
|
146
|
+
.unitOf(date, type)
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Returns a description of how much time has past between the date and today = now.
|
|
150
|
+
* @param {Date}
|
|
151
|
+
* @return {String}
|
|
152
|
+
*/
|
|
153
|
+
.timeAgoSinceNow(date)
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Returns the amount of units between the given date and now. Look up all unit types using `dateUnits`.
|
|
157
|
+
* @param {Date}
|
|
158
|
+
* @param {String}
|
|
159
|
+
* @return {Int}
|
|
160
|
+
*/
|
|
161
|
+
.unitsUntilNow(date, type)
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* Returns the amount of units from now and the given date. Look up all unit types using `dateUnits`.
|
|
165
|
+
* @param {Date}
|
|
166
|
+
* @param {String}
|
|
167
|
+
* @return {Int}
|
|
168
|
+
*/
|
|
169
|
+
.unitsAgoFromNow(date, type)
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Returns the amount of units between the first and second date. Look up all unit types using `dateUnits`.
|
|
173
|
+
* @param {Date}
|
|
174
|
+
* @param {Date}
|
|
175
|
+
* @param {String}
|
|
176
|
+
* @return {Int}
|
|
177
|
+
*/
|
|
178
|
+
.unitsBetween(date1, date2, type)
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* Returns the week number of the given date adjusted by the start of the week configured by the user in the preferences.
|
|
182
|
+
* @param {Date}
|
|
183
|
+
* @return {Int}
|
|
184
|
+
*/
|
|
185
|
+
.weekNumber(date)
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* Note: Available from v3.7
|
|
189
|
+
* Returns the year number of the given date adjusted by the start of the week configured by the user in the preferences.
|
|
190
|
+
* @param {Date}
|
|
191
|
+
* @return {Int}
|
|
192
|
+
*/
|
|
193
|
+
.weekYear(date)
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* Note: Available from v3.7
|
|
197
|
+
* Returns the first day of the given date's week adjusted by the start of the week configured by the user in the preferences (means the returned date will always be the configured first day of the week).
|
|
198
|
+
* @param {Date}
|
|
199
|
+
* @return {Date}
|
|
200
|
+
*/
|
|
201
|
+
.startOfWeek(date)
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* Note: Available from v3.7
|
|
205
|
+
* Returns the last day of the given date's week adjusted by the start of the week configured by the user in the preferences (means the returned endOfWeek date will always be the day before the first day of the week specified in Preferences).
|
|
206
|
+
* @param {Date}
|
|
207
|
+
* @return {Date}
|
|
208
|
+
*/
|
|
209
|
+
.endOfWeek(date)
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* Note: Available from v3.1
|
|
213
|
+
* Get the titles of all calendars the user has access to.
|
|
214
|
+
*
|
|
215
|
+
* @param {Boolean} [writeOnly=false] - If true, returns only calendars the user has write access to (some calendars, like holidays, are not writable). If false or omitted, returns all calendars (writable and read-only).
|
|
216
|
+
* @param {Boolean} [enabledOnly=false] - If true, returns only calendars that are enabled in NotePlan's settings. If false or omitted, returns all calendars the user has access to (including disabled ones).
|
|
217
|
+
* @return {[String]} Array of calendar titles
|
|
218
|
+
*
|
|
219
|
+
* @example
|
|
220
|
+
* // Get all calendars (writable and read-only, including disabled)
|
|
221
|
+
* Calendar.availableCalendarTitles()
|
|
222
|
+
*
|
|
223
|
+
* @example
|
|
224
|
+
* // Get only writable calendars (including disabled)
|
|
225
|
+
* Calendar.availableCalendarTitles(true)
|
|
226
|
+
*
|
|
227
|
+
* @example
|
|
228
|
+
* // Get all calendars, but only enabled ones
|
|
229
|
+
* Calendar.availableCalendarTitles(false, true)
|
|
230
|
+
*
|
|
231
|
+
* @example
|
|
232
|
+
* // Get only writable AND enabled calendars
|
|
233
|
+
* Calendar.availableCalendarTitles(true, true)
|
|
234
|
+
*/
|
|
235
|
+
.availableCalendarTitles(writeOnly, enabledOnly)
|
|
236
|
+
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* Note: Available from v3.1
|
|
240
|
+
* Get the titles of all reminders the user has access to.
|
|
241
|
+
* @return {[String]}
|
|
242
|
+
*/
|
|
243
|
+
.availableReminderListTitles()
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* Note: Available from v3.20
|
|
247
|
+
* Get all calendars the user has access to, returning full calendar objects with detailed information (title, color, source, etc.) instead of just titles.
|
|
248
|
+
*
|
|
249
|
+
* @param {Object} [options] - Optional filter options
|
|
250
|
+
* @param {Boolean} [options.writeOnly=false] - If true, returns only calendars the user has write access to (some calendars, like holidays, are not writable). If false or omitted, returns all calendars (writable and read-only).
|
|
251
|
+
* @param {Boolean} [options.enabledOnly=false] - If true, returns only calendars that are enabled in NotePlan's settings. If false or omitted, returns all calendars the user has access to (including disabled ones). Also accepts `filterEnabled` as an alias.
|
|
252
|
+
* @return {[Object]} Array of calendar objects, each containing:
|
|
253
|
+
* - {String} title - Calendar title
|
|
254
|
+
* - {String} id - Calendar identifier
|
|
255
|
+
* - {String} color - Calendar color as hex string (e.g., "#5A9FD4")
|
|
256
|
+
* - {String} source - Source title (e.g., "iCloud", "Google")
|
|
257
|
+
* - {String} sourceType - Source type (e.g., "calDAV", "local", "exchange", "subscribed", "birthdays")
|
|
258
|
+
* - {Boolean} isWritable - Whether calendar allows content modifications
|
|
259
|
+
* - {Boolean} isEnabled - Whether calendar is enabled (not blacklisted) in NotePlan's settings
|
|
260
|
+
* - {[String]} allowedEntityTypes - Entity types supported by this calendar (e.g., ["event"], ["reminder"], or ["event", "reminder"])
|
|
261
|
+
*
|
|
262
|
+
* @example
|
|
263
|
+
* // Get all calendars (writable and read-only, including disabled)
|
|
264
|
+
* const calendars = Calendar.availableCalendars()
|
|
265
|
+
*
|
|
266
|
+
* @example
|
|
267
|
+
* // Get only writable calendars (including disabled)
|
|
268
|
+
* const calendars = Calendar.availableCalendars({ writeOnly: true })
|
|
269
|
+
*
|
|
270
|
+
* @example
|
|
271
|
+
* // Get all calendars, but only enabled ones
|
|
272
|
+
* const calendars = Calendar.availableCalendars({ enabledOnly: true })
|
|
273
|
+
*
|
|
274
|
+
* @example
|
|
275
|
+
* // Get only writable AND enabled calendars
|
|
276
|
+
* const calendars = Calendar.availableCalendars({ writeOnly: true, enabledOnly: true })
|
|
277
|
+
*
|
|
278
|
+
* @example
|
|
279
|
+
* // Access calendar properties
|
|
280
|
+
* const calendars = Calendar.availableCalendars()
|
|
281
|
+
* calendars.forEach(cal => {
|
|
282
|
+
* console.log(`${cal.title} (${cal.source}) - Color: ${cal.color}, Writable: ${cal.isWritable}, Enabled: ${cal.isEnabled}`)
|
|
283
|
+
* })
|
|
284
|
+
*/
|
|
285
|
+
.availableCalendars(options)
|
|
286
|
+
|
|
287
|
+
/**
|
|
288
|
+
* Note: Available from v3.20
|
|
289
|
+
* Get all reminder lists the user has access to, returning full reminder list objects with detailed information (title, color, source, etc.) instead of just titles.
|
|
290
|
+
*
|
|
291
|
+
* @param {Object} [options] - Optional filter options
|
|
292
|
+
* @param {Boolean} [options.enabledOnly=false] - If true, returns only reminder lists that are enabled in NotePlan's settings. If false or omitted, returns all reminder lists the user has access to (including disabled ones). Also accepts `filterEnabled` as an alias.
|
|
293
|
+
* @return {[Object]} Array of reminder list objects, each containing:
|
|
294
|
+
* - {String} title - Reminder list title
|
|
295
|
+
* - {String} id - Reminder list identifier
|
|
296
|
+
* - {String} color - Reminder list color as hex string (e.g., "#5A9FD4")
|
|
297
|
+
* - {String} source - Source title (e.g., "iCloud", "Google")
|
|
298
|
+
* - {String} sourceType - Source type (e.g., "calDAV", "local", "exchange", "subscribed")
|
|
299
|
+
* - {Boolean} isWritable - Whether reminder list allows content modifications (typically true for reminder lists)
|
|
300
|
+
* - {Boolean} isEnabled - Whether reminder list is enabled (not blacklisted) in NotePlan's settings
|
|
301
|
+
* - {[String]} allowedEntityTypes - Entity types supported by this reminder list (typically ["reminder"])
|
|
302
|
+
*
|
|
303
|
+
* @example
|
|
304
|
+
* // Get all reminder lists (including disabled)
|
|
305
|
+
* const reminderLists = Calendar.availableReminderLists()
|
|
306
|
+
*
|
|
307
|
+
* @example
|
|
308
|
+
* // Get only enabled reminder lists
|
|
309
|
+
* const reminderLists = Calendar.availableReminderLists({ enabledOnly: true })
|
|
310
|
+
*
|
|
311
|
+
* @example
|
|
312
|
+
* // Access reminder list properties
|
|
313
|
+
* const reminderLists = Calendar.availableReminderLists()
|
|
314
|
+
* reminderLists.forEach(list => {
|
|
315
|
+
* console.log(`${list.title} (${list.source}) - Color: ${list.color}, Enabled: ${list.isEnabled}`)
|
|
316
|
+
* })
|
|
317
|
+
*/
|
|
318
|
+
.availableReminderLists(options)
|
|
319
|
+
|
|
320
|
+
---
|
|
321
|
+
|
|
322
|
+
DateRangeObject
|
|
323
|
+
|
|
324
|
+
/**
|
|
325
|
+
* The start date of the parsed date text.
|
|
326
|
+
* @type {Date}
|
|
327
|
+
*/
|
|
328
|
+
.start
|
|
329
|
+
|
|
330
|
+
/**
|
|
331
|
+
* The end date of the parsed date text. This might not be defined in the date text. Then the end date = start date.
|
|
332
|
+
* If two time or dates are mentioned in the input string of `Calendar.parseDateText(...)`, then the start and end dates will have the respective times and dates set.
|
|
333
|
+
* @type {Date}
|
|
334
|
+
*/
|
|
335
|
+
.end
|
|
336
|
+
|
|
337
|
+
/**
|
|
338
|
+
* The detected date text. You can use this to remove the date from the original string
|
|
339
|
+
* @type {String}
|
|
340
|
+
*/
|
|
341
|
+
.text
|
|
342
|
+
|
|
343
|
+
/**
|
|
344
|
+
* The index where the date text was found in the given string. Use this so you know where the date text started and get the length from `.text` to cut it out of the original string if needed.
|
|
345
|
+
* @type {Intege}
|
|
346
|
+
*/
|
|
347
|
+
.index
|
|
348
|
+
|
|
349
|
+
```
|
|
350
|
+
|
|
351
|
+
</p>
|
|
352
|
+
</details>
|
|
353
|
+
|
|
354
|
+
<details>
|
|
355
|
+
<summary>Examples</summary>
|
|
356
|
+
<p>
|
|
357
|
+
|
|
358
|
+
|
|
359
|
+
```javascript
|
|
360
|
+
|
|
361
|
+
function dateExample() {
|
|
362
|
+
console.log(Calendar.dateUnits)
|
|
363
|
+
|
|
364
|
+
let date = Calendar.dateFrom(2021, 5, 14, 15, 0, 0)
|
|
365
|
+
console.log(Calendar.timeAgoSinceNow(date))
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
async function createEvent() {
|
|
369
|
+
try {
|
|
370
|
+
let title = await CommandBar.showInput("Enter the title of the event", "Submit title '%@', then...")
|
|
371
|
+
|
|
372
|
+
// To make this work you need to enter '1st May', 'tomorrow', etc. for example
|
|
373
|
+
let dateText = await CommandBar.showInput("Enter date", "Create event '" + title + "' with date '%@'")
|
|
374
|
+
|
|
375
|
+
console.log("dateText: " + dateText)
|
|
376
|
+
|
|
377
|
+
// Parses date and time text such as 'today at 5pm - 7pm'
|
|
378
|
+
let dates = Calendar.parseDateText(dateText)
|
|
379
|
+
|
|
380
|
+
if(dates.length >= 0) {
|
|
381
|
+
let parsed = dates[0]
|
|
382
|
+
let start = parsed.start
|
|
383
|
+
let end = parsed.start
|
|
384
|
+
|
|
385
|
+
if(parsed.end !== undefined) {
|
|
386
|
+
end = parsed.end
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
console.log("parsed start: '" + start + ", end: '" + end + "' from text: '" + dateText + "'")
|
|
390
|
+
|
|
391
|
+
// CalendarItem.create(title, start date, optional end date, "event" or "reminder", isAllDay)
|
|
392
|
+
var event = CalendarItem.create(title, start, end, "event", false, "", false, "hello world", "https://noteplan.co")
|
|
393
|
+
var createdEvent = Calendar.add(event)
|
|
394
|
+
|
|
395
|
+
if(createdEvent != undefined) {
|
|
396
|
+
console.log("Event created with id: " + createdEvent.id)
|
|
397
|
+
} else {
|
|
398
|
+
console.log("Failed to create event")
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
} catch (error) {
|
|
402
|
+
console.log("Plugin code error: \n"+JSON.stringify(error))
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
async function updateEventByID() {
|
|
407
|
+
try {
|
|
408
|
+
let id = await CommandBar.showInput("Enter the id of the event to update", "Submit id title '%@'.")
|
|
409
|
+
let newtitle = await CommandBar.showInput("Enter the new title of the event", "Submit new title '%@'.")
|
|
410
|
+
|
|
411
|
+
let event = await Calendar.eventByID(id)
|
|
412
|
+
console.log("Found event with title: " + event.title)
|
|
413
|
+
|
|
414
|
+
event.title = newtitle
|
|
415
|
+
Calendar.update(event)
|
|
416
|
+
} catch (error) {
|
|
417
|
+
console.log("Plugin code error: \n"+JSON.stringify(error))
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
async function removeEventByID() {
|
|
422
|
+
try {
|
|
423
|
+
let id = await CommandBar.showInput("Enter the id of the event to update", "Submit id '%@'.")
|
|
424
|
+
|
|
425
|
+
let event = await Calendar.eventByID(id)
|
|
426
|
+
console.log("Found event with title to delete: " + event.title)
|
|
427
|
+
Calendar.remove(event)
|
|
428
|
+
} catch (error) {
|
|
429
|
+
console.log("Plugin code error: \n"+JSON.stringify(error))
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
|
|
434
|
+
async function fetchReminders() {
|
|
435
|
+
try {
|
|
436
|
+
let reminders = await Calendar.remindersByLists(["Reminders"])
|
|
437
|
+
reminders.forEach((item, i) => {
|
|
438
|
+
console.log(item.title + " isCompleted: " + item.isCompleted)
|
|
439
|
+
});
|
|
440
|
+
} catch (error) {
|
|
441
|
+
console.log("Plugin code error: \n"+JSON.stringify(error))
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
```
|
|
445
|
+
|
|
446
|
+
</p>
|
|
447
|
+
</details>
|
|
448
|
+
|