@intentius/chant-lexicon-aws 0.0.5 → 0.0.6
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/README.md +9 -425
- package/dist/integrity.json +5 -5
- package/dist/manifest.json +1 -1
- package/dist/meta.json +70 -9
- package/dist/skills/aws-cloudformation.md +1 -1
- package/dist/types/index.d.ts +115 -11
- package/package.json +2 -2
- package/src/codegen/docs.ts +48 -348
- package/src/codegen/generate.ts +1 -1
- package/src/codegen/sam.ts +11 -11
- package/src/generated/index.d.ts +115 -11
- package/src/generated/index.ts +6 -1
- package/src/generated/lexicon-aws.json +70 -9
- package/src/import/roundtrip-fixtures.test.ts +6 -27
- package/src/plugin.ts +19 -48
- package/src/spec/parse.ts +2 -2
package/src/plugin.ts
CHANGED
|
@@ -54,7 +54,6 @@ export const awsPlugin: LexiconPlugin = {
|
|
|
54
54
|
|
|
55
55
|
initTemplates(): Record<string, string> {
|
|
56
56
|
return {
|
|
57
|
-
"_.ts": `export * from "./config";\n`,
|
|
58
57
|
"config.ts": `/**
|
|
59
58
|
* Shared bucket configuration — encryption, versioning, public access
|
|
60
59
|
*/
|
|
@@ -93,29 +92,29 @@ export const versioningEnabled = new aws.VersioningConfiguration({
|
|
|
93
92
|
* Data bucket — primary storage with encryption and versioning
|
|
94
93
|
*/
|
|
95
94
|
|
|
96
|
-
import
|
|
97
|
-
import
|
|
95
|
+
import { Bucket, Sub, AWS } from "@intentius/chant-lexicon-aws";
|
|
96
|
+
import { versioningEnabled, bucketEncryption, publicAccessBlock } from "./config";
|
|
98
97
|
|
|
99
|
-
export const dataBucket = new
|
|
100
|
-
bucketName:
|
|
101
|
-
versioningConfiguration:
|
|
102
|
-
bucketEncryption:
|
|
103
|
-
publicAccessBlockConfiguration:
|
|
98
|
+
export const dataBucket = new Bucket({
|
|
99
|
+
bucketName: Sub\`\${AWS.StackName}-data\`,
|
|
100
|
+
versioningConfiguration: versioningEnabled,
|
|
101
|
+
bucketEncryption: bucketEncryption,
|
|
102
|
+
publicAccessBlockConfiguration: publicAccessBlock,
|
|
104
103
|
});
|
|
105
104
|
`,
|
|
106
105
|
"logs-bucket.ts": `/**
|
|
107
106
|
* Logs bucket — log delivery with encryption and versioning
|
|
108
107
|
*/
|
|
109
108
|
|
|
110
|
-
import
|
|
111
|
-
import
|
|
109
|
+
import { Bucket, Sub, AWS } from "@intentius/chant-lexicon-aws";
|
|
110
|
+
import { versioningEnabled, bucketEncryption, publicAccessBlock } from "./config";
|
|
112
111
|
|
|
113
|
-
export const logsBucket = new
|
|
114
|
-
bucketName:
|
|
112
|
+
export const logsBucket = new Bucket({
|
|
113
|
+
bucketName: Sub\`\${AWS.StackName}-logs\`,
|
|
115
114
|
accessControl: "LogDeliveryWrite",
|
|
116
|
-
versioningConfiguration:
|
|
117
|
-
bucketEncryption:
|
|
118
|
-
publicAccessBlockConfiguration:
|
|
115
|
+
versioningConfiguration: versioningEnabled,
|
|
116
|
+
bucketEncryption: bucketEncryption,
|
|
117
|
+
publicAccessBlockConfiguration: publicAccessBlock,
|
|
119
118
|
});
|
|
120
119
|
`,
|
|
121
120
|
};
|
|
@@ -185,18 +184,9 @@ export const logsBucket = new aws.Bucket({
|
|
|
185
184
|
|
|
186
185
|
async validate(options?: { verbose?: boolean }): Promise<void> {
|
|
187
186
|
const { validate } = await import("./validate");
|
|
187
|
+
const { printValidationResult } = await import("@intentius/chant/codegen/validate");
|
|
188
188
|
const result = await validate();
|
|
189
|
-
|
|
190
|
-
for (const check of result.checks) {
|
|
191
|
-
const status = check.ok ? "OK" : "FAIL";
|
|
192
|
-
const msg = check.error ? ` — ${check.error}` : "";
|
|
193
|
-
console.error(` [${status}] ${check.name}${msg}`);
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
if (!result.success) {
|
|
197
|
-
throw new Error("Validation failed");
|
|
198
|
-
}
|
|
199
|
-
console.error("All validation checks passed.");
|
|
189
|
+
printValidationResult(result);
|
|
200
190
|
},
|
|
201
191
|
|
|
202
192
|
async coverage(options?: { verbose?: boolean; minOverall?: number }): Promise<void> {
|
|
@@ -227,34 +217,15 @@ export const logsBucket = new aws.Bucket({
|
|
|
227
217
|
|
|
228
218
|
async package(options?: { verbose?: boolean; force?: boolean }): Promise<void> {
|
|
229
219
|
const { packageLexicon } = await import("./codegen/package");
|
|
230
|
-
const {
|
|
220
|
+
const { writeBundleSpec } = await import("@intentius/chant/codegen/package");
|
|
231
221
|
const { join, dirname } = await import("path");
|
|
232
222
|
const { fileURLToPath } = await import("url");
|
|
233
223
|
|
|
234
224
|
const { spec, stats } = await packageLexicon({ verbose: options?.verbose, force: options?.force });
|
|
235
225
|
|
|
236
|
-
// Write manifest and artifacts to dist/
|
|
237
226
|
const pkgDir = dirname(dirname(fileURLToPath(import.meta.url)));
|
|
238
227
|
const distDir = join(pkgDir, "dist");
|
|
239
|
-
|
|
240
|
-
mkdirSync(join(distDir, "rules"), { recursive: true });
|
|
241
|
-
mkdirSync(join(distDir, "skills"), { recursive: true });
|
|
242
|
-
|
|
243
|
-
writeFileSync(join(distDir, "manifest.json"), JSON.stringify(spec.manifest, null, 2));
|
|
244
|
-
writeFileSync(join(distDir, "meta.json"), spec.registry);
|
|
245
|
-
writeFileSync(join(distDir, "types", "index.d.ts"), spec.typesDTS);
|
|
246
|
-
|
|
247
|
-
for (const [name, content] of spec.rules) {
|
|
248
|
-
writeFileSync(join(distDir, "rules", name), content);
|
|
249
|
-
}
|
|
250
|
-
for (const [name, content] of spec.skills) {
|
|
251
|
-
writeFileSync(join(distDir, "skills", name), content);
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
// Write integrity.json if available
|
|
255
|
-
if (spec.integrity) {
|
|
256
|
-
writeFileSync(join(distDir, "integrity.json"), JSON.stringify(spec.integrity, null, 2));
|
|
257
|
-
}
|
|
228
|
+
writeBundleSpec(spec, distDir);
|
|
258
229
|
|
|
259
230
|
console.error(`Packaged ${stats.resources} resources, ${stats.ruleCount} rules, ${stats.skillCount} skills`);
|
|
260
231
|
|
|
@@ -349,7 +320,7 @@ description: AWS CloudFormation best practices and common patterns
|
|
|
349
320
|
3. **Use least-privilege IAM** — Avoid \`*\` in IAM policy actions and resources
|
|
350
321
|
4. **Enable versioning** — Turn on \`VersioningConfiguration\` for data buckets
|
|
351
322
|
5. **Use Sub for dynamic names** — \`Sub\\\`\\\${AWS::StackName}-suffix\\\`\` for unique naming
|
|
352
|
-
6. **Share config via
|
|
323
|
+
6. **Share config via direct imports** — Put common settings in a config file and import directly
|
|
353
324
|
`,
|
|
354
325
|
triggers: [
|
|
355
326
|
{ type: "file-pattern", value: "**/*.aws.ts" },
|
package/src/spec/parse.ts
CHANGED
|
@@ -36,7 +36,7 @@ export interface ParsedAttribute {
|
|
|
36
36
|
|
|
37
37
|
export interface ParsedPropertyType {
|
|
38
38
|
name: string;
|
|
39
|
-
|
|
39
|
+
specType: string;
|
|
40
40
|
properties: ParsedProperty[];
|
|
41
41
|
}
|
|
42
42
|
|
|
@@ -130,7 +130,7 @@ export function parseCFNSchema(data: string | Buffer): SchemaParseResult {
|
|
|
130
130
|
}
|
|
131
131
|
propertyTypes.push({
|
|
132
132
|
name: `${shortName}_${defName}`,
|
|
133
|
-
|
|
133
|
+
specType: defName,
|
|
134
134
|
properties: defProps,
|
|
135
135
|
});
|
|
136
136
|
}
|