@powerlines/plugin-env 0.16.234 → 0.16.236

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 (84) hide show
  1. package/dist/babel/plugin.cjs +23 -71
  2. package/dist/babel/plugin.d.cts.map +1 -1
  3. package/dist/babel/plugin.d.mts.map +1 -1
  4. package/dist/babel/plugin.mjs +23 -71
  5. package/dist/babel/plugin.mjs.map +1 -1
  6. package/dist/components/docs.cjs +14 -14
  7. package/dist/components/docs.d.cts +0 -2
  8. package/dist/components/docs.d.cts.map +1 -1
  9. package/dist/components/docs.d.mts +0 -2
  10. package/dist/components/docs.d.mts.map +1 -1
  11. package/dist/components/docs.mjs +14 -14
  12. package/dist/components/docs.mjs.map +1 -1
  13. package/dist/components/env-builtin.cjs +233 -426
  14. package/dist/components/env-builtin.d.cts +1 -4
  15. package/dist/components/env-builtin.d.cts.map +1 -1
  16. package/dist/components/env-builtin.d.mts +1 -4
  17. package/dist/components/env-builtin.d.mts.map +1 -1
  18. package/dist/components/env-builtin.mjs +236 -428
  19. package/dist/components/env-builtin.mjs.map +1 -1
  20. package/dist/helpers/index.cjs +9 -26
  21. package/dist/helpers/index.d.cts +3 -5
  22. package/dist/helpers/index.d.mts +3 -5
  23. package/dist/helpers/index.mjs +3 -5
  24. package/dist/helpers/load.cjs +8 -7
  25. package/dist/helpers/load.d.cts +3 -3
  26. package/dist/helpers/load.d.cts.map +1 -1
  27. package/dist/helpers/load.d.mts +3 -3
  28. package/dist/helpers/load.d.mts.map +1 -1
  29. package/dist/helpers/load.mjs +7 -6
  30. package/dist/helpers/load.mjs.map +1 -1
  31. package/dist/helpers/schema.cjs +206 -0
  32. package/dist/helpers/schema.d.cts +53 -0
  33. package/dist/helpers/schema.d.cts.map +1 -0
  34. package/dist/helpers/schema.d.mts +53 -0
  35. package/dist/helpers/schema.d.mts.map +1 -0
  36. package/dist/helpers/schema.mjs +199 -0
  37. package/dist/helpers/schema.mjs.map +1 -0
  38. package/dist/index.cjs +23 -201
  39. package/dist/index.d.cts +2 -2
  40. package/dist/index.d.cts.map +1 -1
  41. package/dist/index.d.mts +2 -2
  42. package/dist/index.d.mts.map +1 -1
  43. package/dist/index.mjs +25 -203
  44. package/dist/index.mjs.map +1 -1
  45. package/dist/types/index.cjs +1 -0
  46. package/dist/types/index.d.cts +2 -2
  47. package/dist/types/index.d.mts +2 -2
  48. package/dist/types/index.mjs +2 -2
  49. package/dist/types/plugin.cjs +16 -24
  50. package/dist/types/plugin.d.cts +23 -57
  51. package/dist/types/plugin.d.cts.map +1 -1
  52. package/dist/types/plugin.d.mts +23 -57
  53. package/dist/types/plugin.d.mts.map +1 -1
  54. package/dist/types/plugin.mjs +16 -25
  55. package/dist/types/plugin.mjs.map +1 -1
  56. package/package.json +12 -26
  57. package/dist/helpers/create-reflection-resource.cjs +0 -23
  58. package/dist/helpers/create-reflection-resource.d.cts +0 -13
  59. package/dist/helpers/create-reflection-resource.d.cts.map +0 -1
  60. package/dist/helpers/create-reflection-resource.d.mts +0 -13
  61. package/dist/helpers/create-reflection-resource.d.mts.map +0 -1
  62. package/dist/helpers/create-reflection-resource.mjs +0 -23
  63. package/dist/helpers/create-reflection-resource.mjs.map +0 -1
  64. package/dist/helpers/persistence.cjs +0 -309
  65. package/dist/helpers/persistence.d.cts +0 -84
  66. package/dist/helpers/persistence.d.cts.map +0 -1
  67. package/dist/helpers/persistence.d.mts +0 -84
  68. package/dist/helpers/persistence.d.mts.map +0 -1
  69. package/dist/helpers/persistence.mjs +0 -297
  70. package/dist/helpers/persistence.mjs.map +0 -1
  71. package/dist/helpers/reflect.cjs +0 -290
  72. package/dist/helpers/reflect.d.cts +0 -68
  73. package/dist/helpers/reflect.d.cts.map +0 -1
  74. package/dist/helpers/reflect.d.mts +0 -68
  75. package/dist/helpers/reflect.d.mts.map +0 -1
  76. package/dist/helpers/reflect.mjs +0 -281
  77. package/dist/helpers/reflect.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
@@ -1,9 +1,11 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
  const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
3
3
  const require_types_plugin = require('../types/plugin.cjs');
4
- let _powerlines_deepkit_utilities = require("@powerlines/deepkit/utilities");
4
+ let _stryke_type_checks_is_set_object = require("@stryke/type-checks/is-set-object");
5
5
  let _powerlines_plugin_babel_helpers_create_plugin = require("@powerlines/plugin-babel/helpers/create-plugin");
6
6
  let _powerlines_plugin_babel_helpers_module_helpers = require("@powerlines/plugin-babel/helpers/module-helpers");
7
+ let _powerlines_schema = require("@powerlines/schema");
8
+ let _stryke_type_checks_is_undefined = require("@stryke/type-checks/is-undefined");
7
9
 
8
10
  //#region src/babel/plugin.ts
