@carlonicora/nestjs-neo4jsonapi 6.1.3 → 6.3.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/dist/agents/graph/interfaces/graph.catalog.interface.d.ts +4 -0
- package/dist/agents/graph/interfaces/graph.catalog.interface.d.ts.map +1 -1
- package/dist/agents/graph/prompts/graph.node.system.prompt.d.ts +1 -1
- package/dist/agents/graph/prompts/graph.node.system.prompt.d.ts.map +1 -1
- package/dist/agents/graph/prompts/graph.node.system.prompt.js +1 -1
- package/dist/agents/graph/services/field-formatting.d.ts +11 -0
- package/dist/agents/graph/services/field-formatting.d.ts.map +1 -1
- package/dist/agents/graph/services/field-formatting.js +16 -1
- package/dist/agents/graph/services/field-formatting.js.map +1 -1
- package/dist/agents/graph/services/graph.catalog.service.d.ts +4 -0
- package/dist/agents/graph/services/graph.catalog.service.d.ts.map +1 -1
- package/dist/agents/graph/services/graph.catalog.service.js +2 -0
- package/dist/agents/graph/services/graph.catalog.service.js.map +1 -1
- package/dist/agents/graph/services/graph.search.service.d.ts +16 -0
- package/dist/agents/graph/services/graph.search.service.d.ts.map +1 -1
- package/dist/agents/graph/services/graph.search.service.js +35 -4
- package/dist/agents/graph/services/graph.search.service.js.map +1 -1
- package/dist/agents/graph/tools/describe-entity.tool.d.ts.map +1 -1
- package/dist/agents/graph/tools/describe-entity.tool.js +28 -27
- package/dist/agents/graph/tools/describe-entity.tool.js.map +1 -1
- package/dist/agents/graph/tools/read-entity.tool.d.ts.map +1 -1
- package/dist/agents/graph/tools/read-entity.tool.js +8 -1
- package/dist/agents/graph/tools/read-entity.tool.js.map +1 -1
- package/dist/agents/graph/tools/resolve-entity.tool.d.ts +1 -0
- package/dist/agents/graph/tools/resolve-entity.tool.d.ts.map +1 -1
- package/dist/agents/graph/tools/resolve-entity.tool.js +18 -1
- package/dist/agents/graph/tools/resolve-entity.tool.js.map +1 -1
- package/dist/agents/graph/tools/search-entities.tool.d.ts +7 -0
- package/dist/agents/graph/tools/search-entities.tool.d.ts.map +1 -1
- package/dist/agents/graph/tools/search-entities.tool.js +15 -13
- package/dist/agents/graph/tools/search-entities.tool.js.map +1 -1
- package/dist/agents/graph/tools/traverse.tool.d.ts +24 -0
- package/dist/agents/graph/tools/traverse.tool.d.ts.map +1 -1
- package/dist/agents/graph/tools/traverse.tool.js +55 -10
- package/dist/agents/graph/tools/traverse.tool.js.map +1 -1
- package/dist/common/interfaces/entity.schema.interface.d.ts +20 -0
- package/dist/common/interfaces/entity.schema.interface.d.ts.map +1 -1
- package/dist/common/interfaces/external.entity.source.interface.d.ts +7 -3
- package/dist/common/interfaces/external.entity.source.interface.d.ts.map +1 -1
- package/dist/common/interfaces/external.entity.source.interface.js.map +1 -1
- package/dist/foundations/auth/controllers/auth.discord.controller.d.ts +1 -1
- package/dist/foundations/auth/controllers/auth.discord.controller.d.ts.map +1 -1
- package/dist/foundations/auth/controllers/auth.discord.controller.js +6 -3
- package/dist/foundations/auth/controllers/auth.discord.controller.js.map +1 -1
- package/dist/foundations/auth/controllers/auth.google.controller.d.ts +1 -1
- package/dist/foundations/auth/controllers/auth.google.controller.d.ts.map +1 -1
- package/dist/foundations/auth/controllers/auth.google.controller.js +6 -3
- package/dist/foundations/auth/controllers/auth.google.controller.js.map +1 -1
- package/dist/foundations/auth/dtos/auth.post.register.dto.d.ts +6 -0
- package/dist/foundations/auth/dtos/auth.post.register.dto.d.ts.map +1 -1
- package/dist/foundations/auth/dtos/auth.post.register.dto.js +36 -0
- package/dist/foundations/auth/dtos/auth.post.register.dto.js.map +1 -1
- package/dist/foundations/auth/services/auth.discord.service.d.ts +6 -2
- package/dist/foundations/auth/services/auth.discord.service.d.ts.map +1 -1
- package/dist/foundations/auth/services/auth.discord.service.js +29 -5
- package/dist/foundations/auth/services/auth.discord.service.js.map +1 -1
- package/dist/foundations/auth/services/auth.google.service.d.ts +6 -2
- package/dist/foundations/auth/services/auth.google.service.d.ts.map +1 -1
- package/dist/foundations/auth/services/auth.google.service.js +29 -5
- package/dist/foundations/auth/services/auth.google.service.js.map +1 -1
- package/dist/foundations/auth/services/auth.service.d.ts +12 -0
- package/dist/foundations/auth/services/auth.service.d.ts.map +1 -1
- package/dist/foundations/auth/services/auth.service.js +47 -8
- package/dist/foundations/auth/services/auth.service.js.map +1 -1
- package/dist/foundations/auth/services/pending-registration.service.d.ts +2 -0
- package/dist/foundations/auth/services/pending-registration.service.d.ts.map +1 -1
- package/dist/foundations/auth/services/pending-registration.service.js.map +1 -1
- package/dist/foundations/user/entities/user.d.ts +6 -0
- package/dist/foundations/user/entities/user.d.ts.map +1 -1
- package/dist/foundations/user/entities/user.js +7 -0
- package/dist/foundations/user/entities/user.js.map +1 -1
- package/dist/foundations/user/repositories/user.repository.d.ts +9 -0
- package/dist/foundations/user/repositories/user.repository.d.ts.map +1 -1
- package/dist/foundations/user/repositories/user.repository.js +23 -0
- package/dist/foundations/user/repositories/user.repository.js.map +1 -1
- package/dist/foundations/waitlist/dtos/waitlist.post.dto.d.ts +6 -0
- package/dist/foundations/waitlist/dtos/waitlist.post.dto.d.ts.map +1 -1
- package/dist/foundations/waitlist/dtos/waitlist.post.dto.js +36 -0
- package/dist/foundations/waitlist/dtos/waitlist.post.dto.js.map +1 -1
- package/dist/foundations/waitlist/entities/waitlist.d.ts +6 -0
- package/dist/foundations/waitlist/entities/waitlist.d.ts.map +1 -1
- package/dist/foundations/waitlist/entities/waitlist.js +6 -0
- package/dist/foundations/waitlist/entities/waitlist.js.map +1 -1
- package/dist/foundations/waitlist/index.d.ts +2 -0
- package/dist/foundations/waitlist/index.d.ts.map +1 -1
- package/dist/foundations/waitlist/index.js +8 -1
- package/dist/foundations/waitlist/index.js.map +1 -1
- package/dist/foundations/waitlist/services/waitlist.service.d.ts +2 -1
- package/dist/foundations/waitlist/services/waitlist.service.d.ts.map +1 -1
- package/dist/foundations/waitlist/services/waitlist.service.js +6 -4
- package/dist/foundations/waitlist/services/waitlist.service.js.map +1 -1
- package/dist/foundations/waitlist/utils/signup-source.d.ts +24 -0
- package/dist/foundations/waitlist/utils/signup-source.d.ts.map +1 -0
- package/dist/foundations/waitlist/utils/signup-source.js +52 -0
- package/dist/foundations/waitlist/utils/signup-source.js.map +1 -0
- package/dist/mcp/index.d.ts +2 -2
- package/dist/mcp/index.d.ts.map +1 -1
- package/dist/mcp/index.js +4 -2
- package/dist/mcp/index.js.map +1 -1
- package/dist/mcp/interfaces/mcp.tool.interface.d.ts +21 -0
- package/dist/mcp/interfaces/mcp.tool.interface.d.ts.map +1 -1
- package/dist/mcp/interfaces/mcp.tool.interface.js +8 -1
- package/dist/mcp/interfaces/mcp.tool.interface.js.map +1 -1
- package/dist/mcp/mcp.module.d.ts +5 -0
- package/dist/mcp/mcp.module.d.ts.map +1 -1
- package/dist/mcp/mcp.module.js +5 -0
- package/dist/mcp/mcp.module.js.map +1 -1
- package/dist/mcp/services/mcp.errors.d.ts +11 -0
- package/dist/mcp/services/mcp.errors.d.ts.map +1 -1
- package/dist/mcp/services/mcp.errors.js +36 -0
- package/dist/mcp/services/mcp.errors.js.map +1 -1
- package/dist/mcp/services/mcp.generic.tools.service.d.ts +13 -3
- package/dist/mcp/services/mcp.generic.tools.service.d.ts.map +1 -1
- package/dist/mcp/services/mcp.generic.tools.service.js +66 -7
- package/dist/mcp/services/mcp.generic.tools.service.js.map +1 -1
- package/dist/mcp/services/mcp.promoted.tools.factory.d.ts +1 -0
- package/dist/mcp/services/mcp.promoted.tools.factory.d.ts.map +1 -1
- package/dist/mcp/services/mcp.promoted.tools.factory.js +4 -3
- package/dist/mcp/services/mcp.promoted.tools.factory.js.map +1 -1
- package/dist/mcp/services/mcp.tool.registry.d.ts +1 -0
- package/dist/mcp/services/mcp.tool.registry.d.ts.map +1 -1
- package/dist/mcp/services/mcp.tool.registry.js +5 -0
- package/dist/mcp/services/mcp.tool.registry.js.map +1 -1
- package/package.json +1 -1
|
@@ -21,18 +21,14 @@ const inputSchema = zod_1.z.object({
|
|
|
21
21
|
});
|
|
22
22
|
exports.describeEntityInputSchema = inputSchema;
|
|
23
23
|
/**
|
|
24
|
-
* The filter operators a field accepts
|
|
25
|
-
*
|
|
26
|
-
*
|
|
24
|
+
* The filter operators a field accepts. When the service declares capabilities
|
|
25
|
+
* they win: exactly the operators listed for the field (none when it is not
|
|
26
|
+
* listed). Otherwise those of its type, and none for a non-filterable field.
|
|
27
27
|
*/
|
|
28
28
|
function filterOperators(field, capabilities) {
|
|
29
|
-
if (!field.filterable)
|
|
29
|
+
if (!capabilities && !field.filterable)
|
|
30
30
|
return [];
|
|
31
|
-
|
|
32
|
-
if (!capabilities)
|
|
33
|
-
return byType;
|
|
34
|
-
const supported = capabilities.find((c) => c.field === field.name)?.operators ?? [];
|
|
35
|
-
return byType.filter((op) => supported.includes(op));
|
|
31
|
+
return (0, traverse_tool_1.allowedFilterOperators)(field, capabilities);
|
|
36
32
|
}
|
|
37
33
|
let DescribeEntityTool = class DescribeEntityTool {
|
|
38
34
|
constructor(factory) {
|
|
@@ -60,27 +56,32 @@ let DescribeEntityTool = class DescribeEntityTool {
|
|
|
60
56
|
const writable = entity.writable === true;
|
|
61
57
|
// A service whose records live outside the app database may support
|
|
62
58
|
// fewer filters than the field types allow; advertise only those.
|
|
63
|
-
|
|
64
|
-
const capabilities =
|
|
59
|
+
// When it declares capabilities, a field is filterable only if it has operators.
|
|
60
|
+
const capabilities = (0, traverse_tool_1.serviceFilterCapabilities)(this.factory.resolveService(entity.type));
|
|
65
61
|
return {
|
|
66
62
|
type: entity.type,
|
|
67
63
|
description: entity.description,
|
|
68
|
-
fields: entity.fields.map((f) =>
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
64
|
+
fields: entity.fields.map((f) => {
|
|
65
|
+
const operators = filterOperators(f, capabilities);
|
|
66
|
+
const values = capabilities?.find((c) => c.field === f.name)?.values;
|
|
67
|
+
return {
|
|
68
|
+
name: f.name,
|
|
69
|
+
type: f.type,
|
|
70
|
+
description: f.description,
|
|
71
|
+
filterable: capabilities ? operators.length > 0 : f.filterable,
|
|
72
|
+
sortable: f.sortable,
|
|
73
|
+
operators,
|
|
74
|
+
...(values?.length ? { values: [...values] } : {}),
|
|
75
|
+
...(f.kind ? { kind: f.kind } : {}),
|
|
76
|
+
// A richtext field is READ as markdown (the tool layer renders the
|
|
77
|
+
// stored BlockNote document), so it must be WRITTEN as markdown too —
|
|
78
|
+
// the write tools convert it back. Without saying so the model has no
|
|
79
|
+
// way to know the two directions match.
|
|
80
|
+
...(f.kind?.type === "richtext" ? { format: "markdown" } : {}),
|
|
81
|
+
...(entity.list ? { stage: entity.list.includes(f.name) ? "list" : "detail" } : {}),
|
|
82
|
+
...(writable ? { writable: (0, writable_rules_1.isFieldWritable)(entity, f.name) } : {}),
|
|
83
|
+
};
|
|
84
|
+
}),
|
|
84
85
|
relationships: entity.relationships.map((r) => ({
|
|
85
86
|
name: r.name,
|
|
86
87
|
targetType: r.targetType,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"describe-entity.tool.js","sourceRoot":"","sources":["../../../../src/agents/graph/tools/describe-entity.tool.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA4C;AAC5C,iDAA8D;AAC9D,6BAAwB;AACxB,+DAAqF;AACrF,iDAA0E;AAC1E,
|
|
1
|
+
{"version":3,"file":"describe-entity.tool.js","sourceRoot":"","sources":["../../../../src/agents/graph/tools/describe-entity.tool.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA4C;AAC5C,iDAA8D;AAC9D,6BAAwB;AACxB,+DAAqF;AACrF,iDAA0E;AAC1E,mDAAoF;AAIpF,MAAM,WAAW,GAAG,OAAC,CAAC,MAAM,CAAC;IAC3B,IAAI,EAAE,OAAC,CAAC,MAA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C,EAAE,CAAC;gBACP,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,aAAa,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;aAC1F,CAAC;QACJ,CAAC,EACD,QAAQ,CACT,CAAC;IACJ,CAAC;CACF,CAAA;AA9EY,gDAAkB;6BAAlB,kBAAkB;IAD9B,IAAA,mBAAU,GAAE;qCAE2B,0BAAW;GADtC,kBAAkB,CA8E9B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"read-entity.tool.d.ts","sourceRoot":"","sources":["../../../../src/agents/graph/tools/read-entity.tool.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC1E,OAAO,
|
|
1
|
+
{"version":3,"file":"read-entity.tool.d.ts","sourceRoot":"","sources":["../../../../src/agents/graph/tools/read-entity.tool.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC1E,OAAO,EAAqB,yBAAyB,EAAE,MAAM,8BAA8B,CAAC;AAE5F,OAAO,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AACxE,OAAO,EAAE,qBAAqB,EAAE,MAAM,oDAAoD,CAAC;AAC3F,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAGrD,QAAA,MAAM,WAAW;;;;iBAIf,CAAC;AAEH,OAAO,EAAE,WAAW,IAAI,qBAAqB,EAAE,CAAC;AAEhD,qBACa,cAAc;IAIvB,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACzB,OAAO,CAAC,QAAQ,CAAC,UAAU;IAG3B,OAAO,CAAC,QAAQ,CAAC,SAAS;IAT5B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAmC;gBAGvC,OAAO,EAAE,WAAW,EACpB,OAAO,EAAE,mBAAmB,EAC5B,QAAQ,EAAE,qBAAqB,EAC/B,UAAU,EAAE,UAAU,EAGtB,SAAS,EAAE,yBAAyB;IAGvD,KAAK,CAAC,GAAG,EAAE,WAAW,EAAE,QAAQ,EAAE,cAAc,EAAE,EAAE,OAAO,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,GAAG,qBAAqB;IAS3F,MAAM,CACV,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,EAClC,GAAG,EAAE,WAAW,EAChB,QAAQ,EAAE,cAAc,EAAE,EAC1B,OAAO,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,GACpB,OAAO,CAAC,OAAO,CAAC;IA6JnB;;;;OAIG;YACW,aAAa;CAI5B"}
|
|
@@ -141,6 +141,10 @@ let ReadEntityTool = ReadEntityTool_1 = class ReadEntityTool {
|
|
|
141
141
|
this.logger.warn(`read_entity detail fields failed for ${entity.type} ${input.id}: ${e.message}`);
|
|
142
142
|
}
|
|
143
143
|
}
|
|
144
|
+
// AI-written fields in the output, computed after the detail fields land so
|
|
145
|
+
// a generated detail field is marked too.
|
|
146
|
+
const generated = (0, field_formatting_1.generatedFieldsIn)(entity, baseFields);
|
|
147
|
+
const generatedMarker = generated.length ? { generated } : {};
|
|
144
148
|
// Bridge fanout: if this entity is a bridge, replace the bare payload with
|
|
145
149
|
// the materialised one. The existing `include` block (if any) stacks on top
|
|
146
150
|
// as a sibling `related` map — it carries summary refs, while the bridge
|
|
@@ -160,7 +164,9 @@ let ReadEntityTool = ReadEntityTool_1 = class ReadEntityTool {
|
|
|
160
164
|
});
|
|
161
165
|
// Armed only on a successful read (spec § "3b. read_entity dedup").
|
|
162
166
|
readIds?.add(dedupKey);
|
|
163
|
-
return input.include?.length
|
|
167
|
+
return input.include?.length
|
|
168
|
+
? { ...materialised, ...generatedMarker, related }
|
|
169
|
+
: { ...materialised, ...generatedMarker };
|
|
164
170
|
}
|
|
165
171
|
// Armed only on a successful read (spec § "3b. read_entity dedup").
|
|
166
172
|
readIds?.add(dedupKey);
|
|
@@ -168,6 +174,7 @@ let ReadEntityTool = ReadEntityTool_1 = class ReadEntityTool {
|
|
|
168
174
|
id: record.id,
|
|
169
175
|
type: entity.type,
|
|
170
176
|
fields: baseFields,
|
|
177
|
+
...generatedMarker,
|
|
171
178
|
...(input.include?.length ? { related } : {}),
|
|
172
179
|
};
|
|
173
180
|
}, recorder);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"read-entity.tool.js","sourceRoot":"","sources":["../../../../src/agents/graph/tools/read-entity.tool.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,2CAAoD;AACpD,iDAA8D;AAC9D,6BAAwB;AACxB,iDAA0E;AAC1E,
|
|
1
|
+
{"version":3,"file":"read-entity.tool.js","sourceRoot":"","sources":["../../../../src/agents/graph/tools/read-entity.tool.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,2CAAoD;AACpD,iDAA8D;AAC9D,6BAAwB;AACxB,iDAA0E;AAC1E,mEAA4F;AAC5F,uEAAmE;AACnE,6EAAwE;AACxE,gGAA2F;AAC3F,yDAAqD;AACrD,8GAAiG;AAEjG,MAAM,WAAW,GAAG,OAAC,CAAC,MAAM,CAAC;IAC3B,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE;IAChB,EAAE,EAAE,OAAC,CAAC,MAAM,EAAE;IACd,OAAO,EAAE,OAAC,CAAC,KAAK,CAAC,OAAC,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MAAM,GAAG,CAAC,CAAC,CAAC,YAAY,GAAG,iBAAiB,CAAC;QACjE,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;IAED;;;;OAIG;IACK,KAAK,CAAC,aAAa,CAAC,IAAY,EAAE,OAAc,EAAE,GAAgB;QACxE,IAAI,CAAC,GAAG,CAAC,OAAO,IAAI,CAAC,GAAG,CAAC,SAAS;YAAE,OAAO,OAAO,CAAC;QACnD,OAAO,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,CAAC;IACxD,CAAC;CACF,CAAA;AAjMY,wCAAc;yBAAd,cAAc;IAD1B,IAAA,mBAAU,GAAE;qCAKiB,0BAAW;QACX,2CAAmB;QAClB,+CAAqB;QACnB,wBAAU;QAGX,4CAAyB;GAV5C,cAAc,CAiM1B"}
|
|
@@ -4,6 +4,7 @@ import { ToolFactory, ToolCallRecord, UserContext } from "./tool.factory";
|
|
|
4
4
|
import { GraphSearchService } from "../services/graph.search.service";
|
|
5
5
|
declare const inputSchema: z.ZodObject<{
|
|
6
6
|
text: z.ZodString;
|
|
7
|
+
types: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
7
8
|
}, z.core.$strip>;
|
|
8
9
|
export { inputSchema as resolveEntityInputSchema };
|
|
9
10
|
export declare class ResolveEntityTool {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolve-entity.tool.d.ts","sourceRoot":"","sources":["../../../../src/agents/graph/tools/resolve-entity.tool.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC1E,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AAEtE,QAAA,MAAM,WAAW
|
|
1
|
+
{"version":3,"file":"resolve-entity.tool.d.ts","sourceRoot":"","sources":["../../../../src/agents/graph/tools/resolve-entity.tool.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC1E,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AAEtE,QAAA,MAAM,WAAW;;;iBAQf,CAAC;AAEH,OAAO,EAAE,WAAW,IAAI,wBAAwB,EAAE,CAAC;AAEnD,qBACa,iBAAiB;IAE1B,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,MAAM;gBADN,OAAO,EAAE,WAAW,EACpB,MAAM,EAAE,kBAAkB;IAG7C,KAAK,CAAC,GAAG,EAAE,WAAW,EAAE,QAAQ,EAAE,cAAc,EAAE,GAAG,qBAAqB;IAoBpE,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,EAAE,GAAG,EAAE,WAAW,EAAE,QAAQ,EAAE,cAAc,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC;CAmBjH"}
|
|
@@ -17,6 +17,10 @@ const tool_factory_1 = require("./tool.factory");
|
|
|
17
17
|
const graph_search_service_1 = require("../services/graph.search.service");
|
|
18
18
|
const inputSchema = zod_1.z.object({
|
|
19
19
|
text: zod_1.z.string().min(1).describe("The user's literal phrase. Pass 'Faby and Carlo' verbatim, not split."),
|
|
20
|
+
types: zod_1.z
|
|
21
|
+
.array(zod_1.z.string())
|
|
22
|
+
.optional()
|
|
23
|
+
.describe('Catalog type names to search, e.g. ["accounts"]. Omitted: every visible type except personal communication (emails, messages, chats), which the reply lists in excludedTypes.'),
|
|
20
24
|
});
|
|
21
25
|
exports.resolveEntityInputSchema = inputSchema;
|
|
22
26
|
let ResolveEntityTool = class ResolveEntityTool {
|
|
@@ -29,7 +33,19 @@ let ResolveEntityTool = class ResolveEntityTool {
|
|
|
29
33
|
name: "resolve_entity",
|
|
30
34
|
description: "Resolve a user-named entity across every visible type. Returns ranked candidates from the highest-confidence tier that yielded any match anywhere. Use this before search_entities / read_entity / traverse whenever the user refers to a named record.",
|
|
31
35
|
schema: inputSchema,
|
|
32
|
-
|
|
36
|
+
// An unknown `types` entry throws a BadRequestException (validation_failed
|
|
37
|
+
// over MCP); the LangGraph path hands the model the message instead, so
|
|
38
|
+
// it can retry with a visible type rather than abort the turn.
|
|
39
|
+
func: async (input) => {
|
|
40
|
+
try {
|
|
41
|
+
return JSON.stringify(await this.invoke(input, ctx, recorder));
|
|
42
|
+
}
|
|
43
|
+
catch (e) {
|
|
44
|
+
if (e instanceof common_1.BadRequestException)
|
|
45
|
+
return JSON.stringify({ error: e.message });
|
|
46
|
+
throw e;
|
|
47
|
+
}
|
|
48
|
+
},
|
|
33
49
|
});
|
|
34
50
|
}
|
|
35
51
|
async invoke(input, ctx, recorder) {
|
|
@@ -44,6 +60,7 @@ let ResolveEntityTool = class ResolveEntityTool {
|
|
|
44
60
|
userModuleIds: ctx.userModuleIds,
|
|
45
61
|
scopeId: ctx.scopeId,
|
|
46
62
|
scopeType: ctx.scopeType,
|
|
63
|
+
types: input.types,
|
|
47
64
|
}), recorder);
|
|
48
65
|
}
|
|
49
66
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolve-entity.tool.js","sourceRoot":"","sources":["../../../../src/agents/graph/tools/resolve-entity.tool.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"resolve-entity.tool.js","sourceRoot":"","sources":["../../../../src/agents/graph/tools/resolve-entity.tool.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAAiE;AACjE,iDAA8D;AAC9D,6BAAwB;AACxB,iDAA0E;AAC1E,2EA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AAE,KAAK,EAAE,EACjC,KAAK,IAAI,EAAE;QACT,sEAAsE;QACtE,+DAA+D;QAC/D,qEAAqE;QACrE,sEAAsE;QACtE,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC;YACxB,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,SAAS,EAAE,GAAG,CAAC,SAAS;YACxB,aAAa,EAAE,GAAG,CAAC,aAAa;YAChC,OAAO,EAAE,GAAG,CAAC,OAAO;YACpB,SAAS,EAAE,GAAG,CAAC,SAAS;YACxB,KAAK,EAAE,KAAK,CAAC,KAAK;SACnB,CAAC,EACJ,QAAQ,CACT,CAAC;IACJ,CAAC;CACF,CAAA;AA7CY,8CAAiB;4BAAjB,iBAAiB;IAD7B,IAAA,mBAAU,GAAE;qCAGiB,0BAAW;QACZ,yCAAkB;GAHlC,iBAAiB,CA6C7B"}
|
|
@@ -6,6 +6,13 @@ import { GraphCatalogService } from "../services/graph.catalog.service";
|
|
|
6
6
|
import { ToolFieldFormatterService } from "../services/field-formatting";
|
|
7
7
|
import { EntityServiceRegistry } from "../../../common/registries/entity.service.registry";
|
|
8
8
|
import { ScopeGuard } from "../services/scope.guard";
|
|
9
|
+
import { NormalisedFilter, NormalisedSort } from "./traverse.tool";
|
|
10
|
+
/** What a search_entities call actually ran: the coerced filters and sort and the clamped limit. */
|
|
11
|
+
export interface SearchEntitiesApplied {
|
|
12
|
+
filters: NormalisedFilter[];
|
|
13
|
+
sort: NormalisedSort[];
|
|
14
|
+
limit: number;
|
|
15
|
+
}
|
|
9
16
|
declare const inputSchema: z.ZodObject<{
|
|
10
17
|
type: z.ZodString;
|
|
11
18
|
filters: z.ZodOptional<z.ZodAny>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"search-entities.tool.d.ts","sourceRoot":"","sources":["../../../../src/agents/graph/tools/search-entities.tool.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,EAA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,qBACa,kBAAkB;IAE3B,OAAO,CAAC,QAAQ,CAAC,OAAO;IAGxB,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACzB,OAAO,CAAC,QAAQ,CAAC,UAAU;IAG3B,OAAO,CAAC,QAAQ,CAAC,SAAS;gBATT,OAAO,EAAE,WAAW,EAGpB,OAAO,EAAE,kBAAkB,EAC3B,OAAO,EAAE,mBAAmB,EAC5B,QAAQ,EAAE,qBAAqB,EAC/B,UAAU,EAAE,UAAU,EAGtB,SAAS,EAAE,yBAAyB;IAGvD,KAAK,CAAC,GAAG,EAAE,WAAW,EAAE,QAAQ,EAAE,cAAc,EAAE,GAAG,qBAAqB;IAUpE,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,EAAE,GAAG,EAAE,WAAW,EAAE,QAAQ,EAAE,cAAc,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC;IAqHhH;;;;OAIG;YACW,aAAa;YAKb,WAAW;CA0C1B"}
|
|
@@ -81,6 +81,10 @@ let SearchEntitiesTool = class SearchEntitiesTool {
|
|
|
81
81
|
schema: { fields: entity.fields, relationships: entity.relationships },
|
|
82
82
|
};
|
|
83
83
|
}
|
|
84
|
+
// Resolved before validation: a service that declares filter
|
|
85
|
+
// capabilities decides which operators run (capabilities win).
|
|
86
|
+
const svc = this.factory.resolveService(entity.type);
|
|
87
|
+
const capabilities = (0, traverse_tool_1.serviceFilterCapabilities)(svc);
|
|
84
88
|
const byName = new Map(entity.fields.map((f) => [f.name, f]));
|
|
85
89
|
const validFieldNames = entity.fields.map((f) => f.name).join(", ");
|
|
86
90
|
const relationshipNames = entity.relationships.map((r) => r.name).join(", ");
|
|
@@ -91,12 +95,9 @@ let SearchEntitiesTool = class SearchEntitiesTool {
|
|
|
91
95
|
error: `Field "${f.field}" is not available on ${entity.type}. Valid fields for filter/sort on ${entity.type}: [${validFieldNames}]. To reach records connected via a relationship, use the traverse tool — relationships on ${entity.type}: [${relationshipNames || "none"}]. Dotted paths like "account.name" are never valid here.`,
|
|
92
96
|
};
|
|
93
97
|
}
|
|
94
|
-
const
|
|
95
|
-
if (
|
|
96
|
-
return {
|
|
97
|
-
error: `Operator "${f.op}" is not valid for field "${f.field}" of type ${def.type}. Allowed operators: [${Array.from(allowed).join(", ")}].`,
|
|
98
|
-
};
|
|
99
|
-
}
|
|
98
|
+
const opError = (0, traverse_tool_1.filterOperatorError)({ field: def, op: f.op, entityType: entity.type, capabilities });
|
|
99
|
+
if (opError)
|
|
100
|
+
return { error: opError };
|
|
100
101
|
}
|
|
101
102
|
const sortableFieldNames = entity.fields
|
|
102
103
|
.filter((f) => f.sortable)
|
|
@@ -110,7 +111,6 @@ let SearchEntitiesTool = class SearchEntitiesTool {
|
|
|
110
111
|
};
|
|
111
112
|
}
|
|
112
113
|
}
|
|
113
|
-
const svc = this.factory.resolveService(entity.type);
|
|
114
114
|
if (!svc)
|
|
115
115
|
return { error: `Service not available for "${entity.type}".` };
|
|
116
116
|
const limit = Math.min(Math.max(input.limit ?? 10, 1), traverse_tool_1.MAX_LIST_LIMIT);
|
|
@@ -138,7 +138,8 @@ let SearchEntitiesTool = class SearchEntitiesTool {
|
|
|
138
138
|
}), ctx);
|
|
139
139
|
const hasMore = fetched.length > limit;
|
|
140
140
|
const records = hasMore ? fetched.slice(0, limit) : fetched;
|
|
141
|
-
const
|
|
141
|
+
const applied = { filters, sort, limit };
|
|
142
|
+
const output = await this.buildOutput(entity, records, ctx, localMaterialised, applied);
|
|
142
143
|
return hasMore
|
|
143
144
|
? {
|
|
144
145
|
...output,
|
|
@@ -162,20 +163,21 @@ let SearchEntitiesTool = class SearchEntitiesTool {
|
|
|
162
163
|
return records;
|
|
163
164
|
return this.scopeGuard.filter({ type, records, ctx });
|
|
164
165
|
}
|
|
165
|
-
async buildOutput(entity, records, ctx, localMaterialised) {
|
|
166
|
+
async buildOutput(entity, records, ctx, localMaterialised, applied) {
|
|
166
167
|
const baseItems = records.map((r) => {
|
|
167
|
-
const { fields, availableOnRead } = this.formatter.build({ entity, record: r, stage: "list" });
|
|
168
|
+
const { fields, availableOnRead, generated } = this.formatter.build({ entity, record: r, stage: "list" });
|
|
168
169
|
return {
|
|
169
170
|
id: r.id,
|
|
170
171
|
type: entity.type,
|
|
171
172
|
summary: entity.summary ? entity.summary(r) : String(r.name ?? r.id),
|
|
172
173
|
fields,
|
|
173
174
|
...(availableOnRead ? { availableOnRead } : {}),
|
|
175
|
+
...(generated ? { generated } : {}),
|
|
174
176
|
score: null,
|
|
175
177
|
};
|
|
176
178
|
});
|
|
177
179
|
if (!entity.bridge)
|
|
178
|
-
return {
|
|
180
|
+
return { applied, items: baseItems };
|
|
179
181
|
// Bridge fanout: each item is materialised. The `score` field is preserved
|
|
180
182
|
// on the envelope so the search_entities response shape doesn't drift.
|
|
181
183
|
const items = await Promise.all(baseItems.map(({ score, ...item }) => (0, materialise_bridge_1.materialiseBridge)({
|
|
@@ -189,8 +191,8 @@ let SearchEntitiesTool = class SearchEntitiesTool {
|
|
|
189
191
|
formatter: this.formatter,
|
|
190
192
|
},
|
|
191
193
|
onMaterialised: (relName, count) => localMaterialised.push({ relName, count }),
|
|
192
|
-
}).then((m) => ({ ...m, score }))));
|
|
193
|
-
return {
|
|
194
|
+
}).then((m) => ({ ...m, ...(item.generated ? { generated: item.generated } : {}), score }))));
|
|
195
|
+
return { applied, items };
|
|
194
196
|
}
|
|
195
197
|
};
|
|
196
198
|
exports.SearchEntitiesTool = SearchEntitiesTool;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"search-entities.tool.js","sourceRoot":"","sources":["../../../../src/agents/graph/tools/search-entities.tool.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA4C;AAC5C,iDAA8D;AAC9D,6BAAwB;AACxB,iDAA0E;AAE1E,2EAAsE;AACtE,6EAAwE;AACxE,mEAAyE;AACzE,uEAAmE;AACnE,gGAA2F;AAC3F,yDAAqD;AACrD,
|
|
1
|
+
{"version":3,"file":"search-entities.tool.js","sourceRoot":"","sources":["../../../../src/agents/graph/tools/search-entities.tool.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA4C;AAC5C,iDAA8D;AAC9D,6BAAwB;AACxB,iDAA0E;AAE1E,2EAAsE;AACtE,6EAAwE;AACxE,mEAAyE;AACzE,uEAAmE;AACnE,gGAA2F;AAC3F,yDAAqD;AACrD,mDASyB;AASzB,MAAM,WAAW,GAAG,OAAC;KAClB,MAAM,CAAC;IACN,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,mBAAmB,CAAC;IAC9C,OAAO,EAAE,OAAC,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE;IAC3B,IAAI,EAAE,OAAC,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE;IACxB,KAAK,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE;CACnC,CAAC;KACD,MAAM,EAAE,CAAC;AAEY,gDAAyB;AAG1C,IAAM,kBAAkB,GAAxB,MAAM,kBAAkB;IAC7B,YACmB,OAAoB;IACrC,4EAA4E;IAC5E,oDAAoD;IACnC,OAA2B,EAC3B,OAA4B,EAC5B,QAA+B,EAC/B,UAAsB;IACvC,2EAA2E;IAC3E,kDAAkD;IACjC,SAAoC;QATpC,YAAO,GAAP,OAAO,CAAa;QAGpB,YAAO,GAAP,OAAO,CAAoB;QAC3B,YAAO,GAAP,OAAO,CAAqB;QAC5B,aAAQ,GAAR,QAAQ,CAAuB;QAC/B,eAAU,GAAV,UAAU,CAAY;QAGtB,cAAS,GAAT,SAAS,CAA2B;IACpD,CAAC;IAEJ,KAAK,CAAC,GAAgB,EAAE,QAA0B;QAChD,OAAO,IAAI,6BAAqB,CAAC;YAC/B,IAAI,EAAE,iBAAiB;YACvB,WAAW,EACT,2QAA2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C,UAAU;gBAC3B,SAAS,EAAE,IAAI,CAAC,SAAS;aAC1B;YACD,cAAc,EAAE,CAAC,OAAO,EAAE,KAAK,EAAE,EAAE,CAAC,iBAAiB,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;SAC/E,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,IAAI,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAC5F,CACF,CAAC;QACF,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;IAC5B,CAAC;CACF,CAAA;AAjMY,gDAAkB;6BAAlB,kBAAkB;IAD9B,IAAA,mBAAU,GAAE;qCAGiB,0BAAW;QAGX,yCAAkB;QAClB,2CAAmB;QAClB,+CAAqB;QACnB,wBAAU;QAGX,4CAAyB;GAX5C,kBAAkB,CAiM9B"}
|
|
@@ -3,9 +3,11 @@ import { z } from "zod";
|
|
|
3
3
|
import { ToolFactory, ToolCallRecord, UserContext } from "./tool.factory";
|
|
4
4
|
import { ToolFieldFormatterService } from "../services/field-formatting";
|
|
5
5
|
import { GraphCatalogService } from "../services/graph.catalog.service";
|
|
6
|
+
import { CatalogField } from "../interfaces/graph.catalog.interface";
|
|
6
7
|
import { EntityServiceRegistry } from "../../../common/registries/entity.service.registry";
|
|
7
8
|
import { ScopeGuard } from "../services/scope.guard";
|
|
8
9
|
import { RelatedEdgesService } from "../services/related-edges.service";
|
|
10
|
+
import type { ExternalFilterCapability } from "../../../common/interfaces/external.entity.source.interface";
|
|
9
11
|
/** Every filter operator the graph tools accept, in the order they are advertised. */
|
|
10
12
|
export declare const FILTER_OPERATORS: readonly ["eq", "ne", "in", "like", "gt", "gte", "lt", "lte", "isNull", "isNotNull"];
|
|
11
13
|
export type FilterOperator = (typeof FILTER_OPERATORS)[number];
|
|
@@ -23,6 +25,28 @@ declare const FilterOpEnum: z.ZodEnum<{
|
|
|
23
25
|
}>;
|
|
24
26
|
/** Operators valid for each catalog field type. A type missing here accepts no operator. */
|
|
25
27
|
export declare const TYPE_TO_OP_ALLOWED: Record<string, Set<string>>;
|
|
28
|
+
/**
|
|
29
|
+
* The filter capabilities a type's service declares, or `undefined` when it
|
|
30
|
+
* declares none (records in the app database: the type table applies).
|
|
31
|
+
*/
|
|
32
|
+
export declare function serviceFilterCapabilities(svc: unknown): ExternalFilterCapability[] | undefined;
|
|
33
|
+
/**
|
|
34
|
+
* The operators a filter on `field` may use. When the service declares
|
|
35
|
+
* capabilities they win over the type table: exactly the operators listed for
|
|
36
|
+
* the field, none when it is not listed. Otherwise the operators of the field's type.
|
|
37
|
+
*/
|
|
38
|
+
export declare function allowedFilterOperators(field: CatalogField, capabilities: ExternalFilterCapability[] | undefined): string[];
|
|
39
|
+
/**
|
|
40
|
+
* The error for an operator a field does not accept, or `undefined` when it
|
|
41
|
+
* accepts it. The allowed list named is the one that decided: the source's
|
|
42
|
+
* capabilities when declared, the type table otherwise.
|
|
43
|
+
*/
|
|
44
|
+
export declare function filterOperatorError(params: {
|
|
45
|
+
field: CatalogField;
|
|
46
|
+
op: string;
|
|
47
|
+
entityType: string;
|
|
48
|
+
capabilities: ExternalFilterCapability[] | undefined;
|
|
49
|
+
}): string | undefined;
|
|
26
50
|
/**
|
|
27
51
|
* JSON Schema of `filters` on the MCP wire. The Zod input schemas accept `any`
|
|
28
52
|
* (coerceFilters owns the contract), so without this the client sees `{}` and
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"traverse.tool.d.ts","sourceRoot":"","sources":["../../../../src/agents/graph/tools/traverse.tool.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAC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
12
|
exports.TraverseTool = exports.MAX_LIST_LIMIT = exports.traverseInputSchema = exports.sortJsonSchema = exports.SORT_DIRECTIONS = exports.filtersJsonSchema = exports.TYPE_TO_OP_ALLOWED = exports.FILTER_OPERATORS = void 0;
|
|
13
|
+
exports.serviceFilterCapabilities = serviceFilterCapabilities;
|
|
14
|
+
exports.allowedFilterOperators = allowedFilterOperators;
|
|
15
|
+
exports.filterOperatorError = filterOperatorError;
|
|
13
16
|
exports.coerceSort = coerceSort;
|
|
14
17
|
exports.truncationNote = truncationNote;
|
|
15
18
|
exports.coerceFilters = coerceFilters;
|
|
@@ -34,6 +37,42 @@ exports.TYPE_TO_OP_ALLOWED = {
|
|
|
34
37
|
date: new Set(["eq", "ne", "gt", "gte", "lt", "lte", "isNull", "isNotNull"]),
|
|
35
38
|
datetime: new Set(["eq", "ne", "gt", "gte", "lt", "lte", "isNull", "isNotNull"]),
|
|
36
39
|
};
|
|
40
|
+
/**
|
|
41
|
+
* The filter capabilities a type's service declares, or `undefined` when it
|
|
42
|
+
* declares none (records in the app database: the type table applies).
|
|
43
|
+
*/
|
|
44
|
+
function serviceFilterCapabilities(svc) {
|
|
45
|
+
const hook = svc?.filterCapabilities;
|
|
46
|
+
return typeof hook === "function" ? hook.call(svc) : undefined;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* The operators a filter on `field` may use. When the service declares
|
|
50
|
+
* capabilities they win over the type table: exactly the operators listed for
|
|
51
|
+
* the field, none when it is not listed. Otherwise the operators of the field's type.
|
|
52
|
+
*/
|
|
53
|
+
function allowedFilterOperators(field, capabilities) {
|
|
54
|
+
if (capabilities)
|
|
55
|
+
return [...(capabilities.find((c) => c.field === field.name)?.operators ?? [])];
|
|
56
|
+
return Array.from(exports.TYPE_TO_OP_ALLOWED[field.type] ?? []);
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* The error for an operator a field does not accept, or `undefined` when it
|
|
60
|
+
* accepts it. The allowed list named is the one that decided: the source's
|
|
61
|
+
* capabilities when declared, the type table otherwise.
|
|
62
|
+
*/
|
|
63
|
+
function filterOperatorError(params) {
|
|
64
|
+
const { field, op, entityType, capabilities } = params;
|
|
65
|
+
const allowed = allowedFilterOperators(field, capabilities);
|
|
66
|
+
if (allowed.includes(op))
|
|
67
|
+
return undefined;
|
|
68
|
+
if (capabilities) {
|
|
69
|
+
const filterable = capabilities.filter((c) => c.operators.length).map((c) => c.field);
|
|
70
|
+
return allowed.length
|
|
71
|
+
? `Operator "${op}" is not valid for field "${field.name}" on ${entityType}. The source supports only: [${allowed.join(", ")}].`
|
|
72
|
+
: `Field "${field.name}" cannot be filtered on ${entityType}: the source supports no operator on it. Filterable fields on ${entityType}: [${filterable.join(", ") || "none"}].`;
|
|
73
|
+
}
|
|
74
|
+
return `Operator "${op}" is not valid for field "${field.name}" of type ${field.type}. Allowed operators: [${allowed.join(", ")}].`;
|
|
75
|
+
}
|
|
37
76
|
const FILTER_VALUE_JSON_SCHEMA = {
|
|
38
77
|
anyOf: [
|
|
39
78
|
{ type: "string" },
|
|
@@ -335,6 +374,10 @@ let TraverseTool = class TraverseTool {
|
|
|
335
374
|
const target = this.factory.resolveEntity(rel.targetType, ctx);
|
|
336
375
|
if ("error" in target)
|
|
337
376
|
return target;
|
|
377
|
+
// Resolved before validation: a service that declares filter
|
|
378
|
+
// capabilities decides which operators run (capabilities win).
|
|
379
|
+
const targetSvc = this.factory.resolveService(target.type);
|
|
380
|
+
const capabilities = serviceFilterCapabilities(targetSvc);
|
|
338
381
|
const byName = new Map(target.fields.map((f) => [f.name, f]));
|
|
339
382
|
const validFieldNames = target.fields.map((f) => f.name).join(", ");
|
|
340
383
|
const sortableFieldNames = target.fields
|
|
@@ -348,12 +391,9 @@ let TraverseTool = class TraverseTool {
|
|
|
348
391
|
error: `Field "${f.field}" is not available on ${target.type}. Valid fields on ${target.type}: [${validFieldNames}].`,
|
|
349
392
|
};
|
|
350
393
|
}
|
|
351
|
-
const
|
|
352
|
-
if (
|
|
353
|
-
return {
|
|
354
|
-
error: `Operator "${f.op}" is not valid for field "${f.field}" of type ${def.type}. Allowed operators: [${Array.from(allowed).join(", ")}].`,
|
|
355
|
-
};
|
|
356
|
-
}
|
|
394
|
+
const opError = filterOperatorError({ field: def, op: f.op, entityType: target.type, capabilities });
|
|
395
|
+
if (opError)
|
|
396
|
+
return { error: opError };
|
|
357
397
|
}
|
|
358
398
|
for (const s of sort ?? []) {
|
|
359
399
|
const def = byName.get(s.field);
|
|
@@ -363,7 +403,6 @@ let TraverseTool = class TraverseTool {
|
|
|
363
403
|
};
|
|
364
404
|
}
|
|
365
405
|
}
|
|
366
|
-
const targetSvc = this.factory.resolveService(target.type);
|
|
367
406
|
if (!targetSvc)
|
|
368
407
|
return { error: `Service not available for "${target.type}".` };
|
|
369
408
|
const limit = Math.min(Math.max(input.limit ?? 10, 1), exports.MAX_LIST_LIMIT);
|
|
@@ -394,13 +433,18 @@ let TraverseTool = class TraverseTool {
|
|
|
394
433
|
}
|
|
395
434
|
: {};
|
|
396
435
|
const baseItems = records.map((r) => {
|
|
397
|
-
const { fields, availableOnRead } = this.formatter.build({
|
|
436
|
+
const { fields, availableOnRead, generated } = this.formatter.build({
|
|
437
|
+
entity: target,
|
|
438
|
+
record: r,
|
|
439
|
+
stage: "list",
|
|
440
|
+
});
|
|
398
441
|
return {
|
|
399
442
|
id: r.id,
|
|
400
443
|
type: target.type,
|
|
401
444
|
summary: target.summary ? target.summary(r) : String(r.name ?? r.id),
|
|
402
445
|
fields,
|
|
403
446
|
...(availableOnRead ? { availableOnRead } : {}),
|
|
447
|
+
...(generated ? { generated } : {}),
|
|
404
448
|
};
|
|
405
449
|
});
|
|
406
450
|
if (!target.bridge) {
|
|
@@ -418,7 +462,7 @@ let TraverseTool = class TraverseTool {
|
|
|
418
462
|
formatter: this.formatter,
|
|
419
463
|
},
|
|
420
464
|
onMaterialised: (relName, count) => localMaterialised.push({ relName, count }),
|
|
421
|
-
})));
|
|
465
|
+
}).then((m) => (item.generated ? { ...m, generated: item.generated } : m))));
|
|
422
466
|
return { items, ...truncation };
|
|
423
467
|
}, recorder);
|
|
424
468
|
if (localMaterialised.length && recorder.length) {
|
|
@@ -518,13 +562,14 @@ let TraverseTool = class TraverseTool {
|
|
|
518
562
|
records.push(record);
|
|
519
563
|
}
|
|
520
564
|
for (const record of await this.filterInScope(type, records, ctx)) {
|
|
521
|
-
const { fields, availableOnRead } = this.formatter.build({ entity, record, stage: "list" });
|
|
565
|
+
const { fields, availableOnRead, generated } = this.formatter.build({ entity, record, stage: "list" });
|
|
522
566
|
items.push({
|
|
523
567
|
id: record.id,
|
|
524
568
|
type,
|
|
525
569
|
summary: entity.summary ? entity.summary(record) : String(record.name ?? record.id),
|
|
526
570
|
fields,
|
|
527
571
|
...(availableOnRead ? { availableOnRead } : {}),
|
|
572
|
+
...(generated ? { generated } : {}),
|
|
528
573
|
});
|
|
529
574
|
}
|
|
530
575
|
}
|