@jibone/todotxt-core 0.1.1 → 0.2.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.
package/README.md CHANGED
@@ -54,7 +54,8 @@ const todos = createTodoTxt({
54
54
  ```
55
55
 
56
56
  `write` is optional until the write APIs are implemented, so read-only clients
57
- can omit it.
57
+ can omit it. `logger` is optional too and silent when omitted; see
58
+ [Logging](#logging).
58
59
 
59
60
  `all()` returns a `TodoRecord` for each non-empty line:
60
61
 
@@ -69,6 +70,10 @@ can omit it.
69
70
  | `contexts` | Contexts without the `@` prefix |
70
71
  | `data` | `key:value` metadata (`{ due: "2011-03-05" }`) |
71
72
 
73
+ If a `key:value` key appears more than once, the last value wins. With a
74
+ [logger](#logging) configured, the parser also emits a `warn` for each duplicate
75
+ key.
76
+
72
77
  ## Querying
73
78
 
74
79
  Queries are lazy: chaining filters does no IO. The first query on a client reads
@@ -165,6 +170,42 @@ Filters are applied in sequence:
165
170
  completed record. A project with both pending and completed items appears in
166
171
  both `pending().projects()` and `completed().projects()`.
167
172
 
173
+ ## Logging
174
+
175
+ `createTodoTxt` is silent by default. Pass a `logger` to receive diagnostics.
176
+ It is called as `logger(level, message, meta?)`, where `level` is `"debug"`,
177
+ `"info"`, `"warn"`, or `"error"`. Bring your own implementation:
178
+
179
+ ```ts
180
+ import { createTodoTxt } from "@jibone/todotxt-core";
181
+ import type { TodoLogger } from "@jibone/todotxt-core";
182
+
183
+ const logger: TodoLogger = (level, message, meta) => {
184
+ const line = `[todotxt:${level}] ${message}`;
185
+
186
+ if (meta) {
187
+ console.log(line, meta);
188
+ } else {
189
+ console.log(line);
190
+ }
191
+ };
192
+
193
+ const todos = createTodoTxt({
194
+ read: () => Bun.file("todo.txt").text(),
195
+ logger,
196
+ });
197
+ ```
198
+
199
+ Currently the client emits:
200
+
201
+ - `debug` when a read starts and when it finishes, with `{ records }`.
202
+ - `warn` for each duplicate `key:value` key; the last value still wins.
203
+
204
+ Cached queries do not log. Read failures stay promise rejections and are not
205
+ logged as `error`; the other levels are reserved for the write APIs. Logging is
206
+ best-effort: a logger that throws or rejects never breaks a read or query. See
207
+ `example/todo-logger.ts`.
208
+
168
209
  ## Parser
169
210
 
170
211
  The parser also works without the client wrapper:
@@ -189,6 +230,7 @@ bun example/todo-all.ts
189
230
  bun example/todo-project.ts
190
231
  bun example/todo-context.ts
191
232
  bun example/todo-cross.ts
233
+ bun example/todo-logger.ts
192
234
  ```
193
235
 
194
236
  ## Development
package/dist/index.d.ts CHANGED
@@ -5,19 +5,52 @@
5
5
  * implementations.
6
6
  */
7
7
  type MaybePromise<T> = T | Promise<T>;
8
+ /** Severity passed to a consumer-supplied logger. */
9
+ type LogLevel = "debug" | "info" | "warn" | "error";
8
10
  /**
9
- * File access callbacks supplied by the consumer.
11
+ * Consumer-supplied logger.
12
+ *
13
+ * The library is silent by default. When a logger is provided, it receives a
14
+ * level, a human-readable message, and optional structured context. Logging is
15
+ * best-effort: implementations may throw or return a promise, and neither will
16
+ * affect reads or queries.
17
+ */
18
+ type TodoLogger = (level: LogLevel, message: string, meta?: Record<string, unknown>) => MaybePromise<unknown>;
19
+ /**
20
+ * A non-fatal issue found while parsing.
21
+ *
22
+ * Warnings describe recoverable conditions; the parser still returns a record.
23
+ */
24
+ interface ParseWarning {
25
+ /** Stable identifier for programmatic handling. */
26
+ code: "duplicate-metadata-key";
27
+ /** Human-readable description of the issue. */
28
+ message: string;
29
+ /** 1-based physical line number, when called through {@link parseDocument}. */
30
+ line?: number;
31
+ /** Structured details such as the offending key and values. */
32
+ meta: Record<string, unknown>;
33
+ }
34
+ /** Receives parse warnings. */
35
+ type ParseWarningHandler = (warning: ParseWarning) => void;
36
+ /**
37
+ * Callbacks supplied by the consumer.
10
38
  *
11
39
  * The library itself never touches the filesystem. `read` is used by
12
40
  * {@link createTodoTxt}. `write` is optional until the write APIs land; when
13
41
  * they do, callers that mutate todos will need to provide it. The write hook's
14
42
  * return value is ignored, so it may return anything (for example
15
43
  * `Bun.write`'s `Promise<number>`).
44
+ *
45
+ * `logger` is an optional bring-your-own logger. It is silent when omitted.
16
46
  */
17
- interface TodoFileHooks {
47
+ interface TodoHooks {
18
48
  read: () => MaybePromise<string>;
19
49
  write?: (contents: string) => MaybePromise<unknown>;
50
+ logger?: TodoLogger;
20
51
  }
52
+ /** @deprecated Use {@link TodoHooks}. */
53
+ type TodoFileHooks = TodoHooks;
21
54
  /**
22
55
  * A single todo.txt line parsed into a JSON-friendly record.
23
56
  *
@@ -92,7 +125,8 @@ interface TodoTxtClient {
92
125
  *
93
126
  * The library performs no IO of its own: `hooks.read` is responsible for
94
127
  * producing the file contents and `hooks.write` will be used by the write APIs
95
- * once they are implemented.
128
+ * once they are implemented. `hooks.logger` is optional and silent by default;
129
+ * when supplied, it receives read lifecycle and parse warning diagnostics.
96
130
  *
97
131
  * Parsed records are cached in memory per client. The first query loads and
98
132
  * parses the file; later queries reuse that snapshot. {@link TodoTxtClient.all}
@@ -106,7 +140,7 @@ interface TodoTxtClient {
106
140
  * Returned records are copies, so callers may mutate them without affecting the
107
141
  * cache.
108
142
  */
109
- export declare function createTodoTxt(hooks: TodoFileHooks): TodoTxtClient;
143
+ export declare function createTodoTxt(hooks: TodoHooks): TodoTxtClient;
110
144
  /**
111
145
  * Parse a single todo.txt line directly into a JSON-friendly {@link TodoRecord}.
112
146
  *
@@ -118,13 +152,17 @@ export declare function createTodoTxt(hooks: TodoFileHooks): TodoTxtClient;
118
152
  * creation date.
119
153
  * - Projects, contexts, and `key:value` metadata may appear anywhere in the
120
154
  * remaining text.
155
+ *
156
+ * Recoverable issues are reported to `onWarning` when supplied; parsing still
157
+ * produces a record.
121
158
  */
122
- export declare function parseLine(line: string): TodoRecord;
159
+ export declare function parseLine(line: string, onWarning?: ParseWarningHandler): TodoRecord;
123
160
  /**
124
161
  * Parse the contents of a todo.txt file.
125
162
  *
126
163
  * Lines are split on `\n` or `\r\n`; blank and whitespace-only lines are
127
- * skipped. Every remaining line becomes a {@link TodoRecord}.
164
+ * skipped. Every remaining line becomes a {@link TodoRecord}. Warnings are
165
+ * annotated with the 1-based physical line number.
128
166
  */
129
- export declare function parseDocument(contents: string): TodoRecord[];
130
- export type { MaybePromise, TodoFileHooks, TodoQuery, TodoRecord, TodoTxtClient };
167
+ export declare function parseDocument(contents: string, onWarning?: ParseWarningHandler): TodoRecord[];
168
+ export type { LogLevel, MaybePromise, ParseWarning, ParseWarningHandler, TodoFileHooks, TodoHooks, TodoLogger, TodoQuery, TodoRecord, TodoTxtClient };
package/dist/index.js CHANGED
@@ -28,8 +28,11 @@ function tokenize(text) {
28
28
  *
29
29
  * Previous versions tokenized the text once for metadata and again to strip it;
30
30
  * doing both here keeps parsing to a single split per line.
31
+ *
32
+ * When a `key:value` key is repeated, `onWarning` receives a
33
+ * `duplicate-metadata-key` warning and the last value wins.
31
34
  */
32
- function parseText(text) {
35
+ function parseText(text, onWarning) {
33
36
  const projects = [];
34
37
  const contexts = [];
35
38
  const data = {};
@@ -47,6 +50,15 @@ function parseText(text) {
47
50
  const key = extension?.[1];
48
51
  const value = extension?.[2];
49
52
  if (key !== void 0 && value !== void 0) {
53
+ if (Object.hasOwn(data, key)) onWarning?.({
54
+ code: "duplicate-metadata-key",
55
+ message: `Duplicate metadata key "${key}"; the last value wins.`,
56
+ meta: {
57
+ key,
58
+ previousValue: data[key],
59
+ value
60
+ }
61
+ });
50
62
  data[key] = value;
51
63
  continue;
52
64
  }
@@ -86,8 +98,11 @@ function takeLeadingDate(input) {
86
98
  * creation date.
87
99
  * - Projects, contexts, and `key:value` metadata may appear anywhere in the
88
100
  * remaining text.
101
+ *
102
+ * Recoverable issues are reported to `onWarning` when supplied; parsing still
103
+ * produces a record.
89
104
  */
90
- function parseLine(line) {
105
+ function parseLine(line, onWarning) {
91
106
  let rest = line;
92
107
  let completed = false;
93
108
  let priority = null;
@@ -106,7 +121,7 @@ function parseLine(line) {
106
121
  }
107
122
  [createdAt, rest] = takeLeadingDate(rest);
108
123
  }
109
- const { description, projects, contexts, data } = parseText(rest.trim());
124
+ const { description, projects, contexts, data } = parseText(rest.trim(), onWarning);
110
125
  return {
111
126
  completed,
112
127
  priority,
@@ -122,11 +137,19 @@ function parseLine(line) {
122
137
  * Parse the contents of a todo.txt file.
123
138
  *
124
139
  * Lines are split on `\n` or `\r\n`; blank and whitespace-only lines are
125
- * skipped. Every remaining line becomes a {@link TodoRecord}.
140
+ * skipped. Every remaining line becomes a {@link TodoRecord}. Warnings are
141
+ * annotated with the 1-based physical line number.
126
142
  */
127
- function parseDocument(contents) {
143
+ function parseDocument(contents, onWarning) {
128
144
  const records = [];
129
- for (const line of contents.split(/\r?\n/)) if (line.trim() !== "") records.push(parseLine(line));
145
+ let lineNumber = 0;
146
+ for (const line of contents.split(/\r?\n/)) {
147
+ lineNumber += 1;
148
+ if (line.trim() !== "") records.push(parseLine(line, onWarning ? (warning) => onWarning({
149
+ ...warning,
150
+ line: lineNumber
151
+ }) : void 0));
152
+ }
130
153
  return records;
131
154
  }
132
155
  // src/query.ts
@@ -168,7 +191,8 @@ function createTodoQuery(load, filters = []) {
168
191
  *
169
192
  * The library performs no IO of its own: `hooks.read` is responsible for
170
193
  * producing the file contents and `hooks.write` will be used by the write APIs
171
- * once they are implemented.
194
+ * once they are implemented. `hooks.logger` is optional and silent by default;
195
+ * when supplied, it receives read lifecycle and parse warning diagnostics.
172
196
  *
173
197
  * Parsed records are cached in memory per client. The first query loads and
174
198
  * parses the file; later queries reuse that snapshot. {@link TodoTxtClient.all}
@@ -186,9 +210,25 @@ function createTodoTxt(hooks) {
186
210
  let cache;
187
211
  let inFlight;
188
212
  let generation = 0;
213
+ const logger = hooks.logger;
214
+ const log = (level, message, meta) => {
215
+ if (!logger) return;
216
+ try {
217
+ const result = logger(level, message, meta);
218
+ if (result && typeof result.then === "function") Promise.resolve(result).catch(() => {});
219
+ } catch {}
220
+ };
189
221
  const readFresh = async () => {
190
222
  const currentGeneration = ++generation;
191
- const records = parseDocument(await hooks.read());
223
+ log("debug", "Reading todo file");
224
+ const records = parseDocument(await hooks.read(), (warning) => {
225
+ log("warn", warning.message, {
226
+ ...warning.meta,
227
+ code: warning.code,
228
+ line: warning.line
229
+ });
230
+ });
231
+ log("debug", "Parsed todo file", { records: records.length });
192
232
  if (currentGeneration === generation) cache = records;
193
233
  return records;
194
234
  };
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../src/clone.ts","../src/metadata.ts","../src/parse.ts","../src/query.ts","../src/client.ts"],"sourcesContent":["import type { TodoRecord } from \"./types.ts\";\n\n/** Copy a record so callers cannot mutate the client's cached snapshot. */\nexport function cloneRecord(todo: TodoRecord): TodoRecord {\n return {\n completed: todo.completed,\n priority: todo.priority,\n completedAt: todo.completedAt,\n createdAt: todo.createdAt,\n description: todo.description,\n projects: [...todo.projects],\n contexts: [...todo.contexts],\n data: { ...todo.data },\n };\n}\n\n/** Copy every record in `records`. */\nexport function cloneRecords(records: readonly TodoRecord[]): TodoRecord[] {\n return records.map(cloneRecord);\n}\n","const EXTENSION_PATTERN = /^([^:\\s]+):([^:\\s]+)$/;\n\n/** Metadata collected from a task's text. */\nexport interface TodoMetadata {\n projects: string[];\n contexts: string[];\n data: Record<string, string>;\n}\n\n/** Everything derived from a task's text in one token pass. */\nexport interface TodoText extends TodoMetadata {\n description: string;\n}\n\nfunction tokenize(text: string): string[] {\n const trimmed = text.trim();\n if (trimmed === \"\") {\n return [];\n }\n\n return trimmed.split(/\\s+/);\n}\n\n/**\n * True when a whitespace-delimited token is inline metadata.\n *\n * Inline metadata is a project (`+name`), a context (`@name`), or a\n * `key:value` extension. Bare `+`/`@` tokens and values containing another\n * colon are not metadata.\n */\nexport function isMetadataToken(token: string): boolean {\n if (token.startsWith(\"+\") && token.length > 1) {\n return true;\n }\n\n if (token.startsWith(\"@\") && token.length > 1) {\n return true;\n }\n\n return EXTENSION_PATTERN.test(token);\n}\n\n/**\n * Collect a task's description, projects, contexts, and extensions in one pass.\n *\n * Previous versions tokenized the text once for metadata and again to strip it;\n * doing both here keeps parsing to a single split per line.\n */\nexport function parseText(text: string): TodoText {\n const projects: string[] = [];\n const contexts: string[] = [];\n const data: Record<string, string> = {};\n const descriptionTokens: string[] = [];\n\n for (const token of tokenize(text)) {\n if (token.startsWith(\"+\") && token.length > 1) {\n projects.push(token.slice(1));\n continue;\n }\n\n if (token.startsWith(\"@\") && token.length > 1) {\n contexts.push(token.slice(1));\n continue;\n }\n\n const extension = EXTENSION_PATTERN.exec(token);\n const key = extension?.[1];\n const value = extension?.[2];\n if (key !== undefined && value !== undefined) {\n data[key] = value;\n continue;\n }\n\n descriptionTokens.push(token);\n }\n\n return {\n description: descriptionTokens.join(\" \"),\n projects,\n contexts,\n data,\n };\n}\n\n/** Collect projects, contexts, and extensions from task text. */\nexport function parseMetadata(text: string): TodoMetadata {\n const { projects, contexts, data } = parseText(text);\n return { projects, contexts, data };\n}\n\n/**\n * Remove inline metadata from task text.\n *\n * Remaining tokens are rejoined with single spaces, so repeated whitespace can\n * be normalized.\n */\nexport function stripMetadata(text: string): string {\n return parseText(text).description;\n}\n","import { parseText } from \"./metadata.ts\";\nimport type { TodoRecord } from \"./types.ts\";\n\nconst PRIORITY_PATTERN = /^\\(([A-Z])\\) /;\nconst LEADING_DATE_PATTERN = /^(\\d{4}-\\d{2}-\\d{2})(?: |$)/;\n\n/**\n * Consume a `YYYY-MM-DD` date from the start of `input`.\n *\n * Only the shape is validated; the date does not have to exist on a calendar\n * (matching the literal format rules).\n */\nfunction takeLeadingDate(input: string): [date: string | null, rest: string] {\n const match = LEADING_DATE_PATTERN.exec(input);\n if (!match) {\n return [null, input];\n }\n\n const date = match[1];\n if (date === undefined) {\n return [null, input];\n }\n\n return [date, input.slice(match[0]!.length)];\n}\n\n/**\n * Parse a single todo.txt line directly into a JSON-friendly {@link TodoRecord}.\n *\n * The parser follows the todo.txt format rules:\n *\n * - Completed tasks start with `x `, optionally followed by a completion date\n * and then a creation date.\n * - Incomplete tasks may start with an `(A)`–`(Z)` priority and an optional\n * creation date.\n * - Projects, contexts, and `key:value` metadata may appear anywhere in the\n * remaining text.\n */\nexport function parseLine(line: string): TodoRecord {\n let rest = line;\n let completed = false;\n let priority: string | null = null;\n let completedAt: string | null = null;\n let createdAt: string | null = null;\n\n if (rest.startsWith(\"x \")) {\n completed = true;\n rest = rest.slice(2);\n [completedAt, rest] = takeLeadingDate(rest);\n [createdAt, rest] = takeLeadingDate(rest);\n } else {\n const priorityMatch = PRIORITY_PATTERN.exec(rest);\n if (priorityMatch) {\n priority = priorityMatch[1]!;\n rest = rest.slice(priorityMatch[0]!.length);\n }\n\n [createdAt, rest] = takeLeadingDate(rest);\n }\n\n const text = rest.trim();\n const { description, projects, contexts, data } = parseText(text);\n\n return {\n completed,\n priority,\n completedAt,\n createdAt,\n description,\n projects,\n contexts,\n data,\n };\n}\n\n/**\n * Parse the contents of a todo.txt file.\n *\n * Lines are split on `\\n` or `\\r\\n`; blank and whitespace-only lines are\n * skipped. Every remaining line becomes a {@link TodoRecord}.\n */\nexport function parseDocument(contents: string): TodoRecord[] {\n const records: TodoRecord[] = [];\n\n for (const line of contents.split(/\\r?\\n/)) {\n if (line.trim() !== \"\") {\n records.push(parseLine(line));\n }\n }\n\n return records;\n}\n","import { cloneRecords } from \"./clone.ts\";\nimport type { TodoRecord } from \"./types.ts\";\n\n/** A predicate applied to every record in a query. */\nexport type TodoFilter = (todo: TodoRecord) => boolean;\n\n/** Loads and parses every todo.txt record. */\nexport type LoadRecords = () => Promise<TodoRecord[]>;\n\n/**\n * A lazy query over parsed todo records.\n *\n * Filters return a new query and perform no IO. Awaiting a query resolves\n * through the supplied loader; the client caches parsed records, so only the\n * first query reads the file. {@link TodoQuery.projects} and\n * {@link TodoQuery.contexts} are terminal plucks that resolve to unique,\n * alphabetically sorted names.\n */\nexport interface TodoQuery extends PromiseLike<TodoRecord[]> {\n /** Only records that are not completed. */\n pending: () => TodoQuery;\n /** Only records that are completed. */\n completed: () => TodoQuery;\n /** Only records tagged with the project `name`. */\n project: (name: string) => TodoQuery;\n /** Only records tagged with the context `name`. */\n context: (name: string) => TodoQuery;\n /** Unique project names in the current result, alphabetically sorted. */\n projects: () => Promise<string[]>;\n /** Unique context names in the current result, alphabetically sorted. */\n contexts: () => Promise<string[]>;\n}\n\nfunction uniqueSorted(values: string[]): string[] {\n return [...new Set(values)].sort();\n}\n\nasync function resolveRaw(\n load: LoadRecords,\n filters: TodoFilter[],\n): Promise<TodoRecord[]> {\n const records = await load();\n\n if (filters.length === 0) {\n return records;\n }\n\n return records.filter((record) =>\n filters.every((filter) => filter(record)),\n );\n}\n\nasync function resolveRecords(\n load: LoadRecords,\n filters: TodoFilter[],\n): Promise<TodoRecord[]> {\n return cloneRecords(await resolveRaw(load, filters));\n}\n\nfunction pluckNames(\n load: LoadRecords,\n filters: TodoFilter[],\n pick: (todo: TodoRecord) => string[],\n): Promise<string[]> {\n return resolveRaw(load, filters).then((records) =>\n uniqueSorted(records.flatMap(pick)),\n );\n}\n\n/**\n * Create a lazy query over the records loaded by `load`.\n *\n * Each filter method appends a predicate, so chained calls compose. For\n * example, `pending().completed()` matches nothing, while\n * `project(\"Work\").pending()` matches pending records in `Work`.\n */\nexport function createTodoQuery(\n load: LoadRecords,\n filters: TodoFilter[] = [],\n): TodoQuery {\n return {\n pending: () =>\n createTodoQuery(load, [...filters, (todo) => !todo.completed]),\n completed: () =>\n createTodoQuery(load, [...filters, (todo) => todo.completed]),\n project: (name) =>\n createTodoQuery(load, [\n ...filters,\n (todo) => todo.projects.includes(name),\n ]),\n context: (name) =>\n createTodoQuery(load, [\n ...filters,\n (todo) => todo.contexts.includes(name),\n ]),\n projects: () => pluckNames(load, filters, (todo) => todo.projects),\n contexts: () => pluckNames(load, filters, (todo) => todo.contexts),\n then: (onfulfilled, onrejected) =>\n resolveRecords(load, filters).then(onfulfilled, onrejected),\n };\n}\n","import { cloneRecords } from \"./clone.ts\";\nimport { parseDocument } from \"./parse.ts\";\nimport { createTodoQuery } from \"./query.ts\";\nimport type { TodoQuery } from \"./query.ts\";\nimport type { TodoFileHooks, TodoRecord } from \"./types.ts\";\n\n/** The read interface returned by {@link createTodoTxt}. */\nexport interface TodoTxtClient {\n /** Read fresh todo.txt contents, replace the cache, and return every record. */\n all: () => Promise<TodoRecord[]>;\n /** Query only records that are not completed, using the cached snapshot. */\n pending: () => TodoQuery;\n /** Query only records that are completed, using the cached snapshot. */\n completed: () => TodoQuery;\n /** Query records tagged with a single project name, using the cache. */\n project: (name: string) => TodoQuery;\n /** Query records tagged with a single context name, using the cache. */\n context: (name: string) => TodoQuery;\n /** List unique project names from the cached snapshot, alphabetically sorted. */\n projects: () => Promise<string[]>;\n /** List unique context names from the cached snapshot, alphabetically sorted. */\n contexts: () => Promise<string[]>;\n}\n\n/**\n * Create a todo.txt client backed by consumer-supplied file hooks.\n *\n * The library performs no IO of its own: `hooks.read` is responsible for\n * producing the file contents and `hooks.write` will be used by the write APIs\n * once they are implemented.\n *\n * Parsed records are cached in memory per client. The first query loads and\n * parses the file; later queries reuse that snapshot. {@link TodoTxtClient.all}\n * always reads fresh contents and replaces the cache, so it can be used to\n * refresh after the underlying file changes.\n *\n * Every line is parsed into a {@link TodoRecord} when the cache is populated.\n * Filters such as {@link TodoQuery.pending} and {@link TodoQuery.project}\n * operate on that array of JSON records, and plucks such as\n * {@link TodoQuery.projects} return unique, alphabetically sorted names.\n * Returned records are copies, so callers may mutate them without affecting the\n * cache.\n */\nexport function createTodoTxt(hooks: TodoFileHooks): TodoTxtClient {\n let cache: TodoRecord[] | undefined;\n let inFlight: Promise<TodoRecord[]> | undefined;\n let generation = 0;\n\n const readFresh = async (): Promise<TodoRecord[]> => {\n const currentGeneration = ++generation;\n const records = parseDocument(await hooks.read());\n\n if (currentGeneration === generation) {\n cache = records;\n }\n\n return records;\n };\n\n const refresh = (): Promise<TodoRecord[]> => {\n const promise = readFresh();\n inFlight = promise;\n\n void promise\n .finally(() => {\n if (inFlight === promise) {\n inFlight = undefined;\n }\n })\n .catch(() => {});\n\n return promise;\n };\n\n const loadCached = (): Promise<TodoRecord[]> => {\n if (inFlight) {\n return inFlight;\n }\n\n if (cache) {\n return Promise.resolve(cache);\n }\n\n return refresh();\n };\n\n const all = async (): Promise<TodoRecord[]> =>\n cloneRecords(await refresh());\n\n const query = createTodoQuery(loadCached);\n\n return {\n all,\n pending: query.pending,\n completed: query.completed,\n project: query.project,\n context: query.context,\n projects: query.projects,\n contexts: query.contexts,\n };\n}\n"],"mappings":";;AAGA,SAAgB,YAAY,MAA8B;CACxD,OAAO;EACL,WAAW,KAAK;EAChB,UAAU,KAAK;EACf,aAAa,KAAK;EAClB,WAAW,KAAK;EAChB,aAAa,KAAK;EAClB,UAAU,CAAC,GAAG,KAAK,QAAQ;EAC3B,UAAU,CAAC,GAAG,KAAK,QAAQ;EAC3B,MAAM,EAAE,GAAG,KAAK,KAAK;CACvB;AACF;;AAGA,SAAgB,aAAa,SAA8C;CACzE,OAAO,QAAQ,IAAI,WAAW;AAChC;;ACnBA,MAAM,oBAAoB;AAc1B,SAAS,SAAS,MAAwB;CACxC,MAAM,UAAU,KAAK,KAAK;CAC1B,IAAI,YAAY,IACd,OAAO,CAAC;CAGV,OAAO,QAAQ,MAAM,KAAK;AAC5B;;;;;;;AA2BA,SAAgB,UAAU,MAAwB;CAChD,MAAM,WAAqB,CAAC;CAC5B,MAAM,WAAqB,CAAC;CAC5B,MAAM,OAA+B,CAAC;CACtC,MAAM,oBAA8B,CAAC;CAErC,KAAK,MAAM,SAAS,SAAS,IAAI,GAAG;EAClC,IAAI,MAAM,WAAW,GAAG,KAAK,MAAM,SAAS,GAAG;GAC7C,SAAS,KAAK,MAAM,MAAM,CAAC,CAAC;GAC5B;EACF;EAEA,IAAI,MAAM,WAAW,GAAG,KAAK,MAAM,SAAS,GAAG;GAC7C,SAAS,KAAK,MAAM,MAAM,CAAC,CAAC;GAC5B;EACF;EAEA,MAAM,YAAY,kBAAkB,KAAK,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cAAc,OAAqC;CACjE,IAAI;CACJ,IAAI;CACJ,IAAI,aAAa;CAEjB,MAAM,YAAY,YAAmC;EACnD,MAAM,oBAAoB,EAAE;EAC5B,MAAM,UAAU,cAAc,MAAM,MAAM,KAAK,CAAC;EAEhD,IAAI,sBAAsB,YACxB,QAAQ;EAGV,OAAO;CACT;CAEA,MAAM,gBAAuC;EAC3C,MAAM,UAAU,UAAU;EAC1B,WAAW;EAEX,QACG,cAAc;GACb,IAAI,aAAa,SACf,WAAW,KAAA;EAEf,CAAC,CAAC,CACD,YAAY,CAAC,CAAC;EAEjB,OAAO;CACT;CAEA,MAAM,mBAA0C;EAC9C,IAAI,UACF,OAAO;EAGT,IAAI,OACF,OAAO,QAAQ,QAAQ,KAAK;EAG9B,OAAO,QAAQ;CACjB;CAEA,MAAM,MAAM,YACV,aAAa,MAAM,QAAQ,CAAC;CAE9B,MAAM,QAAQ,gBAAgB,UAAU;CAExC,OAAO;EACL;EACA,SAAS,MAAM;EACf,WAAW,MAAM;EACjB,SAAS,MAAM;EACf,SAAS,MAAM;EACf,UAAU,MAAM;EAChB,UAAU,MAAM;CAClB;AACF"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/clone.ts","../src/metadata.ts","../src/parse.ts","../src/query.ts","../src/client.ts"],"sourcesContent":["import type { TodoRecord } from \"./types.ts\";\n\n/** Copy a record so callers cannot mutate the client's cached snapshot. */\nexport function cloneRecord(todo: TodoRecord): TodoRecord {\n return {\n completed: todo.completed,\n priority: todo.priority,\n completedAt: todo.completedAt,\n createdAt: todo.createdAt,\n description: todo.description,\n projects: [...todo.projects],\n contexts: [...todo.contexts],\n data: { ...todo.data },\n };\n}\n\n/** Copy every record in `records`. */\nexport function cloneRecords(records: readonly TodoRecord[]): TodoRecord[] {\n return records.map(cloneRecord);\n}\n","import type { ParseWarningHandler } from \"./types.ts\";\n\nconst EXTENSION_PATTERN = /^([^:\\s]+):([^:\\s]+)$/;\n\n/** Metadata collected from a task's text. */\nexport interface TodoMetadata {\n projects: string[];\n contexts: string[];\n data: Record<string, string>;\n}\n\n/** Everything derived from a task's text in one token pass. */\nexport interface TodoText extends TodoMetadata {\n description: string;\n}\n\nfunction tokenize(text: string): string[] {\n const trimmed = text.trim();\n if (trimmed === \"\") {\n return [];\n }\n\n return trimmed.split(/\\s+/);\n}\n\n/**\n * True when a whitespace-delimited token is inline metadata.\n *\n * Inline metadata is a project (`+name`), a context (`@name`), or a\n * `key:value` extension. Bare `+`/`@` tokens and values containing another\n * colon are not metadata.\n */\nexport function isMetadataToken(token: string): boolean {\n if (token.startsWith(\"+\") && token.length > 1) {\n return true;\n }\n\n if (token.startsWith(\"@\") && token.length > 1) {\n return true;\n }\n\n return EXTENSION_PATTERN.test(token);\n}\n\n/**\n * Collect a task's description, projects, contexts, and extensions in one pass.\n *\n * Previous versions tokenized the text once for metadata and again to strip it;\n * doing both here keeps parsing to a single split per line.\n *\n * When a `key:value` key is repeated, `onWarning` receives a\n * `duplicate-metadata-key` warning and the last value wins.\n */\nexport function parseText(\n text: string,\n onWarning?: ParseWarningHandler,\n): TodoText {\n const projects: string[] = [];\n const contexts: string[] = [];\n const data: Record<string, string> = {};\n const descriptionTokens: string[] = [];\n\n for (const token of tokenize(text)) {\n if (token.startsWith(\"+\") && token.length > 1) {\n projects.push(token.slice(1));\n continue;\n }\n\n if (token.startsWith(\"@\") && token.length > 1) {\n contexts.push(token.slice(1));\n continue;\n }\n\n const extension = EXTENSION_PATTERN.exec(token);\n const key = extension?.[1];\n const value = extension?.[2];\n if (key !== undefined && value !== undefined) {\n if (Object.hasOwn(data, key)) {\n onWarning?.({\n code: \"duplicate-metadata-key\",\n message: `Duplicate metadata key \"${key}\"; the last value wins.`,\n meta: { key, previousValue: data[key], value },\n });\n }\n\n data[key] = value;\n continue;\n }\n\n descriptionTokens.push(token);\n }\n\n return {\n description: descriptionTokens.join(\" \"),\n projects,\n contexts,\n data,\n };\n}\n\n/** Collect projects, contexts, and extensions from task text. */\nexport function parseMetadata(text: string): TodoMetadata {\n const { projects, contexts, data } = parseText(text);\n return { projects, contexts, data };\n}\n\n/**\n * Remove inline metadata from task text.\n *\n * Remaining tokens are rejoined with single spaces, so repeated whitespace can\n * be normalized.\n */\nexport function stripMetadata(text: string): string {\n return parseText(text).description;\n}\n","import { parseText } from \"./metadata.ts\";\nimport type { ParseWarningHandler, TodoRecord } from \"./types.ts\";\n\nconst PRIORITY_PATTERN = /^\\(([A-Z])\\) /;\nconst LEADING_DATE_PATTERN = /^(\\d{4}-\\d{2}-\\d{2})(?: |$)/;\n\n/**\n * Consume a `YYYY-MM-DD` date from the start of `input`.\n *\n * Only the shape is validated; the date does not have to exist on a calendar\n * (matching the literal format rules).\n */\nfunction takeLeadingDate(input: string): [date: string | null, rest: string] {\n const match = LEADING_DATE_PATTERN.exec(input);\n if (!match) {\n return [null, input];\n }\n\n const date = match[1];\n if (date === undefined) {\n return [null, input];\n }\n\n return [date, input.slice(match[0]!.length)];\n}\n\n/**\n * Parse a single todo.txt line directly into a JSON-friendly {@link TodoRecord}.\n *\n * The parser follows the todo.txt format rules:\n *\n * - Completed tasks start with `x `, optionally followed by a completion date\n * and then a creation date.\n * - Incomplete tasks may start with an `(A)`–`(Z)` priority and an optional\n * creation date.\n * - Projects, contexts, and `key:value` metadata may appear anywhere in the\n * remaining text.\n *\n * Recoverable issues are reported to `onWarning` when supplied; parsing still\n * produces a record.\n */\nexport function parseLine(\n line: string,\n onWarning?: ParseWarningHandler,\n): TodoRecord {\n let rest = line;\n let completed = false;\n let priority: string | null = null;\n let completedAt: string | null = null;\n let createdAt: string | null = null;\n\n if (rest.startsWith(\"x \")) {\n completed = true;\n rest = rest.slice(2);\n [completedAt, rest] = takeLeadingDate(rest);\n [createdAt, rest] = takeLeadingDate(rest);\n } else {\n const priorityMatch = PRIORITY_PATTERN.exec(rest);\n if (priorityMatch) {\n priority = priorityMatch[1]!;\n rest = rest.slice(priorityMatch[0]!.length);\n }\n\n [createdAt, rest] = takeLeadingDate(rest);\n }\n\n const text = rest.trim();\n const { description, projects, contexts, data } = parseText(text, onWarning);\n\n return {\n completed,\n priority,\n completedAt,\n createdAt,\n description,\n projects,\n contexts,\n data,\n };\n}\n\n/**\n * Parse the contents of a todo.txt file.\n *\n * Lines are split on `\\n` or `\\r\\n`; blank and whitespace-only lines are\n * skipped. Every remaining line becomes a {@link TodoRecord}. Warnings are\n * annotated with the 1-based physical line number.\n */\nexport function parseDocument(\n contents: string,\n onWarning?: ParseWarningHandler,\n): TodoRecord[] {\n const records: TodoRecord[] = [];\n let lineNumber = 0;\n\n for (const line of contents.split(/\\r?\\n/)) {\n lineNumber += 1;\n\n if (line.trim() !== \"\") {\n records.push(\n parseLine(\n line,\n onWarning\n ? (warning) => onWarning({ ...warning, line: lineNumber })\n : undefined,\n ),\n );\n }\n }\n\n return records;\n}\n","import { cloneRecords } from \"./clone.ts\";\nimport type { TodoRecord } from \"./types.ts\";\n\n/** A predicate applied to every record in a query. */\nexport type TodoFilter = (todo: TodoRecord) => boolean;\n\n/** Loads and parses every todo.txt record. */\nexport type LoadRecords = () => Promise<TodoRecord[]>;\n\n/**\n * A lazy query over parsed todo records.\n *\n * Filters return a new query and perform no IO. Awaiting a query resolves\n * through the supplied loader; the client caches parsed records, so only the\n * first query reads the file. {@link TodoQuery.projects} and\n * {@link TodoQuery.contexts} are terminal plucks that resolve to unique,\n * alphabetically sorted names.\n */\nexport interface TodoQuery extends PromiseLike<TodoRecord[]> {\n /** Only records that are not completed. */\n pending: () => TodoQuery;\n /** Only records that are completed. */\n completed: () => TodoQuery;\n /** Only records tagged with the project `name`. */\n project: (name: string) => TodoQuery;\n /** Only records tagged with the context `name`. */\n context: (name: string) => TodoQuery;\n /** Unique project names in the current result, alphabetically sorted. */\n projects: () => Promise<string[]>;\n /** Unique context names in the current result, alphabetically sorted. */\n contexts: () => Promise<string[]>;\n}\n\nfunction uniqueSorted(values: string[]): string[] {\n return [...new Set(values)].sort();\n}\n\nasync function resolveRaw(\n load: LoadRecords,\n filters: TodoFilter[],\n): Promise<TodoRecord[]> {\n const records = await load();\n\n if (filters.length === 0) {\n return records;\n }\n\n return records.filter((record) =>\n filters.every((filter) => filter(record)),\n );\n}\n\nasync function resolveRecords(\n load: LoadRecords,\n filters: TodoFilter[],\n): Promise<TodoRecord[]> {\n return cloneRecords(await resolveRaw(load, filters));\n}\n\nfunction pluckNames(\n load: LoadRecords,\n filters: TodoFilter[],\n pick: (todo: TodoRecord) => string[],\n): Promise<string[]> {\n return resolveRaw(load, filters).then((records) =>\n uniqueSorted(records.flatMap(pick)),\n );\n}\n\n/**\n * Create a lazy query over the records loaded by `load`.\n *\n * Each filter method appends a predicate, so chained calls compose. For\n * example, `pending().completed()` matches nothing, while\n * `project(\"Work\").pending()` matches pending records in `Work`.\n */\nexport function createTodoQuery(\n load: LoadRecords,\n filters: TodoFilter[] = [],\n): TodoQuery {\n return {\n pending: () =>\n createTodoQuery(load, [...filters, (todo) => !todo.completed]),\n completed: () =>\n createTodoQuery(load, [...filters, (todo) => todo.completed]),\n project: (name) =>\n createTodoQuery(load, [\n ...filters,\n (todo) => todo.projects.includes(name),\n ]),\n context: (name) =>\n createTodoQuery(load, [\n ...filters,\n (todo) => todo.contexts.includes(name),\n ]),\n projects: () => pluckNames(load, filters, (todo) => todo.projects),\n contexts: () => pluckNames(load, filters, (todo) => todo.contexts),\n then: (onfulfilled, onrejected) =>\n resolveRecords(load, filters).then(onfulfilled, onrejected),\n };\n}\n","import { cloneRecords } from \"./clone.ts\";\nimport { parseDocument } from \"./parse.ts\";\nimport { createTodoQuery } from \"./query.ts\";\nimport type { TodoQuery } from \"./query.ts\";\nimport type { TodoHooks, TodoLogger, TodoRecord } from \"./types.ts\";\n\n/** The read interface returned by {@link createTodoTxt}. */\nexport interface TodoTxtClient {\n /** Read fresh todo.txt contents, replace the cache, and return every record. */\n all: () => Promise<TodoRecord[]>;\n /** Query only records that are not completed, using the cached snapshot. */\n pending: () => TodoQuery;\n /** Query only records that are completed, using the cached snapshot. */\n completed: () => TodoQuery;\n /** Query records tagged with a single project name, using the cache. */\n project: (name: string) => TodoQuery;\n /** Query records tagged with a single context name, using the cache. */\n context: (name: string) => TodoQuery;\n /** List unique project names from the cached snapshot, alphabetically sorted. */\n projects: () => Promise<string[]>;\n /** List unique context names from the cached snapshot, alphabetically sorted. */\n contexts: () => Promise<string[]>;\n}\n\n/**\n * Create a todo.txt client backed by consumer-supplied file hooks.\n *\n * The library performs no IO of its own: `hooks.read` is responsible for\n * producing the file contents and `hooks.write` will be used by the write APIs\n * once they are implemented. `hooks.logger` is optional and silent by default;\n * when supplied, it receives read lifecycle and parse warning diagnostics.\n *\n * Parsed records are cached in memory per client. The first query loads and\n * parses the file; later queries reuse that snapshot. {@link TodoTxtClient.all}\n * always reads fresh contents and replaces the cache, so it can be used to\n * refresh after the underlying file changes.\n *\n * Every line is parsed into a {@link TodoRecord} when the cache is populated.\n * Filters such as {@link TodoQuery.pending} and {@link TodoQuery.project}\n * operate on that array of JSON records, and plucks such as\n * {@link TodoQuery.projects} return unique, alphabetically sorted names.\n * Returned records are copies, so callers may mutate them without affecting the\n * cache.\n */\nexport function createTodoTxt(hooks: TodoHooks): TodoTxtClient {\n let cache: TodoRecord[] | undefined;\n let inFlight: Promise<TodoRecord[]> | undefined;\n let generation = 0;\n\n const logger = hooks.logger;\n\n const log: TodoLogger = (level, message, meta) => {\n if (!logger) {\n return;\n }\n\n try {\n const result = logger(level, message, meta);\n\n if (\n result &&\n typeof (result as PromiseLike<unknown>).then === \"function\"\n ) {\n void Promise.resolve(result).catch(() => {});\n }\n } catch {\n // Logging is best-effort and must never break reads or queries.\n }\n };\n\n const readFresh = async (): Promise<TodoRecord[]> => {\n const currentGeneration = ++generation;\n\n log(\"debug\", \"Reading todo file\");\n const contents = await hooks.read();\n const records = parseDocument(contents, (warning) => {\n log(\"warn\", warning.message, {\n ...warning.meta,\n code: warning.code,\n line: warning.line,\n });\n });\n log(\"debug\", \"Parsed todo file\", { records: records.length });\n\n if (currentGeneration === generation) {\n cache = records;\n }\n\n return records;\n };\n\n const refresh = (): Promise<TodoRecord[]> => {\n const promise = readFresh();\n inFlight = promise;\n\n void promise\n .finally(() => {\n if (inFlight === promise) {\n inFlight = undefined;\n }\n })\n .catch(() => {});\n\n return promise;\n };\n\n const loadCached = (): Promise<TodoRecord[]> => {\n if (inFlight) {\n return inFlight;\n }\n\n if (cache) {\n return Promise.resolve(cache);\n }\n\n return refresh();\n };\n\n const all = async (): Promise<TodoRecord[]> =>\n cloneRecords(await refresh());\n\n const query = createTodoQuery(loadCached);\n\n return {\n all,\n pending: query.pending,\n completed: query.completed,\n project: query.project,\n context: query.context,\n projects: query.projects,\n contexts: query.contexts,\n };\n}\n"],"mappings":";;AAGA,SAAgB,YAAY,MAA8B;CACxD,OAAO;EACL,WAAW,KAAK;EAChB,UAAU,KAAK;EACf,aAAa,KAAK;EAClB,WAAW,KAAK;EAChB,aAAa,KAAK;EAClB,UAAU,CAAC,GAAG,KAAK,QAAQ;EAC3B,UAAU,CAAC,GAAG,KAAK,QAAQ;EAC3B,MAAM,EAAE,GAAG,KAAK,KAAK;CACvB;AACF;;AAGA,SAAgB,aAAa,SAA8C;CACzE,OAAO,QAAQ,IAAI,WAAW;AAChC;;ACjBA,MAAM,oBAAoB;AAc1B,SAAS,SAAS,MAAwB;CACxC,MAAM,UAAU,KAAK,KAAK;CAC1B,IAAI,YAAY,IACd,OAAO,CAAC;CAGV,OAAO,QAAQ,MAAM,KAAK;AAC5B;;;;;;;;;;AA8BA,SAAgB,UACd,MACA,WACU;CACV,MAAM,WAAqB,CAAC;CAC5B,MAAM,WAAqB,CAAC;CAC5B,MAAM,OAA+B,CAAC;CACtC,MAAM,oBAA8B,CAAC;CAErC,KAAK,MAAM,SAAS,SAAS,IAAI,GAAG;EAClC,IAAI,MAAM,WAAW,GAAG,KAAK,MAAM,SAAS,GAAG;GAC7C,SAAS,KAAK,MAAM,MAAM,CAAC,CAAC;GAC5B;EACF;EAEA,IAAI,MAAM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MAAM,mBAA0C;EAC9C,IAAI,UACF,OAAO;EAGT,IAAI,OACF,OAAO,QAAQ,QAAQ,KAAK;EAG9B,OAAO,QAAQ;CACjB;CAEA,MAAM,MAAM,YACV,aAAa,MAAM,QAAQ,CAAC;CAE9B,MAAM,QAAQ,gBAAgB,UAAU;CAExC,OAAO;EACL;EACA,SAAS,MAAM;EACf,WAAW,MAAM;EACjB,SAAS,MAAM;EACf,SAAS,MAAM;EACf,UAAU,MAAM;EAChB,UAAU,MAAM;CAClB;AACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jibone/todotxt-core",
3
- "version": "0.1.1",
3
+ "version": "0.2.0",
4
4
  "description": "Parse and query todo.txt files with runtime-agnostic file hooks.",
5
5
  "license": "MIT",
6
6
  "author": "J Shamsul Bahri",