timonel 3.1.1 → 3.1.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 (83) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/README.md +323 -695
  3. package/dist/cli.js +275 -15
  4. package/dist/index.d.ts +5 -1
  5. package/dist/index.js +12 -0
  6. package/dist/lib/helm.d.ts +471 -0
  7. package/dist/lib/helm.js +483 -0
  8. package/dist/lib/helmChartWriter.d.ts +157 -0
  9. package/dist/lib/helmChartWriter.js +171 -1
  10. package/dist/lib/policy/configurationLoader.d.ts +132 -0
  11. package/dist/lib/policy/configurationLoader.js +132 -0
  12. package/dist/lib/policy/errorContextGenerator.d.ts +89 -0
  13. package/dist/lib/policy/errorContextGenerator.js +99 -2
  14. package/dist/lib/policy/errors.d.ts +35 -0
  15. package/dist/lib/policy/errors.js +36 -0
  16. package/dist/lib/policy/index.d.ts +9 -0
  17. package/dist/lib/policy/index.js +16 -0
  18. package/dist/lib/policy/parallelExecutor.d.ts +90 -0
  19. package/dist/lib/policy/parallelExecutor.js +86 -3
  20. package/dist/lib/policy/pluginLoader.d.ts +92 -0
  21. package/dist/lib/policy/pluginLoader.js +92 -1
  22. package/dist/lib/policy/pluginRegistry.d.ts +54 -0
  23. package/dist/lib/policy/pluginRegistry.js +56 -0
  24. package/dist/lib/policy/policyEngine.d.ts +137 -0
  25. package/dist/lib/policy/policyEngine.js +191 -5
  26. package/dist/lib/policy/resultAggregator.d.ts +46 -0
  27. package/dist/lib/policy/resultAggregator.js +69 -1
  28. package/dist/lib/policy/resultFormatter.d.ts +88 -0
  29. package/dist/lib/policy/resultFormatter.js +101 -0
  30. package/dist/lib/policy/types.d.ts +136 -0
  31. package/dist/lib/policy/types.js +8 -0
  32. package/dist/lib/policy/validationCache.d.ts +146 -0
  33. package/dist/lib/policy/validationCache.js +142 -6
  34. package/dist/lib/resources/baseResourceProvider.d.ts +45 -0
  35. package/dist/lib/resources/baseResourceProvider.js +48 -1
  36. package/dist/lib/resources/cloud/aws/awsResources.d.ts +192 -0
  37. package/dist/lib/resources/cloud/aws/awsResources.js +163 -1
  38. package/dist/lib/resources/cloud/aws/karpenterResources.d.ts +131 -0
  39. package/dist/lib/resources/cloud/aws/karpenterResources.js +77 -0
  40. package/dist/lib/rutter.d.ts +381 -3
  41. package/dist/lib/rutter.js +439 -28
  42. package/dist/lib/security.d.ts +123 -0
  43. package/dist/lib/security.js +162 -4
  44. package/dist/lib/templates/flexible-subchart.d.ts +52 -0
  45. package/dist/lib/templates/flexible-subchart.js +70 -0
  46. package/dist/lib/templates/umbrella-chart.d.ts +27 -0
  47. package/dist/lib/templates/umbrella-chart.js +89 -0
  48. package/dist/lib/types.d.ts +26 -0
  49. package/dist/lib/umbrella.d.ts +23 -0
  50. package/dist/lib/umbrella.js +23 -0
  51. package/dist/lib/umbrellaRutter.d.ts +75 -0
  52. package/dist/lib/umbrellaRutter.js +82 -2
  53. package/dist/lib/utils/envVarsLoader.d.ts +49 -0
  54. package/dist/lib/utils/envVarsLoader.js +53 -0
  55. package/dist/lib/utils/helmConstructSerializer.d.ts +17 -0
  56. package/dist/lib/utils/helmConstructSerializer.js +22 -0
  57. package/dist/lib/utils/helmControlStructures.d.ts +194 -0
  58. package/dist/lib/utils/helmControlStructures.js +180 -0
  59. package/dist/lib/utils/helmHelpers/envHelpers.d.ts +13 -0
  60. package/dist/lib/utils/helmHelpers/envHelpers.js +13 -0
  61. package/dist/lib/utils/helmHelpers/gitopsHelpers.d.ts +13 -0
  62. package/dist/lib/utils/helmHelpers/gitopsHelpers.js +13 -0
  63. package/dist/lib/utils/helmHelpers/index.d.ts +74 -0
  64. package/dist/lib/utils/helmHelpers/index.js +85 -1
  65. package/dist/lib/utils/helmHelpers/observabilityHelpers.d.ts +13 -0
  66. package/dist/lib/utils/helmHelpers/observabilityHelpers.js +13 -0
  67. package/dist/lib/utils/helmHelpers/types.d.ts +23 -0
  68. package/dist/lib/utils/helmHelpers/types.js +4 -0
  69. package/dist/lib/utils/helmHelpers/validationHelpers.d.ts +13 -0
  70. package/dist/lib/utils/helmHelpers/validationHelpers.js +13 -0
  71. package/dist/lib/utils/helmHelpers.d.ts +62 -0
  72. package/dist/lib/utils/helmHelpers.js +77 -0
  73. package/dist/lib/utils/helmYamlSerializer.d.ts +77 -0
  74. package/dist/lib/utils/helmYamlSerializer.js +398 -21
  75. package/dist/lib/utils/logger.d.ts +153 -0
  76. package/dist/lib/utils/logger.js +170 -2
  77. package/dist/lib/utils/valuesRef.d.ts +181 -50
  78. package/dist/lib/utils/valuesRef.js +168 -170
  79. package/dist/lib/validation/inputValidator.d.ts +45 -0
  80. package/dist/lib/validation/inputValidator.js +67 -2
  81. package/dist/types/index.d.ts +34 -0
  82. package/dist/types/index.js +3 -0
  83. package/package.json +31 -38
