@intentius/chant-lexicon-aws 0.0.2

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 (94) hide show
  1. package/README.md +438 -0
  2. package/package.json +30 -0
  3. package/src/codegen/__snapshots__/snapshot.test.ts.snap +197 -0
  4. package/src/codegen/docs-cli.ts +3 -0
  5. package/src/codegen/docs.ts +1206 -0
  6. package/src/codegen/extensions.ts +171 -0
  7. package/src/codegen/fallback.ts +33 -0
  8. package/src/codegen/generate-cli.ts +17 -0
  9. package/src/codegen/generate-lexicon.ts +98 -0
  10. package/src/codegen/generate-typescript.ts +257 -0
  11. package/src/codegen/generate.test.ts +125 -0
  12. package/src/codegen/generate.ts +226 -0
  13. package/src/codegen/idempotency.test.ts +28 -0
  14. package/src/codegen/naming.ts +120 -0
  15. package/src/codegen/package.test.ts +60 -0
  16. package/src/codegen/package.ts +84 -0
  17. package/src/codegen/patches.ts +98 -0
  18. package/src/codegen/rollback.test.ts +80 -0
  19. package/src/codegen/rollback.ts +20 -0
  20. package/src/codegen/sam.ts +387 -0
  21. package/src/codegen/snapshot.test.ts +84 -0
  22. package/src/codegen/typecheck.test.ts +50 -0
  23. package/src/codegen/typecheck.ts +4 -0
  24. package/src/codegen/versions.ts +37 -0
  25. package/src/coverage.ts +14 -0
  26. package/src/generated/index.d.ts +160753 -0
  27. package/src/generated/index.ts +14396 -0
  28. package/src/generated/lexicon-aws.json +114563 -0
  29. package/src/generated/runtime.ts +4 -0
  30. package/src/import/generator.test.ts +181 -0
  31. package/src/import/generator.ts +349 -0
  32. package/src/import/parser.test.ts +200 -0
  33. package/src/import/parser.ts +350 -0
  34. package/src/import/roundtrip-fixtures.test.ts +78 -0
  35. package/src/import/roundtrip.test.ts +195 -0
  36. package/src/index.ts +63 -0
  37. package/src/integration.test.ts +129 -0
  38. package/src/intrinsics.test.ts +167 -0
  39. package/src/intrinsics.ts +223 -0
  40. package/src/lint/post-synth/cf-refs.ts +91 -0
  41. package/src/lint/post-synth/cor020.ts +72 -0
  42. package/src/lint/post-synth/ext001.test.ts +68 -0
  43. package/src/lint/post-synth/ext001.ts +222 -0
  44. package/src/lint/post-synth/post-synth.test.ts +280 -0
  45. package/src/lint/post-synth/waw010.ts +49 -0
  46. package/src/lint/post-synth/waw011.ts +49 -0
  47. package/src/lint/post-synth/waw013.ts +45 -0
  48. package/src/lint/post-synth/waw014.ts +50 -0
  49. package/src/lint/post-synth/waw015.ts +100 -0
  50. package/src/lint/rules/hardcoded-region.ts +43 -0
  51. package/src/lint/rules/iam-wildcard.ts +66 -0
  52. package/src/lint/rules/index.ts +7 -0
  53. package/src/lint/rules/rules.test.ts +175 -0
  54. package/src/lint/rules/s3-encryption.ts +69 -0
  55. package/src/lsp/completions.test.ts +72 -0
  56. package/src/lsp/completions.ts +18 -0
  57. package/src/lsp/hover.test.ts +53 -0
  58. package/src/lsp/hover.ts +53 -0
  59. package/src/nested-stack.test.ts +83 -0
  60. package/src/nested-stack.ts +125 -0
  61. package/src/plugin.test.ts +316 -0
  62. package/src/plugin.ts +514 -0
  63. package/src/pseudo.test.ts +55 -0
  64. package/src/pseudo.ts +29 -0
  65. package/src/serializer.test.ts +507 -0
  66. package/src/serializer.ts +333 -0
  67. package/src/spec/fetch.test.ts +27 -0
  68. package/src/spec/fetch.ts +107 -0
  69. package/src/spec/parse.test.ts +153 -0
  70. package/src/spec/parse.ts +202 -0
  71. package/src/testdata/load-fixtures.ts +17 -0
  72. package/src/testdata/roundtrip/conditions.json +21 -0
  73. package/src/testdata/roundtrip/intrinsic-calls.json +31 -0
  74. package/src/testdata/roundtrip/intrinsics.json +18 -0
  75. package/src/testdata/roundtrip/multi-resource.json +37 -0
  76. package/src/testdata/roundtrip/parameters.json +23 -0
  77. package/src/testdata/roundtrip/simple.json +12 -0
  78. package/src/testdata/sam-fixtures/api.yaml +14 -0
  79. package/src/testdata/sam-fixtures/application.yaml +13 -0
  80. package/src/testdata/sam-fixtures/function.yaml +22 -0
  81. package/src/testdata/sam-fixtures/graphql-api.yaml +13 -0
  82. package/src/testdata/sam-fixtures/http-api.yaml +15 -0
  83. package/src/testdata/sam-fixtures/layer-version.yaml +15 -0
  84. package/src/testdata/sam-fixtures/multi-type-a.yaml +23 -0
  85. package/src/testdata/sam-fixtures/multi-type-b.yaml +29 -0
  86. package/src/testdata/sam-fixtures/simple-table.yaml +12 -0
  87. package/src/testdata/sam-fixtures/state-machine.yaml +14 -0
  88. package/src/testdata/schemas/aws-dynamodb-table.json +126 -0
  89. package/src/testdata/schemas/aws-iam-role.json +85 -0
  90. package/src/testdata/schemas/aws-lambda-function.json +90 -0
  91. package/src/testdata/schemas/aws-s3-bucket.json +83 -0
  92. package/src/testdata/schemas/aws-sns-topic.json +71 -0
  93. package/src/validate-cli.ts +19 -0
  94. package/src/validate.ts +34 -0
