@chronicle.app/things-todo 0.3.0 → 0.4.0

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.
@@ -11,6 +11,11 @@ export declare class ThingsTodoExtractor extends SqliteExtractor<typeof ThingsTo
11
11
  static default: boolean;
12
12
  static schema: any;
13
13
  static defaultTransformer: typeof ThingsTodoTransformer;
14
+ /**
15
+ * The default database lives in a folder macOS guards: say whether it's
16
+ * missing or refused before SQLite reports "unable to open database file".
17
+ */
18
+ setup(): Promise<void>;
14
19
  /** The owner's name from the local machine, used when `agentName` isn't set. */
15
20
  protected resolveAgentName(): string | undefined;
16
21
  private getStatusLabel;
@@ -1,3 +1,4 @@
1
+ import { fileError } from '@chronicle.app/etl';
1
2
  import { SqliteExtractor, timeRangeConditions } from '@chronicle.app/etl-sqlite';
2
3
  import { existsSync, readdirSync } from 'node:fs';
3
4
  import { join } from 'node:path';
@@ -12,11 +13,20 @@ import ThingsTodoTransformer from './ThingsTodoTransformer.js';
12
13
  * cannot be hardcoded. Glob the Group Containers directory for the
13
14
  * `ThingsData-*` folder and return the database inside it.
14
15
  */
16
+ const containerDir = `${process.env.HOME}/Library/Group Containers/JLMPQHK86H.com.culturedcode.ThingsMac`;
15
17
  function resolveThingsDbPath() {
16
- const containerDir = `${process.env.HOME}/Library/Group Containers/JLMPQHK86H.com.culturedcode.ThingsMac`;
17
18
  const dbSuffix = 'Things Database.thingsdatabase/main.sqlite';
19
+ // Listing the container needs Full Disk Access; without it, fall through to
20
+ // the conventional path and let setup() say what's wrong.
18
21
  if (existsSync(containerDir)) {
19
- const thingsDataDirs = readdirSync(containerDir).filter(name => name.startsWith('ThingsData-'));
22
+ let entries = [];
23
+ try {
24
+ entries = readdirSync(containerDir);
25
+ }
26
+ catch {
27
+ // Reported by setup().
28
+ }
29
+ const thingsDataDirs = entries.filter(name => name.startsWith('ThingsData-'));
20
30
  for (const dir of thingsDataDirs) {
21
31
  const dbPath = join(containerDir, dir, dbSuffix);
22
32
  if (existsSync(dbPath)) {
@@ -51,6 +61,22 @@ export class ThingsTodoExtractor extends SqliteExtractor {
51
61
  .describe("Name of the task owner. Defaults to the OS account's full name"),
52
62
  });
53
63
  static defaultTransformer = ThingsTodoTransformer;
64
+ /**
65
+ * The default database lives in a folder macOS guards: say whether it's
66
+ * missing or refused before SQLite reports "unable to open database file".
67
+ */
68
+ async setup() {
69
+ const { input } = this.config;
70
+ if (input.startsWith(containerDir)) {
71
+ try {
72
+ readdirSync(containerDir);
73
+ }
74
+ catch (error) {
75
+ throw fileError(error, containerDir, 'Things library');
76
+ }
77
+ }
78
+ await super.setup();
79
+ }
54
80
  /** The owner's name from the local machine, used when `agentName` isn't set. */
55
81
  resolveAgentName() {
56
82
  return localAccountName();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chronicle.app/things-todo",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "files": [
@@ -19,9 +19,9 @@
19
19
  "type": "module",
20
20
  "description": "Chronicle things-todo extraction plugin",
21
21
  "devDependencies": {
22
- "@chronicle.app/etl": "0.3.0",
23
- "@chronicle.app/schema": "0.3.0",
24
- "@chronicle.app/tsconfig": "0.3.0",
22
+ "@chronicle.app/etl": "0.4.0",
23
+ "@chronicle.app/schema": "0.4.0",
24
+ "@chronicle.app/tsconfig": "0.4.0",
25
25
  "@types/node": "^22.10.1",
26
26
  "typescript": "^5.7.2"
27
27
  },
@@ -36,7 +36,7 @@
36
36
  "registry": "https://registry.npmjs.org/"
37
37
  },
38
38
  "dependencies": {
39
- "@chronicle.app/etl-sqlite": "0.3.0",
39
+ "@chronicle.app/etl-sqlite": "0.4.0",
40
40
  "zod": "^3.24.1"
41
41
  },
42
42
  "peerDependencies": {