@@ -1,3 +1,8 @@
1
+ /**
2
+ * @fileoverview Main index file for Helm helpers with organized exports and helper management functions
3
+ * @since 2.11.0
4
+ */
5
+ // Export all helper categories
1
6
  export { ENV_HELPERS } from './envHelpers.js';
2
7
  export { GITOPS_HELPERS } from './gitopsHelpers.js';
3
8
  export { OBSERVABILITY_HELPERS } from './observabilityHelpers.js';
@@ -6,23 +11,49 @@ import { ENV_HELPERS } from './envHelpers.js';
6
11
  import { GITOPS_HELPERS } from './gitopsHelpers.js';
7
12
  import { OBSERVABILITY_HELPERS } from './observabilityHelpers.js';
8
13
  import { VALIDATION_HELPERS } from './validationHelpers.js';
14
+ /**
15
+ * Performance-optimized helper management using Map for O(1) lookups
16
+ * @since 2.11.0
17
+ */
9
18
  const HELPER_CATEGORIES = new Map([
10
19
  ['env', ENV_HELPERS],
11
20
  ['gitops', GITOPS_HELPERS],
12
21
  ['observability', OBSERVABILITY_HELPERS],
13
22
  ['validation', VALIDATION_HELPERS],
14
23
  ]);
24
+ /**
25
+ * Cached helper compilation for better performance
26
+ * @since 2.11.0
27
+ */
15
28
  const COMPILED_HELPERS_CACHE = new Map();
29
+ /**
30
+ * Performance-optimized helper lookup with O(1) time complexity
31
+ * @param category - Helper category to retrieve
32
+ * @returns Array of helper definitions for the specified category
33
+ * @throws {Error} If category is unknown
34
+ * @since 2.11.0
35
+ */
16
36
  export function getNewHelpersByCategory(category) {
17
37
  const helpers = HELPER_CATEGORIES.get(category);
18
38
  if (!helpers) {
19
39
  throw new Error(`Unknown helper category: ${category}`);
20
40
  }
21
- return [...helpers];
41
+ return [...helpers]; // Return copy to prevent mutations
22
42
  }
43
+ /**
44
+ * Get all available new helper categories
45
+ * @returns Array of available helper categories
46
+ * @since 2.11.0
47
+ */
23
48
  export function getAvailableHelperCategories() {
24
49
  return Array.from(HELPER_CATEGORIES.keys());
25
50
  }