@@ -0,0 +1,85 @@
1
+ {
2
+ "typeName": "AWS::IAM::Role",
3
+ "description": "Creates an IAM role with a trust policy and optional inline policies.",
4
+ "properties": {
5
+ "RoleName": {
6
+ "type": "string",
7
+ "description": "A name for the IAM role.",
8
+ "minLength": 1,
9
+ "maxLength": 64,
10
+ "pattern": "^[\\w+=,.@-]+$"
11
+ },
12
+ "Arn": {
13
+ "type": "string",
14
+ "description": "The Amazon Resource Name (ARN) for the role."
15
+ },
16
+ "RoleId": {
17
+ "type": "string",
18
+ "description": "The stable and unique string identifying the role."
19
+ },
20
+ "AssumeRolePolicyDocument": {
21
+ "type": "object",
22
+ "description": "The trust policy that is associated with this role."
23
+ },
24
+ "Policies": {
25
+ "type": "array",
26
+ "items": {
27
+ "$ref": "#/definitions/Policy"
28
+ },
29
+ "description": "Adds or updates an inline policy document that is embedded in the role."
30
+ },
31
+ "ManagedPolicyArns": {
32
+ "type": "array",
33
+ "items": {
34
+ "type": "string"
35
+ },
36
+ "description": "A list of Amazon Resource Names (ARNs) of the IAM managed policies to attach."
37
+ },
38
+ "Tags": {
39
+ "type": "array",
40
+ "items": {
41
+ "$ref": "#/definitions/Tag"
42
+ },
43
+ "description": "A list of tags attached to the role."
44
+ }
45
+ },
46
+ "definitions": {
47
+ "Policy": {
48
+ "type": "object",
49
+ "description": "An inline policy document embedded in the role.",
50
+ "properties": {
51
+ "PolicyName": {
52
+ "type": "string",
53
+ "description": "The friendly name of the policy.",
54
+ "minLength": 1,
55
+ "maxLength": 128
56
+ },
57
+ "PolicyDocument": {
58
+ "type": "object",
59
+ "description": "The policy document."
60
+ }
61
+ },
62
+ "required": ["PolicyName", "PolicyDocument"]
63
+ },
64
+ "Tag": {
65
+ "type": "object",
66
+ "description": "A key-value pair to associate with a resource.",
67
+ "properties": {
68
+ "Key": {
69
+ "type": "string",
70
+ "minLength": 1,
71
+ "maxLength": 128
72
+ },
73
+ "Value": {
74
+ "type": "string",
75
+ "maxLength": 256
76
+ }
77
+ },
78
+ "required": ["Key", "Value"]
79
+ }
80
+ },
81
+ "required": ["AssumeRolePolicyDocument"],
82
+ "readOnlyProperties": ["/properties/Arn", "/properties/RoleId"],
83
+ "primaryIdentifier": ["/properties/RoleName"],
84
+ "additionalProperties": false
85
+ }
@@ -0,0 +1,90 @@
1
+ {
2
+ "typeName": "AWS::Lambda::Function",
3
+ "description": "The AWS::Lambda::Function resource creates a Lambda function.",
4
+ "properties": {
5
+ "FunctionName": {
6
+ "type": "string",
7
+ "description": "The name of the Lambda function.",
8
+ "minLength": 1,
9
+ "maxLength": 64
10
+ },
11
+ "Arn": {
12
+ "type": "string",
13
+ "description": "The ARN of the function."
14
+ },
15
+ "Runtime": {
16
+ "type": "string",
17
+ "description": "The identifier of the function's runtime.",
18
+ "enum": ["nodejs20.x", "nodejs18.x", "python3.12", "python3.11", "java21", "java17"]
19
+ },
20
+ "Handler": {
21
+ "type": "string",
22
+ "description": "The name of the method within your code that Lambda calls to run your function.",
23
+ "maxLength": 128,
24
+ "pattern": "^[^\\s]+$"
25
+ },
26
+ "Code": {
27
+ "$ref": "#/definitions/Code",
28
+ "description": "The code for the function."
29
+ },
30
+ "Role": {
31
+ "type": "string",
32
+ "description": "The ARN of the function's execution role.",
33
+ "pattern": "^arn:(aws[a-zA-Z-]*)?:iam::\\d{12}:role/?[a-zA-Z_0-9+=,.@\\-_/]+$"
34
+ },
35
+ "MemorySize": {
36
+ "type": "integer",
37
+ "description": "The amount of memory available to the function at runtime.",
38
+ "minimum": 128,
39
+ "maximum": 10240
40
+ }
41
+ },
42
+ "definitions": {
43
+ "Code": {
44
+ "type": "object",
45
+ "description": "The deployment package for a Lambda function.",
46
+ "properties": {
47
+ "S3Bucket": {
48
+ "type": "string",
49
+ "description": "An Amazon S3 bucket in the same AWS Region as your function.",
50
+ "minLength": 3,
51
+ "maxLength": 63
52
+ },
53
+ "S3Key": {
54
+ "type": "string",
55
+ "description": "The Amazon S3 key of the deployment package.",
56
+ "minLength": 1,
57
+ "maxLength": 1024
58
+ },
59
+ "S3ObjectVersion": {
60
+ "type": "string",
61
+ "description": "For versioned objects, the version of the deployment package."
62
+ },
63
+ "ZipFile": {
64
+ "type": "string",
65
+ "description": "The source code of your Lambda function (Node.js and Python)."
66
+ }
67
+ }
68
+ },
69
+ "Tag": {
70
+ "type": "object",
71
+ "description": "A key-value pair to associate with a resource.",
72
+ "properties": {
73
+ "Key": {
74
+ "type": "string",
75
+ "minLength": 1,
76
+ "maxLength": 128
77
+ },
78
+ "Value": {
79
+ "type": "string",
80
+ "maxLength": 256
81
+ }
82
+ },
83
+ "required": ["Key", "Value"]
84
+ }
85
+ },
86
+ "required": ["Code", "Role"],
87
+ "readOnlyProperties": ["/properties/Arn"],
88
+ "primaryIdentifier": ["/properties/FunctionName"],
89
+ "additionalProperties": false
90
+ }
@@ -0,0 +1,83 @@
1
+ {
2
+ "typeName": "AWS::S3::Bucket",
3
+ "description": "The AWS::S3::Bucket resource creates an Amazon S3 bucket.",
4
+ "properties": {
5
+ "BucketName": {
6
+ "type": "string",
7
+ "description": "A name for the bucket.",
8
+ "minLength": 3,
9
+ "maxLength": 63,
10
+ "pattern": "^[a-z0-9][a-z0-9.-]*[a-z0-9]$"
11
+ },
12
+ "Arn": {
13
+ "type": "string",
14
+ "description": "The Amazon Resource Name (ARN) of the bucket."
15
+ },
16
+ "BucketEncryption": {
17
+ "$ref": "#/definitions/BucketEncryption",
18
+ "description": "Specifies default encryption for a bucket."
19
+ },
20
+ "Tags": {
21
+ "type": "array",
22
+ "items": {
23
+ "$ref": "#/definitions/Tag"
24
+ },
25
+ "description": "An arbitrary set of tags (key-value pairs) for this S3 bucket."
26
+ },
27
+ "VersioningConfiguration": {
28
+ "$ref": "#/definitions/VersioningConfiguration",
29
+ "description": "Enables multiple versions of all objects in this bucket."
30
+ }
31
+ },
32
+ "definitions": {
33
+ "BucketEncryption": {
34
+ "type": "object",
35
+ "description": "Specifies default encryption for a bucket using server-side encryption.",
36
+ "properties": {
37
+ "ServerSideEncryptionConfiguration": {
38
+ "type": "array",
39
+ "items": {
40
+ "type": "object"
41
+ },
42
+ "description": "Specifies the default server-side-encryption configuration."
43
+ }
44
+ },
45
+ "required": ["ServerSideEncryptionConfiguration"]
46
+ },
47
+ "Tag": {
48
+ "type": "object",
49
+ "description": "A key-value pair to associate with a resource.",
50
+ "properties": {
51
+ "Key": {
52
+ "type": "string",
53
+ "description": "The key name of the tag.",
54
+ "minLength": 1,
55
+ "maxLength": 128
56
+ },
57
+ "Value": {
58
+ "type": "string",
59
+ "description": "The value for the tag.",
60
+ "maxLength": 256
61
+ }
62
+ },
63
+ "required": ["Key", "Value"]
64
+ },
65
+ "VersioningConfiguration": {
66
+ "type": "object",
67
+ "description": "Describes the versioning state of an Amazon S3 bucket.",
68
+ "properties": {
69
+ "Status": {
70
+ "type": "string",
71
+ "description": "The versioning state of the bucket.",
72
+ "enum": ["Enabled", "Suspended"]
73
+ }
74
+ },
75
+ "required": ["Status"]
76
+ }
77
+ },
78
+ "required": ["BucketName"],
79
+ "readOnlyProperties": ["/properties/Arn"],
80
+ "createOnlyProperties": ["/properties/BucketName"],
81
+ "primaryIdentifier": ["/properties/BucketName"],
82
+ "additionalProperties": false
83
+ }
@@ -0,0 +1,71 @@
1
+ {
2
+ "typeName": "AWS::SNS::Topic",
3
+ "description": "The AWS::SNS::Topic resource creates a topic to which notifications can be published.",
4
+ "properties": {
5
+ "TopicName": {
6
+ "type": "string",
7
+ "description": "The name of the topic.",
8
+ "minLength": 1,
9
+ "maxLength": 256
10
+ },
11
+ "TopicArn": {
12
+ "type": "string",
13
+ "description": "The Amazon Resource Name (ARN) of the topic."
14
+ },
15
+ "DisplayName": {
16
+ "type": "string",
17
+ "description": "The display name to use for an SNS topic with SMS subscriptions."
18
+ },
19
+ "Subscription": {
20
+ "type": "array",
21
+ "items": {
22
+ "$ref": "#/definitions/Subscription"
23
+ },
24
+ "description": "The SNS subscriptions (endpoints) for this topic."
25
+ },
26
+ "Tags": {
27
+ "type": "array",
28
+ "items": {
29
+ "$ref": "#/definitions/Tag"
30
+ },
31
+ "description": "The list of tags to add to a new topic."
32
+ }
33
+ },
34
+ "definitions": {
35
+ "Subscription": {
36
+ "type": "object",
37
+ "description": "An SNS subscription associated with the topic.",
38
+ "properties": {
39
+ "Protocol": {
40
+ "type": "string",
41
+ "description": "The subscription's protocol.",
42
+ "enum": ["http", "https", "email", "email-json", "sms", "sqs", "application", "lambda"]
43
+ },
44
+ "Endpoint": {
45
+ "type": "string",
46
+ "description": "The endpoint that receives notifications from the topic."
47
+ }
48
+ },
49
+ "required": ["Protocol", "Endpoint"]
50
+ },
51
+ "Tag": {
52
+ "type": "object",
53
+ "description": "A key-value pair to associate with a resource.",
54
+ "properties": {
55
+ "Key": {
56
+ "type": "string",
57
+ "minLength": 1,
58
+ "maxLength": 128
59
+ },
60
+ "Value": {
61
+ "type": "string",
62
+ "maxLength": 256
63
+ }
64
+ },
65
+ "required": ["Key", "Value"]
66
+ }
67
+ },
68
+ "readOnlyProperties": ["/properties/TopicArn"],
69
+ "primaryIdentifier": ["/properties/TopicArn"],
70
+ "additionalProperties": false
71
+ }
@@ -0,0 +1,19 @@
1
+ #!/usr/bin/env bun
2
+ /**
3
+ * Thin entry point for `bun run validate` in lexicon-aws.
4
+ */
5
+ import { validate } from "./validate";
6
+
7
+ const result = await validate();
8
+
9
+ for (const check of result.checks) {
10
+ const status = check.ok ? "OK" : "FAIL";
11
+ const msg = check.error ? ` — ${check.error}` : "";
12
+ console.error(` [${status}] ${check.name}${msg}`);
13
+ }
14
+
15
+ if (!result.success) {
16
+ console.error("Validation failed");
17
+ process.exit(1);
18
+ }
19
+ console.error("All validation checks passed.");
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Validate generated lexicon-aws artifacts.
3
+ *
4
+ * Thin wrapper around the core validation framework
5
+ * with AWS-specific configuration.
6
+ */
7
+
8
+ import { dirname } from "path";
9
+ import { fileURLToPath } from "url";
10
+ import { validateLexiconArtifacts, type ValidateResult } from "@intentius/chant/codegen/validate";
11
+
12
+ export type { ValidateCheck, ValidateResult } from "@intentius/chant/codegen/validate";
13
+
14
+ const REQUIRED_NAMES = ["Bucket", "Function", "Role", "Table", "Policy", "LogGroup"];
15
+
16
+ /**
17
+ * Validate the generated lexicon-aws artifacts.
18
+ *
19
+ * @param opts.basePath - Override the package directory (defaults to lexicon-aws package root)
20
+ */
21
+ export async function validate(opts?: { basePath?: string }): Promise<ValidateResult> {
22
+ const basePath = opts?.basePath ?? dirname(dirname(fileURLToPath(import.meta.url)));
23
+
24
+ return validateLexiconArtifacts({
25
+ lexiconJsonFilename: "lexicon-aws.json",
26
+ requiredNames: REQUIRED_NAMES,
27
+ basePath,
28
+ coverageThresholds: {
29
+ minPropertyPct: 1,
30
+ minLifecyclePct: 1,
31
+ minAttrPct: 1,
32
+ },
33
+ });
34
+ }