@powerlines/plugin-env 0.16.240 → 0.16.250

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 (50) hide show
  1. package/dist/babel/plugin.cjs +8 -10
  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 +9 -10
  5. package/dist/babel/plugin.mjs.map +1 -1
  6. package/dist/components/docs.cjs +14 -11
  7. package/dist/components/docs.d.cts.map +1 -1
  8. package/dist/components/docs.d.mts.map +1 -1
  9. package/dist/components/docs.mjs +15 -11
  10. package/dist/components/docs.mjs.map +1 -1
  11. package/dist/components/env-builtin.cjs +19 -22
  12. package/dist/components/env-builtin.d.cts.map +1 -1
  13. package/dist/components/env-builtin.d.mts.map +1 -1
  14. package/dist/components/env-builtin.mjs +19 -21
  15. package/dist/components/env-builtin.mjs.map +1 -1
  16. package/dist/helpers/automd-generator.cjs +0 -1
  17. package/dist/helpers/index.cjs +2 -4
  18. package/dist/helpers/index.d.cts +2 -2
  19. package/dist/helpers/index.d.mts +2 -2
  20. package/dist/helpers/index.mjs +2 -2
  21. package/dist/helpers/load.cjs +1 -1
  22. package/dist/helpers/load.d.cts +3 -3
  23. package/dist/helpers/load.d.mts +3 -3
  24. package/dist/helpers/load.mjs +1 -1
  25. package/dist/helpers/load.mjs.map +1 -1
  26. package/dist/helpers/schema.cjs +24 -75
  27. package/dist/helpers/schema.d.cts +2 -16
  28. package/dist/helpers/schema.d.cts.map +1 -1
  29. package/dist/helpers/schema.d.mts +2 -16
  30. package/dist/helpers/schema.d.mts.map +1 -1
  31. package/dist/helpers/schema.mjs +25 -74
  32. package/dist/helpers/schema.mjs.map +1 -1
  33. package/dist/helpers/source-file-env.cjs +0 -1
  34. package/dist/index.cjs +3 -3
  35. package/dist/index.d.cts +2 -2
  36. package/dist/index.d.mts +2 -2
  37. package/dist/index.mjs +5 -5
  38. package/dist/index.mjs.map +1 -1
  39. package/dist/types/index.cjs +1 -1
  40. package/dist/types/index.d.cts +2 -2
  41. package/dist/types/index.d.mts +2 -2
  42. package/dist/types/index.mjs +2 -2
  43. package/dist/types/plugin.cjs +12 -14
  44. package/dist/types/plugin.d.cts +14 -8
  45. package/dist/types/plugin.d.cts.map +1 -1
  46. package/dist/types/plugin.d.mts +14 -8
  47. package/dist/types/plugin.d.mts.map +1 -1
  48. package/dist/types/plugin.mjs +12 -14
  49. package/dist/types/plugin.mjs.map +1 -1
  50. package/package.json +11 -11
@@ -32,21 +32,7 @@ declare function getDefaultSecretsTypeDefinition<TContext extends UnresolvedCont
32
32
  * @param context - The plugin context
33
33
  * @returns A promise that resolves when the schema has been extracted and stored in the plugin context.
34
34
  */
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[]>;
35
+ declare function extractEnv<TContext extends EnvPluginContext>(context: TContext): Promise<void>;
50
36
  //#endregion
51
- export { extractEnvSchema, getDefaultSecretsTypeDefinition, getDefaultVarsTypeDefinition, readActiveEnv, resolveRuntimeTypeFile, writeActiveEnv };
37
+ export { extractEnv, getDefaultSecretsTypeDefinition, getDefaultVarsTypeDefinition, resolveRuntimeTypeFile };
52
38
  //# sourceMappingURL=schema.d.mts.map
@@ -1 +1 @@
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
+ {"version":3,"file":"schema.d.mts","names":[],"sources":["../../src/helpers/schema.ts"],"mappings":";;;;;;;AAuCA;;;;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,UAAA,kBAA4B,gBAAA,CAAA,CAChD,OAAA,EAAS,QAAA,GACR,OAAA"}
@@ -1,9 +1,8 @@
1
+ import { __ΩEnv } from "../types/plugin.mjs";
1
2
  import { loadEnv } from "./load.mjs";
