timonel 2.2.0 → 2.4.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.
Files changed (77) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/README.md +5 -1
  3. package/SECURITY.md +15 -8
  4. package/dist/cli.js +29 -31
  5. package/dist/cli.js.map +1 -1
  6. package/dist/index.d.ts +7 -2
  7. package/dist/index.d.ts.map +1 -1
  8. package/dist/index.js +7 -2
  9. package/dist/index.js.map +1 -1
  10. package/dist/lib/helm.d.ts +200 -12
  11. package/dist/lib/helm.d.ts.map +1 -1
  12. package/dist/lib/helm.js +234 -13
  13. package/dist/lib/helm.js.map +1 -1
  14. package/dist/lib/helmChartWriter.d.ts +238 -0
  15. package/dist/lib/helmChartWriter.d.ts.map +1 -0
  16. package/dist/lib/helmChartWriter.js +318 -0
  17. package/dist/lib/helmChartWriter.js.map +1 -0
  18. package/dist/lib/resources/autoscaling/autoscalingResources.d.ts +26 -0
  19. package/dist/lib/resources/autoscaling/autoscalingResources.d.ts.map +1 -0
  20. package/dist/lib/resources/autoscaling/autoscalingResources.js +35 -0
  21. package/dist/lib/resources/autoscaling/autoscalingResources.js.map +1 -0
  22. package/dist/lib/resources/baseResourceProvider.d.ts +47 -0
  23. package/dist/lib/resources/baseResourceProvider.d.ts.map +1 -0
  24. package/dist/lib/resources/baseResourceProvider.js +83 -0
  25. package/dist/lib/resources/baseResourceProvider.js.map +1 -0
  26. package/dist/lib/resources/cloud/aws/awsResources.d.ts +165 -0
  27. package/dist/lib/resources/cloud/aws/awsResources.d.ts.map +1 -0
  28. package/dist/lib/resources/cloud/aws/awsResources.js +187 -0
  29. package/dist/lib/resources/cloud/aws/awsResources.js.map +1 -0
  30. package/dist/lib/resources/cloud/azure/azureResources.d.ts +169 -0
  31. package/dist/lib/resources/cloud/azure/azureResources.d.ts.map +1 -0
  32. package/dist/lib/resources/cloud/azure/azureResources.js +218 -0
  33. package/dist/lib/resources/cloud/azure/azureResources.js.map +1 -0
  34. package/dist/lib/resources/cloud/gcp/gcpResources.d.ts +133 -0
  35. package/dist/lib/resources/cloud/gcp/gcpResources.d.ts.map +1 -0
  36. package/dist/lib/resources/cloud/gcp/gcpResources.js +162 -0
  37. package/dist/lib/resources/cloud/gcp/gcpResources.js.map +1 -0
  38. package/dist/lib/resources/core/coreResources.d.ts +584 -0
  39. package/dist/lib/resources/core/coreResources.d.ts.map +1 -0
  40. package/dist/lib/resources/core/coreResources.js +796 -0
  41. package/dist/lib/resources/core/coreResources.js.map +1 -0
  42. package/dist/lib/resources/core/storageResources.d.ts +133 -0
  43. package/dist/lib/resources/core/storageResources.d.ts.map +1 -0
  44. package/dist/lib/resources/core/storageResources.js +120 -0
  45. package/dist/lib/resources/core/storageResources.js.map +1 -0
  46. package/dist/lib/resources/validation/validationResources.d.ts +26 -0
  47. package/dist/lib/resources/validation/validationResources.d.ts.map +1 -0
  48. package/dist/lib/resources/validation/validationResources.js +33 -0
  49. package/dist/lib/resources/validation/validationResources.js.map +1 -0
  50. package/dist/lib/rutter.d.ts +554 -0
  51. package/dist/lib/rutter.d.ts.map +1 -0
  52. package/dist/lib/rutter.js +665 -0
  53. package/dist/lib/rutter.js.map +1 -0
  54. package/dist/lib/security.d.ts +73 -0
  55. package/dist/lib/security.d.ts.map +1 -0
  56. package/dist/lib/security.js +138 -0
  57. package/dist/lib/security.js.map +1 -0
  58. package/dist/lib/umbrella.d.ts +22 -2
  59. package/dist/lib/umbrella.d.ts.map +1 -1
  60. package/dist/lib/umbrella.js +21 -1
  61. package/dist/lib/umbrella.js.map +1 -1
  62. package/dist/lib/umbrellaRutter.d.ts +97 -0
  63. package/dist/lib/umbrellaRutter.d.ts.map +1 -0
  64. package/dist/lib/{UmbrellaRutter.js → umbrellaRutter.js} +72 -23
  65. package/dist/lib/umbrellaRutter.js.map +1 -0
  66. package/package.json +2 -1
  67. package/dist/lib/HelmChartWriter.d.ts +0 -69
  68. package/dist/lib/HelmChartWriter.d.ts.map +0 -1
  69. package/dist/lib/HelmChartWriter.js +0 -124
  70. package/dist/lib/HelmChartWriter.js.map +0 -1
  71. package/dist/lib/Rutter.d.ts +0 -1334
  72. package/dist/lib/Rutter.d.ts.map +0 -1
  73. package/dist/lib/Rutter.js +0 -2138
  74. package/dist/lib/Rutter.js.map +0 -1
  75. package/dist/lib/UmbrellaRutter.d.ts +0 -34
  76. package/dist/lib/UmbrellaRutter.d.ts.map +0 -1
  77. package/dist/lib/UmbrellaRutter.js.map +0 -1
