@equt/clis 0.1.21 → 0.1.22
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/dist/relations/client.d.ts +8 -0
- package/dist/relations/client.d.ts.map +1 -0
- package/dist/relations/client.js +9 -0
- package/dist/relations/client.js.map +1 -0
- package/dist/relations/commands/add.d.ts +3 -0
- package/dist/relations/commands/add.d.ts.map +1 -0
- package/dist/relations/commands/add.js +27 -0
- package/dist/relations/commands/add.js.map +1 -0
- package/dist/relations/commands/list.d.ts +3 -0
- package/dist/relations/commands/list.d.ts.map +1 -0
- package/dist/relations/commands/list.js +32 -0
- package/dist/relations/commands/list.js.map +1 -0
- package/dist/relations/index.d.ts +3 -0
- package/dist/relations/index.d.ts.map +1 -0
- package/dist/relations/index.js +25 -0
- package/dist/relations/index.js.map +1 -0
- package/dist/relations/props.d.ts +5 -0
- package/dist/relations/props.d.ts.map +1 -0
- package/dist/relations/props.js +8 -0
- package/dist/relations/props.js.map +1 -0
- package/package.json +3 -2
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Client } from '@notionhq/client';
|
|
2
|
+
import { queryAll } from '../notion/client.js';
|
|
3
|
+
export declare const DB: {
|
|
4
|
+
readonly Relations: "516144d9-6855-467c-a6de-acf915fc30ee";
|
|
5
|
+
};
|
|
6
|
+
export declare function createClient(): Client;
|
|
7
|
+
export { queryAll };
|
|
8
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/relations/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AAC9C,OAAO,EAAsC,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AAElF,eAAO,MAAM,EAAE;;CAEL,CAAA;AAEV,wBAAgB,YAAY,IAAI,MAAM,CAErC;AAED,OAAO,EAAE,QAAQ,EAAE,CAAA"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { createClient as createNotionClient, queryAll } from '../notion/client.js';
|
|
2
|
+
export const DB = {
|
|
3
|
+
Relations: '516144d9-6855-467c-a6de-acf915fc30ee',
|
|
4
|
+
};
|
|
5
|
+
export function createClient() {
|
|
6
|
+
return createNotionClient('RELATIONS_TOKEN');
|
|
7
|
+
}
|
|
8
|
+
export { queryAll };
|
|
9
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/relations/client.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,IAAI,kBAAkB,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AAElF,MAAM,CAAC,MAAM,EAAE,GAAG;IAChB,SAAS,EAAE,sCAAsC;CACzC,CAAA;AAEV,MAAM,UAAU,YAAY;IAC1B,OAAO,kBAAkB,CAAC,iBAAiB,CAAC,CAAA;AAC9C,CAAC;AAED,OAAO,EAAE,QAAQ,EAAE,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"add.d.ts","sourceRoot":"","sources":["../../../src/relations/commands/add.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAIxC,wBAAgB,WAAW,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CA2BlD"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import process from 'node:process';
|
|
2
|
+
import { createClient, DB } from '../client.js';
|
|
3
|
+
export function registerAdd(program) {
|
|
4
|
+
program
|
|
5
|
+
.command('add <name>')
|
|
6
|
+
.description('Add a new relation')
|
|
7
|
+
.option('-t, --tag <tag...>', 'Tags to assign')
|
|
8
|
+
.action(async (name, opts) => {
|
|
9
|
+
const client = createClient();
|
|
10
|
+
const properties = {
|
|
11
|
+
Name: {
|
|
12
|
+
title: [{ text: { content: name } }],
|
|
13
|
+
},
|
|
14
|
+
};
|
|
15
|
+
if (opts.tag && opts.tag.length > 0) {
|
|
16
|
+
properties.Tag = {
|
|
17
|
+
multi_select: opts.tag.map(t => ({ name: t })),
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
const created = await client.pages.create({
|
|
21
|
+
parent: { type: 'data_source_id', data_source_id: DB.Relations },
|
|
22
|
+
properties: properties,
|
|
23
|
+
});
|
|
24
|
+
process.stdout.write(`${created.id}\n`);
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=add.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"add.js","sourceRoot":"","sources":["../../../src/relations/commands/add.ts"],"names":[],"mappings":"AACA,OAAO,OAAO,MAAM,cAAc,CAAA;AAClC,OAAO,EAAE,YAAY,EAAE,EAAE,EAAE,MAAM,cAAc,CAAA;AAE/C,MAAM,UAAU,WAAW,CAAC,OAAgB;IAC1C,OAAO;SACJ,OAAO,CAAC,YAAY,CAAC;SACrB,WAAW,CAAC,oBAAoB,CAAC;SACjC,MAAM,CAAC,oBAAoB,EAAE,gBAAgB,CAAC;SAC9C,MAAM,CAAC,KAAK,EAAE,IAAY,EAAE,IAAwB,EAAE,EAAE;QACvD,MAAM,MAAM,GAAG,YAAY,EAAE,CAAA;QAE7B,MAAM,UAAU,GAA4B;YAC1C,IAAI,EAAE;gBACJ,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,CAAC;aACrC;SACF,CAAA;QAED,IAAI,IAAI,CAAC,GAAG,IAAI,IAAI,CAAC,GAAG,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACpC,UAAU,CAAC,GAAG,GAAG;gBACf,YAAY,EAAE,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC;aAC/C,CAAA;QACH,CAAC;QAED,MAAM,OAAO,GAAG,MAAM,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC;YACxC,MAAM,EAAE,EAAE,IAAI,EAAE,gBAAgB,EAAE,cAAc,EAAE,EAAE,CAAC,SAAS,EAAE;YAChE,UAAU,EAAE,UAAqE;SAClF,CAAC,CAAA;QAEF,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,OAAO,CAAC,EAAE,IAAI,CAAC,CAAA;IACzC,CAAC,CAAC,CAAA;AACN,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../../src/relations/commands/list.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAKxC,wBAAgB,YAAY,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAiCnD"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { renderTable, renderYaml } from '../../bookkeeping/output.js';
|
|
2
|
+
import { createClient, DB, queryAll } from '../client.js';
|
|
3
|
+
import { extractMultiSelect, extractTitle } from '../props.js';
|
|
4
|
+
export function registerList(program) {
|
|
5
|
+
program
|
|
6
|
+
.command('list', { isDefault: true })
|
|
7
|
+
.description('List relations filtered by tag')
|
|
8
|
+
.requiredOption('-t, --tag <tag>', 'Tag to filter by')
|
|
9
|
+
.action(async (opts) => {
|
|
10
|
+
const yaml = program.opts().yaml;
|
|
11
|
+
const client = createClient();
|
|
12
|
+
const pages = await queryAll(client, {
|
|
13
|
+
data_source_id: DB.Relations,
|
|
14
|
+
filter: {
|
|
15
|
+
property: 'Tag',
|
|
16
|
+
multi_select: { contains: opts.tag },
|
|
17
|
+
},
|
|
18
|
+
});
|
|
19
|
+
const items = pages.map(page => ({
|
|
20
|
+
id: page.id,
|
|
21
|
+
name: extractTitle(page.properties.Name),
|
|
22
|
+
tag: extractMultiSelect(page.properties.Tag),
|
|
23
|
+
}));
|
|
24
|
+
if (yaml) {
|
|
25
|
+
renderYaml(items);
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
renderTable(['ID', 'Name', 'Tag'], items.map(i => [i.id, i.name, i.tag.join(', ')]));
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=list.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list.js","sourceRoot":"","sources":["../../../src/relations/commands/list.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAA;AACrE,OAAO,EAAE,YAAY,EAAE,EAAE,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAA;AACzD,OAAO,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE9D,MAAM,UAAU,YAAY,CAAC,OAAgB;IAC3C,OAAO;SACJ,OAAO,CAAC,MAAM,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;SACpC,WAAW,CAAC,gCAAgC,CAAC;SAC7C,cAAc,CAAC,iBAAiB,EAAE,kBAAkB,CAAC;SACrD,MAAM,CAAC,KAAK,EAAE,IAAqB,EAAE,EAAE;QACtC,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,EAAqB,CAAC,IAAI,CAAA;QACnD,MAAM,MAAM,GAAG,YAAY,EAAE,CAAA;QAE7B,MAAM,KAAK,GAAG,MAAM,QAAQ,CAAC,MAAM,EAAE;YACnC,cAAc,EAAE,EAAE,CAAC,SAAS;YAC5B,MAAM,EAAE;gBACN,QAAQ,EAAE,KAAK;gBACf,YAAY,EAAE,EAAE,QAAQ,EAAE,IAAI,CAAC,GAAG,EAAE;aACrC;SACF,CAAC,CAAA;QAEF,MAAM,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YAC/B,EAAE,EAAE,IAAI,CAAC,EAAE;YACX,IAAI,EAAE,YAAY,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC;YACxC,GAAG,EAAE,kBAAkB,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC;SAC7C,CAAC,CAAC,CAAA;QAEH,IAAI,IAAI,EAAE,CAAC;YACT,UAAU,CAAC,KAAK,CAAC,CAAA;QACnB,CAAC;aACI,CAAC;YACJ,WAAW,CACT,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,EACrB,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CACjD,CAAA;QACH,CAAC;IACH,CAAC,CAAC,CAAA;AACN,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/relations/index.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import process from 'node:process';
|
|
3
|
+
import { APIResponseError } from '@notionhq/client';
|
|
4
|
+
import { program } from 'commander';
|
|
5
|
+
import { registerAdd } from './commands/add.js';
|
|
6
|
+
import { registerList } from './commands/list.js';
|
|
7
|
+
program
|
|
8
|
+
.name('relations')
|
|
9
|
+
.description('Manage personal relations backed by Notion')
|
|
10
|
+
.option('--yaml', 'Emit YAML instead of a formatted table');
|
|
11
|
+
registerList(program);
|
|
12
|
+
registerAdd(program);
|
|
13
|
+
program.parseAsync(process.argv).catch((err) => {
|
|
14
|
+
if (APIResponseError.isAPIResponseError(err)) {
|
|
15
|
+
console.error(`Notion API error ${err.status}: ${err.message}`);
|
|
16
|
+
}
|
|
17
|
+
else if (err instanceof Error) {
|
|
18
|
+
console.error(err.message);
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
console.error(String(err));
|
|
22
|
+
}
|
|
23
|
+
process.exit(1);
|
|
24
|
+
});
|
|
25
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/relations/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,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAEjD,OAAO;KACJ,IAAI,CAAC,WAAW,CAAC;KACjB,WAAW,CAAC,4CAA4C,CAAC;KACzD,MAAM,CAAC,QAAQ,EAAE,wCAAwC,CAAC,CAAA;AAE7D,YAAY,CAAC,OAAO,CAAC,CAAA;AACrB,WAAW,CAAC,OAAO,CAAC,CAAA;AAEpB,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"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { PageObjectResponse } from '@notionhq/client/build/src/api-endpoints.js';
|
|
2
|
+
export { extractTitle } from '../bookkeeping/props.js';
|
|
3
|
+
type PageProp = PageObjectResponse['properties'][string];
|
|
4
|
+
export declare function extractMultiSelect(prop: PageProp | undefined): string[];
|
|
5
|
+
//# sourceMappingURL=props.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"props.d.ts","sourceRoot":"","sources":["../../src/relations/props.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,6CAA6C,CAAA;AAErF,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAA;AAEtD,KAAK,QAAQ,GAAG,kBAAkB,CAAC,YAAY,CAAC,CAAC,MAAM,CAAC,CAAA;AAExD,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,QAAQ,GAAG,SAAS,GAAG,MAAM,EAAE,CAKvE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"props.js","sourceRoot":"","sources":["../../src/relations/props.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAA;AAItD,MAAM,UAAU,kBAAkB,CAAC,IAA0B;IAC3D,IAAI,IAAI,EAAE,IAAI,KAAK,cAAc,EAAE,CAAC;QAClC,OAAO,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAA;IAC3C,CAAC;IACD,OAAO,EAAE,CAAA;AACX,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@equt/clis",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.22",
|
|
5
5
|
"packageManager": "bun@1.3.10",
|
|
6
6
|
"bin": {
|
|
7
7
|
"bookkeeping": "./dist/bookkeeping/index.js",
|
|
8
8
|
"komari": "./dist/komari/index.js",
|
|
9
|
-
"recurring": "./dist/recurring/index.js"
|
|
9
|
+
"recurring": "./dist/recurring/index.js",
|
|
10
|
+
"relations": "./dist/relations/index.js"
|
|
10
11
|
},
|
|
11
12
|
"publishConfig": {
|
|
12
13
|
"access": "public"
|