thinkwork-cli 0.13.1 → 1.0.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/README.md +3 -14
- package/dist/{api-client-4DZ266J5.js → api-client-4P4JZOBX.js} +3 -1
- package/dist/bowser-6Z6JFAIR.js +2822 -0
- package/dist/{chunk-Y2WHJECR.js → chunk-4OMDWYZQ.js} +5 -44
- package/dist/chunk-AD2NIWB5.js +6516 -0
- package/dist/chunk-DV3MRBR5.js +43 -0
- package/dist/chunk-EI5ZX7CN.js +522 -0
- package/dist/chunk-EUJ7X6YD.js +126 -0
- package/dist/chunk-GG5WKBOX.js +436 -0
- package/dist/chunk-I64EZSU5.js +358 -0
- package/dist/chunk-KMIJ5KGT.js +128 -0
- package/dist/chunk-MWQ7RO76.js +137 -0
- package/dist/chunk-OCPHU34C.js +996 -0
- package/dist/chunk-OLUQ4U2Z.js +1728 -0
- package/dist/chunk-XYM7PE2A.js +2264 -0
- package/dist/chunk-YQCYD6NE.js +3299 -0
- package/dist/cli.js +49156 -31257
- package/dist/commands/enterprise/templates/deploy-repo/scripts/apply-release.mjs +0 -1
- package/dist/commands/enterprise/templates/deploy-repo/scripts/smoke.mjs +0 -1
- package/dist/commands/enterprise/templates/deploy-repo/terraform/main.tf +0 -14
- package/dist/dist-es-2OTNTL4N.js +315 -0
- package/dist/dist-es-2XVAH4BQ.js +14726 -0
- package/dist/dist-es-3DPDUJAH.js +2000 -0
- package/dist/dist-es-BNZTBBVC.js +176 -0
- package/dist/dist-es-CD2RBDAC.js +88 -0
- package/dist/dist-es-I4FW57PS.js +88 -0
- package/dist/dist-es-KL7Y5NB2.js +377 -0
- package/dist/dist-es-KVFWJNDY.js +318 -0
- package/dist/dist-es-PS73DWNL.js +70 -0
- package/dist/dist-es-S3NZQFGT.js +170 -0
- package/dist/dist-es-SGCA4P32.js +48 -0
- package/dist/dist-es-WBM6J4RA.js +70 -0
- package/dist/dist-es-ZGVADYIF.js +485 -0
- package/dist/dist-es-ZKC2QKD2.js +377 -0
- package/dist/drizzle/0076_scheduled_jobs_marco_backfill.sql +2 -1
- package/dist/drizzle/0079_seed_tenant_customize_catalog.sql +1 -0
- package/dist/drizzle/0090_brain_schema_extraction.sql +10 -0
- package/dist/drizzle/0132_drop_computer_tables.sql +3 -0
- package/dist/drizzle/0160_compliance_event_types_plugins.sql +2 -0
- package/dist/drizzle/0214_think137_drop_judge_evidence_roi.sql +1 -0
- package/dist/drizzle/0216_drop_agent_loop_versions_goal_worker_policy.sql +1 -0
- package/dist/drizzle/0227_analyst_reader_role.sql +17 -20
- package/dist/drizzle/0230_analyst_rls.sql +28 -36
- package/dist/drizzle/0250_kg_schema_extraction.sql +27 -0
- package/dist/drizzle/0251_brain_stragglers.sql +21 -0
- package/dist/drizzle/0253_drop_brain_substrate.sql +2 -0
- package/dist/drizzle/0257_agents_runtime_allow_harness.sql +24 -0
- package/dist/drizzle/0261_native_auth_control_plane.sql +332 -0
- package/dist/drizzle/0262_auth_subscription_tickets.sql +59 -0
- package/dist/drizzle/0263_agentcore_runtime_identifier.sql +69 -0
- package/dist/drizzle/0263_drop_workos_auth_runtime.sql +236 -0
- package/dist/drizzle/0264_auth_enrollment_attempt_limits.sql +15 -0
- package/dist/drizzle/0265_eval_runs_requester_identity.sql +28 -0
- package/dist/drizzle/0265_require_fully_valid_auth_publication.sql +27 -0
- package/dist/drizzle/0266_auth_identity_recovery_grants.sql +9 -0
- package/dist/drizzle/0266_eval_profiles_runtime_type.sql +12 -0
- package/dist/drizzle/0267_ontology_candidate_rejections.sql +53 -0
- package/dist/drizzle/0268_identity_crosswalk_routing.sql +182 -0
- package/dist/drizzle/0269_ontology_system_map.sql +31 -0
- package/dist/drizzle/0270_tool_execution_ledger.sql +115 -0
- package/dist/drizzle/0271_ontology_twin_declarations.sql +47 -0
- package/dist/drizzle/0272_identity_graph_projection_cursor.sql +23 -0
- package/dist/drizzle/0273_twin_materialization_suggestions.sql +29 -0
- package/dist/drizzle/0274_tenant_mcp_twin_keys.sql +59 -0
- package/dist/drizzle/0275_identity_bulk_rebuild_fence.sql +30 -0
- package/dist/drizzle/0276_tool_execution_ledger_allow_cascade_delete.sql +18 -0
- package/dist/drizzle/0277_knowledge_base_sources.sql +107 -0
- package/dist/drizzle/0278_kb_page_transcription.sql +55 -0
- package/dist/drizzle/0279_mcp_servers_off_plugin_provenance.sql +93 -0
- package/dist/drizzle/0280_work_item_external_refs_drop_plane_provider.sql +46 -0
- package/dist/drizzle/0281_tenant_mcp_twin_keys_expiry_suffix.sql +9 -0
- package/dist/drizzle/0282_tenant_mcp_twin_keys_grants.sql +24 -0
- package/dist/drizzle/0283_agents_agentcore_runtime_dispatch.sql +13 -0
- package/dist/drizzle/0284_user_brain_claims.sql +69 -0
- package/dist/drizzle/0285_tenant_mcp_twin_keys_trusted_subsystem.sql +30 -0
- package/dist/drizzle/0286_brain_analytics_key.sql +26 -0
- package/dist/drizzle/0287_brain_subject.sql +25 -0
- package/dist/drizzle/0288_multi_lane_identities.sql +25 -0
- package/dist/event-streams-7JNLJEEL.js +894 -0
- package/dist/event-streams-KDF5RWR6.js +1515 -0
- package/dist/loadSso-ETCXTR4I.js +576 -0
- package/dist/loadSso-UBD7KUHE.js +583 -0
- package/dist/plugins/README.md +2 -2
- package/dist/plugins/catalog/package.json +1 -5
- package/dist/plugins/catalog/src/__tests__/build-catalog.test.ts +6 -4
- package/dist/plugins/catalog/src/__tests__/catalog.test.ts +21 -21
- package/dist/plugins/catalog/src/__tests__/contracts.test.ts +102 -94
- package/dist/plugins/catalog/src/__tests__/plugin-package.test.ts +7 -8
- package/dist/plugins/catalog/src/__tests__/plugin-registry.test.ts +0 -20
- package/dist/plugins/catalog/src/contracts.ts +17 -179
- package/dist/plugins/catalog/src/registry/generated-first-party.ts +0 -24
- package/dist/plugins/n8n/test/integrated-app-contract.test.ts +1 -1
- package/dist/plugins/twenty/package.json +2 -1
- package/dist/plugins/twenty/scripts/LAMBDA_DEPLOY.md +114 -0
- package/dist/plugins/twenty/scripts/build-lambda.sh +29 -0
- package/dist/plugins/twenty/scripts/configure-product-views.ts +195 -0
- package/dist/plugins/twenty/scripts/lambda-handler.ts +49 -0
- package/dist/plugins/twenty/scripts/lib/__tests__/load-attachments.test.ts +38 -0
- package/dist/plugins/twenty/scripts/lib/__tests__/load-records.test.ts +145 -2
- package/dist/plugins/twenty/scripts/lib/__tests__/mappers.test.ts +397 -151
- package/dist/plugins/twenty/scripts/lib/__tests__/members-ensure.test.ts +28 -129
- package/dist/plugins/twenty/scripts/lib/__tests__/provision-members-db.test.ts +10 -0
- package/dist/plugins/twenty/scripts/lib/__tests__/schema-ensure.test.ts +13 -8
- package/dist/plugins/twenty/scripts/lib/lastmile-reader.ts +222 -2
- package/dist/plugins/twenty/scripts/lib/load-attachments.ts +29 -0
- package/dist/plugins/twenty/scripts/lib/load-records.ts +160 -43
- package/dist/plugins/twenty/scripts/lib/mappers.ts +368 -152
- package/dist/plugins/twenty/scripts/lib/members-ensure.ts +43 -268
- package/dist/plugins/twenty/scripts/lib/provision-members-db.ts +57 -0
- package/dist/plugins/twenty/scripts/lib/schema-ensure.ts +136 -31
- package/dist/plugins/twenty/scripts/migrate-lastmile.ts +254 -152
- package/dist/plugins/twenty/scripts/provision-twenty-members.ts +44 -1
- package/dist/plugins/twenty/scripts/purge-lastmile-import.ts +178 -0
- package/dist/plugins/twenty/scripts/restructure-products.ts +312 -0
- package/dist/plugins/twenty/scripts/retag-stage-values.ts +362 -0
- package/dist/plugins/twenty/test/manifest.test.ts +2 -4
- package/dist/scripts/post-deploy.sh +79 -1
- package/dist/signin-5QZNRSOO.js +821 -0
- package/dist/sso-oidc-XK673P54.js +837 -0
- package/dist/sts-OXI2UALF.js +1113 -0
- package/dist/sts-SQW4NBK3.js +1117 -0
- package/dist/terraform/examples/greenfield/main.tf +391 -176
- package/dist/terraform/examples/greenfield/terraform.tfvars.example +26 -8
- package/dist/terraform/modules/app/agentcore-admin/main.tf +47 -0
- package/dist/terraform/modules/app/agentcore-code-interpreter/README.md +39 -47
- package/dist/terraform/modules/app/agentcore-code-interpreter/main.tf +13 -66
- package/dist/terraform/modules/app/agentcore-identity/main.tf +253 -0
- package/dist/terraform/modules/app/agentcore-identity/outputs.tf +51 -0
- package/dist/terraform/modules/app/agentcore-identity/scripts/bootstrap_twenty_oauth_client.sh +239 -0
- package/dist/terraform/modules/app/agentcore-identity/scripts/delete_identity.sh +22 -0
- package/dist/terraform/modules/app/agentcore-identity/scripts/delete_twenty_identity.sh +16 -0
- package/dist/terraform/modules/app/agentcore-identity/scripts/delete_workload_identity.sh +19 -0
- package/dist/terraform/modules/app/agentcore-identity/scripts/ensure_workload_identity.sh +29 -0
- package/dist/terraform/modules/app/agentcore-identity/scripts/read_identity.sh +55 -0
- package/dist/terraform/modules/app/agentcore-identity/scripts/reconcile_identity.sh +73 -0
- package/dist/terraform/modules/app/agentcore-identity/scripts/reconcile_twenty_identity.sh +45 -0
- package/dist/terraform/modules/app/agentcore-identity/scripts/reconcile_twenty_provider.mjs +123 -0
- package/dist/terraform/modules/app/agentcore-identity/tests/tainted-marker/after.tf +15 -0
- package/dist/terraform/modules/app/agentcore-identity/tests/tainted-marker/before.tf +7 -0
- package/dist/terraform/modules/app/agentcore-identity/tests/tainted-marker/identity-after.tf +8 -0
- package/dist/terraform/modules/app/agentcore-identity/tests/tainted-marker/identity-before.tf +9 -0
- package/dist/terraform/modules/app/agentcore-identity/tests/tainted-marker/thinkwork-after.tf +3 -0
- package/dist/terraform/modules/app/agentcore-identity/tests/tainted-marker/thinkwork-before.tf +3 -0
- package/dist/terraform/modules/app/agentcore-identity/variables.tf +60 -0
- package/dist/terraform/modules/app/agentcore-memory/README.md +46 -9
- package/dist/terraform/modules/app/agentcore-memory/main.tf +27 -10
- package/dist/terraform/modules/app/agentcore-memory/scripts/create_or_find_memory.sh +156 -24
- package/dist/terraform/modules/app/agentcore-pi/README.md +1 -3
- package/dist/terraform/modules/app/agentcore-pi/main.tf +42 -52
- package/dist/terraform/modules/app/agentcore-pi/outputs.tf +3 -3
- package/dist/terraform/modules/app/agentcore-pi/scripts/reconcile_pi_runtime.mjs +175 -0
- package/dist/terraform/modules/app/agentcore-pi/variables.tf +35 -28
- package/dist/terraform/modules/app/agentcore-platform/main.tf +68 -0
- package/dist/terraform/modules/app/agentcore-runtime/main.tf +4 -20
- package/dist/terraform/modules/app/appsync-subscriptions/main.tf +127 -21
- package/dist/terraform/modules/app/appsync-subscriptions/outputs.tf +0 -6
- package/dist/terraform/modules/app/appsync-subscriptions/variables.tf +5 -0
- package/dist/terraform/modules/app/capability-broker/main.tf +2 -2
- package/dist/terraform/modules/app/capability-broker/variables.tf +11 -0
- package/dist/terraform/modules/app/deployment-control-plane/README.md +264 -0
- package/dist/terraform/modules/app/deployment-control-plane/buildspec.yml +4 -1
- package/dist/terraform/modules/app/deployment-control-plane/main.tf +94 -0
- package/dist/terraform/modules/app/deployment-control-plane/outputs.tf +5 -0
- package/dist/terraform/modules/app/deployment-control-plane/runner.py +3689 -233
- package/dist/terraform/modules/app/deployment-control-plane/test_runner_bundle.py +2579 -140
- package/dist/terraform/modules/app/deployment-control-plane/variables.tf +33 -0
- package/dist/terraform/modules/app/lambda-api/auth-state.tf +72 -0
- package/dist/terraform/modules/app/lambda-api/chat-latency-observability.tf +466 -0
- package/dist/terraform/modules/app/lambda-api/dispatch-dlq.tf +55 -0
- package/dist/terraform/modules/app/lambda-api/handlers.tf +531 -619
- package/dist/terraform/modules/app/lambda-api/iam-grouped.tf +350 -241
- package/dist/terraform/modules/app/lambda-api/main.tf +75 -13
- package/dist/terraform/modules/app/lambda-api/memory-alarms.tf +3 -28
- package/dist/terraform/modules/app/lambda-api/oauth-secrets.tf +1 -2
- package/dist/terraform/modules/app/lambda-api/outputs.tf +17 -10
- package/dist/terraform/modules/app/lambda-api/runtime-config.tf +3 -21
- package/dist/terraform/modules/app/lambda-api/turn-assertion.tf +45 -0
- package/dist/terraform/modules/app/lambda-api/variables.tf +307 -121
- package/dist/{plugins/n8n/terraform → terraform/modules/app}/n8n/README.md +1 -1
- package/dist/{plugins/n8n/terraform → terraform/modules/app}/n8n/main.tf +18 -18
- package/dist/terraform/modules/app/sandbox-log-scrubber/README.md +11 -10
- package/dist/terraform/modules/app/sandbox-log-scrubber/main.tf +5 -5
- package/dist/terraform/modules/app/static-site/main.tf +1 -1
- package/dist/terraform/modules/app/www-dns/main.tf +9 -27
- package/dist/terraform/modules/app/www-dns/variables.tf +4 -10
- package/dist/terraform/modules/data/aurora-postgres/README.md +34 -0
- package/dist/terraform/modules/data/aurora-postgres/alarms.tf +82 -0
- package/dist/terraform/modules/data/aurora-postgres/main.tf +27 -57
- package/dist/terraform/modules/data/aurora-postgres/outputs.tf +0 -9
- package/dist/terraform/modules/data/aurora-postgres/variables.tf +41 -0
- package/dist/terraform/modules/data/s3-buckets/main.tf +5 -6
- package/dist/terraform/modules/foundation/cognito/main.tf +367 -72
- package/dist/terraform/modules/foundation/cognito/outputs.tf +47 -0
- package/dist/terraform/modules/foundation/cognito/variables.tf +131 -9
- package/dist/terraform/modules/thinkwork/README.md +5 -1
- package/dist/terraform/modules/thinkwork/main.tf +459 -234
- package/dist/terraform/modules/thinkwork/outputs.tf +44 -62
- package/dist/terraform/modules/thinkwork/variables.tf +353 -89
- package/dist/terraform/schema.graphql +69 -36
- package/dist/workspace-defaults/files/INSTRUCTIONS.md +9 -11
- package/dist/workspace-defaults/files/MEMORY_GUIDE.md +38 -35
- package/dist/workspace-defaults/files/ROUTER.md +1 -1
- package/dist/workspace-defaults/files/TOOLS.md +9 -39
- package/dist/workspace-defaults/files/USER.md +1 -0
- package/dist/workspace-defaults/files/agents/analyst/INSTRUCTIONS.md +6 -3
- package/dist/workspace-defaults/files/catalog-skills/brain-brief-builder/SKILL.md +165 -0
- package/dist/workspace-defaults/files/catalog-skills/n8n-workflow-operator/SKILL.md +75 -0
- package/dist/workspace-defaults/files/catalog-skills/n8n-workflow-operator/references/mcp-tooling.md +40 -0
- package/dist/workspace-defaults/files/catalog-skills/n8n-workflow-operator/references/validation-and-handoff.md +40 -0
- package/dist/workspace-defaults/files/catalog-skills/n8n-workflow-operator/references/workflow-authoring.md +46 -0
- package/dist/workspace-defaults/files/skills/artifact-builder/references/crm-dashboard.md +1 -1
- package/dist/workspace-defaults/files/skills/document-composer/SKILL.md +22 -3
- package/package.json +3 -2
- package/dist/drizzle/0261_thread_turns_origin_turn_index.sql +0 -11
- package/dist/plugins/company-data/README.md +0 -49
- package/dist/plugins/company-data/package.json +0 -21
- package/dist/plugins/company-data/src/index.ts +0 -30
- package/dist/plugins/company-data/src/manifest.ts +0 -26
- package/dist/plugins/company-data/test/manifest.test.ts +0 -116
- package/dist/plugins/company-data/tsconfig.json +0 -8
- package/dist/plugins/company-etl/README.md +0 -46
- package/dist/plugins/company-etl/package.json +0 -21
- package/dist/plugins/company-etl/src/index.ts +0 -29
- package/dist/plugins/company-etl/src/manifest.ts +0 -26
- package/dist/plugins/company-etl/test/manifest.test.ts +0 -108
- package/dist/plugins/company-etl/tsconfig.json +0 -8
- package/dist/plugins/lastmile/README.md +0 -50
- package/dist/plugins/lastmile/package.json +0 -23
- package/dist/plugins/lastmile/smoke/lastmile-plugin-smoke.mjs +0 -661
- package/dist/plugins/lastmile/src/api/tasks-adapter.ts +0 -572
- package/dist/plugins/lastmile/src/discovery.fixture.ts +0 -64
- package/dist/plugins/lastmile/src/index.ts +0 -46
- package/dist/plugins/lastmile/src/manifest.ts +0 -139
- package/dist/plugins/lastmile/test/api/tasks-adapter.test.ts +0 -266
- package/dist/plugins/lastmile/test/discovery.test.ts +0 -88
- package/dist/plugins/lastmile/tsconfig.json +0 -8
- package/dist/plugins/n8n/smoke/n8n-managed-app-smoke.mjs +0 -409
- package/dist/plugins/twenty/smoke/twenty-managed-app-smoke.mjs +0 -359
- package/dist/plugins/workos-auth/package.json +0 -22
- package/dist/plugins/workos-auth/src/index.ts +0 -30
- package/dist/plugins/workos-auth/src/manifest.ts +0 -40
- package/dist/plugins/workos-auth/src/provider-contract.ts +0 -39
- package/dist/plugins/workos-auth/test/manifest.test.ts +0 -94
- package/dist/plugins/workos-auth/tsconfig.json +0 -8
- package/dist/terraform/modules/app/agentcore-code-interpreter/Dockerfile.sandbox-base +0 -61
- package/dist/terraform/modules/app/agentcore-code-interpreter/sandbox/sitecustomize.py +0 -227
- package/dist/terraform/modules/app/agentcore-code-interpreter/sandbox/test_sitecustomize.py +0 -277
- package/dist/terraform/modules/app/agentcore-code-interpreter/scripts/build_and_push_sandbox_base.sh +0 -70
- package/dist/terraform/modules/app/agentcore-harness/main.tf +0 -101
- package/dist/terraform/modules/app/agentcore-harness/outputs.tf +0 -9
- package/dist/terraform/modules/app/agentcore-harness/variables.tf +0 -25
- package/dist/terraform/modules/app/hindsight-memory/README.md +0 -89
- package/dist/terraform/modules/app/hindsight-memory/main.tf +0 -411
- package/dist/terraform/modules/data/bedrock-knowledge-base/main.tf +0 -102
- /package/dist/{plugins/n8n/terraform → terraform/modules/app}/n8n/outputs.tf +0 -0
- /package/dist/{plugins/n8n/terraform → terraform/modules/app}/n8n/scripts/sync-database.py +0 -0
- /package/dist/{plugins/n8n/terraform → terraform/modules/app}/n8n/scripts/test_sync_database.py +0 -0
- /package/dist/{plugins/n8n/terraform → terraform/modules/app}/n8n/variables.tf +0 -0
- /package/dist/{plugins/twenty/terraform → terraform/modules/app}/twenty/README.md +0 -0
- /package/dist/{plugins/twenty/terraform → terraform/modules/app}/twenty/main.tf +0 -0
- /package/dist/{plugins/twenty/terraform → terraform/modules/app}/twenty/outputs.tf +0 -0
- /package/dist/{plugins/twenty/terraform → terraform/modules/app}/twenty/variables.tf +0 -0
|
@@ -0,0 +1,436 @@
|
|
|
1
|
+
import { createRequire as __createRequire } from "node:module"; const require = __createRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
HttpResponse,
|
|
4
|
+
buildQueryString
|
|
5
|
+
} from "./chunk-XYM7PE2A.js";
|
|
6
|
+
|
|
7
|
+
// ../../node_modules/.pnpm/@smithy+node-http-handler@4.9.7/node_modules/@smithy/node-http-handler/dist-es/build-abort-error.js
|
|
8
|
+
function buildAbortError(abortSignal) {
|
|
9
|
+
const reason = abortSignal && typeof abortSignal === "object" && "reason" in abortSignal ? abortSignal.reason : void 0;
|
|
10
|
+
if (reason) {
|
|
11
|
+
if (reason instanceof Error) {
|
|
12
|
+
const abortError3 = new Error("Request aborted");
|
|
13
|
+
abortError3.name = "AbortError";
|
|
14
|
+
abortError3.cause = reason;
|
|
15
|
+
return abortError3;
|
|
16
|
+
}
|
|
17
|
+
const abortError2 = new Error(String(reason));
|
|
18
|
+
abortError2.name = "AbortError";
|
|
19
|
+
return abortError2;
|
|
20
|
+
}
|
|
21
|
+
const abortError = new Error("Request aborted");
|
|
22
|
+
abortError.name = "AbortError";
|
|
23
|
+
return abortError;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// ../../node_modules/.pnpm/@smithy+node-http-handler@4.9.7/node_modules/@smithy/node-http-handler/dist-es/constants.js
|
|
27
|
+
var NODEJS_TIMEOUT_ERROR_CODES = ["ECONNRESET", "EPIPE", "ETIMEDOUT"];
|
|
28
|
+
|
|
29
|
+
// ../../node_modules/.pnpm/@smithy+node-http-handler@4.9.7/node_modules/@smithy/node-http-handler/dist-es/get-transformed-headers.js
|
|
30
|
+
var getTransformedHeaders = (headers) => {
|
|
31
|
+
const transformedHeaders = {};
|
|
32
|
+
for (const name in headers) {
|
|
33
|
+
const headerValues = headers[name];
|
|
34
|
+
transformedHeaders[name] = Array.isArray(headerValues) ? headerValues.join(",") : headerValues;
|
|
35
|
+
}
|
|
36
|
+
return transformedHeaders;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
// ../../node_modules/.pnpm/@smithy+node-http-handler@4.9.7/node_modules/@smithy/node-http-handler/dist-es/node-https.js
|
|
40
|
+
import node_https from "https";
|
|
41
|
+
|
|
42
|
+
// ../../node_modules/.pnpm/@smithy+node-http-handler@4.9.7/node_modules/@smithy/node-http-handler/dist-es/timing.js
|
|
43
|
+
var timing = {
|
|
44
|
+
setTimeout: (cb, ms) => setTimeout(cb, ms),
|
|
45
|
+
clearTimeout: (timeoutId) => clearTimeout(timeoutId)
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
// ../../node_modules/.pnpm/@smithy+node-http-handler@4.9.7/node_modules/@smithy/node-http-handler/dist-es/set-connection-timeout.js
|
|
49
|
+
var DEFER_EVENT_LISTENER_TIME = 1e3;
|
|
50
|
+
var setConnectionTimeout = (request, reject, timeoutInMs = 0) => {
|
|
51
|
+
if (!timeoutInMs) {
|
|
52
|
+
return -1;
|
|
53
|
+
}
|
|
54
|
+
const registerTimeout = (offset) => {
|
|
55
|
+
const timeoutId = timing.setTimeout(() => {
|
|
56
|
+
request.destroy();
|
|
57
|
+
reject(Object.assign(new Error(`@smithy/node-http-handler - the request socket did not establish a connection with the server within the configured timeout of ${timeoutInMs} ms.`), {
|
|
58
|
+
name: "TimeoutError"
|
|
59
|
+
}));
|
|
60
|
+
}, timeoutInMs - offset);
|
|
61
|
+
const doWithSocket = (socket) => {
|
|
62
|
+
if (socket?.connecting) {
|
|
63
|
+
socket.on("connect", () => {
|
|
64
|
+
timing.clearTimeout(timeoutId);
|
|
65
|
+
});
|
|
66
|
+
} else {
|
|
67
|
+
timing.clearTimeout(timeoutId);
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
if (request.socket) {
|
|
71
|
+
doWithSocket(request.socket);
|
|
72
|
+
} else {
|
|
73
|
+
request.on("socket", doWithSocket);
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
if (timeoutInMs < 2e3) {
|
|
77
|
+
registerTimeout(0);
|
|
78
|
+
return 0;
|
|
79
|
+
}
|
|
80
|
+
return timing.setTimeout(registerTimeout.bind(null, DEFER_EVENT_LISTENER_TIME), DEFER_EVENT_LISTENER_TIME);
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
// ../../node_modules/.pnpm/@smithy+node-http-handler@4.9.7/node_modules/@smithy/node-http-handler/dist-es/set-request-timeout.js
|
|
84
|
+
var setRequestTimeout = (req, reject, timeoutInMs = 0, throwOnRequestTimeout, logger) => {
|
|
85
|
+
if (timeoutInMs) {
|
|
86
|
+
return timing.setTimeout(() => {
|
|
87
|
+
let msg = `@smithy/node-http-handler - [${throwOnRequestTimeout ? "ERROR" : "WARN"}] a request has exceeded the configured ${timeoutInMs} ms requestTimeout.`;
|
|
88
|
+
if (throwOnRequestTimeout) {
|
|
89
|
+
const error = Object.assign(new Error(msg), {
|
|
90
|
+
name: "TimeoutError",
|
|
91
|
+
code: "ETIMEDOUT"
|
|
92
|
+
});
|
|
93
|
+
req.destroy(error);
|
|
94
|
+
reject(error);
|
|
95
|
+
} else {
|
|
96
|
+
msg += ` Init client requestHandler with throwOnRequestTimeout=true to turn this into an error.`;
|
|
97
|
+
logger?.warn?.(msg);
|
|
98
|
+
}
|
|
99
|
+
}, timeoutInMs);
|
|
100
|
+
}
|
|
101
|
+
return -1;
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
// ../../node_modules/.pnpm/@smithy+node-http-handler@4.9.7/node_modules/@smithy/node-http-handler/dist-es/set-socket-keep-alive.js
|
|
105
|
+
var DEFER_EVENT_LISTENER_TIME2 = 3e3;
|
|
106
|
+
var setSocketKeepAlive = (request, { keepAlive, keepAliveMsecs }, deferTimeMs = DEFER_EVENT_LISTENER_TIME2) => {
|
|
107
|
+
if (keepAlive !== true) {
|
|
108
|
+
return -1;
|
|
109
|
+
}
|
|
110
|
+
const registerListener = () => {
|
|
111
|
+
if (request.socket) {
|
|
112
|
+
request.socket.setKeepAlive(keepAlive, keepAliveMsecs || 0);
|
|
113
|
+
} else {
|
|
114
|
+
request.on("socket", (socket) => {
|
|
115
|
+
socket.setKeepAlive(keepAlive, keepAliveMsecs || 0);
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
if (deferTimeMs === 0) {
|
|
120
|
+
registerListener();
|
|
121
|
+
return 0;
|
|
122
|
+
}
|
|
123
|
+
return timing.setTimeout(registerListener, deferTimeMs);
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
// ../../node_modules/.pnpm/@smithy+node-http-handler@4.9.7/node_modules/@smithy/node-http-handler/dist-es/set-socket-timeout.js
|
|
127
|
+
var DEFER_EVENT_LISTENER_TIME3 = 3e3;
|
|
128
|
+
var setSocketTimeout = (request, reject, timeoutInMs = 0) => {
|
|
129
|
+
const registerTimeout = (offset) => {
|
|
130
|
+
const timeout = timeoutInMs - offset;
|
|
131
|
+
const onTimeout = () => {
|
|
132
|
+
request.destroy();
|
|
133
|
+
reject(Object.assign(new Error(`@smithy/node-http-handler - the request socket timed out after ${timeoutInMs} ms of inactivity (configured by client requestHandler).`), { name: "TimeoutError" }));
|
|
134
|
+
};
|
|
135
|
+
if (request.socket) {
|
|
136
|
+
request.socket.setTimeout(timeout, onTimeout);
|
|
137
|
+
request.on("close", () => request.socket?.removeListener("timeout", onTimeout));
|
|
138
|
+
} else {
|
|
139
|
+
request.setTimeout(timeout, onTimeout);
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
if (0 < timeoutInMs && timeoutInMs < 6e3) {
|
|
143
|
+
registerTimeout(0);
|
|
144
|
+
return 0;
|
|
145
|
+
}
|
|
146
|
+
return timing.setTimeout(registerTimeout.bind(null, timeoutInMs === 0 ? 0 : DEFER_EVENT_LISTENER_TIME3), DEFER_EVENT_LISTENER_TIME3);
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
// ../../node_modules/.pnpm/@smithy+node-http-handler@4.9.7/node_modules/@smithy/node-http-handler/dist-es/write-request-body.js
|
|
150
|
+
import { Readable } from "stream";
|
|
151
|
+
var MIN_WAIT_TIME = 6e3;
|
|
152
|
+
async function writeRequestBody(httpRequest, request, maxContinueTimeoutMs = MIN_WAIT_TIME, externalAgent = false) {
|
|
153
|
+
const headers = request.headers;
|
|
154
|
+
const expect = headers ? headers.Expect || headers.expect : void 0;
|
|
155
|
+
let timeoutId = -1;
|
|
156
|
+
let sendBody = true;
|
|
157
|
+
if (!externalAgent && expect === "100-continue") {
|
|
158
|
+
sendBody = await Promise.race([
|
|
159
|
+
new Promise((resolve) => {
|
|
160
|
+
timeoutId = Number(timing.setTimeout(() => resolve(true), Math.max(MIN_WAIT_TIME, maxContinueTimeoutMs)));
|
|
161
|
+
}),
|
|
162
|
+
new Promise((resolve) => {
|
|
163
|
+
httpRequest.on("continue", () => {
|
|
164
|
+
timing.clearTimeout(timeoutId);
|
|
165
|
+
resolve(true);
|
|
166
|
+
});
|
|
167
|
+
httpRequest.on("response", () => {
|
|
168
|
+
timing.clearTimeout(timeoutId);
|
|
169
|
+
resolve(false);
|
|
170
|
+
});
|
|
171
|
+
httpRequest.on("error", () => {
|
|
172
|
+
timing.clearTimeout(timeoutId);
|
|
173
|
+
resolve(false);
|
|
174
|
+
});
|
|
175
|
+
})
|
|
176
|
+
]);
|
|
177
|
+
}
|
|
178
|
+
if (sendBody) {
|
|
179
|
+
writeBody(httpRequest, request.body);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
function writeBody(httpRequest, body) {
|
|
183
|
+
if (body instanceof Readable) {
|
|
184
|
+
body.pipe(httpRequest);
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
if (body) {
|
|
188
|
+
const isBuffer = Buffer.isBuffer(body);
|
|
189
|
+
const isString = typeof body === "string";
|
|
190
|
+
if (isBuffer || isString) {
|
|
191
|
+
if (isBuffer && body.byteLength === 0) {
|
|
192
|
+
httpRequest.end();
|
|
193
|
+
} else {
|
|
194
|
+
httpRequest.end(body);
|
|
195
|
+
}
|
|
196
|
+
return;
|
|
197
|
+
}
|
|
198
|
+
const uint8 = body;
|
|
199
|
+
if (typeof uint8 === "object" && uint8.buffer && typeof uint8.byteOffset === "number" && typeof uint8.byteLength === "number") {
|
|
200
|
+
httpRequest.end(Buffer.from(uint8.buffer, uint8.byteOffset, uint8.byteLength));
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
httpRequest.end(Buffer.from(body));
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
206
|
+
httpRequest.end();
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
// ../../node_modules/.pnpm/@smithy+node-http-handler@4.9.7/node_modules/@smithy/node-http-handler/dist-es/node-http-handler.js
|
|
210
|
+
var hAgent = void 0;
|
|
211
|
+
var hRequest = void 0;
|
|
212
|
+
var NodeHttpHandler = class _NodeHttpHandler {
|
|
213
|
+
config;
|
|
214
|
+
configProvider;
|
|
215
|
+
socketWarningTimestamp = 0;
|
|
216
|
+
externalAgent = false;
|
|
217
|
+
metadata = { handlerProtocol: "http/1.1" };
|
|
218
|
+
static create(instanceOrOptions) {
|
|
219
|
+
if (typeof instanceOrOptions?.handle === "function") {
|
|
220
|
+
return instanceOrOptions;
|
|
221
|
+
}
|
|
222
|
+
return new _NodeHttpHandler(instanceOrOptions);
|
|
223
|
+
}
|
|
224
|
+
static checkSocketUsage(agent, socketWarningTimestamp, logger = console) {
|
|
225
|
+
const { sockets, requests, maxSockets } = agent;
|
|
226
|
+
if (typeof maxSockets !== "number" || maxSockets === Infinity) {
|
|
227
|
+
return socketWarningTimestamp;
|
|
228
|
+
}
|
|
229
|
+
const interval = 15e3;
|
|
230
|
+
if (Date.now() - interval < socketWarningTimestamp) {
|
|
231
|
+
return socketWarningTimestamp;
|
|
232
|
+
}
|
|
233
|
+
if (sockets && requests) {
|
|
234
|
+
for (const origin in sockets) {
|
|
235
|
+
const socketsInUse = sockets[origin]?.length ?? 0;
|
|
236
|
+
const requestsEnqueued = requests[origin]?.length ?? 0;
|
|
237
|
+
if (socketsInUse >= maxSockets && requestsEnqueued >= 2 * maxSockets) {
|
|
238
|
+
logger?.warn?.(`@smithy/node-http-handler:WARN - socket usage at capacity=${socketsInUse} and ${requestsEnqueued} additional requests are enqueued.
|
|
239
|
+
See https://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/node-configuring-maxsockets.html
|
|
240
|
+
or increase socketAcquisitionWarningTimeout=(millis) in the NodeHttpHandler config.`);
|
|
241
|
+
return Date.now();
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
return socketWarningTimestamp;
|
|
246
|
+
}
|
|
247
|
+
constructor(options) {
|
|
248
|
+
this.configProvider = new Promise((resolve, reject) => {
|
|
249
|
+
if (typeof options === "function") {
|
|
250
|
+
options().then((_options) => {
|
|
251
|
+
resolve(this.resolveDefaultConfig(_options));
|
|
252
|
+
}).catch(reject);
|
|
253
|
+
} else {
|
|
254
|
+
resolve(this.resolveDefaultConfig(options));
|
|
255
|
+
}
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
destroy() {
|
|
259
|
+
this.config?.httpAgent?.destroy();
|
|
260
|
+
this.config?.httpsAgent?.destroy();
|
|
261
|
+
}
|
|
262
|
+
async handle(request, { abortSignal, requestTimeout } = {}) {
|
|
263
|
+
if (!this.config) {
|
|
264
|
+
this.config = await this.configProvider;
|
|
265
|
+
}
|
|
266
|
+
const config = this.config;
|
|
267
|
+
const isSSL = request.protocol === "https:";
|
|
268
|
+
if (!isSSL && !this.config.httpAgent) {
|
|
269
|
+
this.config.httpAgent = await this.config.httpAgentProvider();
|
|
270
|
+
}
|
|
271
|
+
return new Promise((_resolve, _reject) => {
|
|
272
|
+
let writeRequestBodyPromise = void 0;
|
|
273
|
+
let socketWarningTimeoutId = -1;
|
|
274
|
+
let connectionTimeoutId = -1;
|
|
275
|
+
let requestTimeoutId = -1;
|
|
276
|
+
let socketTimeoutId = -1;
|
|
277
|
+
let keepAliveTimeoutId = -1;
|
|
278
|
+
const clearTimeouts = () => {
|
|
279
|
+
timing.clearTimeout(socketWarningTimeoutId);
|
|
280
|
+
timing.clearTimeout(connectionTimeoutId);
|
|
281
|
+
timing.clearTimeout(requestTimeoutId);
|
|
282
|
+
timing.clearTimeout(socketTimeoutId);
|
|
283
|
+
timing.clearTimeout(keepAliveTimeoutId);
|
|
284
|
+
};
|
|
285
|
+
const resolve = async (arg) => {
|
|
286
|
+
await writeRequestBodyPromise;
|
|
287
|
+
clearTimeouts();
|
|
288
|
+
_resolve(arg);
|
|
289
|
+
};
|
|
290
|
+
const reject = async (arg) => {
|
|
291
|
+
await writeRequestBodyPromise;
|
|
292
|
+
clearTimeouts();
|
|
293
|
+
_reject(arg);
|
|
294
|
+
};
|
|
295
|
+
if (abortSignal?.aborted) {
|
|
296
|
+
const abortError = buildAbortError(abortSignal);
|
|
297
|
+
reject(abortError);
|
|
298
|
+
return;
|
|
299
|
+
}
|
|
300
|
+
const headers = request.headers;
|
|
301
|
+
const expectContinue = headers ? (headers.Expect ?? headers.expect) === "100-continue" : false;
|
|
302
|
+
let agent = isSSL ? config.httpsAgent : config.httpAgent;
|
|
303
|
+
if (expectContinue && !this.externalAgent) {
|
|
304
|
+
agent = new (isSSL ? node_https.Agent : hAgent)({
|
|
305
|
+
keepAlive: false,
|
|
306
|
+
maxSockets: Infinity
|
|
307
|
+
});
|
|
308
|
+
}
|
|
309
|
+
socketWarningTimeoutId = timing.setTimeout(() => {
|
|
310
|
+
this.socketWarningTimestamp = _NodeHttpHandler.checkSocketUsage(agent, this.socketWarningTimestamp, config.logger);
|
|
311
|
+
}, config.socketAcquisitionWarningTimeout ?? (config.requestTimeout ?? 2e3) + (config.connectionTimeout ?? 1e3));
|
|
312
|
+
const queryString = request.query ? buildQueryString(request.query) : "";
|
|
313
|
+
let auth = void 0;
|
|
314
|
+
if (request.username != null || request.password != null) {
|
|
315
|
+
const username = request.username ?? "";
|
|
316
|
+
const password = request.password ?? "";
|
|
317
|
+
auth = `${username}:${password}`;
|
|
318
|
+
}
|
|
319
|
+
let path = request.path;
|
|
320
|
+
if (queryString) {
|
|
321
|
+
path += `?${queryString}`;
|
|
322
|
+
}
|
|
323
|
+
if (request.fragment) {
|
|
324
|
+
path += `#${request.fragment}`;
|
|
325
|
+
}
|
|
326
|
+
let hostname = request.hostname ?? "";
|
|
327
|
+
if (hostname[0] === "[" && hostname.endsWith("]")) {
|
|
328
|
+
hostname = request.hostname.slice(1, -1);
|
|
329
|
+
} else {
|
|
330
|
+
hostname = request.hostname;
|
|
331
|
+
}
|
|
332
|
+
const nodeHttpsOptions = {
|
|
333
|
+
headers: request.headers,
|
|
334
|
+
host: hostname,
|
|
335
|
+
method: request.method,
|
|
336
|
+
path,
|
|
337
|
+
port: request.port,
|
|
338
|
+
agent,
|
|
339
|
+
auth
|
|
340
|
+
};
|
|
341
|
+
const requestFunc = isSSL ? node_https.request : hRequest;
|
|
342
|
+
const req = requestFunc(nodeHttpsOptions, (res) => {
|
|
343
|
+
const httpResponse = new HttpResponse({
|
|
344
|
+
statusCode: res.statusCode || -1,
|
|
345
|
+
reason: res.statusMessage,
|
|
346
|
+
headers: getTransformedHeaders(res.headers),
|
|
347
|
+
body: res
|
|
348
|
+
});
|
|
349
|
+
resolve({ response: httpResponse });
|
|
350
|
+
});
|
|
351
|
+
req.on("error", (err) => {
|
|
352
|
+
if (NODEJS_TIMEOUT_ERROR_CODES.includes(err.code)) {
|
|
353
|
+
reject(Object.assign(err, { name: "TimeoutError" }));
|
|
354
|
+
} else {
|
|
355
|
+
reject(err);
|
|
356
|
+
}
|
|
357
|
+
});
|
|
358
|
+
if (abortSignal) {
|
|
359
|
+
const onAbort = () => {
|
|
360
|
+
req.destroy();
|
|
361
|
+
const abortError = buildAbortError(abortSignal);
|
|
362
|
+
reject(abortError);
|
|
363
|
+
};
|
|
364
|
+
if (typeof abortSignal.addEventListener === "function") {
|
|
365
|
+
const signal = abortSignal;
|
|
366
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
367
|
+
req.once("close", () => signal.removeEventListener("abort", onAbort));
|
|
368
|
+
} else {
|
|
369
|
+
abortSignal.onabort = onAbort;
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
const effectiveRequestTimeout = requestTimeout ?? config.requestTimeout;
|
|
373
|
+
connectionTimeoutId = setConnectionTimeout(req, reject, config.connectionTimeout);
|
|
374
|
+
requestTimeoutId = setRequestTimeout(req, reject, effectiveRequestTimeout, config.throwOnRequestTimeout, config.logger ?? console);
|
|
375
|
+
socketTimeoutId = setSocketTimeout(req, reject, config.socketTimeout);
|
|
376
|
+
const httpAgent = nodeHttpsOptions.agent;
|
|
377
|
+
if (typeof httpAgent === "object" && "keepAlive" in httpAgent) {
|
|
378
|
+
keepAliveTimeoutId = setSocketKeepAlive(req, {
|
|
379
|
+
keepAlive: httpAgent.keepAlive,
|
|
380
|
+
keepAliveMsecs: httpAgent.keepAliveMsecs
|
|
381
|
+
});
|
|
382
|
+
}
|
|
383
|
+
writeRequestBodyPromise = writeRequestBody(req, request, effectiveRequestTimeout, this.externalAgent).catch((e) => {
|
|
384
|
+
clearTimeouts();
|
|
385
|
+
return _reject(e);
|
|
386
|
+
});
|
|
387
|
+
});
|
|
388
|
+
}
|
|
389
|
+
updateHttpClientConfig(key, value) {
|
|
390
|
+
this.config = void 0;
|
|
391
|
+
this.configProvider = this.configProvider.then((config) => {
|
|
392
|
+
return {
|
|
393
|
+
...config,
|
|
394
|
+
[key]: value
|
|
395
|
+
};
|
|
396
|
+
});
|
|
397
|
+
}
|
|
398
|
+
httpHandlerConfigs() {
|
|
399
|
+
return this.config ?? {};
|
|
400
|
+
}
|
|
401
|
+
resolveDefaultConfig(options) {
|
|
402
|
+
const { requestTimeout, connectionTimeout, socketTimeout, socketAcquisitionWarningTimeout, httpAgent, httpsAgent, throwOnRequestTimeout, logger } = options || {};
|
|
403
|
+
const keepAlive = true;
|
|
404
|
+
const maxSockets = 50;
|
|
405
|
+
return {
|
|
406
|
+
connectionTimeout,
|
|
407
|
+
requestTimeout,
|
|
408
|
+
socketTimeout,
|
|
409
|
+
socketAcquisitionWarningTimeout,
|
|
410
|
+
throwOnRequestTimeout,
|
|
411
|
+
httpAgentProvider: async () => {
|
|
412
|
+
const node_http = await import("http");
|
|
413
|
+
const { Agent, request } = node_http.default ?? node_http;
|
|
414
|
+
hRequest = request;
|
|
415
|
+
hAgent = Agent;
|
|
416
|
+
if (httpAgent instanceof hAgent || typeof httpAgent?.destroy === "function") {
|
|
417
|
+
this.externalAgent = true;
|
|
418
|
+
return httpAgent;
|
|
419
|
+
}
|
|
420
|
+
return new hAgent({ keepAlive, maxSockets, ...httpAgent });
|
|
421
|
+
},
|
|
422
|
+
httpsAgent: (() => {
|
|
423
|
+
if (httpsAgent instanceof node_https.Agent || typeof httpsAgent?.destroy === "function") {
|
|
424
|
+
this.externalAgent = true;
|
|
425
|
+
return httpsAgent;
|
|
426
|
+
}
|
|
427
|
+
return new node_https.Agent({ keepAlive, maxSockets, ...httpsAgent });
|
|
428
|
+
})(),
|
|
429
|
+
logger
|
|
430
|
+
};
|
|
431
|
+
}
|
|
432
|
+
};
|
|
433
|
+
|
|
434
|
+
export {
|
|
435
|
+
NodeHttpHandler
|
|
436
|
+
};
|