@powerlines/plugin-env 0.16.65 → 0.16.67

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 (47) hide show
  1. package/dist/babel/plugin.cjs +83 -11
  2. package/dist/babel/plugin.mjs +83 -11
  3. package/dist/babel/plugin.mjs.map +1 -1
  4. package/dist/components/env-builtin.cjs +1 -1
  5. package/dist/components/env-builtin.mjs +1 -1
  6. package/dist/helpers/automd-generator.cjs +14 -4
  7. package/dist/helpers/automd-generator.d.mts +1 -1
  8. package/dist/helpers/automd-generator.mjs +14 -4
  9. package/dist/helpers/automd-generator.mjs.map +1 -1
  10. package/dist/helpers/create-reflection-resource.cjs +8 -0
  11. package/dist/helpers/create-reflection-resource.mjs +9 -0
  12. package/dist/helpers/create-reflection-resource.mjs.map +1 -1
  13. package/dist/helpers/docs-helper.cjs +8 -0
  14. package/dist/helpers/docs-helper.mjs +8 -0
  15. package/dist/helpers/docs-helper.mjs.map +1 -1
  16. package/dist/helpers/index.cjs +1 -0
  17. package/dist/helpers/index.mjs +2 -2
  18. package/dist/helpers/load.cjs +58 -7
  19. package/dist/helpers/load.mjs +58 -7
  20. package/dist/helpers/load.mjs.map +1 -1
  21. package/dist/helpers/persistence.cjs +108 -1
  22. package/dist/helpers/persistence.mjs +108 -1
  23. package/dist/helpers/persistence.mjs.map +1 -1
  24. package/dist/helpers/reflect.cjs +156 -3
  25. package/dist/helpers/reflect.mjs +156 -4
  26. package/dist/helpers/reflect.mjs.map +1 -1
  27. package/dist/helpers/source-file-env.cjs +34 -4
  28. package/dist/helpers/source-file-env.mjs +34 -4
  29. package/dist/helpers/source-file-env.mjs.map +1 -1
  30. package/dist/helpers/template-helpers.cjs +33 -5
  31. package/dist/helpers/template-helpers.mjs +33 -5
  32. package/dist/helpers/template-helpers.mjs.map +1 -1
  33. package/dist/node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/_chunks/rolldown-runtime.mjs +2 -0
  34. package/dist/node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/_chunks/rolldown-runtime.mjs.map +1 -1
  35. package/dist/node_modules/.pnpm/giget@2.0.0/node_modules/giget/dist/index.mjs +4 -0
  36. package/dist/node_modules/.pnpm/giget@2.0.0/node_modules/giget/dist/shared/giget.OCaTp9b-.mjs +1 -0
  37. package/dist/node_modules/.pnpm/giget@2.0.0/node_modules/giget/dist/shared/giget.OCaTp9b-.mjs.map +1 -1
  38. package/dist/types/index.cjs +11 -0
  39. package/dist/types/index.mjs +4 -1
  40. package/dist/types/plugin.cjs +137 -0
  41. package/dist/types/plugin.d.mts +4 -4
  42. package/dist/types/plugin.mjs +132 -1
  43. package/dist/types/plugin.mjs.map +1 -0
  44. package/dist/types/runtime.cjs +244 -0
  45. package/dist/types/runtime.mjs +242 -1
  46. package/dist/types/runtime.mjs.map +1 -0
  47. package/package.json +9 -9
@@ -1,7 +1,9 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
  const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
3
+ const require_types_plugin = require('../types/plugin.cjs');
3
4
  const require_helpers_source_file_env = require('./source-file-env.cjs');
4
5
  const require_index = require('../node_modules/.pnpm/c12@3.3.3_magicast@0.5.2/node_modules/c12/dist/index.cjs');
6
+ let powerlines = require("powerlines");
5
7
  let _stryke_path_join_paths = require("@stryke/path/join-paths");
6
8
  let _stryke_env_load_env = require("@stryke/env/load-env");
7
9
  let _stryke_string_format_kebab_case = require("@stryke/string-format/kebab-case");
@@ -11,16 +13,32 @@ defu = require_runtime.__toESM(defu);
11
13
  let powerlines_utils = require("powerlines/utils");
12
14
 
13
15
  //#region src/helpers/load.ts
16
+ function __assignType(fn, args) {
17
+ fn.__type = args;
18
+ return fn;
19
+ }
14
20
  async function loadEnvFiles(options, mode, cwd) {
15
21
  let env = await (0, _stryke_env_load_env.loadEnv)(cwd, mode);
16
22
  if (options.additionalFiles && options.additionalFiles?.length > 0) {
17
- const additionalEnvFiles = await Promise.all(options.additionalFiles.map(async (additionalEnvFile) => (0, _stryke_env_load_env.loadEnvFile)(additionalEnvFile, cwd)));
23
+ const additionalEnvFiles = await Promise.all(options.additionalFiles.map(__assignType(async (additionalEnvFile) => (0, _stryke_env_load_env.loadEnvFile)(additionalEnvFile, cwd), [
24
+ "additionalEnvFile",
25
+ "",
26
+ "P\"2!\"/\""
27
+ ])));
18
28
  for (const additionalEnvFile of additionalEnvFiles) env = (0, defu.default)(additionalEnvFile, env);
19
29
  }
20
30
  return require_helpers_source_file_env.removeEnvPrefix(env);
21
31
  }
