@modesto_ma/dsh-channels 0.4.0 → 0.5.0-beta.2
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 +83 -57
- package/docs/access-control-design.md +8 -5
- package/docs/attachment-pipeline-v2.md +33 -41
- package/docs/feishu-onboarding.md +36 -33
- package/docs/persistence.md +6 -4
- package/docs/refactor-plan.md +1 -1
- package/docs/workspace-isolation-design.md +7 -8
- package/lib/client.js +444 -288
- package/lib/client.js.map +1 -1
- package/lib/index.js +9017 -6794
- package/lib/index.js.map +1 -1
- package/package.json +1 -1
- package/src/access/cards.ts +9 -9
- package/src/access/controller.ts +10 -10
- package/src/access/index.ts +1 -0
- package/src/access/policy.ts +10 -10
- package/src/access/requests.ts +32 -31
- package/src/access/store.ts +43 -13
- package/src/access/targets.ts +56 -0
- package/src/cards/approval.ts +96 -26
- package/src/cards/index.ts +1 -0
- package/src/cards/onboarding.ts +1 -0
- package/src/cards/picker.ts +108 -0
- package/src/cards/streaming.ts +56 -7
- package/src/cards/wiki.ts +124 -0
- package/src/client/api.ts +5 -25
- package/src/client/panel/access-card.tsx +24 -15
- package/src/client/panel/access-tab.tsx +3 -3
- package/src/client/panel/connection-tab.tsx +70 -1
- package/src/client/panel/index.tsx +11 -62
- package/src/client/panel/shared.tsx +96 -24
- package/src/client/panel/workspace-tab.tsx +2 -18
- package/src/client/string-list.ts +139 -0
- package/src/client/styles.ts +5 -0
- package/src/commands/registry.ts +8 -5
- package/src/config.ts +55 -54
- package/src/domain.ts +36 -123
- package/src/feishu/delivery.ts +34 -1
- package/src/feishu/inbound-attachments.ts +1 -1
- package/src/feishu/manifest.ts +8 -31
- package/src/feishu/message-read.ts +97 -24
- package/src/feishu/scopes.ts +194 -0
- package/src/feishu/send-file.ts +543 -0
- package/src/feishu/slash-commands.ts +134 -0
- package/src/feishu/tools.ts +72 -112
- package/src/feishu/wiki/api.ts +346 -0
- package/src/feishu/wiki/consent.ts +183 -0
- package/src/feishu/wiki/links.ts +122 -0
- package/src/feishu/wiki/scope.ts +66 -0
- package/src/feishu/wiki/tools.ts +984 -0
- package/src/feishu-channel.ts +280 -9
- package/src/index.ts +5 -4
- package/src/interactions/approvals.ts +187 -7
- package/src/interactions/pending.ts +3 -3
- package/src/routing/inbound.ts +73 -106
- package/src/service.ts +545 -440
- package/src/session/manager.ts +1 -1
- package/src/session/routes.ts +2 -3
- package/src/settings/contract.ts +110 -89
- package/src/settings/routes.ts +3 -17
- package/src/settings/surface.ts +144 -94
- package/src/streamer.ts +94 -5
- package/src/workspaces.ts +21 -29
- package/src/cleanup.ts +0 -546
- package/src/client/panel/cleanup-card.tsx +0 -106
- package/src/feishu/pending-attachments.ts +0 -562
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `wikiRoots` containment: decides whether a wiki node lies inside one of the
|
|
3
|
+
* configured roots before any wiki tool touches it.
|
|
4
|
+
*
|
|
5
|
+
* A space root contains every node of that space. A node root contains
|
|
6
|
+
* itself and its descendants; descent is checked by walking the node's
|
|
7
|
+
* parent chain with `spaces/get_node`, bounded by {@link MAX_PARENT_DEPTH}.
|
|
8
|
+
* A node whose chain cannot be read is treated as outside (fail closed).
|
|
9
|
+
*
|
|
10
|
+
* @module dsh-channels/feishu/wiki/scope
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import type { WikiApi, WikiNode } from './api.ts'
|
|
14
|
+
import type { WikiRoot } from './links.ts'
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Longest parent chain walked for a node root. Feishu limits wiki depth well
|
|
18
|
+
* below this; a longer chain is treated as outside.
|
|
19
|
+
*/
|
|
20
|
+
const MAX_PARENT_DEPTH = 64
|
|
21
|
+
|
|
22
|
+
/** The root a node was found under. */
|
|
23
|
+
export interface WikiContainment {
|
|
24
|
+
readonly root: WikiRoot
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Find the configured root containing `node`.
|
|
29
|
+
*
|
|
30
|
+
* @param api Wiki endpoints (for parent lookups).
|
|
31
|
+
* @param roots Configured roots.
|
|
32
|
+
* @param node The node to check.
|
|
33
|
+
* @returns The containing root, or `undefined` when none contains it.
|
|
34
|
+
*/
|
|
35
|
+
export async function containingRoot(
|
|
36
|
+
api: WikiApi,
|
|
37
|
+
roots: readonly WikiRoot[],
|
|
38
|
+
node: WikiNode,
|
|
39
|
+
): Promise<WikiContainment | undefined> {
|
|
40
|
+
for (const root of roots) {
|
|
41
|
+
if (root.kind === 'space' && root.spaceId === node.spaceId) return { root }
|
|
42
|
+
}
|
|
43
|
+
const nodeRoots = roots.filter((root): root is Extract<WikiRoot, { kind: 'node' }> => root.kind === 'node')
|
|
44
|
+
if (nodeRoots.length === 0) return undefined
|
|
45
|
+
const byToken = new Map(nodeRoots.map(root => [root.nodeToken, root]))
|
|
46
|
+
let current: WikiNode = node
|
|
47
|
+
for (let depth = 0; depth <= MAX_PARENT_DEPTH; depth += 1) {
|
|
48
|
+
const match = byToken.get(current.nodeToken)
|
|
49
|
+
if (match !== undefined) return { root: match }
|
|
50
|
+
if (current.parentNodeToken === undefined) return undefined
|
|
51
|
+
current = await api.getNode(current.parentNodeToken, 'wiki')
|
|
52
|
+
}
|
|
53
|
+
return undefined
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Whether a whole space (its top level) is inside the roots: only a space
|
|
58
|
+
* root covers a space's top level.
|
|
59
|
+
*
|
|
60
|
+
* @param roots Configured roots.
|
|
61
|
+
* @param spaceId The space.
|
|
62
|
+
* @returns True when a space root names it.
|
|
63
|
+
*/
|
|
64
|
+
export function spaceIsRoot(roots: readonly WikiRoot[], spaceId: string): boolean {
|
|
65
|
+
return roots.some(root => root.kind === 'space' && root.spaceId === spaceId)
|
|
66
|
+
}
|