9
11
  function __assignType(fn, args) {
@@ -11,79 +13,30 @@ function __assignType(fn, args) {
11
13
  return fn;
12
14
  }
13
15
  const envBabelPlugin = (_powerlines_plugin_babel_helpers_create_plugin.createBabelPlugin.Ω = [[() => require_types_plugin.__ΩEnvPluginContext, "n!"]], (0, _powerlines_plugin_babel_helpers_create_plugin.createBabelPlugin)("env", __assignType(({ logger, context }) => {
14
- function extractEnv(node, pass, isInjectable = false, isUsingBuiltin = false) {
15
- const envTypesAliasProperties = context.env.types.env?.getProperties().filter(__assignType((prop) => prop.getAlias().length > 0, [
16
- "prop",
17
- "",
18
- "P\"2!\"/\""
19
- ]));
16
+ const vars = (0, _powerlines_schema.getProperties)(context.env.vars);
17
+ function extractEnv(node, pass, isInjectable = false) {
20
18
  if (node.name) {
21
19
  const name = node.name.replace(new RegExp(`^(${context.config.env.prefix.join("|")})_`), "");
22
20
  logger.trace({
23
21
  meta: { category: "env" },
24
22
  message: `Environment variable ${name} found in ${pass.filename || "unknown file"}.`
25
23
  });
26
- if (context.env.types.env?.hasProperty(name) || envTypesAliasProperties.some(__assignType((prop) => prop.getAlias().includes(name), [
27
- "prop",
28
- "",
29
- "P\"2!\"/\""
30
- ]))) {
31
- const envProperty = context.env.types.env.hasProperty(name) ? context.env.types.env.getProperty(name) : envTypesAliasProperties.find(__assignType((prop) => prop.getAlias().includes(name), [
32
- "prop",
33
- "",
34
- "P\"2!\"/\""
35
- ]));
36
- if (!envProperty || envProperty.isIgnored()) return;
37
- if (!context.env.used.env.hasProperty(name)) {
38
- logger.debug({
39
- meta: { category: "env" },
40
- message: `Adding "${name}" environment variables found in "${pass.filename || "unknown file"}" to used environment configuration reflection object.`
41
- });
42
- context.env.used.env.addProperty(envProperty.property);
24
+ if (name in vars && (0, _stryke_type_checks_is_set_object.isSetObject)(vars[name]) && !vars[name]?.metadata?.isIgnored) {
25
+ vars[name].metadata ??= {};
26
+ logger.debug({
27
+ meta: { category: "env" },
28
+ message: `The "${name}" environment variable is used in the source code file "${pass.filename || "unknown file"}" and will be added to the environment schema's active variables list.`
29
+ });
30
+ vars[name].metadata.active ??= [];
31
+ vars[name].metadata.active.push(name);
32
+ if (!vars[name].metadata.isRuntime && (context.config.env.inject && isInjectable || context.config.env.validate)) {
33
+ if (context.config.env.validate && !vars[name].optional && (0, _stryke_type_checks_is_undefined.isUndefined)(vars[name].metadata.default)) throw new Error(`Environment variable \`${name}\` is missing a default value, but is active in the source code${pass.filename ? ` file \`${pass.filename}\`` : ""}.\n\nPlease add a default value to the schema, or if this variable is optional, please mark it as optional in the type definition.`);
34
+ return (0, _powerlines_schema.stringifyValue)(vars[name].metadata.default);
43
35
  }
44
- if (context.config.env.inject && isInjectable) {
45
- let value = context.env.parsed?.[name];
46
- if (value === void 0) {
47
- const prefix = context.config.env.prefix.find(__assignType((pre) => {
48
- return context.env.parsed[`${pre.replace(/_$/g, "")}_${name}`];
49
- }, [
50
- "pre",
51
- "",
52
- "P\"2!\"/\""
53
- ]));
54
- if (prefix) value = context.env.parsed[`${prefix.replace(/_$/g, "")}_${name}`];
55
- }
56
- value ??= envProperty.getDefaultValue();
57
- if (envProperty.isValueRequired() && value === void 0) throw new Error(`Environment variable \`${name}\` is not defined in the .env configuration files`);
58
- return (0, _powerlines_deepkit_utilities.stringifyDefaultValue)(envProperty, value);
59
- }
60
- } else if (context.config.env.validate) throw new Error(`The "${name}" environment variable is not defined in the \`env\` type definition, but is used in the source code file ${pass.filename ? pass.filename : "unknown"}.
61
-
62
- The following environment configuration names are defined in the \`env\` type definition: \n${context.env.types.env?.getPropertyNames().sort(__assignType((a, b) => String(a).localeCompare(String(b)), [
63
- "a",
64
- "b",
65
- "",
66
- "P\"2!\"2\"\"/#"
67
- ])).map(__assignType((typeDef) => ` - ${String(typeDef)} ${envTypesAliasProperties.some(__assignType((prop) => prop.getNameAsString() === String(typeDef) && prop.getAlias().length > 0, [
68
- "prop",
69
- "",
70
- "P\"2!\"/\""
71
- ])) ? `(Alias: ${envTypesAliasProperties?.find(__assignType((prop) => prop.getNameAsString() === String(typeDef), [
72
- "prop",
73
- "",
74
- "P\"2!\"/\""
75
- ]))?.getAlias().join(", ")})` : ""}`, [
76
- "typeDef",
77
- "",
78
- "P\"2!\"/\""
79
- ])).join("\n")} \n\nUsing the following env prefix: \n${context.config.env.prefix.map(__assignType((prefix) => ` - ${prefix}`, [
80
- "prefix",
81
- "",
82
- "P\"2!\"/\""
83
- ])).join("\n")} \n\nPlease check your \`env\` configuration option. If you are using a custom dotenv type definition, please make sure that the configuration names match the ones in the code. \n\n`);
84
- else if (pass.filename && isUsingBuiltin) logger.warn({
36
+ } else if (context.config.env.validate) throw new Error(`Environment variable \`${name}\` is active in the source code${pass.filename ? ` file \`${pass.filename}\`` : ""}, but is not defined in the \`vars\` schema. Please check the \`env.vars\` configuration option. If you are using a custom env schema, please make sure that the configuration variable names match the ones used in the source code.`);
37
+ else logger.warn({
85
38
  meta: { category: "env" },
86
- message: `The "${name}" environment variable is used in the source code file ${pass.filename}, but is not defined in the \`env\` type definition. If this is intentional, you can ignore this warning. Otherwise, please check your \`env\` configuration option. If you are using a custom dotenv type definition, please make sure that the configuration names match the ones in the code.`
39
+ message: `Environment variable \`${name}\` is active in the source code${pass.filename ? ` file \`${pass.filename}\`` : ""}, but is not defined in the \`vars\` schema. If this is intentional, you can ignore this warning. Otherwise, please check the \`env.vars\` configuration option. If you are using a custom env schema, please make sure that the configuration variable names match the ones used in the source code.`
87
40
  });
88
41
  }
89
42
  }
@@ -91,15 +44,14 @@ const envBabelPlugin = (_powerlines_plugin_babel_helpers_create_plugin.createBab
91
44
  "node",
92
45
  "pass",
93
46
  "isInjectable",
94
- "isUsingBuiltin",
95
47
  "extractEnv",
96
- "P!2!!2\"\"2#\"2$\"/%"
48
+ "P!2!!2\"\"2#\"/$"
97
49
  ];
98
50
  return { visitor: { MemberExpression: __assignType(function MemberExpression(path, pass) {
99
51
  if (path.get("object")?.get("property")?.isIdentifier({ name: "env" }) && path.get("object")?.get("object")?.isIdentifier({ name: "process" }) && path.get("property")?.isIdentifier()) {
100
52
  const identifier = path.get("property")?.node;
101
53
  if (!identifier.name) return;
102
- extractEnv(identifier, pass, false, false);
54
+ extractEnv(identifier, pass, false);
103
55
  path.replaceWithSourceString(`env.${identifier.name}`);
104
56
  (0, _powerlines_plugin_babel_helpers_module_helpers.addImport)(path, {
105
57
  module: `${context.config.framework?.name || "powerlines"}:env`,
@@ -109,7 +61,7 @@ const envBabelPlugin = (_powerlines_plugin_babel_helpers_create_plugin.createBab
109
61
  } else if (path.get("object")?.get("property")?.isIdentifier({ name: "env" }) && path.get("object")?.get("object")?.isMetaProperty() && path.get("property")?.isIdentifier()) {
110
62
  const identifier = path.get("property")?.node;
111
63
  if (!identifier.name) return;
112
- extractEnv(identifier, pass, false, false);
64
+ extractEnv(identifier, pass, false);
113
65
  path.replaceWithSourceString(`env.${identifier.name}`);
114
66
  (0, _powerlines_plugin_babel_helpers_module_helpers.addImport)(path, {
115
67
  module: `${context.config.framework?.name || "powerlines"}:env`,
@@ -119,7 +71,7 @@ const envBabelPlugin = (_powerlines_plugin_babel_helpers_create_plugin.createBab
119
71
  } else if (path.get("object")?.isIdentifier({ name: "env" }) && path.get("property")?.isIdentifier()) {
120
72
  const identifier = path.get("property")?.node;
121
73
  if (!identifier.name) return;
122
- extractEnv(identifier, pass, false, true);
74
+ extractEnv(identifier, pass, false);
123
75
  }
124
76
  }, [
125
77
  "NodePath",
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.d.cts","names":[],"sources":["../../src/babel/plugin.ts"],"mappings":";;cAgCa,cAAA,qCAAc,iCAAA,CAAA,gBAAA,CAuM1B,uBAAA"}
1
+ {"version":3,"file":"plugin.d.cts","names":[],"sources":["../../src/babel/plugin.ts"],"mappings":";;cAkCa,cAAA,qCAAc,iCAAA,CAAA,gBAAA,CA4J1B,uBAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.d.mts","names":[],"sources":["../../src/babel/plugin.ts"],"mappings":";;cAgCa,cAAA,qCAAc,iCAAA,CAAA,gBAAA,CAuM1B,uBAAA"}
1
+ {"version":3,"file":"plugin.d.mts","names":[],"sources":["../../src/babel/plugin.ts"],"mappings":";;cAkCa,cAAA,qCAAc,iCAAA,CAAA,gBAAA,CA4J1B,uBAAA"}
@@ -1,7 +1,9 @@
1
1
  import { __ΩEnvPluginContext } from "../types/plugin.mjs";
2
- import { stringifyDefaultValue } from "@powerlines/deepkit/utilities";
2
+ import { isSetObject } from "@stryke/type-checks/is-set-object";
3
3
  import { createBabelPlugin } from "@powerlines/plugin-babel/helpers/create-plugin";
4
4
  import { addImport } from "@powerlines/plugin-babel/helpers/module-helpers";
5
+ import { getProperties, stringifyValue } from "@powerlines/schema";
6
+ import { isUndefined } from "@stryke/type-checks/is-undefined";
5
7
 
6
8
  //#region src/babel/plugin.ts
7
9
  function __assignType(fn, args) {
@@ -9,79 +11,30 @@ function __assignType(fn, args) {
9
11
  return fn;
10
12
  }
11
13
  const envBabelPlugin = (createBabelPlugin.Ω = [[() => __ΩEnvPluginContext, "n!"]], createBabelPlugin("env", __assignType(({ logger, context }) => {
12
- function extractEnv(node, pass, isInjectable = false, isUsingBuiltin = false) {
13
- const envTypesAliasProperties = context.env.types.env?.getProperties().filter(__assignType((prop) => prop.getAlias().length > 0, [
14
- "prop",
15
- "",
16
- "P\"2!\"/\""
17
- ]));
14
+ const vars = getProperties(context.env.vars);
15
+ function extractEnv(node, pass, isInjectable = false) {
18
16
  if (node.name) {
19
17
  const name = node.name.replace(new RegExp(`^(${context.config.env.prefix.join("|")})_`), "");
20
18
  logger.trace({
21
19
  meta: { category: "env" },
22
20
  message: `Environment variable ${name} found in ${pass.filename || "unknown file"}.`
23
21
  });
24
- if (context.env.types.env?.hasProperty(name) || envTypesAliasProperties.some(__assignType((prop) => prop.getAlias().includes(name), [
25
- "prop",
26
- "",
27
- "P\"2!\"/\""
28
- ]))) {
29
- const envProperty = context.env.types.env.hasProperty(name) ? context.env.types.env.getProperty(name) : envTypesAliasProperties.find(__assignType((prop) => prop.getAlias().includes(name), [
30
- "prop",
31
- "",
32
- "P\"2!\"/\""
33
- ]));
34
- if (!envProperty || envProperty.isIgnored()) return;
35
- if (!context.env.used.env.hasProperty(name)) {
36
- logger.debug({
37
- meta: { category: "env" },
38
- message: `Adding "${name}" environment variables found in "${pass.filename || "unknown file"}" to used environment configuration reflection object.`
39
- });
40
- context.env.used.env.addProperty(envProperty.property);
22
+ if (name in vars && isSetObject(vars[name]) && !vars[name]?.metadata?.isIgnored) {
23
+ vars[name].metadata ??= {};
24
+ logger.debug({
25
+ meta: { category: "env" },
26
+ message: `The "${name}" environment variable is used in the source code file "${pass.filename || "unknown file"}" and will be added to the environment schema's active variables list.`
27
+ });
28
+ vars[name].metadata.active ??= [];
29
+ vars[name].metadata.active.push(name);
30
+ if (!vars[name].metadata.isRuntime && (context.config.env.inject && isInjectable || context.config.env.validate)) {
31
+ if (context.config.env.validate && !vars[name].optional && isUndefined(vars[name].metadata.default)) throw new Error(`Environment variable \`${name}\` is missing a default value, but is active in the source code${pass.filename ? ` file \`${pass.filename}\`` : ""}.\n\nPlease add a default value to the schema, or if this variable is optional, please mark it as optional in the type definition.`);
32
+ return stringifyValue(vars[name].metadata.default);
41
33
  }
42
- if (context.config.env.inject && isInjectable) {
43
- let value = context.env.parsed?.[name];
44
- if (value === void 0) {
45
- const prefix = context.config.env.prefix.find(__assignType((pre) => {
46
- return context.env.parsed[`${pre.replace(/_$/g, "")}_${name}`];
47
- }, [
48
- "pre",
49
- "",
50
- "P\"2!\"/\""
51
- ]));
52
- if (prefix) value = context.env.parsed[`${prefix.replace(/_$/g, "")}_${name}`];
53
- }
54
- value ??= envProperty.getDefaultValue();
55
- if (envProperty.isValueRequired() && value === void 0) throw new Error(`Environment variable \`${name}\` is not defined in the .env configuration files`);
56
- return stringifyDefaultValue(envProperty, value);
57
- }
58
- } else if (context.config.env.validate) throw new Error(`The "${name}" environment variable is not defined in the \`env\` type definition, but is used in the source code file ${pass.filename ? pass.filename : "unknown"}.
59
-
60
- The following environment configuration names are defined in the \`env\` type definition: \n${context.env.types.env?.getPropertyNames().sort(__assignType((a, b) => String(a).localeCompare(String(b)), [
61
- "a",
62
- "b",
63
- "",
64
- "P\"2!\"2\"\"/#"
65
- ])).map(__assignType((typeDef) => ` - ${String(typeDef)} ${envTypesAliasProperties.some(__assignType((prop) => prop.getNameAsString() === String(typeDef) && prop.getAlias().length > 0, [
66
- "prop",
67
- "",
68
- "P\"2!\"/\""
69
- ])) ? `(Alias: ${envTypesAliasProperties?.find(__assignType((prop) => prop.getNameAsString() === String(typeDef), [
70
- "prop",
71
- "",
72
- "P\"2!\"/\""
73
- ]))?.getAlias().join(", ")})` : ""}`, [
74
- "typeDef",
75
- "",
76
- "P\"2!\"/\""
77
- ])).join("\n")} \n\nUsing the following env prefix: \n${context.config.env.prefix.map(__assignType((prefix) => ` - ${prefix}`, [
78
- "prefix",
79
- "",
80
- "P\"2!\"/\""
81
- ])).join("\n")} \n\nPlease check your \`env\` configuration option. If you are using a custom dotenv type definition, please make sure that the configuration names match the ones in the code. \n\n`);
82
- else if (pass.filename && isUsingBuiltin) logger.warn({
34
+ } else if (context.config.env.validate) throw new Error(`Environment variable \`${name}\` is active in the source code${pass.filename ? ` file \`${pass.filename}\`` : ""}, but is not defined in the \`vars\` schema. Please check the \`env.vars\` configuration option. If you are using a custom env schema, please make sure that the configuration variable names match the ones used in the source code.`);
35
+ else logger.warn({
83
36
  meta: { category: "env" },
84
- message: `The "${name}" environment variable is used in the source code file ${pass.filename}, but is not defined in the \`env\` type definition. If this is intentional, you can ignore this warning. Otherwise, please check your \`env\` configuration option. If you are using a custom dotenv type definition, please make sure that the configuration names match the ones in the code.`
37
+ message: `Environment variable \`${name}\` is active in the source code${pass.filename ? ` file \`${pass.filename}\`` : ""}, but is not defined in the \`vars\` schema. If this is intentional, you can ignore this warning. Otherwise, please check the \`env.vars\` configuration option. If you are using a custom env schema, please make sure that the configuration variable names match the ones used in the source code.`
85
38
  });
86
39
  }
87
40
  }
@@ -89,15 +42,14 @@ const envBabelPlugin = (createBabelPlugin.Ω = [[() => __ΩEnvPluginContext, "n!
89
42
  "node",
90
43
  "pass",
91
44
  "isInjectable",
92
- "isUsingBuiltin",
93
45
  "extractEnv",
94
- "P!2!!2\"\"2#\"2$\"/%"
46
+ "P!2!!2\"\"2#\"/$"
95
47
  ];
96
48
  return { visitor: { MemberExpression: __assignType(function MemberExpression(path, pass) {
97
49
  if (path.get("object")?.get("property")?.isIdentifier({ name: "env" }) && path.get("object")?.get("object")?.isIdentifier({ name: "process" }) && path.get("property")?.isIdentifier()) {
98
50
  const identifier = path.get("property")?.node;
99
51
  if (!identifier.name) return;
100
- extractEnv(identifier, pass, false, false);
52
+ extractEnv(identifier, pass, false);
101
53
  path.replaceWithSourceString(`env.${identifier.name}`);
102
54
  addImport(path, {
103
55
  module: `${context.config.framework?.name || "powerlines"}:env`,
@@ -107,7 +59,7 @@ const envBabelPlugin = (createBabelPlugin.Ω = [[() => __ΩEnvPluginContext, "n!
107
59
  } else if (path.get("object")?.get("property")?.isIdentifier({ name: "env" }) && path.get("object")?.get("object")?.isMetaProperty() && path.get("property")?.isIdentifier()) {
108
60
  const identifier = path.get("property")?.node;
109
61
  if (!identifier.name) return;
110
- extractEnv(identifier, pass, false, false);
62
+ extractEnv(identifier, pass, false);
111
63
  path.replaceWithSourceString(`env.${identifier.name}`);
112
64
  addImport(path, {
113
65
  module: `${context.config.framework?.name || "powerlines"}:env`,
@@ -117,7 +69,7 @@ const envBabelPlugin = (createBabelPlugin.Ω = [[() => __ΩEnvPluginContext, "n!
117
69
  } else if (path.get("object")?.isIdentifier({ name: "env" }) && path.get("property")?.isIdentifier()) {
118
70
  const identifier = path.get("property")?.node;
119
71
  if (!identifier.name) return;
120
- extractEnv(identifier, pass, false, true);
72
+ extractEnv(identifier, pass, false);
121
73
  }
122
74
  }, [
123
75
  "NodePath",
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.mjs","names":[],"sources":["../../src/babel/plugin.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { NodePath } from \"@babel/core\";\nimport * as t from \"@babel/types\";\nimport { stringifyDefaultValue } from \"@powerlines/deepkit/utilities\";\nimport { createBabelPlugin } from \"@powerlines/plugin-babel/helpers/create-plugin\";\nimport { addImport } from \"@powerlines/plugin-babel/helpers/module-helpers\";\nimport { BabelPluginPass } from \"@powerlines/plugin-babel/types/config\";\nimport { EnvPluginContext } from \"../types/plugin\";\n\n/*\n * The Powerlines - Environment Configuration Babel Plugin\n *\n * @param babel - The Babel core module\n * @returns The Babel plugin object\n */\nexport const envBabelPlugin = createBabelPlugin<EnvPluginContext>(\n \"env\",\n ({ logger, context }) => {\n function extractEnv(\n node: t.Identifier,\n pass: BabelPluginPass,\n isInjectable = false,\n isUsingBuiltin = false\n ) {\n const envTypesAliasProperties = context.env.types.env\n ?.getProperties()\n .filter(prop => prop.getAlias().length > 0);\n\n if (node.name) {\n const name = node.name.replace(\n new RegExp(`^(${context.config.env.prefix.join(\"|\")})_`),\n \"\"\n );\n\n logger.trace({\n meta: {\n category: \"env\"\n },\n message: `Environment variable ${name} found in ${\n pass.filename || \"unknown file\"\n }.`\n });\n\n if (\n context.env.types.env?.hasProperty(name) ||\n envTypesAliasProperties.some(prop => prop.getAlias().includes(name))\n ) {\n const envProperty = context.env.types.env.hasProperty(name)\n ? context.env.types.env.getProperty(name)\n : envTypesAliasProperties.find(prop =>\n prop.getAlias().includes(name)\n );\n if (!envProperty || envProperty.isIgnored()) {\n return;\n }\n\n if (!context.env.used.env.hasProperty(name)) {\n logger.debug({\n meta: {\n category: \"env\"\n },\n message: `Adding \"${name}\" environment variables found in \"${\n pass.filename || \"unknown file\"\n }\" to used environment configuration reflection object.`\n });\n\n context.env.used.env.addProperty(envProperty.property);\n }\n\n if (context.config.env.inject && isInjectable) {\n let value = context.env.parsed?.[name];\n if (value === undefined) {\n const prefix = context.config.env.prefix.find(pre => {\n return context.env.parsed[`${pre.replace(/_$/g, \"\")}_${name}`];\n });\n if (prefix) {\n value =\n context.env.parsed[`${prefix.replace(/_$/g, \"\")}_${name}`];\n }\n }\n\n value ??= envProperty.getDefaultValue();\n\n if (envProperty.isValueRequired() && value === undefined) {\n throw new Error(\n `Environment variable \\`${name}\\` is not defined in the .env configuration files`\n );\n }\n\n return stringifyDefaultValue(envProperty, value);\n }\n } else if (context.config.env.validate) {\n throw new Error(\n `The \"${name}\" environment variable is not defined in the \\`env\\` type definition, but is used in the source code file ${\n pass.filename ? pass.filename : \"unknown\"\n }.\n\n The following environment configuration names are defined in the \\`env\\` type definition: \\n${context.env.types.env\n ?.getPropertyNames()\n .sort((a, b) => String(a).localeCompare(String(b)))\n .map(\n typeDef =>\n ` - ${String(typeDef)} ${\n envTypesAliasProperties.some(\n prop =>\n prop.getNameAsString() === String(typeDef) &&\n prop.getAlias().length > 0\n )\n ? `(Alias: ${envTypesAliasProperties\n ?.find(\n prop => prop.getNameAsString() === String(typeDef)\n )\n ?.getAlias()\n .join(\", \")})`\n : \"\"\n }`\n )\n .join(\n \"\\n\"\n )} \\n\\nUsing the following env prefix: \\n${context.config.env.prefix\n .map(prefix => ` - ${prefix}`)\n .join(\n \"\\n\"\n )} \\n\\nPlease check your \\`env\\` configuration option. If you are using a custom dotenv type definition, please make sure that the configuration names match the ones in the code. \\n\\n`\n );\n } else if (pass.filename && isUsingBuiltin) {\n logger.warn({\n meta: {\n category: \"env\"\n },\n message: `The \"${\n name\n }\" environment variable is used in the source code file ${\n pass.filename\n }, but is not defined in the \\`env\\` type definition. If this is intentional, you can ignore this warning. Otherwise, please check your \\`env\\` configuration option. If you are using a custom dotenv type definition, please make sure that the configuration names match the ones in the code.`\n });\n }\n }\n\n return undefined;\n }\n\n return {\n visitor: {\n MemberExpression(\n path: NodePath<t.MemberExpression>,\n pass: BabelPluginPass\n ) {\n if (\n path\n .get(\"object\")\n ?.get(\"property\")\n ?.isIdentifier({ name: \"env\" }) &&\n path\n .get(\"object\")\n ?.get(\"object\")\n ?.isIdentifier({ name: \"process\" }) &&\n path.get(\"property\")?.isIdentifier()\n ) {\n // process.env.CONFIG_NAME\n\n const identifier = path.get(\"property\")?.node as t.Identifier;\n if (!identifier.name) {\n return;\n }\n\n extractEnv(identifier, pass, false, false);\n\n path.replaceWithSourceString(`env.${identifier.name}`);\n addImport(path, {\n module: `${context.config.framework?.name || \"powerlines\"}:env`,\n name: \"env\",\n imported: \"env\"\n });\n } else if (\n path\n .get(\"object\")\n ?.get(\"property\")\n ?.isIdentifier({ name: \"env\" }) &&\n path.get(\"object\")?.get(\"object\")?.isMetaProperty() &&\n path.get(\"property\")?.isIdentifier()\n ) {\n // import.meta.env.CONFIG_NAME\n\n const identifier = path.get(\"property\")?.node as t.Identifier;\n if (!identifier.name) {\n return;\n }\n\n extractEnv(identifier, pass, false, false);\n\n path.replaceWithSourceString(`env.${identifier.name}`);\n addImport(path, {\n module: `${context.config.framework?.name || \"powerlines\"}:env`,\n name: \"env\",\n imported: \"env\"\n });\n } else if (\n path.get(\"object\")?.isIdentifier({ name: \"env\" }) &&\n path.get(\"property\")?.isIdentifier()\n ) {\n // env.CONFIG_NAME\n\n const identifier = path.get(\"property\")?.node as t.Identifier;\n if (!identifier.name) {\n return;\n }\n\n extractEnv(identifier, pass, false, true);\n }\n }\n }\n };\n }\n);\n"],"mappings":";;;;;;AAEA,SAAS,aAAY,IAAK,MAAC;;CAE1B,OAAK;AACN;4HAWE,sBAEI;CACN,SAAW,WAAU,MAAM,MAAM,eAAA,OAAA,iBAAA,OAAA;EACjC,MAAS,0BAAwB,QAAO,IAAA,MAAW,KAAQ,cAAU,EAAA,OAAA,cAAA,SAAA,KAAA,SAAA,EAAA,SAAA,GAAA;GAAA;GAAA;GAAA;EAAA,CAAA,CAAA;EACrE,IAAQ,KAAC,MAAA;GACH,MAAG,OAAU,KAAE,KAAO,QAAA,IAAW,OAAO,KAAM,QAAQ,OAAO,IAAA,OAAQ,KAAA,GAAA,EAAA,GAAA,GAAA,EAAA;GACrE,OAAG,MAAA;IACD,MAAC,kBAER;IACM,SAAU,wBAAe,KAAc,YAAM,KAAA,YAAA,eAAA;GACnD,CAAA;GACG,IAAM,QAAQ,IAAI,MAAM,KAAK,YAAA,IAAA,KAAA,wBAAA,KAAA,cAAA,SAAA,KAAA,SAAA,EAAA,SAAA,IAAA,GAAA;IAAA;IAAA;IAAA;GAAA,CAAA,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AAA,MAAA;;IAEA,QAAO,GAAA,QAAA,OAAA,WAAsB,QAAa,aAAM;IAClD,MAAA;IACA,UAAS;GACT,CAAA;EACF,OAAK,IAAM,KAAK,IAAG,QAAA,GAAY,aAAY,EACzC,MAAI,MACN,CAAC,KAAI,KAAA,IAAA,UAAA,GAAA,aAAA,GAAA;GAEH,MAAI,aAAU,KAAA,IAAY,UAAA,GAAc;GACxC,IAAI,CAAA,WAAA,MACF;GAEF,WAAW,YAAE,MAAA,OAAA,IAAA;EACf;CACF,GAAG;EAAC;EAAQ;EAAA;EAAA;EAA4B;CAAA,CAAA,EAC1C,EACF;AACF,GAAG;CAAC;CAAU;CAAI;AAAS,CAAA,CAAA"}
1
+ {"version":3,"file":"plugin.mjs","names":[],"sources":["../../src/babel/plugin.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { NodePath } from \"@babel/core\";\nimport * as t from \"@babel/types\";\nimport { createBabelPlugin } from \"@powerlines/plugin-babel/helpers/create-plugin\";\nimport { addImport } from \"@powerlines/plugin-babel/helpers/module-helpers\";\nimport { BabelPluginPass } from \"@powerlines/plugin-babel/types/config\";\nimport { getProperties, stringifyValue } from \"@powerlines/schema\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport { isUndefined } from \"@stryke/type-checks/is-undefined\";\nimport { EnvPluginContext, EnvSchemaMetadata } from \"../types/plugin\";\n\n/*\n * The Powerlines - Environment Configuration Babel Plugin\n *\n * @param babel - The Babel core module\n * @returns The Babel plugin object\n */\nexport const envBabelPlugin = createBabelPlugin<EnvPluginContext>(\n \"env\",\n ({ logger, context }) => {\n const vars = getProperties(context.env.vars);\n function extractEnv(\n node: t.Identifier,\n pass: BabelPluginPass,\n isInjectable = false\n ) {\n if (node.name) {\n const name = node.name.replace(\n new RegExp(`^(${context.config.env.prefix.join(\"|\")})_`),\n \"\"\n );\n\n logger.trace({\n meta: {\n category: \"env\"\n },\n message: `Environment variable ${name} found in ${\n pass.filename || \"unknown file\"\n }.`\n });\n\n if (\n name in vars &&\n isSetObject(vars[name]) &&\n !vars[name]?.metadata?.isIgnored\n ) {\n vars[name].metadata ??= {} as EnvSchemaMetadata;\n\n logger.debug({\n meta: {\n category: \"env\"\n },\n message: `The \"${name}\" environment variable is used in the source code file \"${\n pass.filename || \"unknown file\"\n }\" and will be added to the environment schema's active variables list.`\n });\n\n vars[name].metadata.active ??= [];\n vars[name].metadata.active.push(name);\n if (\n !vars[name].metadata.isRuntime &&\n ((context.config.env.inject && isInjectable) ||\n context.config.env.validate)\n ) {\n if (\n context.config.env.validate &&\n !vars[name].optional &&\n isUndefined(vars[name].metadata.default)\n ) {\n throw new Error(\n `Environment variable \\`${\n name\n }\\` is missing a default value, but is active in the source code${\n pass.filename ? ` file \\`${pass.filename}\\`` : \"\"\n }.\\n\\nPlease add a default value to the schema, or if this variable is optional, please mark it as optional in the type definition.`\n );\n }\n\n return stringifyValue(vars[name].metadata.default);\n }\n } else if (context.config.env.validate) {\n throw new Error(\n `Environment variable \\`${name}\\` is active in the source code${\n pass.filename ? ` file \\`${pass.filename}\\`` : \"\"\n }, but is not defined in the \\`vars\\` schema. Please check the \\`env.vars\\` configuration option. If you are using a custom env schema, please make sure that the configuration variable names match the ones used in the source code.`\n );\n } else {\n logger.warn({\n meta: {\n category: \"env\"\n },\n message: `Environment variable \\`${name}\\` is active in the source code${\n pass.filename ? ` file \\`${pass.filename}\\`` : \"\"\n }, but is not defined in the \\`vars\\` schema. If this is intentional, you can ignore this warning. Otherwise, please check the \\`env.vars\\` configuration option. If you are using a custom env schema, please make sure that the configuration variable names match the ones used in the source code.`\n });\n }\n }\n\n return undefined;\n }\n\n return {\n visitor: {\n MemberExpression(\n path: NodePath<t.MemberExpression>,\n pass: BabelPluginPass\n ) {\n if (\n path\n .get(\"object\")\n ?.get(\"property\")\n ?.isIdentifier({ name: \"env\" }) &&\n path\n .get(\"object\")\n ?.get(\"object\")\n ?.isIdentifier({ name: \"process\" }) &&\n path.get(\"property\")?.isIdentifier()\n ) {\n // process.env.CONFIG_NAME\n\n const identifier = path.get(\"property\")?.node as t.Identifier;\n if (!identifier.name) {\n return;\n }\n\n extractEnv(identifier, pass, false);\n\n path.replaceWithSourceString(`env.${identifier.name}`);\n addImport(path, {\n module: `${context.config.framework?.name || \"powerlines\"}:env`,\n name: \"env\",\n imported: \"env\"\n });\n } else if (\n path\n .get(\"object\")\n ?.get(\"property\")\n ?.isIdentifier({ name: \"env\" }) &&\n path.get(\"object\")?.get(\"object\")?.isMetaProperty() &&\n path.get(\"property\")?.isIdentifier()\n ) {\n // import.meta.env.CONFIG_NAME\n\n const identifier = path.get(\"property\")?.node as t.Identifier;\n if (!identifier.name) {\n return;\n }\n\n extractEnv(identifier, pass, false);\n\n path.replaceWithSourceString(`env.${identifier.name}`);\n addImport(path, {\n module: `${context.config.framework?.name || \"powerlines\"}:env`,\n name: \"env\",\n imported: \"env\"\n });\n } else if (\n path.get(\"object\")?.isIdentifier({ name: \"env\" }) &&\n path.get(\"property\")?.isIdentifier()\n ) {\n // env.CONFIG_NAME\n\n const identifier = path.get(\"property\")?.node as t.Identifier;\n if (!identifier.name) {\n return;\n }\n\n extractEnv(identifier, pass, false);\n }\n }\n }\n };\n }\n);\n"],"mappings":";;;;;;;;AAEA,SAAS,aAAY,IAAK,MAAC;;CAE1B,OAAK;AACN;4HAaA,QACA,cACM;CACN,MAAQ,OAAC,cAAmB,QAAA,IAAW,IAAM;CAC7C,SAAS,WAAA,MAAkB,MAAO,eAAW,OAAO;EACpD,IAAQ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AI,UACN,CAAC,KAAI,KAAA,IAAA,UAAA,GAAA,aAAA,GAAA;GAEH,MAAI,aAAe,KAAG,IAAA,UAAY,GAAA;GAClC,IAAI,CAAC,WAAW,MACd;GAEF,WAAW,YAAS,MAAS,KAAI;GACjC,KAAK,wBAAsB,OAAS,WAAC,MAAA;GACrC,UAAG,MAAA;IACD,QAAM,GAAK,QAAC,OAAS,WAAW,QAAA,aAAA;IAChC,MAAE;IACF,UAAU;GACZ,CAAC;EACH,OAAO,IAAA,KAAA,IAAA,QAAA,GAAA,IAAA,UAAA,GAAA,aAAA,EACL,MAAI,MACN,CAAC,KAAK,KAAK,IAAC,QAAM,GAAQ,IAAE,QAAA,GAAA,eAAA,KAAA,KAAA,IAAA,UAAA,GAAA,aAAA,GAAA;GAE1B,MAAI,aAAA,KAAA,IAAA,UAAA,GAAA;GACJ,IAAI,CAAA,WAAU,MACZ;GAEF,WAAU,YAAa,MAAA,KAAQ;GAC/B,KAAK,wBAAqB,OAAS,WAAK,MAAa;GACrD,UAAU,MAAC;IACT,QAAG,GAAA,QAAA,OAAA,WAAA,QAAA,aAAA;IACH,MAAA;;GAEF,CAAC;EACH,OAAE,IAAA,KAAA,IAAA,QAAA,GAAA,aAAA,EACA,MAAK,MACP,CAAC,KAAC,KAAS,IAAC,UAAK,GAAA,aAAA,GAAA;GAEf,MAAI,aAAe,KAAG,IAAM,UAAQ,GAAA;GACpC,IAAI,CAAC,WAAW,MACf;GAED,WAAW,YAAC,MAAA,KAAA;EACd;CACF,GAAG;EAAC;EAAY;EAAM;EAAA;EAAA;CAAA,CAAA,EACxB,EACF;AACF,GAAG;CAAC;CAAU;CAAI;AAAS,CAAC,CAAC"}
@@ -1,7 +1,8 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
  const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
3
3
  const require_types_plugin = require('../types/plugin.cjs');
4
- let _powerlines_deepkit_vendor_type = require("@powerlines/deepkit/vendor/type");
4
+ let _powerlines_schema_helpers = require("@powerlines/schema/helpers");
5
+ let _stryke_path_join = require("@stryke/path/join");
5
6
  let powerlines_plugin_utils = require("powerlines/plugin-utils");
6
7
  let _alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
7
8
  let _alloy_js_core = require("@alloy-js/core");
@@ -11,7 +12,7 @@ let _powerlines_plugin_alloy_core_contexts_context = require("@powerlines/plugin
11
12
  let _powerlines_plugin_alloy_markdown_components_heading = require("@powerlines/plugin-alloy/markdown/components/heading");
12
13
  let _powerlines_plugin_alloy_markdown_components_markdown_file = require("@powerlines/plugin-alloy/markdown/components/markdown-file");
13
14
  let _powerlines_plugin_alloy_markdown_components_markdown_table = require("@powerlines/plugin-alloy/markdown/components/markdown-table");
14
- let _stryke_path_join = require("@stryke/path/join");
15
+ let _powerlines_schema_codegen = require("@powerlines/schema/codegen");
15
16
 
16
17
  //#region src/components/docs.tsx
17
18
  const __ΩPartial = [
@@ -28,15 +29,14 @@ const __ΩEnvDocsFileProps = [
28
29
  "levelOffset",
29
30
  0,
30
31
  "The heading level offset to apply to the generated documentation.",
31
- "reflection",
32
32
  "EnvDocsFileProps",
33
- "P!o!\"'4\"8>#?$!4%Mw&y"
33
+ "P!o!\"'4\"8>#?$Mw%y"
34
34
  ];
35
35
  /**
36
36
  * Generates the environment configuration markdown documentation for the Powerlines project.
37
37
  */
38
38
  function EnvDocsFile(props) {
39
- const { levelOffset = 0, reflection, ...rest } = props;
39
+ const { levelOffset = 0, ...rest } = props;
40
40
  const context = (_powerlines_plugin_alloy_core_contexts_context.usePowerlines.Ω = [[() => require_types_plugin.__ΩEnvPluginContext, "n!"]], (0, _powerlines_plugin_alloy_core_contexts_context.usePowerlines)());
41
41
  return (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_markdown_components_markdown_file.MarkdownFile, (0, _alloy_js_core_jsx_runtime.mergeProps)({ get path() {
42
42
  return (0, _stryke_path_join.joinPaths)((0, powerlines_plugin_utils.getDocsOutputPath)(context.config.root), "env.md");
@@ -72,25 +72,25 @@ function EnvDocsFile(props) {
72
72
  _alloy_js_core.code`The below list of environment variables are used as configuration parameters to drive the processing of the application. The data contained in these variables are **not** considered sensitive or confidential. Any values provided in these variables will be available in plain text.`,
73
73
  (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
74
74
  (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_markdown_components_markdown_table.MarkdownTable, { get data() {
75
- return reflection?.getProperties().filter(__assignType((property) => !property.isHidden() && !property.isIgnored() && !property.isReadonly() && !property.isInternal(), [
75
+ return Object.values((0, _powerlines_schema_helpers.getProperties)(context.env.vars)).filter(__assignType((property) => !property?.metadata?.isHidden && !property?.metadata?.isIgnored && !property?.metadata?.isReadonly && !property?.metadata?.isInternal, [
76
76
  "property",
77
77
  "",
78
78
  "P\"2!\"/\""
79
- ])).sort(__assignType((a, b) => a.getNameAsString().localeCompare(b.getNameAsString()), [
79
+ ])).sort(__assignType((a, b) => !a.metadata?.name && !b.metadata?.name ? 0 : !a.metadata?.name ? 1 : !b.metadata?.name ? -1 : a.metadata?.name.localeCompare(b.metadata?.name), [
80
80
  "a",
81
81
  "b",
82
82
  "",
83
83
  "P\"2!\"2\"\"/#"
84
- ])).map(__assignType((reflectionProperty) => {
84
+ ])).map(__assignType((property) => {
85
85
  return {
86
- name: reflectionProperty.getNameAsString().trim(),
87
- description: (reflectionProperty.getDescription() ?? "").trim(),
88
- type: (0, _powerlines_deepkit_vendor_type.stringifyType)(reflectionProperty.getType()).trim().replaceAll(/\s*(?:\||&)\s*/g, ", or "),
89
- defaultValue: reflectionProperty.hasDefault() ? String(reflectionProperty.getDefaultValue())?.includes("\"") ? reflectionProperty.getDefaultValue() : `\`${reflectionProperty.getDefaultValue()}\`` : "",
90
- required: reflectionProperty.isValueRequired() ? "" : "✔"
86
+ name: property.metadata?.name?.trim(),
87
+ description: (property.metadata?.description ?? "").trim(),
88
+ type: (0, _powerlines_schema_codegen.stringifyType)(property).trim().replaceAll(/\s*(?:\||&)\s*/g, ", or "),
89
+ defaultValue: property.metadata?.defaultValue ? (0, _powerlines_schema_codegen.stringifyType)(property.metadata.defaultValue) : "",
90
+ required: property.optional ? "" : "✔"
91
91
  };
92
92
  }, [
93
- "reflectionProperty",
93
+ "property",
94
94
  "",
95
95
  "P\"2!\"/\""
96
96
  ])) ?? [];
@@ -1,4 +1,3 @@
1
- import { ReflectionClass } from "@powerlines/deepkit/vendor/type";
2
1
  import { MarkdownFileProps } from "@powerlines/plugin-alloy/markdown/components/markdown-file";
3
2
 
4
3
  //#region src/components/docs.d.ts
@@ -12,7 +11,6 @@ interface EnvDocsFileProps extends Partial<MarkdownFileProps> {
12
11
  * @defaultValue 0
13
12
  */
14
13
  levelOffset?: number;
15
- reflection: ReflectionClass<any>;
16
14
  }
17
15
  /**
18
16
  * Generates the environment configuration markdown documentation for the Powerlines project.
@@ -1 +1 @@
1
- {"version":3,"file":"docs.d.cts","names":[],"sources":["../../src/components/docs.tsx"],"mappings":";;;;UAoCiB,gBAAA,SAAyB,OAAA,CAAQ,iBAAA;;AAAlD;;;;;;;EASE,WAAA;EAEA,UAAA,EAAY,eAAA;AAAA;;;;iBAME,WAAA,CAAY,KAAA,EAAO,gBAAgB,4BAAA,QAAA"}
1
+ {"version":3,"file":"docs.d.cts","names":[],"sources":["../../src/components/docs.tsx"],"mappings":";;;UAkCiB,gBAAA,SAAyB,OAAO,CAAC,iBAAA;;AAAlD;;;;;;;EASE,WAAA;AAAA;AAMF;;;AAAA,iBAAgB,WAAA,CAAY,KAAA,EAAO,gBAAgB,4BAAA,QAAA"}
@@ -1,4 +1,3 @@
1
- import { ReflectionClass } from "@powerlines/deepkit/vendor/type";
2
1
  import { MarkdownFileProps } from "@powerlines/plugin-alloy/markdown/components/markdown-file";
3
2
 
4
3
  //#region src/components/docs.d.ts
@@ -12,7 +11,6 @@ interface EnvDocsFileProps extends Partial<MarkdownFileProps> {
12
11
  * @defaultValue 0
13
12
  */
14
13
  levelOffset?: number;
15
- reflection: ReflectionClass<any>;
16
14
  }
17
15
  /**
18
16
  * Generates the environment configuration markdown documentation for the Powerlines project.
@@ -1 +1 @@
1
- {"version":3,"file":"docs.d.mts","names":[],"sources":["../../src/components/docs.tsx"],"mappings":";;;;UAoCiB,gBAAA,SAAyB,OAAA,CAAQ,iBAAA;;AAAlD;;;;;;;EASE,WAAA;EAEA,UAAA,EAAY,eAAA;AAAA;;;;iBAME,WAAA,CAAY,KAAA,EAAO,gBAAgB,4BAAA,QAAA"}
1
+ {"version":3,"file":"docs.d.mts","names":[],"sources":["../../src/components/docs.tsx"],"mappings":";;;UAkCiB,gBAAA,SAAyB,OAAO,CAAC,iBAAA;;AAAlD;;;;;;;EASE,WAAA;AAAA;AAMF;;;AAAA,iBAAgB,WAAA,CAAY,KAAA,EAAO,gBAAgB,4BAAA,QAAA"}
@@ -1,5 +1,6 @@
1
1
  import { __ΩEnvPluginContext } from "../types/plugin.mjs";
2
- import { stringifyType } from "@powerlines/deepkit/vendor/type";
2
+ import { getProperties } from "@powerlines/schema/helpers";
3
+ import { joinPaths } from "@stryke/path/join";
3
4
  import { getDocsOutputPath } from "powerlines/plugin-utils";
4
5
  import { createComponent, mergeProps } from "@alloy-js/core/jsx-runtime";
5
6
  import { Show, code } from "@alloy-js/core";
@@ -9,7 +10,7 @@ import { usePowerlines } from "@powerlines/plugin-alloy/core/contexts/context";
9
10
  import { Heading } from "@powerlines/plugin-alloy/markdown/components/heading";
10
11
  import { MarkdownFile } from "@powerlines/plugin-alloy/markdown/components/markdown-file";
11
12
  import { MarkdownTable } from "@powerlines/plugin-alloy/markdown/components/markdown-table";
12
- import { joinPaths } from "@stryke/path/join";
13
+ import { stringifyType } from "@powerlines/schema/codegen";
13
14
 
14
15
  //#region src/components/docs.tsx
15
16
  const __ΩPartial = [
@@ -26,15 +27,14 @@ const __ΩEnvDocsFileProps = [
26
27
  "levelOffset",
27
28
  0,
28
29
  "The heading level offset to apply to the generated documentation.",
29
- "reflection",
30
30
  "EnvDocsFileProps",
31
- "P!o!\"'4\"8>#?$!4%Mw&y"
31
+ "P!o!\"'4\"8>#?$Mw%y"
32
32
  ];
33
33
  /**
34
34
  * Generates the environment configuration markdown documentation for the Powerlines project.
35
35
  */
36
36
  function EnvDocsFile(props) {
37
- const { levelOffset = 0, reflection, ...rest } = props;
37
+ const { levelOffset = 0, ...rest } = props;
38
38
  const context = (usePowerlines.Ω = [[() => __ΩEnvPluginContext, "n!"]], usePowerlines());
39
39
  return createComponent(MarkdownFile, mergeProps({ get path() {
40
40
  return joinPaths(getDocsOutputPath(context.config.root), "env.md");
@@ -70,25 +70,25 @@ function EnvDocsFile(props) {
70
70
  code`The below list of environment variables are used as configuration parameters to drive the processing of the application. The data contained in these variables are **not** considered sensitive or confidential. Any values provided in these variables will be available in plain text.`,
71
71
  createComponent(Spacing, {}),
72
72
  createComponent(MarkdownTable, { get data() {
73
- return reflection?.getProperties().filter(__assignType((property) => !property.isHidden() && !property.isIgnored() && !property.isReadonly() && !property.isInternal(), [
73
+ return Object.values(getProperties(context.env.vars)).filter(__assignType((property) => !property?.metadata?.isHidden && !property?.metadata?.isIgnored && !property?.metadata?.isReadonly && !property?.metadata?.isInternal, [
74
74
  "property",
75
75
  "",
76
76
  "P\"2!\"/\""
77
- ])).sort(__assignType((a, b) => a.getNameAsString().localeCompare(b.getNameAsString()), [
77
+ ])).sort(__assignType((a, b) => !a.metadata?.name && !b.metadata?.name ? 0 : !a.metadata?.name ? 1 : !b.metadata?.name ? -1 : a.metadata?.name.localeCompare(b.metadata?.name), [
78
78
  "a",
79
79
  "b",
80
80
  "",
81
81
  "P\"2!\"2\"\"/#"
82
- ])).map(__assignType((reflectionProperty) => {
82
+ ])).map(__assignType((property) => {
83
83
  return {
84
- name: reflectionProperty.getNameAsString().trim(),
85
- description: (reflectionProperty.getDescription() ?? "").trim(),
86
- type: stringifyType(reflectionProperty.getType()).trim().replaceAll(/\s*(?:\||&)\s*/g, ", or "),
87
- defaultValue: reflectionProperty.hasDefault() ? String(reflectionProperty.getDefaultValue())?.includes("\"") ? reflectionProperty.getDefaultValue() : `\`${reflectionProperty.getDefaultValue()}\`` : "",
88
- required: reflectionProperty.isValueRequired() ? "" : "✔"
84
+ name: property.metadata?.name?.trim(),
85
+ description: (property.metadata?.description ?? "").trim(),
86
+ type: stringifyType(property).trim().replaceAll(/\s*(?:\||&)\s*/g, ", or "),
87
+ defaultValue: property.metadata?.defaultValue ? stringifyType(property.metadata.defaultValue) : "",
88
+ required: property.optional ? "" : "✔"
89
89
  };
90
90
  }, [
91
- "reflectionProperty",
91
+ "property",
92
92
  "",
93
93
  "P\"2!\"/\""
94
94
  ])) ?? [];
@@ -1 +1 @@
1
- {"version":3,"file":"docs.mjs","names":[],"sources":["../../src/components/docs.tsx"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { code, Show } from \"@alloy-js/core\";\nimport { Link } from \"@alloy-js/markdown\";\nimport {\n ReflectionClass,\n stringifyType\n} from \"@powerlines/deepkit/vendor/type\";\nimport { Spacing } from \"@powerlines/plugin-alloy/core/components/spacing\";\nimport { usePowerlines } from \"@powerlines/plugin-alloy/core/contexts/context\";\nimport { Heading } from \"@powerlines/plugin-alloy/markdown/components/heading\";\nimport {\n MarkdownFile,\n MarkdownFileProps\n} from \"@powerlines/plugin-alloy/markdown/components/markdown-file\";\nimport { MarkdownTable } from \"@powerlines/plugin-alloy/markdown/components/markdown-table\";\nimport { joinPaths } from \"@stryke/path/join\";\nimport { getDocsOutputPath } from \"powerlines/plugin-utils\";\nimport { EnvPluginContext } from \"../types/plugin\";\n\nexport interface EnvDocsFileProps extends Partial<MarkdownFileProps> {\n /**\n * The heading level offset to apply to the generated documentation.\n *\n * @remarks\n * This is useful when nesting the documentation within other markdown files.\n *\n * @defaultValue 0\n */\n levelOffset?: number;\n\n reflection: ReflectionClass<any>;\n}\n\n/**\n * Generates the environment configuration markdown documentation for the Powerlines project.\n */\nexport function EnvDocsFile(props: EnvDocsFileProps) {\n const { levelOffset = 0, reflection, ...rest } = props;\n\n const context = usePowerlines<EnvPluginContext>();\n\n return (\n <MarkdownFile\n path={joinPaths(getDocsOutputPath(context.config.root), \"env.md\")}\n {...rest}>\n <Heading level={1 + levelOffset}>Environment Configuration</Heading>\n {code`Below is a list of environment variables used by the`}\n <Show when={!!context.packageJson.name}>\n <Link\n href={`https://www.npmjs.com/package/${context.packageJson.name}`}\n title={context.packageJson.name!}\n />\n </Show>\n {code`package. These values can be updated in the \\`.env\\` file in the root of the project.`}\n <Spacing />\n <Heading level={2 + levelOffset}>Environment Variables</Heading>\n <Spacing />\n {code`The below list of environment variables are used as configuration parameters to drive the processing of the application. The data contained in these variables are **not** considered sensitive or confidential. Any values provided in these variables will be available in plain text.`}\n <Spacing />\n <MarkdownTable\n data={\n reflection\n ?.getProperties()\n .filter(\n property =>\n !property.isHidden() &&\n !property.isIgnored() &&\n !property.isReadonly() &&\n !property.isInternal()\n )\n .sort((a, b) =>\n a.getNameAsString().localeCompare(b.getNameAsString())\n )\n .map(reflectionProperty => {\n return {\n name: reflectionProperty.getNameAsString().trim(),\n description: (reflectionProperty.getDescription() ?? \"\").trim(),\n type: stringifyType(reflectionProperty.getType())\n .trim()\n .replaceAll(/\\s*(?:\\||&)\\s*/g, \", or \"),\n defaultValue: reflectionProperty.hasDefault()\n ? String(reflectionProperty.getDefaultValue())?.includes('\"')\n ? reflectionProperty.getDefaultValue()\n : `\\`${reflectionPro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uBAAA;KACT,OAAA;MACM,MAAA,mBAAA,gBAAA,EAAA,KAAA;MACH,cAAA,mBAAA,eAAA,KAAA,IAAA,KAAA;MACI,MAAA,cAAc,mBAAA,QAAA,CAAA,EAAA,KAAA,EAAA,WAAA,mBAAA,OAAA;MACf,cAAM,mBAAA,WAAA,IAAA,OAAA,mBAAA,gBAAA,CAAA,GAAA,SAAA,IAAA,IAAA,mBAAA,gBAAA,IAAA,KAAA,mBAAA,gBAAA,EAAA,MAAA;MACL,UAAU,mBAAA,gBAAA,IAAA,KAAA;KACZ;IACF,GAAG;KAAC;KAAsB;KAAG;IAAA,CAAA,CAAA,KAAA,CAAA;GAC/B,EACF,CAAC;EAAC;CACJ,EACF,CAAC,CAAC;AACJ;AACA,YAAY,SAAA;OAAA;CAAA;CAAA;CAAA;CAAA;AAAA"}
1
+ {"version":3,"file":"docs.mjs","names":[],"sources":["../../src/components/docs.tsx"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { code, Show } from \"@alloy-js/core\";\nimport { Link } from \"@alloy-js/markdown\";\nimport { Spacing } from \"@powerlines/plugin-alloy/core/components/spacing\";\nimport { usePowerlines } from \"@powerlines/plugin-alloy/core/contexts/context\";\nimport { Heading } from \"@powerlines/plugin-alloy/markdown/components/heading\";\nimport {\n MarkdownFile,\n MarkdownFileProps\n} from \"@powerlines/plugin-alloy/markdown/components/markdown-file\";\nimport { MarkdownTable } from \"@powerlines/plugin-alloy/markdown/components/markdown-table\";\nimport { stringifyType } from \"@powerlines/schema/codegen\";\nimport { getProperties } from \"@powerlines/schema/helpers\";\nimport { joinPaths } from \"@stryke/path/join\";\nimport { getDocsOutputPath } from \"powerlines/plugin-utils\";\nimport { EnvPluginContext } from \"../types/plugin\";\n\nexport interface EnvDocsFileProps extends Partial<MarkdownFileProps> {\n /**\n * The heading level offset to apply to the generated documentation.\n *\n * @remarks\n * This is useful when nesting the documentation within other markdown files.\n *\n * @defaultValue 0\n */\n levelOffset?: number;\n}\n\n/**\n * Generates the environment configuration markdown documentation for the Powerlines project.\n */\nexport function EnvDocsFile(props: EnvDocsFileProps) {\n const { levelOffset = 0, ...rest } = props;\n\n const context = usePowerlines<EnvPluginContext>();\n\n return (\n <MarkdownFile\n path={joinPaths(getDocsOutputPath(context.config.root), \"env.md\")}\n {...rest}>\n <Heading level={1 + levelOffset}>Environment Configuration</Heading>\n {code`Below is a list of environment variables used by the`}\n <Show when={!!context.packageJson.name}>\n <Link\n href={`https://www.npmjs.com/package/${context.packageJson.name}`}\n title={context.packageJson.name!}\n />\n </Show>\n {code`package. These values can be updated in the \\`.env\\` file in the root of the project.`}\n <Spacing />\n <Heading level={2 + levelOffset}>Environment Variables</Heading>\n <Spacing />\n {code`The below list of environment variables are used as configuration parameters to drive the processing of the application. The data contained in these variables are **not** considered sensitive or confidential. Any values provided in these variables will be available in plain text.`}\n <Spacing />\n <MarkdownTable\n data={\n Object.values(getProperties(context.env.vars))\n .filter(\n property =>\n !property?.metadata?.isHidden &&\n !property?.metadata?.isIgnored &&\n !property?.metadata?.isReadonly &&\n !property?.metadata?.isInternal\n )\n .sort((a, b) =>\n !a.metadata?.name && !b.metadata?.name\n ? 0\n : !a.metadata?.name\n ? 1\n : !b.metadata?.name\n ? -1\n : a.metadata?.name.localeCompare(b.metadata?.name)\n )\n .map(property => {\n return {\n name: property.metadata?.name?.trim(),\n description: (property.metadata?.description ?? \"\").trim(),\n type: stringifyType(property)\n .trim()\n .replaceAll(/\\s*(?:\\||&)\\s*/g, \", or \"),\n defaultValue: property.metadata?.defaultValue\n ? stringifyType(property.metadata.defaultValue)\n : \"\",\n required: property.optional ? \"\" : \"✔\"\n };\n }) ?? []\n }\n />\n </MarkdownFile>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAIA,SAAM,aAAS,IAAW,MAAM;CAC/B,GAAG,SAAU;CACb,OAAQ;AACT;AA6BA,MAAK,sBAAkB;OAAU;CAAa;CAAU;CAAA;CAAa;CAAA;AAAA;;;;AAKrE,SAAM,YAAa,OAAA;CACjB,MAAE,EACF,cAAc,GAChB,GAAA;CAEE,MAAA,WAAA,cAAA,IAAA,CAAA,OAAA,qBAAA,IAAA,CAAA,GAAA,cAAA;CACA,OAAC,gBAAc,cAAY,WAAuB,EAClD,IAAA,OAAA;EACI,OAAC,UAAS,kBAAmB,QAAA,OAAkB,IAAA,GAAA,QAAA;CACnD,aAEA,IAAM,WAAU;;;IAEV,OAAC,IAAA;IACJ,UAAA;GACC,CAAA;GAAI,IAAE;GAA0D,gBAAC,MAAA;IAC/D,IAAE,OAAK;KACR,OAAQ,CAAA,CAAA,QAAW,YAAa;IAChC;IACA,IAAK,WAAQ;KACX,OAAA,gBAAA,MAAA;MACC,IAAM,OAAO;OACb,OAAO,iCAAyB,QAAA,YAAA;MACjC;MACG,IAAA,QAAA;OACA,OAAS,QAAM,YAAc;MAClC;KACA,CAAA;IACA;GACD,CAAC;GAAA,IAAK;GAA0F,gBAAkB,SAAA,CAAW,CAAC;GAAC,gBAAmB,SAAS;IAC1J,OAAQ,IAAC;IACT,UAAA;GACD,CAAC;GAAC,gBAAK,SAAA,CAAA,CAAA;GAAA,IAAA;GAAA,gBAAA,SAAA,CAAA,CAAA;GAAA,gBAAA,eAAA,EACL,IAAE,OAAO;IACP,OAAG,OAAM,OAAA,cAAA,QAAA,IAAA,IAAA,CAAA,EAAA,OAAA,cAAA,aAAA,CAAA,UAAA,UAAA,YAAA,CAAA,UAAA,UAAA,aAAA,CAAA,UAAA,UAAA,cAAA,CAAA,UAAA,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