@aws/nx-plugin 1.0.0-rc.23 → 1.0.0-rc.24
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/LICENSE-THIRD-PARTY +2088 -971
- package/package.json +25 -10
- package/src/agentcore-gateway/attach-upstream.d.ts +7 -7
- package/src/agentcore-gateway/attach-upstream.js +19 -22
- package/src/agentcore-gateway/attach-upstream.js.map +1 -1
- package/src/agentcore-gateway/gateway-connection/generator.d.ts +3 -3
- package/src/agentcore-gateway/gateway-connection/generator.js +42 -45
- package/src/agentcore-gateway/gateway-connection/generator.js.map +1 -1
- package/src/agentcore-gateway/gateway-connection/schema.d.js +6 -0
- package/src/agentcore-gateway/gateway-connection/schema.d.js.map +1 -0
- package/src/agentcore-gateway/generator.js +89 -72
- package/src/agentcore-gateway/generator.js.map +1 -1
- package/src/agentcore-gateway/mcp-connection/generator.d.ts +2 -2
- package/src/agentcore-gateway/mcp-connection/generator.js +24 -30
- package/src/agentcore-gateway/mcp-connection/generator.js.map +1 -1
- package/src/agentcore-gateway/mcp-connection/schema.d.js +6 -0
- package/src/agentcore-gateway/mcp-connection/schema.d.js.map +1 -0
- package/src/agentcore-gateway/schema.d.js +6 -0
- package/src/agentcore-gateway/schema.d.js.map +1 -0
- package/src/bin/aws-nx-mcp.js +14 -0
- package/src/bin/aws-nx-mcp.js.map +1 -0
- package/src/connection/{agent-serve-local.d.ts → agent-local-dev.d.ts} +5 -5
- package/src/connection/agent-local-dev.js +42 -0
- package/src/connection/agent-local-dev.js.map +1 -0
- package/src/connection/agent-runtime-config.js +9 -14
- package/src/connection/agent-runtime-config.js.map +1 -1
- package/src/connection/generator.js +262 -207
- package/src/connection/generator.js.map +1 -1
- package/src/connection/{serve-local.d.ts → local-dev.d.ts} +3 -3
- package/src/connection/local-dev.js +37 -0
- package/src/connection/local-dev.js.map +1 -0
- package/src/connection/schema.d.js +6 -0
- package/src/connection/schema.d.js.map +1 -0
- package/src/index.js +2 -5
- package/src/index.js.map +1 -1
- package/src/infra/app/__snapshots__/generator.spec.ts.snap +4 -26
- package/src/infra/app/generator.js +133 -123
- package/src/infra/app/generator.js.map +1 -1
- package/src/infra/app/schema.d.js +6 -0
- package/src/infra/app/schema.d.js.map +1 -0
- package/src/license/config-types.js +5 -3
- package/src/license/config-types.js.map +1 -1
- package/src/license/config.d.ts +1 -1
- package/src/license/config.js +267 -242
- package/src/license/config.js.map +1 -1
- package/src/license/dependency-check/check.js +51 -46
- package/src/license/dependency-check/check.js.map +1 -1
- package/src/license/dependency-check/collectors/collector.js +41 -71
- package/src/license/dependency-check/collectors/collector.js.map +1 -1
- package/src/license/dependency-check/collectors/npm-collector.js +34 -41
- package/src/license/dependency-check/collectors/npm-collector.js.map +1 -1
- package/src/license/dependency-check/collectors/python-collector.js +55 -62
- package/src/license/dependency-check/collectors/python-collector.js.map +1 -1
- package/src/license/dependency-check/evaluator.js +40 -68
- package/src/license/dependency-check/evaluator.js.map +1 -1
- package/src/license/dependency-check/executor.js +30 -22
- package/src/license/dependency-check/executor.js.map +1 -1
- package/src/license/dependency-check/pre-approved.js +949 -336
- package/src/license/dependency-check/pre-approved.js.map +1 -1
- package/src/license/dependency-check/types.js +2 -3
- package/src/license/dependency-check/types.js.map +1 -1
- package/src/license/generator.js +55 -60
- package/src/license/generator.js.map +1 -1
- package/src/license/index.js +3 -9
- package/src/license/index.js.map +1 -1
- package/src/license/known-exceptions.js +14 -13
- package/src/license/known-exceptions.js.map +1 -1
- package/src/license/schema.d.js +6 -0
- package/src/license/schema.d.js.map +1 -0
- package/src/license/sync/generator.js +94 -119
- package/src/license/sync/generator.js.map +1 -1
- package/src/license/sync/project-file-sync.js +28 -35
- package/src/license/sync/project-file-sync.js.map +1 -1
- package/src/mcp-server/generator-info.js +130 -160
- package/src/mcp-server/generator-info.js.map +1 -1
- package/src/mcp-server/guide-pipeline.js +184 -206
- package/src/mcp-server/guide-pipeline.js.map +1 -1
- package/src/mcp-server/guide-render.js +10 -25
- package/src/mcp-server/guide-render.js.map +1 -1
- package/src/mcp-server/index.js +6 -10
- package/src/mcp-server/index.js.map +1 -1
- package/src/mcp-server/mdx-ast.js +39 -57
- package/src/mcp-server/mdx-ast.js.map +1 -1
- package/src/mcp-server/option-filter.js +33 -47
- package/src/mcp-server/option-filter.js.map +1 -1
- package/src/mcp-server/schema-registry.js +27 -40
- package/src/mcp-server/schema-registry.js.map +1 -1
- package/src/mcp-server/schema.js +9 -7
- package/src/mcp-server/schema.js.map +1 -1
- package/src/mcp-server/server.js +20 -24
- package/src/mcp-server/server.js.map +1 -1
- package/src/mcp-server/tools/create-workspace-command.js +23 -24
- package/src/mcp-server/tools/create-workspace-command.js.map +1 -1
- package/src/mcp-server/tools/general-guidance.js +28 -25
- package/src/mcp-server/tools/general-guidance.js.map +1 -1
- package/src/mcp-server/tools/generator-guide.js +29 -37
- package/src/mcp-server/tools/generator-guide.js.map +1 -1
- package/src/mcp-server/tools/list-generators.js +19 -25
- package/src/mcp-server/tools/list-generators.js.map +1 -1
- package/src/open-api/ts-client/generator.js +16 -26
- package/src/open-api/ts-client/generator.js.map +1 -1
- package/src/open-api/ts-client/schema.d.js +6 -0
- package/src/open-api/ts-client/schema.d.js.map +1 -0
- package/src/open-api/ts-hooks/generator.js +13 -21
- package/src/open-api/ts-hooks/generator.js.map +1 -1
- package/src/open-api/ts-hooks/schema.d.js +6 -0
- package/src/open-api/ts-hooks/schema.d.js.map +1 -0
- package/src/open-api/ts-metadata/generator.js +12 -20
- package/src/open-api/ts-metadata/generator.js.map +1 -1
- package/src/open-api/ts-metadata/schema.d.js +6 -0
- package/src/open-api/ts-metadata/schema.d.js.map +1 -0
- package/src/open-api/utils/codegen-data/languages.js +42 -60
- package/src/open-api/utils/codegen-data/languages.js.map +1 -1
- package/src/open-api/utils/codegen-data/types.js +31 -30
- package/src/open-api/utils/codegen-data/types.js.map +1 -1
- package/src/open-api/utils/codegen-data.js +253 -269
- package/src/open-api/utils/codegen-data.js.map +1 -1
- package/src/open-api/utils/normalise.js +242 -241
- package/src/open-api/utils/normalise.js.map +1 -1
- package/src/open-api/utils/parse.js +8 -14
- package/src/open-api/utils/parse.js.map +1 -1
- package/src/open-api/utils/refs.js +12 -22
- package/src/open-api/utils/refs.js.map +1 -1
- package/src/open-api/utils/types.js +5 -2
- package/src/open-api/utils/types.js.map +1 -1
- package/src/preset/__snapshots__/generator.spec.ts.snap +31 -6
- package/src/preset/generator.d.ts +1 -1
- package/src/preset/generator.js +130 -112
- package/src/preset/generator.js.map +1 -1
- package/src/preset/schema.d.js +6 -0
- package/src/preset/schema.d.js.map +1 -0
- package/src/preset/schema.d.ts +0 -1
- package/src/preset/schema.json +0 -5
- package/src/py/agent/__snapshots__/generator.constructs.spec.ts.snap +304 -0
- package/src/py/agent/__snapshots__/{generator.spec.ts.snap → generator.frameworks.spec.ts.snap} +6 -843
- package/src/py/agent/__snapshots__/generator.protocols.spec.ts.snap +535 -0
- package/src/py/agent/a2a-connection/__snapshots__/generator.spec.ts.snap +1 -2
- package/src/py/agent/a2a-connection/files/agent-connection/app/__targetAgentSnakeCase___client_strands.py.template +1 -1
- package/src/py/agent/a2a-connection/files/langchain/agent-connection/app/__targetAgentSnakeCase___client_langchain.py.template +1 -1
- package/src/py/agent/a2a-connection/generator.js +70 -74
- package/src/py/agent/a2a-connection/generator.js.map +1 -1
- package/src/py/agent/a2a-connection/schema.d.js +8 -0
- package/src/py/agent/a2a-connection/schema.d.js.map +1 -0
- package/src/py/agent/gateway-connection/__snapshots__/generator.spec.ts.snap +6 -8
- package/src/py/agent/gateway-connection/files/agent-connection/app/__gatewaySnakeCase___client_strands.py.template +3 -3
- package/src/py/agent/gateway-connection/files/langchain/agent-connection/app/__gatewaySnakeCase___client_langchain.py.template +3 -3
- package/src/py/agent/gateway-connection/generator.js +61 -57
- package/src/py/agent/gateway-connection/generator.js.map +1 -1
- package/src/py/agent/gateway-connection/schema.d.js +6 -0
- package/src/py/agent/gateway-connection/schema.d.js.map +1 -0
- package/src/py/agent/generator.js +227 -193
- package/src/py/agent/generator.js.map +1 -1
- package/src/py/agent/mcp-connection/__snapshots__/generator.spec.ts.snap +5 -12
- package/src/py/agent/mcp-connection/files/agent-connection/app/__mcpServerSnakeCase___client_strands.py.template +1 -1
- package/src/py/agent/mcp-connection/files/langchain/agent-connection/app/__mcpServerSnakeCase___client_langchain.py.template +1 -1
- package/src/py/agent/mcp-connection/generator.js +53 -51
- package/src/py/agent/mcp-connection/generator.js.map +1 -1
- package/src/py/agent/mcp-connection/schema.d.js +8 -0
- package/src/py/agent/mcp-connection/schema.d.js.map +1 -0
- package/src/py/agent/react-connection/__snapshots__/generator.spec.ts.snap +3 -2
- package/src/py/agent/react-connection/generator.js +51 -58
- package/src/py/agent/react-connection/generator.js.map +1 -1
- package/src/py/agent/react-connection/{serve-local.d.ts → local-dev.d.ts} +4 -4
- package/src/py/agent/react-connection/local-dev.js +36 -0
- package/src/py/agent/react-connection/local-dev.js.map +1 -0
- package/src/py/agent/react-connection/schema.d.js +8 -0
- package/src/py/agent/react-connection/schema.d.js.map +1 -0
- package/src/py/agent/schema.d.js +6 -0
- package/src/py/agent/schema.d.js.map +1 -0
- package/src/py/api/generator.js +12 -12
- package/src/py/api/generator.js.map +1 -1
- package/src/py/api/schema.d.js +6 -0
- package/src/py/api/schema.d.js.map +1 -0
- package/src/py/dynamodb/__snapshots__/generator.spec.ts.snap +68 -28
- package/src/py/dynamodb/agent-connection/__snapshots__/generator.spec.ts.snap +5 -5
- package/src/py/dynamodb/agent-connection/generator.js +27 -29
- package/src/py/dynamodb/agent-connection/generator.js.map +1 -1
- package/src/py/dynamodb/agent-connection/schema.d.js +8 -0
- package/src/py/dynamodb/agent-connection/schema.d.js.map +1 -0
- package/src/py/dynamodb/fast-api-connection/__snapshots__/generator.spec.ts.snap +3 -3
- package/src/py/dynamodb/fast-api-connection/generator.js +26 -28
- package/src/py/dynamodb/fast-api-connection/generator.js.map +1 -1
- package/src/py/dynamodb/fast-api-connection/schema.d.js +8 -0
- package/src/py/dynamodb/fast-api-connection/schema.d.js.map +1 -0
- package/src/py/dynamodb/files/__name__/client.py.template +5 -5
- package/src/py/dynamodb/files/__name__/entities/base.py.template +2 -2
- package/src/py/dynamodb/files/config.json.template +1 -1
- package/src/py/dynamodb/generator.js +63 -62
- package/src/py/dynamodb/generator.js.map +1 -1
- package/src/py/dynamodb/mcp-server-connection/__snapshots__/generator.spec.ts.snap +5 -5
- package/src/py/dynamodb/mcp-server-connection/generator.js +27 -29
- package/src/py/dynamodb/mcp-server-connection/generator.js.map +1 -1
- package/src/py/dynamodb/mcp-server-connection/schema.d.js +8 -0
- package/src/py/dynamodb/mcp-server-connection/schema.d.js.map +1 -0
- package/src/py/dynamodb/schema.d.js +6 -0
- package/src/py/dynamodb/schema.d.js.map +1 -0
- package/src/py/fast-api/__snapshots__/generator.spec.ts.snap +45 -4632
- package/src/py/fast-api/__snapshots__/generator.terraform.spec.ts.snap +4833 -0
- package/src/py/fast-api/generator.js +79 -85
- package/src/py/fast-api/generator.js.map +1 -1
- package/src/py/fast-api/react/__snapshots__/generator.spec.ts.snap +3 -2
- package/src/py/fast-api/react/generator.js +22 -24
- package/src/py/fast-api/react/generator.js.map +1 -1
- package/src/py/fast-api/react/open-api.js +28 -29
- package/src/py/fast-api/react/open-api.js.map +1 -1
- package/src/py/fast-api/react/schema.d.js +6 -0
- package/src/py/fast-api/react/schema.d.js.map +1 -0
- package/src/py/fast-api/schema.d.js +6 -0
- package/src/py/fast-api/schema.d.js.map +1 -0
- package/src/py/lambda-function/__snapshots__/generator.spec.ts.snap +4 -4
- package/src/py/lambda-function/generator.js +57 -58
- package/src/py/lambda-function/generator.js.map +1 -1
- package/src/py/lambda-function/schema.d.js +6 -0
- package/src/py/lambda-function/schema.d.js.map +1 -0
- package/src/py/mcp-server/__snapshots__/generator.spec.ts.snap +4 -4
- package/src/py/mcp-server/generator.js +149 -131
- package/src/py/mcp-server/generator.js.map +1 -1
- package/src/py/mcp-server/schema.d.js +6 -0
- package/src/py/mcp-server/schema.d.js.map +1 -0
- package/src/py/project/generator.js +128 -89
- package/src/py/project/generator.js.map +1 -1
- package/src/py/project/schema.d.js +6 -0
- package/src/py/project/schema.d.js.map +1 -0
- package/src/sdk/agentcore-gateway.d.ts +6 -0
- package/src/sdk/agentcore-gateway.js +7 -0
- package/src/sdk/agentcore-gateway.js.map +1 -0
- package/src/sdk/connection.d.ts +6 -0
- package/src/sdk/connection.js +6 -0
- package/src/sdk/connection.js.map +1 -0
- package/{sdk → src/sdk}/license.d.ts +4 -4
- package/src/sdk/license.js +7 -0
- package/src/sdk/license.js.map +1 -0
- package/src/sdk/open-api.d.ts +10 -0
- package/src/sdk/open-api.js +8 -0
- package/src/sdk/open-api.js.map +1 -0
- package/src/sdk/py.d.ts +14 -0
- package/src/sdk/py.js +10 -0
- package/src/sdk/py.js.map +1 -0
- package/src/sdk/terraform.d.ts +6 -0
- package/src/sdk/terraform.js +7 -0
- package/src/sdk/terraform.js.map +1 -0
- package/src/sdk/ts.d.ts +33 -0
- package/src/sdk/ts.js +35 -0
- package/src/sdk/ts.js.map +1 -0
- package/{sdk → src/sdk}/utils/ast.d.ts +2 -2
- package/src/sdk/utils/ast.js +7 -0
- package/src/sdk/utils/ast.js.map +1 -0
- package/{sdk → src/sdk}/utils/format.d.ts +1 -1
- package/src/sdk/utils/format.js +6 -0
- package/src/sdk/utils/format.js.map +1 -0
- package/{sdk → src/sdk}/utils/test.d.ts +1 -1
- package/src/sdk/utils/test.js +6 -0
- package/src/sdk/utils/test.js.map +1 -0
- package/src/smithy/project/__snapshots__/generator.spec.ts.snap +2 -8
- package/src/smithy/project/files/build.Dockerfile.template +1 -4
- package/src/smithy/project/generator.js +44 -42
- package/src/smithy/project/generator.js.map +1 -1
- package/src/smithy/project/schema.d.js +6 -0
- package/src/smithy/project/schema.d.js.map +1 -0
- package/src/smithy/react-connection/generator.js +35 -46
- package/src/smithy/react-connection/generator.js.map +1 -1
- package/src/smithy/react-connection/schema.d.js +6 -0
- package/src/smithy/react-connection/schema.d.js.map +1 -0
- package/src/smithy/ts/api/__snapshots__/generator.spec.ts.snap +395 -72
- package/src/smithy/ts/api/generator.js +121 -111
- package/src/smithy/ts/api/generator.js.map +1 -1
- package/src/smithy/ts/api/schema.d.js +6 -0
- package/src/smithy/ts/api/schema.d.js.map +1 -0
- package/src/terraform/project/files/application/src/providers.tf.template +1 -1
- package/src/terraform/project/generator.js +141 -103
- package/src/terraform/project/generator.js.map +1 -1
- package/src/terraform/project/schema.d.js +9 -0
- package/src/terraform/project/schema.d.js.map +1 -0
- package/src/trpc/backend/__snapshots__/generator.spec.ts.snap +336 -92
- package/src/trpc/backend/generator.js +93 -86
- package/src/trpc/backend/generator.js.map +1 -1
- package/src/trpc/backend/schema.d.js +6 -0
- package/src/trpc/backend/schema.d.js.map +1 -0
- package/src/trpc/react/__snapshots__/generator.spec.ts.snap +1 -1
- package/src/trpc/react/generator.js +59 -58
- package/src/trpc/react/generator.js.map +1 -1
- package/src/trpc/react/schema.d.js +6 -0
- package/src/trpc/react/schema.d.js.map +1 -0
- package/src/ts/agent/__snapshots__/generator.spec.ts.snap +10 -10
- package/src/ts/agent/a2a-connection/__snapshots__/generator.spec.ts.snap +1 -1
- package/src/ts/agent/a2a-connection/files/agent-connection/app/__targetAgentKebabCase__-client-strands.ts.template +1 -1
- package/src/ts/agent/a2a-connection/generator.js +58 -54
- package/src/ts/agent/a2a-connection/generator.js.map +1 -1
- package/src/ts/agent/a2a-connection/schema.d.js +8 -0
- package/src/ts/agent/a2a-connection/schema.d.js.map +1 -0
- package/src/ts/agent/gateway-connection/__snapshots__/generator.spec.ts.snap +5 -5
- package/src/ts/agent/gateway-connection/files/agent-connection/app/__gatewayKebabCase__-client-strands.ts.template +3 -3
- package/src/ts/agent/gateway-connection/generator.js +57 -52
- package/src/ts/agent/gateway-connection/generator.js.map +1 -1
- package/src/ts/agent/gateway-connection/schema.d.js +6 -0
- package/src/ts/agent/gateway-connection/schema.d.js.map +1 -0
- package/src/ts/agent/generator.js +165 -136
- package/src/ts/agent/generator.js.map +1 -1
- package/src/ts/agent/mcp-connection/__snapshots__/generator.spec.ts.snap +1 -1
- package/src/ts/agent/mcp-connection/files/agent-connection/app/__mcpServerKebabCase__-client-strands.ts.template +1 -1
- package/src/ts/agent/mcp-connection/generator.js +48 -46
- package/src/ts/agent/mcp-connection/generator.js.map +1 -1
- package/src/ts/agent/mcp-connection/schema.d.js +8 -0
- package/src/ts/agent/mcp-connection/schema.d.js.map +1 -0
- package/src/ts/agent/react-connection/generator.js +79 -79
- package/src/ts/agent/react-connection/generator.js.map +1 -1
- package/src/ts/agent/react-connection/{serve-local.d.ts → local-dev.d.ts} +2 -2
- package/src/ts/agent/react-connection/local-dev.js +17 -0
- package/src/ts/agent/react-connection/local-dev.js.map +1 -0
- package/src/ts/agent/react-connection/schema.d.js +8 -0
- package/src/ts/agent/react-connection/schema.d.js.map +1 -0
- package/src/ts/agent/schema.d.js +6 -0
- package/src/ts/agent/schema.d.js.map +1 -0
- package/src/ts/api/generator.js +16 -18
- package/src/ts/api/generator.js.map +1 -1
- package/src/ts/api/schema.d.js +6 -0
- package/src/ts/api/schema.d.js.map +1 -0
- package/src/ts/astro-docs/__snapshots__/generator.spec.ts.snap +8 -8
- package/src/ts/astro-docs/generator.js +59 -48
- package/src/ts/astro-docs/generator.js.map +1 -1
- package/src/ts/astro-docs/schema.d.js +6 -0
- package/src/ts/astro-docs/schema.d.js.map +1 -0
- package/src/ts/docs/generator.js +10 -10
- package/src/ts/docs/generator.js.map +1 -1
- package/src/ts/docs/schema.d.js +6 -0
- package/src/ts/docs/schema.d.js.map +1 -0
- package/src/ts/dynamodb/__snapshots__/generator.spec.ts.snap +68 -30
- package/src/ts/dynamodb/agent-connection/__snapshots__/generator.spec.ts.snap +5 -5
- package/src/ts/dynamodb/agent-connection/generator.js +21 -23
- package/src/ts/dynamodb/agent-connection/generator.js.map +1 -1
- package/src/ts/dynamodb/agent-connection/schema.d.js +8 -0
- package/src/ts/dynamodb/agent-connection/schema.d.js.map +1 -0
- package/src/ts/dynamodb/files/config.json.template +1 -1
- package/src/ts/dynamodb/files/src/client.ts.template +7 -7
- package/src/ts/dynamodb/generator.js +64 -63
- package/src/ts/dynamodb/generator.js.map +1 -1
- package/src/ts/dynamodb/mcp-server-connection/__snapshots__/generator.spec.ts.snap +5 -5
- package/src/ts/dynamodb/mcp-server-connection/generator.js +21 -23
- package/src/ts/dynamodb/mcp-server-connection/generator.js.map +1 -1
- package/src/ts/dynamodb/mcp-server-connection/schema.d.js +8 -0
- package/src/ts/dynamodb/mcp-server-connection/schema.d.js.map +1 -0
- package/src/ts/dynamodb/schema.d.js +6 -0
- package/src/ts/dynamodb/schema.d.js.map +1 -0
- package/src/ts/dynamodb/smithy-connection/__snapshots__/generator.spec.ts.snap +3 -3
- package/src/ts/dynamodb/smithy-connection/generator.js +20 -22
- package/src/ts/dynamodb/smithy-connection/generator.js.map +1 -1
- package/src/ts/dynamodb/smithy-connection/schema.d.js +8 -0
- package/src/ts/dynamodb/smithy-connection/schema.d.js.map +1 -0
- package/src/ts/dynamodb/trpc-connection/__snapshots__/generator.spec.ts.snap +3 -3
- package/src/ts/dynamodb/trpc-connection/generator.js +20 -22
- package/src/ts/dynamodb/trpc-connection/generator.js.map +1 -1
- package/src/ts/dynamodb/trpc-connection/schema.d.js +8 -0
- package/src/ts/dynamodb/trpc-connection/schema.d.js.map +1 -0
- package/src/ts/lambda-function/__snapshots__/generator.spec.ts.snap +4 -4
- package/src/ts/lambda-function/generator.js +55 -55
- package/src/ts/lambda-function/generator.js.map +1 -1
- package/src/ts/lambda-function/io.js +83 -52
- package/src/ts/lambda-function/io.js.map +1 -1
- package/src/ts/lambda-function/schema.d.js +6 -0
- package/src/ts/lambda-function/schema.d.js.map +1 -0
- package/src/ts/lib/__snapshots__/generator.spec.ts.snap +23 -36
- package/src/ts/lib/biome.js +37 -37
- package/src/ts/lib/biome.js.map +1 -1
- package/src/ts/lib/generator.js +75 -77
- package/src/ts/lib/generator.js.map +1 -1
- package/src/ts/lib/schema.d.js +6 -0
- package/src/ts/lib/schema.d.js.map +1 -0
- package/src/ts/lib/ts-project-utils.js +65 -70
- package/src/ts/lib/ts-project-utils.js.map +1 -1
- package/src/ts/lib/types.js +5 -2
- package/src/ts/lib/types.js.map +1 -1
- package/src/ts/lib/vitest.js +29 -26
- package/src/ts/lib/vitest.js.map +1 -1
- package/src/ts/mcp-server/__snapshots__/generator.spec.ts.snap +4 -4
- package/src/ts/mcp-server/generator.js +157 -138
- package/src/ts/mcp-server/generator.js.map +1 -1
- package/src/ts/mcp-server/schema.d.js +6 -0
- package/src/ts/mcp-server/schema.d.js.map +1 -0
- package/src/ts/nx-generator/__snapshots__/generator.spec.ts.snap +14 -9
- package/src/ts/nx-generator/files/local/generator.ts.template +3 -3
- package/src/ts/nx-generator/files/nx-plugin-for-aws/generator/generator.ts.template +4 -4
- package/src/ts/nx-generator/generator.js +84 -83
- package/src/ts/nx-generator/generator.js.map +1 -1
- package/src/ts/nx-generator/schema.d.js +6 -0
- package/src/ts/nx-generator/schema.d.js.map +1 -0
- package/src/ts/nx-plugin/__snapshots__/generator.spec.ts.snap +30 -18
- package/src/ts/nx-plugin/files/mcp-server/server.ts.template +5 -5
- package/src/ts/nx-plugin/files/mcp-server/tools/create-workspace-command.ts.template +2 -2
- package/src/ts/nx-plugin/files/mcp-server/tools/general-guidance.ts.template +1 -1
- package/src/ts/nx-plugin/files/mcp-server/tools/generator-guide.ts.template +2 -2
- package/src/ts/nx-plugin/files/mcp-server/tools/list-generators.ts.template +2 -2
- package/src/ts/nx-plugin/files/mcp-server/utils.ts.template +3 -3
- package/src/ts/nx-plugin/generator.js +49 -48
- package/src/ts/nx-plugin/generator.js.map +1 -1
- package/src/ts/nx-plugin/schema.d.js +9 -0
- package/src/ts/nx-plugin/schema.d.js.map +1 -0
- package/src/ts/nx-plugin/utils.js +32 -44
- package/src/ts/nx-plugin/utils.js.map +1 -1
- package/src/ts/rdb/__snapshots__/generator.spec.ts.snap +30 -30
- package/src/ts/rdb/agent-connection/__snapshots__/generator.spec.ts.snap +6 -6
- package/src/ts/rdb/agent-connection/generator.js +38 -39
- package/src/ts/rdb/agent-connection/generator.js.map +1 -1
- package/src/ts/rdb/agent-connection/schema.d.js +8 -0
- package/src/ts/rdb/agent-connection/schema.d.js.map +1 -0
- package/src/ts/rdb/files/config.json.template +1 -1
- package/src/ts/rdb/files/prisma.config.ts.template +2 -2
- package/src/ts/rdb/files/src/prisma.ts.template +7 -7
- package/src/ts/rdb/files/src/utils.ts.template +1 -0
- package/src/ts/rdb/generator.js +130 -117
- package/src/ts/rdb/generator.js.map +1 -1
- package/src/ts/rdb/mcp-server-connection/__snapshots__/generator.spec.ts.snap +6 -6
- package/src/ts/rdb/mcp-server-connection/generator.js +36 -37
- package/src/ts/rdb/mcp-server-connection/generator.js.map +1 -1
- package/src/ts/rdb/mcp-server-connection/schema.d.js +8 -0
- package/src/ts/rdb/mcp-server-connection/schema.d.js.map +1 -0
- package/src/ts/rdb/schema.d.js +6 -0
- package/src/ts/rdb/schema.d.js.map +1 -0
- package/src/ts/rdb/smithy-connection/__snapshots__/generator.spec.ts.snap +3 -3
- package/src/ts/rdb/smithy-connection/generator.js +46 -43
- package/src/ts/rdb/smithy-connection/generator.js.map +1 -1
- package/src/ts/rdb/smithy-connection/schema.d.js +8 -0
- package/src/ts/rdb/smithy-connection/schema.d.js.map +1 -0
- package/src/ts/rdb/trpc-connection/__snapshots__/generator.spec.ts.snap +3 -3
- package/src/ts/rdb/trpc-connection/generator.js +36 -31
- package/src/ts/rdb/trpc-connection/generator.js.map +1 -1
- package/src/ts/rdb/trpc-connection/schema.d.js +8 -0
- package/src/ts/rdb/trpc-connection/schema.d.js.map +1 -0
- package/src/ts/rdb/utils.js +9 -11
- package/src/ts/rdb/utils.js.map +1 -1
- package/src/ts/react-website/agui/generator.js +69 -61
- package/src/ts/react-website/agui/generator.js.map +1 -1
- package/src/ts/react-website/app/__snapshots__/generator.spec.ts.snap +154 -260
- package/src/ts/react-website/app/generator.js +197 -188
- package/src/ts/react-website/app/generator.js.map +1 -1
- package/src/ts/react-website/app/schema.d.js +6 -0
- package/src/ts/react-website/app/schema.d.js.map +1 -0
- package/src/ts/react-website/app/schema.json +6 -6
- package/src/ts/react-website/cognito-auth/__snapshots__/generator.spec.ts.snap +118 -4
- package/src/ts/react-website/cognito-auth/__snapshots__/generator.terraform.spec.ts.snap +10 -3
- package/src/ts/react-website/cognito-auth/files/app/components/CognitoAuth/index.tsx.template +2 -2
- package/src/ts/react-website/cognito-auth/generator.js +60 -60
- package/src/ts/react-website/cognito-auth/generator.js.map +1 -1
- package/src/ts/react-website/cognito-auth/schema.d.js +6 -0
- package/src/ts/react-website/cognito-auth/schema.d.js.map +1 -0
- package/src/ts/react-website/cognito-auth/utils.js +34 -32
- package/src/ts/react-website/cognito-auth/utils.js.map +1 -1
- package/src/ts/react-website/runtime-config/__snapshots__/generator.spec.ts.snap +2 -2
- package/src/ts/react-website/runtime-config/files/app/components/RuntimeConfig/index.tsx.template +2 -2
- package/src/ts/react-website/runtime-config/generator.js +29 -31
- package/src/ts/react-website/runtime-config/generator.js.map +1 -1
- package/src/ts/react-website/runtime-config/schema.d.js +6 -0
- package/src/ts/react-website/runtime-config/schema.d.js.map +1 -0
- package/src/ts/sync/generator.js +60 -59
- package/src/ts/sync/generator.js.map +1 -1
- package/src/ts/website/app/generator.js +10 -10
- package/src/ts/website/app/generator.js.map +1 -1
- package/src/ts/website/app/schema.d.js +6 -0
- package/src/ts/website/app/schema.d.js.map +1 -0
- package/src/ts/website/app/schema.json +6 -6
- package/src/ts/website/auth/generator.js +11 -11
- package/src/ts/website/auth/generator.js.map +1 -1
- package/src/ts/website/auth/schema.d.js +6 -0
- package/src/ts/website/auth/schema.d.js.map +1 -0
- package/src/utils/agent-chat/agent-chat.d.ts +1 -1
- package/src/utils/agent-chat/agent-chat.js +11 -12
- package/src/utils/agent-chat/agent-chat.js.map +1 -1
- package/src/utils/agent-chat/files/a2a/chat.ts.template +1 -1
- package/src/utils/agent-chat/files/ag-ui/chat.ts.template +1 -1
- package/src/utils/agent-chat/files/http-py/chat.ts.template +1 -1
- package/src/utils/agent-chat/files/http-ts/chat.ts.template +1 -1
- package/src/utils/agent-connection/agent-connection.js +129 -146
- package/src/utils/agent-connection/agent-connection.js.map +1 -1
- package/src/utils/agent-connection/files/core-gateway/agentcore-gateway-mcp-transport.ts.template +1 -1
- package/src/utils/agent-connection/files/core-strands/gateway/agentcore-gateway-mcp-client-strands.ts.template +1 -1
- package/src/utils/agent-connection/files/py-core-gateway/agentcore_gateway_mcp_transport.py.template +1 -1
- package/src/utils/agent-connection/files/py-core-langchain/gateway/agentcore_gateway_mcp_client_langchain.py.template +1 -1
- package/src/utils/agent-connection/files/py-core-strands/gateway/agentcore_gateway_mcp_client_strands.py.template +1 -1
- package/src/utils/agent-core-constructs/agent-core-constructs.js +53 -50
- package/src/utils/agent-core-constructs/agent-core-constructs.js.map +1 -1
- package/src/utils/agent-core-constructs/files/terraform/app/agentcore-gateway/__nameKebabCase__/__nameKebabCase__.tf.template +4 -4
- package/src/utils/agent-core-constructs/files/terraform/core/agent-core/runtime.tf.template +4 -4
- package/src/utils/agent-core-constructs/files/terraform/core/agentcore-gateway/gateway.tf.template +2 -2
- package/src/utils/api-constructs/api-constructs.js +30 -31
- package/src/utils/api-constructs/api-constructs.js.map +1 -1
- package/src/utils/api-constructs/files/cdk/core/api/http/http-api.ts.template +14 -6
- package/src/utils/api-constructs/files/cdk/core/api/rest/api-gateway-account/index.js.template +58 -0
- package/src/utils/api-constructs/files/cdk/core/api/rest/api-gateway-account.ts.template +82 -0
- package/src/utils/api-constructs/files/cdk/core/api/rest/rest-api.ts.template +28 -14
- package/src/utils/api-constructs/files/terraform/app/apis/http/__apiNameKebabCase__/__apiNameKebabCase__.tf.template +1 -8
- package/src/utils/api-constructs/files/terraform/app/apis/rest/__apiNameKebabCase__/__apiNameKebabCase__.tf.template +91 -4
- package/src/utils/api-constructs/files/terraform/core/api/http/http-api/http-api.tf.template +1 -1
- package/src/utils/api-constructs/files/terraform/core/api/rest/api-gateway-account/api-gateway-account.tf.template +83 -0
- package/src/utils/api-constructs/files/terraform/core/api/rest/rest-api/rest-api.tf.template +5 -11
- package/src/utils/api-constructs/open-api-metadata.js +22 -22
- package/src/utils/api-constructs/open-api-metadata.js.map +1 -1
- package/src/utils/ast/website.js +17 -19
- package/src/utils/ast/website.js.map +1 -1
- package/src/utils/ast.js +72 -97
- package/src/utils/ast.js.map +1 -1
- package/src/utils/bundle/bundle.js +50 -47
- package/src/utils/bundle/bundle.js.map +1 -1
- package/src/utils/commands.js +47 -26
- package/src/utils/commands.js.map +1 -1
- package/src/utils/config/index.d.ts +2 -2
- package/src/utils/config/index.js +5 -4
- package/src/utils/config/index.js.map +1 -1
- package/src/utils/config/utils.js +48 -58
- package/src/utils/config/utils.js.map +1 -1
- package/src/utils/connection/open-api/react.d.ts +5 -5
- package/src/utils/connection/open-api/react.js +81 -77
- package/src/utils/connection/open-api/react.js.map +1 -1
- package/src/utils/containers.js +22 -23
- package/src/utils/containers.js.map +1 -1
- package/src/utils/dynamodb-constructs/dynamodb-constructs.js +32 -33
- package/src/utils/dynamodb-constructs/dynamodb-constructs.js.map +1 -1
- package/src/utils/dynamodb-constructs/files/terraform/app/dynamodb/__nameKebabCase__/__nameKebabCase__.tf.template +12 -2
- package/src/utils/dynamodb-constructs/files/terraform/core/dynamodb/dynamodb.tf.template +1 -1
- package/src/utils/files/common/scripts/src/dynamodb/create-local-table.ts.template +2 -2
- package/src/utils/files/common/scripts/src/dynamodb/pull-image.ts.template +1 -1
- package/src/utils/files/common/scripts/src/dynamodb/start-container.ts.template +17 -2
- package/src/utils/files/common/scripts/src/rdb/mysql/wait-for-mysql-db.ts.template +32 -0
- package/src/utils/files/common/scripts/src/rdb/postgres/wait-for-postgres-db.ts.template +32 -0
- package/src/utils/files/common/scripts/src/rdb/{pull-image.ts.template → shared/pull-image.ts.template} +1 -1
- package/src/utils/files/common/scripts/src/rdb/{start-container.ts.template → shared/start-container.ts.template} +16 -1
- package/src/utils/files/terraform/src/core/asset-bucket/asset-bucket.tf.template +2 -2
- package/src/utils/files/terraform/src/core/runtime-config/appconfig/appconfig.tf.template +1 -1
- package/src/utils/files/terraform/src/core/runtime-config/appconfig-deployment/appconfig-deployment.tf.template +3 -3
- package/src/utils/files/terraform/src/core/runtime-config/entry/entry.tf.template +1 -1
- package/src/utils/files/terraform/src/core/runtime-config/read/read.tf.template +2 -2
- package/src/utils/files/website/hooks/sigv4/useSigV4.tsx.template +1 -1
- package/src/utils/format.js +153 -99
- package/src/utils/format.js.map +1 -1
- package/src/utils/fs.js +14 -13
- package/src/utils/fs.js.map +1 -1
- package/src/utils/function-constructs/files/terraform/app/lambda-functions/__nameKebabCase__/__nameKebabCase__.tf.template +2 -2
- package/src/utils/function-constructs/function-constructs.js +21 -26
- package/src/utils/function-constructs/function-constructs.js.map +1 -1
- package/src/utils/generators.js +18 -20
- package/src/utils/generators.js.map +1 -1
- package/src/utils/git.js +19 -34
- package/src/utils/git.js.map +1 -1
- package/src/utils/iac-providers.js +5 -5
- package/src/utils/iac-providers.js.map +1 -1
- package/src/utils/iac.js +12 -14
- package/src/utils/iac.js.map +1 -1
- package/src/utils/identity-constructs/files/cdk/core/user-identity.ts.template +112 -2
- package/src/utils/identity-constructs/files/terraform/core/user-identity/add-callback-url/add-callback-url.tf.template +2 -2
- package/src/utils/identity-constructs/files/terraform/core/user-identity/identity/identity.tf.template +104 -2
- package/src/utils/identity-constructs/files/terraform/core/user-identity/main.tf.template +7 -0
- package/src/utils/identity-constructs/identity-constructs.js +24 -28
- package/src/utils/identity-constructs/identity-constructs.js.map +1 -1
- package/src/utils/js.js +27 -20
- package/src/utils/js.js.map +1 -1
- package/src/utils/mcp.js +34 -41
- package/src/utils/mcp.js.map +1 -1
- package/src/utils/metrics.js +30 -45
- package/src/utils/metrics.js.map +1 -1
- package/src/utils/mock-project-graph.js +8 -12
- package/src/utils/mock-project-graph.js.map +1 -1
- package/src/utils/names.js +25 -51
- package/src/utils/names.js.map +1 -1
- package/src/utils/npm-scope.js +9 -17
- package/src/utils/npm-scope.js.map +1 -1
- package/src/utils/nx.d.ts +18 -2
- package/src/utils/nx.js +111 -74
- package/src/utils/nx.js.map +1 -1
- package/src/utils/nxlv-python.js +27 -15
- package/src/utils/nxlv-python.js.map +1 -1
- package/src/utils/object.js +5 -11
- package/src/utils/object.js.map +1 -1
- package/src/utils/paths.js +11 -15
- package/src/utils/paths.js.map +1 -1
- package/src/utils/pkg-manager.js +4 -9
- package/src/utils/pkg-manager.js.map +1 -1
- package/src/utils/pnpm-workspace.js +22 -22
- package/src/utils/pnpm-workspace.js.map +1 -1
- package/src/utils/port.js +26 -36
- package/src/utils/port.js.map +1 -1
- package/src/utils/py.js +43 -52
- package/src/utils/py.js.map +1 -1
- package/src/utils/rdb-constructs/files/terraform/app/dbs/__nameKebabCase__/__nameKebabCase__.tf.template +4 -4
- package/src/utils/rdb-constructs/files/terraform/core/rdb/aurora/aurora.tf.template +3 -3
- package/src/utils/rdb-constructs/rdb-constructs.js +31 -33
- package/src/utils/rdb-constructs/rdb-constructs.js.map +1 -1
- package/src/utils/shared-constructs-constants.js +16 -16
- package/src/utils/shared-constructs-constants.js.map +1 -1
- package/src/utils/shared-constructs.js +57 -54
- package/src/utils/shared-constructs.js.map +1 -1
- package/src/utils/shared-dynamodb-scripts.js +16 -14
- package/src/utils/shared-dynamodb-scripts.js.map +1 -1
- package/src/utils/shared-infra-config.js +30 -31
- package/src/utils/shared-infra-config.js.map +1 -1
- package/src/utils/shared-infra-scripts.js +30 -25
- package/src/utils/shared-infra-scripts.js.map +1 -1
- package/src/utils/shared-rdb-scripts.d.ts +8 -3
- package/src/utils/shared-rdb-scripts.js +21 -13
- package/src/utils/shared-rdb-scripts.js.map +1 -1
- package/src/utils/shared-scripts.js +12 -17
- package/src/utils/shared-scripts.js.map +1 -1
- package/src/utils/shared-shadcn.js +64 -60
- package/src/utils/shared-shadcn.js.map +1 -1
- package/src/utils/test.d.ts +8 -0
- package/src/utils/test.js +33 -25
- package/src/utils/test.js.map +1 -1
- package/src/utils/toml.js +7 -15
- package/src/utils/toml.js.map +1 -1
- package/src/utils/versions.d.ts +31 -4
- package/src/utils/versions.js +40 -23
- package/src/utils/versions.js.map +1 -1
- package/src/utils/website-constructs/files/terraform/app/static-websites/__websiteNameKebabCase__/__websiteNameKebabCase__.tf.template +1 -1
- package/src/utils/website-constructs/files/terraform/core/static-website/static-website.tf.template +4 -4
- package/src/utils/website-constructs/website-constructs.js +31 -30
- package/src/utils/website-constructs/website-constructs.js.map +1 -1
- package/bin/aws-nx-mcp.js +0 -17
- package/bin/aws-nx-mcp.js.map +0 -1
- package/sdk/agentcore-gateway.d.ts +0 -6
- package/sdk/agentcore-gateway.js +0 -11
- package/sdk/agentcore-gateway.js.map +0 -1
- package/sdk/connection.d.ts +0 -6
- package/sdk/connection.js +0 -10
- package/sdk/connection.js.map +0 -1
- package/sdk/license.js +0 -14
- package/sdk/license.js.map +0 -1
- package/sdk/open-api.d.ts +0 -10
- package/sdk/open-api.js +0 -15
- package/sdk/open-api.js.map +0 -1
- package/sdk/py.d.ts +0 -14
- package/sdk/py.js +0 -18
- package/sdk/py.js.map +0 -1
- package/sdk/terraform.d.ts +0 -6
- package/sdk/terraform.js +0 -11
- package/sdk/terraform.js.map +0 -1
- package/sdk/ts.d.ts +0 -33
- package/sdk/ts.js +0 -53
- package/sdk/ts.js.map +0 -1
- package/sdk/utils/ast.js +0 -12
- package/sdk/utils/ast.js.map +0 -1
- package/sdk/utils/format.js +0 -10
- package/sdk/utils/format.js.map +0 -1
- package/sdk/utils/test.js +0 -10
- package/sdk/utils/test.js.map +0 -1
- package/src/connection/agent-serve-local.js +0 -48
- package/src/connection/agent-serve-local.js.map +0 -1
- package/src/connection/serve-local.js +0 -41
- package/src/connection/serve-local.js.map +0 -1
- package/src/py/agent/react-connection/serve-local.js +0 -38
- package/src/py/agent/react-connection/serve-local.js.map +0 -1
- package/src/ts/agent/react-connection/serve-local.js +0 -19
- package/src/ts/agent/react-connection/serve-local.js.map +0 -1
- package/src/utils/files/common/scripts/src/rdb/wait-for-db.ts.template +0 -59
- /package/src/agentcore-gateway/files/project/{serve-local.ts.template → local-dev.ts.template} +0 -0
- /package/{bin → src/bin}/aws-nx-mcp.d.ts +0 -0
|
@@ -1,27 +1,22 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.addSharedConstructsOpenApiMetadataGenerateTarget = void 0;
|
|
4
1
|
/**
|
|
5
2
|
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
6
3
|
* SPDX-License-Identifier: Apache-2.0
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const shared_constructs_constants_1 = require("../shared-constructs-constants");
|
|
4
|
+
*/ import { joinPathFragments, updateJson } from "@nx/devkit";
|
|
5
|
+
import { updateGitIgnore } from "../git.js";
|
|
6
|
+
import { addDependencyToTargetIfNotPresent } from "../nx.js";
|
|
7
|
+
import { PACKAGES_DIR, SHARED_CONSTRUCTS_DIR } from "../shared-constructs-constants.js";
|
|
12
8
|
/**
|
|
13
9
|
* Adds a generate:<api-name>-metadata target to shared constructs (CDK only)
|
|
14
10
|
* This allows for API CDK constructs to have type-safety for integrations based on an OpenAPI Specification
|
|
15
|
-
*/
|
|
16
|
-
const addSharedConstructsOpenApiMetadataGenerateTarget = (tree, { iac, apiNameKebabCase, specPath, specBuildTargetName, }) => {
|
|
11
|
+
*/ export const addSharedConstructsOpenApiMetadataGenerateTarget = (tree, { iac, apiNameKebabCase, specPath, specBuildTargetName })=>{
|
|
17
12
|
if (iac !== 'cdk') {
|
|
18
13
|
// For Terraform, we do not support type-safe integration builders, rather only the single lambda
|
|
19
14
|
// router pattern, and therefore do not need to add depenencies on metadata generation.
|
|
20
15
|
return;
|
|
21
16
|
}
|
|
22
|
-
const generatedMetadataDir =
|
|
23
|
-
const generatedMetadataDirFromRoot =
|
|
24
|
-
|
|
17
|
+
const generatedMetadataDir = joinPathFragments('generated', apiNameKebabCase);
|
|
18
|
+
const generatedMetadataDirFromRoot = joinPathFragments(joinPathFragments(PACKAGES_DIR, SHARED_CONSTRUCTS_DIR), 'src', generatedMetadataDir);
|
|
19
|
+
updateJson(tree, joinPathFragments(PACKAGES_DIR, SHARED_CONSTRUCTS_DIR, 'project.json'), (config)=>{
|
|
25
20
|
if (!config.targets) {
|
|
26
21
|
config.targets = {};
|
|
27
22
|
}
|
|
@@ -37,26 +32,31 @@ const addSharedConstructsOpenApiMetadataGenerateTarget = (tree, { iac, apiNameKe
|
|
|
37
32
|
executor: 'nx:run-commands',
|
|
38
33
|
inputs: [
|
|
39
34
|
{
|
|
40
|
-
dependentTasksOutputFiles: '**/*.json'
|
|
41
|
-
}
|
|
35
|
+
dependentTasksOutputFiles: '**/*.json'
|
|
36
|
+
}
|
|
42
37
|
],
|
|
43
38
|
outputs: [
|
|
44
|
-
|
|
39
|
+
joinPathFragments('{workspaceRoot}', generatedMetadataDirFromRoot)
|
|
45
40
|
],
|
|
46
41
|
options: {
|
|
47
42
|
commands: [
|
|
48
|
-
`nx g @aws/nx-plugin:open-api#ts-metadata --openApiSpecPath="${specPath}" --outputPath="${generatedMetadataDirFromRoot}" --no-interactive
|
|
49
|
-
]
|
|
43
|
+
`nx g @aws/nx-plugin:open-api#ts-metadata --openApiSpecPath="${specPath}" --outputPath="${generatedMetadataDirFromRoot}" --no-interactive`
|
|
44
|
+
]
|
|
50
45
|
},
|
|
51
|
-
dependsOn: [
|
|
46
|
+
dependsOn: [
|
|
47
|
+
specBuildTargetName
|
|
48
|
+
]
|
|
52
49
|
};
|
|
53
50
|
}
|
|
54
|
-
|
|
51
|
+
addDependencyToTargetIfNotPresent(config, 'compile', metadataTargetName);
|
|
55
52
|
return config;
|
|
56
53
|
});
|
|
57
54
|
// Ignore the generated metadata by default
|
|
58
55
|
// Users can safely remove the entry from the .gitignore if they prefer to check it in
|
|
59
|
-
|
|
56
|
+
updateGitIgnore(tree, joinPathFragments(PACKAGES_DIR, SHARED_CONSTRUCTS_DIR), (patterns)=>[
|
|
57
|
+
...patterns,
|
|
58
|
+
joinPathFragments('src', generatedMetadataDir)
|
|
59
|
+
]);
|
|
60
60
|
};
|
|
61
|
-
|
|
61
|
+
|
|
62
62
|
//# sourceMappingURL=open-api-metadata.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../../../../../../packages/nx-plugin/src/utils/api-constructs/open-api-metadata.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport {\n joinPathFragments,\n type ProjectConfiguration,\n type Tree,\n updateJson,\n} from '@nx/devkit';\nimport { updateGitIgnore } from '../git';\nimport type { Iac } from '../iac';\nimport { addDependencyToTargetIfNotPresent } from '../nx';\nimport {\n PACKAGES_DIR,\n SHARED_CONSTRUCTS_DIR,\n} from '../shared-constructs-constants';\n\nexport interface AddOpenApiMetadataGenerateTargetOptions {\n iac: Iac;\n apiNameKebabCase: string;\n specPath: string;\n specBuildTargetName: string;\n}\n\n/**\n * Adds a generate:<api-name>-metadata target to shared constructs (CDK only)\n * This allows for API CDK constructs to have type-safety for integrations based on an OpenAPI Specification\n */\nexport const addSharedConstructsOpenApiMetadataGenerateTarget = (\n tree: Tree,\n {\n iac,\n apiNameKebabCase,\n specPath,\n specBuildTargetName,\n }: AddOpenApiMetadataGenerateTargetOptions,\n) => {\n if (iac !== 'cdk') {\n // For Terraform, we do not support type-safe integration builders, rather only the single lambda\n // router pattern, and therefore do not need to add depenencies on metadata generation.\n return;\n }\n\n const generatedMetadataDir = joinPathFragments('generated', apiNameKebabCase);\n const generatedMetadataDirFromRoot = joinPathFragments(\n joinPathFragments(PACKAGES_DIR, SHARED_CONSTRUCTS_DIR),\n 'src',\n generatedMetadataDir,\n );\n\n updateJson(\n tree,\n joinPathFragments(PACKAGES_DIR, SHARED_CONSTRUCTS_DIR, 'project.json'),\n (config: ProjectConfiguration) => {\n if (!config.targets) {\n config.targets = {};\n }\n if (!config.targets.build) {\n config.targets.build = {};\n }\n // If not already defined, add a target to generate metadata from the OpenAPI spec, used\n // for providing a type-safe CDK construct\n const metadataTargetName = `generate:${apiNameKebabCase}-metadata`;\n if (!config.targets[metadataTargetName]) {\n config.targets[metadataTargetName] = {\n cache: true,\n executor: 'nx:run-commands',\n inputs: [\n {\n dependentTasksOutputFiles: '**/*.json',\n },\n ],\n outputs: [\n joinPathFragments('{workspaceRoot}', generatedMetadataDirFromRoot),\n ],\n options: {\n commands: [\n `nx g @aws/nx-plugin:open-api#ts-metadata --openApiSpecPath=\"${specPath}\" --outputPath=\"${generatedMetadataDirFromRoot}\" --no-interactive`,\n ],\n },\n dependsOn: [specBuildTargetName],\n };\n }\n addDependencyToTargetIfNotPresent(config, 'compile', metadataTargetName);\n return config;\n },\n );\n\n // Ignore the generated metadata by default\n // Users can safely remove the entry from the .gitignore if they prefer to check it in\n updateGitIgnore(\n tree,\n joinPathFragments(PACKAGES_DIR, SHARED_CONSTRUCTS_DIR),\n (patterns) => [...patterns, joinPathFragments('src', generatedMetadataDir)],\n );\n};\n"],"names":["joinPathFragments","updateJson","updateGitIgnore","addDependencyToTargetIfNotPresent","PACKAGES_DIR","SHARED_CONSTRUCTS_DIR","addSharedConstructsOpenApiMetadataGenerateTarget","tree","iac","apiNameKebabCase","specPath","specBuildTargetName","generatedMetadataDir","generatedMetadataDirFromRoot","config","targets","build","metadataTargetName","cache","executor","inputs","dependentTasksOutputFiles","outputs","options","commands","dependsOn","patterns"],"mappings":"AAAA;;;CAGC,GACD,SACEA,iBAAiB,EAGjBC,UAAU,QACL,aAAa;AACpB,SAASC,eAAe,QAAQ,YAAS;AAEzC,SAASC,iCAAiC,QAAQ,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utils/ast/website.js
CHANGED
|
@@ -1,27 +1,25 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/**
|
|
3
2
|
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
4
3
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
exports.addHookResultToRouterProviderContext = void 0;
|
|
8
|
-
const ast_1 = require("../ast");
|
|
9
|
-
const addHookResultToRouterProviderContext = async (tree, mainTsxPath, { hook, module, contextProp }) => {
|
|
4
|
+
*/ import { addDestructuredImport, applyGritQL, matchGritQL } from "../ast.js";
|
|
5
|
+
export const addHookResultToRouterProviderContext = async (tree, mainTsxPath, { hook, module, contextProp })=>{
|
|
10
6
|
// All 4 patterns must exist for this transform to apply
|
|
11
7
|
const checks = await Promise.all([
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
8
|
+
matchGritQL(tree, mainTsxPath, '`RouterProviderContext`'),
|
|
9
|
+
matchGritQL(tree, mainTsxPath, '`createRouter($_)`'),
|
|
10
|
+
matchGritQL(tree, mainTsxPath, '`const App = $_`'),
|
|
11
|
+
matchGritQL(tree, mainTsxPath, '`<RouterProvider $_ />`')
|
|
16
12
|
]);
|
|
17
|
-
if (checks.some((c)
|
|
13
|
+
if (checks.some((c)=>!c)) {
|
|
18
14
|
return;
|
|
19
15
|
}
|
|
20
|
-
await
|
|
16
|
+
await addDestructuredImport(tree, mainTsxPath, [
|
|
17
|
+
hook
|
|
18
|
+
], module);
|
|
21
19
|
// 1. Add property to RouterProviderContext type
|
|
22
20
|
// 'some' checks direct members only (not nested), so a nested 'auth' won't block adding a top-level one.
|
|
23
21
|
// Type members use ; as terminators, so += with leading \n handles separation.
|
|
24
|
-
await
|
|
22
|
+
await applyGritQL(tree, mainTsxPath, `or {
|
|
25
23
|
\`type RouterProviderContext = {}\` => \`type RouterProviderContext = {
|
|
26
24
|
${contextProp}?: ReturnType<typeof ${hook}>;
|
|
27
25
|
}\`,
|
|
@@ -34,25 +32,25 @@ ${contextProp}?: ReturnType<typeof ${hook}>\`
|
|
|
34
32
|
// 2. Add context property to createRouter config
|
|
35
33
|
// 'some' checks direct properties of the createRouter argument object only.
|
|
36
34
|
// Use += for multi-prop objects, => rewrite for single-prop.
|
|
37
|
-
await
|
|
35
|
+
await applyGritQL(tree, mainTsxPath, `\`createRouter({ $props })\` where {
|
|
38
36
|
$props <: not some \`context: $_\`,
|
|
39
37
|
$props += \`context: { ${contextProp}: undefined }\`
|
|
40
38
|
}`);
|
|
41
39
|
// If context already exists, add the new prop to it.
|
|
42
40
|
// Handle empty context: {} via nested contains => rewrite, scoped to createRouter.
|
|
43
|
-
await
|
|
41
|
+
await applyGritQL(tree, mainTsxPath, `\`createRouter({ $props })\` where {
|
|
44
42
|
$props <: contains \`context: {}\` => \`context: { ${contextProp}: undefined }\`
|
|
45
43
|
}`);
|
|
46
44
|
// Handle non-empty context via rewrite (the context object may be single-prop
|
|
47
45
|
// from the first hook call, where += concatenates without comma)
|
|
48
|
-
await
|
|
46
|
+
await applyGritQL(tree, mainTsxPath, `\`context: { $cprops }\` => \`context: { $cprops, ${contextProp}: undefined }\` where {
|
|
49
47
|
$cprops <: within \`createRouter($_)\`,
|
|
50
48
|
$cprops <: not some \`${contextProp}: $_\`
|
|
51
49
|
}`);
|
|
52
50
|
// 3. Add hook call to App component body
|
|
53
51
|
// Block body: 'some' checks direct statements.
|
|
54
52
|
// Expression body: 'contains' to also prevent matching block bodies.
|
|
55
|
-
await
|
|
53
|
+
await applyGritQL(tree, mainTsxPath, `or {
|
|
56
54
|
\`const App = () => { $body }\` => raw\`const App = () => {
|
|
57
55
|
const ${contextProp} = ${hook}();
|
|
58
56
|
$body
|
|
@@ -64,7 +62,7 @@ ${contextProp}?: ReturnType<typeof ${hook}>\`
|
|
|
64
62
|
}`);
|
|
65
63
|
// 4. Add context prop to RouterProvider JSX element
|
|
66
64
|
// 'some' checks direct JSX attributes only.
|
|
67
|
-
await
|
|
65
|
+
await applyGritQL(tree, mainTsxPath, `or {
|
|
68
66
|
\`<RouterProvider $attrs context={{}} />\` => \`<RouterProvider $attrs context={{ ${contextProp} }} />\`,
|
|
69
67
|
\`<RouterProvider $attrs context={{ $cprops }} />\` => \`<RouterProvider $attrs context={{ $cprops, ${contextProp} }} />\` where {
|
|
70
68
|
$cprops <: not some \`${contextProp}\`
|
|
@@ -74,5 +72,5 @@ ${contextProp}?: ReturnType<typeof ${hook}>\`
|
|
|
74
72
|
}
|
|
75
73
|
}`);
|
|
76
74
|
};
|
|
77
|
-
|
|
75
|
+
|
|
78
76
|
//# sourceMappingURL=website.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../../../../../../packages/nx-plugin/src/utils/ast/website.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport type { Tree } from '@nx/devkit';\nimport { addDestructuredImport, applyGritQL, matchGritQL } from '../ast';\n\nexport interface AddHookResultToRouterProviderContextProps {\n hook: string; // eg useAuth\n module: string; // eg. react-oidc-context\n contextProp: string; // eg. auth\n}\n\nexport const addHookResultToRouterProviderContext = async (\n tree: Tree,\n mainTsxPath: string,\n { hook, module, contextProp }: AddHookResultToRouterProviderContextProps,\n) => {\n // All 4 patterns must exist for this transform to apply\n const checks = await Promise.all([\n matchGritQL(tree, mainTsxPath, '`RouterProviderContext`'),\n matchGritQL(tree, mainTsxPath, '`createRouter($_)`'),\n matchGritQL(tree, mainTsxPath, '`const App = $_`'),\n matchGritQL(tree, mainTsxPath, '`<RouterProvider $_ />`'),\n ]);\n\n if (checks.some((c) => !c)) {\n return;\n }\n\n await addDestructuredImport(tree, mainTsxPath, [hook], module);\n\n // 1. Add property to RouterProviderContext type\n // 'some' checks direct members only (not nested), so a nested 'auth' won't block adding a top-level one.\n // Type members use ; as terminators, so += with leading \\n handles separation.\n await applyGritQL(\n tree,\n mainTsxPath,\n `or {\n \\`type RouterProviderContext = {}\\` => \\`type RouterProviderContext = {\n ${contextProp}?: ReturnType<typeof ${hook}>;\n}\\`,\n \\`type RouterProviderContext = { $members }\\` where {\n $members <: not some \\`${contextProp}?: $_\\`,\n $members += \\`\n${contextProp}?: ReturnType<typeof ${hook}>\\`\n }\n }`,\n );\n\n // 2. Add context property to createRouter config\n // 'some' checks direct properties of the createRouter argument object only.\n // Use += for multi-prop objects, => rewrite for single-prop.\n await applyGritQL(\n tree,\n mainTsxPath,\n `\\`createRouter({ $props })\\` where {\n $props <: not some \\`context: $_\\`,\n $props += \\`context: { ${contextProp}: undefined }\\`\n }`,\n );\n\n // If context already exists, add the new prop to it.\n // Handle empty context: {} via nested contains => rewrite, scoped to createRouter.\n await applyGritQL(\n tree,\n mainTsxPath,\n `\\`createRouter({ $props })\\` where {\n $props <: contains \\`context: {}\\` => \\`context: { ${contextProp}: undefined }\\`\n }`,\n );\n // Handle non-empty context via rewrite (the context object may be single-prop\n // from the first hook call, where += concatenates without comma)\n await applyGritQL(\n tree,\n mainTsxPath,\n `\\`context: { $cprops }\\` => \\`context: { $cprops, ${contextProp}: undefined }\\` where {\n $cprops <: within \\`createRouter($_)\\`,\n $cprops <: not some \\`${contextProp}: $_\\`\n }`,\n );\n\n // 3. Add hook call to App component body\n // Block body: 'some' checks direct statements.\n // Expression body: 'contains' to also prevent matching block bodies.\n await applyGritQL(\n tree,\n mainTsxPath,\n `or {\n \\`const App = () => { $body }\\` => raw\\`const App = () => {\n const ${contextProp} = ${hook}();\n $body\n}\\` where { $body <: not some \\`const ${contextProp} = ${hook}()\\` },\n \\`const App = () => $expr\\` => raw\\`const App = () => {\n const ${contextProp} = ${hook}();\n return $expr;\n}\\` where { $expr <: not contains \\`${hook}()\\` }\n }`,\n );\n\n // 4. Add context prop to RouterProvider JSX element\n // 'some' checks direct JSX attributes only.\n await applyGritQL(\n tree,\n mainTsxPath,\n `or {\n \\`<RouterProvider $attrs context={{}} />\\` => \\`<RouterProvider $attrs context={{ ${contextProp} }} />\\`,\n \\`<RouterProvider $attrs context={{ $cprops }} />\\` => \\`<RouterProvider $attrs context={{ $cprops, ${contextProp} }} />\\` where {\n $cprops <: not some \\`${contextProp}\\`\n },\n \\`<RouterProvider $attrs />\\` => \\`<RouterProvider $attrs context={{ ${contextProp} }} />\\` where {\n $attrs <: not some \\`context={$_}\\`\n }\n }`,\n );\n};\n"],"names":["addDestructuredImport","applyGritQL","matchGritQL","addHookResultToRouterProviderContext","tree","mainTsxPath","hook","module","contextProp","checks","Promise","all","some","c"],"mappings":"AAAA;;;CAGC,GAGD,SAASA,qBAAqB,EAAEC,WAAW,EAAEC,WAAW,QAAQ,YAAS;AAQzE,OAAO,MAAMC,uCAAuC,OAClDC,MACAC,aACA,EAAEC,IAAI,EAAEC,MAAM,EAAEC,WAAW,EAA6C;IAExE,wDAAwD;IACxD,MAAMC,SAAS,MAAMC,QAAQC,GAAG,CAAC;QAC/BT,YAAYE,MAAMC,aAAa;QAC/BH,YAAYE,MAAMC,aAAa;QAC/BH,YAAYE,MAAMC,aAAa;QAC/BH,YAAYE,MAAMC,aAAa;KAChC;IAED,IAAII,OAAOG,IAAI,CAAC,CAACC,IAAM,CAACA,IAAI;QAC1B;IACF;IAEA,MAAMb,sBAAsBI,MAAMC,aAAa;QAACC;KAAK,EAAEC;IAEvD,gDAAgD;IAChD,4GAA4G;IAC5G,kFAAkF;IAClF,MAAMN,YACJG,MACAC,aACA,CAAC;;EAEH,EAAEG,YAAY,qBAAqB,EAAEF,KAAK;;;+BAGb,EAAEE,YAAY;;AAE7C,EAAEA,YAAY,qBAAqB,EAAEF,KAAK;;KAErC,CAAC;IAGJ,iDAAiD;IACjD,+EAA+E;IAC/E,gEAAgE;IAChE,MAAML,YACJG,MACAC,aACA,CAAC;;6BAEwB,EAAEG,YAAY;KACtC,CAAC;IAGJ,qDAAqD;IACrD,mFAAmF;IACnF,MAAMP,YACJG,MACAC,aACA,CAAC;yDACoD,EAAEG,YAAY;KAClE,CAAC;IAEJ,8EAA8E;IAC9E,iEAAiE;IACjE,MAAMP,YACJG,MACAC,aACA,CAAC,kDAAkD,EAAEG,YAAY;;4BAEzC,EAAEA,YAAY;KACrC,CAAC;IAGJ,yCAAyC;IACzC,kDAAkD;IAClD,wEAAwE;IACxE,MAAMP,YACJG,MACAC,aACA,CAAC;;QAEG,EAAEG,YAAY,GAAG,EAAEF,KAAK;;sCAEM,EAAEE,YAAY,GAAG,EAAEF,KAAK;;QAEtD,EAAEE,YAAY,GAAG,EAAEF,KAAK;;oCAEI,EAAEA,KAAK;KACtC,CAAC;IAGJ,oDAAoD;IACpD,+CAA+C;IAC/C,MAAML,YACJG,MACAC,aACA,CAAC;wFACmF,EAAEG,YAAY;0GACI,EAAEA,YAAY;8BAC1F,EAAEA,YAAY;;2EAE+B,EAAEA,YAAY;;;KAGpF,CAAC;AAEN,EAAE"}
|
package/src/utils/ast.js
CHANGED
|
@@ -1,40 +1,35 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/**
|
|
3
2
|
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
4
3
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const tslib_1 = require("tslib");
|
|
9
|
-
const gritql_1 = require("@getgrit/gritql");
|
|
10
|
-
const path = tslib_1.__importStar(require("path"));
|
|
11
|
-
const git_1 = require("./git");
|
|
4
|
+
*/ import { QueryBuilder } from "@getgrit/gritql";
|
|
5
|
+
import * as path from "path";
|
|
6
|
+
import { updateGitIgnore } from "./git.js";
|
|
12
7
|
const GRIT_DIR = '.grit';
|
|
13
8
|
// Pin the gritql native library's "global" stdlib directory to <workspace>/.grit so it doesn't try to write to /usr/local/.grit (or wherever node's grandparent resolves to).
|
|
14
|
-
const ensureGritDir = (tree)
|
|
9
|
+
const ensureGritDir = (tree)=>{
|
|
15
10
|
process.env.GRIT_GLOBAL_DIR ??= path.join(tree.root, GRIT_DIR);
|
|
16
|
-
|
|
11
|
+
updateGitIgnore(tree, '.', (patterns)=>[
|
|
12
|
+
...patterns,
|
|
13
|
+
GRIT_DIR
|
|
14
|
+
]);
|
|
17
15
|
};
|
|
18
|
-
const assertFilePath = (tree, filePath)
|
|
16
|
+
const assertFilePath = (tree, filePath)=>{
|
|
19
17
|
if (!tree.exists(filePath)) {
|
|
20
18
|
throw new Error(`No file located at ${filePath}`);
|
|
21
19
|
}
|
|
22
20
|
};
|
|
23
|
-
const addDestructuredImport = async (tree, filePath, variableNames, from)
|
|
21
|
+
export const addDestructuredImport = async (tree, filePath, variableNames, from)=>{
|
|
24
22
|
assertFilePath(tree, filePath);
|
|
25
23
|
// Check if there's an existing import from this module
|
|
26
|
-
const hasExistingImport = await
|
|
24
|
+
const hasExistingImport = await matchGritQL(tree, filePath, `\`import { $_ } from '${from}'\``);
|
|
27
25
|
if (hasExistingImport) {
|
|
28
26
|
// For each new variable, use GritQL rewrite to add it if not already present
|
|
29
|
-
for (const variableName of variableNames)
|
|
30
|
-
const localName = variableName.includes(' as ')
|
|
31
|
-
? variableName.split(' as ')[1]
|
|
32
|
-
: variableName;
|
|
27
|
+
for (const variableName of variableNames){
|
|
28
|
+
const localName = variableName.includes(' as ') ? variableName.split(' as ')[1] : variableName;
|
|
33
29
|
// Use rewrite (=>) which correctly handles comma-separated import specifier lists
|
|
34
|
-
await
|
|
30
|
+
await applyGritQL(tree, filePath, `\`import { $imports } from '${from}'\` => \`import { $imports, ${variableName} } from '${from}'\` where { $imports <: not contains \`${localName}\` }`);
|
|
35
31
|
}
|
|
36
|
-
}
|
|
37
|
-
else {
|
|
32
|
+
} else {
|
|
38
33
|
// No existing import — prepend a new one (after shebang if present)
|
|
39
34
|
const specifiers = variableNames.join(', ');
|
|
40
35
|
const contents = tree.read(filePath).toString();
|
|
@@ -42,13 +37,11 @@ const addDestructuredImport = async (tree, filePath, variableNames, from) => {
|
|
|
42
37
|
if (contents.startsWith('#!')) {
|
|
43
38
|
const newlineIndex = contents.indexOf('\n');
|
|
44
39
|
tree.write(filePath, `${contents.substring(0, newlineIndex + 1)}${newImport}${contents.substring(newlineIndex + 1)}`);
|
|
45
|
-
}
|
|
46
|
-
else {
|
|
40
|
+
} else {
|
|
47
41
|
tree.write(filePath, `${newImport}${contents}`);
|
|
48
42
|
}
|
|
49
43
|
}
|
|
50
44
|
};
|
|
51
|
-
exports.addDestructuredImport = addDestructuredImport;
|
|
52
45
|
/**
|
|
53
46
|
* Ensure a Python `from <module> import <name1>, <name2>, ...` statement
|
|
54
47
|
* exists in the given file. If the module already has a `from <module> import`
|
|
@@ -61,17 +54,16 @@ exports.addDestructuredImport = addDestructuredImport;
|
|
|
61
54
|
* was rewritten after trying every requested name, we fall back to checking
|
|
62
55
|
* whether the module is imported at all; if not, we prepend a fresh
|
|
63
56
|
* `from <module> import ...` line.
|
|
64
|
-
*/
|
|
65
|
-
const addPythonDestructuredImport = async (tree, filePath, variableNames, from) => {
|
|
57
|
+
*/ export const addPythonDestructuredImport = async (tree, filePath, variableNames, from)=>{
|
|
66
58
|
assertFilePath(tree, filePath);
|
|
67
59
|
// Determine whether there's any `from <module> import ...` line in the file.
|
|
68
60
|
// We detect this by attempting a no-op transformation — the file is unchanged,
|
|
69
61
|
// but a successful match tells us the line exists.
|
|
70
62
|
const beforeContents = tree.read(filePath).toString();
|
|
71
63
|
let moduleAlreadyImported = false;
|
|
72
|
-
for (const variableName of variableNames)
|
|
64
|
+
for (const variableName of variableNames){
|
|
73
65
|
// Appends the name if the import-from exists and the name isn't already there.
|
|
74
|
-
const appended = await
|
|
66
|
+
const appended = await applyGritQL(tree, filePath, `language python\n\`from ${from} import $names\` where { $names <: not contains \`${variableName}\`, $names += \`, ${variableName}\` }`);
|
|
75
67
|
if (appended) {
|
|
76
68
|
moduleAlreadyImported = true;
|
|
77
69
|
}
|
|
@@ -83,9 +75,7 @@ const addPythonDestructuredImport = async (tree, filePath, variableNames, from)
|
|
|
83
75
|
if (moduleAlreadyImported) {
|
|
84
76
|
return;
|
|
85
77
|
}
|
|
86
|
-
const allAlreadyPresent = await
|
|
87
|
-
.map((n) => `$names <: contains \`${n}\``)
|
|
88
|
-
.join(', ')} }`);
|
|
78
|
+
const allAlreadyPresent = await matchGritQL(tree, filePath, `language python\n\`from ${from} import $names\` where { ${variableNames.map((n)=>`$names <: contains \`${n}\``).join(', ')} }`);
|
|
89
79
|
if (allAlreadyPresent) {
|
|
90
80
|
return;
|
|
91
81
|
}
|
|
@@ -94,15 +84,13 @@ const addPythonDestructuredImport = async (tree, filePath, variableNames, from)
|
|
|
94
84
|
const specifiers = variableNames.join(', ');
|
|
95
85
|
tree.write(filePath, `from ${from} import ${specifiers}\n${beforeContents}`);
|
|
96
86
|
};
|
|
97
|
-
exports.addPythonDestructuredImport = addPythonDestructuredImport;
|
|
98
87
|
/**
|
|
99
88
|
* Adds an `import <variableName> from '<from>'; statement to the beginning of the file,
|
|
100
89
|
* if it doesn't already exist
|
|
101
|
-
*/
|
|
102
|
-
const addSingleImport = async (tree, filePath, variableName, from) => {
|
|
90
|
+
*/ export const addSingleImport = async (tree, filePath, variableName, from)=>{
|
|
103
91
|
assertFilePath(tree, filePath);
|
|
104
92
|
// Check if default import already exists using GritQL
|
|
105
|
-
const alreadyImported = await
|
|
93
|
+
const alreadyImported = await matchGritQL(tree, filePath, `\`import ${variableName} from '${from}'\``);
|
|
106
94
|
if (alreadyImported) {
|
|
107
95
|
return;
|
|
108
96
|
}
|
|
@@ -110,12 +98,10 @@ const addSingleImport = async (tree, filePath, variableName, from) => {
|
|
|
110
98
|
const contents = tree.read(filePath).toString();
|
|
111
99
|
tree.write(filePath, `import ${variableName} from '${from}';\n${contents}`);
|
|
112
100
|
};
|
|
113
|
-
exports.addSingleImport = addSingleImport;
|
|
114
101
|
/**
|
|
115
102
|
* Adds an `export * from '<from>'; statement to the given TypeScript file.
|
|
116
103
|
* Note that this will create the file if it does not exist in the tree.
|
|
117
|
-
*/
|
|
118
|
-
const addStarExport = async (tree, filePath, from) => {
|
|
104
|
+
*/ export const addStarExport = async (tree, filePath, from)=>{
|
|
119
105
|
const contents = tree.read(filePath)?.toString() ?? '';
|
|
120
106
|
// For empty/non-existent files, just write the export
|
|
121
107
|
if (!contents.trim()) {
|
|
@@ -123,59 +109,54 @@ const addStarExport = async (tree, filePath, from) => {
|
|
|
123
109
|
return;
|
|
124
110
|
}
|
|
125
111
|
// Check if already exported using GritQL
|
|
126
|
-
const alreadyExported = await
|
|
112
|
+
const alreadyExported = await matchGritQL(tree, filePath, `\`export * from '${from}'\``);
|
|
127
113
|
if (alreadyExported) {
|
|
128
114
|
return;
|
|
129
115
|
}
|
|
130
116
|
// Prepend new export to file
|
|
131
117
|
tree.write(filePath, `export * from '${from}';\n${contents}`);
|
|
132
118
|
};
|
|
133
|
-
exports.addStarExport = addStarExport;
|
|
134
119
|
/**
|
|
135
120
|
* Return whether or not the given identifier is exported in the source file.
|
|
136
121
|
* Checks for both `export { Identifier }` and `export type Identifier = ...`.
|
|
137
|
-
*/
|
|
138
|
-
const hasExportDeclaration = async (tree, source, identifierName) => {
|
|
122
|
+
*/ export const hasExportDeclaration = async (tree, source, identifierName)=>{
|
|
139
123
|
ensureGritDir(tree);
|
|
140
124
|
const patterns = [
|
|
141
125
|
`\`export type ${identifierName} = $_\``,
|
|
142
126
|
`\`export { ${identifierName} }\``,
|
|
143
|
-
`\`export type { ${identifierName} } from $_
|
|
127
|
+
`\`export type { ${identifierName} } from $_\``
|
|
144
128
|
];
|
|
145
|
-
for (const pattern of patterns)
|
|
129
|
+
for (const pattern of patterns){
|
|
146
130
|
try {
|
|
147
|
-
const q = new
|
|
131
|
+
const q = new QueryBuilder(`$p => $p where { $p <: ${pattern} }`);
|
|
148
132
|
const result = await q.applyToFile({
|
|
149
133
|
path: 'check.ts',
|
|
150
|
-
content: source
|
|
134
|
+
content: source
|
|
151
135
|
});
|
|
152
|
-
if (result !== null)
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
catch {
|
|
156
|
-
// Pattern didn't match, try next
|
|
136
|
+
if (result !== null) return true;
|
|
137
|
+
} catch {
|
|
138
|
+
// Pattern didn't match, try next
|
|
157
139
|
}
|
|
158
140
|
}
|
|
159
141
|
return false;
|
|
160
142
|
};
|
|
161
|
-
exports.hasExportDeclaration = hasExportDeclaration;
|
|
162
143
|
/**
|
|
163
144
|
* Apply a GritQL pattern to a file in the Nx tree.
|
|
164
|
-
*/
|
|
165
|
-
|
|
166
|
-
if (!tree.exists(filePath))
|
|
167
|
-
throw new Error(`No file at ${filePath}`);
|
|
145
|
+
*/ export const applyGritQL = async (tree, filePath, pattern)=>{
|
|
146
|
+
if (!tree.exists(filePath)) throw new Error(`No file at ${filePath}`);
|
|
168
147
|
ensureGritDir(tree);
|
|
169
148
|
const source = tree.read(filePath).toString();
|
|
170
|
-
const query = new
|
|
171
|
-
const result = await query.applyToFile({
|
|
149
|
+
const query = new QueryBuilder(pattern);
|
|
150
|
+
const result = await query.applyToFile({
|
|
151
|
+
path: filePath,
|
|
152
|
+
content: source
|
|
153
|
+
});
|
|
172
154
|
if (result && result.content !== source) {
|
|
173
155
|
tree.write(filePath, result.content);
|
|
174
156
|
return true;
|
|
175
157
|
}
|
|
176
158
|
return false;
|
|
177
159
|
};
|
|
178
|
-
exports.applyGritQL = applyGritQL;
|
|
179
160
|
/**
|
|
180
161
|
* Check whether a GritQL pattern matches anywhere in a file.
|
|
181
162
|
* Returns true if the pattern matches at least once.
|
|
@@ -183,82 +164,78 @@ exports.applyGritQL = applyGritQL;
|
|
|
183
164
|
* Accepts raw GritQL, including patterns that start with a `language <name>`
|
|
184
165
|
* header (e.g. `language python\n\`print($_)\``) — the pattern is passed
|
|
185
166
|
* straight through to QueryBuilder without any wrapping rewrite.
|
|
186
|
-
*/
|
|
187
|
-
|
|
188
|
-
if (!tree.exists(filePath))
|
|
189
|
-
return false;
|
|
167
|
+
*/ export const matchGritQL = async (tree, filePath, pattern)=>{
|
|
168
|
+
if (!tree.exists(filePath)) return false;
|
|
190
169
|
ensureGritDir(tree);
|
|
191
170
|
const source = tree.read(filePath).toString();
|
|
192
171
|
let matched = false;
|
|
193
172
|
try {
|
|
194
|
-
const query = new
|
|
195
|
-
query.filter(()
|
|
173
|
+
const query = new QueryBuilder(pattern);
|
|
174
|
+
query.filter(()=>{
|
|
196
175
|
matched = true;
|
|
197
176
|
return true;
|
|
198
177
|
});
|
|
199
|
-
await query.applyToFile({
|
|
200
|
-
|
|
201
|
-
|
|
178
|
+
await query.applyToFile({
|
|
179
|
+
path: filePath,
|
|
180
|
+
content: source
|
|
181
|
+
});
|
|
182
|
+
} catch {
|
|
202
183
|
return false;
|
|
203
184
|
}
|
|
204
185
|
return matched;
|
|
205
186
|
};
|
|
206
|
-
exports.matchGritQL = matchGritQL;
|
|
207
187
|
/**
|
|
208
188
|
* Capture the source text of the first match of a GritQL pattern.
|
|
209
189
|
*
|
|
210
190
|
* For example `` `dependencyCheck: $_` `` returns the whole
|
|
211
191
|
* `dependencyCheck: { ... }` property text. Returns undefined if nothing
|
|
212
192
|
* matches. The file is not modified.
|
|
213
|
-
*/
|
|
214
|
-
|
|
215
|
-
if (!tree.exists(filePath))
|
|
216
|
-
return undefined;
|
|
193
|
+
*/ export const captureGritQL = async (tree, filePath, pattern)=>{
|
|
194
|
+
if (!tree.exists(filePath)) return undefined;
|
|
217
195
|
ensureGritDir(tree);
|
|
218
196
|
const source = tree.read(filePath).toString();
|
|
219
197
|
let captured;
|
|
220
198
|
try {
|
|
221
|
-
const query = new
|
|
222
|
-
query.filter((node)
|
|
199
|
+
const query = new QueryBuilder(pattern);
|
|
200
|
+
query.filter((node)=>{
|
|
223
201
|
captured ??= node.text();
|
|
224
202
|
return true;
|
|
225
203
|
});
|
|
226
|
-
await query.applyToFile({
|
|
227
|
-
|
|
228
|
-
|
|
204
|
+
await query.applyToFile({
|
|
205
|
+
path: filePath,
|
|
206
|
+
content: source
|
|
207
|
+
});
|
|
208
|
+
} catch {
|
|
229
209
|
return undefined;
|
|
230
210
|
}
|
|
231
211
|
return captured;
|
|
232
212
|
};
|
|
233
|
-
exports.captureGritQL = captureGritQL;
|
|
234
213
|
/**
|
|
235
214
|
* Return the text of every node matching the GritQL pattern, in document order.
|
|
236
|
-
*/
|
|
237
|
-
|
|
238
|
-
if (!tree.exists(filePath))
|
|
239
|
-
return [];
|
|
215
|
+
*/ export const captureAllGritQL = async (tree, filePath, pattern)=>{
|
|
216
|
+
if (!tree.exists(filePath)) return [];
|
|
240
217
|
ensureGritDir(tree);
|
|
241
218
|
const source = tree.read(filePath).toString();
|
|
242
219
|
const captured = [];
|
|
243
220
|
try {
|
|
244
|
-
const query = new
|
|
245
|
-
query.filter((node)
|
|
221
|
+
const query = new QueryBuilder(pattern);
|
|
222
|
+
query.filter((node)=>{
|
|
246
223
|
captured.push(node.text());
|
|
247
224
|
return true;
|
|
248
225
|
});
|
|
249
|
-
await query.applyToFile({
|
|
250
|
-
|
|
251
|
-
|
|
226
|
+
await query.applyToFile({
|
|
227
|
+
path: filePath,
|
|
228
|
+
content: source
|
|
229
|
+
});
|
|
230
|
+
} catch {
|
|
252
231
|
return [];
|
|
253
232
|
}
|
|
254
233
|
return captured;
|
|
255
234
|
};
|
|
256
|
-
exports.captureAllGritQL = captureAllGritQL;
|
|
257
235
|
/**
|
|
258
236
|
* A unique token that is a valid identifier, so it can stand in for an array
|
|
259
237
|
* element or object property inside a GritQL rewrite.
|
|
260
|
-
*/
|
|
261
|
-
exports.GRIT_INSERT_PLACEHOLDER = '__GRIT_INSERT_PLACEHOLDER__';
|
|
238
|
+
*/ export const GRIT_INSERT_PLACEHOLDER = '__GRIT_INSERT_PLACEHOLDER__';
|
|
262
239
|
/**
|
|
263
240
|
* Apply a GritQL rewrite that inserts {@link GRIT_INSERT_PLACEHOLDER}, then
|
|
264
241
|
* replace the placeholder with `text`. Routing user-provided text through a
|
|
@@ -272,17 +249,15 @@ exports.GRIT_INSERT_PLACEHOLDER = '__GRIT_INSERT_PLACEHOLDER__';
|
|
|
272
249
|
*
|
|
273
250
|
* The caller formats afterwards. Returns true if the pattern matched and the
|
|
274
251
|
* file changed.
|
|
275
|
-
*/
|
|
276
|
-
|
|
277
|
-
if (!(await (0, exports.applyGritQL)(tree, filePath, pattern)))
|
|
278
|
-
return false;
|
|
252
|
+
*/ export const insertViaGritQL = async (tree, filePath, pattern, text)=>{
|
|
253
|
+
if (!await applyGritQL(tree, filePath, pattern)) return false;
|
|
279
254
|
const content = tree.read(filePath).toString();
|
|
280
|
-
const at = content.indexOf(
|
|
255
|
+
const at = content.indexOf(GRIT_INSERT_PLACEHOLDER);
|
|
281
256
|
const lineSoFar = content.slice(content.lastIndexOf('\n', at) + 1, at);
|
|
282
257
|
const replacement = lineSoFar.includes('//') ? `\n${text}` : text;
|
|
283
258
|
// Function replacer so `$` in `text` isn't treated as a replacement pattern.
|
|
284
|
-
tree.write(filePath, content.replace(
|
|
259
|
+
tree.write(filePath, content.replace(GRIT_INSERT_PLACEHOLDER, ()=>replacement));
|
|
285
260
|
return true;
|
|
286
261
|
};
|
|
287
|
-
|
|
262
|
+
|
|
288
263
|
//# sourceMappingURL=ast.js.map
|
package/src/utils/ast.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ast.js","sourceRoot":"","sources":["../../../../../packages/nx-plugin/src/utils/ast.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;AAEH,4CAA+C;AAE/C,mDAA6B;AAC7B,+BAAwC;AAExC,MAAM,QAAQ,GAAG,OAAO,CAAC;AAEzB,8KAA8K;AAC9K,MAAM,aAAa,GAAG,CAAC,IAAU,EAAE,EAAE;IACnC,OAAO,CAAC,GAAG,CAAC,eAAe,KAAK,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;IAC/D,IAAA,qBAAe,EAAC,IAAI,EAAE,GAAG,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,GA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AAG,CAAC,EAAE,EAAE,CAAC,CAAC;IACvE,MAAM,WAAW,GAAG,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;IAElE,6EAA6E;IAC7E,IAAI,CAAC,KAAK,CACR,QAAQ,EACR,OAAO,CAAC,OAAO,CAAC,+BAAuB,EAAE,GAAG,EAAE,CAAC,WAAW,CAAC,CAC5D,CAAC;IACF,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AAlBW,QAAA,eAAe,mBAkB1B"}
|
|
1
|
+
{"version":3,"sources":["../../../../../packages/nx-plugin/src/utils/ast.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { QueryBuilder } from '@getgrit/gritql';\nimport type { Tree } from '@nx/devkit';\nimport * as path from 'path';\nimport { updateGitIgnore } from './git';\n\nconst GRIT_DIR = '.grit';\n\n// Pin the gritql native library's \"global\" stdlib directory to <workspace>/.grit so it doesn't try to write to /usr/local/.grit (or wherever node's grandparent resolves to).\nconst ensureGritDir = (tree: Tree) => {\n process.env.GRIT_GLOBAL_DIR ??= path.join(tree.root, GRIT_DIR);\n updateGitIgnore(tree, '.', (patterns) => [...patterns, GRIT_DIR]);\n};\n\nconst assertFilePath = (tree: Tree, filePath: string) => {\n if (!tree.exists(filePath)) {\n throw new Error(`No file located at ${filePath}`);\n }\n};\n\nexport const addDestructuredImport = async (\n tree: Tree,\n filePath: string,\n variableNames: string[],\n from: string,\n) => {\n assertFilePath(tree, filePath);\n\n // Check if there's an existing import from this module\n const hasExistingImport = await matchGritQL(\n tree,\n filePath,\n `\\`import { $_ } from '${from}'\\``,\n );\n\n if (hasExistingImport) {\n // For each new variable, use GritQL rewrite to add it if not already present\n for (const variableName of variableNames) {\n const localName = variableName.includes(' as ')\n ? variableName.split(' as ')[1]\n : variableName;\n // Use rewrite (=>) which correctly handles comma-separated import specifier lists\n await applyGritQL(\n tree,\n filePath,\n `\\`import { $imports } from '${from}'\\` => \\`import { $imports, ${variableName} } from '${from}'\\` where { $imports <: not contains \\`${localName}\\` }`,\n );\n }\n } else {\n // No existing import — prepend a new one (after shebang if present)\n const specifiers = variableNames.join(', ');\n const contents = tree.read(filePath)!.toString();\n const newImport = `import { ${specifiers} } from '${from}';\\n`;\n if (contents.startsWith('#!')) {\n const newlineIndex = contents.indexOf('\\n');\n tree.write(\n filePath,\n `${contents.substring(0, newlineIndex + 1)}${newImport}${contents.substring(newlineIndex + 1)}`,\n );\n } else {\n tree.write(filePath, `${newImport}${contents}`);\n }\n }\n};\n\n/**\n * Ensure a Python `from <module> import <name1>, <name2>, ...` statement\n * exists in the given file. If the module already has a `from <module> import`\n * line, any missing names are appended; otherwise a fresh import statement is\n * prepended to the file (ruff's import sorter will reorder it into place on\n * the next format pass).\n *\n * We try to append first (which only succeeds if an import-from for the\n * module already exists AND the name isn't yet in the list). If nothing\n * was rewritten after trying every requested name, we fall back to checking\n * whether the module is imported at all; if not, we prepend a fresh\n * `from <module> import ...` line.\n */\nexport const addPythonDestructuredImport = async (\n tree: Tree,\n filePath: string,\n variableNames: string[],\n from: string,\n) => {\n assertFilePath(tree, filePath);\n\n // Determine whether there's any `from <module> import ...` line in the file.\n // We detect this by attempting a no-op transformation — the file is unchanged,\n // but a successful match tells us the line exists.\n const beforeContents = tree.read(filePath)!.toString();\n let moduleAlreadyImported = false;\n for (const variableName of variableNames) {\n // Appends the name if the import-from exists and the name isn't already there.\n const appended = await applyGritQL(\n tree,\n filePath,\n `language python\\n\\`from ${from} import $names\\` where { $names <: not contains \\`${variableName}\\`, $names += \\`, ${variableName}\\` }`,\n );\n if (appended) {\n moduleAlreadyImported = true;\n }\n }\n\n // If the append succeeded for at least one name, we know the module line\n // exists; we're done. If nothing was appended we need to distinguish\n // between \"module not imported\" (need to add a new line) and \"module\n // imported but all names already present\" (no-op).\n if (moduleAlreadyImported) {\n return;\n }\n\n const allAlreadyPresent = await matchGritQL(\n tree,\n filePath,\n `language python\\n\\`from ${from} import $names\\` where { ${variableNames\n .map((n) => `$names <: contains \\`${n}\\``)\n .join(', ')} }`,\n );\n if (allAlreadyPresent) {\n return;\n }\n\n // No existing `from <module> import` line — prepend one. Ruff's import\n // sorter will place it in the right group on the next formatter pass.\n const specifiers = variableNames.join(', ');\n tree.write(filePath, `from ${from} import ${specifiers}\\n${beforeContents}`);\n};\n\n/**\n * Adds an `import <variableName> from '<from>'; statement to the beginning of the file,\n * if it doesn't already exist\n */\nexport const addSingleImport = async (\n tree: Tree,\n filePath: string,\n variableName: string,\n from: string,\n) => {\n assertFilePath(tree, filePath);\n\n // Check if default import already exists using GritQL\n const alreadyImported = await matchGritQL(\n tree,\n filePath,\n `\\`import ${variableName} from '${from}'\\``,\n );\n if (alreadyImported) {\n return;\n }\n\n // Prepend new import to file\n const contents = tree.read(filePath)!.toString();\n tree.write(filePath, `import ${variableName} from '${from}';\\n${contents}`);\n};\n\n/**\n * Adds an `export * from '<from>'; statement to the given TypeScript file.\n * Note that this will create the file if it does not exist in the tree.\n */\nexport const addStarExport = async (\n tree: Tree,\n filePath: string,\n from: string,\n) => {\n const contents = tree.read(filePath)?.toString() ?? '';\n\n // For empty/non-existent files, just write the export\n if (!contents.trim()) {\n tree.write(filePath, `export * from '${from}';\\n`);\n return;\n }\n\n // Check if already exported using GritQL\n const alreadyExported = await matchGritQL(\n tree,\n filePath,\n `\\`export * from '${from}'\\``,\n );\n if (alreadyExported) {\n return;\n }\n\n // Prepend new export to file\n tree.write(filePath, `export * from '${from}';\\n${contents}`);\n};\n\n/**\n * Return whether or not the given identifier is exported in the source file.\n * Checks for both `export { Identifier }` and `export type Identifier = ...`.\n */\nexport const hasExportDeclaration = async (\n tree: Tree,\n source: string,\n identifierName: string,\n): Promise<boolean> => {\n ensureGritDir(tree);\n const patterns = [\n `\\`export type ${identifierName} = $_\\``,\n `\\`export { ${identifierName} }\\``,\n `\\`export type { ${identifierName} } from $_\\``,\n ];\n\n for (const pattern of patterns) {\n try {\n const q = new QueryBuilder(`$p => $p where { $p <: ${pattern} }`);\n const result = await q.applyToFile({\n path: 'check.ts',\n content: source,\n });\n if (result !== null) return true;\n } catch {\n // Pattern didn't match, try next\n }\n }\n\n return false;\n};\n\n/**\n * Apply a GritQL pattern to a file in the Nx tree.\n */\nexport const applyGritQL = async (\n tree: Tree,\n filePath: string,\n pattern: string,\n): Promise<boolean> => {\n if (!tree.exists(filePath)) throw new Error(`No file at ${filePath}`);\n ensureGritDir(tree);\n const source = tree.read(filePath)!.toString();\n const query = new QueryBuilder(pattern);\n const result = await query.applyToFile({ path: filePath, content: source });\n if (result && result.content !== source) {\n tree.write(filePath, result.content);\n return true;\n }\n return false;\n};\n\n/**\n * Check whether a GritQL pattern matches anywhere in a file.\n * Returns true if the pattern matches at least once.\n *\n * Accepts raw GritQL, including patterns that start with a `language <name>`\n * header (e.g. `language python\\n\\`print($_)\\``) — the pattern is passed\n * straight through to QueryBuilder without any wrapping rewrite.\n */\nexport const matchGritQL = async (\n tree: Tree,\n filePath: string,\n pattern: string,\n): Promise<boolean> => {\n if (!tree.exists(filePath)) return false;\n ensureGritDir(tree);\n const source = tree.read(filePath)!.toString();\n let matched = false;\n try {\n const query = new QueryBuilder(pattern);\n query.filter(() => {\n matched = true;\n return true;\n });\n await query.applyToFile({ path: filePath, content: source });\n } catch {\n return false;\n }\n return matched;\n};\n\n/**\n * Capture the source text of the first match of a GritQL pattern.\n *\n * For example `` `dependencyCheck: $_` `` returns the whole\n * `dependencyCheck: { ... }` property text. Returns undefined if nothing\n * matches. The file is not modified.\n */\nexport const captureGritQL = async (\n tree: Tree,\n filePath: string,\n pattern: string,\n): Promise<string | undefined> => {\n if (!tree.exists(filePath)) return undefined;\n ensureGritDir(tree);\n const source = tree.read(filePath)!.toString();\n let captured: string | undefined;\n try {\n const query = new QueryBuilder(pattern);\n query.filter((node) => {\n captured ??= node.text();\n return true;\n });\n await query.applyToFile({ path: filePath, content: source });\n } catch {\n return undefined;\n }\n return captured;\n};\n\n/**\n * Return the text of every node matching the GritQL pattern, in document order.\n */\nexport const captureAllGritQL = async (\n tree: Tree,\n filePath: string,\n pattern: string,\n): Promise<string[]> => {\n if (!tree.exists(filePath)) return [];\n ensureGritDir(tree);\n const source = tree.read(filePath)!.toString();\n const captured: string[] = [];\n try {\n const query = new QueryBuilder(pattern);\n query.filter((node) => {\n captured.push(node.text());\n return true;\n });\n await query.applyToFile({ path: filePath, content: source });\n } catch {\n return [];\n }\n return captured;\n};\n\n/**\n * A unique token that is a valid identifier, so it can stand in for an array\n * element or object property inside a GritQL rewrite.\n */\nexport const GRIT_INSERT_PLACEHOLDER = '__GRIT_INSERT_PLACEHOLDER__';\n\n/**\n * Apply a GritQL rewrite that inserts {@link GRIT_INSERT_PLACEHOLDER}, then\n * replace the placeholder with `text`. Routing user-provided text through a\n * placeholder keeps it out of the GritQL pattern, where quotes, backticks or\n * `${...}` would otherwise break parsing.\n *\n * Any separator (e.g. a leading `, ` when appending to an array) must be part\n * of the GritQL pattern, not `text`. The one adjustment made here: if the\n * placeholder lands after a trailing line comment (`// ...`) — which would\n * comment out the text — the text is moved to its own line.\n *\n * The caller formats afterwards. Returns true if the pattern matched and the\n * file changed.\n */\nexport const insertViaGritQL = async (\n tree: Tree,\n filePath: string,\n pattern: string,\n text: string,\n): Promise<boolean> => {\n if (!(await applyGritQL(tree, filePath, pattern))) return false;\n const content = tree.read(filePath)!.toString();\n const at = content.indexOf(GRIT_INSERT_PLACEHOLDER);\n const lineSoFar = content.slice(content.lastIndexOf('\\n', at) + 1, at);\n const replacement = lineSoFar.includes('//') ? `\\n${text}` : text;\n\n // Function replacer so `$` in `text` isn't treated as a replacement pattern.\n tree.write(\n filePath,\n content.replace(GRIT_INSERT_PLACEHOLDER, () => replacement),\n );\n return true;\n};\n"],"names":["QueryBuilder","path","updateGitIgnore","GRIT_DIR","ensureGritDir","tree","process","env","GRIT_GLOBAL_DIR","join","root","patterns","assertFilePath","filePath","exists","Error","addDestructuredImport","variableNames","from","hasExistingImport","matchGritQL","variableName","localName","includes","split","applyGritQL","specifiers","contents","read","toString","newImport","startsWith","newlineIndex","indexOf","write","substring","addPythonDestructuredImport","beforeContents","moduleAlreadyImported","appended","allAlreadyPresent","map","n","addSingleImport","alreadyImported","addStarExport","trim","alreadyExported","hasExportDeclaration","source","identifierName","pattern","q","result","applyToFile","content","query","matched","filter","captureGritQL","undefined","captured","node","text","captureAllGritQL","push","GRIT_INSERT_PLACEHOLDER","insertViaGritQL","at","lineSoFar","slice","lastIndexOf","replacement","replace"],"mappings":"AAAA;;;CAGC,GAED,SAASA,YAAY,QAAQ,kBAAkB;AAE/C,YAAYC,UAAU,OAAO;AAC7B,SAASC,eAAe,QAAQ,WAAQ;AAExC,MAAMC,WAAW;AAEjB,8KAA8K;AAC9K,MAAMC,gBAAgB,CAACC;IACrBC,QAAQC,GAAG,CAACC,eAAe,KAAKP,KAAKQ,IAAI,CAACJ,KAAKK,IAAI,EAAEP;IACrDD,gBAAgBG,MAAM,KAAK,CAACM,WAAa;eAAIA;YAAUR;SAAS;AAClE;AAEA,MAAMS,iBAAiB,CAACP,MAAYQ;IAClC,IAAI,CAACR,KAAKS,MAAM,CAACD,WAAW;QAC1B,MAAM,IAAIE,MAAM,CAAC,mBAAmB,EAAEF,UAAU;IAClD;AACF;AAEA,OAAO,MAAMG,wBAAwB,OACnCX,MACAQ,UACAI,eACAC;IAEAN,eAAeP,MAAMQ;IAErB,uDAAuD;IACvD,MAAMM,oBAAoB,MAAMC,YAC9Bf,MACAQ,UACA,CAAC,sBAAsB,EAAEK,KAAK,GAAG,CAAC;IAGpC,IAAIC,mBAAmB;QACrB,6EAA6E;QAC7E,KAAK,MAAME,gBAAgBJ,cAAe;YACxC,MAAMK,YAAYD,aAAaE,QAAQ,CAAC,UACpCF,aAAaG,KAAK,CAAC,OAAO,CAAC,EAAE,GAC7BH;YACJ,kFAAkF;YAClF,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