@greyworld/code-check-core 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/facade/code-checker.d.ts +14 -0
- package/dist/facade/code-checker.d.ts.map +1 -0
- package/dist/facade/code-checker.js +63 -0
- package/dist/facade/code-checker.js.map +1 -0
- package/dist/facade/index.d.ts +3 -0
- package/dist/facade/index.d.ts.map +1 -0
- package/dist/facade/index.js +6 -0
- package/dist/facade/index.js.map +1 -0
- package/dist/facade/types.d.ts +24 -0
- package/dist/facade/types.d.ts.map +1 -0
- package/dist/facade/types.js +3 -0
- package/dist/facade/types.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -0
- package/dist/tools/ast-parser/go/index.d.ts +3 -0
- package/dist/tools/ast-parser/go/index.d.ts.map +1 -0
- package/dist/tools/ast-parser/go/index.js +6 -0
- package/dist/tools/ast-parser/go/index.js.map +1 -0
- package/dist/tools/ast-parser/go/parser.d.ts +56 -0
- package/dist/tools/ast-parser/go/parser.d.ts.map +1 -0
- package/dist/tools/ast-parser/go/parser.js +147 -0
- package/dist/tools/ast-parser/go/parser.js.map +1 -0
- package/dist/tools/ast-parser/go/schema-extractor.d.ts +103 -0
- package/dist/tools/ast-parser/go/schema-extractor.d.ts.map +1 -0
- package/dist/tools/ast-parser/go/schema-extractor.js +487 -0
- package/dist/tools/ast-parser/go/schema-extractor.js.map +1 -0
- package/dist/tools/ast-parser/go/semantic-normalizer.d.ts +51 -0
- package/dist/tools/ast-parser/go/semantic-normalizer.d.ts.map +1 -0
- package/dist/tools/ast-parser/go/semantic-normalizer.js +263 -0
- package/dist/tools/ast-parser/go/semantic-normalizer.js.map +1 -0
- package/dist/tools/ast-parser/go/types.d.ts +131 -0
- package/dist/tools/ast-parser/go/types.d.ts.map +1 -0
- package/dist/tools/ast-parser/go/types.js +3 -0
- package/dist/tools/ast-parser/go/types.js.map +1 -0
- package/dist/tools/ast-parser/markdown/index.d.ts +28 -0
- package/dist/tools/ast-parser/markdown/index.d.ts.map +1 -0
- package/dist/tools/ast-parser/markdown/index.js +31 -0
- package/dist/tools/ast-parser/markdown/index.js.map +1 -0
- package/dist/tools/ast-parser/markdown/parser.d.ts +271 -0
- package/dist/tools/ast-parser/markdown/parser.d.ts.map +1 -0
- package/dist/tools/ast-parser/markdown/parser.js +613 -0
- package/dist/tools/ast-parser/markdown/parser.js.map +1 -0
- package/dist/tools/ast-parser/markdown/types.d.ts +131 -0
- package/dist/tools/ast-parser/markdown/types.d.ts.map +1 -0
- package/dist/tools/ast-parser/markdown/types.js +3 -0
- package/dist/tools/ast-parser/markdown/types.js.map +1 -0
- package/dist/tools/env/index.d.ts +2 -0
- package/dist/tools/env/index.d.ts.map +1 -0
- package/dist/tools/env/index.js +6 -0
- package/dist/tools/env/index.js.map +1 -0
- package/dist/tools/env/load-env.d.ts +9 -0
- package/dist/tools/env/load-env.d.ts.map +1 -0
- package/dist/tools/env/load-env.js +39 -0
- package/dist/tools/env/load-env.js.map +1 -0
- package/dist/tools/line-pattern/index.d.ts +15 -0
- package/dist/tools/line-pattern/index.d.ts.map +1 -0
- package/dist/tools/line-pattern/index.js +25 -0
- package/dist/tools/line-pattern/index.js.map +1 -0
- package/dist/tools/line-pattern/line-pattern.d.ts +53 -0
- package/dist/tools/line-pattern/line-pattern.d.ts.map +1 -0
- package/dist/tools/line-pattern/line-pattern.js +88 -0
- package/dist/tools/line-pattern/line-pattern.js.map +1 -0
- package/dist/tools/line-pattern/segment.d.ts +24 -0
- package/dist/tools/line-pattern/segment.d.ts.map +1 -0
- package/dist/tools/line-pattern/segment.js +15 -0
- package/dist/tools/line-pattern/segment.js.map +1 -0
- package/dist/tools/line-pattern/segments.d.ts +43 -0
- package/dist/tools/line-pattern/segments.d.ts.map +1 -0
- package/dist/tools/line-pattern/segments.js +91 -0
- package/dist/tools/line-pattern/segments.js.map +1 -0
- package/dist/tools/llm/description-intent/format-spec.d.ts +3 -0
- package/dist/tools/llm/description-intent/format-spec.d.ts.map +1 -0
- package/dist/tools/llm/description-intent/format-spec.js +167 -0
- package/dist/tools/llm/description-intent/format-spec.js.map +1 -0
- package/dist/tools/llm/description-intent/index.d.ts +7 -0
- package/dist/tools/llm/description-intent/index.d.ts.map +1 -0
- package/dist/tools/llm/description-intent/index.js +15 -0
- package/dist/tools/llm/description-intent/index.js.map +1 -0
- package/dist/tools/llm/description-intent/intent-detector.d.ts +8 -0
- package/dist/tools/llm/description-intent/intent-detector.d.ts.map +1 -0
- package/dist/tools/llm/description-intent/intent-detector.js +103 -0
- package/dist/tools/llm/description-intent/intent-detector.js.map +1 -0
- package/dist/tools/llm/description-intent/normalizer.d.ts +12 -0
- package/dist/tools/llm/description-intent/normalizer.d.ts.map +1 -0
- package/dist/tools/llm/description-intent/normalizer.js +73 -0
- package/dist/tools/llm/description-intent/normalizer.js.map +1 -0
- package/dist/tools/llm/description-intent/slot-extractor.d.ts +3 -0
- package/dist/tools/llm/description-intent/slot-extractor.d.ts.map +1 -0
- package/dist/tools/llm/description-intent/slot-extractor.js +66 -0
- package/dist/tools/llm/description-intent/slot-extractor.js.map +1 -0
- package/dist/tools/llm/description-intent/types.d.ts +28 -0
- package/dist/tools/llm/description-intent/types.d.ts.map +1 -0
- package/dist/tools/llm/description-intent/types.js +19 -0
- package/dist/tools/llm/description-intent/types.js.map +1 -0
- package/dist/tools/llm/index.d.ts +16 -0
- package/dist/tools/llm/index.d.ts.map +1 -0
- package/dist/tools/llm/index.js +26 -0
- package/dist/tools/llm/index.js.map +1 -0
- package/dist/tools/llm/model.d.ts +3 -0
- package/dist/tools/llm/model.d.ts.map +1 -0
- package/dist/tools/llm/model.js +18 -0
- package/dist/tools/llm/model.js.map +1 -0
- package/dist/tools/llm/structured-caller.d.ts +86 -0
- package/dist/tools/llm/structured-caller.d.ts.map +1 -0
- package/dist/tools/llm/structured-caller.js +181 -0
- package/dist/tools/llm/structured-caller.js.map +1 -0
- package/dist/tools/node-pattern/index.d.ts +17 -0
- package/dist/tools/node-pattern/index.d.ts.map +1 -0
- package/dist/tools/node-pattern/index.js +36 -0
- package/dist/tools/node-pattern/index.js.map +1 -0
- package/dist/tools/node-pattern/matchers.d.ts +61 -0
- package/dist/tools/node-pattern/matchers.d.ts.map +1 -0
- package/dist/tools/node-pattern/matchers.js +154 -0
- package/dist/tools/node-pattern/matchers.js.map +1 -0
- package/dist/tools/node-pattern/node-matcher.d.ts +69 -0
- package/dist/tools/node-pattern/node-matcher.d.ts.map +1 -0
- package/dist/tools/node-pattern/node-matcher.js +122 -0
- package/dist/tools/node-pattern/node-matcher.js.map +1 -0
- package/dist/tools/node-pattern/node-pattern.d.ts +65 -0
- package/dist/tools/node-pattern/node-pattern.d.ts.map +1 -0
- package/dist/tools/node-pattern/node-pattern.js +129 -0
- package/dist/tools/node-pattern/node-pattern.js.map +1 -0
- package/dist/tools/section-check/index.d.ts +4 -0
- package/dist/tools/section-check/index.d.ts.map +1 -0
- package/dist/tools/section-check/index.js +10 -0
- package/dist/tools/section-check/index.js.map +1 -0
- package/dist/tools/section-check/section-check.d.ts +46 -0
- package/dist/tools/section-check/section-check.d.ts.map +1 -0
- package/dist/tools/section-check/section-check.js +264 -0
- package/dist/tools/section-check/section-check.js.map +1 -0
- package/dist/tools/section-check/types.d.ts +35 -0
- package/dist/tools/section-check/types.d.ts.map +1 -0
- package/dist/tools/section-check/types.js +23 -0
- package/dist/tools/section-check/types.js.map +1 -0
- package/dist/tools/text-grep/index.d.ts +10 -0
- package/dist/tools/text-grep/index.d.ts.map +1 -0
- package/dist/tools/text-grep/index.js +13 -0
- package/dist/tools/text-grep/index.js.map +1 -0
- package/dist/tools/text-grep/regex-grep.d.ts +92 -0
- package/dist/tools/text-grep/regex-grep.d.ts.map +1 -0
- package/dist/tools/text-grep/regex-grep.js +141 -0
- package/dist/tools/text-grep/regex-grep.js.map +1 -0
- package/dist/workflow/context/context.d.ts +13 -0
- package/dist/workflow/context/context.d.ts.map +1 -0
- package/dist/workflow/context/context.js +29 -0
- package/dist/workflow/context/context.js.map +1 -0
- package/dist/workflow/implement/resource-check/context-keys.d.ts +30 -0
- package/dist/workflow/implement/resource-check/context-keys.d.ts.map +1 -0
- package/dist/workflow/implement/resource-check/context-keys.js +33 -0
- package/dist/workflow/implement/resource-check/context-keys.js.map +1 -0
- package/dist/workflow/implement/resource-check/resource-check-workflow.d.ts +20 -0
- package/dist/workflow/implement/resource-check/resource-check-workflow.d.ts.map +1 -0
- package/dist/workflow/implement/resource-check/resource-check-workflow.js +325 -0
- package/dist/workflow/implement/resource-check/resource-check-workflow.js.map +1 -0
- package/dist/workflow/implement/resource-check/rules/index.d.ts +5 -0
- package/dist/workflow/implement/resource-check/rules/index.d.ts.map +1 -0
- package/dist/workflow/implement/resource-check/rules/index.js +21 -0
- package/dist/workflow/implement/resource-check/rules/index.js.map +1 -0
- package/dist/workflow/implement/resource-check/rules/markdown-format/arguments/argument-section-format-rule.d.ts +8 -0
- package/dist/workflow/implement/resource-check/rules/markdown-format/arguments/argument-section-format-rule.d.ts.map +1 -0
- package/dist/workflow/implement/resource-check/rules/markdown-format/arguments/argument-section-format-rule.js +51 -0
- package/dist/workflow/implement/resource-check/rules/markdown-format/arguments/argument-section-format-rule.js.map +1 -0
- package/dist/workflow/implement/resource-check/rules/markdown-format/attributes/attribute-section-format-rule.d.ts +8 -0
- package/dist/workflow/implement/resource-check/rules/markdown-format/attributes/attribute-section-format-rule.d.ts.map +1 -0
- package/dist/workflow/implement/resource-check/rules/markdown-format/attributes/attribute-section-format-rule.js +60 -0
- package/dist/workflow/implement/resource-check/rules/markdown-format/attributes/attribute-section-format-rule.js.map +1 -0
- package/dist/workflow/implement/resource-check/rules/markdown-format/blank-line-between-blocks-rule.d.ts +9 -0
- package/dist/workflow/implement/resource-check/rules/markdown-format/blank-line-between-blocks-rule.d.ts.map +1 -0
- package/dist/workflow/implement/resource-check/rules/markdown-format/blank-line-between-blocks-rule.js +80 -0
- package/dist/workflow/implement/resource-check/rules/markdown-format/blank-line-between-blocks-rule.js.map +1 -0
- package/dist/workflow/implement/resource-check/rules/markdown-format/example/example-section-exists-rule.d.ts +8 -0
- package/dist/workflow/implement/resource-check/rules/markdown-format/example/example-section-exists-rule.d.ts.map +1 -0
- package/dist/workflow/implement/resource-check/rules/markdown-format/example/example-section-exists-rule.js +42 -0
- package/dist/workflow/implement/resource-check/rules/markdown-format/example/example-section-exists-rule.js.map +1 -0
- package/dist/workflow/implement/resource-check/rules/markdown-format/example-section-exists-rule.d.ts +8 -0
- package/dist/workflow/implement/resource-check/rules/markdown-format/example-section-exists-rule.d.ts.map +1 -0
- package/dist/workflow/implement/resource-check/rules/markdown-format/example-section-exists-rule.js +34 -0
- package/dist/workflow/implement/resource-check/rules/markdown-format/example-section-exists-rule.js.map +1 -0
- package/dist/workflow/implement/resource-check/rules/markdown-format/frontmatter/frontmatter-check-rule.d.ts +8 -0
- package/dist/workflow/implement/resource-check/rules/markdown-format/frontmatter/frontmatter-check-rule.d.ts.map +1 -0
- package/dist/workflow/implement/resource-check/rules/markdown-format/frontmatter/frontmatter-check-rule.js +33 -0
- package/dist/workflow/implement/resource-check/rules/markdown-format/frontmatter/frontmatter-check-rule.js.map +1 -0
- package/dist/workflow/implement/resource-check/rules/markdown-format/frontmatter-check-rule.d.ts +8 -0
- package/dist/workflow/implement/resource-check/rules/markdown-format/frontmatter-check-rule.d.ts.map +1 -0
- package/dist/workflow/implement/resource-check/rules/markdown-format/frontmatter-check-rule.js +33 -0
- package/dist/workflow/implement/resource-check/rules/markdown-format/frontmatter-check-rule.js.map +1 -0
- package/dist/workflow/implement/resource-check/rules/markdown-format/h1-exists-rule.d.ts +8 -0
- package/dist/workflow/implement/resource-check/rules/markdown-format/h1-exists-rule.d.ts.map +1 -0
- package/dist/workflow/implement/resource-check/rules/markdown-format/h1-exists-rule.js +34 -0
- package/dist/workflow/implement/resource-check/rules/markdown-format/h1-exists-rule.js.map +1 -0
- package/dist/workflow/implement/resource-check/rules/markdown-format/index.d.ts +11 -0
- package/dist/workflow/implement/resource-check/rules/markdown-format/index.d.ts.map +1 -0
- package/dist/workflow/implement/resource-check/rules/markdown-format/index.js +38 -0
- package/dist/workflow/implement/resource-check/rules/markdown-format/index.js.map +1 -0
- package/dist/workflow/implement/resource-check/rules/markdown-format/line-length-rule.d.ts +15 -0
- package/dist/workflow/implement/resource-check/rules/markdown-format/line-length-rule.d.ts.map +1 -0
- package/dist/workflow/implement/resource-check/rules/markdown-format/line-length-rule.js +77 -0
- package/dist/workflow/implement/resource-check/rules/markdown-format/line-length-rule.js.map +1 -0
- package/dist/workflow/implement/resource-check/rules/markdown-format/number-format-rule.d.ts +23 -0
- package/dist/workflow/implement/resource-check/rules/markdown-format/number-format-rule.d.ts.map +1 -0
- package/dist/workflow/implement/resource-check/rules/markdown-format/number-format-rule.js +128 -0
- package/dist/workflow/implement/resource-check/rules/markdown-format/number-format-rule.js.map +1 -0
- package/dist/workflow/implement/resource-check/rules/markdown-format/shared/section-check-result.d.ts +9 -0
- package/dist/workflow/implement/resource-check/rules/markdown-format/shared/section-check-result.d.ts.map +1 -0
- package/dist/workflow/implement/resource-check/rules/markdown-format/shared/section-check-result.js +19 -0
- package/dist/workflow/implement/resource-check/rules/markdown-format/shared/section-check-result.js.map +1 -0
- package/dist/workflow/implement/resource-check/rules/markdown-format/title/h1-exists-rule.d.ts +8 -0
- package/dist/workflow/implement/resource-check/rules/markdown-format/title/h1-exists-rule.d.ts.map +1 -0
- package/dist/workflow/implement/resource-check/rules/markdown-format/title/h1-exists-rule.js +44 -0
- package/dist/workflow/implement/resource-check/rules/markdown-format/title/h1-exists-rule.js.map +1 -0
- package/dist/workflow/implement/resource-check/rules/markdown-format/total/blank-line-between-blocks-rule.d.ts +9 -0
- package/dist/workflow/implement/resource-check/rules/markdown-format/total/blank-line-between-blocks-rule.d.ts.map +1 -0
- package/dist/workflow/implement/resource-check/rules/markdown-format/total/blank-line-between-blocks-rule.js +80 -0
- package/dist/workflow/implement/resource-check/rules/markdown-format/total/blank-line-between-blocks-rule.js.map +1 -0
- package/dist/workflow/implement/resource-check/rules/markdown-format/total/line-length-rule.d.ts +15 -0
- package/dist/workflow/implement/resource-check/rules/markdown-format/total/line-length-rule.d.ts.map +1 -0
- package/dist/workflow/implement/resource-check/rules/markdown-format/total/line-length-rule.js +77 -0
- package/dist/workflow/implement/resource-check/rules/markdown-format/total/line-length-rule.js.map +1 -0
- package/dist/workflow/implement/resource-check/rules/markdown-format/total/number-format-rule.d.ts +23 -0
- package/dist/workflow/implement/resource-check/rules/markdown-format/total/number-format-rule.d.ts.map +1 -0
- package/dist/workflow/implement/resource-check/rules/markdown-format/total/number-format-rule.js +128 -0
- package/dist/workflow/implement/resource-check/rules/markdown-format/total/number-format-rule.js.map +1 -0
- package/dist/workflow/implement/resource-check/rules/markdown-semantic/argument-section-semantic-rule.d.ts +11 -0
- package/dist/workflow/implement/resource-check/rules/markdown-semantic/argument-section-semantic-rule.d.ts.map +1 -0
- package/dist/workflow/implement/resource-check/rules/markdown-semantic/argument-section-semantic-rule.js +145 -0
- package/dist/workflow/implement/resource-check/rules/markdown-semantic/argument-section-semantic-rule.js.map +1 -0
- package/dist/workflow/implement/resource-check/rules/markdown-semantic/arguments/argument-section-semantic-rule.d.ts +11 -0
- package/dist/workflow/implement/resource-check/rules/markdown-semantic/arguments/argument-section-semantic-rule.d.ts.map +1 -0
- package/dist/workflow/implement/resource-check/rules/markdown-semantic/arguments/argument-section-semantic-rule.js +145 -0
- package/dist/workflow/implement/resource-check/rules/markdown-semantic/arguments/argument-section-semantic-rule.js.map +1 -0
- package/dist/workflow/implement/resource-check/rules/markdown-semantic/attribute-section-semantic-rule.d.ts +9 -0
- package/dist/workflow/implement/resource-check/rules/markdown-semantic/attribute-section-semantic-rule.d.ts.map +1 -0
- package/dist/workflow/implement/resource-check/rules/markdown-semantic/attribute-section-semantic-rule.js +83 -0
- package/dist/workflow/implement/resource-check/rules/markdown-semantic/attribute-section-semantic-rule.js.map +1 -0
- package/dist/workflow/implement/resource-check/rules/markdown-semantic/attributes/attribute-section-semantic-rule.d.ts +9 -0
- package/dist/workflow/implement/resource-check/rules/markdown-semantic/attributes/attribute-section-semantic-rule.d.ts.map +1 -0
- package/dist/workflow/implement/resource-check/rules/markdown-semantic/attributes/attribute-section-semantic-rule.js +83 -0
- package/dist/workflow/implement/resource-check/rules/markdown-semantic/attributes/attribute-section-semantic-rule.js.map +1 -0
- package/dist/workflow/implement/resource-check/rules/markdown-semantic/index.d.ts +7 -0
- package/dist/workflow/implement/resource-check/rules/markdown-semantic/index.d.ts.map +1 -0
- package/dist/workflow/implement/resource-check/rules/markdown-semantic/index.js +15 -0
- package/dist/workflow/implement/resource-check/rules/markdown-semantic/index.js.map +1 -0
- package/dist/workflow/implement/resource-check/rules/markdown-semantic/section-existence-rule.d.ts +9 -0
- package/dist/workflow/implement/resource-check/rules/markdown-semantic/section-existence-rule.d.ts.map +1 -0
- package/dist/workflow/implement/resource-check/rules/markdown-semantic/section-existence-rule.js +96 -0
- package/dist/workflow/implement/resource-check/rules/markdown-semantic/section-existence-rule.js.map +1 -0
- package/dist/workflow/implement/resource-check/rules/markdown-semantic/total/section-existence-rule.d.ts +9 -0
- package/dist/workflow/implement/resource-check/rules/markdown-semantic/total/section-existence-rule.d.ts.map +1 -0
- package/dist/workflow/implement/resource-check/rules/markdown-semantic/total/section-existence-rule.js +109 -0
- package/dist/workflow/implement/resource-check/rules/markdown-semantic/total/section-existence-rule.js.map +1 -0
- package/dist/workflow/implement/resource-check/rules/stage-placeholder-rule.d.ts +19 -0
- package/dist/workflow/implement/resource-check/rules/stage-placeholder-rule.d.ts.map +1 -0
- package/dist/workflow/implement/resource-check/rules/stage-placeholder-rule.js +31 -0
- package/dist/workflow/implement/resource-check/rules/stage-placeholder-rule.js.map +1 -0
- package/dist/workflow/implement/resource-check/tools/doc-semantic/builder.d.ts +15 -0
- package/dist/workflow/implement/resource-check/tools/doc-semantic/builder.d.ts.map +1 -0
- package/dist/workflow/implement/resource-check/tools/doc-semantic/builder.js +554 -0
- package/dist/workflow/implement/resource-check/tools/doc-semantic/builder.js.map +1 -0
- package/dist/workflow/implement/resource-check/tools/doc-semantic/index.d.ts +5 -0
- package/dist/workflow/implement/resource-check/tools/doc-semantic/index.d.ts.map +1 -0
- package/dist/workflow/implement/resource-check/tools/doc-semantic/index.js +16 -0
- package/dist/workflow/implement/resource-check/tools/doc-semantic/index.js.map +1 -0
- package/dist/workflow/implement/resource-check/tools/doc-semantic/types.d.ts +94 -0
- package/dist/workflow/implement/resource-check/tools/doc-semantic/types.d.ts.map +1 -0
- package/dist/workflow/implement/resource-check/tools/doc-semantic/types.js +42 -0
- package/dist/workflow/implement/resource-check/tools/doc-semantic/types.js.map +1 -0
- package/dist/workflow/implement/resource-check/tools/schema-semantic/builder.d.ts +4 -0
- package/dist/workflow/implement/resource-check/tools/schema-semantic/builder.d.ts.map +1 -0
- package/dist/workflow/implement/resource-check/tools/schema-semantic/builder.js +103 -0
- package/dist/workflow/implement/resource-check/tools/schema-semantic/builder.js.map +1 -0
- package/dist/workflow/implement/resource-check/tools/schema-semantic/index.d.ts +3 -0
- package/dist/workflow/implement/resource-check/tools/schema-semantic/index.d.ts.map +1 -0
- package/dist/workflow/implement/resource-check/tools/schema-semantic/index.js +6 -0
- package/dist/workflow/implement/resource-check/tools/schema-semantic/index.js.map +1 -0
- package/dist/workflow/implement/resource-check/tools/schema-semantic/types.d.ts +47 -0
- package/dist/workflow/implement/resource-check/tools/schema-semantic/types.d.ts.map +1 -0
- package/dist/workflow/implement/resource-check/tools/schema-semantic/types.js +3 -0
- package/dist/workflow/implement/resource-check/tools/schema-semantic/types.js.map +1 -0
- package/dist/workflow/implement/resource-check/tools/terraform-schema/index.d.ts +4 -0
- package/dist/workflow/implement/resource-check/tools/terraform-schema/index.d.ts.map +1 -0
- package/dist/workflow/implement/resource-check/tools/terraform-schema/index.js +8 -0
- package/dist/workflow/implement/resource-check/tools/terraform-schema/index.js.map +1 -0
- package/dist/workflow/implement/resource-check/tools/terraform-schema/schema-extractor.d.ts +108 -0
- package/dist/workflow/implement/resource-check/tools/terraform-schema/schema-extractor.d.ts.map +1 -0
- package/dist/workflow/implement/resource-check/tools/terraform-schema/schema-extractor.js +498 -0
- package/dist/workflow/implement/resource-check/tools/terraform-schema/schema-extractor.js.map +1 -0
- package/dist/workflow/implement/resource-check/tools/terraform-schema/semantic-normalizer.d.ts +51 -0
- package/dist/workflow/implement/resource-check/tools/terraform-schema/semantic-normalizer.d.ts.map +1 -0
- package/dist/workflow/implement/resource-check/tools/terraform-schema/semantic-normalizer.js +271 -0
- package/dist/workflow/implement/resource-check/tools/terraform-schema/semantic-normalizer.js.map +1 -0
- package/dist/workflow/implement/resource-check/tools/terraform-schema/types.d.ts +133 -0
- package/dist/workflow/implement/resource-check/tools/terraform-schema/types.d.ts.map +1 -0
- package/dist/workflow/implement/resource-check/tools/terraform-schema/types.js +3 -0
- package/dist/workflow/implement/resource-check/tools/terraform-schema/types.js.map +1 -0
- package/dist/workflow/implement/resource-check/types.d.ts +18 -0
- package/dist/workflow/implement/resource-check/types.d.ts.map +1 -0
- package/dist/workflow/implement/resource-check/types.js +107 -0
- package/dist/workflow/implement/resource-check/types.js.map +1 -0
- package/dist/workflow/types/rule/rule.d.ts +72 -0
- package/dist/workflow/types/rule/rule.d.ts.map +1 -0
- package/dist/workflow/types/rule/rule.js +110 -0
- package/dist/workflow/types/rule/rule.js.map +1 -0
- package/dist/workflow/workflow.d.ts +52 -0
- package/dist/workflow/workflow.d.ts.map +1 -0
- package/dist/workflow/workflow.js +121 -0
- package/dist/workflow/workflow.js.map +1 -0
- package/package.json +36 -0
|
@@ -0,0 +1,487 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TerraformSchemaExtractor = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Mapping from `schema.Type*` selector expressions to our SchemaFieldType.
|
|
6
|
+
*/
|
|
7
|
+
const TYPE_MAP = {
|
|
8
|
+
"schema.TypeString": "TypeString",
|
|
9
|
+
"schema.TypeBool": "TypeBool",
|
|
10
|
+
"schema.TypeInt": "TypeInt",
|
|
11
|
+
"schema.TypeFloat": "TypeFloat",
|
|
12
|
+
"schema.TypeList": "TypeList",
|
|
13
|
+
"schema.TypeSet": "TypeSet",
|
|
14
|
+
"schema.TypeMap": "TypeMap",
|
|
15
|
+
};
|
|
16
|
+
function nonNullChildren(node) {
|
|
17
|
+
return node.namedChildren.filter((c) => c !== null);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Unwrap a `literal_element` wrapper node produced by tree-sitter-go.
|
|
21
|
+
* In Go composite literals, `keyed_element` children are wrapped in
|
|
22
|
+
* `literal_element` nodes. This returns the inner content node.
|
|
23
|
+
*/
|
|
24
|
+
function unwrap(node) {
|
|
25
|
+
if (node.type === "literal_element") {
|
|
26
|
+
const inner = node.firstNamedChild;
|
|
27
|
+
return inner ?? node;
|
|
28
|
+
}
|
|
29
|
+
return node;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Extracts Terraform resource schemas from Go source files.
|
|
33
|
+
*
|
|
34
|
+
* Targets the common Terraform Plugin SDK pattern:
|
|
35
|
+
* ```go
|
|
36
|
+
* func resourceXxx() *schema.Resource {
|
|
37
|
+
* return &schema.Resource{
|
|
38
|
+
* Schema: map[string]*schema.Schema{
|
|
39
|
+
* "field": { Type: schema.TypeString, ... },
|
|
40
|
+
* },
|
|
41
|
+
* }
|
|
42
|
+
* }
|
|
43
|
+
* ```
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* ```typescript
|
|
47
|
+
* const parser = await GoParser.create();
|
|
48
|
+
* const extractor = new TerraformSchemaExtractor(parser);
|
|
49
|
+
* const schemas = extractor.extract(goSourceCode);
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
class TerraformSchemaExtractor {
|
|
53
|
+
constructor(parser) {
|
|
54
|
+
this.parser = parser;
|
|
55
|
+
this.currentRoot = null;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Extract all resource schemas from a Go source string.
|
|
59
|
+
*/
|
|
60
|
+
extract(goSource) {
|
|
61
|
+
const tree = this.parser.parse(goSource);
|
|
62
|
+
const root = tree.rootNode;
|
|
63
|
+
this.currentRoot = root;
|
|
64
|
+
const results = [];
|
|
65
|
+
try {
|
|
66
|
+
const funcDecls = this.parser.findByType(root, "function_declaration");
|
|
67
|
+
for (const fn of funcDecls) {
|
|
68
|
+
const schema = this.extractFromFunction(fn);
|
|
69
|
+
if (schema) {
|
|
70
|
+
results.push(schema);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
finally {
|
|
75
|
+
this.currentRoot = null;
|
|
76
|
+
tree.delete();
|
|
77
|
+
}
|
|
78
|
+
return results;
|
|
79
|
+
}
|
|
80
|
+
extractFromFunction(fn) {
|
|
81
|
+
const nameNode = fn.childForFieldName("name");
|
|
82
|
+
if (!nameNode)
|
|
83
|
+
return null;
|
|
84
|
+
const funcName = nameNode.text;
|
|
85
|
+
const body = fn.childForFieldName("body");
|
|
86
|
+
if (!body)
|
|
87
|
+
return null;
|
|
88
|
+
const resourceLiteral = this.findResourceLiteral(body);
|
|
89
|
+
if (!resourceLiteral)
|
|
90
|
+
return null;
|
|
91
|
+
const schemaMap = this.findSchemaMap(resourceLiteral);
|
|
92
|
+
if (!schemaMap)
|
|
93
|
+
return null;
|
|
94
|
+
const fields = this.extractFieldsFromMap(schemaMap);
|
|
95
|
+
const resourceOptions = this.extractResourceOptions(resourceLiteral);
|
|
96
|
+
return {
|
|
97
|
+
resourceName: this.inferResourceName(funcName),
|
|
98
|
+
functionName: funcName,
|
|
99
|
+
fields,
|
|
100
|
+
resourceOptions,
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Locate the returned `&schema.Resource{ ... }` composite literal
|
|
105
|
+
* in a function body.
|
|
106
|
+
*/
|
|
107
|
+
findResourceLiteral(body) {
|
|
108
|
+
const literals = this.parser.findByType(body, "composite_literal");
|
|
109
|
+
for (const literal of literals) {
|
|
110
|
+
if (!this.isResourceCompositeLiteral(literal))
|
|
111
|
+
continue;
|
|
112
|
+
const schemaMap = this.findSchemaMap(literal);
|
|
113
|
+
if (!schemaMap)
|
|
114
|
+
continue;
|
|
115
|
+
return literal;
|
|
116
|
+
}
|
|
117
|
+
return null;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Locate the `Schema: map[string]*schema.Schema{ ... }` value from
|
|
121
|
+
* a resource composite literal.
|
|
122
|
+
*/
|
|
123
|
+
findSchemaMap(resourceLiteral) {
|
|
124
|
+
const valueNode = this.findTopLevelValueByKey(resourceLiteral, "Schema");
|
|
125
|
+
if (!valueNode)
|
|
126
|
+
return null;
|
|
127
|
+
if (this.isSchemaMapLiteral(valueNode))
|
|
128
|
+
return valueNode;
|
|
129
|
+
return null;
|
|
130
|
+
}
|
|
131
|
+
isResourceCompositeLiteral(node) {
|
|
132
|
+
const typeNode = node.childForFieldName("type");
|
|
133
|
+
if (!typeNode)
|
|
134
|
+
return false;
|
|
135
|
+
const typeText = typeNode.text;
|
|
136
|
+
return typeText === "schema.Resource" || typeText === "*schema.Resource";
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Find a top-level keyed value from a composite literal body by key.
|
|
140
|
+
*/
|
|
141
|
+
findTopLevelValueByKey(compositeLiteral, targetKey) {
|
|
142
|
+
const body = compositeLiteral.childForFieldName("body");
|
|
143
|
+
if (!body)
|
|
144
|
+
return null;
|
|
145
|
+
for (const child of nonNullChildren(body)) {
|
|
146
|
+
if (child.type !== "keyed_element")
|
|
147
|
+
continue;
|
|
148
|
+
const keyedChildren = nonNullChildren(child);
|
|
149
|
+
if (keyedChildren.length < 2)
|
|
150
|
+
continue;
|
|
151
|
+
const key = unwrap(keyedChildren[0]);
|
|
152
|
+
if (key.text !== targetKey)
|
|
153
|
+
continue;
|
|
154
|
+
return unwrap(keyedChildren[1]);
|
|
155
|
+
}
|
|
156
|
+
return null;
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Check if a node is a composite_literal of type
|
|
160
|
+
* `map[string]*schema.Schema{ ... }`.
|
|
161
|
+
*/
|
|
162
|
+
isSchemaMapLiteral(node) {
|
|
163
|
+
if (node.type !== "composite_literal")
|
|
164
|
+
return false;
|
|
165
|
+
const typeNode = node.childForFieldName("type");
|
|
166
|
+
if (!typeNode)
|
|
167
|
+
return false;
|
|
168
|
+
return typeNode.text === "map[string]*schema.Schema";
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Extract all schema fields from a map literal
|
|
172
|
+
* `map[string]*schema.Schema{ ... }`.
|
|
173
|
+
*/
|
|
174
|
+
extractFieldsFromMap(mapLiteral) {
|
|
175
|
+
const fields = [];
|
|
176
|
+
const literalBody = mapLiteral.childForFieldName("body");
|
|
177
|
+
if (!literalBody)
|
|
178
|
+
return fields;
|
|
179
|
+
for (const child of nonNullChildren(literalBody)) {
|
|
180
|
+
if (child.type !== "keyed_element")
|
|
181
|
+
continue;
|
|
182
|
+
const field = this.parseSchemaField(child);
|
|
183
|
+
if (field) {
|
|
184
|
+
fields.push(field);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
return fields;
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Parse a single schema field from a keyed_element like:
|
|
191
|
+
* `"field_name": { Type: schema.TypeString, Required: true, ... }`
|
|
192
|
+
*
|
|
193
|
+
* keyed_element -> literal_element(key) + literal_element(value)
|
|
194
|
+
* key unwraps to: interpreted_string_literal
|
|
195
|
+
* value unwraps to: literal_value (shorthand for the struct literal)
|
|
196
|
+
*/
|
|
197
|
+
parseSchemaField(keyedElement) {
|
|
198
|
+
const children = nonNullChildren(keyedElement);
|
|
199
|
+
if (children.length < 2)
|
|
200
|
+
return null;
|
|
201
|
+
const keyNode = unwrap(children[0]);
|
|
202
|
+
const name = this.extractStringLiteral(keyNode);
|
|
203
|
+
if (name === null)
|
|
204
|
+
return null;
|
|
205
|
+
const valueNode = unwrap(children[1]);
|
|
206
|
+
return this.parseFieldProperties(name, valueNode);
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Parse the properties (Type, Required, Optional, etc.) from
|
|
210
|
+
* a literal_value or composite_literal node containing the field's
|
|
211
|
+
* key-value pairs.
|
|
212
|
+
*/
|
|
213
|
+
parseFieldProperties(name, bodyOrLiteral) {
|
|
214
|
+
const field = {
|
|
215
|
+
name,
|
|
216
|
+
type: "",
|
|
217
|
+
required: false,
|
|
218
|
+
optional: false,
|
|
219
|
+
computed: false,
|
|
220
|
+
forceNew: false,
|
|
221
|
+
description: "",
|
|
222
|
+
};
|
|
223
|
+
const body = bodyOrLiteral.type === "literal_value"
|
|
224
|
+
? bodyOrLiteral
|
|
225
|
+
: (bodyOrLiteral.type === "composite_literal"
|
|
226
|
+
? bodyOrLiteral.childForFieldName("body")
|
|
227
|
+
: null);
|
|
228
|
+
if (!body)
|
|
229
|
+
return field;
|
|
230
|
+
for (const child of nonNullChildren(body)) {
|
|
231
|
+
if (child.type !== "keyed_element")
|
|
232
|
+
continue;
|
|
233
|
+
const childNamed = nonNullChildren(child);
|
|
234
|
+
if (childNamed.length < 2)
|
|
235
|
+
continue;
|
|
236
|
+
const propKey = unwrap(childNamed[0]);
|
|
237
|
+
const propVal = unwrap(childNamed[1]);
|
|
238
|
+
const key = propKey.text;
|
|
239
|
+
switch (key) {
|
|
240
|
+
case "Type":
|
|
241
|
+
field.type = TYPE_MAP[propVal.text] ?? propVal.text;
|
|
242
|
+
break;
|
|
243
|
+
case "Required":
|
|
244
|
+
field.required = propVal.text === "true";
|
|
245
|
+
break;
|
|
246
|
+
case "Optional":
|
|
247
|
+
field.optional = propVal.text === "true";
|
|
248
|
+
break;
|
|
249
|
+
case "Computed":
|
|
250
|
+
field.computed = propVal.text === "true";
|
|
251
|
+
break;
|
|
252
|
+
case "ForceNew":
|
|
253
|
+
field.forceNew = propVal.text === "true";
|
|
254
|
+
break;
|
|
255
|
+
case "Description":
|
|
256
|
+
field.description = this.extractStringLiteral(propVal) ?? "";
|
|
257
|
+
break;
|
|
258
|
+
case "Default":
|
|
259
|
+
field.defaultValue = propVal.text;
|
|
260
|
+
break;
|
|
261
|
+
case "Elem":
|
|
262
|
+
this.parseElem(field, propVal);
|
|
263
|
+
break;
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
return field;
|
|
267
|
+
}
|
|
268
|
+
/**
|
|
269
|
+
* Parse the `Elem` property which can be:
|
|
270
|
+
* - `&schema.Schema{ Type: schema.TypeString }` (simple element type)
|
|
271
|
+
* - `&schema.Resource{ Schema: map[string]*schema.Schema{ ... } }` (nested block)
|
|
272
|
+
* - `someSchemaFunc()` (function call returning *schema.Resource)
|
|
273
|
+
*/
|
|
274
|
+
parseElem(field, elemNode) {
|
|
275
|
+
let inner = elemNode;
|
|
276
|
+
if (inner.type === "unary_expression") {
|
|
277
|
+
const operand = inner.childForFieldName("operand");
|
|
278
|
+
if (!operand)
|
|
279
|
+
return;
|
|
280
|
+
inner = operand;
|
|
281
|
+
}
|
|
282
|
+
if (inner.type === "call_expression") {
|
|
283
|
+
const resolved = this.resolveSchemaFuncCall(inner);
|
|
284
|
+
if (resolved) {
|
|
285
|
+
field.subFields = resolved;
|
|
286
|
+
}
|
|
287
|
+
return;
|
|
288
|
+
}
|
|
289
|
+
if (inner.type !== "composite_literal")
|
|
290
|
+
return;
|
|
291
|
+
const typeNode = inner.childForFieldName("type");
|
|
292
|
+
if (!typeNode)
|
|
293
|
+
return;
|
|
294
|
+
const typeText = typeNode.text;
|
|
295
|
+
if (typeText === "schema.Schema" || typeText === "*schema.Schema") {
|
|
296
|
+
const body = inner.childForFieldName("body");
|
|
297
|
+
if (!body)
|
|
298
|
+
return;
|
|
299
|
+
for (const child of nonNullChildren(body)) {
|
|
300
|
+
if (child.type !== "keyed_element")
|
|
301
|
+
continue;
|
|
302
|
+
const childNamed = nonNullChildren(child);
|
|
303
|
+
if (childNamed.length < 2)
|
|
304
|
+
continue;
|
|
305
|
+
const k = unwrap(childNamed[0]);
|
|
306
|
+
const v = unwrap(childNamed[1]);
|
|
307
|
+
if (k.text === "Type") {
|
|
308
|
+
field.elemType = TYPE_MAP[v.text] ?? v.text;
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
else if (typeText === "schema.Resource" || typeText === "*schema.Resource") {
|
|
313
|
+
const schemaMap = this.findSchemaMap(inner);
|
|
314
|
+
if (schemaMap) {
|
|
315
|
+
field.subFields = this.extractFieldsFromMap(schemaMap);
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
/**
|
|
320
|
+
* Resolve an `Elem: someFunc()` call expression by locating the
|
|
321
|
+
* function definition in the same file and extracting its returned
|
|
322
|
+
* schema fields.
|
|
323
|
+
*/
|
|
324
|
+
resolveSchemaFuncCall(callNode) {
|
|
325
|
+
if (!this.currentRoot)
|
|
326
|
+
return undefined;
|
|
327
|
+
const funcNode = callNode.childForFieldName("function");
|
|
328
|
+
if (!funcNode)
|
|
329
|
+
return undefined;
|
|
330
|
+
const funcName = funcNode.text;
|
|
331
|
+
const funcDecls = this.parser.findByType(this.currentRoot, "function_declaration");
|
|
332
|
+
for (const fn of funcDecls) {
|
|
333
|
+
const nameNode = fn.childForFieldName("name");
|
|
334
|
+
if (!nameNode || nameNode.text !== funcName)
|
|
335
|
+
continue;
|
|
336
|
+
const body = fn.childForFieldName("body");
|
|
337
|
+
if (!body)
|
|
338
|
+
continue;
|
|
339
|
+
const resourceLiteral = this.findResourceLiteral(body);
|
|
340
|
+
if (!resourceLiteral)
|
|
341
|
+
continue;
|
|
342
|
+
const schemaMap = this.findSchemaMap(resourceLiteral);
|
|
343
|
+
if (schemaMap) {
|
|
344
|
+
return this.extractFieldsFromMap(schemaMap);
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
return undefined;
|
|
348
|
+
}
|
|
349
|
+
extractResourceOptions(resourceLiteral) {
|
|
350
|
+
const options = {
|
|
351
|
+
hasImporter: false,
|
|
352
|
+
};
|
|
353
|
+
const importerNode = this.findTopLevelValueByKey(resourceLiteral, "Importer");
|
|
354
|
+
if (importerNode && importerNode.text !== "nil") {
|
|
355
|
+
options.hasImporter = true;
|
|
356
|
+
const stateContext = this.extractImporterStateContext(importerNode);
|
|
357
|
+
if (stateContext) {
|
|
358
|
+
options.importerStateContext = stateContext;
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
const customizeDiffNode = this.findTopLevelValueByKey(resourceLiteral, "CustomizeDiff");
|
|
362
|
+
if (customizeDiffNode) {
|
|
363
|
+
options.customizeDiff = customizeDiffNode.text;
|
|
364
|
+
}
|
|
365
|
+
const deprecationNode = this.findTopLevelValueByKey(resourceLiteral, "DeprecationMessage");
|
|
366
|
+
if (deprecationNode) {
|
|
367
|
+
options.deprecationMessage = this.extractStringLiteral(deprecationNode) ?? deprecationNode.text;
|
|
368
|
+
}
|
|
369
|
+
const timeoutsNode = this.findTopLevelValueByKey(resourceLiteral, "Timeouts");
|
|
370
|
+
if (timeoutsNode) {
|
|
371
|
+
const timeouts = this.extractTimeouts(timeoutsNode);
|
|
372
|
+
if (timeouts) {
|
|
373
|
+
options.timeouts = timeouts;
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
return options;
|
|
377
|
+
}
|
|
378
|
+
extractImporterStateContext(importerNode) {
|
|
379
|
+
let node = importerNode;
|
|
380
|
+
if (node.type === "unary_expression") {
|
|
381
|
+
const operand = node.childForFieldName("operand");
|
|
382
|
+
if (!operand)
|
|
383
|
+
return undefined;
|
|
384
|
+
node = operand;
|
|
385
|
+
}
|
|
386
|
+
if (node.type !== "composite_literal")
|
|
387
|
+
return undefined;
|
|
388
|
+
const typeNode = node.childForFieldName("type");
|
|
389
|
+
if (!typeNode)
|
|
390
|
+
return undefined;
|
|
391
|
+
const typeText = typeNode.text;
|
|
392
|
+
if (typeText !== "schema.ResourceImporter" && typeText !== "*schema.ResourceImporter") {
|
|
393
|
+
return undefined;
|
|
394
|
+
}
|
|
395
|
+
const stateContextNode = this.findTopLevelValueByKey(node, "StateContext");
|
|
396
|
+
if (stateContextNode)
|
|
397
|
+
return stateContextNode.text;
|
|
398
|
+
const stateNode = this.findTopLevelValueByKey(node, "State");
|
|
399
|
+
if (stateNode)
|
|
400
|
+
return stateNode.text;
|
|
401
|
+
return undefined;
|
|
402
|
+
}
|
|
403
|
+
extractTimeouts(timeoutsNode) {
|
|
404
|
+
let node = timeoutsNode;
|
|
405
|
+
if (node.type === "unary_expression") {
|
|
406
|
+
const operand = node.childForFieldName("operand");
|
|
407
|
+
if (!operand)
|
|
408
|
+
return undefined;
|
|
409
|
+
node = operand;
|
|
410
|
+
}
|
|
411
|
+
if (node.type !== "composite_literal")
|
|
412
|
+
return undefined;
|
|
413
|
+
const typeNode = node.childForFieldName("type");
|
|
414
|
+
if (!typeNode)
|
|
415
|
+
return undefined;
|
|
416
|
+
const typeText = typeNode.text;
|
|
417
|
+
if (typeText !== "schema.ResourceTimeout" && typeText !== "*schema.ResourceTimeout") {
|
|
418
|
+
return undefined;
|
|
419
|
+
}
|
|
420
|
+
const timeouts = {};
|
|
421
|
+
const mapping = {
|
|
422
|
+
Create: "create",
|
|
423
|
+
Read: "read",
|
|
424
|
+
Update: "update",
|
|
425
|
+
Delete: "delete",
|
|
426
|
+
Default: "default",
|
|
427
|
+
};
|
|
428
|
+
const body = node.childForFieldName("body");
|
|
429
|
+
if (!body)
|
|
430
|
+
return undefined;
|
|
431
|
+
for (const child of nonNullChildren(body)) {
|
|
432
|
+
if (child.type !== "keyed_element")
|
|
433
|
+
continue;
|
|
434
|
+
const keyedChildren = nonNullChildren(child);
|
|
435
|
+
if (keyedChildren.length < 2)
|
|
436
|
+
continue;
|
|
437
|
+
const keyNode = unwrap(keyedChildren[0]);
|
|
438
|
+
const valueNode = unwrap(keyedChildren[1]);
|
|
439
|
+
const mapped = mapping[keyNode.text];
|
|
440
|
+
if (!mapped)
|
|
441
|
+
continue;
|
|
442
|
+
timeouts[mapped] = valueNode.text;
|
|
443
|
+
}
|
|
444
|
+
if (Object.keys(timeouts).length === 0)
|
|
445
|
+
return undefined;
|
|
446
|
+
return timeouts;
|
|
447
|
+
}
|
|
448
|
+
/**
|
|
449
|
+
* Extract the content of a Go interpreted string literal,
|
|
450
|
+
* stripping the surrounding double quotes.
|
|
451
|
+
*/
|
|
452
|
+
extractStringLiteral(node) {
|
|
453
|
+
const text = node.text;
|
|
454
|
+
if (text.startsWith('"') && text.endsWith('"')) {
|
|
455
|
+
return text.slice(1, -1);
|
|
456
|
+
}
|
|
457
|
+
if (text.startsWith('`') && text.endsWith('`')) {
|
|
458
|
+
return text.slice(1, -1);
|
|
459
|
+
}
|
|
460
|
+
return null;
|
|
461
|
+
}
|
|
462
|
+
/**
|
|
463
|
+
* Infer a Terraform resource name from a Go function name.
|
|
464
|
+
*
|
|
465
|
+
* `resourceAwsInstance` -> `aws_instance`
|
|
466
|
+
* `dataSourceAwsAmi` -> `aws_ami`
|
|
467
|
+
* `ResourceAwsVpcSubnet` -> `aws_vpc_subnet`
|
|
468
|
+
*/
|
|
469
|
+
inferResourceName(funcName) {
|
|
470
|
+
let name = funcName;
|
|
471
|
+
const prefixes = ["resource", "dataSource", "Resource", "DataSource"];
|
|
472
|
+
for (const prefix of prefixes) {
|
|
473
|
+
if (name.startsWith(prefix)) {
|
|
474
|
+
name = name.slice(prefix.length);
|
|
475
|
+
break;
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
if (!name)
|
|
479
|
+
return funcName;
|
|
480
|
+
return name
|
|
481
|
+
.replace(/([A-Z])/g, "_$1")
|
|
482
|
+
.toLowerCase()
|
|
483
|
+
.replace(/^_/, "");
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
exports.TerraformSchemaExtractor = TerraformSchemaExtractor;
|
|
487
|
+
//# sourceMappingURL=schema-extractor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema-extractor.js","sourceRoot":"","sources":["../../../../src/tools/ast-parser/go/schema-extractor.ts"],"names":[],"mappings":";;;AAUA;;GAEG;AACH,MAAM,QAAQ,GAAoC;IAC9C,mBAAmB,EAAE,YAAY;IACjC,iBAAiB,EAAE,UAAU;IAC7B,gBAAgB,EAAE,SAAS;IAC3B,kBAAkB,EAAE,WAAW;IAC/B,iBAAiB,EAAE,UAAU;IAC7B,gBAAgB,EAAE,SAAS;IAC3B,gBAAgB,EAAE,SAAS;CAC9B,CAAC;AAEF,SAAS,eAAe,CAAC,IAAgB;IACrC,OAAO,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,CAAC,EAAmB,EAAE,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC;AACzE,CAAC;AAED;;;;GAIG;AACH,SAAS,MAAM,CAAC,IAAgB;IAC5B,IAAI,IAAI,CAAC,IAAI,KAAK,iBAAiB,EAAE,CAAC;QAClC,MAAM,KAAK,GAAG,IAAI,CAAC,eAAe,CAAC;QACnC,OAAO,KAAK,IAAI,IAAI,CAAC;IACzB,CAAC;IACD,OAAO,IAAI,CAAC;AAChB,CAAC;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAa,wBAAwB;IAGjC,YAAoB,MAAgB;QAAhB,WAAM,GAAN,MAAM,CAAU;QAF5B,gBAAW,GAAsB,IAAI,CAAC;IAEP,CAAC;IAExC;;OAEG;IACI,OAAO,CAAC,QAAgB;QAC3B,MAAM,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;QACzC,MAAM,IAAI,GAAG,IAAI,CAAC,QAAQ,CAAC;QAC3B,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;QACxB,MAAM,OAAO,GAAqB,EAAE,CAAC;QAErC,IAAI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AC;QAED,IAAI,CAAC,IAAI;YAAE,OAAO,QAAQ,CAAC;QAE3B,OAAO,IAAI;aACN,OAAO,CAAC,UAAU,EAAE,KAAK,CAAC;aAC1B,WAAW,EAAE;aACb,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;IAC3B,CAAC;CACJ;AAncD,4DAmcC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { ResourceSchema } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* Conservative semantic normalizer on top of raw extractor output.
|
|
4
|
+
* It only derives values for whitelisted, high-confidence patterns.
|
|
5
|
+
*/
|
|
6
|
+
export declare class TerraformSchemaSemanticNormalizer {
|
|
7
|
+
normalizeSchemas(goSource: string, schemas: ResourceSchema[]): ResourceSchema[];
|
|
8
|
+
normalizeSchema(goSource: string, schema: ResourceSchema): ResourceSchema;
|
|
9
|
+
private normalizeTimeouts;
|
|
10
|
+
private normalizeTimeoutValue;
|
|
11
|
+
private unwrapDefaultTimeout;
|
|
12
|
+
/**
|
|
13
|
+
* Parse conservative duration expressions:
|
|
14
|
+
* - `10 * time.Minute`
|
|
15
|
+
* - `time.Minute * 10`
|
|
16
|
+
*/
|
|
17
|
+
private parseDurationToMs;
|
|
18
|
+
private deriveForceNewFromCustomizeDiff;
|
|
19
|
+
private deriveNonUpdatableFromCustomizeDiff;
|
|
20
|
+
/**
|
|
21
|
+
* Extract field names from a `funcName(fields)` call that may appear
|
|
22
|
+
* either as a standalone customizeDiff expression or inside a
|
|
23
|
+
* `customdiff.Sequence(...)` wrapper.
|
|
24
|
+
*/
|
|
25
|
+
private extractFieldsFromDiffCall;
|
|
26
|
+
/**
|
|
27
|
+
* Derive the import ID parts from the importer state function.
|
|
28
|
+
*
|
|
29
|
+
* - `schema.ImportStatePassthroughContext` => bare resource ID
|
|
30
|
+
* - Custom function => look up the function body and parse
|
|
31
|
+
* `strings.Split(d.Id(), "/")` style patterns to infer parts.
|
|
32
|
+
*/
|
|
33
|
+
private deriveImportIdParts;
|
|
34
|
+
private findFuncBody;
|
|
35
|
+
/**
|
|
36
|
+
* Best-effort parsing of an import state function body.
|
|
37
|
+
* Recognises two common patterns:
|
|
38
|
+
*
|
|
39
|
+
* 1. `parts := strings.Split(d.Id(), "/")`
|
|
40
|
+
* followed by length check and `d.Set("field", parts[i])` calls.
|
|
41
|
+
*
|
|
42
|
+
* 2. `parts := strings.SplitN(d.Id(), "/", N)`
|
|
43
|
+
* same downstream pattern.
|
|
44
|
+
*/
|
|
45
|
+
private parseImportIdFromFuncBody;
|
|
46
|
+
private isIdentifier;
|
|
47
|
+
private findStringSliceByIdentifier;
|
|
48
|
+
private parseStringSliceLiteral;
|
|
49
|
+
private extractStringLiterals;
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=semantic-normalizer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"semantic-normalizer.d.ts","sourceRoot":"","sources":["../../../../src/tools/ast-parser/go/semantic-normalizer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAIR,cAAc,EAKjB,MAAM,SAAS,CAAC;AAWjB;;;GAGG;AACH,qBAAa,iCAAiC;IACnC,gBAAgB,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,cAAc,EAAE,GAAG,cAAc,EAAE;IAI/E,eAAe,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,cAAc,GAAG,cAAc;IA6ChF,OAAO,CAAC,iBAAiB;IAmBzB,OAAO,CAAC,qBAAqB;IAc7B,OAAO,CAAC,oBAAoB;IAM5B;;;;OAIG;IACH,OAAO,CAAC,iBAAiB;IAsBzB,OAAO,CAAC,+BAA+B;IAgBvC,OAAO,CAAC,mCAAmC;IAgB3C;;;;OAIG;IACH,OAAO,CAAC,yBAAyB;IAkBjC;;;;;;OAMG;IACH,OAAO,CAAC,mBAAmB;IAmB3B,OAAO,CAAC,YAAY;IA8BpB;;;;;;;;;OASG;IACH,OAAO,CAAC,yBAAyB;IAmCjC,OAAO,CAAC,YAAY;IAIpB,OAAO,CAAC,2BAA2B;IAWnC,OAAO,CAAC,uBAAuB;IAM/B,OAAO,CAAC,qBAAqB;CAShC"}
|