@google/adk 2.2.1 → 2.4.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/agents/agent_engine_client.js +172 -0
- package/dist/cjs/agents/base_agent.js +20 -4
- package/dist/cjs/agents/functions.js +227 -25
- package/dist/cjs/agents/instructions.js +6 -2
- 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 +194 -107
- package/dist/cjs/agents/processors/basic_llm_request_processor.js +1 -1
- package/dist/cjs/agents/processors/code_execution_request_processor.js +18 -6
- package/dist/cjs/agents/processors/content_processor_utils.js +38 -10
- package/dist/cjs/agents/processors/content_request_processor.js +34 -2
- package/dist/cjs/agents/processors/instructions_llm_request_processor.js +1 -1
- package/dist/cjs/agents/processors/nl_planning_processor.js +12 -3
- 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/code_executors/container_code_executor.js +27 -16
- package/dist/cjs/code_executors/unsafe_local_code_executor.js +6 -1
- package/dist/cjs/common.js +61 -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/errors/input_validation_error.js +3 -2
- package/dist/cjs/events/event.js +4 -2
- 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 +104 -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/base_plugin.js +13 -23
- package/dist/cjs/runner/in_memory_runner.js +6 -11
- package/dist/cjs/runner/runner.js +105 -33
- package/dist/cjs/sessions/base_session_service.js +14 -8
- package/dist/cjs/sessions/database_session_service.js +50 -28
- package/dist/cjs/sessions/db/operations.js +1 -1
- package/dist/cjs/sessions/in_memory_session_service.js +3 -1
- package/dist/cjs/sessions/stale_session_error.js +59 -0
- package/dist/cjs/sessions/state.js +8 -4
- package/dist/cjs/sessions/vertex_ai_session_service.js +34 -15
- package/dist/cjs/skills/loader.js +52 -18
- package/dist/cjs/telemetry/setup.js +0 -1
- package/dist/cjs/telemetry/tracing.js +147 -73
- package/dist/cjs/tools/agent_tool.js +44 -0
- package/dist/cjs/tools/apihub_tool/apihub_toolset.js +137 -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 +263 -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 +671 -0
- package/dist/cjs/tools/application_integration_tool/clients/integration_client.js +223 -0
- package/dist/cjs/tools/application_integration_tool/integration_connector_tool.js +184 -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 +100 -0
- package/dist/cjs/tools/google_api_tool/google_api_toolset.js +173 -0
- package/dist/cjs/tools/google_api_tool/google_api_toolsets.js +124 -0
- package/dist/cjs/tools/google_api_tool/googleapi_to_openapi_converter.js +440 -0
- package/dist/cjs/tools/google_api_tool/index.js +61 -0
- package/dist/cjs/tools/load_artifacts_tool.js +12 -6
- package/dist/cjs/tools/load_memory_tool.js +12 -10
- package/dist/cjs/tools/mcp/index.js +12 -0
- package/dist/cjs/tools/mcp/mcp_session_manager.js +25 -0
- package/dist/cjs/tools/mcp/mcp_toolset.js +1 -14
- 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 +4 -3
- package/dist/cjs/tools/openapi_tool/auth/credential_exchangers/service_account_exchanger.js +94 -10
- package/dist/cjs/tools/openapi_tool/openapi_spec_parser/openapi_spec_parser.js +20 -6
- package/dist/cjs/tools/openapi_tool/openapi_spec_parser/operation_parser.js +17 -6
- package/dist/cjs/tools/openapi_tool/openapi_spec_parser/tool_auth_handler.js +14 -2
- package/dist/cjs/tools/openapi_tool/openapi_toolset.js +7 -13
- package/dist/cjs/tools/openapi_tool/rest_api_tool.js +17 -1
- package/dist/cjs/tools/retrieval/base_retrieval_tool.js +18 -3
- package/dist/cjs/tools/toolbox_toolset.js +174 -0
- package/dist/cjs/tools/webmcp/webmcp_toolset.js +1 -14
- package/dist/cjs/utils/client_labels.js +19 -2
- package/dist/cjs/utils/env_aware_utils.js +6 -8
- package/dist/cjs/utils/error_utils.js +11 -11
- package/dist/cjs/utils/failover_utils.js +1 -1
- 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 +28 -7
- 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 +11 -1
- package/dist/cjs/utils/object_notation_utils.js +6 -3
- package/dist/cjs/utils/output_schema_utils.js +5 -2
- package/dist/cjs/utils/streaming_utils.js +12 -12
- package/dist/cjs/utils/task.js +1 -1
- 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/agents/agent_engine_client.js +144 -0
- package/dist/esm/agents/base_agent.js +20 -4
- package/dist/esm/agents/functions.js +226 -25
- package/dist/esm/agents/instructions.js +6 -2
- 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 +204 -110
- package/dist/esm/agents/processors/basic_llm_request_processor.js +1 -1
- package/dist/esm/agents/processors/code_execution_request_processor.js +21 -8
- package/dist/esm/agents/processors/content_processor_utils.js +38 -10
- package/dist/esm/agents/processors/content_request_processor.js +34 -2
- package/dist/esm/agents/processors/instructions_llm_request_processor.js +1 -1
- package/dist/esm/agents/processors/nl_planning_processor.js +12 -3
- 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/code_executors/container_code_executor.js +27 -16
- package/dist/esm/code_executors/unsafe_local_code_executor.js +6 -1
- package/dist/esm/common.js +65 -4
- package/dist/esm/context/summarizers/llm_summarizer.js +12 -10
- package/dist/esm/context/token_based_context_compactor.js +2 -1
- package/dist/esm/errors/input_validation_error.js +3 -2
- package/dist/esm/events/event.js +4 -2
- 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 +114 -2
- 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/base_plugin.js +13 -23
- package/dist/esm/runner/in_memory_runner.js +6 -11
- package/dist/esm/runner/runner.js +105 -33
- package/dist/esm/sessions/base_session_service.js +12 -7
- package/dist/esm/sessions/database_session_service.js +49 -28
- package/dist/esm/sessions/db/operations.js +1 -1
- package/dist/esm/sessions/in_memory_session_service.js +3 -1
- package/dist/esm/sessions/stale_session_error.js +31 -0
- package/dist/esm/sessions/state.js +8 -4
- package/dist/esm/sessions/vertex_ai_session_service.js +34 -15
- package/dist/esm/skills/loader.js +51 -17
- package/dist/esm/telemetry/setup.js +1 -2
- package/dist/esm/telemetry/tracing.js +151 -74
- package/dist/esm/tools/agent_tool.js +44 -0
- package/dist/esm/tools/apihub_tool/apihub_toolset.js +101 -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 +245 -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 +629 -0
- package/dist/esm/tools/application_integration_tool/clients/integration_client.js +219 -0
- package/dist/esm/tools/application_integration_tool/integration_connector_tool.js +158 -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 +73 -0
- package/dist/esm/tools/google_api_tool/google_api_toolset.js +146 -0
- package/dist/esm/tools/google_api_tool/google_api_toolsets.js +94 -0
- package/dist/esm/tools/google_api_tool/googleapi_to_openapi_converter.js +393 -0
- package/dist/esm/tools/google_api_tool/index.js +31 -0
- package/dist/esm/tools/load_artifacts_tool.js +10 -5
- package/dist/esm/tools/load_memory_tool.js +12 -10
- package/dist/esm/tools/mcp/index.js +6 -0
- package/dist/esm/tools/mcp/mcp_session_manager.js +25 -0
- package/dist/esm/tools/mcp/mcp_toolset.js +1 -14
- 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 +4 -3
- package/dist/esm/tools/openapi_tool/auth/credential_exchangers/service_account_exchanger.js +94 -10
- package/dist/esm/tools/openapi_tool/openapi_spec_parser/openapi_spec_parser.js +20 -6
- package/dist/esm/tools/openapi_tool/openapi_spec_parser/operation_parser.js +17 -6
- package/dist/esm/tools/openapi_tool/openapi_spec_parser/tool_auth_handler.js +15 -2
- package/dist/esm/tools/openapi_tool/openapi_toolset.js +6 -12
- package/dist/esm/tools/openapi_tool/rest_api_tool.js +17 -1
- package/dist/esm/tools/retrieval/base_retrieval_tool.js +16 -2
- package/dist/esm/tools/toolbox_toolset.js +148 -0
- package/dist/esm/tools/webmcp/webmcp_toolset.js +1 -14
- package/dist/esm/utils/client_labels.js +19 -2
- package/dist/esm/utils/env_aware_utils.js +6 -8
- package/dist/esm/utils/error_utils.js +9 -10
- package/dist/esm/utils/failover_utils.js +1 -1
- 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 +27 -7
- 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 +11 -1
- package/dist/esm/utils/object_notation_utils.js +4 -2
- package/dist/esm/utils/output_schema_utils.js +5 -2
- package/dist/esm/utils/streaming_utils.js +11 -11
- package/dist/esm/utils/task.js +1 -1
- 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/agent_engine_client.d.ts +37 -0
- package/dist/types/agents/base_agent.d.ts +12 -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/llm_agent.d.ts +5 -1
- package/dist/types/agents/processors/content_processor_utils.d.ts +4 -2
- package/dist/types/agents/processors/nl_planning_processor.d.ts +2 -1
- 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/code_executors/container_code_executor.d.ts +17 -5
- package/dist/types/common.d.ts +24 -5
- package/dist/types/errors/input_validation_error.d.ts +2 -1
- package/dist/types/events/event.d.ts +4 -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 +19 -2
- 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/base_plugin.d.ts +0 -10
- package/dist/types/runner/in_memory_runner.d.ts +2 -1
- package/dist/types/runner/runner.d.ts +34 -0
- package/dist/types/sessions/base_session_service.d.ts +5 -0
- package/dist/types/sessions/database_session_service.d.ts +17 -1
- package/dist/types/sessions/stale_session_error.d.ts +21 -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/loader.d.ts +3 -2
- package/dist/types/skills/skill.d.ts +1 -1
- package/dist/types/telemetry/tracing.d.ts +20 -4
- package/dist/types/tools/apihub_tool/apihub_toolset.d.ts +115 -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 +109 -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 +229 -0
- package/dist/types/tools/application_integration_tool/clients/integration_client.d.ts +72 -0
- package/dist/types/tools/application_integration_tool/integration_connector_tool.d.ts +70 -0
- package/dist/types/tools/base_toolset.d.ts +6 -5
- 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 +37 -0
- package/dist/types/tools/google_api_tool/google_api_toolset.d.ts +55 -0
- package/dist/types/tools/google_api_tool/google_api_toolsets.d.ts +48 -0
- package/dist/types/tools/google_api_tool/googleapi_to_openapi_converter.d.ts +165 -0
- package/dist/types/tools/google_api_tool/index.d.ts +10 -0
- package/dist/types/tools/load_artifacts_tool.d.ts +14 -1
- package/dist/types/tools/load_memory_tool.d.ts +23 -1
- 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/openapi_spec_parser.d.ts +12 -0
- package/dist/types/tools/openapi_tool/openapi_spec_parser/operation_parser.d.ts +8 -0
- package/dist/types/tools/openapi_tool/openapi_spec_parser/tool_auth_handler.d.ts +2 -1
- package/dist/types/tools/openapi_tool/openapi_toolset.d.ts +5 -0
- package/dist/types/tools/openapi_tool/rest_api_tool.d.ts +10 -0
- package/dist/types/tools/retrieval/base_retrieval_tool.d.ts +15 -0
- package/dist/types/tools/toolbox_toolset.d.ts +159 -0
- package/dist/types/utils/client_labels.d.ts +2 -1
- 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 +9 -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/output_schema_utils.d.ts +3 -2
- package/dist/types/utils/simple_zod_to_json.d.ts +1 -2
- package/dist/types/utils/streaming_utils.d.ts +11 -4
- package/dist/types/version.d.ts +1 -1
- package/dist/web/index_web.js +117 -110
- package/dist/web/index_web.js.map +4 -4
- package/package.json +38 -26
- package/dist/cjs/models/gemini_continuation.js +0 -232
- package/dist/esm/models/gemini_continuation.js +0 -205
- package/dist/types/models/gemini_continuation.d.ts +0 -59
|
@@ -0,0 +1,671 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
"use strict";
|
|
8
|
+
var __defProp = Object.defineProperty;
|
|
9
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
10
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
11
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
12
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
13
|
+
var __export = (target, all) => {
|
|
14
|
+
for (var name in all)
|
|
15
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
16
|
+
};
|
|
17
|
+
var __copyProps = (to, from, except, desc) => {
|
|
18
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
19
|
+
for (let key of __getOwnPropNames(from))
|
|
20
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
21
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
22
|
+
}
|
|
23
|
+
return to;
|
|
24
|
+
};
|
|
25
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
26
|
+
var __decorateClass = (decorators, target, key, kind) => {
|
|
27
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
28
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
29
|
+
if (decorator = decorators[i])
|
|
30
|
+
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
31
|
+
if (kind && result) __defProp(target, key, result);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
var connections_client_exports = {};
|
|
35
|
+
__export(connections_client_exports, {
|
|
36
|
+
CONNECTOR_BASE_SPEC: () => CONNECTOR_BASE_SPEC,
|
|
37
|
+
ConnectionsClient: () => ConnectionsClient,
|
|
38
|
+
actionRequest: () => actionRequest,
|
|
39
|
+
actionResponse: () => actionResponse,
|
|
40
|
+
connectorPayload: () => connectorPayload,
|
|
41
|
+
createOperation: () => createOperation,
|
|
42
|
+
createOperationRequest: () => createOperationRequest,
|
|
43
|
+
deleteOperation: () => deleteOperation,
|
|
44
|
+
deleteOperationRequest: () => deleteOperationRequest,
|
|
45
|
+
executeCustomQueryRequest: () => executeCustomQueryRequest,
|
|
46
|
+
getActionOperation: () => getActionOperation,
|
|
47
|
+
getOperation: () => getOperation,
|
|
48
|
+
getOperationRequest: () => getOperationRequest,
|
|
49
|
+
listOperation: () => listOperation,
|
|
50
|
+
listOperationRequest: () => listOperationRequest,
|
|
51
|
+
updateOperation: () => updateOperation,
|
|
52
|
+
updateOperationRequest: () => updateOperationRequest
|
|
53
|
+
});
|
|
54
|
+
module.exports = __toCommonJS(connections_client_exports);
|
|
55
|
+
var import_experimental = require("../../../utils/experimental.js");
|
|
56
|
+
var import_json_utils = require("../../../utils/json_utils.js");
|
|
57
|
+
var import_cloud_request = require("./cloud_request.js");
|
|
58
|
+
/**
|
|
59
|
+
* @license
|
|
60
|
+
* Copyright 2026 Google LLC
|
|
61
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
62
|
+
*/
|
|
63
|
+
const CONNECTOR_URL = "https://connectors.googleapis.com";
|
|
64
|
+
const OPERATION_POLL_INTERVAL_MS = 1e3;
|
|
65
|
+
function toStringValue(value) {
|
|
66
|
+
return typeof value === "string" ? value : "";
|
|
67
|
+
}
|
|
68
|
+
__name(toStringValue, "toStringValue");
|
|
69
|
+
function sleep(ms) {
|
|
70
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
71
|
+
}
|
|
72
|
+
__name(sleep, "sleep");
|
|
73
|
+
function schemaRef(name) {
|
|
74
|
+
return { $ref: `#/components/schemas/${name}` };
|
|
75
|
+
}
|
|
76
|
+
__name(schemaRef, "schemaRef");
|
|
77
|
+
const CONNECTOR_BASE_SPEC = {
|
|
78
|
+
openapi: "3.0.1",
|
|
79
|
+
info: {
|
|
80
|
+
title: "ExecuteConnection",
|
|
81
|
+
description: "This tool can execute a query on connection",
|
|
82
|
+
version: "4"
|
|
83
|
+
},
|
|
84
|
+
servers: [{ url: "https://integrations.googleapis.com" }],
|
|
85
|
+
security: [{ google_auth: ["https://www.googleapis.com/auth/cloud-platform"] }],
|
|
86
|
+
paths: {},
|
|
87
|
+
components: {
|
|
88
|
+
schemas: {
|
|
89
|
+
operation: {
|
|
90
|
+
type: "string",
|
|
91
|
+
default: "LIST_ENTITIES",
|
|
92
|
+
description: "Operation to execute. Possible values are LIST_ENTITIES, GET_ENTITY, CREATE_ENTITY, UPDATE_ENTITY, DELETE_ENTITY in case of entities. EXECUTE_ACTION in case of actions. and EXECUTE_QUERY in case of custom queries."
|
|
93
|
+
},
|
|
94
|
+
entityId: {
|
|
95
|
+
type: "string",
|
|
96
|
+
description: "Name of the entity"
|
|
97
|
+
},
|
|
98
|
+
connectorInputPayload: { type: "object" },
|
|
99
|
+
filterClause: {
|
|
100
|
+
type: "string",
|
|
101
|
+
default: "",
|
|
102
|
+
description: "WHERE clause in SQL query"
|
|
103
|
+
},
|
|
104
|
+
pageSize: {
|
|
105
|
+
type: "integer",
|
|
106
|
+
default: 50,
|
|
107
|
+
description: "Number of entities to return in the response"
|
|
108
|
+
},
|
|
109
|
+
pageToken: {
|
|
110
|
+
type: "string",
|
|
111
|
+
default: "",
|
|
112
|
+
description: "Page token to return the next page of entities"
|
|
113
|
+
},
|
|
114
|
+
connectionName: {
|
|
115
|
+
type: "string",
|
|
116
|
+
default: "",
|
|
117
|
+
description: "Connection resource name to run the query for"
|
|
118
|
+
},
|
|
119
|
+
serviceName: {
|
|
120
|
+
type: "string",
|
|
121
|
+
default: "",
|
|
122
|
+
description: "Service directory for the connection"
|
|
123
|
+
},
|
|
124
|
+
host: {
|
|
125
|
+
type: "string",
|
|
126
|
+
default: "",
|
|
127
|
+
description: "Host name in case of tls service directory"
|
|
128
|
+
},
|
|
129
|
+
entity: {
|
|
130
|
+
type: "string",
|
|
131
|
+
default: "Issues",
|
|
132
|
+
description: "Entity to run the query for"
|
|
133
|
+
},
|
|
134
|
+
action: {
|
|
135
|
+
type: "string",
|
|
136
|
+
default: "ExecuteCustomQuery",
|
|
137
|
+
description: "Action to run the query for"
|
|
138
|
+
},
|
|
139
|
+
query: {
|
|
140
|
+
type: "string",
|
|
141
|
+
default: "",
|
|
142
|
+
description: "Custom Query to execute on the connection"
|
|
143
|
+
},
|
|
144
|
+
dynamicAuthConfig: {
|
|
145
|
+
type: "object",
|
|
146
|
+
default: {},
|
|
147
|
+
description: "Dynamic auth config for the connection"
|
|
148
|
+
},
|
|
149
|
+
timeout: {
|
|
150
|
+
type: "integer",
|
|
151
|
+
default: 120,
|
|
152
|
+
description: "Timeout in seconds for execution of custom query"
|
|
153
|
+
},
|
|
154
|
+
connectorOutputPayload: { type: "object" },
|
|
155
|
+
nextPageToken: { type: "string" },
|
|
156
|
+
"execute-connector_Response": {
|
|
157
|
+
required: ["connectorOutputPayload"],
|
|
158
|
+
type: "object",
|
|
159
|
+
properties: {
|
|
160
|
+
connectorOutputPayload: schemaRef("connectorOutputPayload"),
|
|
161
|
+
nextPageToken: schemaRef("nextPageToken")
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
},
|
|
165
|
+
securitySchemes: {
|
|
166
|
+
google_auth: {
|
|
167
|
+
type: "oauth2",
|
|
168
|
+
flows: {
|
|
169
|
+
implicit: {
|
|
170
|
+
authorizationUrl: "https://accounts.google.com/o/oauth2/auth",
|
|
171
|
+
scopes: {
|
|
172
|
+
"https://www.googleapis.com/auth/cloud-platform": "Auth for google cloud services"
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
};
|
|
180
|
+
function connectorPayload(jsonSchema) {
|
|
181
|
+
const openApiSchema = {};
|
|
182
|
+
if ("description" in jsonSchema) {
|
|
183
|
+
openApiSchema["description"] = jsonSchema["description"];
|
|
184
|
+
}
|
|
185
|
+
if ("type" in jsonSchema) {
|
|
186
|
+
const type = jsonSchema["type"];
|
|
187
|
+
if (Array.isArray(type)) {
|
|
188
|
+
if (type.includes("null")) {
|
|
189
|
+
openApiSchema["nullable"] = true;
|
|
190
|
+
const otherTypes = type.filter((t) => t !== "null");
|
|
191
|
+
if (otherTypes.length > 0) {
|
|
192
|
+
openApiSchema["type"] = otherTypes[0];
|
|
193
|
+
}
|
|
194
|
+
} else if (type.length > 0) {
|
|
195
|
+
openApiSchema["type"] = type[0];
|
|
196
|
+
}
|
|
197
|
+
} else {
|
|
198
|
+
openApiSchema["type"] = type;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
if (openApiSchema["type"] === "object" && "properties" in jsonSchema) {
|
|
202
|
+
const properties = {};
|
|
203
|
+
for (const [name, schema] of Object.entries(
|
|
204
|
+
(0, import_json_utils.toJsonObject)(jsonSchema["properties"])
|
|
205
|
+
)) {
|
|
206
|
+
properties[name] = connectorPayload((0, import_json_utils.toJsonObject)(schema));
|
|
207
|
+
}
|
|
208
|
+
openApiSchema["properties"] = properties;
|
|
209
|
+
} else if (openApiSchema["type"] === "array" && "items" in jsonSchema) {
|
|
210
|
+
const items = jsonSchema["items"];
|
|
211
|
+
openApiSchema["items"] = Array.isArray(items) ? items.map((item) => connectorPayload((0, import_json_utils.toJsonObject)(item))) : connectorPayload((0, import_json_utils.toJsonObject)(items));
|
|
212
|
+
}
|
|
213
|
+
return openApiSchema;
|
|
214
|
+
}
|
|
215
|
+
__name(connectorPayload, "connectorPayload");
|
|
216
|
+
function postOperation(options) {
|
|
217
|
+
const {
|
|
218
|
+
summary,
|
|
219
|
+
description,
|
|
220
|
+
operationId,
|
|
221
|
+
xOperation,
|
|
222
|
+
xEntity,
|
|
223
|
+
xAction,
|
|
224
|
+
requestSchemaRef,
|
|
225
|
+
responseSchema
|
|
226
|
+
} = options;
|
|
227
|
+
const post = {
|
|
228
|
+
summary,
|
|
229
|
+
description,
|
|
230
|
+
operationId,
|
|
231
|
+
"x-operation": xOperation,
|
|
232
|
+
requestBody: {
|
|
233
|
+
content: {
|
|
234
|
+
"application/json": {
|
|
235
|
+
schema: { $ref: requestSchemaRef }
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
},
|
|
239
|
+
responses: {
|
|
240
|
+
"200": {
|
|
241
|
+
description: "Success response",
|
|
242
|
+
content: {
|
|
243
|
+
"application/json": {
|
|
244
|
+
schema: responseSchema
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
};
|
|
250
|
+
if (xEntity !== void 0) {
|
|
251
|
+
post["x-entity"] = xEntity;
|
|
252
|
+
}
|
|
253
|
+
if (xAction !== void 0) {
|
|
254
|
+
post["x-action"] = xAction;
|
|
255
|
+
}
|
|
256
|
+
return { post };
|
|
257
|
+
}
|
|
258
|
+
__name(postOperation, "postOperation");
|
|
259
|
+
function getActionOperation(options) {
|
|
260
|
+
const {
|
|
261
|
+
action,
|
|
262
|
+
operation,
|
|
263
|
+
actionDisplayName,
|
|
264
|
+
toolName = "",
|
|
265
|
+
toolInstructions = ""
|
|
266
|
+
} = options;
|
|
267
|
+
let description = `Use this tool to execute ${action}`;
|
|
268
|
+
if (operation === "EXECUTE_QUERY") {
|
|
269
|
+
description += " Use pageSize = 50 and timeout = 120 until user specifies a different value otherwise. If user provides a query in natural language, convert it to SQL query and then execute it using the tool.";
|
|
270
|
+
}
|
|
271
|
+
return postOperation({
|
|
272
|
+
summary: actionDisplayName,
|
|
273
|
+
description: `${description} ${toolInstructions}`,
|
|
274
|
+
operationId: `${toolName}_${actionDisplayName}`,
|
|
275
|
+
xOperation: operation,
|
|
276
|
+
xAction: action,
|
|
277
|
+
requestSchemaRef: `#/components/schemas/${actionDisplayName}_Request`,
|
|
278
|
+
responseSchema: schemaRef(`${actionDisplayName}_Response`)
|
|
279
|
+
});
|
|
280
|
+
}
|
|
281
|
+
__name(getActionOperation, "getActionOperation");
|
|
282
|
+
function listOperation(options) {
|
|
283
|
+
const {
|
|
284
|
+
entity,
|
|
285
|
+
schemaAsString = "",
|
|
286
|
+
toolName = "",
|
|
287
|
+
toolInstructions = ""
|
|
288
|
+
} = options;
|
|
289
|
+
return postOperation({
|
|
290
|
+
summary: `List ${entity}`,
|
|
291
|
+
description: `Returns the list of ${entity} data. If the page token was available in the response, let users know there are more records available. Ask if the user wants to fetch the next page of results. When passing filter use the following format: \`field_name1='value1' AND field_name2='value2'\`. ${toolInstructions}`,
|
|
292
|
+
operationId: `${toolName}_list_${entity}`,
|
|
293
|
+
xOperation: "LIST_ENTITIES",
|
|
294
|
+
xEntity: entity,
|
|
295
|
+
requestSchemaRef: `#/components/schemas/list_${entity}_Request`,
|
|
296
|
+
responseSchema: {
|
|
297
|
+
description: `Returns a list of ${entity} of json schema: ${schemaAsString}`,
|
|
298
|
+
$ref: "#/components/schemas/execute-connector_Response"
|
|
299
|
+
}
|
|
300
|
+
});
|
|
301
|
+
}
|
|
302
|
+
__name(listOperation, "listOperation");
|
|
303
|
+
function getOperation(options) {
|
|
304
|
+
const {
|
|
305
|
+
entity,
|
|
306
|
+
schemaAsString = "",
|
|
307
|
+
toolName = "",
|
|
308
|
+
toolInstructions = ""
|
|
309
|
+
} = options;
|
|
310
|
+
return postOperation({
|
|
311
|
+
summary: `Get ${entity}`,
|
|
312
|
+
description: `Returns the details of the ${entity}. ${toolInstructions}`,
|
|
313
|
+
operationId: `${toolName}_get_${entity}`,
|
|
314
|
+
xOperation: "GET_ENTITY",
|
|
315
|
+
xEntity: entity,
|
|
316
|
+
requestSchemaRef: `#/components/schemas/get_${entity}_Request`,
|
|
317
|
+
responseSchema: {
|
|
318
|
+
description: `Returns ${entity} of json schema: ${schemaAsString}`,
|
|
319
|
+
$ref: "#/components/schemas/execute-connector_Response"
|
|
320
|
+
}
|
|
321
|
+
});
|
|
322
|
+
}
|
|
323
|
+
__name(getOperation, "getOperation");
|
|
324
|
+
function createOperation(options) {
|
|
325
|
+
const { entity, toolName = "", toolInstructions = "" } = options;
|
|
326
|
+
return postOperation({
|
|
327
|
+
summary: `Creates a new ${entity}`,
|
|
328
|
+
description: `Creates a new ${entity}. ${toolInstructions}`,
|
|
329
|
+
operationId: `${toolName}_create_${entity}`,
|
|
330
|
+
xOperation: "CREATE_ENTITY",
|
|
331
|
+
xEntity: entity,
|
|
332
|
+
requestSchemaRef: `#/components/schemas/create_${entity}_Request`,
|
|
333
|
+
responseSchema: schemaRef("execute-connector_Response")
|
|
334
|
+
});
|
|
335
|
+
}
|
|
336
|
+
__name(createOperation, "createOperation");
|
|
337
|
+
function updateOperation(options) {
|
|
338
|
+
const { entity, toolName = "", toolInstructions = "" } = options;
|
|
339
|
+
return postOperation({
|
|
340
|
+
summary: `Updates the ${entity}`,
|
|
341
|
+
description: `Updates the ${entity}. ${toolInstructions}`,
|
|
342
|
+
operationId: `${toolName}_update_${entity}`,
|
|
343
|
+
xOperation: "UPDATE_ENTITY",
|
|
344
|
+
xEntity: entity,
|
|
345
|
+
requestSchemaRef: `#/components/schemas/update_${entity}_Request`,
|
|
346
|
+
responseSchema: schemaRef("execute-connector_Response")
|
|
347
|
+
});
|
|
348
|
+
}
|
|
349
|
+
__name(updateOperation, "updateOperation");
|
|
350
|
+
function deleteOperation(options) {
|
|
351
|
+
const { entity, toolName = "", toolInstructions = "" } = options;
|
|
352
|
+
return postOperation({
|
|
353
|
+
summary: `Delete the ${entity}`,
|
|
354
|
+
description: `Deletes the ${entity}. ${toolInstructions}`,
|
|
355
|
+
operationId: `${toolName}_delete_${entity}`,
|
|
356
|
+
xOperation: "DELETE_ENTITY",
|
|
357
|
+
xEntity: entity,
|
|
358
|
+
requestSchemaRef: `#/components/schemas/delete_${entity}_Request`,
|
|
359
|
+
responseSchema: schemaRef("execute-connector_Response")
|
|
360
|
+
});
|
|
361
|
+
}
|
|
362
|
+
__name(deleteOperation, "deleteOperation");
|
|
363
|
+
function createOperationRequest(entity, options) {
|
|
364
|
+
const properties = {
|
|
365
|
+
connectorInputPayload: schemaRef(`connectorInputPayload_${entity}`),
|
|
366
|
+
operation: schemaRef("operation"),
|
|
367
|
+
connectionName: schemaRef("connectionName"),
|
|
368
|
+
serviceName: schemaRef("serviceName"),
|
|
369
|
+
host: schemaRef("host"),
|
|
370
|
+
entity: schemaRef("entity")
|
|
371
|
+
};
|
|
372
|
+
if (options == null ? void 0 : options.includeDynamicAuthConfig) {
|
|
373
|
+
properties["dynamicAuthConfig"] = schemaRef("dynamicAuthConfig");
|
|
374
|
+
}
|
|
375
|
+
return {
|
|
376
|
+
type: "object",
|
|
377
|
+
required: [
|
|
378
|
+
"connectorInputPayload",
|
|
379
|
+
"operation",
|
|
380
|
+
"connectionName",
|
|
381
|
+
"serviceName",
|
|
382
|
+
"host",
|
|
383
|
+
"entity"
|
|
384
|
+
],
|
|
385
|
+
properties
|
|
386
|
+
};
|
|
387
|
+
}
|
|
388
|
+
__name(createOperationRequest, "createOperationRequest");
|
|
389
|
+
function updateOperationRequest(entity, options) {
|
|
390
|
+
const properties = {
|
|
391
|
+
connectorInputPayload: schemaRef(`connectorInputPayload_${entity}`),
|
|
392
|
+
entityId: schemaRef("entityId"),
|
|
393
|
+
operation: schemaRef("operation"),
|
|
394
|
+
connectionName: schemaRef("connectionName"),
|
|
395
|
+
serviceName: schemaRef("serviceName"),
|
|
396
|
+
host: schemaRef("host"),
|
|
397
|
+
entity: schemaRef("entity"),
|
|
398
|
+
filterClause: schemaRef("filterClause")
|
|
399
|
+
};
|
|
400
|
+
if (options == null ? void 0 : options.includeDynamicAuthConfig) {
|
|
401
|
+
properties["dynamicAuthConfig"] = schemaRef("dynamicAuthConfig");
|
|
402
|
+
}
|
|
403
|
+
return {
|
|
404
|
+
type: "object",
|
|
405
|
+
required: [
|
|
406
|
+
"connectorInputPayload",
|
|
407
|
+
"entityId",
|
|
408
|
+
"operation",
|
|
409
|
+
"connectionName",
|
|
410
|
+
"serviceName",
|
|
411
|
+
"host",
|
|
412
|
+
"entity"
|
|
413
|
+
],
|
|
414
|
+
properties
|
|
415
|
+
};
|
|
416
|
+
}
|
|
417
|
+
__name(updateOperationRequest, "updateOperationRequest");
|
|
418
|
+
function getOperationRequest(options) {
|
|
419
|
+
const properties = {
|
|
420
|
+
entityId: schemaRef("entityId"),
|
|
421
|
+
operation: schemaRef("operation"),
|
|
422
|
+
connectionName: schemaRef("connectionName"),
|
|
423
|
+
serviceName: schemaRef("serviceName"),
|
|
424
|
+
host: schemaRef("host"),
|
|
425
|
+
entity: schemaRef("entity")
|
|
426
|
+
};
|
|
427
|
+
if (options == null ? void 0 : options.includeDynamicAuthConfig) {
|
|
428
|
+
properties["dynamicAuthConfig"] = schemaRef("dynamicAuthConfig");
|
|
429
|
+
}
|
|
430
|
+
return {
|
|
431
|
+
type: "object",
|
|
432
|
+
required: [
|
|
433
|
+
"entityId",
|
|
434
|
+
"operation",
|
|
435
|
+
"connectionName",
|
|
436
|
+
"serviceName",
|
|
437
|
+
"host",
|
|
438
|
+
"entity"
|
|
439
|
+
],
|
|
440
|
+
properties
|
|
441
|
+
};
|
|
442
|
+
}
|
|
443
|
+
__name(getOperationRequest, "getOperationRequest");
|
|
444
|
+
function deleteOperationRequest(options) {
|
|
445
|
+
const properties = {
|
|
446
|
+
entityId: schemaRef("entityId"),
|
|
447
|
+
operation: schemaRef("operation"),
|
|
448
|
+
connectionName: schemaRef("connectionName"),
|
|
449
|
+
serviceName: schemaRef("serviceName"),
|
|
450
|
+
host: schemaRef("host"),
|
|
451
|
+
entity: schemaRef("entity"),
|
|
452
|
+
filterClause: schemaRef("filterClause")
|
|
453
|
+
};
|
|
454
|
+
if (options == null ? void 0 : options.includeDynamicAuthConfig) {
|
|
455
|
+
properties["dynamicAuthConfig"] = schemaRef("dynamicAuthConfig");
|
|
456
|
+
}
|
|
457
|
+
return {
|
|
458
|
+
type: "object",
|
|
459
|
+
required: [
|
|
460
|
+
"entityId",
|
|
461
|
+
"operation",
|
|
462
|
+
"connectionName",
|
|
463
|
+
"serviceName",
|
|
464
|
+
"host",
|
|
465
|
+
"entity"
|
|
466
|
+
],
|
|
467
|
+
properties
|
|
468
|
+
};
|
|
469
|
+
}
|
|
470
|
+
__name(deleteOperationRequest, "deleteOperationRequest");
|
|
471
|
+
function listOperationRequest(options) {
|
|
472
|
+
const properties = {
|
|
473
|
+
filterClause: schemaRef("filterClause"),
|
|
474
|
+
pageSize: schemaRef("pageSize"),
|
|
475
|
+
pageToken: schemaRef("pageToken"),
|
|
476
|
+
operation: schemaRef("operation"),
|
|
477
|
+
connectionName: schemaRef("connectionName"),
|
|
478
|
+
serviceName: schemaRef("serviceName"),
|
|
479
|
+
host: schemaRef("host"),
|
|
480
|
+
entity: schemaRef("entity")
|
|
481
|
+
};
|
|
482
|
+
if (options == null ? void 0 : options.includeDynamicAuthConfig) {
|
|
483
|
+
properties["dynamicAuthConfig"] = schemaRef("dynamicAuthConfig");
|
|
484
|
+
}
|
|
485
|
+
return {
|
|
486
|
+
type: "object",
|
|
487
|
+
required: ["operation", "connectionName", "serviceName", "host", "entity"],
|
|
488
|
+
properties
|
|
489
|
+
};
|
|
490
|
+
}
|
|
491
|
+
__name(listOperationRequest, "listOperationRequest");
|
|
492
|
+
function actionRequest(action, options) {
|
|
493
|
+
const properties = {
|
|
494
|
+
operation: schemaRef("operation"),
|
|
495
|
+
connectionName: schemaRef("connectionName"),
|
|
496
|
+
serviceName: schemaRef("serviceName"),
|
|
497
|
+
host: schemaRef("host"),
|
|
498
|
+
action: schemaRef("action"),
|
|
499
|
+
connectorInputPayload: schemaRef(`connectorInputPayload_${action}`)
|
|
500
|
+
};
|
|
501
|
+
if (options == null ? void 0 : options.includeDynamicAuthConfig) {
|
|
502
|
+
properties["dynamicAuthConfig"] = schemaRef("dynamicAuthConfig");
|
|
503
|
+
}
|
|
504
|
+
return {
|
|
505
|
+
type: "object",
|
|
506
|
+
required: [
|
|
507
|
+
"operation",
|
|
508
|
+
"connectionName",
|
|
509
|
+
"serviceName",
|
|
510
|
+
"host",
|
|
511
|
+
"action",
|
|
512
|
+
"connectorInputPayload"
|
|
513
|
+
],
|
|
514
|
+
properties
|
|
515
|
+
};
|
|
516
|
+
}
|
|
517
|
+
__name(actionRequest, "actionRequest");
|
|
518
|
+
function actionResponse(action) {
|
|
519
|
+
return {
|
|
520
|
+
type: "object",
|
|
521
|
+
properties: {
|
|
522
|
+
connectorOutputPayload: schemaRef(`connectorOutputPayload_${action}`)
|
|
523
|
+
}
|
|
524
|
+
};
|
|
525
|
+
}
|
|
526
|
+
__name(actionResponse, "actionResponse");
|
|
527
|
+
function executeCustomQueryRequest() {
|
|
528
|
+
return {
|
|
529
|
+
type: "object",
|
|
530
|
+
required: [
|
|
531
|
+
"operation",
|
|
532
|
+
"connectionName",
|
|
533
|
+
"serviceName",
|
|
534
|
+
"host",
|
|
535
|
+
"action",
|
|
536
|
+
"query",
|
|
537
|
+
"timeout",
|
|
538
|
+
"pageSize"
|
|
539
|
+
],
|
|
540
|
+
properties: {
|
|
541
|
+
operation: schemaRef("operation"),
|
|
542
|
+
connectionName: schemaRef("connectionName"),
|
|
543
|
+
serviceName: schemaRef("serviceName"),
|
|
544
|
+
host: schemaRef("host"),
|
|
545
|
+
action: schemaRef("action"),
|
|
546
|
+
query: schemaRef("query"),
|
|
547
|
+
timeout: schemaRef("timeout"),
|
|
548
|
+
pageSize: schemaRef("pageSize")
|
|
549
|
+
}
|
|
550
|
+
};
|
|
551
|
+
}
|
|
552
|
+
__name(executeCustomQueryRequest, "executeCustomQueryRequest");
|
|
553
|
+
let ConnectionsClient = class {
|
|
554
|
+
constructor(options) {
|
|
555
|
+
this.project = options.project;
|
|
556
|
+
this.location = options.location;
|
|
557
|
+
this.connection = options.connection;
|
|
558
|
+
this.tokenSource = new import_cloud_request.CloudPlatformTokenSource(options.serviceAccountJson);
|
|
559
|
+
}
|
|
560
|
+
/**
|
|
561
|
+
* Reads the resource name, service name and host of the connection, and
|
|
562
|
+
* whether it allows an authentication override.
|
|
563
|
+
*/
|
|
564
|
+
async getConnectionDetails() {
|
|
565
|
+
const url = `${CONNECTOR_URL}/v1/projects/${this.project}/locations/${this.location}/connections/${this.connection}?view=BASIC`;
|
|
566
|
+
const connectionData = (0, import_json_utils.toJsonObject)(await this.executeApiCall(url));
|
|
567
|
+
const name = toStringValue(connectionData["name"]);
|
|
568
|
+
const host = toStringValue(connectionData["host"]);
|
|
569
|
+
const serviceName = host ? toStringValue(connectionData["tlsServiceDirectory"]) : toStringValue(connectionData["serviceDirectory"]);
|
|
570
|
+
const authOverrideEnabled = connectionData["authOverrideEnabled"] === true;
|
|
571
|
+
return { name, serviceName, host, authOverrideEnabled };
|
|
572
|
+
}
|
|
573
|
+
/**
|
|
574
|
+
* Reads the JSON schema of an entity and the operations it supports.
|
|
575
|
+
*
|
|
576
|
+
* @param entity The entity name.
|
|
577
|
+
* @throws Error When the API starts no operation for the entity.
|
|
578
|
+
*/
|
|
579
|
+
async getEntitySchemaAndOperations(entity) {
|
|
580
|
+
const url = `${CONNECTOR_URL}/v1/projects/${this.project}/locations/${this.location}/connections/${this.connection}/connectionSchemaMetadata:getEntityType?entityId=${entity}`;
|
|
581
|
+
const operationId = toStringValue(
|
|
582
|
+
(0, import_json_utils.toJsonObject)(await this.executeApiCall(url))["name"]
|
|
583
|
+
);
|
|
584
|
+
if (!operationId) {
|
|
585
|
+
throw new Error(
|
|
586
|
+
`Failed to get entity schema and operations for entity: ${entity}`
|
|
587
|
+
);
|
|
588
|
+
}
|
|
589
|
+
const response = (0, import_json_utils.toJsonObject)(
|
|
590
|
+
(await this.pollOperation(operationId))["response"]
|
|
591
|
+
);
|
|
592
|
+
const operations = response["operations"];
|
|
593
|
+
return {
|
|
594
|
+
schema: (0, import_json_utils.toJsonObject)(response["jsonSchema"]),
|
|
595
|
+
operations: Array.isArray(operations) ? operations.filter((op) => typeof op === "string") : []
|
|
596
|
+
};
|
|
597
|
+
}
|
|
598
|
+
/**
|
|
599
|
+
* Reads the input and output JSON schemas of an action.
|
|
600
|
+
*
|
|
601
|
+
* @param action The action name.
|
|
602
|
+
* @throws Error When the API starts no operation for the action.
|
|
603
|
+
*/
|
|
604
|
+
async getActionSchema(action) {
|
|
605
|
+
const url = `${CONNECTOR_URL}/v1/projects/${this.project}/locations/${this.location}/connections/${this.connection}/connectionSchemaMetadata:getAction?actionId=${action}`;
|
|
606
|
+
const operationId = toStringValue(
|
|
607
|
+
(0, import_json_utils.toJsonObject)(await this.executeApiCall(url))["name"]
|
|
608
|
+
);
|
|
609
|
+
if (!operationId) {
|
|
610
|
+
throw new Error(`Failed to get action schema for action: ${action}`);
|
|
611
|
+
}
|
|
612
|
+
const response = (0, import_json_utils.toJsonObject)(
|
|
613
|
+
(await this.pollOperation(operationId))["response"]
|
|
614
|
+
);
|
|
615
|
+
return {
|
|
616
|
+
inputSchema: (0, import_json_utils.toJsonObject)(response["inputJsonSchema"]),
|
|
617
|
+
outputSchema: (0, import_json_utils.toJsonObject)(response["outputJsonSchema"]),
|
|
618
|
+
description: toStringValue(response["description"]),
|
|
619
|
+
displayName: toStringValue(response["displayName"])
|
|
620
|
+
};
|
|
621
|
+
}
|
|
622
|
+
/**
|
|
623
|
+
* Converts the JSON schema of an entity or an action payload into the
|
|
624
|
+
* OpenAPI schema the connector spec carries.
|
|
625
|
+
*/
|
|
626
|
+
connectorPayload(jsonSchema) {
|
|
627
|
+
return connectorPayload(jsonSchema);
|
|
628
|
+
}
|
|
629
|
+
executeApiCall(url) {
|
|
630
|
+
return (0, import_cloud_request.sendCloudRequest)({
|
|
631
|
+
url,
|
|
632
|
+
method: "GET",
|
|
633
|
+
tokenSource: this.tokenSource,
|
|
634
|
+
invalidRequestMessage: `Invalid request. Please check the provided values of project(${this.project}), location(${this.location}), connection(${this.connection}).`
|
|
635
|
+
});
|
|
636
|
+
}
|
|
637
|
+
/** Polls a long-running operation until it reports `done`. */
|
|
638
|
+
async pollOperation(operationId) {
|
|
639
|
+
const url = `${CONNECTOR_URL}/v1/${operationId}`;
|
|
640
|
+
let operation = (0, import_json_utils.toJsonObject)(await this.executeApiCall(url));
|
|
641
|
+
while (operation["done"] !== true) {
|
|
642
|
+
await sleep(OPERATION_POLL_INTERVAL_MS);
|
|
643
|
+
operation = (0, import_json_utils.toJsonObject)(await this.executeApiCall(url));
|
|
644
|
+
}
|
|
645
|
+
return operation;
|
|
646
|
+
}
|
|
647
|
+
};
|
|
648
|
+
__name(ConnectionsClient, "ConnectionsClient");
|
|
649
|
+
ConnectionsClient = __decorateClass([
|
|
650
|
+
import_experimental.experimental
|
|
651
|
+
], ConnectionsClient);
|
|
652
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
653
|
+
0 && (module.exports = {
|
|
654
|
+
CONNECTOR_BASE_SPEC,
|
|
655
|
+
ConnectionsClient,
|
|
656
|
+
actionRequest,
|
|
657
|
+
actionResponse,
|
|
658
|
+
connectorPayload,
|
|
659
|
+
createOperation,
|
|
660
|
+
createOperationRequest,
|
|
661
|
+
deleteOperation,
|
|
662
|
+
deleteOperationRequest,
|
|
663
|
+
executeCustomQueryRequest,
|
|
664
|
+
getActionOperation,
|
|
665
|
+
getOperation,
|
|
666
|
+
getOperationRequest,
|
|
667
|
+
listOperation,
|
|
668
|
+
listOperationRequest,
|
|
669
|
+
updateOperation,
|
|
670
|
+
updateOperationRequest
|
|
671
|
+
});
|