51
+ /**
52
+ * Get helpers for multiple categories
53
+ * @param categories - Array of categories to retrieve
54
+ * @returns Combined array of helper definitions
55
+ * @since 2.11.0
56
+ */
26
57
  export function getHelpersByCategories(categories) {
27
58
  const helpers = [];
28
59
  for (const category of categories) {
@@ -30,6 +61,12 @@ export function getHelpersByCategories(categories) {
30
61
  }
31
62
  return helpers;
32
63
  }
64
+ /**
65
+ * Get helpers based on options configuration
66
+ * @param options - Configuration options for helper inclusion
67
+ * @returns Array of helper definitions based on options
68
+ * @since 2.11.0
69
+ */
33
70
  export function getHelpersByOptions(options) {
34
71
  const helpers = [];
35
72
  if (options.includeEnv) {
@@ -46,6 +83,12 @@ export function getHelpersByOptions(options) {
46
83
  }
47
84
  return helpers;
48
85
  }
86
+ /**
87
+ * Converts helper definitions to Helm template format
88
+ * @param helpers - Array of helper definitions
89
+ * @returns Formatted Helm template string
90
+ * @since 2.11.0
91
+ */
49
92
  export function formatNewHelpers(helpers) {
50
93
  return helpers
51
94
  .map((helper) => `{{/*
@@ -56,6 +99,13 @@ ${helper.template}
56
99
  {{- end }}`)
57
100
  .join('\n\n');
58
101
  }
102
+ /**
103
+ * Generates complete _helpers.tpl content with new helpers
104
+ * @param options - Configuration options for helper inclusion
105
+ * @param customHelpers - Additional custom helpers
106
+ * @returns Complete helpers template content
107
+ * @since 2.11.0
108
+ */
59
109
  export function generateNewHelpersTemplate(options, customHelpers) {
60
110
  const helpers = [];
61
111
  if (options) {
@@ -66,6 +116,13 @@ export function generateNewHelpersTemplate(options, customHelpers) {
66
116
  }
67
117
  return formatNewHelpers(helpers);
68
118
  }
119
+ /**
120
+ * Cached helper compilation for better performance
121
+ * @param options - Configuration options for helper inclusion
122
+ * @param customHelpers - Additional custom helpers
123
+ * @returns Complete helpers template content from cache or newly generated
124
+ * @since 2.11.0
125
+ */
69
126
  export function getCachedNewHelpersTemplate(options, customHelpers) {
70
127
  const cacheKey = JSON.stringify({ options, customHelpers });
71
128
  if (COMPILED_HELPERS_CACHE.has(cacheKey)) {
@@ -75,9 +132,22 @@ export function getCachedNewHelpersTemplate(options, customHelpers) {
75
132
  COMPILED_HELPERS_CACHE.set(cacheKey, template);
76
133
  return template;
77
134
  }
135
+ /**
136
+ * Creates a custom helper definition
137
+ * @param name - Helper name
138
+ * @param template - Helper template content
139
+ * @returns Helper definition object
140
+ * @since 2.11.0
141
+ */
78
142
  export function createNewHelper(name, template) {
79
143
  return { name, template };
80
144
  }
145
+ /**
146
+ * Validates helper names for Helm compatibility
147
+ * @param helpers - Array of helper definitions to validate
148
+ * @throws {Error} If any helper has an invalid name
149
+ * @since 2.11.0
150
+ */
81
151
  export function validateHelperNames(helpers) {
82
152
  const namePattern = /^[a-zA-Z][a-zA-Z0-9._-]*$/;
83
153
  const duplicates = new Set();
@@ -97,10 +167,24 @@ export function validateHelperNames(helpers) {
97
167
  throw new Error(`Duplicate helper names found: ${Array.from(duplicates).join(', ')}`);
98
168
  }
99
169
  }
170
+ /**
171
+ * Filters helpers by name pattern
172
+ * @param helpers - Array of helper definitions to filter
173
+ * @param pattern - RegExp pattern to match against helper names
174
+ * @returns Filtered array of helper definitions
175
+ * @since 2.11.0
176
+ */
100
177
  export function filterHelpersByPattern(helpers, pattern) {
101
178
  return helpers.filter((helper) => pattern.test(helper.name));
102
179
  }
180
+ /**
181
+ * Gets helper statistics for analysis
182
+ * @param helpers - Array of helper definitions to analyze
183
+ * @returns Statistics about the helpers
184
+ * @since 2.11.0
185
+ */
103
186
  export function getHelperStatistics(helpers) {
187
+ // Use Map to avoid security issues with object injection
104
188
  const categoryMap = new Map();
105
189
  let totalTemplateLength = 0;
106
190
  let longestHelper = '';
@@ -1,2 +1,15 @@
1
+ /**
2
+ * @fileoverview Observability helpers for Helm templates including monitoring, tracing, and logging
3
+ * @since 2.11.0
4
+ */
1
5
  import type { HelperDefinition } from './types.js';
6
+ /**
7
+ * Observability helpers for monitoring, tracing, and logging
8
+ *
9
+ * These helpers provide comprehensive observability patterns for modern cloud-native applications.
10
+ * They support Prometheus monitoring, distributed tracing, structured logging, and health checks
11
+ * following industry best practices for production workloads.
12
+ *
13
+ * @since 2.11.0
14
+ */
2
15
  export declare const OBSERVABILITY_HELPERS: HelperDefinition[];
@@ -1,3 +1,16 @@
1
+ /**
2
+ * @fileoverview Observability helpers for Helm templates including monitoring, tracing, and logging
3
+ * @since 2.11.0
4
+ */
5
+ /**
6
+ * Observability helpers for monitoring, tracing, and logging
7
+ *
8
+ * These helpers provide comprehensive observability patterns for modern cloud-native applications.
9
+ * They support Prometheus monitoring, distributed tracing, structured logging, and health checks
10
+ * following industry best practices for production workloads.
11
+ *
12
+ * @since 2.11.0
13
+ */
1
14
  export const OBSERVABILITY_HELPERS = [
2
15
  {
3
16
  name: 'monitoring.serviceMonitor',
@@ -1,9 +1,32 @@
1
+ /**
2
+ * @fileoverview Base types and interfaces for Helm helpers
3
+ * @since 2.11.0
4
+ */
5
+ /**
6
+ * Helper definition for Helm templates
7
+ * @interface HelperDefinition
8
+ * @since 2.8.0+
9
+ */
1
10
  export interface HelperDefinition {
11
+ /** Helper name (without quotes or hyphens) */
2
12
  name: string;
13
+ /** Helper template content */
3
14
  template: string;
4
15
  }
16
+ /**
17
+ * Helper categories for organization and filtering
18
+ * @since 2.11.0
19
+ */
5
20
  export type HelperCategory = 'standard' | 'fileAccess' | 'templateFunction' | 'sprig' | 'kubernetes' | 'aws' | 'env' | 'gitops' | 'observability' | 'validation';
21
+ /**
22
+ * Cloud provider types for helper selection
23
+ * @since 2.11.0
24
+ */
6
25
  export type CloudProvider = 'aws' | 'azure' | 'gcp';
26
+ /**
27
+ * Options for helper inclusion and configuration
28
+ * @since 2.11.0
29
+ */
7
30
  export interface HelperOptions {
8
31
  includeFileAccess?: boolean;
9
32
  includeTemplateFunction?: boolean;
@@ -1 +1,5 @@
1
+ /**
2
+ * @fileoverview Base types and interfaces for Helm helpers
3
+ * @since 2.11.0
4
+ */
1
5
  export {};
@@ -1,2 +1,15 @@
1
+ /**
2
+ * @fileoverview Validation helpers for Helm templates with type safety and format validation
3
+ * @since 2.11.0
4
+ */
1
5
  import type { HelperDefinition } from './types.js';
6
+ /**
7
+ * Validation helpers for type safety and format validation
8
+ *
9
+ * These helpers provide comprehensive validation for common data types and formats
10
+ * used in Kubernetes and cloud-native applications. They follow security best practices
11
+ * and provide clear error messages for debugging and troubleshooting.
12
+ *
13
+ * @since 2.11.0
14
+ */
2
15
  export declare const VALIDATION_HELPERS: HelperDefinition[];
@@ -1,3 +1,16 @@
1
+ /**
2
+ * @fileoverview Validation helpers for Helm templates with type safety and format validation
3
+ * @since 2.11.0
4
+ */
5
+ /**
6
+ * Validation helpers for type safety and format validation
7
+ *
8
+ * These helpers provide comprehensive validation for common data types and formats
9
+ * used in Kubernetes and cloud-native applications. They follow security best practices
10
+ * and provide clear error messages for debugging and troubleshooting.
11
+ *
12
+ * @since 2.11.0
13
+ */
1
14
  export const VALIDATION_HELPERS = [
2
15
  {
3
16
  name: 'validation.semver',
@@ -1,12 +1,53 @@
1
+ /**
2
+ * @fileoverview Helm chart helpers and templates
3
+ * @since 2.8.0+
4
+ */
1
5
  import type { HelperDefinition } from './helmHelpers/types.js';
2
6
  export type { HelperDefinition } from './helmHelpers/types.js';
7
+ /**
8
+ * Standard Helm chart helpers following best practices
9
+ * @since 2.8.0+
10
+ */
3
11
  export declare const STANDARD_HELPERS: HelperDefinition[];
12
+ /**
13
+ * File access helpers using Helm .Files object
14
+ * @since 2.8.4+
15
+ */
4
16
  export declare const FILE_ACCESS_HELPERS: HelperDefinition[];
17
+ /**
18
+ * Advanced template function helpers
19
+ * @since 2.8.4+
20
+ */
5
21
  export declare const TEMPLATE_FUNCTION_HELPERS: HelperDefinition[];
22
+ /**
23
+ * Sprig library function helpers for common use cases
24
+ * @since 2.8.4+
25
+ */
6
26
  export declare const SPRIG_HELPERS: HelperDefinition[];
27
+ /**
28
+ * Kubernetes-specific helpers for common patterns
29
+ * @since 2.8.4+
30
+ */
7
31
  export declare const KUBERNETES_HELPERS: HelperDefinition[];
32
+ /**
33
+ * AWS-specific Helm helpers
34
+ * @since 2.8.0+
35
+ */
8
36
  export declare const AWS_HELPERS: HelperDefinition[];
37
+ /**
38
+ * Converts helper definitions to Helm template format
39
+ * @param helpers - Array of helper definitions
40
+ * @returns Formatted Helm template string
41
+ * @since 2.8.0+
42
+ */
9
43
  export declare function formatHelpers(helpers: HelperDefinition[]): string;
44
+ /**
45
+ * Gets default helpers based on cloud provider and feature flags
46
+ * @param cloudProvider - Target cloud provider
47
+ * @param options - Configuration options for helper inclusion
48
+ * @returns Combined standard and cloud-specific helpers
49
+ * @since 2.8.4+
50
+ */
10
51
  export declare function getDefaultHelpers(cloudProvider?: 'aws', options?: {
11
52
  includeFileAccess?: boolean;
12
53
  includeTemplateFunction?: boolean;
@@ -17,6 +58,14 @@ export declare function getDefaultHelpers(cloudProvider?: 'aws', options?: {
17
58
  includeObservability?: boolean;
18
59
  includeValidation?: boolean;
19
60
  }): HelperDefinition[];
61
+ /**
62
+ * Generates complete _helpers.tpl content
63
+ * @param cloudProvider - Optional cloud provider for specific helpers
64
+ * @param customHelpers - Additional custom helpers
65
+ * @param options - Configuration options for helper inclusion
66
+ * @returns Complete helpers template content
67
+ * @since 2.8.4+
68
+ */
20
69
  export declare function generateHelpersTemplate(cloudProvider?: 'aws', customHelpers?: HelperDefinition[], options?: {
21
70
  includeFileAccess?: boolean;
22
71
  includeTemplateFunction?: boolean;
@@ -27,7 +76,20 @@ export declare function generateHelpersTemplate(cloudProvider?: 'aws', customHel
27
76
  includeObservability?: boolean;
28
77
  includeValidation?: boolean;
29
78
  }): string;
79
+ /**
80
+ * Gets helpers for specific categories
81
+ * @param category - Helper category to retrieve
82
+ * @returns Array of helper definitions for the specified category
83
+ * @since 2.8.4+
84
+ */
30
85
  export declare function getHelpersByCategory(category: 'standard' | 'fileAccess' | 'templateFunction' | 'sprig' | 'kubernetes' | 'aws' | 'env' | 'gitops' | 'observability' | 'validation'): HelperDefinition[];
86
+ /**
87
+ * Creates a custom helper definition
88
+ * @param name - Helper name
89
+ * @param template - Helper template content
90
+ * @returns Helper definition object
91
+ * @since 2.8.4+
92
+ */
31
93
  export declare function createHelper(name: string, template: string): HelperDefinition;
32
94
  export { getNewHelpersByCategory, getAvailableHelperCategories, getHelpersByCategories, getHelpersByOptions, formatNewHelpers, generateNewHelpersTemplate, getCachedNewHelpersTemplate, createNewHelper, validateHelperNames, filterHelpersByPattern, getHelperStatistics, } from './helmHelpers/index.js';
33
95
  export { ENV_HELPERS, GITOPS_HELPERS, OBSERVABILITY_HELPERS, VALIDATION_HELPERS, } from './helmHelpers/index.js';
@@ -1,4 +1,13 @@
1
+ /**
2
+ * @fileoverview Helm chart helpers and templates
3
+ * @since 2.8.0+
4
+ */
5
+ // Import new helper categories
1
6
  import { ENV_HELPERS, GITOPS_HELPERS, OBSERVABILITY_HELPERS, VALIDATION_HELPERS, getNewHelpersByCategory, } from './helmHelpers/index.js';
7
+ /**
8
+ * Standard Helm chart helpers following best practices
9
+ * @since 2.8.0+
10
+ */
2
11
  export const STANDARD_HELPERS = [
3
12
  {
4
13
  name: 'chart.name',
@@ -36,6 +45,10 @@ app.kubernetes.io/managed-by: {{ .Release.Service }}`,
36
45
  app.kubernetes.io/instance: {{ .Release.Name }}`,
37
46
  },
38
47
  ];
48
+ /**
49
+ * File access helpers using Helm .Files object
50
+ * @since 2.8.4+
51
+ */
39
52
  export const FILE_ACCESS_HELPERS = [
40
53
  {
41
54
  name: 'files.configFromFile',
@@ -75,6 +88,10 @@ false
75
88
  {{- end -}}`,
76
89
  },
77
90
  ];
91
+ /**
92
+ * Advanced template function helpers
93
+ * @since 2.8.4+
94
+ */
78
95
  export const TEMPLATE_FUNCTION_HELPERS = [
79
96
  {
80
97
  name: 'template.render',
@@ -104,6 +121,10 @@ export const TEMPLATE_FUNCTION_HELPERS = [
104
121
  {{- end -}}`,
105
122
  },
106
123
  ];
124
+ /**
125
+ * Sprig library function helpers for common use cases
126
+ * @since 2.8.4+
127
+ */
107
128
  export const SPRIG_HELPERS = [
108
129
  {
109
130
  name: 'string.camelCase',
@@ -157,6 +178,10 @@ export const SPRIG_HELPERS = [
157
178
  {{- $date | date $format }}`,
158
179
  },
159
180
  ];
181
+ /**
182
+ * Kubernetes-specific helpers for common patterns
183
+ * @since 2.8.4+
184
+ */
160
185
  export const KUBERNETES_HELPERS = [
161
186
  {
162
187
  name: 'k8s.imagePullPolicy',
@@ -228,6 +253,10 @@ failureThreshold: {{ $probe.failureThreshold | default 3 }}
228
253
  {{- end }}`,
229
254
  },
230
255
  ];
256
+ /**
257
+ * AWS-specific Helm helpers
258
+ * @since 2.8.0+
259
+ */
231
260
  export const AWS_HELPERS = [
232
261
  {
233
262
  name: 'aws.region',
@@ -259,9 +288,16 @@ export const AWS_HELPERS = [
259
288
  {{- printf "arn:aws:secretsmanager:%s:%s:secret:%s" $region (include "aws.accountId" .) $secretName }}`,
260
289
  },
261
290
  ];
291
+ /**
292
+ * Converts helper definitions to Helm template format
293
+ * @param helpers - Array of helper definitions
294
+ * @returns Formatted Helm template string
295
+ * @since 2.8.0+
296
+ */
262
297
  export function formatHelpers(helpers) {
263
298
  return helpers
264
299
  .map((helper) => {
300
+ // Validate helper has required properties
265
301
  if (!helper.name || typeof helper.name !== 'string') {
266
302
  throw new Error('Helper must have a valid name property');
267
303
  }
@@ -277,37 +313,61 @@ ${helper.template}
277
313
  })
278
314
  .join('\n\n');
279
315
  }
316
+ /**
317
+ * Gets default helpers based on cloud provider and feature flags
318
+ * @param cloudProvider - Target cloud provider
319
+ * @param options - Configuration options for helper inclusion
320
+ * @returns Combined standard and cloud-specific helpers
321
+ * @since 2.8.4+
322
+ */
280
323
  export function getDefaultHelpers(cloudProvider, options) {
281
324
  const helpers = [...STANDARD_HELPERS];
325
+ // Add file access helpers by default
282
326
  if (options?.includeFileAccess !== false) {
283
327
  helpers.push(...FILE_ACCESS_HELPERS);
284
328
  }
329
+ // Add template function helpers by default
285
330
  if (options?.includeTemplateFunction !== false) {
286
331
  helpers.push(...TEMPLATE_FUNCTION_HELPERS);
287
332
  }
333
+ // Add Sprig helpers by default
288
334
  if (options?.includeSprig !== false) {
289
335
  helpers.push(...SPRIG_HELPERS);
290
336
  }
337
+ // Add Kubernetes helpers by default
291
338
  if (options?.includeKubernetes !== false) {
292
339
  helpers.push(...KUBERNETES_HELPERS);
293
340
  }
341
+ // Add environment and configuration helpers
294
342
  if (options?.includeEnv !== false) {
295
343
  helpers.push(...ENV_HELPERS);
296
344
  }
345
+ // Add GitOps and CI/CD helpers
297
346
  if (options?.includeGitops !== false) {
298
347
  helpers.push(...GITOPS_HELPERS);
299
348
  }
349
+ // Add observability helpers
300
350
  if (options?.includeObservability !== false) {
301
351
  helpers.push(...OBSERVABILITY_HELPERS);
302
352
  }
353
+ // Add validation helpers
303
354
  if (options?.includeValidation !== false) {
304
355
  helpers.push(...VALIDATION_HELPERS);
305
356
  }
357
+ // Add cloud-specific helpers
306
358
  if (cloudProvider === 'aws') {
307
359
  helpers.push(...AWS_HELPERS);
308
360
  }
309
361
  return helpers;
310
362
  }
363
+ /**
364
+ * Generates complete _helpers.tpl content
365
+ * @param cloudProvider - Optional cloud provider for specific helpers
366
+ * @param customHelpers - Additional custom helpers
367
+ * @param options - Configuration options for helper inclusion
368
+ * @returns Complete helpers template content
369
+ * @since 2.8.4+
370
+ */
311
371
  export function generateHelpersTemplate(cloudProvider, customHelpers, options) {
312
372
  const helpers = getDefaultHelpers(cloudProvider, options);
313
373
  if (customHelpers) {
@@ -315,10 +375,18 @@ export function generateHelpersTemplate(cloudProvider, customHelpers, options) {
315
375
  }
316
376
  return formatHelpers(helpers);
317
377
  }
378
+ /**
379
+ * Gets helpers for specific categories
380
+ * @param category - Helper category to retrieve
381
+ * @returns Array of helper definitions for the specified category
382
+ * @since 2.8.4+
383
+ */
318
384
  export function getHelpersByCategory(category) {
385
+ // Handle new categories with imported helpers
319
386
  if (['env', 'gitops', 'observability', 'validation'].includes(category)) {
320
387
  return getNewHelpersByCategory(category);
321
388
  }
389
+ // Handle existing categories
322
390
  switch (category) {
323
391
  case 'standard':
324
392
  return [...STANDARD_HELPERS];
@@ -336,8 +404,17 @@ export function getHelpersByCategory(category) {
336
404
  return [];
337
405
  }
338
406
  }
407
+ /**
408
+ * Creates a custom helper definition
409
+ * @param name - Helper name
410
+ * @param template - Helper template content
411
+ * @returns Helper definition object
412
+ * @since 2.8.4+
413
+ */
339
414
  export function createHelper(name, template) {
340
415
  return { name, template };
341
416
  }
417
+ // Re-export new helper functions for convenience
342
418
  export { getNewHelpersByCategory, getAvailableHelperCategories, getHelpersByCategories, getHelpersByOptions, formatNewHelpers, generateNewHelpersTemplate, getCachedNewHelpersTemplate, createNewHelper, validateHelperNames, filterHelpersByPattern, getHelperStatistics, } from './helmHelpers/index.js';
419
+ // Export the new helper constants for direct access
343
420
  export { ENV_HELPERS, GITOPS_HELPERS, OBSERVABILITY_HELPERS, VALIDATION_HELPERS, } from './helmHelpers/index.js';
@@ -1,14 +1,53 @@
1
+ /**
2
+ * Pre-process an object to convert HelmConstruct instances to HelmExpression
3
+ * This allows the yaml library to serialize them correctly
4
+ */
1
5
  export declare function preprocessHelmConstructs(obj: unknown): unknown;
6
+ /**
7
+ * Main method to serialize an object to YAML with Helm template awareness.
8
+ * Uses 'yaml' library to natively handle Helm expressions by forcing QUOTE_DOUBLE style.
9
+ *
10
+ * @param obj Input object to serialize.
11
+ * @param options Options (lineWidth, etc.) - partially supported mapping from legacy options.
12
+ * @returns Helm-aware YAML string.
13
+ * @since 2.11.0
14
+ * @since 2.13.1 Refactored to use 'yaml' library
15
+ * @since 2.14.0 Added HelmConstruct pre-processing
16
+ */
2
17
  export declare function dumpHelmAwareYaml(obj: unknown, options?: {
3
18
  lineWidth?: number;
4
19
  }): string;
20
+ /**
21
+ * Post-processes YAML string to transform field-level conditionals
22
+ * This function should be called after dumpHelmAwareYaml to transform
23
+ * __fieldConditionalContent markers into the correct Helm template format.
24
+ *
25
+ * @param yaml YAML string that may contain __fieldConditionalContent markers
26
+ * @returns YAML string with field-level conditionals properly formatted
27
+ * @since 2.14.0
28
+ */
5
29
  export declare function postProcessFieldConditionals(yaml: string): string;
30
+ /**
31
+ * Legacy compatible stringify method.
32
+ * @param obj Object to serialize.
33
+ * @param options Options.
34
+ * @returns YAML string.
35
+ * @since 2.11.0
36
+ */
6
37
  export declare function stringify(obj: unknown, options?: {
7
38
  lineWidth?: number;
8
39
  doubleQuotedAsJSON?: boolean;
9
40
  simpleKeys?: boolean;
10
41
  }): string;
42
+ /**
43
+ * Helm expression types for pattern matching
44
+ * @since 2.11.0
45
+ */
11
46
  type HelmExpressionType = 'block' | 'nested' | 'comment' | 'action-trimmed' | 'raw' | 'include-context' | 'generic';
47
+ /**
48
+ * Interface to report validation errors of Helm YAML content.
49
+ * @since 2.11.0
50
+ */
12
51
  export interface HelmValidationError {
13
52
  type: 'syntax' | 'semantic' | 'reference' | 'type';
14
53
  message: string;
@@ -17,6 +56,10 @@ export interface HelmValidationError {
17
56
  expression?: string;
18
57
  suggestion?: string;
19
58
  }
59
+ /**
60
+ * Result of Helm YAML validation process.
61
+ * @since 2.11.0
62
+ */
20
63
  export interface HelmValidationResult {
21
64
  isValid: boolean;
22
65
  errors: HelmValidationError[];
@@ -27,7 +70,26 @@ export interface HelmValidationResult {
27
70
  complexity: number;
28
71
  };
29
72
  }
73
+ /**
74
+ * Validate YAML string with Helm template expressions.
75
+ * - Parses Helm expressions from the string,
76
+ * - Performs balanced parentheses and quote checks,
77
+ * - Collects syntax errors, semantic warnings,
78
+ * - Provides statistics including complexity.
79
+ *
80
+ * @param yaml YAML content string to validate.
81
+ * @returns Validation result with errors, warnings, and stats.
82
+ * @since 2.11.0
83
+ * @since 2.14.0 Restored full validation functionality
84
+ */
30
85
  export declare function validateHelmYaml(yaml: string): HelmValidationResult;
86
+ /**
87
+ * Internal helper to parse Helm expressions with line and column positions.
88
+ * Supports advanced expression types and range matching.
89
+ * @param content YAML string content.
90
+ * @returns List of detected Helm expressions with positional info.
91
+ * @since 2.11.0
92
+ */
31
93
  export declare function parseHelmExpressions(content: string): Array<{
32
94
  type: HelmExpressionType;
33
95
  expression: string;
@@ -36,7 +98,22 @@ export declare function parseHelmExpressions(content: string): Array<{
36
98
  endLine: number;
37
99
  endCol: number;
38
100
  }>;
101
+ /**
102
+ * Detect Helm template expressions using Timonel's parser.
103
+ * @param str - YAML/template content to inspect
104
+ * @returns Detected expression descriptors
105
+ */
39
106
  export declare function detectHelmExpressions(str: string): unknown[];
107
+ /**
108
+ * Preprocess Helm marker objects before YAML serialization.
109
+ * @param obj - Value tree containing Helm constructs or ValuesRef proxies
110
+ * @returns Serializer-ready value tree
111
+ */
40
112
  export declare function preprocessHelmExpressions(obj: unknown): unknown;
113
+ /**
114
+ * Preserve the historical post-processing compatibility hook.
115
+ * @param yaml - YAML content to return unchanged
116
+ * @returns The original YAML content
117
+ */
41
118
  export declare function postProcessHelmExpressions(yaml: string): string;
42
119
  export {};