@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/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 * as aws from "@intentius/chant-lexicon-aws";
97
- import * as _ from "./_";
95
+ import { Bucket, Sub, AWS } from "@intentius/chant-lexicon-aws";
96
+ import { versioningEnabled, bucketEncryption, publicAccessBlock } from "./config";
98
97
 
99
- export const dataBucket = new aws.Bucket({
100
- bucketName: aws.Sub\`\${aws.AWS.StackName}-data\`,
101
- versioningConfiguration: _.versioningEnabled,
102
- bucketEncryption: _.bucketEncryption,
103
- publicAccessBlockConfiguration: _.publicAccessBlock,
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 * as aws from "@intentius/chant-lexicon-aws";
111
- import * as _ from "./_";
109
+ import { Bucket, Sub, AWS } from "@intentius/chant-lexicon-aws";
110
+ import { versioningEnabled, bucketEncryption, publicAccessBlock } from "./config";
112
111
 
113
- export const logsBucket = new aws.Bucket({
114
- bucketName: aws.Sub\`\${aws.AWS.StackName}-logs\`,
112
+ export const logsBucket = new Bucket({
113
+ bucketName: Sub\`\${AWS.StackName}-logs\`,
115
114
  accessControl: "LogDeliveryWrite",
116
- versioningConfiguration: _.versioningEnabled,
117
- bucketEncryption: _.bucketEncryption,
118
- publicAccessBlockConfiguration: _.publicAccessBlock,
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 { writeFileSync, mkdirSync } = await import("fs");
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
- mkdirSync(join(distDir, "types"), { recursive: true });
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 barrel files** — Put common settings in \`_.ts\` and import as \`* as _\`
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
- cfnType: string;
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
- cfnType: defName,
133
+ specType: defName,
134
134
  properties: defProps,
135
135
  });
136
136
  }