@google/adk 2.2.0 → 2.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/cjs/a2a/a2a_remote_agent.js +4 -1
- package/dist/cjs/a2a/agent_card.js +102 -26
- package/dist/cjs/a2a/agent_to_a2a.js +1 -1
- package/dist/cjs/a2a/event_converter_utils.js +5 -1
- package/dist/cjs/a2a/metadata_converter_utils.js +2 -1
- package/dist/cjs/agents/functions.js +199 -25
- package/dist/cjs/agents/instructions.js +4 -1
- package/dist/cjs/agents/invocation_context.js +26 -4
- package/dist/cjs/agents/langgraph_agent.js +152 -0
- package/dist/cjs/agents/llm_agent.js +175 -101
- package/dist/cjs/agents/processors/code_execution_request_processor.js +10 -6
- package/dist/cjs/agents/remote_agent.js +187 -0
- package/dist/cjs/artifacts/in_memory_artifact_service.js +14 -0
- package/dist/cjs/auth/auth_handler.js +37 -5
- package/dist/cjs/auth/auth_schemes.js +9 -0
- package/dist/cjs/cli/cli_eval.js +532 -0
- package/dist/cjs/cli/utils/envs.js +116 -0
- package/dist/cjs/cli/utils/evals.js +137 -0
- package/dist/cjs/cli/utils/logs.js +150 -0
- package/dist/cjs/code_executors/agent_engine_sandbox_code_executor.js +7 -2
- package/dist/cjs/code_executors/code_execution_utils.js +48 -16
- package/dist/cjs/code_executors/code_executor_context.js +6 -2
- package/dist/cjs/common.js +90 -0
- package/dist/cjs/context/summarizers/llm_summarizer.js +12 -10
- package/dist/cjs/context/token_based_context_compactor.js +2 -1
- package/dist/cjs/events/abort_events.js +135 -0
- package/dist/cjs/events/event.js +4 -2
- package/dist/cjs/events/internal_metadata.js +131 -0
- package/dist/cjs/examples/example_util.js +23 -2
- package/dist/cjs/flows/llm_flows/audio_transcriber.js +170 -0
- package/dist/cjs/index.js +97 -1
- package/dist/cjs/integrations/agent_registry/helpers.js +1 -1
- package/dist/cjs/models/gemini_llm_connection.js +16 -8
- package/dist/cjs/models/google_llm.js +13 -16
- package/dist/cjs/models/llm_response.js +9 -1
- package/dist/cjs/models/registry.js +1 -1
- package/dist/cjs/models/routed_llm.js +9 -8
- package/dist/cjs/planners/plan_re_act_planner.js +1 -1
- package/dist/cjs/plugins/debug_logging_plugin.js +653 -0
- package/dist/cjs/plugins/plugin_manager.js +1 -1
- package/dist/cjs/plugins/tool_call_integrity_plugin.js +364 -0
- package/dist/cjs/runner/in_memory_runner.js +6 -11
- package/dist/cjs/runner/runner.js +121 -35
- package/dist/cjs/sessions/db/operations.js +1 -1
- package/dist/cjs/sessions/in_memory_session_service.js +3 -1
- package/dist/cjs/sessions/state.js +8 -4
- package/dist/cjs/sessions/vertex_ai_session_service.js +34 -15
- package/dist/cjs/telemetry/tracing.js +97 -66
- package/dist/cjs/tools/agent_tool.js +44 -0
- package/dist/cjs/tools/apihub_tool/apihub_toolset.js +142 -0
- package/dist/cjs/tools/apihub_tool/clients/apihub_client.js +272 -0
- package/dist/cjs/tools/apihub_tool/clients/secret_client.js +148 -0
- package/dist/cjs/tools/apihub_tool/clients/service_account.js +48 -0
- package/dist/cjs/tools/application_integration_tool/application_integration_toolset.js +185 -0
- package/dist/cjs/tools/application_integration_tool/clients/cloud_request.js +133 -0
- package/dist/cjs/tools/application_integration_tool/clients/connections_client.js +603 -0
- package/dist/cjs/tools/application_integration_tool/clients/integration_client.js +219 -0
- package/dist/cjs/tools/crewai_tool.js +132 -0
- package/dist/cjs/tools/example_tool.js +10 -0
- package/dist/cjs/tools/function_tool.js +319 -0
- package/dist/cjs/tools/google_api_tool/google_api_tool.js +97 -0
- package/dist/cjs/tools/google_api_tool/google_api_tool_set.js +226 -0
- package/dist/cjs/tools/google_api_tool/google_api_tool_sets.js +58 -0
- package/dist/cjs/tools/google_api_tool/googleapi_to_openapi_converter.js +440 -0
- package/dist/cjs/tools/google_api_tool/index.js +64 -0
- package/dist/cjs/tools/langchain_tool.js +172 -0
- package/dist/cjs/tools/mcp/index.js +12 -0
- package/dist/cjs/tools/mcp/mcp_session_manager.js +25 -0
- package/dist/cjs/tools/openapi_tool/auth/auth_helpers.js +1 -2
- package/dist/cjs/tools/openapi_tool/auth/credential_exchangers/auto_auth_credential_exchanger.js +46 -2
- package/dist/cjs/tools/openapi_tool/auth/credential_exchangers/oauth2_exchanger.js +2 -1
- package/dist/cjs/tools/openapi_tool/auth/credential_exchangers/service_account_exchanger.js +94 -10
- package/dist/cjs/tools/openapi_tool/openapi_spec_parser/tool_auth_handler.js +14 -2
- package/dist/cjs/tools/retrieval/base_retrieval_tool.js +18 -3
- package/dist/cjs/tools/toolbox_tool.js +108 -0
- package/dist/cjs/utils/env_aware_utils.js +6 -8
- package/dist/cjs/utils/error_utils.js +11 -11
- package/dist/cjs/utils/file_extension_utils.js +11 -0
- package/dist/cjs/utils/file_utils.js +2 -24
- package/dist/cjs/utils/gemini_schema_util.js +4 -1
- package/dist/cjs/utils/json_utils.js +49 -0
- package/dist/cjs/utils/live_connection_utils.js +4 -5
- package/dist/cjs/utils/logger_node.js +7 -1
- package/dist/cjs/utils/object_notation_utils.js +6 -3
- package/dist/cjs/utils/streaming_utils.js +12 -12
- package/dist/cjs/version.js +1 -1
- package/dist/esm/a2a/a2a_remote_agent.js +4 -1
- package/dist/esm/a2a/agent_card.js +103 -27
- package/dist/esm/a2a/agent_to_a2a.js +5 -2
- package/dist/esm/a2a/event_converter_utils.js +5 -1
- package/dist/esm/a2a/metadata_converter_utils.js +2 -1
- package/dist/esm/agents/functions.js +198 -25
- package/dist/esm/agents/instructions.js +4 -1
- package/dist/esm/agents/invocation_context.js +24 -4
- package/dist/esm/agents/langgraph_agent.js +123 -0
- package/dist/esm/agents/llm_agent.js +185 -104
- package/dist/esm/agents/processors/code_execution_request_processor.js +13 -8
- package/dist/esm/agents/remote_agent.js +164 -0
- package/dist/esm/artifacts/in_memory_artifact_service.js +14 -0
- package/dist/esm/auth/auth_handler.js +37 -5
- package/dist/esm/auth/auth_schemes.js +8 -0
- package/dist/esm/cli/cli_eval.js +510 -0
- package/dist/esm/cli/utils/envs.js +78 -0
- package/dist/esm/cli/utils/evals.js +109 -0
- package/dist/esm/cli/utils/logs.js +111 -0
- package/dist/esm/code_executors/agent_engine_sandbox_code_executor.js +7 -2
- package/dist/esm/code_executors/code_execution_utils.js +46 -16
- package/dist/esm/code_executors/code_executor_context.js +5 -2
- package/dist/esm/common.js +87 -3
- package/dist/esm/context/summarizers/llm_summarizer.js +12 -10
- package/dist/esm/context/token_based_context_compactor.js +2 -1
- package/dist/esm/events/abort_events.js +110 -0
- package/dist/esm/events/event.js +4 -2
- package/dist/esm/events/internal_metadata.js +97 -0
- package/dist/esm/examples/example_util.js +21 -1
- package/dist/esm/flows/llm_flows/audio_transcriber.js +142 -0
- package/dist/esm/index.js +99 -1
- package/dist/esm/integrations/agent_registry/helpers.js +1 -1
- package/dist/esm/models/gemini_llm_connection.js +16 -8
- package/dist/esm/models/google_llm.js +14 -17
- package/dist/esm/models/llm_response.js +9 -1
- package/dist/esm/models/registry.js +1 -1
- package/dist/esm/models/routed_llm.js +9 -8
- package/dist/esm/planners/plan_re_act_planner.js +1 -1
- package/dist/esm/plugins/debug_logging_plugin.js +615 -0
- package/dist/esm/plugins/plugin_manager.js +1 -1
- package/dist/esm/plugins/tool_call_integrity_plugin.js +339 -0
- package/dist/esm/runner/in_memory_runner.js +6 -11
- package/dist/esm/runner/runner.js +124 -35
- package/dist/esm/sessions/db/operations.js +1 -1
- package/dist/esm/sessions/in_memory_session_service.js +3 -1
- package/dist/esm/sessions/state.js +8 -4
- package/dist/esm/sessions/vertex_ai_session_service.js +34 -15
- package/dist/esm/telemetry/tracing.js +97 -66
- package/dist/esm/tools/agent_tool.js +44 -0
- package/dist/esm/tools/apihub_tool/apihub_toolset.js +106 -0
- package/dist/esm/tools/apihub_tool/clients/apihub_client.js +244 -0
- package/dist/esm/tools/apihub_tool/clients/secret_client.js +132 -0
- package/dist/esm/tools/apihub_tool/clients/service_account.js +21 -0
- package/dist/esm/tools/application_integration_tool/application_integration_toolset.js +163 -0
- package/dist/esm/tools/application_integration_tool/clients/cloud_request.js +103 -0
- package/dist/esm/tools/application_integration_tool/clients/connections_client.js +561 -0
- package/dist/esm/tools/application_integration_tool/clients/integration_client.js +215 -0
- package/dist/esm/tools/crewai_tool.js +107 -0
- package/dist/esm/tools/example_tool.js +13 -1
- package/dist/esm/tools/function_tool.js +316 -0
- package/dist/esm/tools/google_api_tool/google_api_tool.js +70 -0
- package/dist/esm/tools/google_api_tool/google_api_tool_set.js +188 -0
- package/dist/esm/tools/google_api_tool/google_api_tool_sets.js +24 -0
- package/dist/esm/tools/google_api_tool/googleapi_to_openapi_converter.js +393 -0
- package/dist/esm/tools/google_api_tool/index.js +33 -0
- package/dist/esm/tools/langchain_tool.js +148 -0
- package/dist/esm/tools/mcp/index.js +6 -0
- package/dist/esm/tools/mcp/mcp_session_manager.js +25 -0
- package/dist/esm/tools/openapi_tool/auth/auth_helpers.js +1 -2
- package/dist/esm/tools/openapi_tool/auth/credential_exchangers/auto_auth_credential_exchanger.js +50 -3
- package/dist/esm/tools/openapi_tool/auth/credential_exchangers/oauth2_exchanger.js +2 -1
- package/dist/esm/tools/openapi_tool/auth/credential_exchangers/service_account_exchanger.js +94 -10
- package/dist/esm/tools/openapi_tool/openapi_spec_parser/tool_auth_handler.js +15 -2
- package/dist/esm/tools/retrieval/base_retrieval_tool.js +16 -2
- package/dist/esm/tools/toolbox_tool.js +80 -0
- package/dist/esm/utils/env_aware_utils.js +6 -8
- package/dist/esm/utils/error_utils.js +9 -10
- package/dist/esm/utils/file_extension_utils.js +11 -0
- package/dist/esm/utils/file_utils.js +2 -23
- package/dist/esm/utils/gemini_schema_util.js +4 -1
- package/dist/esm/utils/json_utils.js +21 -0
- package/dist/esm/utils/live_connection_utils.js +4 -5
- package/dist/esm/utils/logger_node.js +7 -1
- package/dist/esm/utils/object_notation_utils.js +4 -2
- package/dist/esm/utils/streaming_utils.js +11 -11
- package/dist/esm/version.js +1 -1
- package/dist/types/a2a/a2a_remote_agent.d.ts +9 -0
- package/dist/types/a2a/agent_card.d.ts +44 -1
- package/dist/types/a2a/agent_to_a2a.d.ts +9 -0
- package/dist/types/a2a/index.d.ts +1 -0
- package/dist/types/agents/functions.d.ts +33 -1
- package/dist/types/agents/invocation_context.d.ts +20 -1
- package/dist/types/agents/langgraph_agent.d.ts +153 -0
- package/dist/types/agents/remote_agent.d.ts +68 -0
- package/dist/types/auth/auth_handler.d.ts +28 -1
- package/dist/types/auth/auth_schemes.d.ts +13 -0
- package/dist/types/cli/cli_eval.d.ts +173 -0
- package/dist/types/cli/utils/envs.d.ts +23 -0
- package/dist/types/cli/utils/evals.d.ts +47 -0
- package/dist/types/cli/utils/logs.d.ts +38 -0
- package/dist/types/code_executors/code_execution_utils.d.ts +39 -0
- package/dist/types/code_executors/code_executor_context.d.ts +1 -0
- package/dist/types/common.d.ts +30 -4
- package/dist/types/events/abort_events.d.ts +43 -0
- package/dist/types/events/event.d.ts +4 -0
- package/dist/types/events/internal_metadata.d.ts +78 -0
- package/dist/types/examples/example_util.d.ts +17 -0
- package/dist/types/flows/llm_flows/audio_transcriber.d.ts +85 -0
- package/dist/types/index.d.ts +16 -1
- package/dist/types/models/gemini_llm_connection.d.ts +6 -7
- package/dist/types/models/routed_llm.d.ts +1 -1
- package/dist/types/plugins/debug_logging_plugin.d.ts +157 -0
- package/dist/types/plugins/tool_call_integrity_plugin.d.ts +116 -0
- package/dist/types/runner/in_memory_runner.d.ts +2 -1
- package/dist/types/runner/runner.d.ts +34 -0
- package/dist/types/sessions/state.d.ts +5 -1
- package/dist/types/sessions/vertex_ai_session_service.d.ts +8 -0
- package/dist/types/skills/skill.d.ts +1 -1
- package/dist/types/telemetry/tracing.d.ts +4 -2
- package/dist/types/tools/apihub_tool/apihub_toolset.d.ts +122 -0
- package/dist/types/tools/apihub_tool/clients/apihub_client.d.ts +142 -0
- package/dist/types/tools/apihub_tool/clients/secret_client.d.ts +55 -0
- package/dist/types/tools/apihub_tool/clients/service_account.d.ts +11 -0
- package/dist/types/tools/application_integration_tool/application_integration_toolset.d.ts +86 -0
- package/dist/types/tools/application_integration_tool/clients/cloud_request.d.ts +53 -0
- package/dist/types/tools/application_integration_tool/clients/connections_client.d.ts +215 -0
- package/dist/types/tools/application_integration_tool/clients/integration_client.d.ts +72 -0
- package/dist/types/tools/crewai_tool.d.ts +85 -0
- package/dist/types/tools/example_tool.d.ts +10 -0
- package/dist/types/tools/function_tool.d.ts +32 -0
- package/dist/types/tools/google_api_tool/google_api_tool.d.ts +30 -0
- package/dist/types/tools/google_api_tool/google_api_tool_set.d.ts +78 -0
- package/dist/types/tools/google_api_tool/google_api_tool_sets.d.ts +33 -0
- package/dist/types/tools/google_api_tool/googleapi_to_openapi_converter.d.ts +164 -0
- package/dist/types/tools/google_api_tool/index.d.ts +11 -0
- package/dist/types/tools/langchain_tool.d.ts +103 -0
- package/dist/types/tools/mcp/index.d.ts +3 -0
- package/dist/types/tools/mcp/mcp_session_manager.d.ts +34 -1
- package/dist/types/tools/mcp/mcp_toolset.d.ts +15 -0
- package/dist/types/tools/openapi_tool/auth/auth_helpers.d.ts +19 -0
- package/dist/types/tools/openapi_tool/auth/credential_exchangers/auto_auth_credential_exchanger.d.ts +18 -1
- package/dist/types/tools/openapi_tool/openapi_spec_parser/tool_auth_handler.d.ts +2 -1
- package/dist/types/tools/retrieval/base_retrieval_tool.d.ts +15 -0
- package/dist/types/tools/toolbox_tool.d.ts +73 -0
- package/dist/types/utils/env_aware_utils.d.ts +18 -2
- package/dist/types/utils/error_utils.d.ts +7 -0
- package/dist/types/utils/file_utils.d.ts +6 -1
- package/dist/types/utils/gemini_schema_util.d.ts +1 -2
- package/dist/types/utils/json_utils.d.ts +11 -0
- package/dist/types/utils/object_notation_utils.d.ts +7 -0
- package/dist/types/utils/streaming_utils.d.ts +11 -4
- package/dist/types/version.d.ts +1 -1
- package/dist/web/index_web.js +105 -106
- package/dist/web/index_web.js.map +4 -4
- package/package.json +8 -3
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { OpenAPIV3 } from 'openapi-types';
|
|
7
|
+
import { ReadonlyContext } from '../../agents/readonly_context.js';
|
|
8
|
+
import { AuthCredential } from '../../auth/auth_credential.js';
|
|
9
|
+
import { BaseTool } from '../base_tool.js';
|
|
10
|
+
import { BaseToolset } from '../base_toolset.js';
|
|
11
|
+
import { RestApiTool } from '../openapi_tool/rest_api_tool.js';
|
|
12
|
+
import { BaseAPIHubClient } from './clients/apihub_client.js';
|
|
13
|
+
/** Options for {@link APIHubToolset}. */
|
|
14
|
+
export interface APIHubToolsetOptions {
|
|
15
|
+
/**
|
|
16
|
+
* The API Hub resource to build tools from. It must name an API, and may
|
|
17
|
+
* also name a version and a spec, for example
|
|
18
|
+
* `projects/my-project/locations/us-central1/apis/my-api`. An API Hub
|
|
19
|
+
* console URL is also accepted.
|
|
20
|
+
*
|
|
21
|
+
* When it names a spec, that spec is used. Otherwise the first spec of the
|
|
22
|
+
* named version, or of the first version of the named API, is used.
|
|
23
|
+
*/
|
|
24
|
+
apihubResourceName: string;
|
|
25
|
+
/**
|
|
26
|
+
* An OAuth access token for API Hub, for example the output of
|
|
27
|
+
* `gcloud auth print-access-token`. Ignored when `apihubClient` is set.
|
|
28
|
+
*/
|
|
29
|
+
accessToken?: string;
|
|
30
|
+
/**
|
|
31
|
+
* The content of a service account key file, as a JSON string, used to
|
|
32
|
+
* authenticate to API Hub when `accessToken` is not set. Ignored when
|
|
33
|
+
* `apihubClient` is set.
|
|
34
|
+
*/
|
|
35
|
+
serviceAccountJson?: string;
|
|
36
|
+
/**
|
|
37
|
+
* The toolset name. When empty, it is set from the spec's `info.title` in
|
|
38
|
+
* snake_case, or `unnamed` when the spec has no title.
|
|
39
|
+
*/
|
|
40
|
+
name?: string;
|
|
41
|
+
/**
|
|
42
|
+
* The toolset description. When empty, it is set from the spec's
|
|
43
|
+
* `info.description`.
|
|
44
|
+
*/
|
|
45
|
+
description?: string;
|
|
46
|
+
/**
|
|
47
|
+
* When true, the spec is fetched on the first call to `getTools` or
|
|
48
|
+
* `getTool` instead of when the toolset is constructed.
|
|
49
|
+
*/
|
|
50
|
+
lazyLoadSpec?: boolean;
|
|
51
|
+
/** Auth scheme applied to every tool the spec produces. */
|
|
52
|
+
authScheme?: OpenAPIV3.SecuritySchemeObject;
|
|
53
|
+
/** Auth credential applied to every tool the spec produces. */
|
|
54
|
+
authCredential?: AuthCredential;
|
|
55
|
+
/**
|
|
56
|
+
* The client that fetches the spec. Defaults to an {@link APIHubClient}
|
|
57
|
+
* built from `accessToken` and `serviceAccountJson`.
|
|
58
|
+
*/
|
|
59
|
+
apihubClient?: BaseAPIHubClient;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Builds one tool per operation of an API registered in API Hub.
|
|
63
|
+
*
|
|
64
|
+
* The toolset fetches an OpenAPI spec from API Hub, parses it as YAML or JSON,
|
|
65
|
+
* and hands it to an {@link OpenAPIToolset}, which produces a
|
|
66
|
+
* {@link RestApiTool} for each operation.
|
|
67
|
+
*
|
|
68
|
+
* ```ts
|
|
69
|
+
* const toolset = new APIHubToolset({
|
|
70
|
+
* apihubResourceName:
|
|
71
|
+
* 'projects/my-project/locations/us-central1/apis/my-api',
|
|
72
|
+
* });
|
|
73
|
+
* const agent = new LlmAgent({
|
|
74
|
+
* name: 'api_agent',
|
|
75
|
+
* model: 'gemini-flash-latest',
|
|
76
|
+
* tools: [toolset],
|
|
77
|
+
* });
|
|
78
|
+
* ```
|
|
79
|
+
*
|
|
80
|
+
* By default the spec is fetched when the toolset is constructed. A
|
|
81
|
+
* constructor cannot wait for the request, so a failure is reported by the
|
|
82
|
+
* first call to `getTools` or `getTool`, and every later call reports the same
|
|
83
|
+
* failure.
|
|
84
|
+
*
|
|
85
|
+
* With `lazyLoadSpec`, the spec is fetched on the first call to `getTools` or
|
|
86
|
+
* `getTool`. A successful result is kept, including a spec that produced no
|
|
87
|
+
* tools. A failed fetch is not kept, so the next call fetches again.
|
|
88
|
+
*/
|
|
89
|
+
export declare class APIHubToolset extends BaseToolset {
|
|
90
|
+
/** The toolset name, filled in from the spec when empty. */
|
|
91
|
+
name: string;
|
|
92
|
+
/** The toolset description, filled in from the spec when empty. */
|
|
93
|
+
description: string;
|
|
94
|
+
readonly apihubResourceName: string;
|
|
95
|
+
readonly lazyLoadSpec: boolean;
|
|
96
|
+
private readonly apihubClient;
|
|
97
|
+
private readonly authScheme?;
|
|
98
|
+
private readonly authCredential?;
|
|
99
|
+
private toolsetPromise?;
|
|
100
|
+
constructor(options: APIHubToolsetOptions);
|
|
101
|
+
/**
|
|
102
|
+
* Returns one tool per operation in the spec, or an empty array when the
|
|
103
|
+
* spec is empty.
|
|
104
|
+
*
|
|
105
|
+
* @throws When the spec cannot be fetched or is not valid YAML or JSON.
|
|
106
|
+
*/
|
|
107
|
+
getTools(context?: ReadonlyContext): Promise<BaseTool[]>;
|
|
108
|
+
/**
|
|
109
|
+
* Returns the tool with the given name, or `undefined` when the spec
|
|
110
|
+
* produced no such tool.
|
|
111
|
+
*
|
|
112
|
+
* Unlike `OpenAPIToolset.getTool`, the result is a Promise, because the spec
|
|
113
|
+
* may still be loading.
|
|
114
|
+
*
|
|
115
|
+
* @param name The tool name, which is the operation ID in snake_case.
|
|
116
|
+
* @throws When the spec cannot be fetched or is not valid YAML or JSON.
|
|
117
|
+
*/
|
|
118
|
+
getTool(name: string): Promise<RestApiTool | undefined>;
|
|
119
|
+
close(): Promise<void>;
|
|
120
|
+
private loadToolset;
|
|
121
|
+
private prepareTools;
|
|
122
|
+
}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Fetches the content of an API specification registered in API Hub.
|
|
8
|
+
*
|
|
9
|
+
* Implement this interface to give an `APIHubToolset` a different source of
|
|
10
|
+
* specs, such as a cache, a local file, or a test double.
|
|
11
|
+
*/
|
|
12
|
+
export interface BaseAPIHubClient {
|
|
13
|
+
/**
|
|
14
|
+
* Returns the content of the spec that `path` resolves to.
|
|
15
|
+
*
|
|
16
|
+
* @param path An API, API version or API spec resource name, or an API Hub
|
|
17
|
+
* console URL.
|
|
18
|
+
*/
|
|
19
|
+
getSpecContent(path: string): Promise<string>;
|
|
20
|
+
}
|
|
21
|
+
/** Options for {@link APIHubClient}. */
|
|
22
|
+
export interface APIHubClientOptions {
|
|
23
|
+
/**
|
|
24
|
+
* An OAuth access token sent as the bearer token on every request, for
|
|
25
|
+
* example the output of `gcloud auth print-access-token`. Takes precedence
|
|
26
|
+
* over `serviceAccountJson`.
|
|
27
|
+
*/
|
|
28
|
+
accessToken?: string;
|
|
29
|
+
/**
|
|
30
|
+
* The content of a service account key file, as a JSON string. Used to mint
|
|
31
|
+
* access tokens when `accessToken` is not set. When neither is set, the
|
|
32
|
+
* client uses application default credentials.
|
|
33
|
+
*/
|
|
34
|
+
serviceAccountJson?: string;
|
|
35
|
+
}
|
|
36
|
+
/** An API resource as API Hub returns it. */
|
|
37
|
+
export interface APIHubApi {
|
|
38
|
+
/** Resource name, `projects/{p}/locations/{l}/apis/{a}`. */
|
|
39
|
+
name: string;
|
|
40
|
+
/** Resource names of the versions of this API. */
|
|
41
|
+
versions?: string[];
|
|
42
|
+
}
|
|
43
|
+
/** An API version resource as API Hub returns it. */
|
|
44
|
+
export interface APIHubApiVersion {
|
|
45
|
+
/** Resource name, `projects/{p}/locations/{l}/apis/{a}/versions/{v}`. */
|
|
46
|
+
name: string;
|
|
47
|
+
/** Resource names of the specs attached to this version. */
|
|
48
|
+
specs?: string[];
|
|
49
|
+
}
|
|
50
|
+
/** The resource names parsed out of an API Hub path or URL. */
|
|
51
|
+
export interface APIHubResourceNames {
|
|
52
|
+
/** `projects/{p}/locations/{l}/apis/{a}`. */
|
|
53
|
+
apiResourceName: string;
|
|
54
|
+
/** `.../apis/{a}/versions/{v}`, when the input names a version. */
|
|
55
|
+
apiVersionResourceName?: string;
|
|
56
|
+
/** `.../versions/{v}/specs/{s}`, when the input names a version and a spec. */
|
|
57
|
+
apiSpecResourceName?: string;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Client for the API Hub REST API.
|
|
61
|
+
*
|
|
62
|
+
* Each request sends a bearer token. The token is `accessToken` when it is
|
|
63
|
+
* set; otherwise the client mints one from `serviceAccountJson`, or from
|
|
64
|
+
* application default credentials when that is not set either. Minted tokens
|
|
65
|
+
* are cached and refreshed by `google-auth-library`.
|
|
66
|
+
*/
|
|
67
|
+
export declare class APIHubClient implements BaseAPIHubClient {
|
|
68
|
+
private readonly accessToken?;
|
|
69
|
+
private readonly serviceAccountJson?;
|
|
70
|
+
private auth?;
|
|
71
|
+
constructor(options?: APIHubClientOptions);
|
|
72
|
+
/**
|
|
73
|
+
* Returns the content of the first spec that `path` resolves to.
|
|
74
|
+
*
|
|
75
|
+
* - A path naming an API resolves to the first spec of its first version.
|
|
76
|
+
* - A path naming an API version resolves to the first spec of that version.
|
|
77
|
+
* - A path naming an API spec resolves to that spec.
|
|
78
|
+
*
|
|
79
|
+
* `path` may be a resource name such as
|
|
80
|
+
* `projects/my-project/locations/us-central1/apis/my-api`, or a console URL
|
|
81
|
+
* such as
|
|
82
|
+
* `https://console.cloud.google.com/apigee/api-hub/locations/us-central1/apis/my-api?project=my-project`.
|
|
83
|
+
*
|
|
84
|
+
* @param path The API, API version or API spec to read.
|
|
85
|
+
* @return The decoded spec content, or `''` when the spec is empty.
|
|
86
|
+
* @throws When the path cannot be parsed, when the API has no versions, when
|
|
87
|
+
* the version has no specs, or when a request fails.
|
|
88
|
+
*/
|
|
89
|
+
getSpecContent(path: string): Promise<string>;
|
|
90
|
+
/**
|
|
91
|
+
* Lists the APIs registered in a project and location.
|
|
92
|
+
*
|
|
93
|
+
* @param project The Google Cloud project ID.
|
|
94
|
+
* @param location The API Hub location, for example `us-central1`.
|
|
95
|
+
* @return The APIs, or an empty array when there are none.
|
|
96
|
+
*/
|
|
97
|
+
listApis(project: string, location: string): Promise<APIHubApi[]>;
|
|
98
|
+
/**
|
|
99
|
+
* Gets an API by resource name.
|
|
100
|
+
*
|
|
101
|
+
* @param apiResourceName `projects/{p}/locations/{l}/apis/{a}`.
|
|
102
|
+
*/
|
|
103
|
+
getApi(apiResourceName: string): Promise<APIHubApi>;
|
|
104
|
+
/**
|
|
105
|
+
* Gets an API version by resource name.
|
|
106
|
+
*
|
|
107
|
+
* @param apiVersionName `projects/{p}/locations/{l}/apis/{a}/versions/{v}`.
|
|
108
|
+
*/
|
|
109
|
+
getApiVersion(apiVersionName: string): Promise<APIHubApiVersion>;
|
|
110
|
+
/** Reads the base64-encoded contents of a spec and decodes them as UTF-8. */
|
|
111
|
+
private fetchSpec;
|
|
112
|
+
/** Sends an authenticated GET request and parses the JSON response. */
|
|
113
|
+
private get;
|
|
114
|
+
/**
|
|
115
|
+
* Returns the bearer token for the next request.
|
|
116
|
+
*
|
|
117
|
+
* `GoogleAuth` is created once and reused, so that it can cache the token
|
|
118
|
+
* and refresh it when it expires.
|
|
119
|
+
*/
|
|
120
|
+
private getAccessToken;
|
|
121
|
+
/**
|
|
122
|
+
* Builds the error for a token that could not be obtained.
|
|
123
|
+
*
|
|
124
|
+
* Without a service account, the likely fix is to supply a credential. With
|
|
125
|
+
* one, the key itself was rejected, so the error says so and gives the
|
|
126
|
+
* reason.
|
|
127
|
+
*/
|
|
128
|
+
private tokenError;
|
|
129
|
+
private createAuth;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Extracts the API, API version and API spec resource names from an API Hub
|
|
133
|
+
* resource path or console URL.
|
|
134
|
+
*
|
|
135
|
+
* The project comes from a `projects/{p}` segment, or from a `project` query
|
|
136
|
+
* parameter when the path has none. The location and the API are required.
|
|
137
|
+
* The spec name is returned only when both a version and a spec are present.
|
|
138
|
+
*
|
|
139
|
+
* @param urlOrPath A resource name, or a console URL under `api-hub/`.
|
|
140
|
+
* @throws When the project, the location or the API cannot be found.
|
|
141
|
+
*/
|
|
142
|
+
export declare function extractResourceName(urlOrPath: string): APIHubResourceNames;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
/** Options for {@link SecretManagerClient}. */
|
|
7
|
+
export interface SecretManagerClientOptions {
|
|
8
|
+
/**
|
|
9
|
+
* The content of a service account key file, as a JSON string, not a path.
|
|
10
|
+
* Takes precedence over `authToken`.
|
|
11
|
+
*/
|
|
12
|
+
serviceAccountJson?: string;
|
|
13
|
+
/** An existing OAuth access token. */
|
|
14
|
+
authToken?: string;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Reads secrets from Google Cloud Secret Manager.
|
|
18
|
+
*
|
|
19
|
+
* The client authenticates with `serviceAccountJson` when it is set, then with
|
|
20
|
+
* `authToken`, and otherwise with application default credentials.
|
|
21
|
+
*
|
|
22
|
+
* `@google-cloud/secret-manager` is an optional peer dependency. It is loaded
|
|
23
|
+
* on the first call to {@link SecretManagerClient.getSecret}, so constructing
|
|
24
|
+
* the client does not require it.
|
|
25
|
+
*/
|
|
26
|
+
export declare class SecretManagerClient {
|
|
27
|
+
private readonly credentials?;
|
|
28
|
+
private readonly authToken?;
|
|
29
|
+
private clientPromise?;
|
|
30
|
+
/**
|
|
31
|
+
* @throws `Invalid service account JSON: ...` when `serviceAccountJson`
|
|
32
|
+
* does not parse.
|
|
33
|
+
*/
|
|
34
|
+
constructor(options?: SecretManagerClientOptions);
|
|
35
|
+
/**
|
|
36
|
+
* Returns the payload of a secret version as a UTF-8 string.
|
|
37
|
+
*
|
|
38
|
+
* @param resourceName The secret version, in the form
|
|
39
|
+
* `projects/{project}/secrets/{secret}/versions/{version}`. Use
|
|
40
|
+
* `latest` as the version to read the newest one.
|
|
41
|
+
* @throws When default credentials are needed and cannot be resolved, or
|
|
42
|
+
* when Secret Manager returns an error, such as a missing secret or a
|
|
43
|
+
* denied permission.
|
|
44
|
+
*/
|
|
45
|
+
getSecret(resourceName: string): Promise<string>;
|
|
46
|
+
/**
|
|
47
|
+
* Resolves the Secret Manager client, loading the optional peer and the
|
|
48
|
+
* credentials on first use.
|
|
49
|
+
*
|
|
50
|
+
* A created client is kept. A failure is not kept, so the next call tries
|
|
51
|
+
* again, for example once default credentials become available.
|
|
52
|
+
*/
|
|
53
|
+
private getClient;
|
|
54
|
+
private createClient;
|
|
55
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Parses a service account key from its JSON text.
|
|
8
|
+
*
|
|
9
|
+
* @throws `Invalid service account JSON: ...` when `json` does not parse.
|
|
10
|
+
*/
|
|
11
|
+
export declare function parseServiceAccountJson(json: string): Record<string, string>;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { BaseTool } from '../base_tool.js';
|
|
7
|
+
import { BaseToolset } from '../base_toolset.js';
|
|
8
|
+
/** Options of {@link ApplicationIntegrationToolset}. */
|
|
9
|
+
export interface ApplicationIntegrationToolsetOptions {
|
|
10
|
+
/** The Google Cloud project ID. */
|
|
11
|
+
project: string;
|
|
12
|
+
/** The Google Cloud location, such as `us-central1`. */
|
|
13
|
+
location: string;
|
|
14
|
+
/** The integration name. Set it together with `trigger`. */
|
|
15
|
+
integration?: string;
|
|
16
|
+
/** The API trigger ID of the integration, such as `api_trigger/my_trigger`. */
|
|
17
|
+
trigger?: string;
|
|
18
|
+
/**
|
|
19
|
+
* The Integration Connectors connection name. Set it together with
|
|
20
|
+
* `entityOperations`, `actions`, or both.
|
|
21
|
+
*/
|
|
22
|
+
connection?: string;
|
|
23
|
+
/**
|
|
24
|
+
* Operations to expose, keyed by entity name, such as
|
|
25
|
+
* `{Issues: ['LIST', 'GET']}`. An empty list exposes every operation the
|
|
26
|
+
* entity supports.
|
|
27
|
+
*/
|
|
28
|
+
entityOperations?: Record<string, string[]>;
|
|
29
|
+
/** Connection actions to expose, such as `['ExecuteCustomQuery']`. */
|
|
30
|
+
actions?: string[];
|
|
31
|
+
/** Prefix of every generated tool name. Defaults to `''`. */
|
|
32
|
+
toolName?: string;
|
|
33
|
+
/** Text appended to every generated tool description. Defaults to `''`. */
|
|
34
|
+
toolInstructions?: string;
|
|
35
|
+
/**
|
|
36
|
+
* A service-account key, as a JSON string. It authenticates both the spec
|
|
37
|
+
* requests and the generated tools. When omitted, both use Application
|
|
38
|
+
* Default Credentials.
|
|
39
|
+
*/
|
|
40
|
+
serviceAccountJson?: string;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* A toolset generated from a Google Cloud Application Integration API trigger,
|
|
44
|
+
* or from the entity operations and actions of an Integration Connectors
|
|
45
|
+
* connection.
|
|
46
|
+
*
|
|
47
|
+
* The constructor only validates the options. The first `getTools` call
|
|
48
|
+
* fetches the spec and builds the tools, and later calls reuse them.
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* // Every operation of an integration API trigger.
|
|
52
|
+
* const integrationToolset = new ApplicationIntegrationToolset({
|
|
53
|
+
* project: 'my-project',
|
|
54
|
+
* location: 'us-central1',
|
|
55
|
+
* integration: 'my-integration',
|
|
56
|
+
* trigger: 'api_trigger/my_trigger',
|
|
57
|
+
* });
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* // Entity operations and actions of a connection.
|
|
61
|
+
* const connectionToolset = new ApplicationIntegrationToolset({
|
|
62
|
+
* project: 'my-project',
|
|
63
|
+
* location: 'us-central1',
|
|
64
|
+
* connection: 'my-connection',
|
|
65
|
+
* entityOperations: {Issues: ['LIST', 'GET'], Projects: []},
|
|
66
|
+
* actions: ['ExecuteCustomQuery'],
|
|
67
|
+
* });
|
|
68
|
+
*/
|
|
69
|
+
export declare class ApplicationIntegrationToolset extends BaseToolset {
|
|
70
|
+
private readonly options;
|
|
71
|
+
private toolsPromise?;
|
|
72
|
+
/**
|
|
73
|
+
* @throws Error Unless the options name either an integration and a trigger,
|
|
74
|
+
* or a connection with at least one entity operation or action.
|
|
75
|
+
*/
|
|
76
|
+
constructor(options: ApplicationIntegrationToolsetOptions);
|
|
77
|
+
/**
|
|
78
|
+
* Returns the generated tools.
|
|
79
|
+
*
|
|
80
|
+
* The first call fetches the spec and builds the tools. Concurrent calls
|
|
81
|
+
* share that load. When it fails, the next call tries again.
|
|
82
|
+
*/
|
|
83
|
+
getTools(): Promise<BaseTool[]>;
|
|
84
|
+
close(): Promise<void>;
|
|
85
|
+
private loadTools;
|
|
86
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
/** OAuth scope every Integration Connectors and Application Integration call needs. */
|
|
7
|
+
export declare const CLOUD_PLATFORM_SCOPE = "https://www.googleapis.com/auth/cloud-platform";
|
|
8
|
+
/** Wraps a failure as `An unexpected error occurred: …`. */
|
|
9
|
+
export declare function unexpectedError(e: unknown): Error;
|
|
10
|
+
/**
|
|
11
|
+
* Supplies cloud-platform access tokens from a service-account key, or from
|
|
12
|
+
* Application Default Credentials when no key is given.
|
|
13
|
+
*
|
|
14
|
+
* One instance holds one `GoogleAuth`, which caches the token and refreshes it
|
|
15
|
+
* before it expires.
|
|
16
|
+
*/
|
|
17
|
+
export declare class CloudPlatformTokenSource {
|
|
18
|
+
private readonly serviceAccountJson?;
|
|
19
|
+
private auth?;
|
|
20
|
+
constructor(serviceAccountJson?: string | undefined);
|
|
21
|
+
/**
|
|
22
|
+
* Returns an access token.
|
|
23
|
+
*
|
|
24
|
+
* @throws Error When no key is given and Application Default Credentials are
|
|
25
|
+
* unavailable, or when no token is issued.
|
|
26
|
+
*/
|
|
27
|
+
getAccessToken(): Promise<string>;
|
|
28
|
+
private getAuth;
|
|
29
|
+
}
|
|
30
|
+
/** Options for {@link sendCloudRequest}. */
|
|
31
|
+
export interface SendCloudRequestOptions {
|
|
32
|
+
/** The request URL. */
|
|
33
|
+
url: string;
|
|
34
|
+
/** The HTTP method. */
|
|
35
|
+
method: 'GET' | 'POST';
|
|
36
|
+
/** The JSON request body for a POST request. */
|
|
37
|
+
body?: unknown;
|
|
38
|
+
/** Supplies the bearer token. */
|
|
39
|
+
tokenSource: CloudPlatformTokenSource;
|
|
40
|
+
/** The message for an HTTP 400 or 404 response. */
|
|
41
|
+
invalidRequestMessage: string;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Sends an authenticated JSON request to a Google Cloud API and returns the
|
|
45
|
+
* parsed response body.
|
|
46
|
+
*
|
|
47
|
+
* @param options The request URL, method, body, token source, and 400/404 message.
|
|
48
|
+
* @throws Error `invalidRequestMessage` for HTTP 400 and 404,
|
|
49
|
+
* `Request error: …` for any other non-2xx status or a failed fetch, and
|
|
50
|
+
* `An unexpected error occurred: …` for anything else, such as a missing
|
|
51
|
+
* credential or a body that is not JSON.
|
|
52
|
+
*/
|
|
53
|
+
export declare function sendCloudRequest(options: SendCloudRequestOptions): Promise<unknown>;
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { OpenAPIV3 } from 'openapi-types';
|
|
7
|
+
import { JsonObject } from '../../../utils/json_utils.js';
|
|
8
|
+
/** Options for {@link ConnectionsClient}. */
|
|
9
|
+
export interface ConnectionsClientOptions {
|
|
10
|
+
/** The Google Cloud project ID. */
|
|
11
|
+
project: string;
|
|
12
|
+
/** The Google Cloud location, such as `us-central1`. */
|
|
13
|
+
location: string;
|
|
14
|
+
/** The connection name. */
|
|
15
|
+
connection: string;
|
|
16
|
+
/**
|
|
17
|
+
* A service-account key, as a JSON string. When omitted, requests use
|
|
18
|
+
* Application Default Credentials.
|
|
19
|
+
*/
|
|
20
|
+
serviceAccountJson?: string;
|
|
21
|
+
}
|
|
22
|
+
/** Service details of an Integration Connectors connection. */
|
|
23
|
+
export interface ConnectionDetails {
|
|
24
|
+
/**
|
|
25
|
+
* The Service Directory name of the connection. For a connection with a
|
|
26
|
+
* `host`, the TLS Service Directory name.
|
|
27
|
+
*/
|
|
28
|
+
serviceName: string;
|
|
29
|
+
/** The host of the connection, or `''` when it has none. */
|
|
30
|
+
host: string;
|
|
31
|
+
/** Whether the connection lets a request override its authentication. */
|
|
32
|
+
authOverrideEnabled: boolean;
|
|
33
|
+
}
|
|
34
|
+
/** The schema of one entity of a connection, and the operations it supports. */
|
|
35
|
+
export interface EntitySchemaAndOperations {
|
|
36
|
+
/** The JSON schema of the entity. */
|
|
37
|
+
schema: JsonObject;
|
|
38
|
+
/** The operations the entity supports, such as `LIST` or `GET`. */
|
|
39
|
+
operations: string[];
|
|
40
|
+
}
|
|
41
|
+
/** The input and output schemas of one action of a connection. */
|
|
42
|
+
export interface ActionSchema {
|
|
43
|
+
/** The JSON schema of the action input. */
|
|
44
|
+
inputSchema: JsonObject;
|
|
45
|
+
/** The JSON schema of the action output. */
|
|
46
|
+
outputSchema: JsonObject;
|
|
47
|
+
/** The description of the action. */
|
|
48
|
+
description: string;
|
|
49
|
+
/** The display name of the action. */
|
|
50
|
+
displayName: string;
|
|
51
|
+
}
|
|
52
|
+
/** The OpenAPI document of the `ExecuteConnection` integration. */
|
|
53
|
+
export interface ConnectorSpec {
|
|
54
|
+
openapi: string;
|
|
55
|
+
info: {
|
|
56
|
+
title: string;
|
|
57
|
+
description: string;
|
|
58
|
+
version: string;
|
|
59
|
+
};
|
|
60
|
+
servers: Array<{
|
|
61
|
+
url: string;
|
|
62
|
+
}>;
|
|
63
|
+
security: Array<Record<string, string[]>>;
|
|
64
|
+
/** Path items, keyed by path. */
|
|
65
|
+
paths: Record<string, JsonObject>;
|
|
66
|
+
components: {
|
|
67
|
+
/** Schemas, keyed by name. */
|
|
68
|
+
schemas: Record<string, JsonObject>;
|
|
69
|
+
securitySchemes: Record<string, OpenAPIV3.SecuritySchemeObject>;
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
/** Options for {@link getActionOperation}. */
|
|
73
|
+
export interface GetActionOperationOptions {
|
|
74
|
+
/** The action name. */
|
|
75
|
+
action: string;
|
|
76
|
+
/** `EXECUTE_ACTION`, or `EXECUTE_QUERY` for a custom query. */
|
|
77
|
+
operation: string;
|
|
78
|
+
/** The display name of the action. */
|
|
79
|
+
actionDisplayName: string;
|
|
80
|
+
/** Prefix of the generated `operationId`. Defaults to `''`. */
|
|
81
|
+
toolName?: string;
|
|
82
|
+
/** Text appended to the description. Defaults to `''`. */
|
|
83
|
+
toolInstructions?: string;
|
|
84
|
+
}
|
|
85
|
+
/** Options for {@link listOperation} and {@link getOperation}. */
|
|
86
|
+
export interface EntitySchemaOperationOptions {
|
|
87
|
+
/** The entity name. */
|
|
88
|
+
entity: string;
|
|
89
|
+
/**
|
|
90
|
+
* The entity JSON schema, quoted in the response description. Defaults to
|
|
91
|
+
* `''`.
|
|
92
|
+
*/
|
|
93
|
+
schemaAsString?: string;
|
|
94
|
+
/** Prefix of the generated `operationId`. Defaults to `''`. */
|
|
95
|
+
toolName?: string;
|
|
96
|
+
/** Text appended to the description. Defaults to `''`. */
|
|
97
|
+
toolInstructions?: string;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Options for {@link createOperation}, {@link updateOperation} and
|
|
101
|
+
* {@link deleteOperation}.
|
|
102
|
+
*/
|
|
103
|
+
export interface EntityOperationOptions {
|
|
104
|
+
/** The entity name. */
|
|
105
|
+
entity: string;
|
|
106
|
+
/** Prefix of the generated `operationId`. Defaults to `''`. */
|
|
107
|
+
toolName?: string;
|
|
108
|
+
/** Text appended to the description. Defaults to `''`. */
|
|
109
|
+
toolInstructions?: string;
|
|
110
|
+
}
|
|
111
|
+
/** The base OpenAPI document of the `ExecuteConnection` integration. */
|
|
112
|
+
export declare const CONNECTOR_BASE_SPEC: ConnectorSpec;
|
|
113
|
+
/**
|
|
114
|
+
* Converts the JSON schema of an entity or an action payload into the
|
|
115
|
+
* OpenAPI schema the connector spec carries.
|
|
116
|
+
*
|
|
117
|
+
* Keeps `description`, maps a `type` array holding `null` to `nullable: true`
|
|
118
|
+
* plus the first other type, and recurses into `properties` of an object and
|
|
119
|
+
* `items` of an array. Every other keyword is dropped.
|
|
120
|
+
*
|
|
121
|
+
* @param jsonSchema The JSON schema.
|
|
122
|
+
* @returns The OpenAPI schema.
|
|
123
|
+
*/
|
|
124
|
+
export declare function connectorPayload(jsonSchema: JsonObject): JsonObject;
|
|
125
|
+
/**
|
|
126
|
+
* Builds the path item that runs an action.
|
|
127
|
+
*
|
|
128
|
+
* @param options The action, operation, display name, tool name, and instructions.
|
|
129
|
+
*/
|
|
130
|
+
export declare function getActionOperation(options: GetActionOperationOptions): JsonObject;
|
|
131
|
+
/**
|
|
132
|
+
* Builds the path item that lists the records of an entity.
|
|
133
|
+
*
|
|
134
|
+
* @param options The entity, schema string, tool name, and instructions.
|
|
135
|
+
*/
|
|
136
|
+
export declare function listOperation(options: EntitySchemaOperationOptions): JsonObject;
|
|
137
|
+
/**
|
|
138
|
+
* Builds the path item that reads one record of an entity.
|
|
139
|
+
*
|
|
140
|
+
* @param options The entity, schema string, tool name, and instructions.
|
|
141
|
+
*/
|
|
142
|
+
export declare function getOperation(options: EntitySchemaOperationOptions): JsonObject;
|
|
143
|
+
/**
|
|
144
|
+
* Builds the path item that creates a record of an entity.
|
|
145
|
+
*
|
|
146
|
+
* @param options The entity, tool name, and instructions.
|
|
147
|
+
*/
|
|
148
|
+
export declare function createOperation(options: EntityOperationOptions): JsonObject;
|
|
149
|
+
/**
|
|
150
|
+
* Builds the path item that updates a record of an entity.
|
|
151
|
+
*
|
|
152
|
+
* @param options The entity, tool name, and instructions.
|
|
153
|
+
*/
|
|
154
|
+
export declare function updateOperation(options: EntityOperationOptions): JsonObject;
|
|
155
|
+
/**
|
|
156
|
+
* Builds the path item that deletes a record of an entity.
|
|
157
|
+
*
|
|
158
|
+
* @param options The entity, tool name, and instructions.
|
|
159
|
+
*/
|
|
160
|
+
export declare function deleteOperation(options: EntityOperationOptions): JsonObject;
|
|
161
|
+
/** Builds the request schema of the create operation of an entity. */
|
|
162
|
+
export declare function createOperationRequest(entity: string): JsonObject;
|
|
163
|
+
/** Builds the request schema of the update operation of an entity. */
|
|
164
|
+
export declare function updateOperationRequest(entity: string): JsonObject;
|
|
165
|
+
/** Builds the request schema of the get operation. */
|
|
166
|
+
export declare function getOperationRequest(): JsonObject;
|
|
167
|
+
/** Builds the request schema of the delete operation. */
|
|
168
|
+
export declare function deleteOperationRequest(): JsonObject;
|
|
169
|
+
/** Builds the request schema of the list operation. */
|
|
170
|
+
export declare function listOperationRequest(): JsonObject;
|
|
171
|
+
/** Builds the request schema of an action. */
|
|
172
|
+
export declare function actionRequest(action: string): JsonObject;
|
|
173
|
+
/** Builds the response schema of an action. */
|
|
174
|
+
export declare function actionResponse(action: string): JsonObject;
|
|
175
|
+
/** Builds the request schema of the `ExecuteCustomQuery` action. */
|
|
176
|
+
export declare function executeCustomQueryRequest(): JsonObject;
|
|
177
|
+
/**
|
|
178
|
+
* A client for the Integration Connectors API.
|
|
179
|
+
*
|
|
180
|
+
* It reads the details, entity schemas and action schemas of one connection.
|
|
181
|
+
*/
|
|
182
|
+
export declare class ConnectionsClient {
|
|
183
|
+
private readonly project;
|
|
184
|
+
private readonly location;
|
|
185
|
+
private readonly connection;
|
|
186
|
+
private readonly tokenSource;
|
|
187
|
+
constructor(options: ConnectionsClientOptions);
|
|
188
|
+
/**
|
|
189
|
+
* Reads the service name and host of the connection, and whether it allows
|
|
190
|
+
* an authentication override.
|
|
191
|
+
*/
|
|
192
|
+
getConnectionDetails(): Promise<ConnectionDetails>;
|
|
193
|
+
/**
|
|
194
|
+
* Reads the JSON schema of an entity and the operations it supports.
|
|
195
|
+
*
|
|
196
|
+
* @param entity The entity name.
|
|
197
|
+
* @throws Error When the API starts no operation for the entity.
|
|
198
|
+
*/
|
|
199
|
+
getEntitySchemaAndOperations(entity: string): Promise<EntitySchemaAndOperations>;
|
|
200
|
+
/**
|
|
201
|
+
* Reads the input and output JSON schemas of an action.
|
|
202
|
+
*
|
|
203
|
+
* @param action The action name.
|
|
204
|
+
* @throws Error When the API starts no operation for the action.
|
|
205
|
+
*/
|
|
206
|
+
getActionSchema(action: string): Promise<ActionSchema>;
|
|
207
|
+
/**
|
|
208
|
+
* Converts the JSON schema of an entity or an action payload into the
|
|
209
|
+
* OpenAPI schema the connector spec carries.
|
|
210
|
+
*/
|
|
211
|
+
connectorPayload(jsonSchema: JsonObject): JsonObject;
|
|
212
|
+
private executeApiCall;
|
|
213
|
+
/** Polls a long-running operation until it reports `done`. */
|
|
214
|
+
private pollOperation;
|
|
215
|
+
}
|