buddy-workbench 0.1.30 → 0.1.31

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "buddy-workbench",
3
- "version": "0.1.30",
3
+ "version": "0.1.31",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "bin": {
package/server/config.js CHANGED
@@ -14,6 +14,7 @@ export const paths = {
14
14
  errors: join(root, 'data', 'errors.json'),
15
15
  postman: join(root, 'data', 'postman.json'),
16
16
  branchSync: join(root, 'data', 'branch-sync.json'),
17
+ presentations: join(root, 'data', 'presentations.json'),
17
18
  shutdownLog: join(root, 'data', 'shutdown.log'),
18
19
  clipboardDir: join(root, 'data', 'clipboard'),
19
20
  plugins: join(root, 'plugins'),
@@ -0,0 +1,31 @@
1
+ import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
2
+ import { dirname } from 'node:path';
3
+ import { paths } from '../config.js';
4
+
5
+ const EMPTY_DATA = { plans: [], activePlan: null };
6
+
7
+ export function getPresentations() {
8
+ try {
9
+ if (!existsSync(paths.presentations)) return EMPTY_DATA;
10
+ const parsed = JSON.parse(readFileSync(paths.presentations, 'utf8'));
11
+ return {
12
+ plans: Array.isArray(parsed.plans) ? parsed.plans : [],
13
+ activePlan: parsed.activePlan || null
14
+ };
15
+ } catch {
16
+ return EMPTY_DATA;
17
+ }
18
+ }
19
+
20
+ export function savePresentations(data) {
21
+ mkdirSync(dirname(paths.presentations), { recursive: true });
22
+ const current = getPresentations();
23
+ const next = {
24
+ plans: Array.isArray(data.plans) ? data.plans : [],
25
+ activePlan: Object.prototype.hasOwnProperty.call(data, 'activePlan')
26
+ ? data.activePlan || null
27
+ : current.activePlan
28
+ };
29
+ writeFileSync(paths.presentations, JSON.stringify(next, null, 2), 'utf8');
30
+ return next;
31
+ }
@@ -0,0 +1,19 @@
1
+ import { Router } from 'express';
2
+ import { getPresentations, savePresentations } from '../repositories/presentations.js';
3
+
4
+ const router = Router();
5
+
6
+ router.get('/', (_req, res) => {
7
+ res.json(getPresentations());
8
+ });
9
+
10
+ router.put('/', (req, res) => {
11
+ res.json(savePresentations(req.body || {}));
12
+ });
13
+
14
+ router.put('/active', (req, res) => {
15
+ const current = getPresentations();
16
+ res.json(savePresentations({ ...current, activePlan: req.body?.plan || null }));
17
+ });
18
+
19
+ export default router;
package/server.js CHANGED
@@ -23,6 +23,7 @@ import fileOrganizerRoutes from './server/routes/file-organizer.js';
23
23
  import branchSyncRoutes from './server/routes/branch-sync.js';
24
24
  import updateRoutes from './server/routes/updates.js';
25
25
  import dataBackupRoutes from './server/routes/data-backup.js';
26
+ import presentationsRoutes from './server/routes/presentations.js';
26
27
  import { addErrorRecord } from './server/repositories/errors.js';
27
28
  import { startClipboardCapture } from './server/services/clipboard-history.js';
28
29
 
@@ -81,6 +82,7 @@ app.use('/api/file-organizer', fileOrganizerRoutes);
81
82
  app.use('/api/branch-sync', branchSyncRoutes);
82
83
  app.use('/api/updates', updateRoutes);
83
84
  app.use('/api/data-backup', dataBackupRoutes);
85
+ app.use('/api/presentations', presentationsRoutes);
84
86
 
85
87
  app.use((err, req, res, _next) => {
86
88
  addErrorRecord({