32
+ loadEnvFiles.__type = [
33
+ () => require_types_plugin.__ΩEnvPluginOptions,
34
+ "options",
35
+ "mode",
36
+ "cwd",
37
+ "loadEnvFiles",
38
+ "Pn!2\"&2#&2$\"`/%"
39
+ ];
22
40
  async function loadEnvDirectory(options, directory, mode, cacheDir, packageJson, workspaceConfig) {
23
- const [envResult, c12Result] = await Promise.all([loadEnvFiles(options, mode, directory), require_index.loadConfig({
41
+ const [envResult, c12Result] = await Promise.all([(loadEnvFiles.Ω = [["!"]], loadEnvFiles(options, mode, directory)), require_index.loadConfig({
24
42
  cwd: directory,
25
43
  name: "storm",
26
44
  envName: mode,
@@ -39,6 +57,18 @@ async function loadEnvDirectory(options, directory, mode, cacheDir, packageJson,
39
57
  })]);
40
58
  return (0, defu.default)(envResult, c12Result.config, workspaceConfig);
41
59
  }
60
+ loadEnvDirectory.__type = [
61
+ () => require_types_plugin.__ΩEnvPluginOptions,
62
+ "options",
63
+ "directory",
64
+ "mode",
65
+ "cacheDir",
66
+ "packageJson",
67
+ () => powerlines.__ΩWorkspaceConfig,
68
+ "workspaceConfig",
69
+ "loadEnvDirectory",
70
+ "Pn!2\"&2#&2$&2%!2&n'2(\"`/)"
71
+ ];
42
72
  /**
43
73
  * Retrieves various dotenv configuration parameters from the context.
44
74
  *
@@ -66,19 +96,40 @@ function loadEnvFromContext(context, parsed) {
66
96
  DEBUG: context.config.mode === "development",
67
97
  STACKTRACE: context.config.mode !== "production",
68
98
  ENVIRONMENT: !context.environment.name || context.environment.name === powerlines_utils.DEFAULT_ENVIRONMENT ? context.config.mode : context.environment.name
69
- }, (0, _stryke_type_checks_is_set_object.isSetObject)(context?.env?.types?.env) ? context.env.types.env?.getProperties().reduce((ret, prop) => {
99
+ }, (0, _stryke_type_checks_is_set_object.isSetObject)(context?.env?.types?.env) ? context.env.types.env?.getProperties().reduce(__assignType((ret, prop) => {
70
100
  ret[prop.name] = parsed[prop.name] ?? prop.getDefaultValue();
71
101
  return ret;
72
- }, {}) : {});
102
+ }, [
103
+ "ret",
104
+ "prop",
105
+ "",
106
+ "P\"2!\"2\"\"/#"
107
+ ]), {}) : {});
73
108
  }
109
+ loadEnvFromContext.__type = [
110
+ () => require_types_plugin.__ΩEnvPluginContext,
111
+ "context",
112
+ "parsed",
113
+ "loadEnvFromContext",
114
+ "Retrieves various dotenv configuration parameters from the context.",
115
+ "Pn!2\"!2#\"/$?%"
116
+ ];
74
117
  async function loadEnv(context, options) {
75
118
  const [project, workspace, config] = await Promise.all([
76
- loadEnvDirectory(options, context.config.root, context.config.mode, context.cachePath, context.packageJson, context.workspaceConfig),
77
- loadEnvDirectory(options, context.workspaceConfig.workspaceRoot, context.config.mode, context.cachePath, context.packageJson, context.workspaceConfig),
78
- loadEnvDirectory(options, context.envPaths.config, context.config.mode, context.cachePath, context.packageJson, context.workspaceConfig)
119
+ (loadEnvDirectory.Ω = [["!"]], loadEnvDirectory(options, context.config.root, context.config.mode, context.cachePath, context.packageJson, context.workspaceConfig)),
120
+ (loadEnvDirectory.Ω = [["!"]], loadEnvDirectory(options, context.workspaceConfig.workspaceRoot, context.config.mode, context.cachePath, context.packageJson, context.workspaceConfig)),
121
+ (loadEnvDirectory.Ω = [["!"]], loadEnvDirectory(options, context.envPaths.config, context.config.mode, context.cachePath, context.packageJson, context.workspaceConfig))
79
122
  ]);
80
123
  return (0, defu.default)(loadEnvFromContext(context, process.env), project, workspace, config);
81
124
  }
125
+ loadEnv.__type = [
126
+ () => require_types_plugin.__ΩEnvPluginContext,
127
+ "context",
128
+ () => require_types_plugin.__ΩEnvPluginOptions,
129
+ "options",
130
+ "loadEnv",
131
+ "Pn!2\"n#2$\"`/%"
132
+ ];
82
133
 
83
134
  //#endregion
84
135
  exports.loadEnv = loadEnv;
@@ -1,5 +1,7 @@
1
+ import { __ΩEnvPluginContext, __ΩEnvPluginOptions } from "../types/plugin.mjs";
1
2
  import { removeEnvPrefix } from "./source-file-env.mjs";
2
3
  import { loadConfig } from "../node_modules/.pnpm/c12@3.3.3_magicast@0.5.2/node_modules/c12/dist/index.mjs";
4
+ import { __ΩWorkspaceConfig } from "powerlines";
3
5
  import { joinPaths } from "@stryke/path/join-paths";
4
6
  import { loadEnv as loadEnv$1, loadEnvFile } from "@stryke/env/load-env";
5
7
  import { kebabCase } from "@stryke/string-format/kebab-case";
@@ -8,16 +10,32 @@ import defu from "defu";
8
10
  import { DEFAULT_ENVIRONMENT } from "powerlines/utils";
9
11
 
10
12
  //#region src/helpers/load.ts
13
+ function __assignType(fn, args) {
14
+ fn.__type = args;
15
+ return fn;
16
+ }
11
17
  async function loadEnvFiles(options, mode, cwd) {
12
18
  let env = await loadEnv$1(cwd, mode);
13
19
  if (options.additionalFiles && options.additionalFiles?.length > 0) {
14
- const additionalEnvFiles = await Promise.all(options.additionalFiles.map(async (additionalEnvFile) => loadEnvFile(additionalEnvFile, cwd)));
20
+ const additionalEnvFiles = await Promise.all(options.additionalFiles.map(__assignType(async (additionalEnvFile) => loadEnvFile(additionalEnvFile, cwd), [
21
+ "additionalEnvFile",
22
+ "",
23
+ "P\"2!\"/\""
24
+ ])));
15
25
  for (const additionalEnvFile of additionalEnvFiles) env = defu(additionalEnvFile, env);
16
26
  }
17
27
  return removeEnvPrefix(env);
18
28
  }
29
+ loadEnvFiles.__type = [
30
+ () => __ΩEnvPluginOptions,
31
+ "options",
32
+ "mode",
33
+ "cwd",
34
+ "loadEnvFiles",
35
+ "Pn!2\"&2#&2$\"`/%"
36
+ ];
19
37
  async function loadEnvDirectory(options, directory, mode, cacheDir, packageJson, workspaceConfig) {
20
- const [envResult, c12Result] = await Promise.all([loadEnvFiles(options, mode, directory), loadConfig({
38
+ const [envResult, c12Result] = await Promise.all([(loadEnvFiles.Ω = [["!"]], loadEnvFiles(options, mode, directory)), loadConfig({
21
39
  cwd: directory,
22
40
  name: "storm",
23
41
  envName: mode,
@@ -36,6 +54,18 @@ async function loadEnvDirectory(options, directory, mode, cacheDir, packageJson,
36
54
  })]);
37
55
  return defu(envResult, c12Result.config, workspaceConfig);
38
56
  }
57
+ loadEnvDirectory.__type = [
58
+ () => __ΩEnvPluginOptions,
59
+ "options",
60
+ "directory",
61
+ "mode",
62
+ "cacheDir",
63
+ "packageJson",
64
+ () => __ΩWorkspaceConfig,
65
+ "workspaceConfig",
66
+ "loadEnvDirectory",
67
+ "Pn!2\"&2#&2$&2%!2&n'2(\"`/)"
68
+ ];
39
69
  /**
40
70
  * Retrieves various dotenv configuration parameters from the context.
41
71
  *
@@ -63,19 +93,40 @@ function loadEnvFromContext(context, parsed) {
63
93
  DEBUG: context.config.mode === "development",
64
94
  STACKTRACE: context.config.mode !== "production",
65
95
  ENVIRONMENT: !context.environment.name || context.environment.name === DEFAULT_ENVIRONMENT ? context.config.mode : context.environment.name
66
- }, isSetObject(context?.env?.types?.env) ? context.env.types.env?.getProperties().reduce((ret, prop) => {
96
+ }, isSetObject(context?.env?.types?.env) ? context.env.types.env?.getProperties().reduce(__assignType((ret, prop) => {
67
97
  ret[prop.name] = parsed[prop.name] ?? prop.getDefaultValue();
68
98
  return ret;
69
- }, {}) : {});
99
+ }, [
100
+ "ret",
101
+ "prop",
102
+ "",
103
+ "P\"2!\"2\"\"/#"
104
+ ]), {}) : {});
70
105
  }
106
+ loadEnvFromContext.__type = [
107
+ () => __ΩEnvPluginContext,
108
+ "context",
109
+ "parsed",
110
+ "loadEnvFromContext",
111
+ "Retrieves various dotenv configuration parameters from the context.",
112
+ "Pn!2\"!2#\"/$?%"
113
+ ];
71
114
  async function loadEnv(context, options) {
72
115
  const [project, workspace, config] = await Promise.all([
73
- loadEnvDirectory(options, context.config.root, context.config.mode, context.cachePath, context.packageJson, context.workspaceConfig),
74
- loadEnvDirectory(options, context.workspaceConfig.workspaceRoot, context.config.mode, context.cachePath, context.packageJson, context.workspaceConfig),
75
- loadEnvDirectory(options, context.envPaths.config, context.config.mode, context.cachePath, context.packageJson, context.workspaceConfig)
116
+ (loadEnvDirectory.Ω = [["!"]], loadEnvDirectory(options, context.config.root, context.config.mode, context.cachePath, context.packageJson, context.workspaceConfig)),
117
+ (loadEnvDirectory.Ω = [["!"]], loadEnvDirectory(options, context.workspaceConfig.workspaceRoot, context.config.mode, context.cachePath, context.packageJson, context.workspaceConfig)),
118
+ (loadEnvDirectory.Ω = [["!"]], loadEnvDirectory(options, context.envPaths.config, context.config.mode, context.cachePath, context.packageJson, context.workspaceConfig))
76
119
  ]);
77
120
  return defu(loadEnvFromContext(context, process.env), project, workspace, config);
78
121
  }
122
+ loadEnv.__type = [
123
+ () => __ΩEnvPluginContext,
124
+ "context",
125
+ () => __ΩEnvPluginOptions,
126
+ "options",
127
+ "loadEnv",
128
+ "Pn!2\"n#2$\"`/%"
129
+ ];
79
130
 
80
131
  //#endregion
81
132
  export { loadEnv, loadEnvFromContext };
@@ -1 +1 @@
1
- {"version":3,"file":"load.mjs","names":["loadEnvBase","loadEnvFileBase"],"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 {\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/utils\";\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 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: \"storm\",\n envName: mode,\n defaults: {\n NAME: packageJson.name?.replace(`@${workspaceConfig.namespace}/`, \"\"),\n MODE: mode,\n ORG: 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) {\n return defu(\n {\n APP_NAME: kebabCase(\n context.config.name ||\n context.packageJson.name?.replace(\n `/${context.workspaceConfig.namespace}`,\n \"\"\n )\n ),\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: context.workspaceConfig.locale,\n DEFAULT_TIMEZONE: context.workspaceConfig.timezone,\n LOG_LEVEL:\n context.config.logLevel === \"trace\" ? \"debug\" : context.config.logLevel,\n ERROR_URL: context.workspaceConfig.error?.url,\n ORGANIZATION:\n context.config.organization ||\n (isSetObject(context.workspaceConfig.organization)\n ? context.workspaceConfig.organization.name\n : context.workspaceConfig.organization),\n PLATFORM: context.config.platform,\n MODE: context.config.mode,\n TEST: context.config.mode === \"test\",\n DEBUG: context.config.mode === \"development\",\n STACKTRACE: context.config.mode !== \"production\",\n ENVIRONMENT:\n !context.environment.name ||\n context.environment.name === DEFAULT_ENVIRONMENT\n ? context.config.mode\n : context.environment.name\n },\n isSetObject(context?.env?.types?.env)\n ? context.env.types.env?.getProperties().reduce(\n (ret, prop) => {\n ret[prop.name] = parsed[prop.name] ?? prop.getDefaultValue();\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 [project, workspace, config] = await Promise.all([\n loadEnvDirectory<TEnv>(\n options,\n context.config.root,\n context.config.mode,\n context.cachePath,\n context.packageJson,\n context.workspaceConfig\n ),\n loadEnvDirectory<TEnv>(\n options,\n context.workspaceConfig.workspaceRoot,\n context.config.mode,\n context.cachePath,\n context.packageJson,\n context.workspaceConfig\n ),\n loadEnvDirectory<TEnv>(\n options,\n context.envPaths.config,\n context.config.mode,\n context.cachePath,\n context.packageJson,\n context.workspaceConfig\n )\n ]);\n\n return defu(\n loadEnvFromContext(context, process.env),\n project,\n workspace,\n config\n ) as TEnv;\n}\n"],"mappings":";;;;;;;;;;AAkCA,eAAe,aACb,SACA,MACA,KACe;CACf,IAAI,MAAM,MAAMA,UAAY,KAAK,KAAK;AACtC,KAAI,QAAQ,mBAAmB,QAAQ,iBAAiB,SAAS,GAAG;EAClE,MAAM,qBAAqB,MAAM,QAAQ,IACvC,QAAQ,gBAAgB,IAAI,OAAM,sBAChCC,YAAgB,mBAAmB,IAAI,CACxC,CACF;AAED,OAAK,MAAM,qBAAqB,mBAC9B,OAAM,KAAK,mBAAmB,IAAI;;AAItC,QAAO,gBAAgB,IAAI;;AAG7B,eAAe,iBAGb,SACA,WACA,MACA,UACA,aACA,iBACe;CACf,MAAM,CAAC,WAAW,aAAa,MAAM,QAAQ,IAAI,CAC/C,aAAmB,SAAS,MAAM,UAAU,EAC5C,WAAW;EACT,KAAK;EACL,MAAM;EACN,SAAS;EACT,UAAU;GACR,MAAM,YAAY,MAAM,QAAQ,IAAI,gBAAgB,UAAU,IAAI,GAAG;GACrE,MAAM;GACN,KAAK,gBAAgB;GACtB;EACD,UAAU;EACV,aAAa;EACb,QAAQ;EACR,aAAa;GACX,SAAS,UAAU,UAAU,OAAO;GACpC,aAAa;GACd;EACF,CAAC,CACH,CAAC;AAEF,QAAO,KAAK,WAAkB,UAAU,QAAQ,gBAAgB;;;;;;;;;AAUlE,SAAgB,mBACd,SACA,QACA;AACA,QAAO,KACL;EACE,UAAU,UACR,QAAQ,OAAO,QACb,QAAQ,YAAY,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,WACR,QAAQ,aACR,QAAQ,gBACT;EACD,iBACE,SACA,QAAQ,SAAS,QACjB,QAAQ,OAAO,MACf,QAAQ,WACR,QAAQ,aACR,QAAQ,gBACT;EACF,CAAC;AAEF,QAAO,KACL,mBAAmB,SAAS,QAAQ,IAAI,EACxC,SACA,WACA,OACD"}
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 {\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/utils\";\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 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: \"storm\",\n envName: mode,\n defaults: {\n NAME: packageJson.name?.replace(`@${workspaceConfig.namespace}/`, \"\"),\n MODE: mode,\n ORG: 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) {\n return defu(\n {\n APP_NAME: kebabCase(\n context.config.name ||\n context.packageJson.name?.replace(\n `/${context.workspaceConfig.namespace}`,\n \"\"\n )\n ),\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: context.workspaceConfig.locale,\n DEFAULT_TIMEZONE: context.workspaceConfig.timezone,\n LOG_LEVEL:\n context.config.logLevel === \"trace\" ? \"debug\" : context.config.logLevel,\n ERROR_URL: context.workspaceConfig.error?.url,\n ORGANIZATION:\n context.config.organization ||\n (isSetObject(context.workspaceConfig.organization)\n ? context.workspaceConfig.organization.name\n : context.workspaceConfig.organization),\n PLATFORM: context.config.platform,\n MODE: context.config.mode,\n TEST: context.config.mode === \"test\",\n DEBUG: context.config.mode === \"development\",\n STACKTRACE: context.config.mode !== \"production\",\n ENVIRONMENT:\n !context.environment.name ||\n context.environment.name === DEFAULT_ENVIRONMENT\n ? context.config.mode\n : context.environment.name\n },\n isSetObject(context?.env?.types?.env)\n ? context.env.types.env?.getProperties().reduce(\n (ret, prop) => {\n ret[prop.name] = parsed[prop.name] ?? prop.getDefaultValue();\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 [project, workspace, config] = await Promise.all([\n loadEnvDirectory<TEnv>(\n options,\n context.config.root,\n context.config.mode,\n context.cachePath,\n context.packageJson,\n context.workspaceConfig\n ),\n loadEnvDirectory<TEnv>(\n options,\n context.workspaceConfig.workspaceRoot,\n context.config.mode,\n context.cachePath,\n context.packageJson,\n context.workspaceConfig\n ),\n loadEnvDirectory<TEnv>(\n options,\n context.envPaths.config,\n context.config.mode,\n context.cachePath,\n context.packageJson,\n context.workspaceConfig\n )\n ]);\n\n return defu(\n loadEnvFromContext(context, process.env),\n project,\n workspace,\n config\n ) as TEnv;\n}\n"],"mappings":";;;;;;;;;;;;AAMA,SAAS,aAAY,IAAI,MAAO;AAC5B,IAAC,SAAU;;;AA4Bf,eAAW,aAAgB,SAAA,MAAA,KAAA;CACzB,IAAM,MAAM,MAAA,UAAA,KAAA,KAAA;AACZ,KAAK,QAAA,mBAAA,QAAA,iBAAA,SAAA,GAAA;EACJ,MAAQ,qBAAM,MAAA,QAAA,IAAA,QAAA,gBAAA,IAAA,aAAA,OAAA,sBAAA,YAAA,mBAAA,IAAA,EAAA;GAAA;GAAA;GAAA;GAAA,CAAA,C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virtual/_rolldown/runtime.cjs');
3
+ const require_types_plugin = require('../types/plugin.cjs');
3
4
  const require_helpers_reflect = require('./reflect.cjs');
5
+ let _powerlines_deepkit_vendor_type = require("@powerlines/deepkit/vendor/type");
6
+ let powerlines = require("powerlines");
4
7
  let _powerlines_deepkit_capnp = require("@powerlines/deepkit/capnp");
5
8
  let _powerlines_deepkit_resolve_reflections = require("@powerlines/deepkit/resolve-reflections");
6
9
  let _powerlines_deepkit_schemas_reflection = require("@powerlines/deepkit/schemas/reflection");
7
- let _powerlines_deepkit_vendor_type = require("@powerlines/deepkit/vendor/type");
8
10
  let _stryke_capnp = require("@stryke/capnp");
9
11
  _stryke_capnp = require_runtime.__toESM(_stryke_capnp);
10
12
  let _stryke_fs_buffer = require("@stryke/fs/buffer");
@@ -24,6 +26,14 @@ async function resolveRuntimeTypeFile(context) {
24
26
  if (!resolved) throw new Error(`Failed to resolve the runtime type definition file for the environment variables. Please ensure that the "@powerlines/plugin-env" package is installed.`);
25
27
  return resolved;
26
28
  }
29
+ resolveRuntimeTypeFile.__type = [
30
+ () => powerlines.__ΩUnresolvedContext,
31
+ () => require_types_plugin.__ΩEnvPluginResolvedConfig,
32
+ "context",
33
+ "resolveRuntimeTypeFile",
34
+ "Resolves the runtime type definition file for the environment variables.",
35
+ "Pn\"o!\"2#&`/$?%"
36
+ ];
27
37
  /**
28
38
  * Gets the default type definition for the environment variables.
29
39
  *
@@ -36,6 +46,14 @@ async function getEnvDefaultTypeDefinition(context) {
36
46
  name: "EnvInterface"
37
47
  };
38
48
  }
49
+ getEnvDefaultTypeDefinition.__type = [
50
+ () => powerlines.__ΩUnresolvedContext,
51
+ () => require_types_plugin.__ΩEnvPluginResolvedConfig,
52
+ "context",
53
+ "getEnvDefaultTypeDefinition",
54
+ "Gets the default type definition for the environment variables.",
55
+ "Pn\"o!\"2#!`/$?%"
56
+ ];
39
57
  /** Gets the default type definition for the environment secrets.
40
58
  *
41
59
  * @param context - The plugin context.
@@ -47,6 +65,13 @@ async function getSecretsDefaultTypeDefinition(context) {
47
65
  name: "SecretsInterface"
48
66
  };
49
67
  }
68
+ getSecretsDefaultTypeDefinition.__type = [
69
+ () => powerlines.__ΩUnresolvedContext,
70
+ () => require_types_plugin.__ΩEnvPluginResolvedConfig,
71
+ "context",
72
+ "getSecretsDefaultTypeDefinition",
73
+ "Pn\"o!\"2#!`/$"
74
+ ];
50
75
  /**
51
76
  * Gets the path to the environment type reflections.
52
77
  *
@@ -57,6 +82,17 @@ async function getSecretsDefaultTypeDefinition(context) {
57
82
  function getEnvTypeReflectionsPath(context, name = "env") {
58
83
  return (0, _stryke_path_join_paths.joinPaths)((0, _powerlines_deepkit_resolve_reflections.getReflectionsPath)(context), "env", `${name}-types.bin`);
59
84
  }
85
+ getEnvTypeReflectionsPath.__type = [
86
+ () => powerlines.__ΩContext,
87
+ () => require_types_plugin.__ΩEnvPluginResolvedConfig,
88
+ "context",
89
+ () => require_types_plugin.__ΩEnvType,
90
+ "name",
91
+ () => "env",
92
+ "getEnvTypeReflectionsPath",
93
+ "Gets the path to the environment type reflections.",
94
+ "Pn\"o!\"2#n$2%>&&/'?("
95
+ ];
60
96
  /**
61
97
  * Reads the environment type reflection from the file system.
62
98
  *
@@ -85,6 +121,17 @@ async function readEnvTypeReflection(context, name = "env") {
85
121
  context.env.types[name].dataBuffer = buffer;
86
122
  return reflection;
87
123
  }
124
+ readEnvTypeReflection.__type = [
125
+ () => require_types_plugin.__ΩEnvPluginContext,
126
+ "context",
127
+ () => require_types_plugin.__ΩEnvType,
128
+ "name",
129
+ () => "env",
130
+ () => _powerlines_deepkit_vendor_type.ReflectionClass,
131
+ "readEnvTypeReflection",
132
+ "Reads the environment type reflection from the file system.",
133
+ "Pn!2\"n#2$>%P\"7&`/'?("
134
+ ];
88
135
  /**
89
136
  * Writes the environment type reflection to the file system.
90
137
  *
@@ -98,9 +145,29 @@ async function writeEnvTypeReflection(context, reflection, name = "env") {
98
145
  (0, _powerlines_deepkit_capnp.convertToCapnp)(serialized, message.initRoot(_powerlines_deepkit_schemas_reflection.SerializedTypes)._initTypes(serialized.length));
99
146
  await (0, _stryke_fs_buffer.writeFileBuffer)(getEnvTypeReflectionsPath(context, name), message.toArrayBuffer());
100
147
  }
148
+ writeEnvTypeReflection.__type = [
149
+ () => require_types_plugin.__ΩEnvPluginContext,
150
+ "context",
151
+ () => _powerlines_deepkit_vendor_type.ReflectionClass,
152
+ "reflection",
153
+ () => require_types_plugin.__ΩEnvType,
154
+ "name",
155
+ () => "env",
156
+ "writeEnvTypeReflection",
157
+ "Writes the environment type reflection to the file system.",
158
+ "Pn!2\"P\"7#2$n%2&>'\"/(?)"
159
+ ];
101
160
  function getEnvReflectionsPath(context, name) {
102
161
  return (0, _stryke_path_join_paths.joinPaths)((0, _powerlines_deepkit_resolve_reflections.getReflectionsPath)(context), "env", `${name}.bin`);
103
162
  }
163
+ getEnvReflectionsPath.__type = [
164
+ () => require_types_plugin.__ΩEnvPluginContext,
165
+ "context",
166
+ () => require_types_plugin.__ΩEnvType,
167
+ "name",
168
+ "getEnvReflectionsPath",
169
+ "Pn!2\"n#2$&/%"
170
+ ];
104
171
  /**
105
172
  * Reads the environment reflection data from the file system.
106
173
  *
@@ -138,6 +205,14 @@ async function readEnvReflection(context) {
138
205
  context.env.used.env.dataBuffer = buffer;
139
206
  return reflection;
140
207
  }
208
+ readEnvReflection.__type = [
209
+ () => require_types_plugin.__ΩEnvPluginContext,
210
+ "context",
211
+ () => _powerlines_deepkit_vendor_type.ReflectionClass,
212
+ "readEnvReflection",
213
+ "Reads the environment reflection data from the file system.",
214
+ "Pn!2\"P\"7#`/$?%"
215
+ ];
141
216
  /**
142
217
  * Reads the secret environment reflection data from the file system.
143
218
  *
@@ -175,6 +250,14 @@ async function readSecretsReflection(context) {
175
250
  context.env.used.secrets.dataBuffer = buffer;
176
251
  return reflection;
177
252
  }
253
+ readSecretsReflection.__type = [
254
+ () => require_types_plugin.__ΩEnvPluginContext,
255
+ "context",
256
+ () => _powerlines_deepkit_vendor_type.ReflectionClass,
257
+ "readSecretsReflection",
258
+ "Reads the secret environment reflection data from the file system.",
259
+ "Pn!2\"P\"7#`/$?%"
260
+ ];
178
261
  /**
179
262
  * Writes the environment reflection data to the file system.
180
263
  *
@@ -188,6 +271,18 @@ async function writeEnvReflection(context, reflection, name = "env") {
188
271
  (0, _powerlines_deepkit_capnp.convertToCapnp)(serialized, message.initRoot(_powerlines_deepkit_schemas_reflection.SerializedTypes)._initTypes(serialized.length));
189
272
  await (0, _stryke_fs_buffer.writeFileBuffer)(getEnvReflectionsPath(context, name), message.toArrayBuffer());
190
273
  }
274
+ writeEnvReflection.__type = [
275
+ () => require_types_plugin.__ΩEnvPluginContext,
276
+ "context",
277
+ () => _powerlines_deepkit_vendor_type.ReflectionClass,
278
+ "reflection",
279
+ () => require_types_plugin.__ΩEnvType,
280
+ "name",
281
+ () => "env",
282
+ "writeEnvReflection",
283
+ "Writes the environment reflection data to the file system.",
284
+ "Pn!2\"P\"7#2$n%2&>'\"/(?)"
285
+ ];
191
286
  /**
192
287
  * Writes the environment reflection data to the file system.
193
288
  *
@@ -201,6 +296,18 @@ function writeEnvReflectionSync(context, reflection, name = "env") {
201
296
  (0, _powerlines_deepkit_capnp.convertToCapnp)(serialized, message.initRoot(_powerlines_deepkit_schemas_reflection.SerializedTypes)._initTypes(serialized.length));
202
297
  (0, _stryke_fs_buffer.writeFileBufferSync)(getEnvReflectionsPath(context, name), message.toArrayBuffer());
203
298
  }
299
+ writeEnvReflectionSync.__type = [
300
+ () => require_types_plugin.__ΩEnvPluginContext,
301
+ "context",
302
+ () => _powerlines_deepkit_vendor_type.ReflectionClass,
303
+ "reflection",
304
+ () => require_types_plugin.__ΩEnvType,
305
+ "name",
306
+ () => "env",
307
+ "writeEnvReflectionSync",
308
+ "Writes the environment reflection data to the file system.",
309
+ "Pn!2\"P\"7#2$n%2&>'\"/(?)"
310
+ ];
204
311
 
205
312
  //#endregion
206
313
  exports.getEnvDefaultTypeDefinition = getEnvDefaultTypeDefinition;
@@ -1,8 +1,10 @@
1
+ import { __ΩEnvPluginContext, __ΩEnvPluginResolvedConfig, __ΩEnvType } from "../types/plugin.mjs";
1
2
  import { createEnvReflection } from "./reflect.mjs";
3
+ import { ReflectionClass, ReflectionKind, deserializeType, resolveClassType } from "@powerlines/deepkit/vendor/type";
4
+ import { __ΩContext, __ΩUnresolvedContext } from "powerlines";
2
5
  import { convertFromCapnp, convertToCapnp } from "@powerlines/deepkit/capnp";
3
6
  import { getReflectionsPath } from "@powerlines/deepkit/resolve-reflections";
4
7
  import { SerializedTypes } from "@powerlines/deepkit/schemas/reflection";
5
- import { ReflectionKind, deserializeType, resolveClassType } from "@powerlines/deepkit/vendor/type";
6
8
  import * as capnp from "@stryke/capnp";
7
9
  import { readFileBuffer, writeFileBuffer, writeFileBufferSync } from "@stryke/fs/buffer";
8
10
  import { joinPaths } from "@stryke/path/join-paths";
@@ -21,6 +23,14 @@ async function resolveRuntimeTypeFile(context) {
21
23
  if (!resolved) throw new Error(`Failed to resolve the runtime type definition file for the environment variables. Please ensure that the "@powerlines/plugin-env" package is installed.`);
22
24
  return resolved;
23
25
  }
26
+ resolveRuntimeTypeFile.__type = [
27
+ () => __ΩUnresolvedContext,
28
+ () => __ΩEnvPluginResolvedConfig,
29
+ "context",
30
+ "resolveRuntimeTypeFile",
31
+ "Resolves the runtime type definition file for the environment variables.",
32
+ "Pn\"o!\"2#&`/$?%"
33
+ ];
24
34
  /**
25
35
  * Gets the default type definition for the environment variables.
26
36
  *
@@ -33,6 +43,14 @@ async function getEnvDefaultTypeDefinition(context) {
33
43
  name: "EnvInterface"
34
44
  };
35
45
  }
46
+ getEnvDefaultTypeDefinition.__type = [
47
+ () => __ΩUnresolvedContext,
48
+ () => __ΩEnvPluginResolvedConfig,
49
+ "context",
50
+ "getEnvDefaultTypeDefinition",
51
+ "Gets the default type definition for the environment variables.",
52
+ "Pn\"o!\"2#!`/$?%"
53
+ ];
36
54
  /** Gets the default type definition for the environment secrets.
37
55
  *
38
56
  * @param context - The plugin context.
@@ -44,6 +62,13 @@ async function getSecretsDefaultTypeDefinition(context) {
44
62
  name: "SecretsInterface"
45
63
  };
46
64
  }
65
+ getSecretsDefaultTypeDefinition.__type = [
66
+ () => __ΩUnresolvedContext,
67
+ () => __ΩEnvPluginResolvedConfig,
68
+ "context",
69
+ "getSecretsDefaultTypeDefinition",
70
+ "Pn\"o!\"2#!`/$"
71
+ ];
47
72
  /**
48
73
  * Gets the path to the environment type reflections.
49
74
  *
@@ -54,6 +79,17 @@ async function getSecretsDefaultTypeDefinition(context) {
54
79
  function getEnvTypeReflectionsPath(context, name = "env") {
55
80
  return joinPaths(getReflectionsPath(context), "env", `${name}-types.bin`);
56
81
  }
82
+ getEnvTypeReflectionsPath.__type = [
83
+ () => __ΩContext,
84
+ () => __ΩEnvPluginResolvedConfig,
85
+ "context",
86
+ () => __ΩEnvType,
87
+ "name",
88
+ () => "env",
89
+ "getEnvTypeReflectionsPath",
90
+ "Gets the path to the environment type reflections.",
91
+ "Pn\"o!\"2#n$2%>&&/'?("
92
+ ];
57
93
  /**
58
94
  * Reads the environment type reflection from the file system.
59
95
  *
@@ -82,6 +118,17 @@ async function readEnvTypeReflection(context, name = "env") {
82
118
  context.env.types[name].dataBuffer = buffer;
83
119
  return reflection;
84
120
  }
121
+ readEnvTypeReflection.__type = [
122
+ () => __ΩEnvPluginContext,
123
+ "context",
124
+ () => __ΩEnvType,
125
+ "name",
126
+ () => "env",
127
+ () => ReflectionClass,
128
+ "readEnvTypeReflection",
129
+ "Reads the environment type reflection from the file system.",
130
+ "Pn!2\"n#2$>%P\"7&`/'?("
131
+ ];
85
132
  /**
86
133
  * Writes the environment type reflection to the file system.
87
134
  *
@@ -95,9 +142,29 @@ async function writeEnvTypeReflection(context, reflection, name = "env") {
95
142
  convertToCapnp(serialized, message.initRoot(SerializedTypes)._initTypes(serialized.length));
96
143
  await writeFileBuffer(getEnvTypeReflectionsPath(context, name), message.toArrayBuffer());
97
144
  }
145
+ writeEnvTypeReflection.__type = [
146
+ () => __ΩEnvPluginContext,
147
+ "context",
148
+ () => ReflectionClass,
149
+ "reflection",
150
+ () => __ΩEnvType,
151
+ "name",
152
+ () => "env",
153
+ "writeEnvTypeReflection",
154
+ "Writes the environment type reflection to the file system.",
155
+ "Pn!2\"P\"7#2$n%2&>'\"/(?)"
156
+ ];
98
157
  function getEnvReflectionsPath(context, name) {
99
158
  return joinPaths(getReflectionsPath(context), "env", `${name}.bin`);
100
159
  }
160
+ getEnvReflectionsPath.__type = [
161
+ () => __ΩEnvPluginContext,
162
+ "context",
163
+ () => __ΩEnvType,
164
+ "name",
165
+ "getEnvReflectionsPath",
166
+ "Pn!2\"n#2$&/%"
167
+ ];
101
168
  /**
102
169
  * Reads the environment reflection data from the file system.
103
170
  *
@@ -135,6 +202,14 @@ async function readEnvReflection(context) {
135
202
  context.env.used.env.dataBuffer = buffer;
136
203
  return reflection;
137
204
  }
205
+ readEnvReflection.__type = [
206
+ () => __ΩEnvPluginContext,
207
+ "context",
208
+ () => ReflectionClass,
209
+ "readEnvReflection",
210
+ "Reads the environment reflection data from the file system.",
211
+ "Pn!2\"P\"7#`/$?%"
212
+ ];
138
213
  /**
139
214
  * Reads the secret environment reflection data from the file system.
140
215
  *
@@ -172,6 +247,14 @@ async function readSecretsReflection(context) {
172
247
  context.env.used.secrets.dataBuffer = buffer;
173
248
  return reflection;
174
249
  }
250
+ readSecretsReflection.__type = [
251
+ () => __ΩEnvPluginContext,
252
+ "context",
253
+ () => ReflectionClass,
254
+ "readSecretsReflection",
255
+ "Reads the secret environment reflection data from the file system.",
256
+ "Pn!2\"P\"7#`/$?%"
257
+ ];
175
258
  /**
176
259
  * Writes the environment reflection data to the file system.
177
260
  *
@@ -185,6 +268,18 @@ async function writeEnvReflection(context, reflection, name = "env") {
185
268
  convertToCapnp(serialized, message.initRoot(SerializedTypes)._initTypes(serialized.length));
186
269
  await writeFileBuffer(getEnvReflectionsPath(context, name), message.toArrayBuffer());
187
270
  }
271
+ writeEnvReflection.__type = [
272
+ () => __ΩEnvPluginContext,
273
+ "context",
274
+ () => ReflectionClass,
275
+ "reflection",
276
+ () => __ΩEnvType,
277
+ "name",
278
+ () => "env",
279
+ "writeEnvReflection",
280
+ "Writes the environment reflection data to the file system.",
281
+ "Pn!2\"P\"7#2$n%2&>'\"/(?)"
282
+ ];
188
283
  /**
189
284
  * Writes the environment reflection data to the file system.
190
285
  *
@@ -198,6 +293,18 @@ function writeEnvReflectionSync(context, reflection, name = "env") {
198
293
  convertToCapnp(serialized, message.initRoot(SerializedTypes)._initTypes(serialized.length));
199
294
  writeFileBufferSync(getEnvReflectionsPath(context, name), message.toArrayBuffer());
200
295
  }
296
+ writeEnvReflectionSync.__type = [
297
+ () => __ΩEnvPluginContext,
298
+ "context",
299
+ () => ReflectionClass,
300
+ "reflection",
301
+ () => __ΩEnvType,
302
+ "name",
303
+ () => "env",
304
+ "writeEnvReflectionSync",
305
+ "Writes the environment reflection data to the file system.",
306
+ "Pn!2\"P\"7#2$n%2&>'\"/(?)"
307
+ ];
201
308
 
202
309
  //#endregion
203
310
  export { getEnvDefaultTypeDefinition, getEnvReflectionsPath, getEnvTypeReflectionsPath, getSecretsDefaultTypeDefinition, readEnvReflection, readEnvTypeReflection, readSecretsReflection, resolveRuntimeTypeFile, writeEnvReflection, writeEnvReflectionSync, writeEnvTypeReflection };