@powerlines/plugin-env 0.16.131 → 0.16.134

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