@powerlines/plugin-env 0.16.156 → 0.16.158

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 (109) hide show
  1. package/package.json +9 -9
  2. package/dist/_virtual/_rolldown/runtime.cjs +0 -29
  3. package/dist/babel/index.cjs +0 -4
  4. package/dist/babel/index.d.cts +0 -2
  5. package/dist/babel/index.d.mts +0 -2
  6. package/dist/babel/index.mjs +0 -3
  7. package/dist/babel/plugin.cjs +0 -130
  8. package/dist/babel/plugin.d.cts +0 -8
  9. package/dist/babel/plugin.d.cts.map +0 -1
  10. package/dist/babel/plugin.d.mts +0 -8
  11. package/dist/babel/plugin.d.mts.map +0 -1
  12. package/dist/babel/plugin.mjs +0 -129
  13. package/dist/babel/plugin.mjs.map +0 -1
  14. package/dist/components/docs.cjs +0 -111
  15. package/dist/components/docs.d.cts +0 -24
  16. package/dist/components/docs.d.cts.map +0 -1
  17. package/dist/components/docs.d.mts +0 -24
  18. package/dist/components/docs.d.mts.map +0 -1
  19. package/dist/components/docs.mjs +0 -109
  20. package/dist/components/docs.mjs.map +0 -1
  21. package/dist/components/env-builtin.cjs +0 -815
  22. package/dist/components/env-builtin.d.cts +0 -21
  23. package/dist/components/env-builtin.d.cts.map +0 -1
  24. package/dist/components/env-builtin.d.mts +0 -21
  25. package/dist/components/env-builtin.d.mts.map +0 -1
  26. package/dist/components/env-builtin.mjs +0 -811
  27. package/dist/components/env-builtin.mjs.map +0 -1
  28. package/dist/components/index.cjs +0 -9
  29. package/dist/components/index.d.cts +0 -3
  30. package/dist/components/index.d.mts +0 -3
  31. package/dist/components/index.mjs +0 -4
  32. package/dist/helpers/automd-generator.cjs +0 -32
  33. package/dist/helpers/automd-generator.d.cts +0 -14
  34. package/dist/helpers/automd-generator.d.cts.map +0 -1
  35. package/dist/helpers/automd-generator.d.mts +0 -14
  36. package/dist/helpers/automd-generator.d.mts.map +0 -1
  37. package/dist/helpers/automd-generator.mjs +0 -31
  38. package/dist/helpers/automd-generator.mjs.map +0 -1
  39. package/dist/helpers/create-reflection-resource.cjs +0 -23
  40. package/dist/helpers/create-reflection-resource.d.cts +0 -13
  41. package/dist/helpers/create-reflection-resource.d.cts.map +0 -1
  42. package/dist/helpers/create-reflection-resource.d.mts +0 -13
  43. package/dist/helpers/create-reflection-resource.d.mts.map +0 -1
  44. package/dist/helpers/create-reflection-resource.mjs +0 -23
  45. package/dist/helpers/create-reflection-resource.mjs.map +0 -1
  46. package/dist/helpers/index.cjs +0 -34
  47. package/dist/helpers/index.d.cts +0 -7
  48. package/dist/helpers/index.d.mts +0 -7
  49. package/dist/helpers/index.mjs +0 -8
  50. package/dist/helpers/load.cjs +0 -139
  51. package/dist/helpers/load.d.cts +0 -36
  52. package/dist/helpers/load.d.cts.map +0 -1
  53. package/dist/helpers/load.d.mts +0 -36
  54. package/dist/helpers/load.d.mts.map +0 -1
  55. package/dist/helpers/load.mjs +0 -136
  56. package/dist/helpers/load.mjs.map +0 -1
  57. package/dist/helpers/persistence.cjs +0 -308
  58. package/dist/helpers/persistence.d.cts +0 -84
  59. package/dist/helpers/persistence.d.cts.map +0 -1
  60. package/dist/helpers/persistence.d.mts +0 -84
  61. package/dist/helpers/persistence.d.mts.map +0 -1
  62. package/dist/helpers/persistence.mjs +0 -296
  63. package/dist/helpers/persistence.mjs.map +0 -1
  64. package/dist/helpers/reflect.cjs +0 -290
  65. package/dist/helpers/reflect.d.cts +0 -68
  66. package/dist/helpers/reflect.d.cts.map +0 -1
  67. package/dist/helpers/reflect.d.mts +0 -68
  68. package/dist/helpers/reflect.d.mts.map +0 -1
  69. package/dist/helpers/reflect.mjs +0 -281
  70. package/dist/helpers/reflect.mjs.map +0 -1
  71. package/dist/helpers/source-file-env.cjs +0 -59
  72. package/dist/helpers/source-file-env.d.cts +0 -9
  73. package/dist/helpers/source-file-env.d.cts.map +0 -1
  74. package/dist/helpers/source-file-env.d.mts +0 -9
  75. package/dist/helpers/source-file-env.d.mts.map +0 -1
  76. package/dist/helpers/source-file-env.mjs +0 -57
  77. package/dist/helpers/source-file-env.mjs.map +0 -1
  78. package/dist/helpers/template-helpers.cjs +0 -70
  79. package/dist/helpers/template-helpers.d.cts +0 -15
  80. package/dist/helpers/template-helpers.d.cts.map +0 -1
  81. package/dist/helpers/template-helpers.d.mts +0 -15
  82. package/dist/helpers/template-helpers.d.mts.map +0 -1
  83. package/dist/helpers/template-helpers.mjs +0 -69
  84. package/dist/helpers/template-helpers.mjs.map +0 -1
  85. package/dist/index.cjs +0 -241
  86. package/dist/index.d.cts +0 -17
  87. package/dist/index.d.cts.map +0 -1
  88. package/dist/index.d.mts +0 -17
  89. package/dist/index.d.mts.map +0 -1
  90. package/dist/index.mjs +0 -235
  91. package/dist/index.mjs.map +0 -1
  92. package/dist/types/index.cjs +0 -11
  93. package/dist/types/index.d.cts +0 -3
  94. package/dist/types/index.d.mts +0 -3
  95. package/dist/types/index.mjs +0 -4
  96. package/dist/types/plugin.cjs +0 -115
  97. package/dist/types/plugin.d.cts +0 -163
  98. package/dist/types/plugin.d.cts.map +0 -1
  99. package/dist/types/plugin.d.mts +0 -163
  100. package/dist/types/plugin.d.mts.map +0 -1
  101. package/dist/types/plugin.mjs +0 -110
  102. package/dist/types/plugin.mjs.map +0 -1
  103. package/dist/types/runtime.cjs +0 -535
  104. package/dist/types/runtime.d.cts +0 -934
  105. package/dist/types/runtime.d.cts.map +0 -1
  106. package/dist/types/runtime.d.mts +0 -934
  107. package/dist/types/runtime.d.mts.map +0 -1
  108. package/dist/types/runtime.mjs +0 -533
  109. package/dist/types/runtime.mjs.map +0 -1
