kibana/x-pack/solutions/chat/packages/wci-common/src/integration_tools.ts
Pierre Gayvallet c05dda37e2
[workchat] reintegrate into main (#215627)
## Summary

~**DO NOT MERGE:** depends on
https://github.com/elastic/kibana/issues/213468~

This PR reintegrates the work from the `workchat_m1` branch into `main`:

- introduces a 4th solution type, `chat`, that will be used for the
*WorkChat* project type.
- edit things in various platform code to introduce/handle that new
project type
- add plugins and packages for the workchat app. 

### To AppEx reviewers:

File change count is scary, but you can safely ignore anything from
`xpack/solutions/chat` (given it's solution code), and focus on your
owned changes, which are way more reasonable

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Joe McElroy <joseph.mcelroy@elastic.co>
Co-authored-by: Rodney Norris <rodney.norris@elastic.co>
Co-authored-by: Jedr Blaszyk <jedrazb@gmail.com>
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
Co-authored-by: Meghan Murphy <meghan.murphy@elastic.co>
2025-04-02 11:00:32 +01:00

32 lines
1 KiB
TypeScript

/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
const TOOL_NAME_SEPARATOR = '___';
export interface ToolNameAndIntegrationId {
integrationId: string;
toolName: string;
}
/**
* Generates a unique tool name based on the integrationId and base tool name.
* This is used by the orchestration layer to generate "uuids" for each integration/tool tuples.
*/
export const buildToolName = ({ integrationId, toolName }: ToolNameAndIntegrationId) => {
return `${toolName}${TOOL_NAME_SEPARATOR}${integrationId}`;
};
export const parseToolName = (fullToolName: string): ToolNameAndIntegrationId => {
const splits = fullToolName.split(TOOL_NAME_SEPARATOR);
if (splits.length !== 2) {
throw new Error(`Invalid tool name format : "${fullToolName}"`);
}
return {
toolName: splits[0],
integrationId: splits[1],
};
};