@aws/nx-plugin 1.1.1 → 1.2.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.
Files changed (115) hide show
  1. package/README.md +30 -29
  2. package/generators.json +8 -0
  3. package/migrations.json +1 -1
  4. package/package.json +1 -1
  5. package/src/agentcore-harness/generator.d.ts +1 -1
  6. package/src/greengrass/component/common.d.ts +60 -0
  7. package/src/greengrass/component/common.js +191 -0
  8. package/src/greengrass/component/common.js.map +1 -0
  9. package/src/greengrass/component/dependencies.d.ts +101 -0
  10. package/src/greengrass/component/dependencies.js +37 -0
  11. package/src/greengrass/component/dependencies.js.map +1 -0
  12. package/src/greengrass/component/generator.d.ts +174 -0
  13. package/src/greengrass/component/generator.js +32 -0
  14. package/src/greengrass/component/generator.js.map +1 -0
  15. package/src/greengrass/component/metadata.d.ts +2 -0
  16. package/src/greengrass/component/metadata.js +14 -0
  17. package/src/greengrass/component/metadata.js.map +1 -0
  18. package/src/greengrass/component/python/__snapshots__/generator.spec.ts.snap +450 -0
  19. package/src/greengrass/component/python/files/component/main.py.template +60 -0
  20. package/src/greengrass/component/python/files/component/recipe.yaml.template +30 -0
  21. package/src/greengrass/component/python/files/gdk/gdk-config.json.template +13 -0
  22. package/src/greengrass/component/python/files/tests/test___componentSnakeCase__.py.template +37 -0
  23. package/src/greengrass/component/python/generator.d.ts +15 -0
  24. package/src/greengrass/component/python/generator.js +192 -0
  25. package/src/greengrass/component/python/generator.js.map +1 -0
  26. package/src/greengrass/component/schema.d.js +6 -0
  27. package/src/greengrass/component/schema.d.js.map +1 -0
  28. package/src/greengrass/component/schema.d.ts +18 -0
  29. package/src/greengrass/component/schema.json +82 -0
  30. package/src/greengrass/component/typescript/__snapshots__/generator.spec.ts.snap +275 -0
  31. package/src/greengrass/component/typescript/files/component/recipe.yaml.template +41 -0
  32. package/src/greengrass/component/typescript/files/entrypoint/main.ts.template +58 -0
  33. package/src/greengrass/component/typescript/files/gdk/gdk-config.json.template +13 -0
  34. package/src/greengrass/component/typescript/files/scripts/vendor-crt-addon.ts.template +115 -0
  35. package/src/greengrass/component/typescript/generator.d.ts +16 -0
  36. package/src/greengrass/component/typescript/generator.js +194 -0
  37. package/src/greengrass/component/typescript/generator.js.map +1 -0
  38. package/src/infra/app/generator.d.ts +1 -1
  39. package/src/init/generator.d.ts +1 -1
  40. package/src/internal/test-matrix/generator.js +42 -0
  41. package/src/internal/test-matrix/generator.js.map +1 -1
  42. package/src/license/dependency-check/pre-approved.js +2 -1
  43. package/src/license/dependency-check/pre-approved.js.map +1 -1
  44. package/src/open-api/py-client/generator.d.ts +1 -1
  45. package/src/preset/__snapshots__/generator.spec.ts.snap +2 -0
  46. package/src/preset/generator.d.ts +1 -1
  47. package/src/py/agent/a2a-connection/generator.d.ts +1 -1
  48. package/src/py/agent/gateway-connection/generator.d.ts +1 -1
  49. package/src/py/agent/mcp-connection/generator.d.ts +1 -1
  50. package/src/py/agent/react-connection/generator.d.ts +1 -1
  51. package/src/py/fast-api/react/generator.d.ts +1 -1
  52. package/src/py/project/generator.js +2 -0
  53. package/src/py/project/generator.js.map +1 -1
  54. package/src/sdk/greengrass.d.ts +6 -0
  55. package/src/sdk/greengrass.js +6 -0
  56. package/src/sdk/greengrass.js.map +1 -0
  57. package/src/smithy/project/generator.d.ts +1 -1
  58. package/src/smithy/react-connection/generator.d.ts +1 -1
  59. package/src/terraform/project/generator.d.ts +1 -1
  60. package/src/trpc/react/generator.d.ts +1 -1
  61. package/src/ts/agent/a2a-connection/generator.d.ts +1 -1
  62. package/src/ts/agent/gateway-connection/generator.d.ts +1 -1
  63. package/src/ts/agent/mcp-connection/generator.d.ts +1 -1
  64. package/src/ts/agent/react-connection/generator.d.ts +1 -1
  65. package/src/ts/astro-docs/generator.d.ts +1 -1
  66. package/src/ts/dcr-proxy/generator.d.ts +1 -1
  67. package/src/ts/dynamodb/generator.d.ts +1 -1
  68. package/src/ts/lambda-function/generator.d.ts +1 -1
  69. package/src/ts/lib/generator.d.ts +1 -1
  70. package/src/ts/nx-generator/generator.d.ts +1 -1
  71. package/src/ts/nx-migration/generator.d.ts +1 -1
  72. package/src/ts/nx-plugin/generator.d.ts +1 -1
  73. package/src/ts/rdb/generator.d.ts +1 -1
  74. package/src/ts/react-website/agui/generator.d.ts +1 -1
  75. package/src/utils/__snapshots__/shared-greengrass-scripts.spec.ts.snap +1279 -0
  76. package/src/utils/files/common/scripts/src/greengrass/build-artifact.ts.template +236 -0
  77. package/src/utils/files/common/scripts/src/greengrass/component-logs.ts.template +48 -0
  78. package/src/utils/files/common/scripts/src/greengrass/deploy-local.ts.template +497 -0
  79. package/src/utils/files/common/scripts/src/greengrass/recipe-utils.ts.template +356 -0
  80. package/src/utils/files/common/scripts/src/greengrass/zip-writer.ts.template +121 -0
  81. package/src/utils/files/terraform/src/core/runtime-config/read/read.tf.template +3 -3
  82. package/src/utils/files/terraform/src/metrics/metrics.tf.template +1 -1
  83. package/src/utils/greengrass/constants.d.ts +58 -0
  84. package/src/utils/greengrass/constants.js +63 -0
  85. package/src/utils/greengrass/constants.js.map +1 -0
  86. package/src/utils/greengrass/naming.d.ts +46 -0
  87. package/src/utils/greengrass/naming.js +67 -0
  88. package/src/utils/greengrass/naming.js.map +1 -0
  89. package/src/utils/greengrass/recipe.d.ts +143 -0
  90. package/src/utils/greengrass/recipe.js +119 -0
  91. package/src/utils/greengrass/recipe.js.map +1 -0
  92. package/src/utils/greengrass-constructs/files/cdk/app/greengrass-component/__componentDirName__.ts.template +42 -0
  93. package/src/utils/greengrass-constructs/files/cdk/core/greengrass/artifact-bucket.ts.template +82 -0
  94. package/src/utils/greengrass-constructs/files/cdk/core/greengrass/component-version.ts.template +370 -0
  95. package/src/utils/greengrass-constructs/files/cdk/core/greengrass/deployment.ts.template +276 -0
  96. package/src/utils/greengrass-constructs/files/cdk/core/greengrass/index.ts.template +5 -0
  97. package/src/utils/greengrass-constructs/files/cdk/core/greengrass/next-version.ts.template +119 -0
  98. package/src/utils/greengrass-constructs/files/cdk/core/greengrass/recipe.ts.template +90 -0
  99. package/src/utils/greengrass-constructs/files/next-version/__nextVersionFileName__.template +195 -0
  100. package/src/utils/greengrass-constructs/files/terraform/app/greengrass-component/__componentDirName__/__componentDirName__.tf.template +26 -0
  101. package/src/utils/greengrass-constructs/files/terraform/core/greengrass/artifact-bucket/main.tf.template +204 -0
  102. package/src/utils/greengrass-constructs/files/terraform/core/greengrass/component-version/main.tf.template +156 -0
  103. package/src/utils/greengrass-constructs/files/terraform/core/greengrass/deployment/main.tf.template +186 -0
  104. package/src/utils/greengrass-constructs/greengrass-constructs.d.ts +57 -0
  105. package/src/utils/greengrass-constructs/greengrass-constructs.js +154 -0
  106. package/src/utils/greengrass-constructs/greengrass-constructs.js.map +1 -0
  107. package/src/utils/nx.d.ts +15 -0
  108. package/src/utils/nx.js +32 -0
  109. package/src/utils/nx.js.map +1 -1
  110. package/src/utils/shared-greengrass-scripts.d.ts +21 -0
  111. package/src/utils/shared-greengrass-scripts.js +43 -0
  112. package/src/utils/shared-greengrass-scripts.js.map +1 -0
  113. package/src/utils/versions.d.ts +7 -0
  114. package/src/utils/versions.js +7 -0
  115. package/src/utils/versions.js.map +1 -1