@@ -1,815 +0,0 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
3
- const require_types_plugin = require('../types/plugin.cjs');
4
- const require_helpers_load = require('../helpers/load.cjs');
5
- let _stryke_string_format_title_case = require("@stryke/string-format/title-case");
6
- let _powerlines_deepkit_vendor_type = require("@powerlines/deepkit/vendor/type");
7
- let defu = require("defu");
8
- defu = require_runtime.__toESM(defu);
9
- let _alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
10
- let _alloy_js_core = require("@alloy-js/core");
11
- let _powerlines_plugin_alloy_core_components_spacing = require("@powerlines/plugin-alloy/core/components/spacing");
12
- let _powerlines_plugin_alloy_core_contexts_context = require("@powerlines/plugin-alloy/core/contexts/context");
13
- let _alloy_js_typescript = require("@alloy-js/typescript");
14
- let _powerlines_plugin_alloy_helpers_refkey = require("@powerlines/plugin-alloy/helpers/refkey");
15
- let _powerlines_plugin_alloy_typescript_components_builtin_file = require("@powerlines/plugin-alloy/typescript/components/builtin-file");
16
- let _powerlines_plugin_alloy_typescript_components_interface_declaration = require("@powerlines/plugin-alloy/typescript/components/interface-declaration");
17
- let _powerlines_plugin_alloy_typescript_components_object_declaration = require("@powerlines/plugin-alloy/typescript/components/object-declaration");
18
- let _powerlines_plugin_alloy_typescript_components_tsdoc = require("@powerlines/plugin-alloy/typescript/components/tsdoc");
19
- let _powerlines_plugin_alloy_typescript_components_tsdoc_reflection = require("@powerlines/plugin-alloy/typescript/components/tsdoc-reflection");
20
- let _stryke_helpers_get_unique = require("@stryke/helpers/get-unique");
21
-
22
- //#region src/components/env-builtin.tsx
23
- const __ΩOmit = [
24
- "T",
25
- "K",
26
- () => __ΩPick,
27
- () => __ΩExclude,
28
- "Omit",
29
- "b!b\"e!!e!!ge!\"o$#o##w%y"
30
- ];
31
- const __ΩPick = [
32
- "T",
33
- "K",
34
- "Pick",
35
- "l+e#!e\"!fRb!b\"Pde\"\"N#!w#y"
36
- ];
37
- const __ΩExclude = [
38
- "T",
39
- "U",
40
- "Exclude",
41
- "l6!Re$!RPe#!e$\"qk#%QRb!b\"Pde\"!p)w#y"
42
- ];
43
- function __assignType(fn, args) {
44
- fn.__type = args;
45
- return fn;
46
- }
47
- /**
48
- * Generates the environment configuration typescript definition for the Powerlines project.
49
- */
50
- function EnvTypeDefinition(props) {
51
- const [{ defaultValue, reflection }] = (0, _alloy_js_core.splitProps)(props, ["defaultValue", "reflection"]);
52
- const context = (_powerlines_plugin_alloy_core_contexts_context.usePowerlines.Ω = [[() => require_types_plugin.__ΩEnvPluginContext, "n!"]], (0, _powerlines_plugin_alloy_core_contexts_context.usePowerlines)());
53
- return [
54
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceDeclaration, {
55
- name: "UnprefixedEnv",
56
- defaultValue,
57
- reflection,
58
- "export": true
59
- }),
60
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
61
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
62
- heading: "The environment configuration object with prefixed keys.",
63
- get children() {
64
- return (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocRemarks, { children: `The \`Env\` type extends the \`UnprefixedEnv\` interface by including additional keys that are prefixed according to the project's configuration. This allows for flexibility in accessing environment variables with different naming conventions.` });
65
- }
66
- }),
67
- (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.InterfaceDeclaration, {
68
- name: "Env",
69
- "export": true,
70
- "extends": "UnprefixedEnv",
71
- get children() {
72
- return (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.For, {
73
- get each() {
74
- return (0, _stryke_helpers_get_unique.getUnique)(context.config.env.prefix).map(__assignType((prefix) => prefix.replace(/_$/, ""), [
75
- "prefix",
76
- "",
77
- "P\"2!\"/\""
78
- ]));
79
- },
80
- doubleHardline: true,
81
- get children() {
82
- return __assignType((prefix) => (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.For, {
83
- get each() {
84
- return reflection?.getProperties().filter(__assignType((property) => !property.isIgnored(), [
85
- "property",
86
- "",
87
- "P\"2!\"/\""
88
- ])) ?? [];
89
- },
90
- doubleHardline: true,
91
- get children() {
92
- return __assignType((property) => [(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc_reflection.TSDocReflectionProperty, { reflection: property }), (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.InterfaceMember, {
93
- get name() {
94
- return `${prefix}_${property.getNameAsString()}`;
95
- },
96
- get type() {
97
- return `UnprefixedEnv["${property.getNameAsString()}"]`;
98
- },
99
- get readonly() {
100
- return property.isReadonly();
101
- }
102
- })], [
103
- "property",
104
- "",
105
- "P\"2!\"/\""
106
- ]);
107
- }
108
- }), [
109
- "prefix",
110
- "",
111
- "P\"2!\"/\""
112
- ]);
113
- }
114
- });
115
- }
116
- }),
117
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {})
118
- ];
119
- }
120
- EnvTypeDefinition.__type = [
121
- () => __ΩOmit,
122
- "name",
123
- "props",
124
- "EnvTypeDefinition",
125
- "Generates the environment configuration typescript definition for the Powerlines project.",
126
- "P!.\"o!#2#\"/$?%"
127
- ];
128
- const __ΩConfigPropertyConditionalProps = [
129
- () => require_types_plugin.__ΩEnvPluginContext,
130
- "context",
131
- "name",
132
- "ConfigPropertyConditionalProps",
133
- "P!n!4\"&4#Mw$y"
134
- ];
135
- function ConfigPropertyConditional(props) {
136
- const [{ context, name }] = (0, _alloy_js_core.splitProps)(props, ["context", "name"]);
137
- return _alloy_js_core.code`propertyName === "${name}" || propertyName.replace(/^(${(0, _stryke_helpers_get_unique.getUnique)(context.config.env.prefix.sort(__assignType((a, b) => a.startsWith(b) ? -1 : b.startsWith(a) ? 1 : a.localeCompare(b), [
138
- "a",
139
- "b",
140
- "",
141
- "P\"2!\"2\"\"/#"
142
- ])).map(__assignType((prefix) => `${prefix.replace(/_$/, "")}_`, [
143
- "prefix",
144
- "",
145
- "P\"2!\"/\""
146
- ]))).join("|")})/g, "").toLowerCase().replace(/[\\s\\-_]+/g, "") === "${name.toLowerCase().replace(/[\s\-_]+/g, "")}"`;
147
- }
148
- ConfigPropertyConditional.__type = [
149
- () => __ΩConfigPropertyConditionalProps,
150
- "props",
151
- "ConfigPropertyConditional",
152
- "Pn!2\"\"/#"
153
- ];
154
- const __ΩConfigPropertyProps = [
155
- "index",
156
- () => require_types_plugin.__ΩEnvPluginContext,
157
- "context",
158
- "property",
159
- "ConfigPropertyProps",
160
- "P!'4!n\"4#!4$Mw%y"
161
- ];
162
- function ConfigPropertyGet(props) {
163
- const [{ context, property, index }] = (0, _alloy_js_core.splitProps)(props, [
164
- "context",
165
- "property",
166
- "index"
167
- ]);
168
- return [index === 0 ? (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.IfStatement, {
169
- get condition() {
170
- return [(0, _alloy_js_core_jsx_runtime.createComponent)(ConfigPropertyConditional, {
171
- get name() {
172
- return property.getNameAsString();
173
- },
174
- context
175
- }), (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Show, {
176
- get when() {
177
- return (0, _alloy_js_core_jsx_runtime.memo)(() => !!property.getAlias())() && property.getAlias().length > 0;
178
- },
179
- get children() {
180
- return [_alloy_js_core.code` || `, (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.For, {
181
- get each() {
182
- return property.getAlias();
183
- },
184
- joiner: _alloy_js_core.code` || `,
185
- get children() {
186
- return __assignType((alias) => (0, _alloy_js_core_jsx_runtime.createComponent)(ConfigPropertyConditional, {
187
- name: alias,
188
- context
189
- }), [
190
- "alias",
191
- "",
192
- "P\"2!\"/\""
193
- ]);
194
- }
195
- })];
196
- }
197
- })];
198
- },
199
- get children() {
200
- return _alloy_js_core.code`return target["${property.getNameAsString()}"];`;
201
- }
202
- }) : (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.ElseIfClause, {
203
- get condition() {
204
- return [(0, _alloy_js_core_jsx_runtime.createComponent)(ConfigPropertyConditional, {
205
- get name() {
206
- return property.getNameAsString();
207
- },
208
- context
209
- }), (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Show, {
210
- get when() {
211
- return (0, _alloy_js_core_jsx_runtime.memo)(() => !!property.getAlias())() && property.getAlias().length > 0;
212
- },
213
- get children() {
214
- return [_alloy_js_core.code` || `, (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.For, {
215
- get each() {
216
- return property.getAlias();
217
- },
218
- joiner: _alloy_js_core.code` || `,
219
- get children() {
220
- return __assignType((alias) => (0, _alloy_js_core_jsx_runtime.createComponent)(ConfigPropertyConditional, {
221
- name: alias,
222
- context
223
- }), [
224
- "alias",
225
- "",
226
- "P\"2!\"/\""
227
- ]);
228
- }
229
- })];
230
- }
231
- })];
232
- },
233
- get children() {
234
- return _alloy_js_core.code`return target["${property.getNameAsString()}"];`;
235
- }
236
- })];
237
- }
238
- ConfigPropertyGet.__type = [
239
- () => __ΩConfigPropertyProps,
240
- "props",
241
- "ConfigPropertyGet",
242
- "Pn!2\"\"/#"
243
- ];
244
- function ConfigPropertySet(props) {
245
- const [{ context, property, index }] = (0, _alloy_js_core.splitProps)(props, [
246
- "context",
247
- "property",
248
- "index"
249
- ]);
250
- return [index === 0 ? (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.IfStatement, {
251
- get condition() {
252
- return [(0, _alloy_js_core_jsx_runtime.createComponent)(ConfigPropertyConditional, {
253
- get name() {
254
- return property.getNameAsString();
255
- },
256
- context
257
- }), (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Show, {
258
- get when() {
259
- return (0, _alloy_js_core_jsx_runtime.memo)(() => !!property.getAlias())() && property.getAlias().length > 0;
260
- },
261
- get children() {
262
- return [_alloy_js_core.code` || `, (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.For, {
263
- get each() {
264
- return property.getAlias();
265
- },
266
- joiner: _alloy_js_core.code` || `,
267
- get children() {
268
- return __assignType((alias) => (0, _alloy_js_core_jsx_runtime.createComponent)(ConfigPropertyConditional, {
269
- name: alias,
270
- context
271
- }), [
272
- "alias",
273
- "",
274
- "P\"2!\"/\""
275
- ]);
276
- }
277
- })];
278
- }
279
- })];
280
- },
281
- get children() {
282
- return _alloy_js_core.code`
283
- target["${property.getNameAsString()}"] = newValue;
284
- return true;
285
- `;
286
- }
287
- }) : (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.ElseIfClause, {
288
- get condition() {
289
- return [(0, _alloy_js_core_jsx_runtime.createComponent)(ConfigPropertyConditional, {
290
- get name() {
291
- return property.getNameAsString();
292
- },
293
- context
294
- }), (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Show, {
295
- get when() {
296
- return (0, _alloy_js_core_jsx_runtime.memo)(() => !!property.getAlias())() && property.getAlias().length > 0;
297
- },
298
- get children() {
299
- return [_alloy_js_core.code` || `, (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.For, {
300
- get each() {
301
- return property.getAlias();
302
- },
303
- joiner: _alloy_js_core.code` || `,
304
- get children() {
305
- return __assignType((alias) => (0, _alloy_js_core_jsx_runtime.createComponent)(ConfigPropertyConditional, {
306
- name: alias,
307
- context
308
- }), [
309
- "alias",
310
- "",
311
- "P\"2!\"/\""
312
- ]);
313
- }
314
- })];
315
- }
316
- })];
317
- },
318
- get children() {
319
- return _alloy_js_core.code`
320
- target["${property.getNameAsString()}"] = newValue;
321
- return true;
322
- `;
323
- }
324
- })];
325
- }
326
- ConfigPropertySet.__type = [
327
- () => __ΩConfigPropertyProps,
328
- "props",
329
- "ConfigPropertySet",
330
- "Pn!2\"\"/#"
331
- ];
332
- const __ΩEnvBuiltinProps = [
333
- () => __ΩOmit,
334
- "id",
335
- "Children",
336
- "defaultConfig",
337
- "reflection",
338
- "EnvBuiltinProps",
339
- "P!.\"o!#\"w#4$8!4%Mw&y"
340
- ];
341
- const createEnvRefkey = (0, _powerlines_plugin_alloy_helpers_refkey.refkey)("createEnv");
342
- const envRefkey = (0, _powerlines_plugin_alloy_helpers_refkey.refkey)("env");
343
- const envSerializerRefkey = (0, _powerlines_plugin_alloy_helpers_refkey.refkey)("EnvSerializer");
344
- /**
345
- * Generates the environment configuration module for the Powerlines project.
346
- */
347
- function EnvBuiltin(props) {
348
- const [{ defaultConfig, reflection, children }, rest] = (0, _alloy_js_core.splitProps)(props, [
349
- "defaultConfig",
350
- "reflection",
351
- "children"
352
- ]);
353
- const context = (_powerlines_plugin_alloy_core_contexts_context.usePowerlines.Ω = [[() => require_types_plugin.__ΩEnvPluginContext, "n!"]], (0, _powerlines_plugin_alloy_core_contexts_context.usePowerlines)());
354
- const defaultValue = (0, _alloy_js_core.computed)(() => context && require_helpers_load.loadEnvFromContext(context, process.env));
355
- const envInstance = (0, _alloy_js_core.computed)(() => {
356
- const result = new _powerlines_deepkit_vendor_type.ReflectionClass({
357
- kind: _powerlines_deepkit_vendor_type.ReflectionKind.objectLiteral,
358
- description: `The initial environment configuration state for the ${(0, _stryke_string_format_title_case.titleCase)(context?.config?.name)} project.`,
359
- types: []
360
- }, reflection);
361
- result.getProperties().filter(__assignType((property) => property.isRuntime() || property.getTags().runtime === true, [
362
- "property",
363
- "",
364
- "P\"2!\"/\""
365
- ])).forEach(__assignType((property) => {
366
- result.removeProperty(property.getNameAsString());
367
- }, [
368
- "property",
369
- "",
370
- "P\"2!\"/\""
371
- ]));
372
- return result;
373
- });
374
- const reflectionGetProperties = (0, _alloy_js_core.computed)(() => reflection?.getProperties().filter(__assignType((property) => !property.isIgnored(), [
375
- "property",
376
- "",
377
- "P\"2!\"/\""
378
- ])).sort(__assignType((a, b) => a.getNameAsString().localeCompare(b.getNameAsString()), [
379
- "a",
380
- "b",
381
- "",
382
- "P\"2!\"2\"\"/#"
383
- ])) ?? []);
384
- const reflectionSetProperties = (0, _alloy_js_core.computed)(() => reflection?.getProperties().filter(__assignType((property) => !property.isIgnored() && !property.isReadonly(), [
385
- "property",
386
- "",
387
- "P\"2!\"/\""
388
- ])).sort(__assignType((a, b) => a.getNameAsString().localeCompare(b.getNameAsString()), [
389
- "a",
390
- "b",
391
- "",
392
- "P\"2!\"2\"\"/#"
393
- ])) ?? []);
394
- return (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_builtin_file.BuiltinFile, (0, _alloy_js_core_jsx_runtime.mergeProps)({
395
- id: "env",
396
- description: "The environment configuration module provides an interface to define environment configuration parameters."
397
- }, rest, {
398
- get imports() {
399
- return (0, defu.default)({ "@powerlines/deepkit/vendor/type": [
400
- "serializeFunction",
401
- "deserializeFunction",
402
- "ReflectionKind",
403
- "Serializer",
404
- "NamingStrategy",
405
- "TemplateState",
406
- "Type",
407
- "TypeProperty",
408
- "TypePropertySignature"
409
- ] }, rest.imports ?? {});
410
- },
411
- get children() {
412
- return [
413
- (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Show, {
414
- get when() {
415
- return Boolean(reflection);
416
- },
417
- get children() {
418
- return [
419
- (0, _alloy_js_core_jsx_runtime.createComponent)(EnvTypeDefinition, {
420
- defaultValue,
421
- reflection
422
- }),
423
- (0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
424
- (0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {})
425
- ];
426
- }
427
- }),
428
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_object_declaration.ObjectDeclaration, {
429
- name: "initialEnv",
430
- type: "Partial<Env>",
431
- defaultValue,
432
- reflection: envInstance,
433
- "export": true,
434
- "const": true,
435
- doc: "The initial environment configuration object values for the runtime."
436
- }),
437
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
438
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
439
- heading: "The environment configuration serializer for the Powerlines application.",
440
- get children() {
441
- return [
442
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocLink, { children: `https://deepkit.io/docs/serialization/serializers` }),
443
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocLink, { children: `https://github.com/marcj/untitled-code/blob/master/packages/type/src/serializer.ts#L1918` }),
444
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocRemarks, { children: `This serializer is used to serialize and deserialize the Powerlines environment configuration.` })
445
- ];
446
- }
447
- }),
448
- (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.ClassDeclaration, {
449
- refkey: envSerializerRefkey,
450
- name: "EnvSerializer",
451
- "extends": "Serializer",
452
- "export": true,
453
- get children() {
454
- return (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.ClassMethod, {
455
- name: "constructor",
456
- "public": true,
457
- doc: "Initializes a new instance of the `EnvSerializer` class.",
458
- children: _alloy_js_core.code`super("env");
459
-
460
- this.deserializeRegistry.register(
461
- ReflectionKind.boolean,
462
- (type: Type, state: TemplateState) => {
463
- state.addSetter(
464
- \`typeof \${state.accessor.toString()} !== "boolean" ? \${state.accessor.toString()} === 1 || \${state.accessor.toString()} === "1" || \${state.accessor.toString()}.toLowerCase() === "t" || \${state.accessor.toString()}.toLowerCase() === "true" || \${state.accessor.toString()}.toLowerCase() === "y" || \${state.accessor.toString()}.toLowerCase() === "yes" : \${state.accessor.toString()}\`
465
- );
466
- }
467
- ); `
468
- });
469
- }
470
- }),
471
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
472
- (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.VarDeclaration, {
473
- name: "envNamingStrategy",
474
- "const": true,
475
- doc: "The environment naming strategy for the runtime.",
476
- get initializer() {
477
- return _alloy_js_core.code`new class extends NamingStrategy {
478
- constructor() {
479
- super("env");
480
- }
481
-
482
- getPropertyName(type: TypeProperty | TypePropertySignature, forSerializer: string): string | undefined {
483
- const name = super.getPropertyName(type, forSerializer);
484
- if (!name) {
485
- return name;
486
- }
487
-
488
- return name.replace(/^(${(0, _stryke_helpers_get_unique.getUnique)(context.config.env.prefix).map(__assignType((prefix) => prefix.replace(/_$/, ""), [
489
- "prefix",
490
- "",
491
- "P\"2!\"/\""
492
- ])).join("|")})_/, "");
493
- }
494
- }; `;
495
- }
496
- }),
497
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
498
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
499
- heading: "A {@link EnvSerializer | environment configuration serializer} instance for the Powerlines application.",
500
- get children() {
501
- return [
502
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocLink, { children: `https://deepkit.io/docs/serialization/serializers` }),
503
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocLink, { children: `https://github.com/marcj/untitled-code/blob/master/packages/type/src/serializer.ts#L1918` }),
504
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocRemarks, { children: `This serializer is used to serialize and deserialize the Powerlines environment configuration.` })
505
- ];
506
- }
507
- }),
508
- (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.VarDeclaration, {
509
- name: "envSerializer",
510
- "const": true,
511
- get initializer() {
512
- return (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.NewExpression, {
513
- args: [],
514
- target: "EnvSerializer"
515
- });
516
- }
517
- }),
518
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
519
- (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.VarDeclaration, {
520
- name: "_serializeEnv",
521
- "const": true,
522
- initializer: "serializeFunction<Env>(envSerializer, envNamingStrategy)"
523
- }),
524
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
525
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
526
- heading: "Serialize a environment configuration object to JSON data objects (not a JSON string).",
527
- get children() {
528
- return [
529
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocRemarks, { children: `The resulting JSON object can be stringified using \`JSON.stringify()\`.` }),
530
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocExample, { children: `const json = serializeEnv(env);` }),
531
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
532
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam, {
533
- name: "input",
534
- children: `The environment configuration object to serialize.`
535
- }),
536
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocReturns, { children: `The serialized environment configuration as JSON data objects.` }),
537
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocThrows, { children: `ValidationError when serialization or validation fails.` })
538
- ];
539
- }
540
- }),
541
- (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
542
- name: "serializeEnv",
543
- "export": true,
544
- parameters: [{
545
- name: "input",
546
- type: "Env"
547
- }],
548
- children: _alloy_js_core.code` return _serializeEnv(input, { loosely: true }); `
549
- }),
550
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
551
- (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.VarDeclaration, {
552
- name: "_deserializeEnv",
553
- "const": true,
554
- initializer: "deserializeFunction<Env>(envSerializer, envNamingStrategy)"
555
- }),
556
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
557
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
558
- heading: "Deserialize a environment configuration object from JSON data objects to JavaScript objects, without running any validators.",
559
- get children() {
560
- return [
561
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocRemarks, { children: `Types that are already correct will be used as-is.` }),
562
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocExample, { children: `const env = deserializeEnv(json);` }),
563
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocThrows, { children: `ValidationError when deserialization fails.` })
564
- ];
565
- }
566
- }),
567
- (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
568
- name: "deserializeEnv",
569
- "export": true,
570
- parameters: [{
571
- name: "input",
572
- type: "Env"
573
- }],
574
- children: _alloy_js_core.code` return _deserializeEnv(input, { loosely: true }); `
575
- }),
576
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
577
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
578
- heading: "Initializes the Powerlines environment configuration module.",
579
- get children() {
580
- return [
581
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocRemarks, { children: `This function initializes the Powerlines environment configuration object.` }),
582
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam, {
583
- name: "environmentConfig",
584
- children: `The dynamic/runtime configuration - this could include the current environment variables or any other environment-specific settings provided by the runtime.`
585
- }),
586
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocReturns, { children: `The initialized Powerlines configuration object.` })
587
- ];
588
- }
589
- }),
590
- (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Show, {
591
- get when() {
592
- return Boolean(context?.entryPath);
593
- },
594
- get children() {
595
- return (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
596
- refkey: createEnvRefkey,
597
- async: false,
598
- "export": true,
599
- name: "createEnv",
600
- parameters: [{
601
- name: "environmentConfig",
602
- type: `Partial<Env>`,
603
- optional: false,
604
- default: "{}"
605
- }],
606
- returnType: "Env",
607
- get children() {
608
- return [
609
- _alloy_js_core.code`
610
- return new Proxy<Env>(
611
- deserializeEnv({
612
- ...initialEnv,
613
- ...environmentConfig
614
- } as Env),
615
- {
616
- get: (target: UnprefixedEnv, propertyName: string) => { `,
617
- (0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
618
- (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.For, {
619
- each: reflectionGetProperties,
620
- get children() {
621
- return __assignType((property, index) => (0, _alloy_js_core_jsx_runtime.createComponent)(ConfigPropertyGet, {
622
- index,
623
- context,
624
- property
625
- }), [
626
- "property",
627
- "index",
628
- "",
629
- "P!2!'2\"\"/#"
630
- ]);
631
- }
632
- }),
633
- _alloy_js_core.code`
634
- return undefined;
635
- }, `,
636
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
637
- _alloy_js_core.code` set: (target: UnprefixedEnv, propertyName: string, newValue: any) => { `,
638
- (0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
639
- (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.For, {
640
- each: reflectionSetProperties,
641
- ender: _alloy_js_core.code` else `,
642
- get children() {
643
- return __assignType((property, index) => (0, _alloy_js_core_jsx_runtime.createComponent)(ConfigPropertySet, {
644
- index,
645
- context,
646
- property
647
- }), [
648
- "property",
649
- "index",
650
- "",
651
- "P!2!'2\"\"/#"
652
- ]);
653
- }
654
- }),
655
- (0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
656
- _alloy_js_core.code`return false;
657
- }
658
- }
659
- );
660
- `
661
- ];
662
- }
663
- });
664
- }
665
- }),
666
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
667
- (0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
668
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
669
- heading: "The environment configuration object.",
670
- get children() {
671
- return (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocRemarks, { children: `This object provides access to the environment configuration parameters in the application runtime.` });
672
- }
673
- }),
674
- (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.VarDeclaration, {
675
- refkey: envRefkey,
676
- name: "env",
677
- type: "Env",
678
- "export": true,
679
- "const": true,
680
- get initializer() {
681
- return [_alloy_js_core.code`createEnv(${defaultConfig || "{}"} as Partial<Env>);`];
682
- }
683
- }),
684
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
685
- (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.VarDeclaration, {
686
- "export": true,
687
- "const": true,
688
- name: "isCI",
689
- doc: "Detect if the application is running in a continuous integration (CI) environment.",
690
- initializer: _alloy_js_core.code`Boolean(
691
- env.CI ||
692
- env.RUN_ID ||
693
- env.AGOLA_GIT_REF ||
694
- env.AC_APPCIRCLE ||
695
- env.APPVEYOR ||
696
- env.CODEBUILD ||
697
- env.TF_BUILD ||
698
- env.bamboo_planKey ||
699
- env.BITBUCKET_COMMIT ||
700
- env.BITRISE_IO ||
701
- env.BUDDY_WORKSPACE_ID ||
702
- env.BUILDKITE ||
703
- env.CIRCLECI ||
704
- env.CIRRUS_CI ||
705
- env.CF_BUILD_ID ||
706
- env.CM_BUILD_ID ||
707
- env.CI_NAME ||
708
- env.DRONE ||
709
- env.DSARI ||
710
- env.EARTHLY_CI ||
711
- env.EAS_BUILD ||
712
- env.GERRIT_PROJECT ||
713
- env.GITEA_ACTIONS ||
714
- env.GITHUB_ACTIONS ||
715
- env.GITLAB_CI ||
716
- env.GOCD ||
717
- env.BUILDER_OUTPUT ||
718
- env.HARNESS_BUILD_ID ||
719
- env.JENKINS_URL ||
720
- env.LAYERCI ||
721
- env.MAGNUM ||
722
- env.NETLIFY ||
723
- env.NEVERCODE ||
724
- env.PROW_JOB_ID ||
725
- env.RELEASE_BUILD_ID ||
726
- env.RENDER ||
727
- env.SAILCI ||
728
- env.HUDSON ||
729
- env.SCREWDRIVER ||
730
- env.SEMAPHORE ||
731
- env.SOURCEHUT ||
732
- env.STRIDER ||
733
- env.TASK_ID ||
734
- env.RUN_ID ||
735
- env.TEAMCITY_VERSION ||
736
- env.TRAVIS ||
737
- env.VELA ||
738
- env.NOW_BUILDER ||
739
- env.APPCENTER_BUILD_ID ||
740
- env.CI_XCODE_PROJECT ||
741
- env.XCS || false
742
- ); `
743
- }),
744
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
745
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
746
- heading: "Detect the \\`mode\\` of the current runtime environment.",
747
- get children() {
748
- return (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocRemarks, { children: _alloy_js_core.code`The \`mode\` is determined by the \`MODE\` environment variable, or falls back to the \`NEXT_PUBLIC_VERCEL_ENV\`, \`NODE_ENV\`, or defaults to \`production\`. While the value can potentially be any string, it is generally recommended to only allow a value in the following list:
749
- - \`production\`
750
- - \`test\`
751
- - \`development\`
752
- ` });
753
- }
754
- }),
755
- (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.VarDeclaration, {
756
- "export": true,
757
- "const": true,
758
- name: "mode",
759
- initializer: _alloy_js_core.code`String(env.MODE) || "production"; `
760
- }),
761
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
762
- (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.VarDeclaration, {
763
- "export": true,
764
- "const": true,
765
- name: "isProduction",
766
- doc: "Detect if the application is running in `\"production\"` mode",
767
- initializer: _alloy_js_core.code`["prd", "prod", "production"].includes(mode.toLowerCase()); `
768
- }),
769
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
770
- (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.VarDeclaration, {
771
- "export": true,
772
- "const": true,
773
- name: "isTest",
774
- doc: "Detect if the application is running in `\"test\"` mode",
775
- initializer: _alloy_js_core.code`["tst", "test", "testing", "stg", "stage", "staging"].includes(mode.toLowerCase()) || env.TEST; `
776
- }),
777
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
778
- (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.VarDeclaration, {
779
- "export": true,
780
- "const": true,
781
- name: "isDevelopment",
782
- doc: "Detect if the application is running in `\"development\"` mode",
783
- initializer: _alloy_js_core.code`["dev", "development"].includes(mode.toLowerCase()); `
784
- }),
785
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
786
- (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.VarDeclaration, {
787
- "export": true,
788
- "const": true,
789
- name: "isDebug",
790
- doc: "Detect if the application is currently being debugged",
791
- initializer: _alloy_js_core.code`Boolean(isDevelopment && env.DEBUG); `
792
- }),
793
- (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
794
- (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Show, {
795
- get when() {
796
- return Boolean(children);
797
- },
798
- children
799
- })
800
- ];
801
- }
802
- }));
803
- }
804
- EnvBuiltin.__type = [
805
- () => __ΩEnvBuiltinProps,
806
- "props",
807
- "EnvBuiltin",
808
- "Generates the environment configuration module for the Powerlines project.",
809
- "Pn!2\"\"/#?$"
810
- ];
811
-
812
- //#endregion
813
- exports.EnvBuiltin = EnvBuiltin;
814
- exports.EnvTypeDefinition = EnvTypeDefinition;
815
- exports.__ΩEnvBuiltinProps = __ΩEnvBuiltinProps;