rename(phase 1): CapaKraken → Nexus across code, UI, docs, CI (#61)
CI / Architecture Guardrails (push) Successful in 2m38s
CI / Assistant Split Regression (push) Successful in 3m33s
CI / Typecheck (push) Successful in 3m51s
CI / Lint (push) Successful in 5m2s
CI / E2E Tests (push) Has been cancelled
CI / Fresh-Linux Docker Deploy (push) Has been cancelled
CI / Release Images (push) Has been cancelled
CI / Build (push) Has been cancelled
CI / Unit Tests (push) Has been cancelled
CI / Architecture Guardrails (push) Successful in 2m38s
CI / Assistant Split Regression (push) Successful in 3m33s
CI / Typecheck (push) Successful in 3m51s
CI / Lint (push) Successful in 5m2s
CI / E2E Tests (push) Has been cancelled
CI / Fresh-Linux Docker Deploy (push) Has been cancelled
CI / Release Images (push) Has been cancelled
CI / Build (push) Has been cancelled
CI / Unit Tests (push) Has been cancelled
rename(phase 1): CapaKraken → Nexus across code, UI, docs, CI (#61) Co-authored-by: Hartmut Nörenberg <hn@hartmut-noerenberg.com> Co-committed-by: Hartmut Nörenberg <hn@hartmut-noerenberg.com>
This commit was merged in pull request #61.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import type { Prisma } from "@capakraken/db";
|
||||
import type { Prisma } from "@nexus/db";
|
||||
import type { TRPCContext } from "../../trpc.js";
|
||||
import { withToolAccess, type ToolContext, type ToolDef, type ToolExecutor } from "./shared.js";
|
||||
|
||||
@@ -22,65 +22,66 @@ type CountryReadmodelsDeps = {
|
||||
};
|
||||
createScopedCallerContext: (ctx: ToolContext) => TRPCContext;
|
||||
formatCountry: (country: CountryRecord) => unknown;
|
||||
toAssistantCountryNotFoundError: (
|
||||
error: unknown,
|
||||
) => AssistantToolErrorResult | null;
|
||||
toAssistantCountryNotFoundError: (error: unknown) => AssistantToolErrorResult | null;
|
||||
};
|
||||
|
||||
export const countryReadmodelToolDefinitions: ToolDef[] = withToolAccess([
|
||||
{
|
||||
type: "function",
|
||||
function: {
|
||||
name: "list_countries",
|
||||
description: "List countries including working hours, schedule rules, active flag, and metro cities.",
|
||||
parameters: {
|
||||
type: "object",
|
||||
properties: {
|
||||
includeInactive: { type: "boolean", description: "Include inactive countries. Default: false." },
|
||||
search: { type: "string", description: "Optional country code or name search." },
|
||||
export const countryReadmodelToolDefinitions: ToolDef[] = withToolAccess(
|
||||
[
|
||||
{
|
||||
type: "function",
|
||||
function: {
|
||||
name: "list_countries",
|
||||
description:
|
||||
"List countries including working hours, schedule rules, active flag, and metro cities.",
|
||||
parameters: {
|
||||
type: "object",
|
||||
properties: {
|
||||
includeInactive: {
|
||||
type: "boolean",
|
||||
description: "Include inactive countries. Default: false.",
|
||||
},
|
||||
search: { type: "string", description: "Optional country code or name search." },
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
type: "function",
|
||||
function: {
|
||||
name: "get_country",
|
||||
description: "Get one country with schedule rules, active flag, metro cities, and resource count. Accepts ID, code, or name.",
|
||||
parameters: {
|
||||
type: "object",
|
||||
properties: {
|
||||
identifier: { type: "string", description: "Country ID, code, or name." },
|
||||
{
|
||||
type: "function",
|
||||
function: {
|
||||
name: "get_country",
|
||||
description:
|
||||
"Get one country with schedule rules, active flag, metro cities, and resource count. Accepts ID, code, or name.",
|
||||
parameters: {
|
||||
type: "object",
|
||||
properties: {
|
||||
identifier: { type: "string", description: "Country ID, code, or name." },
|
||||
},
|
||||
required: ["identifier"],
|
||||
},
|
||||
required: ["identifier"],
|
||||
},
|
||||
},
|
||||
],
|
||||
{
|
||||
get_country: {
|
||||
requiresResourceOverview: true,
|
||||
},
|
||||
},
|
||||
], {
|
||||
get_country: {
|
||||
requiresResourceOverview: true,
|
||||
},
|
||||
});
|
||||
);
|
||||
|
||||
export function createCountryReadmodelExecutors(
|
||||
deps: CountryReadmodelsDeps,
|
||||
): Record<string, ToolExecutor> {
|
||||
return {
|
||||
async list_countries(
|
||||
params: { includeInactive?: boolean; search?: string },
|
||||
ctx: ToolContext,
|
||||
) {
|
||||
async list_countries(params: { includeInactive?: boolean; search?: string }, ctx: ToolContext) {
|
||||
const caller = deps.createCountryCaller(deps.createScopedCallerContext(ctx));
|
||||
const countries = await caller.list(
|
||||
params.includeInactive
|
||||
? undefined
|
||||
: { isActive: true },
|
||||
);
|
||||
const countries = await caller.list(params.includeInactive ? undefined : { isActive: true });
|
||||
const normalizedSearch = params.search?.trim().toLowerCase();
|
||||
const filteredCountries = normalizedSearch
|
||||
? countries.filter((country) =>
|
||||
country.code.toLowerCase().includes(normalizedSearch)
|
||||
|| country.name.toLowerCase().includes(normalizedSearch))
|
||||
? countries.filter(
|
||||
(country) =>
|
||||
country.code.toLowerCase().includes(normalizedSearch) ||
|
||||
country.name.toLowerCase().includes(normalizedSearch),
|
||||
)
|
||||
: countries;
|
||||
|
||||
return {
|
||||
@@ -89,10 +90,7 @@ export function createCountryReadmodelExecutors(
|
||||
};
|
||||
},
|
||||
|
||||
async get_country(
|
||||
params: { identifier: string },
|
||||
ctx: ToolContext,
|
||||
) {
|
||||
async get_country(params: { identifier: string }, ctx: ToolContext) {
|
||||
const caller = deps.createCountryCaller(deps.createScopedCallerContext(ctx));
|
||||
let country;
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user