package/dist/lib/helm.js CHANGED
@@ -1,24 +1,127 @@
1
1
  /**
2
- * Helpers to embed Helm template expressions while staying type-safe in TS.
2
+ * @fileoverview Helpers to embed Helm template expressions while staying type-safe in TypeScript.
3
3
  * We treat Helm placeholders as opaque strings that will be preserved in YAML.
4
+ * @since 0.1.0
5
+ */
6
+ import { SecurityUtils } from './security.js';
7
+ /**
8
+ * Creates a reference to a value in .Values of Helm
9
+ *
10
+ * Generates a Helm template expression that references a value
11
+ * in the chart's values.yaml file using dot notation.
12
+ *
13
+ * @param {string} path - Path to the value using dot notation (e.g., 'image.tag')
14
+ * @returns {string} Helm template expression (e.g., '{{ .Values.image.tag }}')
15
+ * @throws {Error} If the path is not valid for Helm templates
16
+ *
17
+ * @example
18
+ * ```typescript
19
+ * const imageTag = valuesRef('image.tag');
20
+ * // Returns: '{{ .Values.image.tag }}'
21
+ *
22
+ * const replicas = valuesRef('deployment.replicas');
23
+ * // Returns: '{{ .Values.deployment.replicas }}'
24
+ * ```
25
+ *
26
+ * @since 0.1.0
4
27
  */
5
- /** Create a .Values reference like {{ .Values.key }} */
6
28
  export function valuesRef(path) {
29
+ if (!isValidHelmPath(path)) {
30
+ throw new Error(`Invalid Helm template path: ${path}`);
31
+ }
7
32
  return `{{ .Values.${path} }}`;
8
33
  }
