Add rule code to list summaries and schemas
This commit is contained in:
1 parent
f0522b72da
commit
39de757042
6 files changed
+20
-6
No files matched your search
@@ -10,3 +10,7 @@ dist/bin/
|
||||
# Local enterprise configs can contain credentials.
|
||||
enterprises/*.json
|
||||
!enterprises/example.*.json
|
||||
|
||||
# Local generated reports and exported deliverables.
|
||||
html/
|
||||
reports/
|
||||
@@ -31,12 +31,12 @@ Use summaries for navigation and selection.
|
||||
seal-home rules list --corp <corpId> --summary
|
||||
```
|
||||
|
||||
Default summary should include only fields such as `id`, `scope`, `strictness`, `status`, and `updatedAt`. Do not pull `description` unless the user needs rule text.
|
||||
Default summary should include only fields such as `id`, `code`, `scope`, `strictness`, `status`, and `updatedAt`. Do not pull `description` unless the user needs rule text.
|
||||
|
||||
Tool-layer equivalent:
|
||||
|
||||
```bash
|
||||
seal-home tool seal_approval_rules_list --corp <corpId> --json '{"fields":["id","scope","strictness","status","updatedAt"]}'
|
||||
seal-home tool seal_approval_rules_list --corp <corpId> --json '{"fields":["id","code","scope","strictness","status","updatedAt"]}'
|
||||
```
|
||||
|
||||
## Clear Draft Rules Before Import
|
||||
|
||||
+1
-1
@@ -29,7 +29,7 @@ const DEFAULT_APP_ROOT = dirname(dirname(dirname(fileURLToPath(import.meta.url))
|
||||
const STATE_DIR = join(homedir(), ".config", "seal-home");
|
||||
const RULE_LIST_FULL_COUNT_LIMIT = 100;
|
||||
const RULE_LIST_FULL_BYTES_LIMIT = 120_000;
|
||||
const RULE_SUMMARY_FIELDS = ["id", "status", "strictness", "scope", "createdAt", "updatedAt"];
|
||||
const RULE_SUMMARY_FIELDS = ["id", "code", "status", "strictness", "scope", "createdAt", "updatedAt"];
|
||||
const DEFAULT_OUTPUT_BYTES_LIMIT = 200_000;
|
||||
const KNOWN_AREAS = new Set([
|
||||
"config",
|
||||
|
||||
@@ -134,7 +134,7 @@ describe("sealTools", () => {
|
||||
const handler = tool!.handler as ToolHandler;
|
||||
const result = await handler(
|
||||
fakeRulesClient(),
|
||||
{ fields: ["id", "status", "strictness", "scope"], limit: 1 },
|
||||
{ fields: ["id", "code", "status", "strictness", "scope"], limit: 1 },
|
||||
fakeContext()
|
||||
) as { count: number; rules: Array<Record<string, unknown>> };
|
||||
|
||||
@@ -142,6 +142,7 @@ describe("sealTools", () => {
|
||||
expect(result.rules).toEqual([
|
||||
{
|
||||
id: "rule-1",
|
||||
code: 29,
|
||||
status: "active",
|
||||
strictness: "MUST_FOLLOW",
|
||||
scope: "travel"
|
||||
@@ -620,12 +621,12 @@ describe("sealTools", () => {
|
||||
const handler = tool!.handler as ToolHandler;
|
||||
const result = await handler(
|
||||
fakeRulesClient(),
|
||||
{ versionNumber: 16, code: "#0002" },
|
||||
{ versionNumber: 16, code: "#0044" },
|
||||
fakeContext()
|
||||
) as { ruleCode?: string; description?: string; versionNumber?: number };
|
||||
|
||||
expect(result).toMatchObject({
|
||||
ruleCode: "#0002",
|
||||
ruleCode: "#0044",
|
||||
description: "Second published rule",
|
||||
versionNumber: 16
|
||||
});
|
||||
@@ -762,11 +763,13 @@ function fakeRulesClient(): KyInstance {
|
||||
publishedByName: "Tester",
|
||||
rules: [
|
||||
{
|
||||
code: "rule-29",
|
||||
description: "First published rule",
|
||||
scope: "travel",
|
||||
strictness: "MUST_FOLLOW"
|
||||
},
|
||||
{
|
||||
code: "rule-44",
|
||||
description: "Second published rule",
|
||||
scope: "meal",
|
||||
strictness: "SHOULD_FOLLOW"
|
||||
@@ -780,6 +783,7 @@ function fakeRulesClient(): KyInstance {
|
||||
{
|
||||
id: "rule-1",
|
||||
tenantId: "tenant-1",
|
||||
code: 29,
|
||||
description: "Must include full invoice detail",
|
||||
scope: "travel",
|
||||
strictness: "MUST_FOLLOW",
|
||||
@@ -790,6 +794,7 @@ function fakeRulesClient(): KyInstance {
|
||||
{
|
||||
id: "rule-2",
|
||||
tenantId: "tenant-1",
|
||||
code: 44,
|
||||
description: "Prefer matching attendee names",
|
||||
scope: "meal",
|
||||
strictness: "SHOULD_FOLLOW",
|
||||
@@ -809,6 +814,7 @@ function fakeClearRulesClient(): KyInstance {
|
||||
{
|
||||
id: "rule-1",
|
||||
tenantId: "tenant-1",
|
||||
code: 29,
|
||||
description: "Must include full invoice detail",
|
||||
scope: "travel",
|
||||
strictness: "MUST_FOLLOW",
|
||||
@@ -817,6 +823,7 @@ function fakeClearRulesClient(): KyInstance {
|
||||
{
|
||||
id: "rule-2",
|
||||
tenantId: "tenant-1",
|
||||
code: 44,
|
||||
description: "Prefer matching attendee names",
|
||||
scope: "meal",
|
||||
strictness: "SHOULD_FOLLOW",
|
||||
|
||||
@@ -182,6 +182,7 @@ export const sealTools = [
|
||||
countOnly: z.boolean().optional().describe("只返回规则数量,不返回规则列表"),
|
||||
fields: z.array(z.enum([
|
||||
"id",
|
||||
"code",
|
||||
"tenantId",
|
||||
"status",
|
||||
"strictness",
|
||||
|
||||
@@ -73,6 +73,7 @@ export const SealSessionDataSchema = z.object({
|
||||
export const ApprovalRuleSchema = z.object({
|
||||
id: z.string(),
|
||||
tenantId: z.string().optional(),
|
||||
code: z.number().optional(),
|
||||
description: z.string(),
|
||||
scope: z.string(),
|
||||
strictness: z.string(),
|
||||
@@ -87,6 +88,7 @@ export const ApprovalRulesDataSchema = z.object({
|
||||
});
|
||||
|
||||
export const PublishedRuleSnapshotSchema = z.object({
|
||||
code: z.string().optional(),
|
||||
description: z.string(),
|
||||
scope: z.string(),
|
||||
strictness: z.string()
|
||||
|
||||
Reference in new issue
Block a user