@unbrained/pm-web 2026.6.2 → 2026.6.4
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/CHANGELOG.md +21 -0
- package/README.md +92 -1
- package/dist/auth.js +6 -0
- package/dist/auth.js.map +1 -1
- package/dist/ical.js +141 -0
- package/dist/ical.js.map +1 -0
- package/dist/index.js +351 -6
- package/dist/index.js.map +1 -1
- package/dist/routes/pm.js +43 -0
- package/dist/routes/pm.js.map +1 -1
- package/dist/server.js +13 -2
- package/dist/server.js.map +1 -1
- package/manifest.json +1 -1
- package/package.json +2 -2
- package/public/index.html +2 -1
- package/public/src/app.js +12 -1
- package/public/src/app.js.map +1 -1
- package/public/src/app.ts +12 -1
- package/public/src/filters.js +40 -0
- package/public/src/filters.js.map +1 -0
- package/public/src/filters.ts +52 -0
- package/public/src/state.js +1 -1
- package/public/src/state.js.map +1 -1
- package/public/src/state.ts +1 -1
- package/public/src/theme.js +74 -0
- package/public/src/theme.js.map +1 -0
- package/public/src/theme.ts +75 -0
- package/public/src/types.ts +1 -0
- package/public/src/views/calendar.js +1 -0
- package/public/src/views/calendar.js.map +1 -1
- package/public/src/views/calendar.ts +1 -0
- package/public/src/views/items.js +56 -3
- package/public/src/views/items.js.map +1 -1
- package/public/src/views/items.ts +55 -3
- package/public/styles.css +85 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,26 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 2026.6.4 - 2026-06-04
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
|
|
7
|
+
- Add light/auto theme toggle, URL-state item filters, and iCal \(.ics\) calendar export ([pm-web-b6eo](https://github.com/unbraind/pm-web/blob/main/.agents/pm/tasks/pm-web-b6eo.toon))
|
|
8
|
+
|
|
9
|
+
## 2026.06.02-1 - 2026-06-02
|
|
10
|
+
|
|
11
|
+
### Added
|
|
12
|
+
|
|
13
|
+
- Do NOT add the 'services' extension capability to pm-web ([pm-web-vyfp](https://github.com/unbraind/pm-web/blob/main/.agents/pm/decisions/pm-web-vyfp.toon))
|
|
14
|
+
- Deepen pm-web extension command surface \(status/stop/doctor\) + services-capability evaluation ([pm-web-7pxa](https://github.com/unbraind/pm-web/blob/main/.agents/pm/features/pm-web-7pxa.toon))
|
|
15
|
+
- Add /healthz version + unit tests + README docs ([pm-web-edyj](https://github.com/unbraind/pm-web/blob/main/.agents/pm/tasks/pm-web-edyj.toon))
|
|
16
|
+
- Introduce CommandError \(numeric exitCode\) for new handlers ([pm-web-9ycn](https://github.com/unbraind/pm-web/blob/main/.agents/pm/tasks/pm-web-9ycn.toon))
|
|
17
|
+
|
|
18
|
+
### Other
|
|
19
|
+
|
|
20
|
+
- Implement 'pm web doctor' command ([pm-web-vyqb](https://github.com/unbraind/pm-web/blob/main/.agents/pm/tasks/pm-web-vyqb.toon))
|
|
21
|
+
- Implement 'pm web stop' command + pidfile-on-detach ([pm-web-odwq](https://github.com/unbraind/pm-web/blob/main/.agents/pm/tasks/pm-web-odwq.toon))
|
|
22
|
+
- Implement 'pm web status' command ([pm-web-8eqs](https://github.com/unbraind/pm-web/blob/main/.agents/pm/tasks/pm-web-8eqs.toon))
|
|
23
|
+
|
|
3
24
|
## 2026.05.30 - 2026-05-30
|
|
4
25
|
|
|
5
26
|
### Fixed
|
package/README.md
CHANGED
|
@@ -52,8 +52,55 @@ The package repository is at **github.com/unbraind/pm-web**.
|
|
|
52
52
|
|
|
53
53
|
| Command | Description |
|
|
54
54
|
|---|---|
|
|
55
|
-
| `pm web` | Start the pm-web server |
|
|
55
|
+
| `pm web` | Start the pm-web server (foreground) |
|
|
56
56
|
| `pm web --port 8080` | Start on a custom port |
|
|
57
|
+
| `pm web --detach` | Start the server in the background (tracked via a pidfile) |
|
|
58
|
+
| `pm web status` | Report whether a server is reachable (probes `/healthz`); `--json` supported |
|
|
59
|
+
| `pm web stop` | Stop a server previously started with `--detach`; `--json` supported |
|
|
60
|
+
| `pm web doctor` | Preflight diagnostics (Node, runtime deps, port, pm, workspace); `--json` supported |
|
|
61
|
+
|
|
62
|
+
#### `pm web status`
|
|
63
|
+
|
|
64
|
+
Probes `http://localhost:<port>/healthz` and reports `up`/`down`, the responding
|
|
65
|
+
port, and the server version. Never errors when the server is down — it returns a
|
|
66
|
+
structured `down` result. The port is resolved from `--port`, then `PORT`, then
|
|
67
|
+
the default `4000`.
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
pm web status # human-readable
|
|
71
|
+
pm web status --port 8080 --json
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
#### `pm web stop`
|
|
75
|
+
|
|
76
|
+
Stops a server started with `pm web --detach`. The detached PID is recorded in a
|
|
77
|
+
pidfile (under `PM_WEB_STATE_DIR` if set, otherwise the OS temp dir, keyed by
|
|
78
|
+
port). `pm web stop` reads the pidfile, sends `SIGTERM`, and clears the pidfile.
|
|
79
|
+
If nothing is running it reports `not_running` gracefully and cleans up any stale
|
|
80
|
+
pidfile.
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
pm web stop # stops the server on the default port
|
|
84
|
+
pm web stop --port 8080 --json
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
#### `pm web doctor`
|
|
88
|
+
|
|
89
|
+
Runs preflight checks before starting the server: Node version (>= 20), whether
|
|
90
|
+
runtime dependencies (express, etc.) are installed, whether the target port is
|
|
91
|
+
free, whether `pm` is on `PATH`, and whether the workspace is initialized.
|
|
92
|
+
Returns an overall `ok` boolean. The `port_available` check is informational (a
|
|
93
|
+
busy port may just be a server you already started) and does not gate `ok`.
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
pm web doctor
|
|
97
|
+
pm web doctor --json
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
> Note: the `services` extension capability is intentionally **not** declared.
|
|
101
|
+
> The pm SDK's `registerService` only overrides one of eight fixed core services
|
|
102
|
+
> (e.g. `output_format`), which would alter core output for unrelated commands;
|
|
103
|
+
> the server lifecycle is exposed safely through the commands above instead.
|
|
57
104
|
|
|
58
105
|
### Environment Variables
|
|
59
106
|
|
|
@@ -64,6 +111,7 @@ The package repository is at **github.com/unbraind/pm-web**.
|
|
|
64
111
|
| `PM_WEB_SECRET_KEY` | Recommended | At-rest encryption key for saved GitHub PATs. Falls back to `JWT_SECRET`; use at least 32 characters |
|
|
65
112
|
| `PM_WEB_BOOTSTRAP_ADMIN_EMAIL` | Recommended | Email of the user account to auto-promote to admin on schema init. Leave unset to skip auto-promotion (manage admins via the admin UI). |
|
|
66
113
|
| `PORT` | No | Server port (default: 4000) |
|
|
114
|
+
| `PM_WEB_STATE_DIR` | No | Directory for the `--detach` pidfile used by `pm web stop` (default: OS temp dir) |
|
|
67
115
|
| `NODE_ENV` | No | `production` enables caching |
|
|
68
116
|
| `OLLAMA_BASE_URL` / `OLLAMA_HOST` | No | Local Ollama endpoint for semantic pm search |
|
|
69
117
|
| `PM_OLLAMA_MODEL` | No | Embedding model for new projects, default `qwen3-embedding:0.6b` |
|
|
@@ -118,6 +166,49 @@ extensions):
|
|
|
118
166
|
search over id, title, tags and body.
|
|
119
167
|
- `GET /api/projects/:projectId/pm/schema` — runtime types/statuses (existing).
|
|
120
168
|
- `GET /api/projects/:projectId/pm/graph` — dependency graph (existing).
|
|
169
|
+
- `GET /api/projects/:projectId/pm/calendar.ics` — RFC 5545 iCalendar feed of
|
|
170
|
+
item deadlines (see below).
|
|
121
171
|
|
|
122
172
|
The pure grouping/search helpers live in `src/board.ts` and are unit-tested
|
|
123
173
|
independently of the database.
|
|
174
|
+
|
|
175
|
+
## UI features
|
|
176
|
+
|
|
177
|
+
### Theme (dark / light / auto)
|
|
178
|
+
|
|
179
|
+
The web UI supports three themes — **dark** (default), **light**, and **auto**
|
|
180
|
+
(follows the OS `prefers-color-scheme`). Toggle with the button in the top nav
|
|
181
|
+
or the `t` keyboard shortcut; the choice is persisted to `localStorage`. The
|
|
182
|
+
palette is driven entirely by CSS variables (`public/styles.css`); the toggle
|
|
183
|
+
logic lives in `public/src/theme.ts`.
|
|
184
|
+
|
|
185
|
+
### Shareable filtered views
|
|
186
|
+
|
|
187
|
+
The Items view mirrors its filters into the URL query string, so a filtered
|
|
188
|
+
view is shareable and bookmarkable:
|
|
189
|
+
|
|
190
|
+
```
|
|
191
|
+
/items?status=open&type=Feature&priority=1&assignee=alice&tag=release
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
Filterable dimensions: `status`, `type`, `priority`, `sprint`, `release`,
|
|
195
|
+
`assignee`, `tag`. Opening such a URL restores the filters; use the **Copy
|
|
196
|
+
link** button to copy the current filtered view. The pure (de)serialization
|
|
197
|
+
helpers live in `public/src/filters.ts` and are unit-tested.
|
|
198
|
+
|
|
199
|
+
### Calendar export (iCal / .ics)
|
|
200
|
+
|
|
201
|
+
`GET /api/projects/:projectId/pm/calendar.ics` returns an RFC 5545 `VCALENDAR`
|
|
202
|
+
with a `VEVENT` per item that has a deadline, suitable for **subscribing** in
|
|
203
|
+
Google Calendar, Outlook, or Apple Calendar. Date-only deadlines become all-day
|
|
204
|
+
events; items without a deadline are skipped. Use the **Export .ics** button on
|
|
205
|
+
the Calendar view to download, or subscribe to the feed URL. Because calendar
|
|
206
|
+
clients cannot send cookies, the feed also accepts the JWT via a `?token=<jwt>`
|
|
207
|
+
query parameter (in addition to the usual `Authorization: Bearer` header /
|
|
208
|
+
cookie). The pure generator lives in `src/ical.ts` and is unit-tested.
|
|
209
|
+
|
|
210
|
+
### Keyboard shortcuts
|
|
211
|
+
|
|
212
|
+
Press `?` for the in-app shortcuts overlay. Highlights: `Ctrl/⌘+K` global
|
|
213
|
+
search, `/` focus search, `n`/`c` new item, `t` cycle theme, `a` activity,
|
|
214
|
+
`g i` items, `g g` graph, `g s` search, `g c` calendar, `Esc` close modal.
|
package/dist/auth.js
CHANGED
|
@@ -15,6 +15,12 @@ export function extractToken(req) {
|
|
|
15
15
|
const cookie = req.cookies?.pm_token;
|
|
16
16
|
if (cookie)
|
|
17
17
|
return cookie;
|
|
18
|
+
// Allow a `?token=` query param. Calendar clients subscribing to an .ics
|
|
19
|
+
// feed cannot send cookies or an Authorization header, so the feed URL
|
|
20
|
+
// carries the JWT directly. Additive — header/cookie still take precedence.
|
|
21
|
+
const queryToken = req.query?.["token"];
|
|
22
|
+
if (typeof queryToken === "string" && queryToken)
|
|
23
|
+
return queryToken;
|
|
18
24
|
return null;
|
|
19
25
|
}
|
|
20
26
|
//# sourceMappingURL=auth.js.map
|
package/dist/auth.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,cAAc,CAAC;AAG/B,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,CAAC,UAAU,IAAI,kCAAkC,CAAC;AAChF,MAAM,WAAW,GAAG,KAAK,CAAC;AAO1B,MAAM,UAAU,SAAS,CAAC,OAAmB;IAC3C,OAAO,GAAG,CAAC,IAAI,CAAC,OAAO,EAAE,UAAU,EAAE,EAAE,SAAS,EAAE,WAAW,EAAE,CAAC,CAAC;AACnE,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,KAAa;IACvC,OAAO,GAAG,CAAC,MAAM,CAAC,KAAK,EAAE,UAAU,CAAe,CAAC;AACrD,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,GAAY;IACvC,MAAM,UAAU,GAAG,GAAG,CAAC,OAAO,CAAC,aAAa,CAAC;IAC7C,IAAI,UAAU,EAAE,UAAU,CAAC,SAAS,CAAC,EAAE,CAAC;QACtC,OAAO,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAC7B,CAAC;IACD,MAAM,MAAM,GAAI,GAAsD,CAAC,OAAO,EAAE,QAAQ,CAAC;IACzF,IAAI,MAAM;QAAE,OAAO,MAAM,CAAC;IAC1B,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
1
|
+
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,cAAc,CAAC;AAG/B,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,CAAC,UAAU,IAAI,kCAAkC,CAAC;AAChF,MAAM,WAAW,GAAG,KAAK,CAAC;AAO1B,MAAM,UAAU,SAAS,CAAC,OAAmB;IAC3C,OAAO,GAAG,CAAC,IAAI,CAAC,OAAO,EAAE,UAAU,EAAE,EAAE,SAAS,EAAE,WAAW,EAAE,CAAC,CAAC;AACnE,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,KAAa;IACvC,OAAO,GAAG,CAAC,MAAM,CAAC,KAAK,EAAE,UAAU,CAAe,CAAC;AACrD,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,GAAY;IACvC,MAAM,UAAU,GAAG,GAAG,CAAC,OAAO,CAAC,aAAa,CAAC;IAC7C,IAAI,UAAU,EAAE,UAAU,CAAC,SAAS,CAAC,EAAE,CAAC;QACtC,OAAO,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAC7B,CAAC;IACD,MAAM,MAAM,GAAI,GAAsD,CAAC,OAAO,EAAE,QAAQ,CAAC;IACzF,IAAI,MAAM;QAAE,OAAO,MAAM,CAAC;IAC1B,yEAAyE;IACzE,uEAAuE;IACvE,4EAA4E;IAC5E,MAAM,UAAU,GAAI,GAAG,CAAC,KAA6C,EAAE,CAAC,OAAO,CAAC,CAAC;IACjF,IAAI,OAAO,UAAU,KAAK,QAAQ,IAAI,UAAU;QAAE,OAAO,UAAU,CAAC;IACpE,OAAO,IAAI,CAAC;AACd,CAAC"}
|
package/dist/ical.js
ADDED
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
// Pure, dependency-free RFC 5545 (iCalendar) generation for pm items.
|
|
2
|
+
//
|
|
3
|
+
// Kept in its own module (no db/express/neo4j imports) so it is unit-testable
|
|
4
|
+
// without booting the server or a database. The pm route layer reads items via
|
|
5
|
+
// the pm CLI and hands the relevant fields here.
|
|
6
|
+
// Escape a text value per RFC 5545 §3.3.11 (TEXT): backslash, semicolon,
|
|
7
|
+
// comma and newlines must be escaped.
|
|
8
|
+
export function icsEscapeText(value) {
|
|
9
|
+
return value
|
|
10
|
+
.replace(/\\/g, "\\\\")
|
|
11
|
+
.replace(/;/g, "\\;")
|
|
12
|
+
.replace(/,/g, "\\,")
|
|
13
|
+
.replace(/\r\n|\r|\n/g, "\\n");
|
|
14
|
+
}
|
|
15
|
+
// Fold long content lines to 75 octets per RFC 5545 §3.1. Continuation lines
|
|
16
|
+
// begin with a single space. We fold on character boundaries which is safe for
|
|
17
|
+
// the ASCII-dominant content pm produces.
|
|
18
|
+
export function foldLine(line) {
|
|
19
|
+
if (line.length <= 75)
|
|
20
|
+
return line;
|
|
21
|
+
const parts = [];
|
|
22
|
+
let remaining = line;
|
|
23
|
+
parts.push(remaining.slice(0, 75));
|
|
24
|
+
remaining = remaining.slice(75);
|
|
25
|
+
while (remaining.length > 0) {
|
|
26
|
+
// 74 chars + 1 leading space = 75 octets per continuation line.
|
|
27
|
+
parts.push(" " + remaining.slice(0, 74));
|
|
28
|
+
remaining = remaining.slice(74);
|
|
29
|
+
}
|
|
30
|
+
return parts.join("\r\n");
|
|
31
|
+
}
|
|
32
|
+
// Format a Date as a UTC timestamp: YYYYMMDDTHHMMSSZ (RFC 5545 form 2).
|
|
33
|
+
export function formatUtcTimestamp(d) {
|
|
34
|
+
const p = (n, w = 2) => String(n).padStart(w, "0");
|
|
35
|
+
return (`${d.getUTCFullYear()}${p(d.getUTCMonth() + 1)}${p(d.getUTCDate())}` +
|
|
36
|
+
`T${p(d.getUTCHours())}${p(d.getUTCMinutes())}${p(d.getUTCSeconds())}Z`);
|
|
37
|
+
}
|
|
38
|
+
// Format a Date as an all-day DATE value: YYYYMMDD (RFC 5545 §3.3.4).
|
|
39
|
+
export function formatDateValue(d) {
|
|
40
|
+
const p = (n) => String(n).padStart(2, "0");
|
|
41
|
+
return `${d.getUTCFullYear()}${p(d.getUTCMonth() + 1)}${p(d.getUTCDate())}`;
|
|
42
|
+
}
|
|
43
|
+
// A pm deadline may be a date-only string (YYYY-MM-DD) or a full ISO datetime.
|
|
44
|
+
// Returns null for anything unparseable so callers can skip the item.
|
|
45
|
+
function parseDeadline(raw) {
|
|
46
|
+
const trimmed = raw.trim();
|
|
47
|
+
if (!trimmed)
|
|
48
|
+
return null;
|
|
49
|
+
const dateOnly = /^\d{4}-\d{2}-\d{2}$/.test(trimmed);
|
|
50
|
+
const d = new Date(dateOnly ? `${trimmed}T00:00:00Z` : trimmed);
|
|
51
|
+
if (Number.isNaN(d.getTime()))
|
|
52
|
+
return null;
|
|
53
|
+
// pm normalizes date-only deadlines to a midnight-UTC ISO timestamp
|
|
54
|
+
// (e.g. "2026-06-10T00:00:00.000Z"). Treat any exact-midnight-UTC value as
|
|
55
|
+
// an all-day event, which renders far better in calendar clients than a
|
|
56
|
+
// zero-length event at 00:00.
|
|
57
|
+
const isMidnightUtc = d.getUTCHours() === 0 &&
|
|
58
|
+
d.getUTCMinutes() === 0 &&
|
|
59
|
+
d.getUTCSeconds() === 0 &&
|
|
60
|
+
d.getUTCMilliseconds() === 0;
|
|
61
|
+
return { date: d, allDay: dateOnly || isMidnightUtc };
|
|
62
|
+
}
|
|
63
|
+
// Build a single VEVENT for a pm item with a deadline. Returns null when the
|
|
64
|
+
// item has no usable deadline.
|
|
65
|
+
export function itemToVevent(item, opts) {
|
|
66
|
+
if (!item.deadline)
|
|
67
|
+
return null;
|
|
68
|
+
const parsed = parseDeadline(item.deadline);
|
|
69
|
+
if (!parsed)
|
|
70
|
+
return null;
|
|
71
|
+
const lines = ["BEGIN:VEVENT"];
|
|
72
|
+
lines.push(`UID:${item.id}@${opts.uidDomain}`);
|
|
73
|
+
lines.push(`DTSTAMP:${opts.dtstamp}`);
|
|
74
|
+
if (parsed.allDay) {
|
|
75
|
+
// All-day event: DTSTART/DTEND use VALUE=DATE, DTEND is the next day
|
|
76
|
+
// (exclusive end) per RFC 5545.
|
|
77
|
+
const end = new Date(parsed.date.getTime() + 24 * 60 * 60 * 1000);
|
|
78
|
+
lines.push(`DTSTART;VALUE=DATE:${formatDateValue(parsed.date)}`);
|
|
79
|
+
lines.push(`DTEND;VALUE=DATE:${formatDateValue(end)}`);
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
lines.push(`DTSTART:${formatUtcTimestamp(parsed.date)}`);
|
|
83
|
+
lines.push(`DTEND:${formatUtcTimestamp(parsed.date)}`);
|
|
84
|
+
}
|
|
85
|
+
const summaryPrefix = item.type ? `[${item.type}] ` : "";
|
|
86
|
+
lines.push(`SUMMARY:${icsEscapeText(summaryPrefix + (item.title ?? item.id))}`);
|
|
87
|
+
const descParts = [`pm item ${item.id}`];
|
|
88
|
+
if (item.status)
|
|
89
|
+
descParts.push(`Status: ${item.status}`);
|
|
90
|
+
if (item.assignee)
|
|
91
|
+
descParts.push(`Assignee: ${item.assignee}`);
|
|
92
|
+
if (item.priority !== undefined && item.priority !== null)
|
|
93
|
+
descParts.push(`Priority: P${item.priority}`);
|
|
94
|
+
if (item.tags && item.tags.length)
|
|
95
|
+
descParts.push(`Tags: ${item.tags.join(", ")}`);
|
|
96
|
+
// Join with real newlines; icsEscapeText turns them into the RFC 5545 "\n"
|
|
97
|
+
// escape sequence (escaping here directly would double-escape).
|
|
98
|
+
lines.push(`DESCRIPTION:${icsEscapeText(descParts.join("\n"))}`);
|
|
99
|
+
// Map pm priority (0 highest .. 4 lowest) onto the iCal 1..9 scale where 1
|
|
100
|
+
// is highest. Leave unset when no priority is present.
|
|
101
|
+
if (typeof item.priority === "number" && item.priority >= 0 && item.priority <= 4) {
|
|
102
|
+
const icalPriority = Math.min(9, Math.max(1, item.priority * 2 + 1));
|
|
103
|
+
lines.push(`PRIORITY:${icalPriority}`);
|
|
104
|
+
}
|
|
105
|
+
if (item.tags && item.tags.length) {
|
|
106
|
+
lines.push(`CATEGORIES:${item.tags.map(icsEscapeText).join(",")}`);
|
|
107
|
+
}
|
|
108
|
+
// Closed/canceled items are recorded as CANCELLED so subscribers can hide
|
|
109
|
+
// them; everything else is CONFIRMED.
|
|
110
|
+
const cancelled = item.status === "closed" || item.status === "canceled";
|
|
111
|
+
lines.push(`STATUS:${cancelled ? "CANCELLED" : "CONFIRMED"}`);
|
|
112
|
+
lines.push("END:VEVENT");
|
|
113
|
+
return lines.map(foldLine).join("\r\n");
|
|
114
|
+
}
|
|
115
|
+
// Build a complete VCALENDAR document from pm items. Items without a usable
|
|
116
|
+
// deadline are skipped. Output uses CRLF line endings per RFC 5545 §3.1.
|
|
117
|
+
export function buildIcsCalendar(items, opts = {}) {
|
|
118
|
+
const now = opts.now ?? new Date();
|
|
119
|
+
const dtstamp = formatUtcTimestamp(now);
|
|
120
|
+
const uidDomain = (opts.uidDomain ?? "pm-web").replace(/[^A-Za-z0-9._-]/g, "-");
|
|
121
|
+
const calName = opts.calendarName ?? "pm-web";
|
|
122
|
+
const head = [
|
|
123
|
+
"BEGIN:VCALENDAR",
|
|
124
|
+
"VERSION:2.0",
|
|
125
|
+
"PRODID:-//pm-web//pm-cli calendar//EN",
|
|
126
|
+
"CALSCALE:GREGORIAN",
|
|
127
|
+
"METHOD:PUBLISH",
|
|
128
|
+
`X-WR-CALNAME:${icsEscapeText(calName)}`,
|
|
129
|
+
`NAME:${icsEscapeText(calName)}`,
|
|
130
|
+
];
|
|
131
|
+
const events = [];
|
|
132
|
+
for (const item of items) {
|
|
133
|
+
const vevent = itemToVevent(item, { uidDomain, dtstamp });
|
|
134
|
+
if (vevent)
|
|
135
|
+
events.push(vevent);
|
|
136
|
+
}
|
|
137
|
+
const all = [...head.map(foldLine), ...events, "END:VCALENDAR"];
|
|
138
|
+
// Trailing CRLF is conventional and accepted by all major parsers.
|
|
139
|
+
return all.join("\r\n") + "\r\n";
|
|
140
|
+
}
|
|
141
|
+
//# sourceMappingURL=ical.js.map
|
package/dist/ical.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|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