2
3
  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 as getProperties$1, getPropertiesList, mergeSchemas } from "@powerlines/schema/helpers";
6
- import { joinPaths } from "@stryke/path/join";
5
+ import { getProperties, getPropertiesList, mergeSchemas } from "@powerlines/schema/helpers";
7
6
  import { isSetArray } from "@stryke/type-checks/is-set-array";
8
7
  import { isSetObject } from "@stryke/type-checks/is-set-object";
9
8
  import defu from "defu";
@@ -73,13 +72,13 @@ getDefaultSecretsTypeDefinition.__type = [
73
72
  * @param context - The plugin context
74
73
  * @returns A promise that resolves when the schema has been extracted and stored in the plugin context.
75
74
  */
76
- async function extractEnvSchema(context) {
75
+ async function extractEnv(context) {
77
76
  const defaultVarsTypeDefinition = await getDefaultVarsTypeDefinition(context);
78
77
  const defaultSecretsTypeDefinition = await getDefaultSecretsTypeDefinition(context);
79
- const vars = await extract(context, context.config.env.vars);
80
- if (isString(context.config.env.vars) && context.config.env.vars !== `${defaultVarsTypeDefinition.file}#${defaultVarsTypeDefinition.name}` || isSetObject(context.config.env.vars) && (context.config.env.vars.file !== defaultVarsTypeDefinition.file || context.config.env.vars.name !== defaultVarsTypeDefinition.name)) vars.schema = mergeSchemas(vars, await extract(context, defaultVarsTypeDefinition));
81
- const secrets = await extract(context, context.config.env.secrets);
82
- if (isString(context.config.env.secrets) && context.config.env.secrets !== `${defaultSecretsTypeDefinition.file}#${defaultSecretsTypeDefinition.name}` || isSetObject(context.config.env.secrets) && (context.config.env.secrets.file !== defaultSecretsTypeDefinition.file || context.config.env.secrets.name !== defaultSecretsTypeDefinition.name)) secrets.schema = mergeSchemas(secrets, await extract(context, defaultSecretsTypeDefinition));
78
+ const vars = await (extract.Ω = [[() => __ΩEnv, "n!"]], extract(context, context.config.env.vars));
79
+ if (isString(context.config.env.vars) && context.config.env.vars !== `${defaultVarsTypeDefinition.file}#${defaultVarsTypeDefinition.name}` || isSetObject(context.config.env.vars) && (context.config.env.vars.file !== defaultVarsTypeDefinition.file || context.config.env.vars.name !== defaultVarsTypeDefinition.name)) vars.schema = (mergeSchemas.Ω = [[() => __ΩEnv, "n!"]], mergeSchemas(vars, await (extract.Ω = [[() => __ΩEnv, "n!"]], extract(context, defaultVarsTypeDefinition))));
80
+ const secrets = await (extract.Ω = [[() => __ΩEnv, "n!"]], extract(context, context.config.env.secrets));
81
+ if (isString(context.config.env.secrets) && context.config.env.secrets !== `${defaultSecretsTypeDefinition.file}#${defaultSecretsTypeDefinition.name}` || isSetObject(context.config.env.secrets) && (context.config.env.secrets.file !== defaultSecretsTypeDefinition.file || context.config.env.secrets.name !== defaultSecretsTypeDefinition.name)) secrets.schema = (mergeSchemas.Ω = [[() => __ΩEnv, "n!"]], mergeSchemas(secrets, await (extract.Ω = [[() => __ΩEnv, "n!"]], extract(context, defaultSecretsTypeDefinition))));
83
82
  context.env = defu({
84
83
  vars,
85
84
  secrets,
@@ -88,18 +87,19 @@ async function extractEnvSchema(context) {
88
87
  parsed: {},
89
88
  injected: []
90
89
  });
91
- await readActiveEnv(context);
92
- const properties = getProperties$1(context.env.vars);
90
+ const properties = getProperties(context.env.vars);
93
91
  context.info({
94
92
  meta: { category: "env" },
95
93
  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"}`
96
94
  });
97
- const aliases = Object.fromEntries(Object.entries(properties).flatMap(__assignType(([key, prop]) => isSetArray(prop.metadata?.alias) ? prop.metadata?.alias?.map(__assignType((alias) => [alias, {
95
+ const aliases = Object.fromEntries(Object.entries(properties).flatMap(__assignType(([key, prop]) => isSetArray(prop.alias) ? prop.alias?.map(__assignType((alias) => [alias, {
98
96
  ...prop,
99
- metadata: {
100
- ...prop.metadata,
101
- alias: [key]
102
- }
97
+ name: alias,
98
+ alias: [...prop.alias?.filter(__assignType((a) => a !== alias, [
99
+ "a",
100
+ "",
101
+ "P\"2!\"/\""
102
+ ])) ?? [], key]
103
103
  }], [
104
104
  "alias",
105
105
  "",
@@ -120,75 +120,26 @@ async function extractEnvSchema(context) {
120
120
  "P\"2!\"2\"\"/#"
121
121
  ]), key);
122
122
  if (properties[unprefixedKey]) {
123
- if (!properties[unprefixedKey].metadata?.isRuntime) {
124
- if (properties[unprefixedKey].optional && context.env.vars.schema.optionalProperties?.[unprefixedKey]) {
125
- context.env.vars.schema.optionalProperties[unprefixedKey].metadata ??= {};
126
- context.env.vars.schema.optionalProperties[unprefixedKey].metadata.default = value;
127
- } else if (context.env.vars.schema.properties?.[unprefixedKey]) {
128
- context.env.vars.schema.properties[unprefixedKey].metadata ??= {};
129
- context.env.vars.schema.properties[unprefixedKey].metadata.default = value;
130
- }
123
+ if (!properties[unprefixedKey]?.runtime) {
124
+ const propertySchema = context.env.vars.schema.properties?.[unprefixedKey];
125
+ if (propertySchema) propertySchema.default = value;
131
126
  }
132
127
  } else if (aliases[unprefixedKey]) {
133
- if (!aliases[unprefixedKey].metadata?.isRuntime) {
134
- const alias = aliases[unprefixedKey].metadata?.alias?.[0] ?? unprefixedKey;
135
- if (aliases[unprefixedKey].optional && context.env.vars.schema.optionalProperties?.[alias]) {
136
- context.env.vars.schema.optionalProperties[alias].metadata ??= {};
137
- context.env.vars.schema.optionalProperties[alias].metadata.default = value;
138
- } else if (context.env.vars.schema.properties?.[alias]) {
139
- context.env.vars.schema.properties[alias].metadata ??= {};
140
- context.env.vars.schema.properties[alias].metadata.default = value;
141
- }
128
+ if (!aliases[unprefixedKey]?.runtime) {
129
+ const alias = aliases[unprefixedKey]?.alias?.[0] ?? unprefixedKey;
130
+ const aliasSchema = context.env.vars.schema.properties?.[alias];
131
+ if (aliasSchema) aliasSchema.default = value;
142
132
  }
143
133
  }
144
134
  }
145
135
  }
146
- extractEnvSchema.__type = [
136
+ extractEnv.__type = [
147
137
  "context",
148
- "extractEnvSchema",
138
+ "extractEnv",
149
139
  "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.",
150
140
  "P\"2!$`/\"?#"
151
141
  ];
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!\"/\"?#"
190
- ];
191
142
 
192
143
  //#endregion
193
- export { extractEnvSchema, getDefaultSecretsTypeDefinition, getDefaultVarsTypeDefinition, readActiveEnv, resolveRuntimeTypeFile, writeActiveEnv };
144
+ export { extractEnv, getDefaultSecretsTypeDefinition, getDefaultVarsTypeDefinition, resolveRuntimeTypeFile };
194
145
  //# 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 { 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,UAA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AA,IAAA,KAAA,OACJ,CAAC,CAAC,IAAE,QAAY,WAAQ,QAAY,IAAC,QAAU,MAAA,IAAA,QAAA,GAAA,MAAA,UAAA,kBAAA,OAAA,GAAA,OAAA,cAAA,GAAA,KAAA,UAAA,EAC7C,UAAO,QAAQ,IAAK,QAAU,OAChC,CAAC,CAAC,IAAI,MAAS,EAAC,OAAI,OAAQ,CAAA;AAC9B;AACA,eAAY,SAAY;CAAA;CAAQ;CAAsB;CAAM;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 { extract } from \"@powerlines/schema/extract\";\nimport {\n getProperties,\n getPropertiesList,\n mergeSchemas\n} 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 { Env, EnvPluginContext } 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 extractEnv<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<Env>(context, context.config.env.vars);\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<Env>(\n vars,\n await extract<Env>(context, defaultVarsTypeDefinition)\n );\n }\n\n const secrets = await extract<Env>(context, context.config.env.secrets);\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<Env>(\n secrets,\n await extract<Env>(context, defaultSecretsTypeDefinition)\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 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.alias)\n ? prop.alias?.map(alias => [\n alias,\n {\n ...prop,\n name: alias,\n alias: [...(prop.alias?.filter(a => a !== alias) ?? []), key]\n }\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]?.runtime) {\n const propertySchema =\n context.env.vars.schema.properties?.[unprefixedKey];\n if (propertySchema) {\n propertySchema.default = value;\n }\n }\n } else if (aliases[unprefixedKey]) {\n if (!aliases[unprefixedKey]?.runtime) {\n const alias = aliases[unprefixedKey]?.alias?.[0] ?? unprefixedKey;\n const aliasSchema = context.env.vars.schema.properties?.[alias];\n if (aliasSchema) {\n aliasSchema.default = value;\n }\n }\n }\n }\n}\n"],"mappings":";;;;;;;;;;AAEA,SAAS,aAAY,IAAK,MAAC;;CAE1B,OAAK;AACN;;;;;;;AA+BA,eAAoB,uBAAkB,SAAA;CACpC,MAAE,WAAY,MAAQ,QAAK,GAAA,QAAe,kCAA8B;CACxE,IAAA,CAAA,UACF,MAAO,IAAM,MAAA,yJAA+B;CAE1C,OAAO;AACT;AACA,uBAAiB,SAAA;CAAA;CAAA;CAAA;CAAA;AAAA;;;;;;;AAOjB,eAAA,6BAAA,SAAA;;EAEE,MAAA,MAAA,uBAAA,OAAA;EACC,MAAK;CACP;AACD;AACA,6BAA6B,SAAA;CAAU;CAAS;CAAqB;CAAA;AAAA;;;;;;AAMrE,eAAgB,gCAA+B,SAAA;CAC7C,OAAO;EACN,MAAA,MAAA,uBAAA,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AA,CAAA,IAAyB,CAAC,GAAA;EAAI;EAAC;EAAA;CAAA,CAAA,CAAA,CAAA;CACvC,KAAE,MAAA,CAAA,KAAA,UAAA,OAAA,QAAA,MAAA,QAAA,SAAA,QAAA,OAAA,GAAA,CAAA,GAAA;EACA,MAAK,gBAAS,QAAgB,OAAC,IAAA,OAAA,OAAA,cAAA,KAAA,WAAA;GAC7B,IAAI,IAAA,QAAA,OAAA,EAAA,EAAA,WAAA,MAAA,GACJ,OAAM,IAAO,QAAM,OAAS,EAAA,EAAA,MAAA,OAAA,MAAA;GAEhC,OAAA;;;;;;;EAEA,IAAM,WAAU,gBACb;OAAA,CAAA,WAAA,gBAAA,SAAA;IACA,MAAS,iBAAe,QAAI,IAAU,KAAA,OAAA,aAAA;IACrC,IAAA,gBACI,eAAC,UAAA;GAEL;SACD,IAAA,QAAY,gBACX;OAAE,CAAA,QAAQ,gBAAmB,SAAG;IAC9B,MAAA,QAAA,QAAA,gBAAmC,QAAA,MAAA;IACnC,MAAC,cAAmB,QAAQ,IAAG,KAAA,OAAA,aAAuB;IACtD,IAAE,aACN,YAAA,UAAA;GAEE;;CAEJ;AACF"}
@@ -1,5 +1,4 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
3
2
  let _stryke_env_types = require("@stryke/env/types");
4
3
  let _stryke_string_format_camel_case = require("@stryke/string-format/camel-case");
5
4
  let _stryke_type_checks_is_string = require("@stryke/type-checks/is-string");
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");
11
10
  let defu = require("defu");
12
11
  defu = require_runtime.__toESM(defu);
13
12
  let powerlines_plugin_utils = require("powerlines/plugin-utils");
14
13
  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);
80
+ await require_helpers_schema.extractEnv(this);
81
81
  }, ["configResolved", "P\"/!"]),
82
82
  prepare: __assignType(async function prepare() {
83
83
  const _self$ = this;
@@ -123,12 +123,12 @@ const plugin = __assignType((options = {}) => {
123
123
  ]);
124
124
 
125
125
  //#endregion
126
+ exports.__ΩEnv = require_types_plugin.__ΩEnv;
126
127
  exports.__ΩEnvInterface = require_types_env.__ΩEnvInterface;
127
128
  exports.__ΩEnvPluginContext = require_types_plugin.__ΩEnvPluginContext;
128
129
  exports.__ΩEnvPluginOptions = require_types_plugin.__ΩEnvPluginOptions;
129
130
  exports.__ΩEnvPluginResolvedConfig = require_types_plugin.__ΩEnvPluginResolvedConfig;
130
131
  exports.__ΩEnvPluginUserConfig = require_types_plugin.__ΩEnvPluginUserConfig;
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, EnvSchema, EnvType } from "./types/plugin.cjs";
1
+ import { Env, EnvPluginContext, EnvPluginOptions, EnvPluginResolvedConfig, EnvPluginUserConfig, 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, EnvSchema, EnvType, SecretsInterface, plugin as default, plugin };
16
+ export { Env, EnvInterface, EnvPluginContext, EnvPluginOptions, EnvPluginResolvedConfig, EnvPluginUserConfig, 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, EnvSchema, EnvType } from "./types/plugin.mjs";
1
+ import { Env, EnvPluginContext, EnvPluginOptions, EnvPluginResolvedConfig, EnvPluginUserConfig, 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, EnvSchema, EnvType, SecretsInterface, plugin as default, plugin };
16
+ export { Env, EnvInterface, EnvPluginContext, EnvPluginOptions, EnvPluginResolvedConfig, EnvPluginUserConfig, 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, __ΩEnvSchema, __ΩEnvType } from "./types/plugin.mjs";
1
+ import { __ΩEnv, __ΩEnvPluginContext, __ΩEnvPluginOptions, __ΩEnvPluginResolvedConfig, __ΩEnvPluginUserConfig, __ΩEnvType } from "./types/plugin.mjs";
2
2
  import { __ΩEnvInterface, __ΩSecretsInterface } from "./types/env.mjs";
3
- import { extractEnvSchema, getDefaultSecretsTypeDefinition, getDefaultVarsTypeDefinition } from "./helpers/schema.mjs";
3
+ import { extractEnv, 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";
9
8
  import defu from "defu";
10
9
  import { getDocsOutputPath } from "powerlines/plugin-utils";
11
10
  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);
75
+ await extractEnv(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, __ΩEnvSchema, __ΩEnvType, __ΩSecretsInterface, plugin as default, plugin };
121
+ export { __ΩEnv, __ΩEnvInterface, __ΩEnvPluginContext, __ΩEnvPluginOptions, __ΩEnvPluginResolvedConfig, __ΩEnvPluginUserConfig, __Ω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);\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,CAAA;IACtB,OAAM,IAAA,SAAc,UAAU,QAAM,OAAA,IAAA,MAAA,EAAA,OAAA,cAAA,KAAA,WAAA;KAClC,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"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 extractEnv,\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 extractEnv(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,CAAA;IACtB,OAAM,IAAA,SAAc,UAAU,QAAM,OAAA,IAAA,MAAA,EAAA,OAAA,cAAA,KAAA,WAAA;KAClC,IAAI,CAAA,IAAA,SAAU,OAAA,QAAc,OAAA,EAAA,CAAA,GAC1B,IAAA,KAAA,OAAA,QAAA,OAAA,EAAA,CAAA;;IAGJ,GAAE;KAAE;KAAG;KAAW;KAAM;IAAA,CAAA,GAAA,CAAA,CAAA,CAAA;IACxB,OAAI;GACN;GACA,gBAAO,aAAA,eAAA,iBAAA;;IAEL,MAAI,WAAW,IAAM;GACvB,GAAG,CAAC,kBAAY,OAAA,CAAA;GAChB,SAAO,aAAA,eAAA,UAAA;IACL,MAAE,SAAA;;IAEF,OAAO,OAAO,MAAI,gBAAS,YAAA,EACzB,IAAE,gBAAkB;KAClB,OAAO,OAAG,OAAA,IAAA;IACZ,EACF,CAAC,CAAC;;GAEJ,MAAI,aAAW,eAAgB,OAAA;IAC7B,KAAK,MAAM,8DAA6B,UAAA,kBAAA,KAAA,OAAA,IAAA,GAAA,QAAA,EAAA,EAAA;IACxC,OAAI,OAAM,MAAA,gBAAA,aAAA,EACR,aAAQ,EACV,CAAC,CAAC;GACJ,GAAG,CAAC,QAAQ,OAAK,CAAA;GACjB,UAAU,aAAS,eAAgB,WAAA;IACjC,KAAK,MAAC,+CAAA;;GAER,GAAG,CAAC,YAAW,OAAG,CAAA;EACpB;EAAG;GACD,MAAM;GACN,gBAAS,aAAY,SAAA,iBAAA;IACnB,OAAM,EACJ,QAAM,KAAK,QAAO,UAAW,CAAA,GAAM,EACjC,YAAO,EACL,KAAA,IAAO,IAAA,EACV,KAEH;GACF,GAAG,CAAC,kBAAiB,OAAI,CAAA;EAC3B;EAAG;GACD,MAAM;GACN,MAAM,EACJ,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"}
@@ -2,11 +2,11 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
  const require_types_plugin = require('./plugin.cjs');
3
3
  const require_types_env = require('./env.cjs');
4
4
 
5
+ exports.__ΩEnv = require_types_plugin.__ΩEnv;
5
6
  exports.__ΩEnvInterface = require_types_env.__ΩEnvInterface;
6
7
  exports.__ΩEnvPluginContext = require_types_plugin.__ΩEnvPluginContext;
7
8
  exports.__ΩEnvPluginOptions = require_types_plugin.__ΩEnvPluginOptions;
8
9
  exports.__ΩEnvPluginResolvedConfig = require_types_plugin.__ΩEnvPluginResolvedConfig;
9
10
  exports.__ΩEnvPluginUserConfig = require_types_plugin.__ΩEnvPluginUserConfig;
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, EnvSchema, EnvType } from "./plugin.cjs";
1
+ import { Env, EnvPluginContext, EnvPluginOptions, EnvPluginResolvedConfig, EnvPluginUserConfig, EnvType } from "./plugin.cjs";
2
2
  import { EnvInterface, SecretsInterface } from "./env.cjs";
3
- export { EnvInterface, EnvPluginContext, EnvPluginOptions, EnvPluginResolvedConfig, EnvPluginUserConfig, EnvSchema, EnvType, SecretsInterface };
3
+ export { Env, EnvInterface, EnvPluginContext, EnvPluginOptions, EnvPluginResolvedConfig, EnvPluginUserConfig, EnvType, SecretsInterface };
@@ -1,3 +1,3 @@
1
- import { EnvPluginContext, EnvPluginOptions, EnvPluginResolvedConfig, EnvPluginUserConfig, EnvSchema, EnvType } from "./plugin.mjs";
1
+ import { Env, EnvPluginContext, EnvPluginOptions, EnvPluginResolvedConfig, EnvPluginUserConfig, EnvType } from "./plugin.mjs";
2
2
  import { EnvInterface, SecretsInterface } from "./env.mjs";
3
- export { EnvInterface, EnvPluginContext, EnvPluginOptions, EnvPluginResolvedConfig, EnvPluginUserConfig, EnvSchema, EnvType, SecretsInterface };
3
+ export { Env, EnvInterface, EnvPluginContext, EnvPluginOptions, EnvPluginResolvedConfig, EnvPluginUserConfig, EnvType, SecretsInterface };
@@ -1,4 +1,4 @@
1
- import { __ΩEnvPluginContext, __ΩEnvPluginOptions, __ΩEnvPluginResolvedConfig, __ΩEnvPluginUserConfig, __ΩEnvSchema, __ΩEnvType } from "./plugin.mjs";
1
+ import { __ΩEnv, __ΩEnvPluginContext, __ΩEnvPluginOptions, __ΩEnvPluginResolvedConfig, __ΩEnvPluginUserConfig, __ΩEnvType } from "./plugin.mjs";
2
2
  import { __ΩEnvInterface, __ΩSecretsInterface } from "./env.mjs";
3
3
 
4
- export { __ΩEnvInterface, __ΩEnvPluginContext, __ΩEnvPluginOptions, __ΩEnvPluginResolvedConfig, __ΩEnvPluginUserConfig, __ΩEnvSchema, __ΩEnvType, __ΩSecretsInterface };
4
+ export { __ΩEnv, __ΩEnvInterface, __ΩEnvPluginContext, __ΩEnvPluginOptions, __ΩEnvPluginResolvedConfig, __ΩEnvPluginUserConfig, __ΩEnvType, __ΩSecretsInterface };
@@ -20,10 +20,11 @@ const __ΩPick = [
20
20
  "Pick",
21
21
  "l+e#!e\"!fRb!b\"Pde\"\"N#!w#y"
22
22
  ];
23
- const __ΩPartial = [
23
+ const __ΩRecord = [
24
+ "K",
24
25
  "T",
25
- "Partial",
26
- "l+e#!e\"!fRb!Pde\"!gN#\"w\"y"
26
+ "Record",
27
+ "l'e#\"Rb!b\"Pde\"!N#!w#y"
27
28
  ];
28
29
  const __ΩExclude = [
29
30
  "T",
@@ -81,22 +82,19 @@ const __ΩEnvPluginResolvedConfig = [
81
82
  "EnvPluginResolvedConfig",
82
83
  "P!PP!.#o\"#o!\"!P)4$?%)4&?'&F4(?)MK4*MKw+y"
83
84
  ];
84
- const __ΩEnvSchema = [
85
- () => __ΩPartial,
86
- "TMetadata",
85
+ const __ΩEnv = [
86
+ () => __ΩRecord,
87
+ "T",
87
88
  "active",
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).",
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"
89
+ "An indicator specifying whether or not this environment variable or secret is active and should be injected during the build process.",
90
+ "Env",
91
+ "&\"o!#c\"P!P&F4#?$MKw%y"
92
92
  ];
93
93
  const __ΩEnvPluginContext = [
94
94
  () => __ΩEnvPluginResolvedConfig,
95
95
  "TResolvedConfig",
96
- () => __ΩEnvSchema,
97
96
  "vars",
98
97
  "The type definition for the expected env variable parameters",
99
- () => __ΩEnvSchema,
100
98
  "secrets",
101
99
  "The type definition for the expected env secret parameters",
102
100
  "parsed",
@@ -105,13 +103,13 @@ const __ΩEnvPluginContext = [
105
103
  "The injected environment variables and secrets reflection",
106
104
  "env",
107
105
  "EnvPluginContext",
108
- "n!c\"P!Pn#4$?%n&4'?(!4)?*&F4+?,M4-Mw.y"
106
+ "n!c\"P!P!4#?$!4%?&!4'?(&F4)?*M4+Mw,y"
109
107
  ];
110
108
 
111
109
  //#endregion
110
+ exports.__ΩEnv = __ΩEnv;
112
111
  exports.__ΩEnvPluginContext = __ΩEnvPluginContext;
113
112
  exports.__ΩEnvPluginOptions = __ΩEnvPluginOptions;
114
113
  exports.__ΩEnvPluginResolvedConfig = __ΩEnvPluginResolvedConfig;
115
114
  exports.__ΩEnvPluginUserConfig = __ΩEnvPluginUserConfig;
116
- exports.__ΩEnvSchema = __ΩEnvSchema;
117
115
  exports.__ΩEnvType = __ΩEnvType;
@@ -1,7 +1,7 @@
1
1
  import { Children } from "@alloy-js/core";
2
2
  import { AutoMDPluginOptions } from "@powerlines/plugin-automd/types/plugin";
3
3
  import { BabelPluginContext, BabelPluginOptions, BabelPluginResolvedConfig, BabelPluginUserConfig } from "@powerlines/plugin-babel/types";
4
- import { ObjectSchema, SchemaInput, SchemaMetadata } from "@powerlines/schema";
4
+ import { JsonSchema, Schema, SchemaInput } from "@powerlines/schema";
5
5
  import { DotenvParseOutput } from "@stryke/env/types";
6
6
  import { RequiredKeys } from "@stryke/types";
7
7
  import { DotenvConfiguration } from "@stryke/types/configuration";
@@ -87,14 +87,20 @@ type EnvPluginResolvedConfig = BabelPluginResolvedConfig & {
87
87
  };
88
88
  };
89
89
  /**
90
- * 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
+ * The schema for environment variables and secrets used by the plugin.
91
+ *
92
+ * @remarks
93
+ * This schema is the result of parsing the type definitions provided in the {@link EnvPluginOptions.vars} and {@link EnvPluginOptions.secrets} options, and is used to validate the loaded environment variables and secrets, as well as to determine which variables should be injected into the source code when the {@link EnvPluginOptions.inject} option is enabled.
91
94
  */
92
- interface EnvSchema<TMetadata extends Partial<SchemaMetadata> = Partial<SchemaMetadata>> extends ObjectSchema<TMetadata> {
95
+ type Env<T extends Record<string, any> = Record<string, any>> = JsonSchema<T> & {
93
96
  /**
94
- * 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).
97
+ * An indicator specifying whether or not this environment variable or secret is active and should be injected during the build process.
98
+ *
99
+ * @remarks
100
+ * This value is determined during the build process based on the loaded environment variables and secrets, and is used to filter which variables are actually injected into the source code when the {@link EnvPluginOptions.inject} option is enabled.
95
101
  */
96
102
  active: string[];
97
- }
103
+ };
98
104
  interface EnvPluginContext<TResolvedConfig extends EnvPluginResolvedConfig = EnvPluginResolvedConfig> extends BabelPluginContext<TResolvedConfig> {
99
105
  env: {
100
106
  /**
@@ -103,14 +109,14 @@ interface EnvPluginContext<TResolvedConfig extends EnvPluginResolvedConfig = Env
103
109
  * @remarks
104
110
  * This value is parsed from the {@link EnvPluginOptions.vars} option.
105
111
  */
106
- vars: EnvSchema;
112
+ vars: Schema<Env>;
107
113
  /**
108
114
  * The type definition for the expected env secret parameters
109
115
  *
110
116
  * @remarks
111
117
  * This value is parsed from the {@link EnvPluginOptions.secrets} option.
112
118
  */
113
- secrets: EnvSchema;
119
+ secrets: Schema<Env>;
114
120
  /**
115
121
  * The parsed .env configuration object
116
122
  *
@@ -128,5 +134,5 @@ interface EnvPluginContext<TResolvedConfig extends EnvPluginResolvedConfig = Env
128
134
  };
129
135
  }
130
136
  //#endregion
131
- export { EnvPluginContext, EnvPluginOptions, EnvPluginResolvedConfig, EnvPluginUserConfig, EnvSchema, EnvType };
137
+ export { Env, EnvPluginContext, EnvPluginOptions, EnvPluginResolvedConfig, EnvPluginUserConfig, EnvType };
132
138
  //# sourceMappingURL=plugin.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.d.cts","names":[],"sources":["../../src/types/plugin.ts"],"mappings":";;;;;;;;;KAmCY,OAAA;AAAA,KAEA,gBAAA,GAAmB,IAAA,CAAK,mBAAA;EAFxB;;;EAMV,IAAA,GAAO,WAAA;EANU;AAEnB;;EASE,OAAA,GAAU,WAAA;EATwB;;;;;;EAiBlC,MAAA;EAsC4B;;;;;EA/B5B,MAAA;EAfA;;;;;EAsBA,QAAA;EAQgB;;;;;;EAAhB,aAAA,GAAgB,QAAA;EAmBN;;;;;;EAXV,KAAA,GAAQ,kBAAA;EAYa;AAAA;AAGvB;;;;EAPE,MAAA,GAAS,mBAAA;AAAA;AAAA,KAGC,mBAAA,GAAsB,qBAAA;EAChC,GAAA,EAAK,gBAAgB;AAAA;AAAA,KAGX,uBAAA,GAA0B,yBAAA;EACpC,GAAA,EAAK,QAAA,CAAS,IAAA,CAAK,mBAAA,wBACjB,YAAA,CAAa,gBAAA;IAFqB;;;;;;IAShC,MAAA;IAAA;;;;AAgBM;AAOZ;IAfM,QAAA;IAeoB;;;;;;IAPpB,MAAA;EAAA;AAAA;;;;UAOW,SAAA,mBACG,OAAA,CAAQ,cAAA,IAAkB,OAAA,CAAQ,cAAA,WAC5C,YAAA,CAAa,SAAA;EAD+B;;;EAKp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