package/README.md CHANGED
@@ -88,36 +88,37 @@ pnpm nx g @aws/nx-plugin:ts#infra
88
88
 
89
89
  ## Available Generators
90
90
 
91
- | Generator | Description |
92
- | -------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
93
- | `init` | Configure an existing Nx workspace to use the plugin |
94
- | `ts#project` | TypeScript library |
95
- | `ts#api` | TypeScript API (tRPC or Smithy) with API Gateway + Lambda + [Powertools](https://github.com/aws-powertools/powertools-lambda-typescript) |
96
- | `ts#rdb` | Relational databases with Aurora RDS |
97
- | `ts#dynamodb` | Type-safe DynamoDB single-table design (TypeScript, ElectroDB) |
98
- | `ts#website` | React app (Vite) |
99
- | `ts#website#auth` | Add Cognito auth to a website |
100
- | `ts#infra` | AWS CDK infrastructure project |
101
- | `ts#lambda-function` | TypeScript Lambda with type-safe event sources |
102
- | `ts#mcp-server` | MCP server (TypeScript) |
103
- | `ts#dcr-proxy` | OAuth DCR proxy construct for Cognito-authenticated MCP servers |
104
- | `ts#agent` | [Strands Agent](https://strandsagents.com/) (TypeScript) |
91
+ | Generator | Description |
92
+ | ---------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
93
+ | `init` | Configure an existing Nx workspace to use the plugin |
94
+ | `ts#project` | TypeScript library |
95
+ | `ts#api` | TypeScript API (tRPC or Smithy) with API Gateway + Lambda + [Powertools](https://github.com/aws-powertools/powertools-lambda-typescript) |
96
+ | `ts#rdb` | Relational databases with Aurora RDS |
97
+ | `ts#dynamodb` | Type-safe DynamoDB single-table design (TypeScript, ElectroDB) |
98
+ | `ts#website` | React app (Vite) |
99
+ | `ts#website#auth` | Add Cognito auth to a website |
100
+ | `ts#infra` | AWS CDK infrastructure project |
101
+ | `ts#lambda-function` | TypeScript Lambda with type-safe event sources |
102
+ | `ts#mcp-server` | MCP server (TypeScript) |
103
+ | `ts#dcr-proxy` | OAuth DCR proxy construct for Cognito-authenticated MCP servers |
104
+ | `ts#agent` | [Strands Agent](https://strandsagents.com/) (TypeScript) |
105
105
  | `ts#agent#guardrails` | Amazon Bedrock Guardrail for a TypeScript Agent (experimental) |
106
- | `ts#nx-generator` | Nx generator scaffold |
107
- | `ts#docs` | Documentation site (Astro + Starlight) |
108
- | `smithy#project` | Smithy model project — a service model, or a shape library shared between Smithy projects |
109
- | `py#project` | Python project (uv) |
110
- | `py#api` | Python API (FastAPI) with API Gateway + Lambda + [Powertools](https://github.com/aws-powertools/powertools-lambda-python) |
111
- | `py#rdb` | Relational databases with Aurora RDS (Python) |
112
- | `py#dynamodb` | Python DynamoDB project |
113
- | `py#lambda-function` | Python Lambda with type-safe event sources |
114
- | `py#mcp-server` | MCP server (Python) |
115
- | `py#agent` | [Strands Agent](https://strandsagents.com/) (Python) |
116
- | `agentcore-gateway` | [AgentCore Gateway](https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/gateway.html) project |
117
- | `agentcore-harness` | [AgentCore Harness](https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/harness.html) agent loop (experimental) |
118
- | `connection` | Connect projects together (e.g. frontend to API) |
119
- | `terraform#project` | Terraform project |
120
- | `license` | Manage LICENSE files and source headers |
106
+ | `ts#nx-generator` | Nx generator scaffold |
107
+ | `ts#docs` | Documentation site (Astro + Starlight) |
108
+ | `smithy#project` | Smithy model project — a service model, or a shape library shared between Smithy projects |
109
+ | `py#project` | Python project (uv) |
110
+ | `py#api` | Python API (FastAPI) with API Gateway + Lambda + [Powertools](https://github.com/aws-powertools/powertools-lambda-python) |
111
+ | `py#rdb` | Relational databases with Aurora RDS (Python) |
112
+ | `py#dynamodb` | Python DynamoDB project |
113
+ | `py#lambda-function` | Python Lambda with type-safe event sources |
114
+ | `py#mcp-server` | MCP server (Python) |
115
+ | `py#agent` | [Strands Agent](https://strandsagents.com/) (Python) |
116
+ | `agentcore-gateway` | [AgentCore Gateway](https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/gateway.html) project |
117
+ | `greengrass#component` | [AWS IoT Greengrass](https://docs.aws.amazon.com/greengrass/v2/developerguide/) v2 component for Python or TypeScript (experimental) |
118
+ | `agentcore-harness` | [AgentCore Harness](https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/harness.html) agent loop (experimental) |
119
+ | `connection` | Connect projects together (e.g. frontend to API) |
120
+ | `terraform#project` | Terraform project |
121
+ | `license` | Manage LICENSE files and source headers |
121
122
 
122
123
  ## Community
123
124
 
package/generators.json CHANGED
@@ -91,6 +91,14 @@
91
91
  "connection/react-agentcore-gateway"
92
92
  ]
93
93
  },
94
+ "greengrass#component": {
95
+ "factory": "./src/greengrass/component/generator",
96
+ "schema": "./src/greengrass/component/schema.json",
97
+ "description": "Add an AWS IoT Greengrass component to an existing Python or TypeScript project",
98
+ "metric": "g74",
99
+ "guidePages": ["greengrass-component"],
100
+ "experimental": true
101
+ },
94
102
  "license": {
95
103
  "factory": "./src/license/generator",
96
104
  "schema": "./src/license/schema.json",
package/migrations.json CHANGED
@@ -428,7 +428,7 @@
428
428
  "implementation": "./src/migrations/v1.0.9/0001-py-dynamodb-bind-base-model-meta/migration"
429
429
  },
430
430
  "sync-vended-versions": {
431
- "version": "1.1.1",
431
+ "version": "1.2.0",
432
432
  "description": "Sync vended dependency versions and the tracked plugin version to those vended by this release",
433
433
  "implementation": "./src/utils/version-upgrade-migration/migration"
434
434
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aws/nx-plugin",
3
- "version": "1.1.1",
3
+ "version": "1.2.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/awslabs/nx-plugin-for-aws.git",
@@ -40,7 +40,7 @@ export declare const DEPENDENCIES: import("../utils/declared-dependencies.js").D
40
40
  readonly name: "@types/node";
41
41
  } & {
42
42
  versionOnly: true;
43
- }], readonly import("../utils/declared-dependencies.js").DeclaredPyDependency<"ruff" | "a2a-sdk" | "ag-ui-langgraph" | "ag-ui-protocol" | "ag-ui-strands" | "aiosqlite" | "aws-lambda-powertools" | "aws-lambda-powertools[tracer]" | "aws-lambda-powertools[parser]" | "aws-opentelemetry-distro" | "bedrock-agentcore" | "boto3" | "checkov" | "fastapi" | "fastapi[standard]" | "httpx" | "langchain" | "langchain-aws" | "langchain-mcp-adapters" | "langgraph" | "langgraph-checkpoint-aws" | "langgraph-checkpoint-sqlite" | "mcp" | "pip-check-updates" | "pip-licenses" | "pydantic" | "strands-agents" | "strands-agents[a2a]" | "strands-agents-tools" | "ty" | "pynamodb" | "uvicorn" | "sqlmodel" | "alembic" | "aiomysql" | "asyncpg" | "greenlet", AgentCoreHarnessMetadata>[]>;
43
+ }], readonly import("../utils/declared-dependencies.js").DeclaredPyDependency<"ruff" | "a2a-sdk" | "ag-ui-langgraph" | "ag-ui-protocol" | "ag-ui-strands" | "aiosqlite" | "aws-lambda-powertools" | "aws-lambda-powertools[tracer]" | "aws-lambda-powertools[parser]" | "aws-opentelemetry-distro" | "awsiotsdk" | "bedrock-agentcore" | "boto3" | "checkov" | "fastapi" | "fastapi[standard]" | "httpx" | "langchain" | "langchain-aws" | "langchain-mcp-adapters" | "langgraph" | "langgraph-checkpoint-aws" | "langgraph-checkpoint-sqlite" | "mcp" | "pip-check-updates" | "pip-licenses" | "pydantic" | "strands-agents" | "strands-agents[a2a]" | "strands-agents-tools" | "ty" | "pynamodb" | "uvicorn" | "sqlmodel" | "alembic" | "aiomysql" | "asyncpg" | "greenlet", AgentCoreHarnessMetadata>[]>;
44
44
  export declare const AGENTCORE_HARNESS_GENERATOR_INFO: NxGeneratorInfo;
45
45
  export declare const agentcoreHarnessGenerator: (tree: Tree, options: AgentcoreHarnessGeneratorSchema) => Promise<GeneratorCallback>;
46
46
  /**
@@ -0,0 +1,60 @@
1
+ /**
2
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+ import { type GeneratorCallback, type ProjectConfiguration, type Tree } from '@nx/devkit';
6
+ import { type DependencyDeclaration, type MustDeclare } from '../../utils/declared-dependencies.js';
7
+ import { type GreengrassPlatformSelection, resolvePlatforms } from '../../utils/greengrass/constants.js';
8
+ import { type GREENGRASS_CONSTRUCTS_DEPENDENCIES } from '../../utils/greengrass-constructs/greengrass-constructs.js';
9
+ import { type SHARED_CONSTRUCTS_DEPENDENCIES } from '../../utils/shared-constructs.js';
10
+ import type { GreengrassComponentMetadata } from './generator.js';
11
+ import type { GreengrassComponentGeneratorSchema } from './schema.js';
12
+ export type Language = NonNullable<GreengrassComponentGeneratorSchema['language']>;
13
+ export interface NormalizedComponent {
14
+ readonly options: GreengrassComponentGeneratorSchema;
15
+ readonly language: Language;
16
+ readonly project: ProjectConfiguration;
17
+ readonly componentDirName: string;
18
+ readonly componentName: string;
19
+ readonly componentVersion: string;
20
+ readonly publisher: string;
21
+ readonly ipc: boolean;
22
+ readonly gdkConfig: boolean;
23
+ readonly platform: GreengrassPlatformSelection;
24
+ readonly platforms: ReturnType<typeof resolvePlatforms>;
25
+ readonly infra: 'component-version' | 'none';
26
+ readonly iac?: 'cdk' | 'terraform';
27
+ readonly existingMetadata?: GreengrassComponentMetadata;
28
+ }
29
+ export declare const GREENGRASS_SCRIPTS_DIR: string;
30
+ export declare const sharedComponentTargets: ({ artifactTarget, componentDirName, componentName, distDir, }: {
31
+ readonly artifactTarget: string;
32
+ readonly componentDirName: string;
33
+ readonly componentName: string;
34
+ readonly distDir: string;
35
+ }) => {
36
+ [x: string]: {
37
+ executor: string;
38
+ dependsOn: string[];
39
+ options: {
40
+ command: string;
41
+ };
42
+ } | {
43
+ executor: string;
44
+ continuous: boolean;
45
+ options: {
46
+ command: string;
47
+ };
48
+ };
49
+ };
50
+ export declare const normalizeComponent: (tree: Tree, options: GreengrassComponentGeneratorSchema) => Promise<NormalizedComponent>;
51
+ export declare const assertUnchangedPlatform: (component: NormalizedComponent, manifestPreview: string) => void;
52
+ /**
53
+ * The shared tail every language adapter owes after it writes its
54
+ * language-specific templates and targets: record/update metadata (language
55
+ * always persisted, so a later rerun can refuse a language change under the
56
+ * same identity), provision the optional shared/app infrastructure, install the
57
+ * language's applicable dependencies, emit metrics and format. Called once,
58
+ * from each adapter, rather than duplicated in both.
59
+ */
60
+ export declare const finalizeComponent: <const D extends DependencyDeclaration>(tree: Tree, component: NormalizedComponent, entrypoint: string, dependencies: D & MustDeclare<typeof SHARED_CONSTRUCTS_DEPENDENCIES, D> & MustDeclare<typeof GREENGRASS_CONSTRUCTS_DEPENDENCIES, D>) => Promise<GeneratorCallback>;
@@ -0,0 +1,191 @@
1
+ /**
2
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */ import { joinPathFragments } from "@nx/devkit";
5
+ import { addPyDependencies, addTsDependencies } from "../../utils/add-dependencies.js";
6
+ import { forDependencies } from "../../utils/declared-dependencies.js";
7
+ import { formatFilesInSubtree } from "../../utils/format.js";
8
+ import { resolvePlatforms } from "../../utils/greengrass/constants.js";
9
+ import { assertValidComponentName, buildDefaultComponentName, MAX_CDK_COMPONENT_NAME_LENGTH } from "../../utils/greengrass/naming.js";
10
+ import { isValidComponentVersion } from "../../utils/greengrass/recipe.js";
11
+ import { addGreengrassComponentAppConstruct } from "../../utils/greengrass-constructs/greengrass-constructs.js";
12
+ import { resolveIac } from "../../utils/iac.js";
13
+ import { installDependencies } from "../../utils/install.js";
14
+ import { addGeneratorMetricsIfApplicable } from "../../utils/metrics.js";
15
+ import { toClassName, toKebabCase } from "../../utils/names.js";
16
+ import { getNpmScope } from "../../utils/npm-scope.js";
17
+ import { addComponentGeneratorMetadata, normalizeTargetKeyOrder, readProjectConfigurationUnqualified, updateComponentGeneratorMetadata } from "../../utils/nx.js";
18
+ import { sharedConstructsGenerator } from "../../utils/shared-constructs.js";
19
+ import { PACKAGES_DIR, SHARED_SCRIPTS_DIR } from "../../utils/shared-constructs-constants.js";
20
+ import { GREENGRASS_COMPONENT_GENERATOR_INFO } from "./metadata.js";
21
+ export const GREENGRASS_SCRIPTS_DIR = joinPathFragments(PACKAGES_DIR, SHARED_SCRIPTS_DIR, 'src', 'greengrass');
22
+ export const sharedComponentTargets = ({ artifactTarget, componentDirName, componentName, distDir })=>({
23
+ [`${componentDirName}-deploy-local`]: normalizeTargetKeyOrder({
24
+ executor: 'nx:run-commands',
25
+ dependsOn: [
26
+ artifactTarget
27
+ ],
28
+ options: {
29
+ command: `tsx ${GREENGRASS_SCRIPTS_DIR}/deploy-local.ts ${distDir}`
30
+ }
31
+ }),
32
+ [`${componentDirName}-logs`]: normalizeTargetKeyOrder({
33
+ executor: 'nx:run-commands',
34
+ continuous: true,
35
+ options: {
36
+ command: `tsx ${GREENGRASS_SCRIPTS_DIR}/component-logs.ts ${componentName}`
37
+ }
38
+ })
39
+ });
40
+ export const normalizeComponent = async (tree, options)=>{
41
+ const project = readProjectConfigurationUnqualified(tree, options.project);
42
+ const hasTypeScript = tree.exists(joinPathFragments(project.root, 'tsconfig.json'));
43
+ const hasPython = tree.exists(joinPathFragments(project.root, 'pyproject.toml'));
44
+ if (!hasTypeScript && !hasPython) {
45
+ throw new Error(`Greengrass components require a supported host project. "${options.project}" has neither tsconfig.json nor pyproject.toml.`);
46
+ }
47
+ let language;
48
+ if (!options.language) {
49
+ if (hasTypeScript && hasPython) {
50
+ throw new Error(`The project "${options.project}" has both tsconfig.json and pyproject.toml. Pass --language=typescript or --language=python.`);
51
+ }
52
+ language = hasTypeScript ? 'typescript' : 'python';
53
+ } else {
54
+ language = options.language;
55
+ if (language === 'typescript' && !hasTypeScript) {
56
+ throw new Error(`--language=typescript requires tsconfig.json in "${options.project}".`);
57
+ }
58
+ if (language === 'python' && !hasPython) {
59
+ throw new Error(`--language=python requires pyproject.toml in "${options.project}".`);
60
+ }
61
+ }
62
+ if (language === 'typescript' && !project.sourceRoot) {
63
+ throw new Error('This project does not have a source root. Please add a source root to the project configuration before running this generator.');
64
+ }
65
+ const components = project.metadata?.components ?? [];
66
+ const componentDirName = toKebabCase(options.name);
67
+ const existingMetadata = components.find((component)=>component.generator === GREENGRASS_COMPONENT_GENERATOR_INFO.id && component.name === componentDirName);
68
+ if (existingMetadata?.language && existingMetadata.language !== language) {
69
+ throw new Error(`The Greengrass component "${componentDirName}" already uses ${existingMetadata.language}. A component cannot change language under the same name.`);
70
+ }
71
+ const componentName = options.componentName ?? buildDefaultComponentName(tree, options.name);
72
+ assertValidComponentName(componentName);
73
+ const componentVersion = options.componentVersion ?? '1.0.0';
74
+ if (!isValidComponentVersion(componentVersion)) {
75
+ throw new Error(`ComponentVersion "${componentVersion}" must be a valid semantic version (eg. "1.0.0") or one of NEXT_PATCH, NEXT_MINOR, NEXT_MAJOR.`);
76
+ }
77
+ const infra = options.infra ?? 'component-version';
78
+ if (existingMetadata?.iac && infra === 'none') {
79
+ throw new Error(`This project already has a Greengrass component named "${componentDirName}" with infrastructure provisioned (iac=${existingMetadata.iac}). Re-running with --infra=none would leave that infrastructure orphaned - remove it manually first, or keep --infra=component-version.`);
80
+ }
81
+ const iac = infra === 'none' ? undefined : await resolveIac(tree, options.iac ?? 'inherit');
82
+ if (iac === 'cdk' && componentName.length > MAX_CDK_COMPONENT_NAME_LENGTH) {
83
+ throw new Error(`ComponentName "${componentName}" is ${componentName.length} characters long, exceeding the ${MAX_CDK_COMPONENT_NAME_LENGTH}-character limit for CDK Greengrass component artifacts. Shorten --componentName to ${MAX_CDK_COMPONENT_NAME_LENGTH} characters or fewer.`);
84
+ }
85
+ if (iac === 'terraform' && componentVersion.startsWith('NEXT_')) {
86
+ throw new Error('Terraform Greengrass components require an explicit semantic version. Set --componentVersion to a value such as 1.0.0; NEXT_* versions are supported with CDK infrastructure.');
87
+ }
88
+ const platform = options.platform ?? 'linux-arm64';
89
+ return {
90
+ options,
91
+ language,
92
+ project,
93
+ componentDirName,
94
+ componentName,
95
+ componentVersion,
96
+ publisher: options.publisher ?? getNpmScope(tree) ?? 'monorepo',
97
+ ipc: options.ipc ?? false,
98
+ gdkConfig: options.gdkConfig ?? false,
99
+ platform,
100
+ platforms: resolvePlatforms(platform),
101
+ infra,
102
+ iac,
103
+ existingMetadata
104
+ };
105
+ };
106
+ export const assertUnchangedPlatform = (component, manifestPreview)=>{
107
+ const existingPlatform = component.existingMetadata?.platform;
108
+ if (!existingPlatform || existingPlatform === component.platform) {
109
+ return;
110
+ }
111
+ throw new Error(`This project already has a Greengrass component named "${component.componentDirName}" generated for platform "${existingPlatform}". recipe.yaml is user-owned and is never rewritten, so this run cannot change it to "${component.platform}" - the targets would then build artifacts the recipe does not declare. If you did not mean to change the platform, re-run with --platform=${existingPlatform} (this option has a default, so leaving it off asks for "${component.platform}"). To change it on purpose, edit ${joinPathFragments(component.project.root, 'greengrass', component.componentDirName, 'recipe.yaml')} by hand so its Manifests match, bump ComponentVersion (published versions are immutable), and set platform to "${component.platform}" in this project's project.json metadata.components entry. The manifests "${component.platform}" expects are:\n${manifestPreview}`);
112
+ };
113
+ /**
114
+ * The shared tail every language adapter owes after it writes its
115
+ * language-specific templates and targets: record/update metadata (language
116
+ * always persisted, so a later rerun can refuse a language change under the
117
+ * same identity), provision the optional shared/app infrastructure, install the
118
+ * language's applicable dependencies, emit metrics and format. Called once,
119
+ * from each adapter, rather than duplicated in both.
120
+ */ export const finalizeComponent = async (tree, component, entrypoint, dependencies)=>{
121
+ const metadata = {
122
+ language: component.language,
123
+ componentName: component.componentName,
124
+ componentVersion: component.componentVersion,
125
+ platform: component.platform,
126
+ ipc: component.ipc,
127
+ gdkConfig: component.gdkConfig,
128
+ ...component.iac ? {
129
+ iac: component.iac
130
+ } : {}
131
+ };
132
+ addComponentGeneratorMetadata(tree, component.project.name, GREENGRASS_COMPONENT_GENERATOR_INFO, entrypoint, component.componentDirName, metadata);
133
+ // An escalation from `--infra none` already has an entry, which the add above
134
+ // leaves as it is - including its missing `iac`. Record the resolved one, or
135
+ // the orphan guard would not see the infrastructure this run provisions and a
136
+ // later `--infra none` would silently orphan it.
137
+ if (component.iac || component.existingMetadata) {
138
+ updateComponentGeneratorMetadata(tree, component.project.name, GREENGRASS_COMPONENT_GENERATOR_INFO, component.componentDirName, {
139
+ language: component.language,
140
+ gdkConfig: component.gdkConfig,
141
+ ...component.iac ? {
142
+ iac: component.iac
143
+ } : {}
144
+ });
145
+ }
146
+ if (component.infra !== 'none') {
147
+ // Each helper below is itself generic over the caller's declaration and
148
+ // re-checks MustDeclare against its own constant; `dependencies`'s type
149
+ // here already proves both to the *outer* MustDeclare intersection above,
150
+ // so this narrows to what each helper asks for, same as those helpers'
151
+ // own internal forwarding.
152
+ await sharedConstructsGenerator(tree, {
153
+ iac: component.iac
154
+ }, forDependencies(dependencies));
155
+ await addGreengrassComponentAppConstruct(tree, {
156
+ iac: component.iac,
157
+ componentNameClassName: toClassName(component.options.name),
158
+ componentDisplayName: component.componentName,
159
+ componentDirName: component.componentDirName,
160
+ project: component.project.name,
161
+ hostProjectName: component.project.name,
162
+ recipesDirFromRoot: `dist/${component.project.root}/greengrass/${component.componentDirName}/greengrass-build/recipes`,
163
+ artifactsDirFromRoot: `dist/${component.project.root}/greengrass/${component.componentDirName}/greengrass-build/artifacts`
164
+ }, forDependencies(dependencies));
165
+ }
166
+ if (component.language === 'python') {
167
+ addPyDependencies(tree, dependencies, {
168
+ metadata,
169
+ projectRoot: component.project.root
170
+ });
171
+ } else {
172
+ addTsDependencies(tree, dependencies, {
173
+ metadata,
174
+ projectRoot: component.project.root
175
+ });
176
+ }
177
+ await addGeneratorMetricsIfApplicable(tree, [
178
+ GREENGRASS_COMPONENT_GENERATOR_INFO
179
+ ]);
180
+ await formatFilesInSubtree(tree);
181
+ return ()=>installDependencies(tree, component.options.preferInstallDependencies, {
182
+ languages: component.language === 'python' ? [
183
+ 'typescript',
184
+ 'python'
185
+ ] : [
186
+ 'typescript'
187
+ ]
188
+ });
189
+ };
190
+
191
+ //# sourceMappingURL=common.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../packages/nx-plugin/src/greengrass/component/common.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport {\n type GeneratorCallback,\n joinPathFragments,\n type ProjectConfiguration,\n type Tree,\n} from '@nx/devkit';\nimport {\n addPyDependencies,\n addTsDependencies,\n} from '../../utils/add-dependencies.js';\nimport {\n type DependencyDeclaration,\n forDependencies,\n type MustDeclare,\n} from '../../utils/declared-dependencies.js';\nimport { formatFilesInSubtree } from '../../utils/format.js';\nimport {\n type GreengrassPlatformSelection,\n resolvePlatforms,\n} from '../../utils/greengrass/constants.js';\nimport {\n assertValidComponentName,\n buildDefaultComponentName,\n MAX_CDK_COMPONENT_NAME_LENGTH,\n} from '../../utils/greengrass/naming.js';\nimport { isValidComponentVersion } from '../../utils/greengrass/recipe.js';\nimport {\n addGreengrassComponentAppConstruct,\n type GREENGRASS_CONSTRUCTS_DEPENDENCIES,\n} from '../../utils/greengrass-constructs/greengrass-constructs.js';\nimport { resolveIac } from '../../utils/iac.js';\nimport { installDependencies } from '../../utils/install.js';\nimport { addGeneratorMetricsIfApplicable } from '../../utils/metrics.js';\nimport { toClassName, toKebabCase } from '../../utils/names.js';\nimport { getNpmScope } from '../../utils/npm-scope.js';\nimport {\n addComponentGeneratorMetadata,\n normalizeTargetKeyOrder,\n readProjectConfigurationUnqualified,\n updateComponentGeneratorMetadata,\n} from '../../utils/nx.js';\nimport {\n type SHARED_CONSTRUCTS_DEPENDENCIES,\n sharedConstructsGenerator,\n} from '../../utils/shared-constructs.js';\nimport {\n PACKAGES_DIR,\n SHARED_SCRIPTS_DIR,\n} from '../../utils/shared-constructs-constants.js';\nimport type { GreengrassComponentMetadata } from './generator.js';\nimport { GREENGRASS_COMPONENT_GENERATOR_INFO } from './metadata.js';\nimport type { GreengrassComponentGeneratorSchema } from './schema.js';\n\nexport type Language = NonNullable<\n GreengrassComponentGeneratorSchema['language']\n>;\n\nexport interface NormalizedComponent {\n readonly options: GreengrassComponentGeneratorSchema;\n readonly language: Language;\n readonly project: ProjectConfiguration;\n readonly componentDirName: string;\n readonly componentName: string;\n readonly componentVersion: string;\n readonly publisher: string;\n readonly ipc: boolean;\n readonly gdkConfig: boolean;\n readonly platform: GreengrassPlatformSelection;\n readonly platforms: ReturnType<typeof resolvePlatforms>;\n readonly infra: 'component-version' | 'none';\n readonly iac?: 'cdk' | 'terraform';\n readonly existingMetadata?: GreengrassComponentMetadata;\n}\n\nexport const GREENGRASS_SCRIPTS_DIR = joinPathFragments(\n PACKAGES_DIR,\n SHARED_SCRIPTS_DIR,\n 'src',\n 'greengrass',\n);\n\nexport const sharedComponentTargets = ({\n artifactTarget,\n componentDirName,\n componentName,\n distDir,\n}: {\n readonly artifactTarget: string;\n readonly componentDirName: string;\n readonly componentName: string;\n readonly distDir: string;\n}) => ({\n [`${componentDirName}-deploy-local`]: normalizeTargetKeyOrder({\n executor: 'nx:run-commands',\n dependsOn: [artifactTarget],\n options: {\n command: `tsx ${GREENGRASS_SCRIPTS_DIR}/deploy-local.ts ${distDir}`,\n },\n }),\n [`${componentDirName}-logs`]: normalizeTargetKeyOrder({\n executor: 'nx:run-commands',\n continuous: true,\n options: {\n command: `tsx ${GREENGRASS_SCRIPTS_DIR}/component-logs.ts ${componentName}`,\n },\n }),\n});\n\nexport const normalizeComponent = async (\n tree: Tree,\n options: GreengrassComponentGeneratorSchema,\n): Promise<NormalizedComponent> => {\n const project = readProjectConfigurationUnqualified(tree, options.project);\n const hasTypeScript = tree.exists(\n joinPathFragments(project.root, 'tsconfig.json'),\n );\n const hasPython = tree.exists(\n joinPathFragments(project.root, 'pyproject.toml'),\n );\n if (!hasTypeScript && !hasPython) {\n throw new Error(\n `Greengrass components require a supported host project. \"${options.project}\" has neither tsconfig.json nor pyproject.toml.`,\n );\n }\n let language: Language;\n if (!options.language) {\n if (hasTypeScript && hasPython) {\n throw new Error(\n `The project \"${options.project}\" has both tsconfig.json and pyproject.toml. Pass --language=typescript or --language=python.`,\n );\n }\n language = hasTypeScript ? 'typescript' : 'python';\n } else {\n language = options.language;\n if (language === 'typescript' && !hasTypeScript) {\n throw new Error(\n `--language=typescript requires tsconfig.json in \"${options.project}\".`,\n );\n }\n if (language === 'python' && !hasPython) {\n throw new Error(\n `--language=python requires pyproject.toml in \"${options.project}\".`,\n );\n }\n }\n if (language === 'typescript' && !project.sourceRoot) {\n throw new Error(\n 'This project does not have a source root. Please add a source root to the project configuration before running this generator.',\n );\n }\n const components =\n (\n project.metadata as {\n components?: (GreengrassComponentMetadata & {\n generator?: string;\n name?: string;\n })[];\n }\n )?.components ?? [];\n const componentDirName = toKebabCase(options.name);\n const existingMetadata = components.find(\n (component) =>\n component.generator === GREENGRASS_COMPONENT_GENERATOR_INFO.id &&\n component.name === componentDirName,\n );\n if (existingMetadata?.language && existingMetadata.language !== language) {\n throw new Error(\n `The Greengrass component \"${componentDirName}\" already uses ${existingMetadata.language}. A component cannot change language under the same name.`,\n );\n }\n const componentName =\n options.componentName ?? buildDefaultComponentName(tree, options.name);\n assertValidComponentName(componentName);\n const componentVersion = options.componentVersion ?? '1.0.0';\n if (!isValidComponentVersion(componentVersion)) {\n throw new Error(\n `ComponentVersion \"${componentVersion}\" must be a valid semantic version (eg. \"1.0.0\") or one of NEXT_PATCH, NEXT_MINOR, NEXT_MAJOR.`,\n );\n }\n const infra = options.infra ?? 'component-version';\n if (existingMetadata?.iac && infra === 'none') {\n throw new Error(\n `This project already has a Greengrass component named \"${componentDirName}\" with infrastructure provisioned (iac=${existingMetadata.iac}). Re-running with --infra=none would leave that infrastructure orphaned - remove it manually first, or keep --infra=component-version.`,\n );\n }\n const iac =\n infra === 'none'\n ? undefined\n : ((await resolveIac(tree, options.iac ?? 'inherit')) as\n | 'cdk'\n | 'terraform');\n if (iac === 'cdk' && componentName.length > MAX_CDK_COMPONENT_NAME_LENGTH) {\n throw new Error(\n `ComponentName \"${componentName}\" is ${componentName.length} characters long, exceeding the ${MAX_CDK_COMPONENT_NAME_LENGTH}-character limit for CDK Greengrass component artifacts. Shorten --componentName to ${MAX_CDK_COMPONENT_NAME_LENGTH} characters or fewer.`,\n );\n }\n if (iac === 'terraform' && componentVersion.startsWith('NEXT_')) {\n throw new Error(\n 'Terraform Greengrass components require an explicit semantic version. Set --componentVersion to a value such as 1.0.0; NEXT_* versions are supported with CDK infrastructure.',\n );\n }\n const platform = options.platform ?? 'linux-arm64';\n return {\n options,\n language,\n project,\n componentDirName,\n componentName,\n componentVersion,\n publisher: options.publisher ?? getNpmScope(tree) ?? 'monorepo',\n ipc: options.ipc ?? false,\n gdkConfig: options.gdkConfig ?? false,\n platform,\n platforms: resolvePlatforms(platform),\n infra,\n iac,\n existingMetadata,\n };\n};\n\nexport const assertUnchangedPlatform = (\n component: NormalizedComponent,\n manifestPreview: string,\n): void => {\n const existingPlatform = component.existingMetadata?.platform;\n if (!existingPlatform || existingPlatform === component.platform) {\n return;\n }\n throw new Error(\n `This project already has a Greengrass component named \"${component.componentDirName}\" generated for platform \"${existingPlatform}\". recipe.yaml is user-owned and is never rewritten, so this run cannot change it to \"${component.platform}\" - the targets would then build artifacts the recipe does not declare. If you did not mean to change the platform, re-run with --platform=${existingPlatform} (this option has a default, so leaving it off asks for \"${component.platform}\"). To change it on purpose, edit ${joinPathFragments(component.project.root, 'greengrass', component.componentDirName, 'recipe.yaml')} by hand so its Manifests match, bump ComponentVersion (published versions are immutable), and set platform to \"${component.platform}\" in this project's project.json metadata.components entry. The manifests \"${component.platform}\" expects are:\\n${manifestPreview}`,\n );\n};\n\n/**\n * The shared tail every language adapter owes after it writes its\n * language-specific templates and targets: record/update metadata (language\n * always persisted, so a later rerun can refuse a language change under the\n * same identity), provision the optional shared/app infrastructure, install the\n * language's applicable dependencies, emit metrics and format. Called once,\n * from each adapter, rather than duplicated in both.\n */\nexport const finalizeComponent = async <const D extends DependencyDeclaration>(\n tree: Tree,\n component: NormalizedComponent,\n entrypoint: string,\n dependencies: D &\n MustDeclare<typeof SHARED_CONSTRUCTS_DEPENDENCIES, D> &\n MustDeclare<typeof GREENGRASS_CONSTRUCTS_DEPENDENCIES, D>,\n): Promise<GeneratorCallback> => {\n const metadata: GreengrassComponentMetadata = {\n language: component.language,\n componentName: component.componentName,\n componentVersion: component.componentVersion,\n platform: component.platform,\n ipc: component.ipc,\n gdkConfig: component.gdkConfig,\n ...(component.iac ? { iac: component.iac } : {}),\n };\n addComponentGeneratorMetadata(\n tree,\n component.project.name,\n GREENGRASS_COMPONENT_GENERATOR_INFO,\n entrypoint,\n component.componentDirName,\n metadata,\n );\n // An escalation from `--infra none` already has an entry, which the add above\n // leaves as it is - including its missing `iac`. Record the resolved one, or\n // the orphan guard would not see the infrastructure this run provisions and a\n // later `--infra none` would silently orphan it.\n if (component.iac || component.existingMetadata) {\n updateComponentGeneratorMetadata(\n tree,\n component.project.name,\n GREENGRASS_COMPONENT_GENERATOR_INFO,\n component.componentDirName,\n {\n language: component.language,\n gdkConfig: component.gdkConfig,\n ...(component.iac ? { iac: component.iac } : {}),\n },\n );\n }\n if (component.infra !== 'none') {\n // Each helper below is itself generic over the caller's declaration and\n // re-checks MustDeclare against its own constant; `dependencies`'s type\n // here already proves both to the *outer* MustDeclare intersection above,\n // so this narrows to what each helper asks for, same as those helpers'\n // own internal forwarding.\n await sharedConstructsGenerator(\n tree,\n { iac: component.iac! },\n forDependencies<typeof SHARED_CONSTRUCTS_DEPENDENCIES>(dependencies),\n );\n await addGreengrassComponentAppConstruct(\n tree,\n {\n iac: component.iac!,\n componentNameClassName: toClassName(component.options.name),\n componentDisplayName: component.componentName,\n componentDirName: component.componentDirName,\n project: component.project.name,\n hostProjectName: component.project.name,\n recipesDirFromRoot: `dist/${component.project.root}/greengrass/${component.componentDirName}/greengrass-build/recipes`,\n artifactsDirFromRoot: `dist/${component.project.root}/greengrass/${component.componentDirName}/greengrass-build/artifacts`,\n },\n forDependencies<typeof GREENGRASS_CONSTRUCTS_DEPENDENCIES>(dependencies),\n );\n }\n if (component.language === 'python') {\n addPyDependencies(tree, dependencies, {\n metadata,\n projectRoot: component.project.root,\n });\n } else {\n addTsDependencies(tree, dependencies, {\n metadata,\n projectRoot: component.project.root,\n });\n }\n await addGeneratorMetricsIfApplicable(tree, [\n GREENGRASS_COMPONENT_GENERATOR_INFO,\n ]);\n await formatFilesInSubtree(tree);\n\n return () =>\n installDependencies(tree, component.options.preferInstallDependencies, {\n languages:\n component.language === 'python'\n ? ['typescript', 'python']\n : ['typescript'],\n });\n};\n"],"names":["joinPathFragments","addPyDependencies","addTsDependencies","forDependencies","formatFilesInSubtree","resolvePlatforms","assertValidComponentName","buildDefaultComponentName","MAX_CDK_COMPONENT_NAME_LENGTH","isValidComponentVersion","addGreengrassComponentAppConstruct","resolveIac","installDependencies","addGeneratorMetricsIfApplicable","toClassName","toKebabCase","getNpmScope","addComponentGeneratorMetadata","normalizeTargetKeyOrder","readProjectConfigurationUnqualified","updateComponentGeneratorMetadata","sharedConstructsGenerator","PACKAGES_DIR","SHARED_SCRIPTS_DIR","GREENGRASS_COMPONENT_GENERATOR_INFO","GREENGRASS_SCRIPTS_DIR","sharedComponentTargets","artifactTarget","componentDirName","componentName","distDir","executor","dependsOn","options","command","continuous","normalizeComponent","tree","project","hasTypeScript","exists","root","hasPython","Error","language","sourceRoot","components","metadata","name","existingMetadata","find","component","generator","id","componentVersion","infra","iac","undefined","length","startsWith","platform","publisher","ipc","gdkConfig","platforms","assertUnchangedPlatform","manifestPreview","existingPlatform","finalizeComponent","entrypoint","dependencies","componentNameClassName","componentDisplayName","hostProjectName","recipesDirFromRoot","artifactsDirFromRoot","projectRoot","preferInstallDependencies","languages"],"mappings":"AAAA;;;CAGC,GACD,SAEEA,iBAAiB,QAGZ,aAAa;AACpB,SACEC,iBAAiB,EACjBC,iBAAiB,QACZ,kCAAkC;AACzC,SAEEC,eAAe,QAEV,uCAAuC;AAC9C,SAASC,oBAAoB,QAAQ,wBAAwB;AAC7D,SAEEC,gBAAgB,QACX,sCAAsC;AAC7C,SACEC,wBAAwB,EACxBC,yBAAyB,EACzBC,6BAA6B,QACxB,mCAAmC;AAC1C,SAASC,uBAAuB,QAAQ,mCAAmC;AAC3E,SACEC,kCAAkC,QAE7B,6DAA6D;AACpE,SAASC,UAAU,QAAQ,qBAAqB;AAChD,SAASC,mBAAmB,QAAQ,yBAAyB;AAC7D,SAASC,+BAA+B,QAAQ,yBAAyB;AACzE,SAASC,WAAW,EAAEC,WAAW,QAAQ,uBAAuB;AAChE,SAASC,WAAW,QAAQ,2BAA2B;AACvD,SACEC,6BAA6B,EAC7BC,uBAAuB,EACvBC,mCAAmC,EACnCC,gCAAgC,QAC3B,oBAAoB;AAC3B,SAEEC,yBAAyB,QACpB,mCAAmC;AAC1C,SACEC,YAAY,EACZC,kBAAkB,QACb,6CAA6C;AAEpD,SAASC,mCAAmC,QAAQ,gBAAgB;AAwBpE,OAAO,MAAMC,yBAAyBzB,kBACp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B,CAAC,yBAAyB,CAAC;YACtH+C,sBAAsB,CAAC,KAAK,EAAExB,UAAUb,OAAO,CAACG,IAAI,CAAC,YAAY,EAAEU,UAAUvB,gBAAgB,CAAC,2BAA2B,CAAC;QAC5H,GACAzB,gBAA2DmE;IAE/D;IACA,IAAInB,UAAUP,QAAQ,KAAK,UAAU;QACnC3C,kBAAkBoC,MAAMiC,cAAc;YACpCvB;YACA6B,aAAazB,UAAUb,OAAO,CAACG,IAAI;QACrC;IACF,OAAO;QACLvC,kBAAkBmC,MAAMiC,cAAc;YACpCvB;YACA6B,aAAazB,UAAUb,OAAO,CAACG,IAAI;QACrC;IACF;IACA,MAAM5B,gCAAgCwB,MAAM;QAC1Cb;KACD;IACD,MAAMpB,qBAAqBiC;IAE3B,OAAO,IACLzB,oBAAoByB,MAAMc,UAAUlB,OAAO,CAAC4C,yBAAyB,EAAE;YACrEC,WACE3B,UAAUP,QAAQ,KAAK,WACnB;gBAAC;gBAAc;aAAS,GACxB;gBAAC;aAAa;QACtB;AACJ,EAAE"}
@@ -0,0 +1,101 @@
1
+ import type { GreengrassComponentMetadata } from './generator.js';
2
+ export declare const PY_DEPENDENCIES: import("../../utils/declared-dependencies.js").DependencyDeclaration<readonly [{
3
+ readonly name: "shx";
4
+ } & {
5
+ versionOnly: true;
6
+ }, {
7
+ readonly name: "js-yaml";
8
+ } & {
9
+ versionOnly: true;
10
+ }, {
11
+ readonly name: "@types/js-yaml";
12
+ } & {
13
+ versionOnly: true;
14
+ }, {
15
+ readonly name: "tsx";
16
+ } & {
17
+ versionOnly: true;
18
+ }, {
19
+ readonly name: "constructs";
20
+ readonly when: (m: import("../../utils/shared-constructs-constants.js").IacMetadata) => boolean;
21
+ } & {
22
+ versionOnly: true;
23
+ }, {
24
+ readonly name: "aws-cdk-lib";
25
+ readonly when: (m: import("../../utils/shared-constructs-constants.js").IacMetadata) => boolean;
26
+ } & {
27
+ versionOnly: true;
28
+ }, {
29
+ readonly name: "@types/node";
30
+ } & {
31
+ versionOnly: true;
32
+ }, {
33
+ readonly name: "js-yaml";
34
+ readonly when: (m: import("../../utils/shared-constructs-constants.js").IacMetadata) => boolean;
35
+ } & {
36
+ versionOnly: true;
37
+ }, {
38
+ readonly name: "@types/js-yaml";
39
+ readonly dev: true;
40
+ readonly when: (m: import("../../utils/shared-constructs-constants.js").IacMetadata) => boolean;
41
+ } & {
42
+ versionOnly: true;
43
+ }, {
44
+ readonly name: "@aws-sdk/client-greengrassv2";
45
+ readonly when: (m: import("../../utils/shared-constructs-constants.js").IacMetadata) => boolean;
46
+ } & {
47
+ versionOnly: true;
48
+ }], readonly [{
49
+ readonly name: "awsiotsdk";
50
+ readonly when: (metadata: GreengrassComponentMetadata) => boolean;
51
+ }]>;
52
+ export declare const TYPESCRIPT_DEPENDENCIES: import("../../utils/declared-dependencies.js").DependencyDeclaration<readonly [{
53
+ readonly name: "aws-iot-device-sdk-v2";
54
+ readonly when: (metadata: GreengrassComponentMetadata) => boolean;
55
+ }, {
56
+ readonly name: "rolldown";
57
+ } & {
58
+ versionOnly: true;
59
+ }, {
60
+ readonly name: "js-yaml";
61
+ } & {
62
+ versionOnly: true;
63
+ }, {
64
+ readonly name: "@types/js-yaml";
65
+ } & {
66
+ versionOnly: true;
67
+ }, {
68
+ readonly name: "tsx";
69
+ } & {
70
+ versionOnly: true;
71
+ }, {
72
+ readonly name: "constructs";
73
+ readonly when: (m: import("../../utils/shared-constructs-constants.js").IacMetadata) => boolean;
74
+ } & {
75
+ versionOnly: true;
76
+ }, {
77
+ readonly name: "aws-cdk-lib";
78
+ readonly when: (m: import("../../utils/shared-constructs-constants.js").IacMetadata) => boolean;
79
+ } & {
80
+ versionOnly: true;
81
+ }, {
82
+ readonly name: "@types/node";
83
+ } & {
84
+ versionOnly: true;
85
+ }, {
86
+ readonly name: "js-yaml";
87
+ readonly when: (m: import("../../utils/shared-constructs-constants.js").IacMetadata) => boolean;
88
+ } & {
89
+ versionOnly: true;
90
+ }, {
91
+ readonly name: "@types/js-yaml";
92
+ readonly dev: true;
93
+ readonly when: (m: import("../../utils/shared-constructs-constants.js").IacMetadata) => boolean;
94
+ } & {
95
+ versionOnly: true;
96
+ }, {
97
+ readonly name: "@aws-sdk/client-greengrassv2";
98
+ readonly when: (m: import("../../utils/shared-constructs-constants.js").IacMetadata) => boolean;
99
+ } & {
100
+ versionOnly: true;
101
+ }], readonly import("../../utils/declared-dependencies.js").DeclaredPyDependency<"ruff" | "a2a-sdk" | "ag-ui-langgraph" | "ag-ui-protocol" | "ag-ui-strands" | "aiosqlite" | "aws-lambda-powertools" | "aws-lambda-powertools[tracer]" | "aws-lambda-powertools[parser]" | "aws-opentelemetry-distro" | "awsiotsdk" | "bedrock-agentcore" | "boto3" | "checkov" | "fastapi" | "fastapi[standard]" | "httpx" | "langchain" | "langchain-aws" | "langchain-mcp-adapters" | "langgraph" | "langgraph-checkpoint-aws" | "langgraph-checkpoint-sqlite" | "mcp" | "pip-check-updates" | "pip-licenses" | "pydantic" | "strands-agents" | "strands-agents[a2a]" | "strands-agents-tools" | "ty" | "pynamodb" | "uvicorn" | "sqlmodel" | "alembic" | "aiomysql" | "asyncpg" | "greenlet", GreengrassComponentMetadata>[]>;
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */ import { BUNDLE_DEPENDENCIES } from "../../utils/bundle/bundle.js";
5
+ import { declareDependencies, ownedElsewhere } from "../../utils/declared-dependencies.js";
6
+ import { FS_DEPENDENCIES } from "../../utils/fs.js";
7
+ import { GREENGRASS_CONSTRUCTS_DEPENDENCIES } from "../../utils/greengrass-constructs/greengrass-constructs.js";
8
+ import { SHARED_CONSTRUCTS_DEPENDENCIES } from "../../utils/shared-constructs.js";
9
+ import { SHARED_GREENGRASS_SCRIPTS_DEPENDENCIES } from "../../utils/shared-greengrass-scripts.js";
10
+ export const PY_DEPENDENCIES = declareDependencies()({
11
+ ts: [
12
+ ...ownedElsewhere(FS_DEPENDENCIES),
13
+ ...ownedElsewhere(SHARED_GREENGRASS_SCRIPTS_DEPENDENCIES),
14
+ ...ownedElsewhere(SHARED_CONSTRUCTS_DEPENDENCIES),
15
+ ...ownedElsewhere(GREENGRASS_CONSTRUCTS_DEPENDENCIES)
16
+ ],
17
+ py: [
18
+ {
19
+ name: 'awsiotsdk',
20
+ when: (metadata)=>metadata.ipc
21
+ }
22
+ ]
23
+ });
24
+ export const TYPESCRIPT_DEPENDENCIES = declareDependencies()({
25
+ ts: [
26
+ {
27
+ name: 'aws-iot-device-sdk-v2',
28
+ when: (metadata)=>metadata.ipc
29
+ },
30
+ ...ownedElsewhere(BUNDLE_DEPENDENCIES),
31
+ ...ownedElsewhere(SHARED_GREENGRASS_SCRIPTS_DEPENDENCIES),
32
+ ...ownedElsewhere(SHARED_CONSTRUCTS_DEPENDENCIES),
33
+ ...ownedElsewhere(GREENGRASS_CONSTRUCTS_DEPENDENCIES)
34
+ ]
35
+ });
36
+
37
+ //# sourceMappingURL=dependencies.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../packages/nx-plugin/src/greengrass/component/dependencies.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport { BUNDLE_DEPENDENCIES } from '../../utils/bundle/bundle.js';\nimport {\n declareDependencies,\n ownedElsewhere,\n} from '../../utils/declared-dependencies.js';\nimport { FS_DEPENDENCIES } from '../../utils/fs.js';\nimport { GREENGRASS_CONSTRUCTS_DEPENDENCIES } from '../../utils/greengrass-constructs/greengrass-constructs.js';\nimport { SHARED_CONSTRUCTS_DEPENDENCIES } from '../../utils/shared-constructs.js';\nimport { SHARED_GREENGRASS_SCRIPTS_DEPENDENCIES } from '../../utils/shared-greengrass-scripts.js';\n// Type-only, so the factory's runtime import of this module stays acyclic.\nimport type { GreengrassComponentMetadata } from './generator.js';\n\nexport const PY_DEPENDENCIES =\n declareDependencies<GreengrassComponentMetadata>()({\n ts: [\n ...ownedElsewhere(FS_DEPENDENCIES),\n ...ownedElsewhere(SHARED_GREENGRASS_SCRIPTS_DEPENDENCIES),\n ...ownedElsewhere(SHARED_CONSTRUCTS_DEPENDENCIES),\n ...ownedElsewhere(GREENGRASS_CONSTRUCTS_DEPENDENCIES),\n ],\n py: [{ name: 'awsiotsdk', when: (metadata) => metadata.ipc }],\n });\n\nexport const TYPESCRIPT_DEPENDENCIES =\n declareDependencies<GreengrassComponentMetadata>()({\n ts: [\n { name: 'aws-iot-device-sdk-v2', when: (metadata) => metadata.ipc },\n ...ownedElsewhere(BUNDLE_DEPENDENCIES),\n ...ownedElsewhere(SHARED_GREENGRASS_SCRIPTS_DEPENDENCIES),\n ...ownedElsewhere(SHARED_CONSTRUCTS_DEPENDENCIES),\n ...ownedElsewhere(GREENGRASS_CONSTRUCTS_DEPENDENCIES),\n ],\n });\n"],"names":["BUNDLE_DEPENDENCIES","declareDependencies","ownedElsewhere","FS_DEPENDENCIES","GREENGRASS_CONSTRUCTS_DEPENDENCIES","SHARED_CONSTRUCTS_DEPENDENCIES","SHARED_GREENGRASS_SCRIPTS_DEPENDENCIES","PY_DEPENDENCIES","ts","py","name","when","metadata","ipc","TYPESCRIPT_DEPENDENCIES"],"mappings":"AAAA;;;CAGC,GACD,SAASA,mBAAmB,QAAQ,+BAA+B;AACnE,SACEC,mBAAmB,EACnBC,cAAc,QACT,uCAAuC;AAC9C,SAASC,eAAe,QAAQ,oBAAoB;AACpD,SAASC,kCAAkC,QAAQ,6DAA6D;AAChH,SAASC,8BAA8B,QAAQ,mCAAmC;AAClF,SAASC,sCAAsC,QAAQ,2CAA2C;AAIlG,OAAO,MAAMC,kBACXN,sBAAmD;IACjDO,IAAI;WACCN,eAAeC;WACfD,eAAeI;WACfJ,eAAeG;WACfH,eAAeE;KACnB;IACDK,IAAI;QAAC;YAAEC,MAAM;YAAaC,MAAM,CAACC,WAAaA,SAASC,GAAG;QAAC;KAAE;AAC/D,GAAG;AAEL,OAAO,MAAMC,0BACXb,sBAAmD;IACjDO,IAAI;QACF;YAAEE,MAAM;YAAyBC,MAAM,CAACC,WAAaA,SAASC,GAAG;QAAC;WAC/DX,eAAeF;WACfE,eAAeI;WACfJ,eAAeG;WACfH,eAAeE;KACnB;AACH,GAAG"}