@powerlines/plugin-env 0.16.237 → 0.16.240

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 (40) hide show
  1. package/dist/babel/plugin.cjs +1 -1
  2. package/dist/babel/plugin.mjs +1 -1
  3. package/dist/components/docs.cjs +2 -2
  4. package/dist/components/docs.mjs +3 -3
  5. package/dist/components/docs.mjs.map +1 -1
  6. package/dist/components/env-builtin.cjs +14 -18
  7. package/dist/components/env-builtin.d.cts +1 -1
  8. package/dist/components/env-builtin.d.mts +1 -1
  9. package/dist/components/env-builtin.mjs +12 -16
  10. package/dist/components/env-builtin.mjs.map +1 -1
  11. package/dist/helpers/index.cjs +3 -1
  12. package/dist/helpers/index.d.cts +2 -2
  13. package/dist/helpers/index.d.mts +2 -2
  14. package/dist/helpers/index.mjs +2 -2
  15. package/dist/helpers/load.d.cts +2 -2
  16. package/dist/helpers/load.d.mts +2 -2
  17. package/dist/helpers/schema.cjs +48 -9
  18. package/dist/helpers/schema.d.cts +17 -4
  19. package/dist/helpers/schema.d.cts.map +1 -1
  20. package/dist/helpers/schema.d.mts +17 -4
  21. package/dist/helpers/schema.d.mts.map +1 -1
  22. package/dist/helpers/schema.mjs +48 -11
  23. package/dist/helpers/schema.mjs.map +1 -1
  24. package/dist/index.cjs +3 -3
  25. package/dist/index.d.cts +2 -2
  26. package/dist/index.d.mts +2 -2
  27. package/dist/index.mjs +4 -4
  28. package/dist/index.mjs.map +1 -1
  29. package/dist/types/index.cjs +1 -1
  30. package/dist/types/index.d.cts +2 -2
  31. package/dist/types/index.d.mts +2 -2
  32. package/dist/types/index.mjs +2 -2
  33. package/dist/types/plugin.cjs +15 -5
  34. package/dist/types/plugin.d.cts +7 -4
  35. package/dist/types/plugin.d.cts.map +1 -1
  36. package/dist/types/plugin.d.mts +8 -5
  37. package/dist/types/plugin.d.mts.map +1 -1
  38. package/dist/types/plugin.mjs +15 -5
  39. package/dist/types/plugin.mjs.map +1 -1
  40. package/package.json +9 -9
@@ -1,10 +1,11 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
  const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
3
- const require_types_plugin = require('../types/plugin.cjs');
4
3
  const require_helpers_load = require('./load.cjs');
5
4
  let _stryke_type_checks_is_string = require("@stryke/type-checks/is-string");
5
+ let _powerlines_schema = require("@powerlines/schema");
6
6
  let _powerlines_schema_extract = require("@powerlines/schema/extract");
7
7
  let _powerlines_schema_helpers = require("@powerlines/schema/helpers");
8
+ let _stryke_path_join = require("@stryke/path/join");
8
9
  let _stryke_type_checks_is_set_array = require("@stryke/type-checks/is-set-array");
9
10
  let _stryke_type_checks_is_set_object = require("@stryke/type-checks/is-set-object");
10
11
  let defu = require("defu");
