@equt/clis 0.1.24 → 0.1.25
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.
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"add.d.ts","sourceRoot":"","sources":["../../../src/recurring/commands/add.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAQxC,wBAAgB,WAAW,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CA6ClD"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import process from 'node:process';
|
|
2
|
+
import { format } from 'date-fns';
|
|
3
|
+
import { renderTable, renderYaml } from '../../bookkeeping/output.js';
|
|
4
|
+
import { createClient, DB } from '../client.js';
|
|
5
|
+
const VALID_UNITS = ['Day', 'Month', 'Year'];
|
|
6
|
+
export function registerAdd(program) {
|
|
7
|
+
program
|
|
8
|
+
.command('add <name>')
|
|
9
|
+
.description('Add a new recurring item.')
|
|
10
|
+
.requiredOption('-a, --amount <number>', 'Recurrence interval amount', Number)
|
|
11
|
+
.requiredOption('-u, --unit <unit>', 'Recurrence interval unit (Day, Month, Year)')
|
|
12
|
+
.option('-t, --today', 'Set the "Use Today" flag', false)
|
|
13
|
+
.action(async (name, opts) => {
|
|
14
|
+
const yaml = program.opts().yaml;
|
|
15
|
+
if (!Number.isInteger(opts.amount) || opts.amount <= 0) {
|
|
16
|
+
console.error(`Invalid amount: ${opts.amount}`);
|
|
17
|
+
process.exit(1);
|
|
18
|
+
}
|
|
19
|
+
const unit = VALID_UNITS.find(u => u.toLowerCase() === opts.unit.toLowerCase());
|
|
20
|
+
if (!unit) {
|
|
21
|
+
console.error(`Invalid unit: ${opts.unit}. Must be one of: ${VALID_UNITS.join(', ')}`);
|
|
22
|
+
process.exit(1);
|
|
23
|
+
}
|
|
24
|
+
const client = createClient();
|
|
25
|
+
const next = format(new Date(), 'yyyy-MM-dd');
|
|
26
|
+
const page = await client.pages.create({
|
|
27
|
+
parent: { database_id: DB.Recurring },
|
|
28
|
+
properties: {
|
|
29
|
+
'Name': { title: [{ text: { content: name } }] },
|
|
30
|
+
'Amount': { number: opts.amount },
|
|
31
|
+
'Unit': { select: { name: unit } },
|
|
32
|
+
'Next': { date: { start: next } },
|
|
33
|
+
'Use Today': { checkbox: opts.today },
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
if (yaml) {
|
|
37
|
+
renderYaml({ id: page.id, name, next, amount: opts.amount, unit, useToday: opts.today });
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
renderTable(['ID', 'Name', 'Next', 'Amount', 'Unit', 'Use Today'], [[page.id, name, next, String(opts.amount), unit, opts.today ? 'Yes' : 'No']]);
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=add.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"add.js","sourceRoot":"","sources":["../../../src/recurring/commands/add.ts"],"names":[],"mappings":"AACA,OAAO,OAAO,MAAM,cAAc,CAAA;AAClC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AACjC,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAA;AACrE,OAAO,EAAE,YAAY,EAAE,EAAE,EAAE,MAAM,cAAc,CAAA;AAE/C,MAAM,WAAW,GAAG,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,CAAU,CAAA;AAErD,MAAM,UAAU,WAAW,CAAC,OAAgB;IAC1C,OAAO;SACJ,OAAO,CAAC,YAAY,CAAC;SACrB,WAAW,CAAC,2BAA2B,CAAC;SACxC,cAAc,CAAC,uBAAuB,EAAE,4BAA4B,EAAE,MAAM,CAAC;SAC7E,cAAc,CAAC,mBAAmB,EAAE,6CAA6C,CAAC;SAClF,MAAM,CAAC,aAAa,EAAE,0BAA0B,EAAE,KAAK,CAAC;SACxD,MAAM,CAAC,KAAK,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BAClC,MAAM,EAAE,EAAE,IAAI,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE;gBACjC,WAAW,EAAE,EAAE,QAAQ,EAAE,IAAI,CAAC,KAAK,EAAE;aACqB;SAC7D,CAAC,CAAA;QAEF,IAAI,IAAI,EAAE,CAAC;YACT,UAAU,CAAC,EAAE,EAAE,EAAE,IAAI,CAAC,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC,CAAA;QAC1F,CAAC;aACI,CAAC;YACJ,WAAW,CACT,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,WAAW,CAAC,EACrD,CAAC,CAAC,IAAI,CAAC,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAC9E,CAAA;QACH,CAAC;IACH,CAAC,CAAC,CAAA;AACN,CAAC"}
|
package/dist/recurring/index.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import process from 'node:process';
|
|
3
3
|
import { APIResponseError } from '@notionhq/client';
|
|
4
4
|
import { program } from 'commander';
|
|
5
|
+
import { registerAdd } from './commands/add.js';
|
|
5
6
|
import { registerComplete } from './commands/complete.js';
|
|
6
7
|
import { registerList } from './commands/list.js';
|
|
7
8
|
program
|
|
@@ -14,6 +15,7 @@ program
|
|
|
14
15
|
+ ' RECURRING_TOKEN Notion integration token (required)')
|
|
15
16
|
.option('--yaml', 'Emit YAML instead of a formatted table');
|
|
16
17
|
registerList(program);
|
|
18
|
+
registerAdd(program);
|
|
17
19
|
registerComplete(program);
|
|
18
20
|
program.parseAsync(process.argv).catch((err) => {
|
|
19
21
|
if (APIResponseError.isAPIResponseError(err)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/recurring/index.ts"],"names":[],"mappings":";AACA,OAAO,OAAO,MAAM,cAAc,CAAA;AAClC,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAA;AACnD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAEjD,OAAO;KACJ,IAAI,CAAC,WAAW,CAAC;KACjB,WAAW,CACV,oDAAoD;MAClD,4EAA4E;MAC5E,8EAA8E;MAC9E,qDAAqD;MACrD,0BAA0B;MAC1B,wDAAwD,CAC3D;KACA,MAAM,CAAC,QAAQ,EAAE,wCAAwC,CAAC,CAAA;AAE7D,YAAY,CAAC,OAAO,CAAC,CAAA;AACrB,gBAAgB,CAAC,OAAO,CAAC,CAAA;AAEzB,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;IAC7C,IAAI,gBAAgB,CAAC,kBAAkB,CAAC,GAAG,CAAC,EAAE,CAAC;QAC7C,OAAO,CAAC,KAAK,CAAC,oBAAoB,GAAG,CAAC,MAAM,KAAK,GAAG,CAAC,OAAO,EAAE,CAAC,CAAA;IACjE,CAAC;SACI,IAAI,GAAG,YAAY,KAAK,EAAE,CAAC;QAC9B,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,CAAA;IAC5B,CAAC;SACI,CAAC;QACJ,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAA;IAC5B,CAAC;IACD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;AACjB,CAAC,CAAC,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"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