@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,50 @@
1
+ import { describe, test, expect } from "bun:test";
2
+ import { typecheckDTS } from "./typecheck";
3
+
4
+ describe("typecheckDTS", () => {
5
+ test("passes valid .d.ts", async () => {
6
+ const content = `
7
+ export declare class Bucket {
8
+ readonly type: string;
9
+ readonly bucketName?: string;
10
+ }
11
+ `;
12
+ const result = await typecheckDTS(content);
13
+ expect(result.ok).toBe(true);
14
+ expect(result.diagnostics).toHaveLength(0);
15
+ });
16
+
17
+ test("fails on undefined type reference", async () => {
18
+ const content = `
19
+ export declare class Broken {
20
+ readonly value: UndefinedType;
21
+ }
22
+ `;
23
+ const result = await typecheckDTS(content);
24
+ expect(result.ok).toBe(false);
25
+ expect(result.diagnostics.length).toBeGreaterThan(0);
26
+ });
27
+
28
+ test("fails on syntax error", async () => {
29
+ const content = `
30
+ export declare class {
31
+ this is not valid typescript
32
+ }
33
+ `;
34
+ const result = await typecheckDTS(content);
35
+ expect(result.ok).toBe(false);
36
+ });
37
+
38
+ test("passes fixture-generated .d.ts", async () => {
39
+ const { loadSchemaFixtures } = await import("../testdata/load-fixtures");
40
+ const { generate } = await import("./generate");
41
+ const fixtures = loadSchemaFixtures();
42
+ const genResult = await generate({ schemaSource: fixtures });
43
+
44
+ const result = await typecheckDTS(genResult.typesDTS);
45
+ expect(result.ok).toBe(true);
46
+ if (!result.ok) {
47
+ console.error("Diagnostics:", result.diagnostics);
48
+ }
49
+ });
50
+ });
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Re-export from core — typecheck is lexicon-agnostic.
3
+ */
4
+ export { typecheckDTS, type TypeCheckResult } from "@intentius/chant/codegen/typecheck";
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Pinned dependency versions for reproducible generation.
3
+ */
4
+
5
+ export const PINNED_VERSIONS = {
6
+ cfnLint: "v1.32.4",
7
+ } as const;
8
+
9
+ /**
10
+ * Build the cfn-lint tarball URL for a given version tag.
11
+ */
12
+ export function cfnLintTarballUrl(version?: string): string {
13
+ const tag = version ?? PINNED_VERSIONS.cfnLint;
14
+ return `https://github.com/aws-cloudformation/cfn-lint/archive/refs/tags/${tag}.tar.gz`;
15
+ }
16
+
17
+ /**
18
+ * Check for newer versions of pinned dependencies.
19
+ */
20
+ export async function checkForUpdates(): Promise<{ cfnLint: { current: string; latest: string } }> {
21
+ const current = PINNED_VERSIONS.cfnLint;
22
+ let latest: string = current;
23
+
24
+ try {
25
+ const resp = await fetch("https://api.github.com/repos/aws-cloudformation/cfn-lint/releases/latest", {
26
+ headers: { Accept: "application/vnd.github.v3+json" },
27
+ });
28
+ if (resp.ok) {
29
+ const data = await resp.json() as { tag_name: string };
30
+ latest = data.tag_name;
31
+ }
32
+ } catch {
33
+ // Network failure — return current as latest
34
+ }
35
+
36
+ return { cfnLint: { current, latest } };
37
+ }
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Re-export from core — coverage analysis is lexicon-agnostic.
3
+ */
4
+ export {
5
+ computeCoverage,
6
+ overallPct,
7
+ formatSummary,
8
+ formatVerbose,
9
+ checkThresholds,
10
+ type ResourceCoverage,
11
+ type CoverageReport,
12
+ type CoverageThresholds,
13
+ type ThresholdResult,
14
+ } from "@intentius/chant/codegen/coverage";