@@ -73,10 +74,9 @@ getDefaultSecretsTypeDefinition.__type = [
73
74
  * This function should be called during the plugin's `config` hook to ensure that the environment variables and secrets schema is available in the plugin context before the build process begins. The resulting schema will be used to validate the loaded environment variables and secrets, as well as to provide type information for the injected environment variables and secrets during the build process.
74
75
  *
75
76
  * @param context - The plugin context
76
- * @param options - The plugin options containing the environment variables and secrets type definitions to extract the schema from. If not provided, the default type definitions will be used.
77
77
  * @returns A promise that resolves when the schema has been extracted and stored in the plugin context.
78
78
  */
79
- async function extractEnvSchema(context, options = {}) {
79
+ async function extractEnvSchema(context) {
80
80
  const defaultVarsTypeDefinition = await getDefaultVarsTypeDefinition(context);
81
81
  const defaultSecretsTypeDefinition = await getDefaultSecretsTypeDefinition(context);
82
82
  const vars = await (0, _powerlines_schema_extract.extract)(context, context.config.env.vars);
@@ -91,10 +91,11 @@ async function extractEnvSchema(context, options = {}) {
91
91
  parsed: {},
92
92
  injected: []
93
93
  });
94
+ await readActiveEnv(context);
94
95
  const properties = (0, _powerlines_schema_helpers.getProperties)(context.env.vars);
95
96
  context.info({
96
97
  meta: { category: "env" },
97
- message: `Environment Variables configuration: ${options.vars ? "" : "Defaulted "}${context.env.vars.variant === "reflection" ? "Deepkit type definition" : context.env.vars.variant === "json-schema" ? "JSON Schema" : context.env.vars.variant === "standard-schema" ? "Standard Schema" : context.env.vars.variant === "zod3" ? "Zod v3 schema" : "Typescript exported type"}${options.vars ? " from plugin options" : ""} provided ${Object.keys(properties).length} parameters\nEnvironment Secret configuration: ${options.secrets ? "" : "Defaulted "}${context.env.secrets.variant === "reflection" ? "Deepkit type definition" : context.env.secrets.variant === "json-schema" ? "JSON Schema" : context.env.secrets.variant === "standard-schema" ? "Standard Schema" : context.env.secrets.variant === "zod3" ? "Zod v3 schema" : "Typescript exported type"}${options.secrets ? " from plugin options" : ""} provided ${context.env.secrets?.schema ? Object.keys((0, _powerlines_schema_helpers.getProperties)(context.env.secrets)).length : "0"} parameters\nEnvironment variable Prefixes: ${context.config.env.prefix.join(", ")}\nShould inject values: ${context.config.env.inject ? "Yes" : "No"}\nShould validate configuration: ${context.config.env.validate ? "Yes" : "No"}`
98
+ message: `Environment Variables configuration: ${context.config.env.vars ? "" : "Defaulted "}${context.env.vars.variant === "reflection" ? "Deepkit type definition" : context.env.vars.variant === "json-schema" ? "JSON Schema" : context.env.vars.variant === "standard-schema" ? "Standard Schema" : context.env.vars.variant === "zod3" ? "Zod v3 schema" : "Typescript exported type"}${context.config.env.vars ? " from plugin options" : ""} provided ${Object.keys(properties).length} parameters\nEnvironment Secret configuration: ${context.config.env.secrets ? "" : "Defaulted "}${context.env.secrets.variant === "reflection" ? "Deepkit type definition" : context.env.secrets.variant === "json-schema" ? "JSON Schema" : context.env.secrets.variant === "standard-schema" ? "Standard Schema" : context.env.secrets.variant === "zod3" ? "Zod v3 schema" : "Typescript exported type"}${context.config.env.secrets ? " from plugin options" : ""} provided ${context.env.secrets?.schema ? (0, _powerlines_schema_helpers.getPropertiesList)(context.env.secrets).length : "0"} parameters\nEnvironment variable Prefixes: ${context.config.env.prefix.join(", ")}\nShould inject values: ${context.config.env.inject ? "Yes" : "No"}\nShould validate configuration: ${context.config.env.validate ? "Yes" : "No"}`
98
99
  });
99
100
  const aliases = Object.fromEntries(Object.entries(properties).flatMap(__assignType(([key, prop]) => (0, _stryke_type_checks_is_set_array.isSetArray)(prop.metadata?.alias) ? prop.metadata?.alias?.map(__assignType((alias) => [alias, {
100
101
  ...prop,
@@ -147,16 +148,54 @@ async function extractEnvSchema(context, options = {}) {
147
148
  }
148
149
  extractEnvSchema.__type = [
149
150
  "context",
150
- () => require_types_plugin.__ΩEnvPluginOptions,
151
- "options",
152
- () => ({}),
153
151
  "extractEnvSchema",
154
152
  "Extracts the environment variables and secrets schema from the provided type definitions in the plugin options, merges them with the default environment variables and secrets schema, and stores the resulting schema in the plugin context for later use during the build process.",
155
- "P\"2!n\"2#>$$`/%?&"
153
+ "P\"2!$`/\"?#"
154
+ ];
155
+ /**
156
+ * Reads the active environment variables and secrets from the plugin context's cache and stores them in the plugin context for use during the build process. This function should be called during the plugin's `buildStart` hook to ensure that the active environment variables and secrets are available before the build process begins.
157
+ *
158
+ * @param context - The plugin context
159
+ * @returns A promise that resolves when the active environment variables and secrets have been read and stored in the plugin context.
160
+ */
161
+ async function readActiveEnv(context) {
162
+ context.env.vars.active ??= [];
163
+ if (context.fs.existsSync((0, _stryke_path_join.joinPaths)((0, _powerlines_schema.getCacheDirectory)(context), "env", "vars.json"))) {
164
+ const content = await context.fs.read((0, _stryke_path_join.joinPaths)((0, _powerlines_schema.getCacheDirectory)(context), "env", "vars.json"));
165
+ if (content) context.env.vars.active = JSON.parse(content)?.elements ?? [];
166
+ }
167
+ context.env.secrets.active ??= [];
168
+ if (context.fs.existsSync((0, _stryke_path_join.joinPaths)((0, _powerlines_schema.getCacheDirectory)(context), "env", "secrets.json"))) {
169
+ const content = await context.fs.read((0, _stryke_path_join.joinPaths)((0, _powerlines_schema.getCacheDirectory)(context), "env", "secrets.json"));
170
+ if (content) context.env.secrets.active = JSON.parse(content)?.elements ?? [];
171
+ }
172
+ }
173
+ readActiveEnv.__type = [
174
+ "context",
175
+ "readActiveEnv",
176
+ "Reads the active environment variables and secrets from the plugin context's cache and stores them in the plugin context for use during the build process. This function should be called during the plugin's `buildStart` hook to ensure that the active environment variables and secrets are available before the build process begins.",
177
+ "P\"2!\"/\"?#"
178
+ ];
179
+ /**
180
+ * Writes the active environment variables and secrets from the plugin context to the plugin context's cache for use during the build process. This function should be called whenever the active environment variables and secrets are updated in the plugin context to ensure that the latest values are available during the build process.
181
+ *
182
+ * @param context - The plugin context
183
+ * @returns A promise that resolves when the active environment variables and secrets have been written to the plugin context's cache.
184
+ */
185
+ async function writeActiveEnv(context) {
186
+ return Promise.all([(0, _stryke_type_checks_is_set_array.isSetArray)(context.env.vars.active) ? context.fs.write((0, _stryke_path_join.joinPaths)((0, _powerlines_schema.getCacheDirectory)(context), "env", "vars.json"), JSON.stringify({ elements: context.env.vars.active })) : void 0, (0, _stryke_type_checks_is_set_array.isSetArray)(context.env.secrets.active) ? context.fs.write((0, _stryke_path_join.joinPaths)((0, _powerlines_schema.getCacheDirectory)(context), "env", "secrets.json"), JSON.stringify({ elements: context.env.secrets.active })) : void 0].filter(Boolean));
187
+ }
188
+ writeActiveEnv.__type = [
189
+ "context",
190
+ "writeActiveEnv",
191
+ "Writes the active environment variables and secrets from the plugin context to the plugin context's cache for use during the build process. This function should be called whenever the active environment variables and secrets are updated in the plugin context to ensure that the latest values are available during the build process.",
192
+ "P\"2!\"/\"?#"
156
193
  ];
157
194
 
158
195
  //#endregion
159
196
  exports.extractEnvSchema = extractEnvSchema;
160
197
  exports.getDefaultSecretsTypeDefinition = getDefaultSecretsTypeDefinition;
161
198
  exports.getDefaultVarsTypeDefinition = getDefaultVarsTypeDefinition;
162
- exports.resolveRuntimeTypeFile = resolveRuntimeTypeFile;
199
+ exports.readActiveEnv = readActiveEnv;
200
+ exports.resolveRuntimeTypeFile = resolveRuntimeTypeFile;
201
+ exports.writeActiveEnv = writeActiveEnv;
@@ -1,4 +1,4 @@
1
- import { EnvPluginContext, EnvPluginOptions } from "../types/plugin.cjs";
1
+ import { EnvPluginContext } from "../types/plugin.cjs";
2
2
  import { UnresolvedContext } from "powerlines";
3
3
  import { TypeDefinition } from "@stryke/types/configuration";
4
4
 
@@ -30,10 +30,23 @@ declare function getDefaultSecretsTypeDefinition<TContext extends UnresolvedCont
30
30
  * This function should be called during the plugin's `config` hook to ensure that the environment variables and secrets schema is available in the plugin context before the build process begins. The resulting schema will be used to validate the loaded environment variables and secrets, as well as to provide type information for the injected environment variables and secrets during the build process.
31
31
  *
32
32
  * @param context - The plugin context
33
- * @param options - The plugin options containing the environment variables and secrets type definitions to extract the schema from. If not provided, the default type definitions will be used.
34
33
  * @returns A promise that resolves when the schema has been extracted and stored in the plugin context.
35
34
  */
36
- declare function extractEnvSchema<TContext extends EnvPluginContext>(context: TContext, options?: EnvPluginOptions): Promise<void>;
35
+ declare function extractEnvSchema<TContext extends EnvPluginContext>(context: TContext): Promise<void>;
36
+ /**
37
+ * Reads the active environment variables and secrets from the plugin context's cache and stores them in the plugin context for use during the build process. This function should be called during the plugin's `buildStart` hook to ensure that the active environment variables and secrets are available before the build process begins.
38
+ *
39
+ * @param context - The plugin context
40
+ * @returns A promise that resolves when the active environment variables and secrets have been read and stored in the plugin context.
41
+ */
42
+ declare function readActiveEnv<TContext extends EnvPluginContext>(context: TContext): Promise<void>;
43
+ /**
44
+ * Writes the active environment variables and secrets from the plugin context to the plugin context's cache for use during the build process. This function should be called whenever the active environment variables and secrets are updated in the plugin context to ensure that the latest values are available during the build process.
45
+ *
46
+ * @param context - The plugin context
47
+ * @returns A promise that resolves when the active environment variables and secrets have been written to the plugin context's cache.
48
+ */
49
+ declare function writeActiveEnv<TContext extends EnvPluginContext>(context: TContext): Promise<void[]>;
37
50
  //#endregion
38
- export { extractEnvSchema, getDefaultSecretsTypeDefinition, getDefaultVarsTypeDefinition, resolveRuntimeTypeFile };
51
+ export { extractEnvSchema, getDefaultSecretsTypeDefinition, getDefaultVarsTypeDefinition, readActiveEnv, resolveRuntimeTypeFile, writeActiveEnv };
39
52
  //# sourceMappingURL=schema.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"schema.d.cts","names":[],"sources":["../../src/helpers/schema.ts"],"mappings":";;;;;;;AAwCA;;;;iBAAsB,sBAAA,kBACH,iBAAA,CAAA,CACjB,OAAA,EAAS,QAAA,GAAW,OAAA;;;;;;;iBAiBA,4BAAA,kBACH,iBAAA,CAAA,CACjB,OAAA,EAAS,QAAA,GAAW,OAAA,CAAQ,cAAA;;;AAnBD;AAiB7B;;iBAcsB,+BAAA,kBACH,iBAAA,CAAA,CACjB,OAAA,EAAS,QAAA,GAAW,OAAA,CAAQ,cAAA;;;;;;;;;;;iBAiBR,gBAAA,kBAAkC,gBAAA,CAAA,CACtD,OAAA,EAAS,QAAA,EACT,OAAA,GAAS,gBAAA,GACR,OAAA"}
1
+ {"version":3,"file":"schema.d.cts","names":[],"sources":["../../src/helpers/schema.ts"],"mappings":";;;;;;;AAyCA;;;;iBAAsB,sBAAA,kBACH,iBAAA,CAAA,CACjB,OAAA,EAAS,QAAA,GAAW,OAAA;;;;;;;iBAiBA,4BAAA,kBACH,iBAAA,CAAA,CACjB,OAAA,EAAS,QAAA,GAAW,OAAA,CAAQ,cAAA;;;AAnBD;AAiB7B;;iBAcsB,+BAAA,kBACH,iBAAA,CAAA,CACjB,OAAA,EAAS,QAAA,GAAW,OAAA,CAAQ,cAAA;;;;;;;;;;iBAgBR,gBAAA,kBAAkC,gBAAA,CAAA,CACtD,OAAA,EAAS,QAAA,GACR,OAAA;;;;AAhCyC;AAY5C;;iBA4LsB,aAAA,kBAA+B,gBAAA,CAAA,CACnD,OAAA,EAAS,QAAA,GAAQ,OAAA;;;;;;;iBAqCG,cAAA,kBAAgC,gBAAA,CAAA,CACpD,OAAA,EAAS,QAAA,GAAQ,OAAA"}
@@ -1,4 +1,4 @@
1
- import { EnvPluginContext, EnvPluginOptions } from "../types/plugin.mjs";
1
+ import { EnvPluginContext } from "../types/plugin.mjs";
2
2
  import { UnresolvedContext } from "powerlines";
3
3
  import { TypeDefinition } from "@stryke/types/configuration";
4
4
 
@@ -30,10 +30,23 @@ declare function getDefaultSecretsTypeDefinition<TContext extends UnresolvedCont
30
30
  * This function should be called during the plugin's `config` hook to ensure that the environment variables and secrets schema is available in the plugin context before the build process begins. The resulting schema will be used to validate the loaded environment variables and secrets, as well as to provide type information for the injected environment variables and secrets during the build process.
31
31
  *
32
32
  * @param context - The plugin context
33
- * @param options - The plugin options containing the environment variables and secrets type definitions to extract the schema from. If not provided, the default type definitions will be used.
34
33
  * @returns A promise that resolves when the schema has been extracted and stored in the plugin context.
35
34
  */
36
- declare function extractEnvSchema<TContext extends EnvPluginContext>(context: TContext, options?: EnvPluginOptions): Promise<void>;
35
+ declare function extractEnvSchema<TContext extends EnvPluginContext>(context: TContext): Promise<void>;
36
+ /**
37
+ * Reads the active environment variables and secrets from the plugin context's cache and stores them in the plugin context for use during the build process. This function should be called during the plugin's `buildStart` hook to ensure that the active environment variables and secrets are available before the build process begins.
38
+ *
39
+ * @param context - The plugin context
40
+ * @returns A promise that resolves when the active environment variables and secrets have been read and stored in the plugin context.
41
+ */
42
+ declare function readActiveEnv<TContext extends EnvPluginContext>(context: TContext): Promise<void>;
43
+ /**
44
+ * Writes the active environment variables and secrets from the plugin context to the plugin context's cache for use during the build process. This function should be called whenever the active environment variables and secrets are updated in the plugin context to ensure that the latest values are available during the build process.
45
+ *
46
+ * @param context - The plugin context
47
+ * @returns A promise that resolves when the active environment variables and secrets have been written to the plugin context's cache.
48
+ */
49
+ declare function writeActiveEnv<TContext extends EnvPluginContext>(context: TContext): Promise<void[]>;
37
50
  //#endregion
38
- export { extractEnvSchema, getDefaultSecretsTypeDefinition, getDefaultVarsTypeDefinition, resolveRuntimeTypeFile };
51
+ export { extractEnvSchema, getDefaultSecretsTypeDefinition, getDefaultVarsTypeDefinition, readActiveEnv, resolveRuntimeTypeFile, writeActiveEnv };
39
52
  //# sourceMappingURL=schema.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"schema.d.mts","names":[],"sources":["../../src/helpers/schema.ts"],"mappings":";;;;;;;AAwCA;;;;iBAAsB,sBAAA,kBACH,iBAAA,CAAA,CACjB,OAAA,EAAS,QAAA,GAAW,OAAA;;;;;;;iBAiBA,4BAAA,kBACH,iBAAA,CAAA,CACjB,OAAA,EAAS,QAAA,GAAW,OAAA,CAAQ,cAAA;;;AAnBD;AAiB7B;;iBAcsB,+BAAA,kBACH,iBAAA,CAAA,CACjB,OAAA,EAAS,QAAA,GAAW,OAAA,CAAQ,cAAA;;;;;;;;;;;iBAiBR,gBAAA,kBAAkC,gBAAA,CAAA,CACtD,OAAA,EAAS,QAAA,EACT,OAAA,GAAS,gBAAA,GACR,OAAA"}
1
+ {"version":3,"file":"schema.d.mts","names":[],"sources":["../../src/helpers/schema.ts"],"mappings":";;;;;;;AAyCA;;;;iBAAsB,sBAAA,kBACH,iBAAA,CAAA,CACjB,OAAA,EAAS,QAAA,GAAW,OAAA;;;;;;;iBAiBA,4BAAA,kBACH,iBAAA,CAAA,CACjB,OAAA,EAAS,QAAA,GAAW,OAAA,CAAQ,cAAA;;;AAnBD;AAiB7B;;iBAcsB,+BAAA,kBACH,iBAAA,CAAA,CACjB,OAAA,EAAS,QAAA,GAAW,OAAA,CAAQ,cAAA;;;;;;;;;;iBAgBR,gBAAA,kBAAkC,gBAAA,CAAA,CACtD,OAAA,EAAS,QAAA,GACR,OAAA;;;;AAhCyC;AAY5C;;iBA4LsB,aAAA,kBAA+B,gBAAA,CAAA,CACnD,OAAA,EAAS,QAAA,GAAQ,OAAA;;;;;;;iBAqCG,cAAA,kBAAgC,gBAAA,CAAA,CACpD,OAAA,EAAS,QAAA,GAAQ,OAAA"}
@@ -1,8 +1,9 @@
1
- import { __ΩEnvPluginOptions } from "../types/plugin.mjs";
2
1
  import { loadEnv } from "./load.mjs";
3
2
  import { isString } from "@stryke/type-checks/is-string";
3
+ import { getCacheDirectory } from "@powerlines/schema";
4
4
  import { extract } from "@powerlines/schema/extract";
5
- import { getProperties, mergeSchemas } from "@powerlines/schema/helpers";
5
+ import { getProperties as getProperties$1, getPropertiesList, mergeSchemas } from "@powerlines/schema/helpers";
6
+ import { joinPaths } from "@stryke/path/join";
6
7
  import { isSetArray } from "@stryke/type-checks/is-set-array";
7
8
  import { isSetObject } from "@stryke/type-checks/is-set-object";
8
9
  import defu from "defu";
@@ -70,10 +71,9 @@ getDefaultSecretsTypeDefinition.__type = [
70
71
  * This function should be called during the plugin's `config` hook to ensure that the environment variables and secrets schema is available in the plugin context before the build process begins. The resulting schema will be used to validate the loaded environment variables and secrets, as well as to provide type information for the injected environment variables and secrets during the build process.
71
72
  *
72
73
  * @param context - The plugin context
73
- * @param options - The plugin options containing the environment variables and secrets type definitions to extract the schema from. If not provided, the default type definitions will be used.
74
74
  * @returns A promise that resolves when the schema has been extracted and stored in the plugin context.
75
75
  */
76
- async function extractEnvSchema(context, options = {}) {
76
+ async function extractEnvSchema(context) {
77
77
  const defaultVarsTypeDefinition = await getDefaultVarsTypeDefinition(context);
78
78
  const defaultSecretsTypeDefinition = await getDefaultSecretsTypeDefinition(context);
79
79
  const vars = await extract(context, context.config.env.vars);
@@ -88,10 +88,11 @@ async function extractEnvSchema(context, options = {}) {
88
88
  parsed: {},
89
89
  injected: []
90
90
  });
91
- const properties = getProperties(context.env.vars);
91
+ await readActiveEnv(context);
92
+ const properties = getProperties$1(context.env.vars);
92
93
  context.info({
93
94
  meta: { category: "env" },
94
- message: `Environment Variables configuration: ${options.vars ? "" : "Defaulted "}${context.env.vars.variant === "reflection" ? "Deepkit type definition" : context.env.vars.variant === "json-schema" ? "JSON Schema" : context.env.vars.variant === "standard-schema" ? "Standard Schema" : context.env.vars.variant === "zod3" ? "Zod v3 schema" : "Typescript exported type"}${options.vars ? " from plugin options" : ""} provided ${Object.keys(properties).length} parameters\nEnvironment Secret configuration: ${options.secrets ? "" : "Defaulted "}${context.env.secrets.variant === "reflection" ? "Deepkit type definition" : context.env.secrets.variant === "json-schema" ? "JSON Schema" : context.env.secrets.variant === "standard-schema" ? "Standard Schema" : context.env.secrets.variant === "zod3" ? "Zod v3 schema" : "Typescript exported type"}${options.secrets ? " from plugin options" : ""} provided ${context.env.secrets?.schema ? Object.keys(getProperties(context.env.secrets)).length : "0"} parameters\nEnvironment variable Prefixes: ${context.config.env.prefix.join(", ")}\nShould inject values: ${context.config.env.inject ? "Yes" : "No"}\nShould validate configuration: ${context.config.env.validate ? "Yes" : "No"}`
95
+ message: `Environment Variables configuration: ${context.config.env.vars ? "" : "Defaulted "}${context.env.vars.variant === "reflection" ? "Deepkit type definition" : context.env.vars.variant === "json-schema" ? "JSON Schema" : context.env.vars.variant === "standard-schema" ? "Standard Schema" : context.env.vars.variant === "zod3" ? "Zod v3 schema" : "Typescript exported type"}${context.config.env.vars ? " from plugin options" : ""} provided ${Object.keys(properties).length} parameters\nEnvironment Secret configuration: ${context.config.env.secrets ? "" : "Defaulted "}${context.env.secrets.variant === "reflection" ? "Deepkit type definition" : context.env.secrets.variant === "json-schema" ? "JSON Schema" : context.env.secrets.variant === "standard-schema" ? "Standard Schema" : context.env.secrets.variant === "zod3" ? "Zod v3 schema" : "Typescript exported type"}${context.config.env.secrets ? " from plugin options" : ""} provided ${context.env.secrets?.schema ? getPropertiesList(context.env.secrets).length : "0"} parameters\nEnvironment variable Prefixes: ${context.config.env.prefix.join(", ")}\nShould inject values: ${context.config.env.inject ? "Yes" : "No"}\nShould validate configuration: ${context.config.env.validate ? "Yes" : "No"}`
95
96
  });
96
97
  const aliases = Object.fromEntries(Object.entries(properties).flatMap(__assignType(([key, prop]) => isSetArray(prop.metadata?.alias) ? prop.metadata?.alias?.map(__assignType((alias) => [alias, {
97
98
  ...prop,
@@ -144,14 +145,50 @@ async function extractEnvSchema(context, options = {}) {
144
145
  }
145
146
  extractEnvSchema.__type = [
146
147
  "context",
147
- () => __ΩEnvPluginOptions,
148
- "options",
149
- () => ({}),
150
148
  "extractEnvSchema",
151
149
  "Extracts the environment variables and secrets schema from the provided type definitions in the plugin options, merges them with the default environment variables and secrets schema, and stores the resulting schema in the plugin context for later use during the build process.",
152
- "P\"2!n\"2#>$$`/%?&"
150
+ "P\"2!$`/\"?#"
151
+ ];
152
+ /**
153
+ * Reads the active environment variables and secrets from the plugin context's cache and stores them in the plugin context for use during the build process. This function should be called during the plugin's `buildStart` hook to ensure that the active environment variables and secrets are available before the build process begins.
154
+ *
155
+ * @param context - The plugin context
156
+ * @returns A promise that resolves when the active environment variables and secrets have been read and stored in the plugin context.
157
+ */
158
+ async function readActiveEnv(context) {
159
+ context.env.vars.active ??= [];
160
+ if (context.fs.existsSync(joinPaths(getCacheDirectory(context), "env", "vars.json"))) {
161
+ const content = await context.fs.read(joinPaths(getCacheDirectory(context), "env", "vars.json"));
162
+ if (content) context.env.vars.active = JSON.parse(content)?.elements ?? [];
163
+ }
164
+ context.env.secrets.active ??= [];
165
+ if (context.fs.existsSync(joinPaths(getCacheDirectory(context), "env", "secrets.json"))) {
166
+ const content = await context.fs.read(joinPaths(getCacheDirectory(context), "env", "secrets.json"));
167
+ if (content) context.env.secrets.active = JSON.parse(content)?.elements ?? [];
168
+ }
169
+ }
170
+ readActiveEnv.__type = [
171
+ "context",
172
+ "readActiveEnv",
173
+ "Reads the active environment variables and secrets from the plugin context's cache and stores them in the plugin context for use during the build process. This function should be called during the plugin's `buildStart` hook to ensure that the active environment variables and secrets are available before the build process begins.",
174
+ "P\"2!\"/\"?#"
175
+ ];
176
+ /**
177
+ * Writes the active environment variables and secrets from the plugin context to the plugin context's cache for use during the build process. This function should be called whenever the active environment variables and secrets are updated in the plugin context to ensure that the latest values are available during the build process.
178
+ *
179
+ * @param context - The plugin context
180
+ * @returns A promise that resolves when the active environment variables and secrets have been written to the plugin context's cache.
181
+ */
182
+ async function writeActiveEnv(context) {
183
+ return Promise.all([isSetArray(context.env.vars.active) ? context.fs.write(joinPaths(getCacheDirectory(context), "env", "vars.json"), JSON.stringify({ elements: context.env.vars.active })) : void 0, isSetArray(context.env.secrets.active) ? context.fs.write(joinPaths(getCacheDirectory(context), "env", "secrets.json"), JSON.stringify({ elements: context.env.secrets.active })) : void 0].filter(Boolean));
184
+ }
185
+ writeActiveEnv.__type = [
186
+ "context",
187
+ "writeActiveEnv",
188
+ "Writes the active environment variables and secrets from the plugin context to the plugin context's cache for use during the build process. This function should be called whenever the active environment variables and secrets are updated in the plugin context to ensure that the latest values are available during the build process.",
189
+ "P\"2!\"/\"?#"
153
190
  ];
154
191
 
155
192
  //#endregion
156
- export { extractEnvSchema, getDefaultSecretsTypeDefinition, getDefaultVarsTypeDefinition, resolveRuntimeTypeFile };
193
+ export { extractEnvSchema, getDefaultSecretsTypeDefinition, getDefaultVarsTypeDefinition, readActiveEnv, resolveRuntimeTypeFile, writeActiveEnv };
157
194
  //# sourceMappingURL=schema.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"schema.mjs","names":[],"sources":["../../src/helpers/schema.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 { ObjectSchema } from \"@powerlines/schema\";\nimport { extract } from \"@powerlines/schema/extract\";\nimport { getProperties, mergeSchemas } from \"@powerlines/schema/helpers\";\nimport { isSetArray } from \"@stryke/type-checks/is-set-array\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport { isString } from \"@stryke/type-checks/is-string\";\nimport type { TypeDefinition } from \"@stryke/types/configuration\";\nimport defu from \"defu\";\nimport { UnresolvedContext } from \"powerlines\";\nimport {\n EnvPluginContext,\n EnvPluginOptions,\n EnvSchemaMetadata\n} from \"../types/plugin\";\nimport { loadEnv } from \"./load\";\n\n/**\n * Resolves the runtime type definition file for the environment variables.\n *\n * @param context - The plugin context.\n * @returns The runtime type definition file for the environment variables.\n */\nexport async function resolveRuntimeTypeFile<\n TContext extends UnresolvedContext\n>(context: TContext): Promise<string> {\n const resolved = await context.fs.resolve(\"@powerlines/plugin-env/types/env\");\n if (!resolved) {\n throw new Error(\n `Failed to resolve the runtime type definition file for the environment variables. Please ensure that the \"@powerlines/plugin-env\" package is installed.`\n );\n }\n\n return resolved;\n}\n\n/**\n * Gets the default type definition for the environment variables.\n *\n * @param context - The plugin context.\n * @returns The default type definition for the environment variables.\n */\nexport async function getDefaultVarsTypeDefinition<\n TContext extends UnresolvedContext\n>(context: TContext): Promise<TypeDefinition> {\n return {\n file: await resolveRuntimeTypeFile(context),\n name: \"EnvInterface\"\n };\n}\n\n/** Gets the default type definition for the environment secrets.\n *\n * @param context - The plugin context.\n * @returns The default type definition for the environment secrets.\n */\nexport async function getDefaultSecretsTypeDefinition<\n TContext extends UnresolvedContext\n>(context: TContext): Promise<TypeDefinition> {\n return {\n file: await resolveRuntimeTypeFile(context),\n name: \"SecretsInterface\"\n };\n}\n\n/**\n * Extracts the environment variables and secrets schema from the provided type definitions in the plugin options, merges them with the default environment variables and secrets schema, and stores the resulting schema in the plugin context for later use during the build process.\n *\n * @remarks\n * This function should be called during the plugin's `config` hook to ensure that the environment variables and secrets schema is available in the plugin context before the build process begins. The resulting schema will be used to validate the loaded environment variables and secrets, as well as to provide type information for the injected environment variables and secrets during the build process.\n *\n * @param context - The plugin context\n * @param options - The plugin options containing the environment variables and secrets type definitions to extract the schema from. If not provided, the default type definitions will be used.\n * @returns A promise that resolves when the schema has been extracted and stored in the plugin context.\n */\nexport async function extractEnvSchema<TContext extends EnvPluginContext>(\n context: TContext,\n options: EnvPluginOptions = {}\n): Promise<void> {\n const defaultVarsTypeDefinition = await getDefaultVarsTypeDefinition(context);\n const defaultSecretsTypeDefinition =\n await getDefaultSecretsTypeDefinition(context);\n\n const vars = (await extract(\n context,\n context.config.env.vars\n )) as ObjectSchema<EnvSchemaMetadata>;\n if (\n (isString(context.config.env.vars) &&\n context.config.env.vars !==\n `${defaultVarsTypeDefinition.file}#${\n defaultVarsTypeDefinition.name\n }`) ||\n (isSetObject(context.config.env.vars) &&\n ((context.config.env.vars as TypeDefinition).file !==\n defaultVarsTypeDefinition.file ||\n (context.config.env.vars as TypeDefinition).name !==\n defaultVarsTypeDefinition.name))\n ) {\n vars.schema = mergeSchemas(\n vars,\n (await extract(\n context,\n defaultVarsTypeDefinition\n )) as ObjectSchema<EnvSchemaMetadata>\n );\n }\n\n const secrets = (await extract(\n context,\n context.config.env.secrets\n )) as ObjectSchema<EnvSchemaMetadata>;\n if (\n (isString(context.config.env.secrets) &&\n context.config.env.secrets !==\n `${defaultSecretsTypeDefinition.file}#${\n defaultSecretsTypeDefinition.name\n }`) ||\n (isSetObject(context.config.env.secrets) &&\n ((context.config.env.secrets as TypeDefinition).file !==\n defaultSecretsTypeDefinition.file ||\n (context.config.env.secrets as TypeDefinition).name !==\n defaultSecretsTypeDefinition.name))\n ) {\n secrets.schema = mergeSchemas(\n secrets,\n (await extract(\n context,\n defaultSecretsTypeDefinition\n )) as ObjectSchema<EnvSchemaMetadata>\n );\n }\n\n context.env = defu(\n {\n vars,\n secrets,\n parsed: await loadEnv(context, context.config.env)\n },\n context.env ?? {},\n {\n parsed: {},\n injected: []\n }\n );\n\n const properties = getProperties(context.env.vars);\n context.info({\n meta: {\n category: \"env\"\n },\n message: `Environment Variables configuration: ${\n options.vars ? \"\" : \"Defaulted \"\n }${\n context.env.vars.variant === \"reflection\"\n ? \"Deepkit type definition\"\n : context.env.vars.variant === \"json-schema\"\n ? \"JSON Schema\"\n : context.env.vars.variant === \"standard-schema\"\n ? \"Standard Schema\"\n : context.env.vars.variant === \"zod3\"\n ? \"Zod v3 schema\"\n : \"Typescript exported type\"\n }${options.vars ? \" from plugin options\" : \"\"} provided ${\n Object.keys(properties).length\n } parameters\\nEnvironment Secret configuration: ${\n options.secrets ? \"\" : \"Defaulted \"\n }${\n context.env.secrets.variant === \"reflection\"\n ? \"Deepkit type definition\"\n : context.env.secrets.variant === \"json-schema\"\n ? \"JSON Schema\"\n : context.env.secrets.variant === \"standard-schema\"\n ? \"Standard Schema\"\n : context.env.secrets.variant === \"zod3\"\n ? \"Zod v3 schema\"\n : \"Typescript exported type\"\n }${options.secrets ? \" from plugin options\" : \"\"} provided ${\n context.env.secrets?.schema\n ? Object.keys(getProperties(context.env.secrets)).length\n : \"0\"\n } parameters\\nEnvironment variable Prefixes: ${context.config.env.prefix.join(\n \", \"\n )}\\nShould inject values: ${\n context.config.env.inject ? \"Yes\" : \"No\"\n }\\nShould validate configuration: ${\n context.config.env.validate ? \"Yes\" : \"No\"\n }`\n });\n\n const aliases = Object.fromEntries(\n Object.entries(properties).flatMap(\n ([key, prop]) =>\n (isSetArray(prop.metadata?.alias)\n ? prop.metadata?.alias?.map(alias => [\n alias,\n { ...prop, metadata: { ...prop.metadata, alias: [key] } }\n ])\n : []) as [string, typeof prop][]\n )\n );\n\n for (const [key, value] of Object.entries(\n await loadEnv(context, context.config.env)\n )) {\n const unprefixedKey = context.config.env.prefix.reduce((ret, prefix) => {\n if (key.replace(/_$/g, \"\").startsWith(prefix)) {\n return key.replace(/_$/g, \"\").slice(prefix.length);\n }\n return ret;\n }, key);\n if (properties[unprefixedKey]) {\n if (!properties[unprefixedKey].metadata?.isRuntime) {\n if (\n properties[unprefixedKey].optional &&\n context.env.vars.schema.optionalProperties?.[unprefixedKey]\n ) {\n context.env.vars.schema.optionalProperties[unprefixedKey].metadata ??=\n {} as EnvSchemaMetadata;\n context.env.vars.schema.optionalProperties[\n unprefixedKey\n ].metadata.default = value;\n } else if (context.env.vars.schema.properties?.[unprefixedKey]) {\n context.env.vars.schema.properties[unprefixedKey].metadata ??=\n {} as EnvSchemaMetadata;\n context.env.vars.schema.properties[unprefixedKey].metadata.default =\n value;\n }\n }\n } else if (aliases[unprefixedKey]) {\n if (!aliases[unprefixedKey].metadata?.isRuntime) {\n const alias =\n aliases[unprefixedKey].metadata?.alias?.[0] ?? unprefixedKey;\n if (\n aliases[unprefixedKey].optional &&\n context.env.vars.schema.optionalProperties?.[alias]\n ) {\n context.env.vars.schema.optionalProperties[alias].metadata ??=\n {} as EnvSchemaMetadata;\n context.env.vars.schema.optionalProperties[alias].metadata.default =\n value;\n } else if (context.env.vars.schema.properties?.[alias]) {\n context.env.vars.schema.properties[alias].metadata ??=\n {} as EnvSchemaMetadata;\n context.env.vars.schema.properties[alias].metadata.default = value;\n }\n }\n }\n }\n}\n"],"mappings":";;;;;;;;;;AAEA,SAAS,aAAY,IAAK,MAAC;;CAE1B,OAAK;AACN;;;;;;;AAcA,eAAmB,uBAAyB,SAAQ;CACpD,MAAQ,WAAC,MAAe,QAAA,GAAY,QAAQ,kCAA4B;CACxE,IAAM,CAAC,UACP,MAAS,IAAA,MAAW,yJAA2C;CAE/D,OAAO;AACP;AACA,uBAAS,SAAoB;CAAI;CAAE;CAAW;CAAA;AAAA;;;;;;;;CAQ5C,OAAA;EACC,MAAA,MAAa,uBAAuB,OAAM;EAC5C,MAAA;CACC;AACF;AACA,6BAAE,SAAA;CAAA;CAAA;CAAA;CAAA;AAAA;;;;;;AAMF,eAAmB,gCAAA,SAAA;CACjB,OAAK;EACH,MAAC,MAAA,uBAAA,OAAA;EACH,MAAA;;AAEF;AACA,gCAAA,SAAA;CAAA;CAAA;CAAA;AAAA;;;;;;;;;;;AAWA,eAAS,iBAAA,SAAA,UAAA,CAAA,GAAA;CACP,MAAM,4BAAQ,MAAuB,6BAAQ,OAAA;CAC7C,MAAM,+BAAe,MAAA,gCAAA,OAAA;CACrB,MAAC,OAAA,MAAA,QAAA,SAAA,QAAA,OAAA,IAAA,IAAA;CACH,IAAA,SAAA,QAAA,OAAA,IAAA,IAAA,KAAA,QAAA,OAAA,IAAA,SAAA,GAAA,0BAAA,KAAA,GAAA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AAA;KAC1B,QAAG,IAAA,KAAA,OAAA,WAAA,eAAA,SAAA,UAAA;IACR;;EACC,OACE,IAAA,QAAA,gBACF;OAAG,CAAA,QAAQ,eAAgB,UAAG,WAAgB;IAC5C,MAAE,QAAA,QAAA,eAA+B,UAAA,QAAA,MAAA;IACrC,IAAA,QAAA,eAAA,YAAA,QAAA,IAAA,KAAA,OAAA,qBAAA,QAAA;KACK,QAAS,IAAA,KAAA,OAAY,mBAAA,OAAA,aAAA,CAAA;KACpB,QAAA,IAAA,KAAA,OAAA,mBAAA,OAAA,SAAA,UAAA;IACH,OAAM,IAAA,QAAO,IAAA,KAAA,OAAA,aAAA,QAAA;KACZ,QAAO,IAAA,KAAA,OAAA,WAAA,OAAA,aAAA,CAAA;KACP,QAAA,IAAA,KAAA,OAAA,WAAA,OAAA,SAAA,UAAA;IACA;GACH;;;AAGL;AACA,iBAAW,SAAA;CAAA;OAAA;CAAA;QAAA,CAAA;CAAA;CAAA;CAAA;AAAA"}
1
+ {"version":3,"file":"schema.mjs","names":[],"sources":["../../src/helpers/schema.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 { getCacheDirectory } from \"@powerlines/schema\";\nimport { extract } from \"@powerlines/schema/extract\";\nimport {\n getProperties,\n getPropertiesList,\n mergeSchemas\n} from \"@powerlines/schema/helpers\";\nimport { joinPaths } from \"@stryke/path/join\";\nimport { isSetArray } from \"@stryke/type-checks/is-set-array\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport { isString } from \"@stryke/type-checks/is-string\";\nimport type { TypeDefinition } from \"@stryke/types/configuration\";\nimport defu from \"defu\";\nimport { UnresolvedContext } from \"powerlines\";\nimport { EnvPluginContext, EnvSchema } from \"../types/plugin\";\nimport { loadEnv } from \"./load\";\n\n/**\n * Resolves the runtime type definition file for the environment variables.\n *\n * @param context - The plugin context.\n * @returns The runtime type definition file for the environment variables.\n */\nexport async function resolveRuntimeTypeFile<\n TContext extends UnresolvedContext\n>(context: TContext): Promise<string> {\n const resolved = await context.fs.resolve(\"@powerlines/plugin-env/types/env\");\n if (!resolved) {\n throw new Error(\n `Failed to resolve the runtime type definition file for the environment variables. Please ensure that the \"@powerlines/plugin-env\" package is installed.`\n );\n }\n\n return resolved;\n}\n\n/**\n * Gets the default type definition for the environment variables.\n *\n * @param context - The plugin context.\n * @returns The default type definition for the environment variables.\n */\nexport async function getDefaultVarsTypeDefinition<\n TContext extends UnresolvedContext\n>(context: TContext): Promise<TypeDefinition> {\n return {\n file: await resolveRuntimeTypeFile(context),\n name: \"EnvInterface\"\n };\n}\n\n/** Gets the default type definition for the environment secrets.\n *\n * @param context - The plugin context.\n * @returns The default type definition for the environment secrets.\n */\nexport async function getDefaultSecretsTypeDefinition<\n TContext extends UnresolvedContext\n>(context: TContext): Promise<TypeDefinition> {\n return {\n file: await resolveRuntimeTypeFile(context),\n name: \"SecretsInterface\"\n };\n}\n\n/**\n * Extracts the environment variables and secrets schema from the provided type definitions in the plugin options, merges them with the default environment variables and secrets schema, and stores the resulting schema in the plugin context for later use during the build process.\n *\n * @remarks\n * This function should be called during the plugin's `config` hook to ensure that the environment variables and secrets schema is available in the plugin context before the build process begins. The resulting schema will be used to validate the loaded environment variables and secrets, as well as to provide type information for the injected environment variables and secrets during the build process.\n *\n * @param context - The plugin context\n * @returns A promise that resolves when the schema has been extracted and stored in the plugin context.\n */\nexport async function extractEnvSchema<TContext extends EnvPluginContext>(\n context: TContext\n): Promise<void> {\n const defaultVarsTypeDefinition = await getDefaultVarsTypeDefinition(context);\n const defaultSecretsTypeDefinition =\n await getDefaultSecretsTypeDefinition(context);\n\n const vars = (await extract(context, context.config.env.vars)) as EnvSchema;\n if (\n (isString(context.config.env.vars) &&\n context.config.env.vars !==\n `${defaultVarsTypeDefinition.file}#${\n defaultVarsTypeDefinition.name\n }`) ||\n (isSetObject(context.config.env.vars) &&\n ((context.config.env.vars as TypeDefinition).file !==\n defaultVarsTypeDefinition.file ||\n (context.config.env.vars as TypeDefinition).name !==\n defaultVarsTypeDefinition.name))\n ) {\n vars.schema = mergeSchemas(\n vars,\n (await extract(context, defaultVarsTypeDefinition)) as EnvSchema\n );\n }\n\n const secrets = (await extract(\n context,\n context.config.env.secrets\n )) as EnvSchema;\n if (\n (isString(context.config.env.secrets) &&\n context.config.env.secrets !==\n `${defaultSecretsTypeDefinition.file}#${\n defaultSecretsTypeDefinition.name\n }`) ||\n (isSetObject(context.config.env.secrets) &&\n ((context.config.env.secrets as TypeDefinition).file !==\n defaultSecretsTypeDefinition.file ||\n (context.config.env.secrets as TypeDefinition).name !==\n defaultSecretsTypeDefinition.name))\n ) {\n secrets.schema = mergeSchemas(\n secrets,\n (await extract(context, defaultSecretsTypeDefinition)) as EnvSchema\n );\n }\n\n context.env = defu(\n {\n vars,\n secrets,\n parsed: await loadEnv(context, context.config.env)\n },\n context.env ?? {},\n {\n parsed: {},\n injected: []\n }\n );\n await readActiveEnv(context);\n\n const properties = getProperties(context.env.vars);\n context.info({\n meta: {\n category: \"env\"\n },\n message: `Environment Variables configuration: ${\n context.config.env.vars ? \"\" : \"Defaulted \"\n }${\n context.env.vars.variant === \"reflection\"\n ? \"Deepkit type definition\"\n : context.env.vars.variant === \"json-schema\"\n ? \"JSON Schema\"\n : context.env.vars.variant === \"standard-schema\"\n ? \"Standard Schema\"\n : context.env.vars.variant === \"zod3\"\n ? \"Zod v3 schema\"\n : \"Typescript exported type\"\n }${context.config.env.vars ? \" from plugin options\" : \"\"} provided ${\n Object.keys(properties).length\n } parameters\\nEnvironment Secret configuration: ${\n context.config.env.secrets ? \"\" : \"Defaulted \"\n }${\n context.env.secrets.variant === \"reflection\"\n ? \"Deepkit type definition\"\n : context.env.secrets.variant === \"json-schema\"\n ? \"JSON Schema\"\n : context.env.secrets.variant === \"standard-schema\"\n ? \"Standard Schema\"\n : context.env.secrets.variant === \"zod3\"\n ? \"Zod v3 schema\"\n : \"Typescript exported type\"\n }${context.config.env.secrets ? \" from plugin options\" : \"\"} provided ${\n context.env.secrets?.schema\n ? getPropertiesList(context.env.secrets).length\n : \"0\"\n } parameters\\nEnvironment variable Prefixes: ${context.config.env.prefix.join(\n \", \"\n )}\\nShould inject values: ${\n context.config.env.inject ? \"Yes\" : \"No\"\n }\\nShould validate configuration: ${\n context.config.env.validate ? \"Yes\" : \"No\"\n }`\n });\n\n const aliases = Object.fromEntries(\n Object.entries(properties).flatMap(\n ([key, prop]) =>\n (isSetArray(prop.metadata?.alias)\n ? prop.metadata?.alias?.map(alias => [\n alias,\n { ...prop, metadata: { ...prop.metadata, alias: [key] } }\n ])\n : []) as [string, typeof prop][]\n )\n );\n\n for (const [key, value] of Object.entries(\n await loadEnv(context, context.config.env)\n )) {\n const unprefixedKey = context.config.env.prefix.reduce((ret, prefix) => {\n if (key.replace(/_$/g, \"\").startsWith(prefix)) {\n return key.replace(/_$/g, \"\").slice(prefix.length);\n }\n return ret;\n }, key);\n if (properties[unprefixedKey]) {\n if (!properties[unprefixedKey].metadata?.isRuntime) {\n if (\n properties[unprefixedKey].optional &&\n context.env.vars.schema.optionalProperties?.[unprefixedKey]\n ) {\n context.env.vars.schema.optionalProperties[unprefixedKey].metadata ??=\n {};\n context.env.vars.schema.optionalProperties[\n unprefixedKey\n ].metadata.default = value;\n } else if (context.env.vars.schema.properties?.[unprefixedKey]) {\n context.env.vars.schema.properties[unprefixedKey].metadata ??= {};\n context.env.vars.schema.properties[unprefixedKey].metadata.default =\n value;\n }\n }\n } else if (aliases[unprefixedKey]) {\n if (!aliases[unprefixedKey].metadata?.isRuntime) {\n const alias =\n aliases[unprefixedKey].metadata?.alias?.[0] ?? unprefixedKey;\n if (\n aliases[unprefixedKey].optional &&\n context.env.vars.schema.optionalProperties?.[alias]\n ) {\n context.env.vars.schema.optionalProperties[alias].metadata ??= {};\n context.env.vars.schema.optionalProperties[alias].metadata.default =\n value;\n } else if (context.env.vars.schema.properties?.[alias]) {\n context.env.vars.schema.properties[alias].metadata ??= {};\n context.env.vars.schema.properties[alias].metadata.default = value;\n }\n }\n }\n }\n}\n\n/**\n * Reads the active environment variables and secrets from the plugin context's cache and stores them in the plugin context for use during the build process. This function should be called during the plugin's `buildStart` hook to ensure that the active environment variables and secrets are available before the build process begins.\n *\n * @param context - The plugin context\n * @returns A promise that resolves when the active environment variables and secrets have been read and stored in the plugin context.\n */\nexport async function readActiveEnv<TContext extends EnvPluginContext>(\n context: TContext\n) {\n context.env.vars.active ??= [];\n if (\n context.fs.existsSync(\n joinPaths(getCacheDirectory(context), \"env\", \"vars.json\")\n )\n ) {\n const content = await context.fs.read(\n joinPaths(getCacheDirectory(context), \"env\", \"vars.json\")\n );\n if (content) {\n context.env.vars.active = JSON.parse(content)?.elements ?? [];\n }\n }\n\n context.env.secrets.active ??= [];\n if (\n context.fs.existsSync(\n joinPaths(getCacheDirectory(context), \"env\", \"secrets.json\")\n )\n ) {\n const content = await context.fs.read(\n joinPaths(getCacheDirectory(context), \"env\", \"secrets.json\")\n );\n if (content) {\n context.env.secrets.active = JSON.parse(content)?.elements ?? [];\n }\n }\n}\n\n/**\n * Writes the active environment variables and secrets from the plugin context to the plugin context's cache for use during the build process. This function should be called whenever the active environment variables and secrets are updated in the plugin context to ensure that the latest values are available during the build process.\n *\n * @param context - The plugin context\n * @returns A promise that resolves when the active environment variables and secrets have been written to the plugin context's cache.\n */\nexport async function writeActiveEnv<TContext extends EnvPluginContext>(\n context: TContext\n) {\n return Promise.all(\n [\n isSetArray(context.env.vars.active)\n ? context.fs.write(\n joinPaths(getCacheDirectory(context), \"env\", \"vars.json\"),\n JSON.stringify({\n elements: context.env.vars.active\n })\n )\n : undefined,\n isSetArray(context.env.secrets.active)\n ? context.fs.write(\n joinPaths(getCacheDirectory(context), \"env\", \"secrets.json\"),\n JSON.stringify({\n elements: context.env.secrets.active\n })\n )\n : undefined\n ].filter(Boolean) as Promise<void>[]\n );\n}\n"],"mappings":";;;;;;;;;;;AAAA,SAAS,aAAa,IAAI,MAAM;;CAE9B,OAAO;;;;;;;;AAkCT,eAAgB,uBAA6B,SAAQ;CACpD,MAAA,WAAA,MAAA,QAAA,GAAA,QAAA,kCAAA;CACC,IAAE,CAAA,UACA,MAAA,IAAQ,MAAI,yJAA0D;CAE1E,OAAO;AACP;AACA,uBAAsB,SAAQ;CAAA;CAAQ;CAAA;CAAA;AAAA;;;;;;;;CAQpC,OAAO;EACT,MAAA,MAAA,uBAAA,OAAA;;CAEE;AACF;AACA,6BAAC,SAAA;CAAA;CAAA;CAAA;CAAA;AAAA;;;;;;AAMD,eAAsB,gCAAwB,SAAA;CAC5C,OAAO;EACL,MAAM,MAAM,uBAAuB,OAAO;EAC1C,MAAM;CACR;AACF;;;;;;;;;;;;;;;AAWA,eAAgB,iBAAuB,SAAQ;CAC7C,MAAM,4BAAmB,MAAA,6BAAA,OAAA;CACzB,MAAC,+BAAA,MAAA,gCAAA,OAAA;CACH,MAAA,OAAA,MAAA,QAAA,SAAA,QAAA,OAAA,IAAA,IAAA;6TAEE,KAAA,SAAA,aAAA,MAAA,MAAA,QAAA,SAAA,yBAAA,CAAA;CAED,MAAA,UAAA,MAAA,QAAA,SAAA,QAAA,OAAA,IAAA,OAAA;CACC,IAAE,SAAA,QAAA,OAAA,IAAA,OAAA,KAAA,QAAA,OAAA,IAAA,YAAA,GAAA,6BAAA,KAAA,GAAA,6BAAA,UAAA,YAAA,QAAA,OAAA,IAAA,OAAA,MAAA,QAAA,OAAA,IAAA,QAAA,SAAA,6BAAA,QAAA,QAAA,OAAA,IAAA,QAAA,SAAA,6BAAA,OACD,QAAK,S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AAsB;CAAM;AAAA"}
package/dist/index.cjs CHANGED
@@ -7,11 +7,11 @@ const require_helpers_automd_generator = require('./helpers/automd-generator.cjs
7
7
  const require_components_docs = require('./components/docs.cjs');
8
8
  const require_components_env_builtin = require('./components/env-builtin.cjs');
9
9
  const require_babel_plugin = require('./babel/plugin.cjs');
10
+ let _stryke_path_join = require("@stryke/path/join");
10
11
  let defu = require("defu");
11
12
  defu = require_runtime.__toESM(defu);
12
13
  let powerlines_plugin_utils = require("powerlines/plugin-utils");
13
14
  let _alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
14
- let _stryke_path_join = require("@stryke/path/join");
15
15
  let _stryke_helpers_get_unique = require("@stryke/helpers/get-unique");
16
16
  let _powerlines_plugin_alloy_render = require("@powerlines/plugin-alloy/render");
17
17
  let _powerlines_plugin_automd = require("@powerlines/plugin-automd");
@@ -77,7 +77,7 @@ const plugin = __assignType((options = {}) => {
77
77
  },
78
78
  configResolved: __assignType(async function configResolved() {
79
79
  this.debug(`Environment plugin configuration has been resolved for the Powerlines project.`);
80
- await require_helpers_schema.extractEnvSchema(this, options);
80
+ await require_helpers_schema.extractEnvSchema(this);
81
81
  }, ["configResolved", "P\"/!"]),
82
82
  prepare: __assignType(async function prepare() {
83
83
  const _self$ = this;
@@ -128,7 +128,7 @@ exports.__ΩEnvPluginContext = require_types_plugin.__ΩEnvPluginContext;
128
128
  exports.__ΩEnvPluginOptions = require_types_plugin.__ΩEnvPluginOptions;
129
129
  exports.__ΩEnvPluginResolvedConfig = require_types_plugin.__ΩEnvPluginResolvedConfig;
130
130
  exports.__ΩEnvPluginUserConfig = require_types_plugin.__ΩEnvPluginUserConfig;
131
- exports.__ΩEnvSchemaMetadata = require_types_plugin.__ΩEnvSchemaMetadata;
131
+ exports.__ΩEnvSchema = require_types_plugin.__ΩEnvSchema;
132
132
  exports.__ΩEnvType = require_types_plugin.__ΩEnvType;
133
133
  exports.__ΩSecretsInterface = require_types_env.__ΩSecretsInterface;
134
134
  exports.default = plugin;
package/dist/index.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { EnvPluginContext, EnvPluginOptions, EnvPluginResolvedConfig, EnvPluginUserConfig, EnvSchemaMetadata, EnvType } from "./types/plugin.cjs";
1
+ import { EnvPluginContext, EnvPluginOptions, EnvPluginResolvedConfig, EnvPluginUserConfig, EnvSchema, EnvType } from "./types/plugin.cjs";
2
2
  import { EnvInterface, SecretsInterface } from "./types/env.cjs";
3
3
  import { Plugin } from "powerlines";
4
4
 
@@ -13,5 +13,5 @@ declare module "powerlines" {
13
13
  */
14
14
  declare const plugin: <TContext extends EnvPluginContext = EnvPluginContext>(options?: EnvPluginOptions) => Plugin<TContext>[];
15
15
  //#endregion
16
- export { EnvInterface, EnvPluginContext, EnvPluginOptions, EnvPluginResolvedConfig, EnvPluginUserConfig, EnvSchemaMetadata, EnvType, SecretsInterface, plugin as default, plugin };
16
+ export { EnvInterface, EnvPluginContext, EnvPluginOptions, EnvPluginResolvedConfig, EnvPluginUserConfig, EnvSchema, EnvType, SecretsInterface, plugin as default, plugin };
17
17
  //# sourceMappingURL=index.d.cts.map
package/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { EnvPluginContext, EnvPluginOptions, EnvPluginResolvedConfig, EnvPluginUserConfig, EnvSchemaMetadata, EnvType } from "./types/plugin.mjs";
1
+ import { EnvPluginContext, EnvPluginOptions, EnvPluginResolvedConfig, EnvPluginUserConfig, EnvSchema, EnvType } from "./types/plugin.mjs";
2
2
  import { EnvInterface, SecretsInterface } from "./types/env.mjs";
3
3
  import { Plugin } from "powerlines";
4
4
 
@@ -13,5 +13,5 @@ declare module "powerlines" {
13
13
  */
14
14
  declare const plugin: <TContext extends EnvPluginContext = EnvPluginContext>(options?: EnvPluginOptions) => Plugin<TContext>[];
15
15
  //#endregion
16
- export { EnvInterface, EnvPluginContext, EnvPluginOptions, EnvPluginResolvedConfig, EnvPluginUserConfig, EnvSchemaMetadata, EnvType, SecretsInterface, plugin as default, plugin };
16
+ export { EnvInterface, EnvPluginContext, EnvPluginOptions, EnvPluginResolvedConfig, EnvPluginUserConfig, EnvSchema, EnvType, SecretsInterface, plugin as default, plugin };
17
17
  //# sourceMappingURL=index.d.mts.map
package/dist/index.mjs CHANGED
@@ -1,14 +1,14 @@
1
- import { __ΩEnvPluginContext, __ΩEnvPluginOptions, __ΩEnvPluginResolvedConfig, __ΩEnvPluginUserConfig, __ΩEnvSchemaMetadata, __ΩEnvType } from "./types/plugin.mjs";
1
+ import { __ΩEnvPluginContext, __ΩEnvPluginOptions, __ΩEnvPluginResolvedConfig, __ΩEnvPluginUserConfig, __ΩEnvSchema, __ΩEnvType } from "./types/plugin.mjs";
2
2
  import { __ΩEnvInterface, __ΩSecretsInterface } from "./types/env.mjs";
3
3
  import { extractEnvSchema, getDefaultSecretsTypeDefinition, getDefaultVarsTypeDefinition } from "./helpers/schema.mjs";
4
4
  import { env } from "./helpers/automd-generator.mjs";
5
5
  import { EnvDocsFile } from "./components/docs.mjs";
6
6
  import { EnvBuiltin } from "./components/env-builtin.mjs";
7
7
  import { envBabelPlugin } from "./babel/plugin.mjs";
8
+ import { joinPaths } from "@stryke/path/join";
8
9
  import defu from "defu";
9
10
  import { getDocsOutputPath } from "powerlines/plugin-utils";
10
11
  import { createComponent } from "@alloy-js/core/jsx-runtime";
11
- import { joinPaths } from "@stryke/path/join";
12
12
  import { getUnique } from "@stryke/helpers/get-unique";
13
13
  import { render } from "@powerlines/plugin-alloy/render";
14
14
  import automd from "@powerlines/plugin-automd";
@@ -72,7 +72,7 @@ const plugin = __assignType((options = {}) => {
72
72
  },
73
73
  configResolved: __assignType(async function configResolved() {
74
74
  this.debug(`Environment plugin configuration has been resolved for the Powerlines project.`);
75
- await extractEnvSchema(this, options);
75
+ await extractEnvSchema(this);
76
76
  }, ["configResolved", "P\"/!"]),
77
77
  prepare: __assignType(async function prepare() {
78
78
  const _self$ = this;
@@ -118,5 +118,5 @@ const plugin = __assignType((options = {}) => {
118
118
  ]);
119
119
 
120
120
  //#endregion
121
- export { __ΩEnvInterface, __ΩEnvPluginContext, __ΩEnvPluginOptions, __ΩEnvPluginResolvedConfig, __ΩEnvPluginUserConfig, __ΩEnvSchemaMetadata, __ΩEnvType, __ΩSecretsInterface, plugin as default, plugin };
121
+ export { __ΩEnvInterface, __ΩEnvPluginContext, __ΩEnvPluginOptions, __ΩEnvPluginResolvedConfig, __ΩEnvPluginUserConfig, __ΩEnvSchema, __ΩEnvType, __ΩSecretsInterface, plugin as default, plugin };
122
122
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":[],"sources":["../src/index.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 { render } from \"@powerlines/plugin-alloy/render\";\nimport automd from \"@powerlines/plugin-automd\";\nimport babel from \"@powerlines/plugin-babel\";\nimport { writeSchema } from \"@powerlines/schema/persistence\";\nimport { toArray } from \"@stryke/convert/to-array\";\nimport { getUnique } from \"@stryke/helpers/get-unique\";\nimport { joinPaths } from \"@stryke/path/join\";\nimport { constantCase } from \"@stryke/string-format/constant-case\";\nimport defu from \"defu\";\nimport type { Plugin, UnresolvedContext } from \"powerlines\";\nimport { getDocsOutputPath } from \"powerlines/plugin-utils\";\nimport type { UserConfig as ViteUserConfig } from \"vite\";\nimport { envBabelPlugin } from \"./babel/plugin\";\nimport { EnvDocsFile } from \"./components/docs\";\nimport { EnvBuiltin } from \"./components/env-builtin\";\nimport { env } from \"./helpers/automd-generator\";\nimport {\n extractEnvSchema,\n getDefaultSecretsTypeDefinition,\n getDefaultVarsTypeDefinition\n} from \"./helpers/schema\";\nimport type { EnvPluginContext, EnvPluginOptions } from \"./types/plugin\";\n\nexport * from \"./types\";\n\ndeclare module \"powerlines\" {\n interface Config {\n env?: EnvPluginOptions;\n }\n}\n\n/**\n * A Powerlines plugin to inject environment variables into the source code.\n */\nexport const plugin = <TContext extends EnvPluginContext = EnvPluginContext>(\n options: EnvPluginOptions = {}\n) => {\n return [\n babel(options.babel),\n {\n name: \"env\",\n async config() {\n this.debug(\n \"Providing default configuration for the Powerlines `env` build plugin.\"\n );\n\n const config = {\n env: defu(options, {\n validate: false,\n inject: false,\n prefix: []\n }),\n babel: {\n ...options.babel,\n skipTransform: !options.inject,\n plugins: [envBabelPlugin]\n }\n };\n\n if (!config.env.vars) {\n this.warn(\n \"The `env.vars` configuration parameter was not provided. Please ensure this is expected.\"\n );\n\n config.env.vars = await getDefaultVarsTypeDefinition(\n this as UnresolvedContext\n );\n }\n\n if (!config.env.secrets) {\n config.env.secrets = await getDefaultSecretsTypeDefinition(\n this as UnresolvedContext\n );\n }\n\n config.env.prefix = toArray(\n (config.env.prefix ?? []) as string[]\n ).reduce(\n (ret: string[], prefix: string) => {\n const formattedPrefix = constantCase(prefix);\n if (!ret.includes(formattedPrefix)) {\n ret.push(formattedPrefix);\n }\n\n return ret;\n },\n [\n \"POWERLINES_\",\n this.config.framework?.name &&\n this.config.framework?.name !== \"powerlines\" &&\n `${constantCase(this.config.framework?.name)}_`\n ].filter(Boolean) as string[]\n );\n\n config.env.prefix = getUnique(\n toArray(config.env.prefix).reduce((ret, prefix) => {\n if (!ret.includes(prefix.replace(/_$/g, \"\"))) {\n ret.push(prefix.replace(/_$/g, \"\"));\n }\n return ret;\n }, [] as string[])\n );\n\n return config;\n },\n async configResolved() {\n this.debug(\n `Environment plugin configuration has been resolved for the Powerlines project.`\n );\n\n await extractEnvSchema(this, options);\n },\n async prepare() {\n this.debug(\n `Preparing the Environment runtime artifacts for the Powerlines project.`\n );\n\n return render(\n this,\n <EnvBuiltin defaultConfig={this.config.env.defaultConfig} />\n );\n },\n async docs() {\n this.debug(\n `Documenting environment variables configuration values in \"${joinPaths(\n getDocsOutputPath(this.config.root),\n \"env.md\"\n )}\"`\n );\n\n return render(this, <EnvDocsFile levelOffset={0} />);\n },\n async buildEnd() {\n this.debug(\"Writing active environment variables to disk.\");\n\n await writeSchema(this, this.env.vars);\n }\n },\n {\n name: \"env:automd-generator\",\n configResolved() {\n return {\n automd: defu(options.automd ?? {}, {\n generators: {\n env: env(this)\n }\n })\n };\n }\n },\n {\n name: \"env:vite\",\n vite: {\n configResolved(this: TContext) {\n return {\n envPrefix: this.config?.env?.prefix\n } as ViteUserConfig;\n }\n }\n },\n automd(options.automd)\n ] as Plugin<TContext>[];\n};\n\nexport default plugin;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;CAEE,GAAG,SAAS;;AAEd;;;;AAqCA,MAAa,SAAS,cAAC,UAAA,CAAA,MAAA;;;;GAEvB,MAAQ;GACN,MAAA,SAAiB;IACf,KAAM,MAAA,wEAAgB;IACxB,MAAA,SAAA;KACF,KAAA,KAAA,SAAA;;MAEE,QAAA;MACG,QAAW,CAAA;KACd,CAAA;KACK,OAAM;MACH,GAAC,QAAA;MACN,eAAA,CAAA,QAAA;MACI,SAAA,CAAA,cAAA;KACL;IACA;IACE,IAAI,CAAC,OAAM,IAAA,MAAA;KACX,KAAM,KAAM,0FAAG;KACb,OAAK,IAAK,OAAA,MAAA,6BAAA,IAAA;IACZ;IACA,IAAG,CAAA,OAAA,IAAA;IAGH,OAAO,IAAE,SAAK,QAAS,OAAA,IAAA,UAAA,CAAA,CAAA,EAAA,OAAA,cAAA,KAAA,WAAA;KACrB,MAAI,kBAAe,aAAA,MAAA;KACnB,IAAI,CAAA,IAAA,SAAa,eAAA,GACf,IAAE,KAAO,eAAE;KAEb,OAAO;IACT,GAAG;KAAC;KAAK;KAAQ;KAAK;IAAA,CAAA,G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ACJ,gBAAgB,aAAA,SAAA,iBAAA;IACd,OAAO,EACN,WAAA,KAAA,QAAA,KAAA;GAEH,GAAE;IAAA;IAAa;IAAA;IAAA;GAAA,CAAA,EACjB;EACF;EAAG,OAAO,QAAA,MAAc;CAAC;AAC3B,GAAG;CAAC;CAAc;QAAA,CAAA;CAAA;CAAA;AAAA,CAAA"}
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../src/index.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 { render } from \"@powerlines/plugin-alloy/render\";\nimport automd from \"@powerlines/plugin-automd\";\nimport babel from \"@powerlines/plugin-babel\";\nimport { writeSchema } from \"@powerlines/schema/persistence\";\nimport { toArray } from \"@stryke/convert/to-array\";\nimport { getUnique } from \"@stryke/helpers/get-unique\";\nimport { joinPaths } from \"@stryke/path/join\";\nimport { constantCase } from \"@stryke/string-format/constant-case\";\nimport defu from \"defu\";\nimport type { Plugin, UnresolvedContext } from \"powerlines\";\nimport { getDocsOutputPath } from \"powerlines/plugin-utils\";\nimport type { UserConfig as ViteUserConfig } from \"vite\";\nimport { envBabelPlugin } from \"./babel/plugin\";\nimport { EnvDocsFile } from \"./components/docs\";\nimport { EnvBuiltin } from \"./components/env-builtin\";\nimport { env } from \"./helpers/automd-generator\";\nimport {\n extractEnvSchema,\n getDefaultSecretsTypeDefinition,\n getDefaultVarsTypeDefinition\n} from \"./helpers/schema\";\nimport type { EnvPluginContext, EnvPluginOptions } from \"./types/plugin\";\n\nexport * from \"./types\";\n\ndeclare module \"powerlines\" {\n interface Config {\n env?: EnvPluginOptions;\n }\n}\n\n/**\n * A Powerlines plugin to inject environment variables into the source code.\n */\nexport const plugin = <TContext extends EnvPluginContext = EnvPluginContext>(\n options: EnvPluginOptions = {}\n) => {\n return [\n babel(options.babel),\n {\n name: \"env\",\n async config() {\n this.debug(\n \"Providing default configuration for the Powerlines `env` build plugin.\"\n );\n\n const config = {\n env: defu(options, {\n validate: false,\n inject: false,\n prefix: []\n }),\n babel: {\n ...options.babel,\n skipTransform: !options.inject,\n plugins: [envBabelPlugin]\n }\n };\n\n if (!config.env.vars) {\n this.warn(\n \"The `env.vars` configuration parameter was not provided. Please ensure this is expected.\"\n );\n\n config.env.vars = await getDefaultVarsTypeDefinition(\n this as UnresolvedContext\n );\n }\n\n if (!config.env.secrets) {\n config.env.secrets = await getDefaultSecretsTypeDefinition(\n this as UnresolvedContext\n );\n }\n\n config.env.prefix = toArray(\n (config.env.prefix ?? []) as string[]\n ).reduce(\n (ret: string[], prefix: string) => {\n const formattedPrefix = constantCase(prefix);\n if (!ret.includes(formattedPrefix)) {\n ret.push(formattedPrefix);\n }\n\n return ret;\n },\n [\n \"POWERLINES_\",\n this.config.framework?.name &&\n this.config.framework?.name !== \"powerlines\" &&\n `${constantCase(this.config.framework?.name)}_`\n ].filter(Boolean) as string[]\n );\n\n config.env.prefix = getUnique(\n toArray(config.env.prefix).reduce((ret, prefix) => {\n if (!ret.includes(prefix.replace(/_$/g, \"\"))) {\n ret.push(prefix.replace(/_$/g, \"\"));\n }\n return ret;\n }, [] as string[])\n );\n\n return config;\n },\n async configResolved() {\n this.debug(\n `Environment plugin configuration has been resolved for the Powerlines project.`\n );\n\n await extractEnvSchema(this);\n },\n async prepare() {\n this.debug(\n `Preparing the Environment runtime artifacts for the Powerlines project.`\n );\n\n return render(\n this,\n <EnvBuiltin defaultConfig={this.config.env.defaultConfig} />\n );\n },\n async docs() {\n this.debug(\n `Documenting environment variables configuration values in \"${joinPaths(\n getDocsOutputPath(this.config.root),\n \"env.md\"\n )}\"`\n );\n\n return render(this, <EnvDocsFile levelOffset={0} />);\n },\n async buildEnd() {\n this.debug(\"Writing active environment variables to disk.\");\n\n await writeSchema(this, this.env.vars);\n }\n },\n {\n name: \"env:automd-generator\",\n configResolved() {\n return {\n automd: defu(options.automd ?? {}, {\n generators: {\n env: env(this)\n }\n })\n };\n }\n },\n {\n name: \"env:vite\",\n vite: {\n configResolved(this: TContext) {\n return {\n envPrefix: this.config?.env?.prefix\n } as ViteUserConfig;\n }\n }\n },\n automd(options.automd)\n ] as Plugin<TContext>[];\n};\n\nexport default plugin;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;CAEE,GAAG,SAAS;;AAEd;;;;AAqCA,MAAa,SAAS,cAAC,UAAA,CAAA,MAAA;;;;GAEvB,MAAQ;GACN,MAAA,SAAiB;IACf,KAAM,MAAA,wEAAgB;IACxB,MAAA,SAAA;KACF,KAAA,KAAA,SAAA;;MAEE,QAAA;MACG,QAAW,CAAA;KACd,CAAA;KACK,OAAM;MACH,GAAC,QAAA;MACN,eAAA,CAAA,QAAA;MACI,SAAA,CAAA,cAAA;KACL;IACA;IACE,IAAI,CAAC,OAAM,IAAA,MAAA;KACX,KAAM,KAAM,0FAAG;KACb,OAAK,IAAK,OAAA,MAAA,6BAAA,IAAA;IACZ;IACA,IAAG,CAAA,OAAA,IAAA;IAGH,OAAO,IAAE,SAAK,QAAS,OAAA,IAAA,UAAA,CAAA,CAAA,EAAA,OAAA,cAAA,KAAA,WAAA;KACrB,MAAI,kBAAe,aAAA,MAAA;KACnB,IAAI,CAAA,IAAA,SAAa,eAAA,GACf,IAAE,KAAO,eAAE;KAEb,OAAO;IACT,GAAG;KAAC;KAAK;KAAQ;KAAK;IAAA,CAAA,GAAA,CAAA,eAAA,KAAA,OAAA,WAAA,QAAA,KAAA,OAAA,WAAA,SAAA,gBAAA,GAAA,aAAA,KAAA,OAAA,WAAA,IAAA,EAAA,EAAA,EAAA,OAAA,OAAA,CA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A,MAAc;CAAC;AAC3B,GAAG;CAAC;CAAc;QAAA,CAAA;CAAA;CAAA;AAAA,CAAA"}
@@ -7,6 +7,6 @@ exports.__ΩEnvPluginContext = require_types_plugin.__ΩEnvPluginContext;
7
7
  exports.__ΩEnvPluginOptions = require_types_plugin.__ΩEnvPluginOptions;
8
8
  exports.__ΩEnvPluginResolvedConfig = require_types_plugin.__ΩEnvPluginResolvedConfig;
9
9
  exports.__ΩEnvPluginUserConfig = require_types_plugin.__ΩEnvPluginUserConfig;
10
- exports.__ΩEnvSchemaMetadata = require_types_plugin.__ΩEnvSchemaMetadata;
10
+ exports.__ΩEnvSchema = require_types_plugin.__ΩEnvSchema;
11
11
  exports.__ΩEnvType = require_types_plugin.__ΩEnvType;
12
12
  exports.__ΩSecretsInterface = require_types_env.__ΩSecretsInterface;
@@ -1,3 +1,3 @@
1
- import { EnvPluginContext, EnvPluginOptions, EnvPluginResolvedConfig, EnvPluginUserConfig, EnvSchemaMetadata, EnvType } from "./plugin.cjs";
1
+ import { EnvPluginContext, EnvPluginOptions, EnvPluginResolvedConfig, EnvPluginUserConfig, EnvSchema, EnvType } from "./plugin.cjs";
2
2
  import { EnvInterface, SecretsInterface } from "./env.cjs";
3
- export { EnvInterface, EnvPluginContext, EnvPluginOptions, EnvPluginResolvedConfig, EnvPluginUserConfig, EnvSchemaMetadata, EnvType, SecretsInterface };
3
+ export { EnvInterface, EnvPluginContext, EnvPluginOptions, EnvPluginResolvedConfig, EnvPluginUserConfig, EnvSchema, EnvType, SecretsInterface };
@@ -1,3 +1,3 @@
1
- import { EnvPluginContext, EnvPluginOptions, EnvPluginResolvedConfig, EnvPluginUserConfig, EnvSchemaMetadata, EnvType } from "./plugin.mjs";
1
+ import { EnvPluginContext, EnvPluginOptions, EnvPluginResolvedConfig, EnvPluginUserConfig, EnvSchema, EnvType } from "./plugin.mjs";
2
2
  import { EnvInterface, SecretsInterface } from "./env.mjs";
3
- export { EnvInterface, EnvPluginContext, EnvPluginOptions, EnvPluginResolvedConfig, EnvPluginUserConfig, EnvSchemaMetadata, EnvType, SecretsInterface };
3
+ export { EnvInterface, EnvPluginContext, EnvPluginOptions, EnvPluginResolvedConfig, EnvPluginUserConfig, EnvSchema, EnvType, SecretsInterface };
@@ -1,4 +1,4 @@
1
- import { __ΩEnvPluginContext, __ΩEnvPluginOptions, __ΩEnvPluginResolvedConfig, __ΩEnvPluginUserConfig, __ΩEnvSchemaMetadata, __ΩEnvType } from "./plugin.mjs";
1
+ import { __ΩEnvPluginContext, __ΩEnvPluginOptions, __ΩEnvPluginResolvedConfig, __ΩEnvPluginUserConfig, __ΩEnvSchema, __ΩEnvType } from "./plugin.mjs";
2
2
  import { __ΩEnvInterface, __ΩSecretsInterface } from "./env.mjs";
3
3
 
4
- export { __ΩEnvInterface, __ΩEnvPluginContext, __ΩEnvPluginOptions, __ΩEnvPluginResolvedConfig, __ΩEnvPluginUserConfig, __ΩEnvSchemaMetadata, __ΩEnvType, __ΩSecretsInterface };
4
+ export { __ΩEnvInterface, __ΩEnvPluginContext, __ΩEnvPluginOptions, __ΩEnvPluginResolvedConfig, __ΩEnvPluginUserConfig, __ΩEnvSchema, __ΩEnvType, __ΩSecretsInterface };
@@ -20,6 +20,11 @@ const __ΩPick = [
20
20
  "Pick",
21
21
  "l+e#!e\"!fRb!b\"Pde\"\"N#!w#y"
22
22
  ];
23
+ const __ΩPartial = [
24
+ "T",
25
+ "Partial",
26
+ "l+e#!e\"!fRb!Pde\"!gN#\"w\"y"
27
+ ];
23
28
  const __ΩExclude = [
24
29
  "T",
25
30
  "U",
@@ -76,17 +81,22 @@ const __ΩEnvPluginResolvedConfig = [
76
81
  "EnvPluginResolvedConfig",
77
82
  "P!PP!.#o\"#o!\"!P)4$?%)4&?'&F4(?)MK4*MKw+y"
78
83
  ];
79
- const __ΩEnvSchemaMetadata = [
84
+ const __ΩEnvSchema = [
85
+ () => __ΩPartial,
86
+ "TMetadata",
80
87
  "active",
81
88
  "The active environment variables or secrets that are used by the project and are expected to be injected into the source code (if {@link EnvPluginOptions.inject} is true).",
82
- "EnvSchemaMetadata",
83
- "P!&F4!?\"Mw#y"
89
+ "The schema for the environment variables or secrets used by the project and expected to be injected into the source code (if {@link EnvPluginOptions.inject} is true). This schema extends the base {@link ObjectSchema} with additional metadata specific to environment variables, including an `active` property that lists the environment variables or secrets that are currently active and should be injected during the build process.",
90
+ "EnvSchema",
91
+ "!o!\"c\"P!&F4#?$M?%w&y"
84
92
  ];
85
93
  const __ΩEnvPluginContext = [
86
94
  () => __ΩEnvPluginResolvedConfig,
87
95
  "TResolvedConfig",
96
+ () => __ΩEnvSchema,
88
97
  "vars",
89
98
  "The type definition for the expected env variable parameters",
99
+ () => __ΩEnvSchema,
90
100
  "secrets",
91
101
  "The type definition for the expected env secret parameters",
92
102
  "parsed",
@@ -95,7 +105,7 @@ const __ΩEnvPluginContext = [
95
105
  "The injected environment variables and secrets reflection",
96
106
  "env",
97
107
  "EnvPluginContext",
98
- "n!c\"P!P!4#?$!4%?&!4'?(&F4)?*M4+Mw,y"
108
+ "n!c\"P!Pn#4$?%n&4'?(!4)?*&F4+?,M4-Mw.y"
99
109
  ];
100
110
 
101
111
  //#endregion
@@ -103,5 +113,5 @@ exports.__ΩEnvPluginContext = __ΩEnvPluginContext;
103
113
  exports.__ΩEnvPluginOptions = __ΩEnvPluginOptions;
104
114
  exports.__ΩEnvPluginResolvedConfig = __ΩEnvPluginResolvedConfig;
105
115
  exports.__ΩEnvPluginUserConfig = __ΩEnvPluginUserConfig;
106
- exports.__ΩEnvSchemaMetadata = __ΩEnvSchemaMetadata;
116
+ exports.__ΩEnvSchema = __ΩEnvSchema;
107
117
  exports.__ΩEnvType = __ΩEnvType;