@doist/outline-cli 1.8.0 → 1.9.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/CHANGELOG.md +6 -0
- package/dist/commands/account.d.ts +2 -0
- package/dist/commands/account.js +107 -0
- package/dist/commands/account.js.map +1 -0
- package/dist/commands/auth.d.ts +0 -12
- package/dist/commands/auth.js +15 -26
- package/dist/commands/auth.js.map +1 -1
- package/dist/index.js +19 -4
- package/dist/index.js.map +1 -1
- package/dist/lib/api.js +20 -9
- package/dist/lib/api.js.map +1 -1
- package/dist/lib/auth-output.d.ts +15 -0
- package/dist/lib/auth-output.js +27 -0
- package/dist/lib/auth-output.js.map +1 -0
- package/dist/lib/auth-provider.d.ts +26 -18
- package/dist/lib/auth-provider.js +47 -19
- package/dist/lib/auth-provider.js.map +1 -1
- package/dist/lib/auth.d.ts +32 -11
- package/dist/lib/auth.js +54 -13
- package/dist/lib/auth.js.map +1 -1
- package/dist/lib/errors.d.ts +1 -1
- package/dist/lib/errors.js.map +1 -1
- package/dist/lib/global-args.d.ts +25 -0
- package/dist/lib/global-args.js +50 -1
- package/dist/lib/global-args.js.map +1 -1
- package/dist/lib/outline-account.d.ts +7 -1
- package/dist/lib/outline-account.js +10 -0
- package/dist/lib/outline-account.js.map +1 -1
- package/dist/lib/skills/content.d.ts +1 -1
- package/dist/lib/skills/content.js +18 -0
- package/dist/lib/skills/content.js.map +1 -1
- package/dist/lib/user-records.d.ts +8 -1
- package/dist/lib/user-records.js +17 -1
- package/dist/lib/user-records.js.map +1 -1
- package/dist/lib/user-ref-store.d.ts +16 -0
- package/dist/lib/user-ref-store.js +37 -0
- package/dist/lib/user-ref-store.js.map +1 -0
- package/package.json +2 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { UserRecord, UserRecordStore } from '@doist/cli-core/auth';
|
|
1
|
+
import type { AccountRef, UserRecord, UserRecordStore } from '@doist/cli-core/auth';
|
|
2
2
|
import { type Config } from './config.js';
|
|
3
3
|
import { type OutlineAccount } from './outline-account.js';
|
|
4
4
|
/**
|
|
@@ -12,3 +12,10 @@ export declare function createOutlineUserRecordStore(): UserRecordStore<OutlineA
|
|
|
12
12
|
* Returns `null` when no users are stored.
|
|
13
13
|
*/
|
|
14
14
|
export declare function getDefaultUserRecord(config: Partial<Config>): UserRecord<OutlineAccount> | null;
|
|
15
|
+
/**
|
|
16
|
+
* Resolve a `UserRecord` by `--user` ref (UUID or display name). Falls back to
|
|
17
|
+
* the default-or-first record when `ref` is absent, so callers can pass the
|
|
18
|
+
* global selector straight through. Returns `null` when no users are stored or
|
|
19
|
+
* an explicit ref matches nothing.
|
|
20
|
+
*/
|
|
21
|
+
export declare function recordForRef(config: Partial<Config>, ref?: AccountRef): UserRecord<OutlineAccount> | null;
|
package/dist/lib/user-records.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getConfig, updateConfig } from './config.js';
|
|
2
|
-
import { makeOutlineAccount } from './outline-account.js';
|
|
2
|
+
import { makeOutlineAccount, matchOutlineAccount } from './outline-account.js';
|
|
3
3
|
/**
|
|
4
4
|
* `UserRecordStore` adapter over `config.users[]`. `StoredUser.token` is
|
|
5
5
|
* surfaced as `fallbackToken` — cli-core's name for the plaintext copy
|
|
@@ -54,6 +54,22 @@ export function getDefaultUserRecord(config) {
|
|
|
54
54
|
const user = (defaultId && users.find((u) => u.id === defaultId)) || users[0];
|
|
55
55
|
return toRecord(user);
|
|
56
56
|
}
|
|
57
|
+
/**
|
|
58
|
+
* Resolve a `UserRecord` by `--user` ref (UUID or display name). Falls back to
|
|
59
|
+
* the default-or-first record when `ref` is absent, so callers can pass the
|
|
60
|
+
* global selector straight through. Returns `null` when no users are stored or
|
|
61
|
+
* an explicit ref matches nothing.
|
|
62
|
+
*/
|
|
63
|
+
export function recordForRef(config, ref) {
|
|
64
|
+
if (ref === undefined)
|
|
65
|
+
return getDefaultUserRecord(config);
|
|
66
|
+
for (const user of config.users ?? []) {
|
|
67
|
+
const record = toRecord(user);
|
|
68
|
+
if (matchOutlineAccount(record.account, ref))
|
|
69
|
+
return record;
|
|
70
|
+
}
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
57
73
|
function toRecord(user) {
|
|
58
74
|
const account = makeOutlineAccount({
|
|
59
75
|
id: user.id,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user-records.js","sourceRoot":"","sources":["../../src/lib/user-records.ts"],"names":[],"mappings":"AACA,OAAO,EAAe,SAAS,EAAmB,YAAY,EAAE,MAAM,aAAa,CAAA;AACnF,OAAO,EAAE,kBAAkB,EAAuB,MAAM,sBAAsB,CAAA;
|
|
1
|
+
{"version":3,"file":"user-records.js","sourceRoot":"","sources":["../../src/lib/user-records.ts"],"names":[],"mappings":"AACA,OAAO,EAAe,SAAS,EAAmB,YAAY,EAAE,MAAM,aAAa,CAAA;AACnF,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAuB,MAAM,sBAAsB,CAAA;AAEnG;;;;GAIG;AACH,MAAM,UAAU,4BAA4B;IACxC,OAAO;QACH,KAAK,CAAC,IAAI;YACN,MAAM,MAAM,GAAG,MAAM,SAAS,EAAE,CAAA;YAChC,OAAO,CAAC,MAAM,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;QAC7C,CAAC;QACD,KAAK,CAAC,MAAM,CAAC,MAAM;YACf,MAAM,MAAM,GAAG,MAAM,SAAS,EAAE,CAAA;YAChC,MAAM,QAAQ,GAAG,MAAM,CAAC,KAAK,IAAI,EAAE,CAAA;YACnC,MAAM,IAAI,GAAG,UAAU,CAAC,MAAM,CAAC,CAAA;YAC/B,MAAM,KAAK,GAAG,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,CAAA;YACnE,MAAM,KAAK,GACP,KAAK,IAAI,CAA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SAAS,EAAE,CAAC;QAC5C,IAAI,CAAC,uBAAuB,GAAG,MAAM,CAAC,oBAAoB,CAAA;IAC9D,CAAC;IACD,IAAI,MAAM,CAAC,qBAAqB,KAAK,SAAS,EAAE,CAAC;QAC7C,IAAI,CAAC,wBAAwB,GAAG,MAAM,CAAC,qBAAqB,CAAA;IAChE,CAAC;IACD,IAAI,MAAM,CAAC,eAAe,KAAK,SAAS;QAAE,IAAI,CAAC,iBAAiB,GAAG,MAAM,CAAC,eAAe,CAAA;IACzF,OAAO,IAAI,CAAA;AACf,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { OutlineTokenStore } from './auth-provider.js';
|
|
2
|
+
/**
|
|
3
|
+
* Bridge the global `ol --user <ref>` selector — stripped from argv before
|
|
4
|
+
* Commander parses (see `applyUserSelector`) — into store reads that make no
|
|
5
|
+
* explicit ref. An explicit `ref` argument always wins; only a missing one
|
|
6
|
+
* falls back to the global selector. Used by both the request path
|
|
7
|
+
* (`auth.ts` `tokenStore()`) and cli-core's auth attachers (`auth status` /
|
|
8
|
+
* `auth logout`), so a `--user` placed before any command is honoured
|
|
9
|
+
* everywhere.
|
|
10
|
+
*
|
|
11
|
+
* Existence is checked via `activeAccount(ref)` rather than `list()` so the
|
|
12
|
+
* check is both token-free (a keyring-offline account can still be cleared by
|
|
13
|
+
* `auth logout`) and legacy-aware (`list()` only exposes v2 records, but a
|
|
14
|
+
* pending v1→v2 migration can still resolve its single legacy account).
|
|
15
|
+
*/
|
|
16
|
+
export declare function withUserRefAware(store: OutlineTokenStore): OutlineTokenStore;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { CliError } from './errors.js';
|
|
2
|
+
import { getRequestedUserRef } from './global-args.js';
|
|
3
|
+
/**
|
|
4
|
+
* Bridge the global `ol --user <ref>` selector — stripped from argv before
|
|
5
|
+
* Commander parses (see `applyUserSelector`) — into store reads that make no
|
|
6
|
+
* explicit ref. An explicit `ref` argument always wins; only a missing one
|
|
7
|
+
* falls back to the global selector. Used by both the request path
|
|
8
|
+
* (`auth.ts` `tokenStore()`) and cli-core's auth attachers (`auth status` /
|
|
9
|
+
* `auth logout`), so a `--user` placed before any command is honoured
|
|
10
|
+
* everywhere.
|
|
11
|
+
*
|
|
12
|
+
* Existence is checked via `activeAccount(ref)` rather than `list()` so the
|
|
13
|
+
* check is both token-free (a keyring-offline account can still be cleared by
|
|
14
|
+
* `auth logout`) and legacy-aware (`list()` only exposes v2 records, but a
|
|
15
|
+
* pending v1→v2 migration can still resolve its single legacy account).
|
|
16
|
+
*/
|
|
17
|
+
export function withUserRefAware(store) {
|
|
18
|
+
async function resolveRef(ref) {
|
|
19
|
+
const target = ref ?? getRequestedUserRef();
|
|
20
|
+
if (target === undefined)
|
|
21
|
+
return undefined;
|
|
22
|
+
if (!(await store.activeAccount(target))) {
|
|
23
|
+
throw new CliError('ACCOUNT_NOT_FOUND', `No stored account matches "${target}".`, [
|
|
24
|
+
'Check the account id or display name, or run `ol auth login` to add it.',
|
|
25
|
+
]);
|
|
26
|
+
}
|
|
27
|
+
return target;
|
|
28
|
+
}
|
|
29
|
+
return {
|
|
30
|
+
...store,
|
|
31
|
+
active: async (ref) => store.active(await resolveRef(ref)),
|
|
32
|
+
activeBundle: async (ref) => store.activeBundle(await resolveRef(ref)),
|
|
33
|
+
activeAccount: async (ref) => store.activeAccount(await resolveRef(ref)),
|
|
34
|
+
clear: async (ref) => store.clear(await resolveRef(ref)),
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=user-ref-store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"user-ref-store.js","sourceRoot":"","sources":["../../src/lib/user-ref-store.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AACtC,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAA;AAEtD;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,gBAAgB,CAAC,KAAwB;IACrD,KAAK,UAAU,UAAU,CAAC,GAAgB;QACtC,MAAM,MAAM,GAAG,GAAG,IAAI,mBAAmB,EAAE,CAAA;QAC3C,IAAI,MAAM,KAAK,SAAS;YAAE,OAAO,SAAS,CAAA;QAC1C,IAAI,CAAC,CAAC,MAAM,KAAK,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC;YACvC,MAAM,IAAI,QAAQ,CAAC,mBAAmB,EAAE,8BAA8B,MAAM,IAAI,EAAE;gBAC9E,yEAAyE;aAC5E,CAAC,CAAA;QACN,CAAC;QACD,OAAO,MAAM,CAAA;IACjB,CAAC;IAED,OAAO;QACH,GAAG,KAAK;QACR,MAAM,EAAE,KAAK,EAAE,GAAgB,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,UAAU,CAAC,GAAG,CAAC,CAAC;QACvE,YAAY,EAAE,KAAK,EAAE,GAAgB,EAAE,EAAE,CAAC,KAAK,CAAC,YAAY,CAAC,MAAM,UAAU,CAAC,GAAG,CAAC,CAAC;QACnF,aAAa,EAAE,KAAK,EAAE,GAAgB,EAAE,EAAE,CAAC,KAAK,CAAC,aAAa,CAAC,MAAM,UAAU,CAAC,GAAG,CAAC,CAAC;QACrF,KAAK,EAAE,KAAK,EAAE,GAAgB,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,UAAU,CAAC,GAAG,CAAC,CAAC;KACxE,CAAA;AACL,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@doist/outline-cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.9.0",
|
|
4
4
|
"description": "CLI for the Outline wiki/knowledge base API",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"node": ">=20.18.1"
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@doist/cli-core": "0.
|
|
51
|
+
"@doist/cli-core": "0.24.0",
|
|
52
52
|
"chalk": "5.6.2",
|
|
53
53
|
"commander": "14.0.2",
|
|
54
54
|
"marked": "18.0.3",
|