9
- /** Create a required .Values reference with default: {{ required msg .Values.key }} */
34
+ /**
35
+ * Creates a required reference to a value in .Values of Helm
36
+ *
37
+ * Similar to valuesRef, but uses Helm's 'required' function to
38
+ * ensure the value is present, failing chart rendering if not provided.
39
+ *
40
+ * @param {string} path - Path to the value using dot notation
41
+ * @param {string} [message] - Custom error message if value is missing
42
+ * @returns {string} Helm template expression with required validation
43
+ * @throws {Error} If the path is not valid for Helm templates
44
+ *
45
+ * @example
46
+ * ```typescript
47
+ * const dbPassword = requiredValuesRef('database.password', 'Database password is required');
48
+ * // Returns: '{{ required "Database password is required" .Values.database.password }}'
49
+ *
50
+ * const apiKey = requiredValuesRef('api.key');
51
+ * // Returns: '{{ required "api.key is required" .Values.api.key }}'
52
+ * ```
53
+ *
54
+ * @since 0.1.0
55
+ */
10
56
  export function requiredValuesRef(path, message) {
57
+ if (!isValidHelmPath(path)) {
58
+ throw new Error(`Invalid Helm template path: ${path}`);
59
+ }
11
60
  const msg = message ?? `${path} is required`;
12
- return `{{ required "${msg}" .Values.${path} }}`;
61
+ // Escape quotes and backslashes in message to prevent template injection
62
+ const escapedMsg = msg.replace(/\\/g, '\\\\').replace(/"/g, '\\"');
63
+ return `{{ required "${escapedMsg}" .Values.${path} }}`;
64
+ }
65
+ /**
66
+ * Validates Helm template path syntax with enhanced security
67
+ *
68
+ * @private
69
+ * @param {string} path - Path to validate
70
+ * @returns {boolean} True if path is valid for Helm templates
71
+ * @since 0.1.0
72
+ */
73
+ function isValidHelmPath(path) {
74
+ // Use centralized validation from SecurityUtils
75
+ return SecurityUtils.isValidHelmTemplatePath(path);
13
76
  }
14
- /** Built-in Helm references */
77
+ /**
78
+ * Built-in Helm references for release and chart metadata
79
+ *
80
+ * Object containing the most common references to Helm's built-in
81
+ * variables for release and chart information.
82
+ *
83
+ * @namespace helm
84
+ * @since 0.1.0
85
+ *
86
+ * @example
87
+ * ```typescript
88
+ * const deploymentName = `${helm.releaseName}-deployment`;
89
+ * // Uses: '{{ .Release.Name }}-deployment'
90
+ *
91
+ * const version = helm.chartVersion;
92
+ * // Uses: '{{ .Chart.Version }}'
93
+ * ```
94
+ */
15
95
  export const helm = {
96
+ /** Release name: {{ .Release.Name }} */
16
97
  releaseName: '{{ .Release.Name }}',
98
+ /** Chart name: {{ .Chart.Name }} */
17
99
  chartName: '{{ .Chart.Name }}',
100
+ /** Chart version: {{ .Chart.Version }} */
18
101
  chartVersion: '{{ .Chart.Version }}',
102
+ /** Release namespace: {{ .Release.Namespace }} */
19
103
  namespace: '{{ .Release.Namespace }}',
20
104
  };
21
- /** Quote a Helm template expression for safe YAML embedding */
105
+ /**
106
+ * Quotes a Helm template expression for safe YAML embedding
107
+ *
108
+ * Ensures Helm template expressions are properly quoted to avoid
109
+ * YAML parsing issues when the expression contains special characters.
110
+ *
111
+ * @param {string} expr - Helm template expression to quote
112
+ * @returns {string} Quoted expression if it's a Helm template, otherwise unchanged
113
+ *
114
+ * @example
115
+ * ```typescript
116
+ * const quoted = quote('{{ .Values.image.tag }}');
117
+ * // Returns: "'{{ .Values.image.tag }}'"
118
+ *
119
+ * const normal = quote('nginx:1.21');
120
+ * // Returns: "nginx:1.21"
121
+ * ```
122
+ *
123
+ * @since 0.1.0
124
+ */
22
125
  export function quote(expr) {
23
126
  // ensure Helm templates are quoted to avoid YAML parsing issues
24
127
  if (expr.startsWith('{{') && expr.endsWith('}}')) {
@@ -26,7 +129,24 @@ export function quote(expr) {
26
129
  }
27
130
  return expr;
28
131
  }
29
- /** Indent helper matching Helm indent fn: {{- n indent -}} */
132
+ /**
133
+ * Indents text by specified number of spaces
134
+ *
135
+ * Helper function that matches Helm's indent function behavior,
136
+ * adding the specified number of spaces to each non-empty line.
137
+ *
138
+ * @param {number} n - Number of spaces to indent
139
+ * @param {string} expr - Text to indent
140
+ * @returns {string} Indented text
141
+ *
142
+ * @example
143
+ * ```typescript
144
+ * const indented = indent(4, 'line1\nline2');
145
+ * // Returns: " line1\n line2"
146
+ * ```
147
+ *
148
+ * @since 0.1.0
149
+ */
30
150
  export function indent(n, expr) {
31
151
  const spaces = ' '.repeat(n);
32
152
  return expr
@@ -34,28 +154,129 @@ export function indent(n, expr) {
34
154
  .map((l) => (l.trim().length ? spaces + l : l))
35
155
  .join('\n');
36
156
  }
37
- /** Insert a call to a named Helm template: {{ template "name" . }} */
157
+ /**
158
+ * Inserts a call to a named Helm template using template function
159
+ *
160
+ * @param {string} name - Name of the template to call
161
+ * @param {string} [context='.'] - Context to pass to the template
162
+ * @returns {string} Helm template expression
163
+ *
164
+ * @example
165
+ * ```typescript
166
+ * const tmpl = template('myapp.labels');
167
+ * // Returns: '{{ template "myapp.labels" . }}'
168
+ * ```
169
+ *
170
+ * @since 0.1.0
171
+ */
38
172
  export function template(name, context = '.') {
39
173
  return `{{ template "${name}" ${context} }}`;
40
174
  }
41
- /** Insert a call to a named Helm template using include: {{ include "name" . }} */
175
+ /**
176
+ * Inserts a call to a named Helm template using include function
177
+ *
178
+ * Preferred over template() as include allows piping and better error handling.
179
+ *
180
+ * @param {string} name - Name of the template to include
181
+ * @param {string} [context='.'] - Context to pass to the template
182
+ * @returns {string} Helm template expression
183
+ *
184
+ * @example
185
+ * ```typescript
186
+ * const tmpl = include('myapp.labels');
187
+ * // Returns: '{{ include "myapp.labels" . }}'
188
+ * ```
189
+ *
190
+ * @since 0.1.0
191
+ */
42
192
  export function include(name, context = '.') {
43
193
  return `{{ include "${name}" ${context} }}`;
44
194
  }
45
- /** Numeric value from .Values with int cast: {{ .Values.path | int }} */
195
+ /**
196
+ * Creates a numeric reference from .Values with int cast
197
+ *
198
+ * Generates a Helm template expression that casts the value to integer,
199
+ * truncating any decimal places.
200
+ *
201
+ * @param {string} path - Path to the value using dot notation
202
+ * @returns {string} Helm template expression with int cast
203
+ * @throws {Error} If the path is not valid for Helm templates
204
+ *
205
+ * @example
206
+ * ```typescript
207
+ * const replicas = numberRef('deployment.replicas');
208
+ * // Returns: '{{ .Values.deployment.replicas | int }}'
209
+ * ```
210
+ *
211
+ * @since 0.1.0
212
+ */
46
213
  export function numberRef(path) {
214
+ if (!isValidHelmPath(path)) {
215
+ throw new Error(`Invalid Helm template path: ${path}`);
216
+ }
47
217
  return `{{ .Values.${path} | int }}`;
48
218
  }
49
- /** Boolean value from .Values with toBool cast: {{ .Values.path | toBool }} */
219
+ /**
220
+ * Creates a boolean reference from .Values with toBool cast
221
+ *
222
+ * @param {string} path - Path to the value using dot notation
223
+ * @returns {string} Helm template expression with toBool cast
224
+ * @throws {Error} If the path is not valid for Helm templates
225
+ *
226
+ * @example
227
+ * ```typescript
228
+ * const enabled = boolRef('feature.enabled');
229
+ * // Returns: '{{ .Values.feature.enabled | toBool }}'
230
+ * ```
231
+ *
232
+ * @since 0.1.0
233
+ */
50
234
  export function boolRef(path) {
235
+ if (!isValidHelmPath(path)) {
236
+ throw new Error(`Invalid Helm template path: ${path}`);
237
+ }
51
238
  return `{{ .Values.${path} | toBool }}`;
52
239
  }
53
- /** String value from .Values with toString cast: {{ .Values.path | toString }} */
240
+ /**
241
+ * Creates a string reference from .Values with toString cast
242
+ *
243
+ * @param {string} path - Path to the value using dot notation
244
+ * @returns {string} Helm template expression with toString cast
245
+ * @throws {Error} If the path is not valid for Helm templates
246
+ *
247
+ * @example
248
+ * ```typescript
249
+ * const version = stringRef('app.version');
250
+ * // Returns: '{{ .Values.app.version | toString }}'
251
+ * ```
252
+ *
253
+ * @since 0.1.0
254
+ */
54
255
  export function stringRef(path) {
256
+ if (!isValidHelmPath(path)) {
257
+ throw new Error(`Invalid Helm template path: ${path}`);
258
+ }
55
259
  return `{{ .Values.${path} | toString }}`;
56
260
  }
57
- /** Float value from .Values with float64 cast: {{ .Values.path | float64 }} */
261
+ /**
262
+ * Creates a float reference from .Values with float64 cast
263
+ *
264
+ * @param {string} path - Path to the value using dot notation
265
+ * @returns {string} Helm template expression with float64 cast
266
+ * @throws {Error} If the path is not valid for Helm templates
267
+ *
268
+ * @example
269
+ * ```typescript
270
+ * const ratio = floatRef('scaling.ratio');
271
+ * // Returns: '{{ .Values.scaling.ratio | float64 }}'
272
+ * ```
273
+ *
274
+ * @since 0.1.0
275
+ */
58
276
  export function floatRef(path) {
277
+ if (!isValidHelmPath(path)) {
278
+ throw new Error(`Invalid Helm template path: ${path}`);
279
+ }
59
280
  return `{{ .Values.${path} | float64 }}`;
60
281
  }
61
282
  //# sourceMappingURL=helm.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"helm.js","sourceRoot":"","sources":["../../src/lib/helm.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,wDAAwD;AACxD,MAAM,UAAU,SAAS,CAAC,IAAY;IACpC,OAAO,cAAc,IAAI,KAAK,CAAC;AACjC,CAAC;AAED,uFAAuF;AACvF,MAAM,UAAU,iBAAiB,CAAC,IAAY,EAAE,OAAgB;IAC9D,MAAM,GAAG,GAAG,OAAO,IAAI,GAAG,IAAI,cAAc,CAAC;IAC7C,OAAO,gBAAgB,GAAG,aAAa,IAAI,KAAK,CAAC;AACnD,CAAC;AAED,+BAA+B;AAC/B,MAAM,CAAC,MAAM,IAAI,GAAG;IAClB,WAAW,EAAE,qBAAqB;IAClC,SAAS,EAAE,mBAAmB;IAC9B,YAAY,EAAE,sBAAsB;IACpC,SAAS,EAAE,0BAA0B;CACtC,CAAC;AAEF,+DAA+D;AAC/D,MAAM,UAAU,KAAK,CAAC,IAAY;IAChC,gEAAgE;IAChE,IAAI,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;QACjD,OAAO,IAAI,IAAI,GAAG,CAAC;IACrB,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,8DAA8D;AAC9D,MAAM,UAAU,MAAM,CAAC,CAAS,EAAE,IAAY;IAC5C,MAAM,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IAC7B,OAAO,IAAI;SACR,KAAK,CAAC,IAAI,CAAC;SACX,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,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;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,QAAQ,CAAC,IAAY;IACnC,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,EAAE,CAAC;QAC3B,MAAM,IAAI,KAAK,CAAC,+BAA+B,IAAI,EAAE,CAAC,CAAC;IACzD,CAAC;IACD,OAAO,cAAc,IAAI,eAAe,CAAC;AAC3C,CAAC"}
@@ -0,0 +1,238 @@
1
+ /**
2
+ * @fileoverview Helm chart writer for generating complete Helm chart structures
3
+ * @since 1.0.0
4
+ */
5
+ /**
6
+ * Metadata for a Helm chart
7
+ *
8
+ * Contains all the information needed for Chart.yaml file generation
9
+ * following Helm chart specification.
10
+ *
11
+ * @interface HelmChartMeta
12
+ * @since 1.0.0
13
+ */
14
+ export interface HelmChartMeta {
15
+ /** Chart name */
16
+ name: string;
17
+ /** SemVer chart version */
18
+ version: string;
19
+ /** Chart description */
20
+ description?: string;
21
+ /** Underlying application version */
22
+ appVersion?: string;
23
+ /** Chart type */
24
+ type?: 'application' | 'library';
25
+ /** Kubernetes version constraint */
26
+ kubeVersion?: string;
27
+ /** Chart keywords for searchability */
28
+ keywords?: string[];
29
+ /** Chart home page URL */
30
+ home?: string;
31
+ /** Source code URLs */
32
+ sources?: string[];
33
+ /** Chart maintainers */
34
+ maintainers?: {
35
+ name: string;
36
+ email?: string;
37
+ url?: string;
38
+ }[];
39
+ /** Chart icon URL */
40
+ icon?: string;
41
+ /** Chart dependencies */
42
+ dependencies?: Array<{
43
+ name: string;
44
+ version: string;
45
+ repository: string;
46
+ alias?: string;
47
+ condition?: string | string[];
48
+ tags?: string[];
49
+ importValues?: unknown;
50
+ }>;
51
+ }
52
+ /**
53
+ * Environment-specific values mapping
54
+ *
55
+ * @interface EnvValuesMap
56
+ * @since 1.0.0
57
+ */
58
+ export interface EnvValuesMap {
59
+ [env: string]: Record<string, unknown>;
60
+ }
61
+ /**
62
+ * Synthesized Kubernetes asset for Helm chart
63
+ *
64
+ * Represents a Kubernetes manifest that will be written to the chart's
65
+ * templates or crds directory.
66
+ *
67
+ * @interface SynthAsset
68
+ * @since 1.0.0
69
+ */
70
+ export interface SynthAsset {
71
+ /** Filename or logical identifier */
72
+ id: string;
73
+ /** YAML content, may contain multiple documents separated by --- */
74
+ yaml: string;
75
+ /** Target directory inside chart */
76
+ target?: 'templates' | 'crds';
77
+ /** If true, don't split into multiple files even with multiple docs */
78
+ singleFile?: boolean;
79
+ }
80
+ /**
81
+ * Options for writing a complete Helm chart
82
+ *
83
+ * @interface HelmChartWriteOptions
84
+ * @since 1.0.0
85
+ */
86
+ export interface HelmChartWriteOptions {
87
+ /** Output directory path (e.g., dist/charts/my-chart) */
88
+ outDir: string;
89
+ /** Chart metadata */
90
+ meta: HelmChartMeta;
91
+ /** Default values for values.yaml */
92
+ defaultValues?: Record<string, unknown> | undefined;
93
+ /** Environment-specific values (e.g., { dev: {...}, prod: {...} }) */
94
+ envValues?: EnvValuesMap | undefined;
95
+ /** Kubernetes manifests to place under templates/ */
96
+ assets: SynthAsset[];
97
+ /** Helm helpers content for templates/_helpers.tpl */
98
+ helpersTpl?: string | HelperDefinition[];
99
+ /** NOTES.txt content under templates/ */
100
+ notesTpl?: string;
101
+ /** JSON schema for values validation */
102
+ valuesSchema?: Record<string, unknown>;
103
+ }
104
+ /**
105
+ * Helm template helper definition
106
+ *
107
+ * @interface HelperDefinition
108
+ * @since 1.0.0
109
+ */
110
+ export interface HelperDefinition {
111
+ /** Template name */
112
+ name: string;
113
+ /** Template body content */
114
+ body: string;
115
+ }
116
+ /**
117
+ * Helm chart writer for generating complete chart structures
118
+ *
119
+ * This class provides static methods to generate a complete Helm chart
120
+ * including Chart.yaml, values.yaml, templates, and auxiliary files.
121
+ *
122
+ * @class HelmChartWriter
123
+ * @since 1.0.0
124
+ *
125
+ * @example
126
+ * ```typescript
127
+ * HelmChartWriter.write({
128
+ * outDir: './dist/my-chart',
129
+ * meta: { name: 'my-app', version: '1.0.0' },
130
+ * assets: []
131
+ * });
132
+ * ```
133
+ */
134
+ export declare class HelmChartWriter {
135
+ /**
136
+ * Writes a complete Helm chart to the specified directory
137
+ *
138
+ * Creates the full directory structure and writes all necessary files
139
+ * for a valid Helm chart including Chart.yaml, values files, templates,
140
+ * and auxiliary files.
141
+ *
142
+ * @param {HelmChartWriteOptions} opts - Chart configuration options
143
+ * @throws {Error} If output directory path is invalid
144
+ * @throws {Error} If chart metadata is invalid
145
+ *
146
+ * @example
147
+ * ```typescript
148
+ * HelmChartWriter.write({
149
+ * outDir: './charts/my-app',
150
+ * meta: {
151
+ * name: 'my-app',
152
+ * version: '1.0.0',
153
+ * description: 'My application'
154
+ * },
155
+ * defaultValues: { replicas: 3 },
156
+ * assets: []
157
+ * });
158
+ * ```
159
+ *
160
+ * @since 1.0.0
161
+ */
162
+ static write(opts: HelmChartWriteOptions): void;
163
+ /**
164
+ * Creates the necessary directory structure for the chart
165
+ *
166
+ * @private
167
+ * @param {string} outDir - Output directory path
168
+ * @throws {Error} If directories cannot be created
169
+ * @since 1.0.0
170
+ */
171
+ private static createDirectories;
172
+ /**
173
+ * Writes the Chart.yaml file with chart metadata
174
+ *
175
+ * @private
176
+ * @param {string} outDir - Output directory path
177
+ * @param {HelmChartMeta} meta - Chart metadata
178
+ * @throws {Error} If Chart.yaml cannot be written
179
+ * @since 1.0.0
180
+ */
181
+ private static writeChartYaml;
182
+ /**
183
+ * Writes values.yaml and environment-specific values files
184
+ *
185
+ * @private
186
+ * @param {string} outDir - Output directory path
187
+ * @param {Record<string, unknown>} defaultValues - Default values
188
+ * @param {EnvValuesMap} envValues - Environment-specific values
189
+ * @throws {Error} If values files cannot be written
190
+ * @since 1.0.0
191
+ */
192
+ private static writeValuesFiles;
193
+ /**
194
+ * Writes Kubernetes manifest assets to templates directory
195
+ *
196
+ * @private
197
+ * @param {string} outDir - Output directory path
198
+ * @param {SynthAsset[]} assets - Kubernetes manifests to write
199
+ * @since 1.0.0
200
+ */
201
+ private static writeAssets;
202
+ /**
203
+ * Writes Helm template helpers to _helpers.tpl file
204
+ *
205
+ * @private
206
+ * @param {string} outDir - Output directory path
207
+ * @param {string | HelperDefinition[]} [helpersTpl] - Helpers content
208
+ * @since 1.0.0
209
+ */
210
+ private static writeHelpers;
211
+ /**
212
+ * Writes NOTES.txt file for post-install instructions
213
+ *
214
+ * @private
215
+ * @param {string} outDir - Output directory path
216
+ * @param {string} [notesTpl] - Notes content
217
+ * @since 1.0.0
218
+ */
219
+ private static writeNotes;
220
+ /**
221
+ * Writes values.schema.json for values validation
222
+ *
223
+ * @private
224
+ * @param {string} outDir - Output directory path
225
+ * @param {Record<string, unknown>} [valuesSchema] - JSON schema
226
+ * @since 1.0.0
227
+ */
228
+ private static writeSchema;
229
+ /**
230
+ * Writes .helmignore file with common ignore patterns
231
+ *
232
+ * @private
233
+ * @param {string} outDir - Output directory path
234
+ * @since 1.0.0
235
+ */
236
+ private static writeHelmIgnore;
237
+ }
238
+ //# sourceMappingURL=helmChartWriter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helmChartWriter.d.ts","sourceRoot":"","sources":["../../src/lib/helmChartWriter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AASH;;;;;;;;GAQG;AACH,MAAM,WAAW,aAAa;IAC5B,iBAAiB;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,2BAA2B;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,wBAAwB;IACxB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,qCAAqC;IACrC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,iBAAiB;IACjB,IAAI,CAAC,EAAE,aAAa,GAAG,SAAS,CAAC;IACjC,oCAAoC;IACpC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,uCAAuC;IACvC,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,0BAA0B;IAC1B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,uBAAuB;IACvB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,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