@powerlines/plugin-env 0.16.253 → 0.16.255
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.
- package/dist/babel/plugin.cjs +10 -10
- package/dist/babel/plugin.d.cts.map +1 -1
- package/dist/babel/plugin.d.mts.map +1 -1
- package/dist/babel/plugin.mjs +11 -11
- package/dist/babel/plugin.mjs.map +1 -1
- package/dist/components/docs.cjs +6 -23
- package/dist/components/docs.d.cts.map +1 -1
- package/dist/components/docs.d.mts.map +1 -1
- package/dist/components/docs.mjs +9 -26
- package/dist/components/docs.mjs.map +1 -1
- package/dist/components/env-builtin.cjs +6 -6
- package/dist/components/env-builtin.mjs +6 -6
- package/dist/components/env-builtin.mjs.map +1 -1
- package/dist/helpers/index.cjs +4 -1
- package/dist/helpers/index.d.cts +2 -2
- package/dist/helpers/index.d.mts +2 -2
- package/dist/helpers/index.mjs +2 -2
- package/dist/helpers/load.cjs +1 -1
- package/dist/helpers/load.mjs +1 -1
- package/dist/helpers/load.mjs.map +1 -1
- package/dist/helpers/schema.cjs +99 -10
- package/dist/helpers/schema.d.cts +16 -1
- package/dist/helpers/schema.d.cts.map +1 -1
- package/dist/helpers/schema.d.mts +16 -1
- package/dist/helpers/schema.d.mts.map +1 -1
- package/dist/helpers/schema.mjs +98 -12
- package/dist/helpers/schema.mjs.map +1 -1
- package/dist/index.cjs +6 -7
- package/dist/index.d.cts +2 -2
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +8 -9
- package/dist/index.mjs.map +1 -1
- package/dist/types/index.cjs +1 -1
- package/dist/types/index.d.cts +2 -2
- package/dist/types/index.d.mts +2 -2
- package/dist/types/index.mjs +2 -2
- package/dist/types/plugin.cjs +9 -7
- package/dist/types/plugin.d.cts +11 -11
- package/dist/types/plugin.d.cts.map +1 -1
- package/dist/types/plugin.d.mts +11 -11
- package/dist/types/plugin.d.mts.map +1 -1
- package/dist/types/plugin.mjs +9 -7
- package/dist/types/plugin.mjs.map +1 -1
- package/package.json +10 -10
package/dist/helpers/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { env } from "./automd-generator.cjs";
|
|
2
2
|
import { loadEnv, loadEnvFromContext } from "./load.cjs";
|
|
3
|
-
import { extractEnv, getDefaultSecretsTypeDefinition, getDefaultVarsTypeDefinition, resolveRuntimeTypeFile } from "./schema.cjs";
|
|
3
|
+
import { extractEnv, getCacheDirectory, getCacheFilePath, getDefaultSecretsTypeDefinition, getDefaultVarsTypeDefinition, resolveRuntimeTypeFile, writeEnv } from "./schema.cjs";
|
|
4
4
|
import { formatEnvField, removeEnvPrefix } from "./source-file-env.cjs";
|
|
5
|
-
export { env, extractEnv, formatEnvField, getDefaultSecretsTypeDefinition, getDefaultVarsTypeDefinition, loadEnv, loadEnvFromContext, removeEnvPrefix, resolveRuntimeTypeFile };
|
|
5
|
+
export { env, extractEnv, formatEnvField, getCacheDirectory, getCacheFilePath, getDefaultSecretsTypeDefinition, getDefaultVarsTypeDefinition, loadEnv, loadEnvFromContext, removeEnvPrefix, resolveRuntimeTypeFile, writeEnv };
|
package/dist/helpers/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { env } from "./automd-generator.mjs";
|
|
2
2
|
import { loadEnv, loadEnvFromContext } from "./load.mjs";
|
|
3
|
-
import { extractEnv, getDefaultSecretsTypeDefinition, getDefaultVarsTypeDefinition, resolveRuntimeTypeFile } from "./schema.mjs";
|
|
3
|
+
import { extractEnv, getCacheDirectory, getCacheFilePath, getDefaultSecretsTypeDefinition, getDefaultVarsTypeDefinition, resolveRuntimeTypeFile, writeEnv } from "./schema.mjs";
|
|
4
4
|
import { formatEnvField, removeEnvPrefix } from "./source-file-env.mjs";
|
|
5
|
-
export { env, extractEnv, formatEnvField, getDefaultSecretsTypeDefinition, getDefaultVarsTypeDefinition, loadEnv, loadEnvFromContext, removeEnvPrefix, resolveRuntimeTypeFile };
|
|
5
|
+
export { env, extractEnv, formatEnvField, getCacheDirectory, getCacheFilePath, getDefaultSecretsTypeDefinition, getDefaultVarsTypeDefinition, loadEnv, loadEnvFromContext, removeEnvPrefix, resolveRuntimeTypeFile, writeEnv };
|
package/dist/helpers/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { formatEnvField, removeEnvPrefix } from "./source-file-env.mjs";
|
|
2
2
|
import { loadEnv, loadEnvFromContext } from "./load.mjs";
|
|
3
|
-
import { extractEnv, getDefaultSecretsTypeDefinition, getDefaultVarsTypeDefinition, resolveRuntimeTypeFile } from "./schema.mjs";
|
|
3
|
+
import { extractEnv, getCacheDirectory, getCacheFilePath, getDefaultSecretsTypeDefinition, getDefaultVarsTypeDefinition, resolveRuntimeTypeFile, writeEnv } from "./schema.mjs";
|
|
4
4
|
import { env } from "./automd-generator.mjs";
|
|
5
5
|
|
|
6
|
-
export { env, extractEnv, formatEnvField, getDefaultSecretsTypeDefinition, getDefaultVarsTypeDefinition, loadEnv, loadEnvFromContext, removeEnvPrefix, resolveRuntimeTypeFile };
|
|
6
|
+
export { env, extractEnv, formatEnvField, getCacheDirectory, getCacheFilePath, getDefaultSecretsTypeDefinition, getDefaultVarsTypeDefinition, loadEnv, loadEnvFromContext, removeEnvPrefix, resolveRuntimeTypeFile, writeEnv };
|
package/dist/helpers/load.cjs
CHANGED
|
@@ -100,7 +100,7 @@ function loadEnvFromContext(context, parsed, workspaceConfig) {
|
|
|
100
100
|
STACKTRACE: context.config.mode !== "production",
|
|
101
101
|
RUNTIME: context.config.environment.runtime,
|
|
102
102
|
ENVIRONMENT: !context.config.environment.name || context.config.environment.name === powerlines_constants.DEFAULT_ENVIRONMENT ? context.config.mode : context.config.environment.name
|
|
103
|
-
}, (0, _stryke_type_checks_is_set_object.isSetObject)(context.env.
|
|
103
|
+
}, (0, _stryke_type_checks_is_set_object.isSetObject)(context.env.config) ? Object.entries((0, _powerlines_schema_helpers.getProperties)(context.env.config)).reduce(__assignType((ret, [name, prop]) => {
|
|
104
104
|
ret[name] = parsed[name] ?? prop?.default;
|
|
105
105
|
return ret;
|
|
106
106
|
}, [
|
package/dist/helpers/load.mjs
CHANGED
|
@@ -97,7 +97,7 @@ function loadEnvFromContext(context, parsed, workspaceConfig) {
|
|
|
97
97
|
STACKTRACE: context.config.mode !== "production",
|
|
98
98
|
RUNTIME: context.config.environment.runtime,
|
|
99
99
|
ENVIRONMENT: !context.config.environment.name || context.config.environment.name === DEFAULT_ENVIRONMENT ? context.config.mode : context.config.environment.name
|
|
100
|
-
}, isSetObject(context.env.
|
|
100
|
+
}, isSetObject(context.env.config) ? Object.entries(getProperties(context.env.config)).reduce(__assignType((ret, [name, prop]) => {
|
|
101
101
|
ret[name] = parsed[name] ?? prop?.default;
|
|
102
102
|
return ret;
|
|
103
103
|
}, [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"load.mjs","names":[],"sources":["../../src/helpers/load.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 { getProperties } from \"@powerlines/schema/helpers\";\nimport { tryGetWorkspaceConfig } from \"@storm-software/config-tools/get-config\";\nimport {\n isDevelopmentMode,\n isTestMode,\n toMode\n} from \"@stryke/env/environment-checks\";\nimport {\n loadEnv as loadEnvBase,\n loadEnvFile as loadEnvFileBase\n} from \"@stryke/env/load-env\";\nimport type { DotenvParseOutput } from \"@stryke/env/types\";\nimport { joinPaths } from \"@stryke/path/join-paths\";\nimport { kebabCase } from \"@stryke/string-format/kebab-case\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport type { PackageJson } from \"@stryke/types/package-json\";\nimport { loadConfig } from \"c12\";\nimport defu from \"defu\";\nimport { WorkspaceConfig } from \"powerlines\";\nimport { DEFAULT_ENVIRONMENT } from \"powerlines/constants\";\nimport { EnvPluginContext, EnvPluginOptions } from \"../types/plugin\";\nimport { removeEnvPrefix } from \"./source-file-env\";\n\nasync function loadEnvFiles<TEnv extends DotenvParseOutput = DotenvParseOutput>(\n options: EnvPluginOptions,\n mode: string,\n cwd: string\n): Promise<TEnv> {\n let env = await loadEnvBase(cwd, mode);\n if (options.additionalFiles && options.additionalFiles?.length > 0) {\n const additionalEnvFiles = await Promise.all(\n options.additionalFiles.map(async additionalEnvFile =>\n loadEnvFileBase(additionalEnvFile, cwd)\n )\n );\n\n for (const additionalEnvFile of additionalEnvFiles) {\n env = defu(additionalEnvFile, env);\n }\n }\n\n return removeEnvPrefix(env) as TEnv;\n}\n\nasync function loadEnvDirectory<\n TEnv extends DotenvParseOutput = DotenvParseOutput\n>(\n context: EnvPluginContext,\n options: EnvPluginOptions,\n directory: string,\n mode: string,\n cacheDir: string,\n packageJson: PackageJson,\n workspaceConfig?: WorkspaceConfig\n): Promise<TEnv> {\n const [envResult, c12Result] = await Promise.all([\n loadEnvFiles<TEnv>(options, mode, directory),\n loadConfig({\n cwd: directory,\n name: context.config.framework?.name || \"powerlines\",\n envName: mode,\n defaults: {\n NAME:\n workspaceConfig?.namespace && packageJson.name\n ? packageJson.name?.replace(`@${workspaceConfig.namespace}/`, \"\")\n : context.config.name,\n MODE: mode,\n ORG: context.config.organization || workspaceConfig?.organization\n },\n globalRc: true,\n packageJson: true,\n dotenv: true,\n jitiOptions: {\n fsCache: joinPaths(cacheDir, \"jiti\"),\n moduleCache: true\n }\n })\n ]);\n\n return defu(envResult as any, c12Result.config, workspaceConfig) as TEnv;\n}\n\n/**\n * Retrieves various dotenv configuration parameters from the context.\n *\n * @param context - The context to retrieve the dotenv configuration from.\n * @param parsed - The parsed dotenv configuration.\n * @returns An object containing the dotenv configuration.\n */\nexport function loadEnvFromContext(\n context: EnvPluginContext,\n parsed: DotenvParseOutput,\n workspaceConfig?: WorkspaceConfig\n) {\n return defu(\n {\n APP_NAME: kebabCase(context.config.name),\n APP_VERSION: context.packageJson.version,\n BUILD_ID: context.meta.buildId,\n BUILD_TIMESTAMP: new Date(context.meta.timestamp).toISOString(),\n BUILD_CHECKSUM: context.meta.checksum,\n RELEASE_ID: context.meta.releaseId,\n RELEASE_TAG: `${kebabCase(context.config.name)}@${context.packageJson.version}`,\n DEFAULT_LOCALE: workspaceConfig?.locale,\n DEFAULT_TIMEZONE: workspaceConfig?.timezone,\n LOG_LEVEL:\n context.config.logLevel.general === \"trace\"\n ? \"debug\"\n : context.config.logLevel.general,\n ERROR_URL: workspaceConfig?.error?.url,\n ORGANIZATION:\n context.config.organization ||\n (isSetObject(workspaceConfig?.organization)\n ? workspaceConfig.organization.name\n : workspaceConfig?.organization),\n PLATFORM: context.config.platform,\n MODE: toMode(context.config.mode),\n TEST: isTestMode(context.config.mode),\n DEBUG: isDevelopmentMode(context.config.mode),\n STACKTRACE: context.config.mode !== \"production\",\n RUNTIME: context.config.environment.runtime,\n ENVIRONMENT:\n !context.config.environment.name ||\n context.config.environment.name === DEFAULT_ENVIRONMENT\n ? context.config.mode\n : context.config.environment.name\n },\n isSetObject(context.env.
|
|
1
|
+
{"version":3,"file":"load.mjs","names":[],"sources":["../../src/helpers/load.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 { getProperties } from \"@powerlines/schema/helpers\";\nimport { tryGetWorkspaceConfig } from \"@storm-software/config-tools/get-config\";\nimport {\n isDevelopmentMode,\n isTestMode,\n toMode\n} from \"@stryke/env/environment-checks\";\nimport {\n loadEnv as loadEnvBase,\n loadEnvFile as loadEnvFileBase\n} from \"@stryke/env/load-env\";\nimport type { DotenvParseOutput } from \"@stryke/env/types\";\nimport { joinPaths } from \"@stryke/path/join-paths\";\nimport { kebabCase } from \"@stryke/string-format/kebab-case\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport type { PackageJson } from \"@stryke/types/package-json\";\nimport { loadConfig } from \"c12\";\nimport defu from \"defu\";\nimport { WorkspaceConfig } from \"powerlines\";\nimport { DEFAULT_ENVIRONMENT } from \"powerlines/constants\";\nimport { EnvPluginContext, EnvPluginOptions } from \"../types/plugin\";\nimport { removeEnvPrefix } from \"./source-file-env\";\n\nasync function loadEnvFiles<TEnv extends DotenvParseOutput = DotenvParseOutput>(\n options: EnvPluginOptions,\n mode: string,\n cwd: string\n): Promise<TEnv> {\n let env = await loadEnvBase(cwd, mode);\n if (options.additionalFiles && options.additionalFiles?.length > 0) {\n const additionalEnvFiles = await Promise.all(\n options.additionalFiles.map(async additionalEnvFile =>\n loadEnvFileBase(additionalEnvFile, cwd)\n )\n );\n\n for (const additionalEnvFile of additionalEnvFiles) {\n env = defu(additionalEnvFile, env);\n }\n }\n\n return removeEnvPrefix(env) as TEnv;\n}\n\nasync function loadEnvDirectory<\n TEnv extends DotenvParseOutput = DotenvParseOutput\n>(\n context: EnvPluginContext,\n options: EnvPluginOptions,\n directory: string,\n mode: string,\n cacheDir: string,\n packageJson: PackageJson,\n workspaceConfig?: WorkspaceConfig\n): Promise<TEnv> {\n const [envResult, c12Result] = await Promise.all([\n loadEnvFiles<TEnv>(options, mode, directory),\n loadConfig({\n cwd: directory,\n name: context.config.framework?.name || \"powerlines\",\n envName: mode,\n defaults: {\n NAME:\n workspaceConfig?.namespace && packageJson.name\n ? packageJson.name?.replace(`@${workspaceConfig.namespace}/`, \"\")\n : context.config.name,\n MODE: mode,\n ORG: context.config.organization || workspaceConfig?.organization\n },\n globalRc: true,\n packageJson: true,\n dotenv: true,\n jitiOptions: {\n fsCache: joinPaths(cacheDir, \"jiti\"),\n moduleCache: true\n }\n })\n ]);\n\n return defu(envResult as any, c12Result.config, workspaceConfig) as TEnv;\n}\n\n/**\n * Retrieves various dotenv configuration parameters from the context.\n *\n * @param context - The context to retrieve the dotenv configuration from.\n * @param parsed - The parsed dotenv configuration.\n * @returns An object containing the dotenv configuration.\n */\nexport function loadEnvFromContext(\n context: EnvPluginContext,\n parsed: DotenvParseOutput,\n workspaceConfig?: WorkspaceConfig\n) {\n return defu(\n {\n APP_NAME: kebabCase(context.config.name),\n APP_VERSION: context.packageJson.version,\n BUILD_ID: context.meta.buildId,\n BUILD_TIMESTAMP: new Date(context.meta.timestamp).toISOString(),\n BUILD_CHECKSUM: context.meta.checksum,\n RELEASE_ID: context.meta.releaseId,\n RELEASE_TAG: `${kebabCase(context.config.name)}@${context.packageJson.version}`,\n DEFAULT_LOCALE: workspaceConfig?.locale,\n DEFAULT_TIMEZONE: workspaceConfig?.timezone,\n LOG_LEVEL:\n context.config.logLevel.general === \"trace\"\n ? \"debug\"\n : context.config.logLevel.general,\n ERROR_URL: workspaceConfig?.error?.url,\n ORGANIZATION:\n context.config.organization ||\n (isSetObject(workspaceConfig?.organization)\n ? workspaceConfig.organization.name\n : workspaceConfig?.organization),\n PLATFORM: context.config.platform,\n MODE: toMode(context.config.mode),\n TEST: isTestMode(context.config.mode),\n DEBUG: isDevelopmentMode(context.config.mode),\n STACKTRACE: context.config.mode !== \"production\",\n RUNTIME: context.config.environment.runtime,\n ENVIRONMENT:\n !context.config.environment.name ||\n context.config.environment.name === DEFAULT_ENVIRONMENT\n ? context.config.mode\n : context.config.environment.name\n },\n isSetObject(context.env.config)\n ? Object.entries(getProperties(context.env.config)).reduce(\n (ret, [name, prop]) => {\n ret[name] = parsed[name] ?? prop?.default;\n return ret;\n },\n {} as Record<string, any>\n )\n : {}\n );\n}\n\nexport async function loadEnv<\n TEnv extends DotenvParseOutput = DotenvParseOutput\n>(context: EnvPluginContext, options: EnvPluginOptions): Promise<TEnv> {\n const workspaceConfig = await tryGetWorkspaceConfig();\n\n const [project, workspace, config] = await Promise.all([\n loadEnvDirectory<TEnv>(\n context,\n options,\n context.config.root,\n context.config.mode,\n context.cachePath,\n context.packageJson,\n workspaceConfig\n ),\n loadEnvDirectory<TEnv>(\n context,\n options,\n context.config.cwd,\n context.config.mode,\n context.cachePath,\n context.packageJson,\n workspaceConfig\n ),\n loadEnvDirectory<TEnv>(\n context,\n options,\n context.envPaths.config,\n context.config.mode,\n context.cachePath,\n context.packageJson,\n workspaceConfig\n )\n ]);\n\n return defu(\n loadEnvFromContext(context, process.env, workspaceConfig),\n project,\n workspace,\n config\n ) as TEnv;\n}\n"],"mappings":";;;;;;;;;;;;;;AAIA,SAAM,aAAS,IAAW,MAAM;CAC/B,GAAG,SAAU;CACb,OAAQ;AACT;AA6BA,eAAS,aAAkB,SAAM,MAAU,KAAC;CAC5C,IAAM,MAAG,MAAA,UAAqB,KAAK,IAAE;CACrC,IAAM,QAAG,mBAAkB,QAAA,iBAA4B,SAAY,GAAC;EACpE,MAAS,qBAAsB,MAAI,QAAO,IAAK,QAAI,gBAAA,IAAA,aAAA,OAAA,sBAAA,YAAA,mBAAA,GAAA,GAAA;GAAA;GAAA;GAAA;EAAA,CAAA,CAAA,CAAA;sDAE7C,MAAA,KAAS,mBAAkB,GAAA;CAE/B;CACA,OAAK,gBAAA,GAAA;AACP;AACA,aAAY,SAAM;OAAW;CAAW;CAAA;CAAA;CAAA;CAAA;AAAA;AACxC,eAAc,iBAAkB,SAAS,SAAA,WAAiB,MAAS,UAAG,aAAA,iBAAA;CACpE,MAAE,CAAK,WAAC,aAAqB,MAAM,QAAQ,IAAG,EAAA,aAAA,IAAA,CAAA,CAAA,GAAA,CAAA,GAAA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AAM,OAAS,SAAS,MAAA;EAChC,OAAA;;;;;;;AAEA;AACA,mBAAa,SAAe;OAAA;CAAyB;CAAS;CAAO;CAAA;CAAA;CAAA;AAAA;AACrE,eAAC,QAAA,SAAA,SAAA;CACC,MAAE,kBAAoB,MAAQ,sBAAsB;CACpD,MAAE,CAAK,SAAS,WAAW,UAAQ,MAAA,QAAa,IAAA;GAAA,iBAAA,IAAA,CAAA,CAAA,GAAA,CAAA,GAAA,iBAAA,SAAA,SAAA,QAAA,OAAA,MAAA,QAAA,OAAA,MAAA,QAAA,WAAA,QAAA,aAAA,eAAA;GAAA,iBAAA,IAAA,CAAA,CAAA,GAAA,CAAA,GAAA,iBAAA,SAAA,SAAA,QAAA,OAAA,KAAA,QAAA,OAAA,MAAA,QAAA,WAAA,QAAA,aAAA,eAAA;GAAA,iBAAA,IAAA,CAAA,CAAA,GAAA,CAAA,GAAA,iBAAA,SAAA,SAAA,QAAA,SAAA,QAAA,QAAA,OAAA,MAAA,QAAA,WAAA,QAAA,aAAA,eAAA;CAAA,CAAA;CAChD,OAAE,KAAU,mBAAmB,SAAI,QAAO,KAAA,eAAa,GAAA,SAAA,WAAA,MAAA;AACzD;AACA,QAAO,SAAS;OAAA;CAAkB;OAAA;CAAA;CAAA;CAAA;AAAA"}
|
package/dist/helpers/schema.cjs
CHANGED
|
@@ -3,14 +3,23 @@ const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
|
3
3
|
const require_types_plugin = require('../types/plugin.cjs');
|
|
4
4
|
const require_helpers_load = require('./load.cjs');
|
|
5
5
|
let _stryke_type_checks_is_string = require("@stryke/type-checks/is-string");
|
|
6
|
+
let _powerlines_schema = require("@powerlines/schema");
|
|
6
7
|
let _powerlines_schema_extract = require("@powerlines/schema/extract");
|
|
7
8
|
let _powerlines_schema_helpers = require("@powerlines/schema/helpers");
|
|
9
|
+
let _stryke_helpers_omit = require("@stryke/helpers/omit");
|
|
10
|
+
let _stryke_path_join = require("@stryke/path/join");
|
|
8
11
|
let _stryke_type_checks_is_set_array = require("@stryke/type-checks/is-set-array");
|
|
9
12
|
let _stryke_type_checks_is_set_object = require("@stryke/type-checks/is-set-object");
|
|
10
13
|
let defu = require("defu");
|
|
11
14
|
defu = require_runtime.__toESM(defu, 1);
|
|
12
15
|
|
|
13
16
|
//#region src/helpers/schema.ts
|
|
17
|
+
const __ΩRecord = [
|
|
18
|
+
"K",
|
|
19
|
+
"T",
|
|
20
|
+
"Record",
|
|
21
|
+
"l'e#\"Rb!b\"Pde\"!N#!w#y"
|
|
22
|
+
];
|
|
14
23
|
function __assignType(fn, args) {
|
|
15
24
|
fn.__type = args;
|
|
16
25
|
return fn;
|
|
@@ -67,6 +76,60 @@ getDefaultSecretsTypeDefinition.__type = [
|
|
|
67
76
|
"P\"2!!`/\""
|
|
68
77
|
];
|
|
69
78
|
/**
|
|
79
|
+
* A helper function to get the cache directory path for storing schemas. This function takes a context object as input and returns the path to the cache directory where schemas are stored. The cache directory is constructed by joining the `cachePath` property from the context with a subdirectory named "schemas". This function is useful for centralizing the logic for determining where schema files should be cached, ensuring that all schema-related file operations use a consistent location for storing and retrieving cached schemas.
|
|
80
|
+
*
|
|
81
|
+
* @param context - The context object providing access to the cache path.
|
|
82
|
+
* @returns The path to the cache directory for storing schemas, constructed by joining the context's `cachePath` with the "schemas" subdirectory.
|
|
83
|
+
*/
|
|
84
|
+
function getCacheDirectory(context) {
|
|
85
|
+
return (0, _stryke_path_join.joinPaths)(context.cachePath, "env");
|
|
86
|
+
}
|
|
87
|
+
getCacheDirectory.__type = [
|
|
88
|
+
"context",
|
|
89
|
+
"getCacheDirectory",
|
|
90
|
+
"A helper function to get the cache directory path for storing schemas. This function takes a context object as input and returns the path to the cache directory where schemas are stored. The cache directory is constructed by joining the `cachePath` property from the context with a subdirectory named \"schemas\". This function is useful for centralizing the logic for determining where schema files should be cached, ensuring that all schema-related file operations use a consistent location for storing and retrieving cached schemas.",
|
|
91
|
+
"P\"2!&/\"?#"
|
|
92
|
+
];
|
|
93
|
+
function getCacheFilePath(context, variant) {
|
|
94
|
+
return (0, _stryke_path_join.joinPaths)(getCacheDirectory(context), `${variant}.json`);
|
|
95
|
+
}
|
|
96
|
+
getCacheFilePath.__type = [
|
|
97
|
+
"context",
|
|
98
|
+
"config",
|
|
99
|
+
"secrets",
|
|
100
|
+
"variant",
|
|
101
|
+
"getCacheFilePath",
|
|
102
|
+
"P\"2!P.\".#J2$&/%"
|
|
103
|
+
];
|
|
104
|
+
async function writeActive(context, variant, schema) {
|
|
105
|
+
if (!(_powerlines_schema.isSchema.Ω = [[() => require_types_plugin.__ΩEnvSchema, "n!"]], (0, _powerlines_schema.isSchema)(schema))) throw new Error(`The provided input is not a valid env schema. A valid schema must have a "variant" property indicating the type of the input and a "schema" property containing the parsed JSON Schema object.`);
|
|
106
|
+
await context.fs.write(getCacheFilePath(context, variant), JSON.stringify(schema.schema));
|
|
107
|
+
}
|
|
108
|
+
writeActive.__type = [
|
|
109
|
+
"context",
|
|
110
|
+
"config",
|
|
111
|
+
"secrets",
|
|
112
|
+
"variant",
|
|
113
|
+
() => require_types_plugin.__ΩEnvSchema,
|
|
114
|
+
"schema",
|
|
115
|
+
"writeActive",
|
|
116
|
+
"P\"2!P.\".#J2$n%2&\"/'"
|
|
117
|
+
];
|
|
118
|
+
async function readActive(context, variant) {
|
|
119
|
+
if (!context.fs.existsSync(getCacheFilePath(context, variant))) return [];
|
|
120
|
+
const data = await context.fs.read(getCacheFilePath(context, variant));
|
|
121
|
+
if (!data) return [];
|
|
122
|
+
return JSON.parse(data);
|
|
123
|
+
}
|
|
124
|
+
readActive.__type = [
|
|
125
|
+
"context",
|
|
126
|
+
"config",
|
|
127
|
+
"secrets",
|
|
128
|
+
"variant",
|
|
129
|
+
"readActive",
|
|
130
|
+
"P\"2!P.\".#J2$&F`/%"
|
|
131
|
+
];
|
|
132
|
+
/**
|
|
70
133
|
* 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.
|
|
71
134
|
*
|
|
72
135
|
* @remarks
|
|
@@ -78,22 +141,25 @@ getDefaultSecretsTypeDefinition.__type = [
|
|
|
78
141
|
async function extractEnv(context) {
|
|
79
142
|
const defaultVarsTypeDefinition = await getDefaultVarsTypeDefinition(context);
|
|
80
143
|
const defaultSecretsTypeDefinition = await getDefaultSecretsTypeDefinition(context);
|
|
81
|
-
const
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
144
|
+
const config = await (_powerlines_schema_extract.extract.Ω = [[() => __ΩRecord, "&\"o!#"]], (0, _powerlines_schema_extract.extract)(context, context.config.env.config));
|
|
145
|
+
config.active = await readActive(context, "config");
|
|
146
|
+
if ((0, _stryke_type_checks_is_string.isString)(context.config.env.config) && context.config.env.config !== `${defaultVarsTypeDefinition.file}#${defaultVarsTypeDefinition.name}` || (0, _stryke_type_checks_is_set_object.isSetObject)(context.config.env.config) && (context.config.env.config.file !== defaultVarsTypeDefinition.file || context.config.env.config.name !== defaultVarsTypeDefinition.name)) config.schema = (_powerlines_schema_helpers.mergeSchemas.Ω = [[() => __ΩRecord, "&\"o!#"]], (0, _powerlines_schema_helpers.mergeSchemas)(config, await (_powerlines_schema_extract.extract.Ω = [[() => __ΩRecord, "&\"o!#"]], (0, _powerlines_schema_extract.extract)(context, defaultVarsTypeDefinition))));
|
|
147
|
+
const secrets = await (_powerlines_schema_extract.extract.Ω = [[() => __ΩRecord, "&\"o!#"]], (0, _powerlines_schema_extract.extract)(context, context.config.env.secrets));
|
|
148
|
+
secrets.active = await readActive(context, "secrets");
|
|
149
|
+
if ((0, _stryke_type_checks_is_string.isString)(context.config.env.secrets) && context.config.env.secrets !== `${defaultSecretsTypeDefinition.file}#${defaultSecretsTypeDefinition.name}` || (0, _stryke_type_checks_is_set_object.isSetObject)(context.config.env.secrets) && (context.config.env.secrets.file !== defaultSecretsTypeDefinition.file || context.config.env.secrets.name !== defaultSecretsTypeDefinition.name)) secrets.schema = (_powerlines_schema_helpers.mergeSchemas.Ω = [[() => __ΩRecord, "&\"o!#"]], (0, _powerlines_schema_helpers.mergeSchemas)(secrets, await (_powerlines_schema_extract.extract.Ω = [[() => __ΩRecord, "&\"o!#"]], (0, _powerlines_schema_extract.extract)(context, defaultSecretsTypeDefinition))));
|
|
85
150
|
context.env = (0, defu.default)({
|
|
86
|
-
|
|
151
|
+
config,
|
|
87
152
|
secrets,
|
|
88
153
|
parsed: await require_helpers_load.loadEnv(context, context.config.env)
|
|
89
154
|
}, context.env ?? {}, {
|
|
155
|
+
active: [],
|
|
90
156
|
parsed: {},
|
|
91
157
|
injected: []
|
|
92
158
|
});
|
|
93
|
-
const properties = (0, _powerlines_schema_helpers.getProperties)(context.env.
|
|
159
|
+
const properties = (0, _powerlines_schema_helpers.getProperties)(context.env.config);
|
|
94
160
|
context.info({
|
|
95
161
|
meta: { category: "env" },
|
|
96
|
-
message: `Environment Variables configuration: ${context.config.env.
|
|
162
|
+
message: `Environment Variables configuration: ${context.config.env.config ? "" : "Defaulted "}${context.env.config.variant === "reflection" ? "Deepkit type definition" : context.env.config.variant === "json-schema" ? "JSON Schema" : context.env.config.variant === "standard-schema" ? "Standard Schema" : context.env.config.variant === "zod3" ? "Zod v3 schema" : "Typescript exported type"}${context.config.env.config ? " 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"}`
|
|
97
163
|
});
|
|
98
164
|
const aliases = Object.fromEntries(Object.entries(properties).flatMap(__assignType(([key, prop]) => (0, _stryke_type_checks_is_set_array.isSetArray)(prop.alias) ? prop.alias?.map(__assignType((alias) => [alias, {
|
|
99
165
|
...prop,
|
|
@@ -124,13 +190,13 @@ async function extractEnv(context) {
|
|
|
124
190
|
]), key);
|
|
125
191
|
if (properties[unprefixedKey]) {
|
|
126
192
|
if (!properties[unprefixedKey]?.runtime) {
|
|
127
|
-
const propertySchema = context.env.
|
|
193
|
+
const propertySchema = context.env.config.schema.properties?.[unprefixedKey];
|
|
128
194
|
if (propertySchema) propertySchema.default = value;
|
|
129
195
|
}
|
|
130
196
|
} else if (aliases[unprefixedKey]) {
|
|
131
197
|
if (!aliases[unprefixedKey]?.runtime) {
|
|
132
198
|
const alias = aliases[unprefixedKey]?.alias?.[0] ?? unprefixedKey;
|
|
133
|
-
const aliasSchema = context.env.
|
|
199
|
+
const aliasSchema = context.env.config.schema.properties?.[alias];
|
|
134
200
|
if (aliasSchema) aliasSchema.default = value;
|
|
135
201
|
}
|
|
136
202
|
}
|
|
@@ -142,9 +208,32 @@ extractEnv.__type = [
|
|
|
142
208
|
"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.",
|
|
143
209
|
"P\"2!$`/\"?#"
|
|
144
210
|
];
|
|
211
|
+
/**
|
|
212
|
+
* Writes the environment variables and secrets schema stored in the plugin context to the cache directory for later retrieval during the build process. This function should be called during the plugin's `build` hook after the schema has been extracted and stored in the plugin context to ensure that the active environment variables and secrets are persisted across builds and can be accessed during the build process for validation and injection purposes.
|
|
213
|
+
*
|
|
214
|
+
* @param context - The plugin context containing the environment variables and secrets schema to be written to the cache directory.
|
|
215
|
+
* @returns A promise that resolves when the schema has been successfully written to the cache directory.
|
|
216
|
+
*/
|
|
217
|
+
async function writeEnv(context) {
|
|
218
|
+
return Promise.all([
|
|
219
|
+
(0, _powerlines_schema.writeSchema)(context, (0, _stryke_helpers_omit.omit)(context.env.config, ["active"])),
|
|
220
|
+
(0, _powerlines_schema.writeSchema)(context, (0, _stryke_helpers_omit.omit)(context.env.secrets, ["active"])),
|
|
221
|
+
writeActive(context, "config", context.env.config),
|
|
222
|
+
writeActive(context, "secrets", context.env.secrets)
|
|
223
|
+
]);
|
|
224
|
+
}
|
|
225
|
+
writeEnv.__type = [
|
|
226
|
+
"context",
|
|
227
|
+
"writeEnv",
|
|
228
|
+
"Writes the environment variables and secrets schema stored in the plugin context to the cache directory for later retrieval during the build process. This function should be called during the plugin's `build` hook after the schema has been extracted and stored in the plugin context to ensure that the active environment variables and secrets are persisted across builds and can be accessed during the build process for validation and injection purposes.",
|
|
229
|
+
"P\"2!$F`/\"?#"
|
|
230
|
+
];
|
|
145
231
|
|
|
146
232
|
//#endregion
|
|
147
233
|
exports.extractEnv = extractEnv;
|
|
234
|
+
exports.getCacheDirectory = getCacheDirectory;
|
|
235
|
+
exports.getCacheFilePath = getCacheFilePath;
|
|
148
236
|
exports.getDefaultSecretsTypeDefinition = getDefaultSecretsTypeDefinition;
|
|
149
237
|
exports.getDefaultVarsTypeDefinition = getDefaultVarsTypeDefinition;
|
|
150
|
-
exports.resolveRuntimeTypeFile = resolveRuntimeTypeFile;
|
|
238
|
+
exports.resolveRuntimeTypeFile = resolveRuntimeTypeFile;
|
|
239
|
+
exports.writeEnv = writeEnv;
|
|
@@ -23,6 +23,14 @@ declare function getDefaultVarsTypeDefinition<TContext extends UnresolvedContext
|
|
|
23
23
|
* @returns The default type definition for the environment secrets.
|
|
24
24
|
*/
|
|
25
25
|
declare function getDefaultSecretsTypeDefinition<TContext extends UnresolvedContext>(context: TContext): Promise<TypeDefinition>;
|
|
26
|
+
/**
|
|
27
|
+
* A helper function to get the cache directory path for storing schemas. This function takes a context object as input and returns the path to the cache directory where schemas are stored. The cache directory is constructed by joining the `cachePath` property from the context with a subdirectory named "schemas". This function is useful for centralizing the logic for determining where schema files should be cached, ensuring that all schema-related file operations use a consistent location for storing and retrieving cached schemas.
|
|
28
|
+
*
|
|
29
|
+
* @param context - The context object providing access to the cache path.
|
|
30
|
+
* @returns The path to the cache directory for storing schemas, constructed by joining the context's `cachePath` with the "schemas" subdirectory.
|
|
31
|
+
*/
|
|
32
|
+
declare function getCacheDirectory<TContext extends EnvPluginContext>(context: TContext): string;
|
|
33
|
+
declare function getCacheFilePath<TContext extends EnvPluginContext>(context: TContext, variant: "config" | "secrets"): string;
|
|
26
34
|
/**
|
|
27
35
|
* 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.
|
|
28
36
|
*
|
|
@@ -33,6 +41,13 @@ declare function getDefaultSecretsTypeDefinition<TContext extends UnresolvedCont
|
|
|
33
41
|
* @returns A promise that resolves when the schema has been extracted and stored in the plugin context.
|
|
34
42
|
*/
|
|
35
43
|
declare function extractEnv<TContext extends EnvPluginContext>(context: TContext): Promise<void>;
|
|
44
|
+
/**
|
|
45
|
+
* Writes the environment variables and secrets schema stored in the plugin context to the cache directory for later retrieval during the build process. This function should be called during the plugin's `build` hook after the schema has been extracted and stored in the plugin context to ensure that the active environment variables and secrets are persisted across builds and can be accessed during the build process for validation and injection purposes.
|
|
46
|
+
*
|
|
47
|
+
* @param context - The plugin context containing the environment variables and secrets schema to be written to the cache directory.
|
|
48
|
+
* @returns A promise that resolves when the schema has been successfully written to the cache directory.
|
|
49
|
+
*/
|
|
50
|
+
declare function writeEnv<TContext extends EnvPluginContext>(context: TContext): Promise<void[]>;
|
|
36
51
|
//#endregion
|
|
37
|
-
export { extractEnv, getDefaultSecretsTypeDefinition, getDefaultVarsTypeDefinition, resolveRuntimeTypeFile };
|
|
52
|
+
export { extractEnv, getCacheDirectory, getCacheFilePath, getDefaultSecretsTypeDefinition, getDefaultVarsTypeDefinition, resolveRuntimeTypeFile, writeEnv };
|
|
38
53
|
//# sourceMappingURL=schema.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.cts","names":[],"sources":["../../src/helpers/schema.ts"],"mappings":";;;;;;;
|
|
1
|
+
{"version":3,"file":"schema.d.cts","names":[],"sources":["../../src/helpers/schema.ts"],"mappings":";;;;;;;AA0CA;;;;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;;;;;;;iBAad,iBAAA,kBAAmC,gBAAA,CAAA,CACjD,OAAA,EAAS,QAAQ;AAAA,iBAKH,gBAAA,kBAAkC,gBAAA,CAAA,CAChD,OAAA,EAAS,QAAQ,EACjB,OAAA;;;;;;AAnC0C;AAY5C;;;iBAsEsB,UAAA,kBAA4B,gBAAA,CAAA,CAChD,OAAA,EAAS,QAAA,GACR,OAAA;;;;;;;iBAkKmB,QAAA,kBAA0B,gBAAA,CAAA,CAC9C,OAAA,EAAS,QAAA,GACR,OAAA"}
|
|
@@ -23,6 +23,14 @@ declare function getDefaultVarsTypeDefinition<TContext extends UnresolvedContext
|
|
|
23
23
|
* @returns The default type definition for the environment secrets.
|
|
24
24
|
*/
|
|
25
25
|
declare function getDefaultSecretsTypeDefinition<TContext extends UnresolvedContext>(context: TContext): Promise<TypeDefinition>;
|
|
26
|
+
/**
|
|
27
|
+
* A helper function to get the cache directory path for storing schemas. This function takes a context object as input and returns the path to the cache directory where schemas are stored. The cache directory is constructed by joining the `cachePath` property from the context with a subdirectory named "schemas". This function is useful for centralizing the logic for determining where schema files should be cached, ensuring that all schema-related file operations use a consistent location for storing and retrieving cached schemas.
|
|
28
|
+
*
|
|
29
|
+
* @param context - The context object providing access to the cache path.
|
|
30
|
+
* @returns The path to the cache directory for storing schemas, constructed by joining the context's `cachePath` with the "schemas" subdirectory.
|
|
31
|
+
*/
|
|
32
|
+
declare function getCacheDirectory<TContext extends EnvPluginContext>(context: TContext): string;
|
|
33
|
+
declare function getCacheFilePath<TContext extends EnvPluginContext>(context: TContext, variant: "config" | "secrets"): string;
|
|
26
34
|
/**
|
|
27
35
|
* 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.
|
|
28
36
|
*
|
|
@@ -33,6 +41,13 @@ declare function getDefaultSecretsTypeDefinition<TContext extends UnresolvedCont
|
|
|
33
41
|
* @returns A promise that resolves when the schema has been extracted and stored in the plugin context.
|
|
34
42
|
*/
|
|
35
43
|
declare function extractEnv<TContext extends EnvPluginContext>(context: TContext): Promise<void>;
|
|
44
|
+
/**
|
|
45
|
+
* Writes the environment variables and secrets schema stored in the plugin context to the cache directory for later retrieval during the build process. This function should be called during the plugin's `build` hook after the schema has been extracted and stored in the plugin context to ensure that the active environment variables and secrets are persisted across builds and can be accessed during the build process for validation and injection purposes.
|
|
46
|
+
*
|
|
47
|
+
* @param context - The plugin context containing the environment variables and secrets schema to be written to the cache directory.
|
|
48
|
+
* @returns A promise that resolves when the schema has been successfully written to the cache directory.
|
|
49
|
+
*/
|
|
50
|
+
declare function writeEnv<TContext extends EnvPluginContext>(context: TContext): Promise<void[]>;
|
|
36
51
|
//#endregion
|
|
37
|
-
export { extractEnv, getDefaultSecretsTypeDefinition, getDefaultVarsTypeDefinition, resolveRuntimeTypeFile };
|
|
52
|
+
export { extractEnv, getCacheDirectory, getCacheFilePath, getDefaultSecretsTypeDefinition, getDefaultVarsTypeDefinition, resolveRuntimeTypeFile, writeEnv };
|
|
38
53
|
//# sourceMappingURL=schema.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.mts","names":[],"sources":["../../src/helpers/schema.ts"],"mappings":";;;;;;;
|
|
1
|
+
{"version":3,"file":"schema.d.mts","names":[],"sources":["../../src/helpers/schema.ts"],"mappings":";;;;;;;AA0CA;;;;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;;;;;;;iBAad,iBAAA,kBAAmC,gBAAA,CAAA,CACjD,OAAA,EAAS,QAAQ;AAAA,iBAKH,gBAAA,kBAAkC,gBAAA,CAAA,CAChD,OAAA,EAAS,QAAQ,EACjB,OAAA;;;;;;AAnC0C;AAY5C;;;iBAsEsB,UAAA,kBAA4B,gBAAA,CAAA,CAChD,OAAA,EAAS,QAAA,GACR,OAAA;;;;;;;iBAkKmB,QAAA,kBAA0B,gBAAA,CAAA,CAC9C,OAAA,EAAS,QAAA,GACR,OAAA"}
|
package/dist/helpers/schema.mjs
CHANGED
|
@@ -1,13 +1,22 @@
|
|
|
1
|
-
import { __Ω
|
|
1
|
+
import { __ΩEnvSchema } from "../types/plugin.mjs";
|
|
2
2
|
import { loadEnv } from "./load.mjs";
|
|
3
3
|
import { isString } from "@stryke/type-checks/is-string";
|
|
4
|
+
import { isSchema, writeSchema } from "@powerlines/schema";
|
|
4
5
|
import { extract } from "@powerlines/schema/extract";
|
|
5
|
-
import { getProperties, getPropertiesList, mergeSchemas } from "@powerlines/schema/helpers";
|
|
6
|
+
import { getProperties as getProperties$1, getPropertiesList, mergeSchemas } from "@powerlines/schema/helpers";
|
|
7
|
+
import { omit } from "@stryke/helpers/omit";
|
|
8
|
+
import { joinPaths } from "@stryke/path/join";
|
|
6
9
|
import { isSetArray } from "@stryke/type-checks/is-set-array";
|
|
7
10
|
import { isSetObject } from "@stryke/type-checks/is-set-object";
|
|
8
11
|
import defu from "defu";
|
|
9
12
|
|
|
10
13
|
//#region src/helpers/schema.ts
|
|
14
|
+
const __ΩRecord = [
|
|
15
|
+
"K",
|
|
16
|
+
"T",
|
|
17
|
+
"Record",
|
|
18
|
+
"l'e#\"Rb!b\"Pde\"!N#!w#y"
|
|
19
|
+
];
|
|
11
20
|
function __assignType(fn, args) {
|
|
12
21
|
fn.__type = args;
|
|
13
22
|
return fn;
|
|
@@ -64,6 +73,60 @@ getDefaultSecretsTypeDefinition.__type = [
|
|
|
64
73
|
"P\"2!!`/\""
|
|
65
74
|
];
|
|
66
75
|
/**
|
|
76
|
+
* A helper function to get the cache directory path for storing schemas. This function takes a context object as input and returns the path to the cache directory where schemas are stored. The cache directory is constructed by joining the `cachePath` property from the context with a subdirectory named "schemas". This function is useful for centralizing the logic for determining where schema files should be cached, ensuring that all schema-related file operations use a consistent location for storing and retrieving cached schemas.
|
|
77
|
+
*
|
|
78
|
+
* @param context - The context object providing access to the cache path.
|
|
79
|
+
* @returns The path to the cache directory for storing schemas, constructed by joining the context's `cachePath` with the "schemas" subdirectory.
|
|
80
|
+
*/
|
|
81
|
+
function getCacheDirectory(context) {
|
|
82
|
+
return joinPaths(context.cachePath, "env");
|
|
83
|
+
}
|
|
84
|
+
getCacheDirectory.__type = [
|
|
85
|
+
"context",
|
|
86
|
+
"getCacheDirectory",
|
|
87
|
+
"A helper function to get the cache directory path for storing schemas. This function takes a context object as input and returns the path to the cache directory where schemas are stored. The cache directory is constructed by joining the `cachePath` property from the context with a subdirectory named \"schemas\". This function is useful for centralizing the logic for determining where schema files should be cached, ensuring that all schema-related file operations use a consistent location for storing and retrieving cached schemas.",
|
|
88
|
+
"P\"2!&/\"?#"
|
|
89
|
+
];
|
|
90
|
+
function getCacheFilePath(context, variant) {
|
|
91
|
+
return joinPaths(getCacheDirectory(context), `${variant}.json`);
|
|
92
|
+
}
|
|
93
|
+
getCacheFilePath.__type = [
|
|
94
|
+
"context",
|
|
95
|
+
"config",
|
|
96
|
+
"secrets",
|
|
97
|
+
"variant",
|
|
98
|
+
"getCacheFilePath",
|
|
99
|
+
"P\"2!P.\".#J2$&/%"
|
|
100
|
+
];
|
|
101
|
+
async function writeActive(context, variant, schema) {
|
|
102
|
+
if (!(isSchema.Ω = [[() => __ΩEnvSchema, "n!"]], isSchema(schema))) throw new Error(`The provided input is not a valid env schema. A valid schema must have a "variant" property indicating the type of the input and a "schema" property containing the parsed JSON Schema object.`);
|
|
103
|
+
await context.fs.write(getCacheFilePath(context, variant), JSON.stringify(schema.schema));
|
|
104
|
+
}
|
|
105
|
+
writeActive.__type = [
|
|
106
|
+
"context",
|
|
107
|
+
"config",
|
|
108
|
+
"secrets",
|
|
109
|
+
"variant",
|
|
110
|
+
() => __ΩEnvSchema,
|
|
111
|
+
"schema",
|
|
112
|
+
"writeActive",
|
|
113
|
+
"P\"2!P.\".#J2$n%2&\"/'"
|
|
114
|
+
];
|
|
115
|
+
async function readActive(context, variant) {
|
|
116
|
+
if (!context.fs.existsSync(getCacheFilePath(context, variant))) return [];
|
|
117
|
+
const data = await context.fs.read(getCacheFilePath(context, variant));
|
|
118
|
+
if (!data) return [];
|
|
119
|
+
return JSON.parse(data);
|
|
120
|
+
}
|
|
121
|
+
readActive.__type = [
|
|
122
|
+
"context",
|
|
123
|
+
"config",
|
|
124
|
+
"secrets",
|
|
125
|
+
"variant",
|
|
126
|
+
"readActive",
|
|
127
|
+
"P\"2!P.\".#J2$&F`/%"
|
|
128
|
+
];
|
|
129
|
+
/**
|
|
67
130
|
* 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.
|
|
68
131
|
*
|
|
69
132
|
* @remarks
|
|
@@ -75,22 +138,25 @@ getDefaultSecretsTypeDefinition.__type = [
|
|
|
75
138
|
async function extractEnv(context) {
|
|
76
139
|
const defaultVarsTypeDefinition = await getDefaultVarsTypeDefinition(context);
|
|
77
140
|
const defaultSecretsTypeDefinition = await getDefaultSecretsTypeDefinition(context);
|
|
78
|
-
const
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
141
|
+
const config = await (extract.Ω = [[() => __ΩRecord, "&\"o!#"]], extract(context, context.config.env.config));
|
|
142
|
+
config.active = await readActive(context, "config");
|
|
143
|
+
if (isString(context.config.env.config) && context.config.env.config !== `${defaultVarsTypeDefinition.file}#${defaultVarsTypeDefinition.name}` || isSetObject(context.config.env.config) && (context.config.env.config.file !== defaultVarsTypeDefinition.file || context.config.env.config.name !== defaultVarsTypeDefinition.name)) config.schema = (mergeSchemas.Ω = [[() => __ΩRecord, "&\"o!#"]], mergeSchemas(config, await (extract.Ω = [[() => __ΩRecord, "&\"o!#"]], extract(context, defaultVarsTypeDefinition))));
|
|
144
|
+
const secrets = await (extract.Ω = [[() => __ΩRecord, "&\"o!#"]], extract(context, context.config.env.secrets));
|
|
145
|
+
secrets.active = await readActive(context, "secrets");
|
|
146
|
+
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.Ω = [[() => __ΩRecord, "&\"o!#"]], mergeSchemas(secrets, await (extract.Ω = [[() => __ΩRecord, "&\"o!#"]], extract(context, defaultSecretsTypeDefinition))));
|
|
82
147
|
context.env = defu({
|
|
83
|
-
|
|
148
|
+
config,
|
|
84
149
|
secrets,
|
|
85
150
|
parsed: await loadEnv(context, context.config.env)
|
|
86
151
|
}, context.env ?? {}, {
|
|
152
|
+
active: [],
|
|
87
153
|
parsed: {},
|
|
88
154
|
injected: []
|
|
89
155
|
});
|
|
90
|
-
const properties = getProperties(context.env.
|
|
156
|
+
const properties = getProperties$1(context.env.config);
|
|
91
157
|
context.info({
|
|
92
158
|
meta: { category: "env" },
|
|
93
|
-
message: `Environment Variables configuration: ${context.config.env.
|
|
159
|
+
message: `Environment Variables configuration: ${context.config.env.config ? "" : "Defaulted "}${context.env.config.variant === "reflection" ? "Deepkit type definition" : context.env.config.variant === "json-schema" ? "JSON Schema" : context.env.config.variant === "standard-schema" ? "Standard Schema" : context.env.config.variant === "zod3" ? "Zod v3 schema" : "Typescript exported type"}${context.config.env.config ? " 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"}`
|
|
94
160
|
});
|
|
95
161
|
const aliases = Object.fromEntries(Object.entries(properties).flatMap(__assignType(([key, prop]) => isSetArray(prop.alias) ? prop.alias?.map(__assignType((alias) => [alias, {
|
|
96
162
|
...prop,
|
|
@@ -121,13 +187,13 @@ async function extractEnv(context) {
|
|
|
121
187
|
]), key);
|
|
122
188
|
if (properties[unprefixedKey]) {
|
|
123
189
|
if (!properties[unprefixedKey]?.runtime) {
|
|
124
|
-
const propertySchema = context.env.
|
|
190
|
+
const propertySchema = context.env.config.schema.properties?.[unprefixedKey];
|
|
125
191
|
if (propertySchema) propertySchema.default = value;
|
|
126
192
|
}
|
|
127
193
|
} else if (aliases[unprefixedKey]) {
|
|
128
194
|
if (!aliases[unprefixedKey]?.runtime) {
|
|
129
195
|
const alias = aliases[unprefixedKey]?.alias?.[0] ?? unprefixedKey;
|
|
130
|
-
const aliasSchema = context.env.
|
|
196
|
+
const aliasSchema = context.env.config.schema.properties?.[alias];
|
|
131
197
|
if (aliasSchema) aliasSchema.default = value;
|
|
132
198
|
}
|
|
133
199
|
}
|
|
@@ -139,7 +205,27 @@ extractEnv.__type = [
|
|
|
139
205
|
"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.",
|
|
140
206
|
"P\"2!$`/\"?#"
|
|
141
207
|
];
|
|
208
|
+
/**
|
|
209
|
+
* Writes the environment variables and secrets schema stored in the plugin context to the cache directory for later retrieval during the build process. This function should be called during the plugin's `build` hook after the schema has been extracted and stored in the plugin context to ensure that the active environment variables and secrets are persisted across builds and can be accessed during the build process for validation and injection purposes.
|
|
210
|
+
*
|
|
211
|
+
* @param context - The plugin context containing the environment variables and secrets schema to be written to the cache directory.
|
|
212
|
+
* @returns A promise that resolves when the schema has been successfully written to the cache directory.
|
|
213
|
+
*/
|
|
214
|
+
async function writeEnv(context) {
|
|
215
|
+
return Promise.all([
|
|
216
|
+
writeSchema(context, omit(context.env.config, ["active"])),
|
|
217
|
+
writeSchema(context, omit(context.env.secrets, ["active"])),
|
|
218
|
+
writeActive(context, "config", context.env.config),
|
|
219
|
+
writeActive(context, "secrets", context.env.secrets)
|
|
220
|
+
]);
|
|
221
|
+
}
|
|
222
|
+
writeEnv.__type = [
|
|
223
|
+
"context",
|
|
224
|
+
"writeEnv",
|
|
225
|
+
"Writes the environment variables and secrets schema stored in the plugin context to the cache directory for later retrieval during the build process. This function should be called during the plugin's `build` hook after the schema has been extracted and stored in the plugin context to ensure that the active environment variables and secrets are persisted across builds and can be accessed during the build process for validation and injection purposes.",
|
|
226
|
+
"P\"2!$F`/\"?#"
|
|
227
|
+
];
|
|
142
228
|
|
|
143
229
|
//#endregion
|
|
144
|
-
export { extractEnv, getDefaultSecretsTypeDefinition, getDefaultVarsTypeDefinition, resolveRuntimeTypeFile };
|
|
230
|
+
export { extractEnv, getCacheDirectory, getCacheFilePath, getDefaultSecretsTypeDefinition, getDefaultVarsTypeDefinition, resolveRuntimeTypeFile, writeEnv };
|
|
145
231
|
//# 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 { 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,OAAA;EACH,MAAA;;AAEA;AACA,gCAAC,SAAA;CAAA;CAAA;CAAA;AAAA;;;;;;;;;;AAUD,eAAG,WAAA,SAAA;CACH,MAAA,4BAAA,MAAA,6BAAA,OAAA;;CAEE,MAAA,OAAA,OAAA,QAAA,IAAA,CAAA,OAAA,QAAA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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
|
+
{"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 { isSchema, Schema, writeSchema } from \"@powerlines/schema\";\nimport { extract } from \"@powerlines/schema/extract\";\nimport {\n getProperties,\n getPropertiesList,\n mergeSchemas\n} from \"@powerlines/schema/helpers\";\nimport { omit } from \"@stryke/helpers/omit\";\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 * A helper function to get the cache directory path for storing schemas. This function takes a context object as input and returns the path to the cache directory where schemas are stored. The cache directory is constructed by joining the `cachePath` property from the context with a subdirectory named \"schemas\". This function is useful for centralizing the logic for determining where schema files should be cached, ensuring that all schema-related file operations use a consistent location for storing and retrieving cached schemas.\n *\n * @param context - The context object providing access to the cache path.\n * @returns The path to the cache directory for storing schemas, constructed by joining the context's `cachePath` with the \"schemas\" subdirectory.\n */\nexport function getCacheDirectory<TContext extends EnvPluginContext>(\n context: TContext\n): string {\n return joinPaths(context.cachePath, \"env\");\n}\n\nexport function getCacheFilePath<TContext extends EnvPluginContext>(\n context: TContext,\n variant: \"config\" | \"secrets\"\n): string {\n return joinPaths(getCacheDirectory(context), `${variant}.json`);\n}\n\nasync function writeActive<TContext extends EnvPluginContext>(\n context: TContext,\n variant: \"config\" | \"secrets\",\n schema: EnvSchema\n) {\n if (!isSchema<EnvSchema>(schema)) {\n throw new Error(\n `The provided input is not a valid env schema. A valid schema must have a \"variant\" property indicating the type of the input and a \"schema\" property containing the parsed JSON Schema object.`\n );\n }\n\n await context.fs.write(\n getCacheFilePath(context, variant),\n JSON.stringify(schema.schema)\n );\n}\n\nasync function readActive<TContext extends EnvPluginContext>(\n context: TContext,\n variant: \"config\" | \"secrets\"\n): Promise<string[]> {\n if (!context.fs.existsSync(getCacheFilePath(context, variant))) {\n return [];\n }\n\n const data = await context.fs.read(getCacheFilePath(context, variant));\n if (!data) {\n return [];\n }\n\n return JSON.parse(data);\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 config = (await extract<Record<string, any>>(\n context,\n context.config.env.config\n )) as EnvSchema;\n config.active = await readActive(context, \"config\");\n\n if (\n (isString(context.config.env.config) &&\n context.config.env.config !==\n `${defaultVarsTypeDefinition.file}#${\n defaultVarsTypeDefinition.name\n }`) ||\n (isSetObject(context.config.env.config) &&\n ((context.config.env.config as TypeDefinition).file !==\n defaultVarsTypeDefinition.file ||\n (context.config.env.config as TypeDefinition).name !==\n defaultVarsTypeDefinition.name))\n ) {\n config.schema = mergeSchemas<Record<string, any>>(\n config,\n await extract<Record<string, any>>(context, defaultVarsTypeDefinition)\n );\n }\n\n const secrets = (await extract<Record<string, any>>(\n context,\n context.config.env.secrets\n )) as EnvSchema;\n secrets.active = await readActive(context, \"secrets\");\n\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<Record<string, any>>(\n secrets,\n await extract<Record<string, any>>(context, defaultSecretsTypeDefinition)\n );\n }\n\n context.env = defu(\n {\n config,\n secrets,\n parsed: await loadEnv(context, context.config.env)\n },\n context.env ?? {},\n {\n active: [],\n parsed: {},\n injected: []\n }\n );\n\n const properties = getProperties(context.env.config);\n context.info({\n meta: {\n category: \"env\"\n },\n message: `Environment Variables configuration: ${\n context.config.env.config ? \"\" : \"Defaulted \"\n }${\n context.env.config.variant === \"reflection\"\n ? \"Deepkit type definition\"\n : context.env.config.variant === \"json-schema\"\n ? \"JSON Schema\"\n : context.env.config.variant === \"standard-schema\"\n ? \"Standard Schema\"\n : context.env.config.variant === \"zod3\"\n ? \"Zod v3 schema\"\n : \"Typescript exported type\"\n }${context.config.env.config ? \" 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.config.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.config.schema.properties?.[alias];\n if (aliasSchema) {\n aliasSchema.default = value;\n }\n }\n }\n }\n}\n\n/**\n * Writes the environment variables and secrets schema stored in the plugin context to the cache directory for later retrieval during the build process. This function should be called during the plugin's `build` hook after the schema has been extracted and stored in the plugin context to ensure that the active environment variables and secrets are persisted across builds and can be accessed during the build process for validation and injection purposes.\n *\n * @param context - The plugin context containing the environment variables and secrets schema to be written to the cache directory.\n * @returns A promise that resolves when the schema has been successfully written to the cache directory.\n */\nexport async function writeEnv<TContext extends EnvPluginContext>(\n context: TContext\n): Promise<void[]> {\n return Promise.all([\n writeSchema(context, omit(context.env.config, [\"active\"]) as Schema),\n writeSchema(context, omit(context.env.secrets, [\"active\"]) as Schema),\n writeActive(context, \"config\", context.env.config),\n writeActive(context, \"secrets\", context.env.secrets)\n ]);\n}\n"],"mappings":";;;;;;;;;;;;;AAAA,MAAM,YAAY;CAAC;CAAK;CAAK;CAAU;AAAwB;;CAI9D,GAAI,SAAS;CACb,OAAG;AACJ;;;;;;;AAkCA,eAAgB,uBAA6B,SAAQ;CACnD,MAAA,WAAA,MAAA,QAAA,GAAA,QAAA,kCAAA;CACF,IAAM,CAAC,UACL,MAAQ,IAAC,MAAQ,yJAAA;CAEjB,OAAM;AACR;AACA,uBAAmB,SAAA;CAAA;CAAA;CAAA;CAAA;AAAA;;;;;;;;CAQjB,OAAA;EACC,MAAK,MAAI,uBAA2B,OAAK;EAC3C,MAAA;CACC;AACF;AACA,6BAAE,SAAA;CAAA;CAAA;CAAA;CAAA;AAAA;;;;;;AAMF,eAAW,gCAAY,SAAA;CACrB,OAAC;EACH,MAAA,MAAA,uBAAA,OAAA;;CAEE;AACF;AACA,gCAA+B,SAAO;CAAA;CAAA;CAAA;AAAA;;;;;;;AAOtC,SAAgB,kBAAA,SAAuB;CACrC,OAAO,UAAE,QAAgB,WAAA,KAAA;AAC3B;AACA,kBAAA,SAAA;CAAA;CAAA;CAAA;CAAA;AAAA;;CAEE,OAAA,UAAA,kBAAA,OAAA,GAAA,GAAA,QAAA,MAAA;AACF;AACA,iBAAC,SAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;AAAA;AACD,eAAU,YAAc,SAAQ,SAAO,QAAU;CAC/C,IAAE,EAAA,SAAY,IAAK,CAAA,OAAO,cAAe,IAAI,CAAC,GAAA,SAAQ,MAAS,IAC/D,MAAA,IAAA,MAAA,gMAAA;CAEA,MAAA,QAAS,GAAA,MAAA,iBAAA,SAAA,OAAA,GAAA,KAAA,UAAA,OAAA,MAAA,CAAA;AACX;AACA,YAAS,SAAU;CAAA;CAAQ;CAAgB;CAAC;OAAA;CAAA;CAAA;CAAA;AAAA;AAC5C,e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