@powerlines/plugin-react 0.1.122 → 0.1.123

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 (100) hide show
  1. package/dist/_virtual/rolldown_runtime.cjs +37 -1
  2. package/dist/_virtual/rolldown_runtime.mjs +29 -1
  3. package/dist/components/index.cjs +3 -1
  4. package/dist/components/index.mjs +3 -1
  5. package/dist/components/react-optimized.cjs +45 -1
  6. package/dist/components/react-optimized.mjs +43 -1
  7. package/dist/deepkit/schemas/reflection.cjs +3940 -1
  8. package/dist/deepkit/schemas/reflection.mjs +3938 -1
  9. package/dist/deepkit/schemas/reflection2.cjs +4112 -1
  10. package/dist/deepkit/schemas/reflection2.mjs +4110 -1
  11. package/dist/deepkit/src/capnp.cjs +913 -1
  12. package/dist/deepkit/src/capnp.mjs +911 -1
  13. package/dist/deepkit/src/esbuild-plugin.cjs +47 -4
  14. package/dist/deepkit/src/esbuild-plugin.mjs +46 -4
  15. package/dist/deepkit/src/reflect-type.cjs +22 -1
  16. package/dist/deepkit/src/reflect-type.mjs +20 -1
  17. package/dist/deepkit/src/resolve-reflections.cjs +16 -1
  18. package/dist/deepkit/src/resolve-reflections.mjs +15 -1
  19. package/dist/deepkit/src/transformer.cjs +52 -1
  20. package/dist/deepkit/src/transformer.mjs +49 -1
  21. package/dist/deepkit/src/transpile.cjs +29 -1
  22. package/dist/deepkit/src/transpile.mjs +27 -1
  23. package/dist/deepkit/src/utilities.cjs +66 -1
  24. package/dist/deepkit/src/utilities.mjs +65 -1
  25. package/dist/deepkit/src/vendor/type-compiler/index.cjs +38 -1
  26. package/dist/deepkit/src/vendor/type-compiler/index.mjs +19 -1
  27. package/dist/deepkit/src/vendor/type.cjs +20 -1
  28. package/dist/deepkit/src/vendor/type.mjs +11 -1
  29. package/dist/index.cjs +104 -1
  30. package/dist/index.mjs +98 -1
  31. package/dist/plugin-alloy/src/core/components/output.cjs +45 -1
  32. package/dist/plugin-alloy/src/core/components/output.mjs +44 -1
  33. package/dist/plugin-alloy/src/core/contexts/context.cjs +11 -1
  34. package/dist/plugin-alloy/src/core/contexts/context.mjs +10 -1
  35. package/dist/plugin-alloy/src/index.cjs +93 -1
  36. package/dist/plugin-alloy/src/index.mjs +91 -1
  37. package/dist/plugin-automd/src/index.cjs +101 -1
  38. package/dist/plugin-automd/src/index.mjs +98 -1
  39. package/dist/plugin-babel/src/helpers/ast-utils.cjs +10 -1
  40. package/dist/plugin-babel/src/helpers/ast-utils.mjs +9 -1
  41. package/dist/plugin-babel/src/helpers/create-plugin.cjs +41 -1
  42. package/dist/plugin-babel/src/helpers/create-plugin.mjs +39 -1
  43. package/dist/plugin-babel/src/helpers/filters.cjs +23 -1
  44. package/dist/plugin-babel/src/helpers/filters.mjs +21 -1
  45. package/dist/plugin-babel/src/helpers/index.cjs +5 -1
  46. package/dist/plugin-babel/src/helpers/index.mjs +7 -1
  47. package/dist/plugin-babel/src/helpers/module-helpers.cjs +38 -1
  48. package/dist/plugin-babel/src/helpers/module-helpers.mjs +35 -1
  49. package/dist/plugin-babel/src/helpers/options.cjs +50 -1
  50. package/dist/plugin-babel/src/helpers/options.mjs +47 -1
  51. package/dist/plugin-babel/src/index.cjs +91 -1
  52. package/dist/plugin-babel/src/index.mjs +89 -1
  53. package/dist/plugin-env/src/babel/index.cjs +1 -1
  54. package/dist/plugin-env/src/babel/index.mjs +3 -1
  55. package/dist/plugin-env/src/babel/plugin.cjs +120 -4
  56. package/dist/plugin-env/src/babel/plugin.mjs +118 -4
  57. package/dist/plugin-env/src/components/docs.cjs +9 -1
  58. package/dist/plugin-env/src/components/docs.mjs +11 -1
  59. package/dist/plugin-env/src/components/env.cjs +432 -11
  60. package/dist/plugin-env/src/components/env.mjs +430 -9
  61. package/dist/plugin-env/src/components/index.cjs +2 -1
  62. package/dist/plugin-env/src/components/index.mjs +4 -1
  63. package/dist/plugin-env/src/helpers/automd-generator.cjs +22 -1
  64. package/dist/plugin-env/src/helpers/automd-generator.mjs +21 -1
  65. package/dist/plugin-env/src/helpers/create-reflection-resource.cjs +55 -1
  66. package/dist/plugin-env/src/helpers/create-reflection-resource.mjs +54 -1
  67. package/dist/plugin-env/src/helpers/index.cjs +6 -1
  68. package/dist/plugin-env/src/helpers/index.mjs +8 -1
  69. package/dist/plugin-env/src/helpers/load.cjs +83 -1
  70. package/dist/plugin-env/src/helpers/load.mjs +80 -1
  71. package/dist/plugin-env/src/helpers/persistence.cjs +200 -1
  72. package/dist/plugin-env/src/helpers/persistence.mjs +189 -1
  73. package/dist/plugin-env/src/helpers/reflect.cjs +111 -1
  74. package/dist/plugin-env/src/helpers/reflect.mjs +103 -1
  75. package/dist/plugin-env/src/helpers/source-file-env.cjs +24 -1
  76. package/dist/plugin-env/src/helpers/source-file-env.mjs +23 -1
  77. package/dist/plugin-env/src/helpers/template-helpers.cjs +2 -1
  78. package/dist/plugin-env/src/helpers/template-helpers.mjs +4 -1
  79. package/dist/plugin-env/src/index.cjs +170 -5
  80. package/dist/plugin-env/src/index.mjs +168 -5
  81. package/dist/powerlines/src/lib/build/esbuild.cjs +102 -14
  82. package/dist/powerlines/src/lib/build/esbuild.mjs +100 -14
  83. package/dist/powerlines/src/lib/entry.cjs +12 -1
  84. package/dist/powerlines/src/lib/entry.mjs +14 -1
  85. package/dist/powerlines/src/lib/logger.cjs +41 -1
  86. package/dist/powerlines/src/lib/logger.mjs +39 -1
  87. package/dist/powerlines/src/lib/typescript/tsconfig.cjs +38 -1
  88. package/dist/powerlines/src/lib/typescript/tsconfig.mjs +35 -1
  89. package/dist/powerlines/src/lib/utilities/bundle.cjs +35 -1
  90. package/dist/powerlines/src/lib/utilities/bundle.mjs +34 -1
  91. package/dist/powerlines/src/lib/utilities/resolve.cjs +30 -1
  92. package/dist/powerlines/src/lib/utilities/resolve.mjs +29 -1
  93. package/dist/powerlines/src/plugin-utils/paths.cjs +1 -1
  94. package/dist/powerlines/src/plugin-utils/paths.mjs +3 -1
  95. package/dist/powerlines/src/types/context.d.cts +27 -3
  96. package/dist/powerlines/src/types/context.d.mts +27 -3
  97. package/dist/types/index.mjs +1 -1
  98. package/dist/types/plugin.mjs +1 -1
  99. package/dist/types/runtime.mjs +1 -1
  100. package/package.json +10 -10
@@ -1 +1,83 @@
1
- const e=require(`../../../_virtual/rolldown_runtime.cjs`),t=require(`./source-file-env.cjs`);let n=require(`@stryke/type-checks/is-set-object`),r=require(`defu`);r=e.__toESM(r);let i=require(`@stryke/type-checks/is-set-string`),a=require(`@stryke/string-format/kebab-case`),o=require(`@stryke/path/join-paths`),s=require(`c12`),c=require(`@stryke/env/load-env`);async function l(e,n,i){let a=await(0,c.loadEnv)(i,n);if(e.additionalFiles&&e.additionalFiles?.length>0){let t=await Promise.all(e.additionalFiles.map(async e=>(0,c.loadEnvFile)(e,i)));for(let e of t)a=(0,r.default)(e,a)}return t.removeEnvPrefix(a)}async function u(e,t,n,i,a,c){let[u,d]=await Promise.all([l(e,n,t),(0,s.loadConfig)({cwd:t,name:`storm`,envName:n,defaults:{NAME:a.name?.replace(`@${c.namespace}/`,``),MODE:n,ORG:c.organization},globalRc:!0,packageJson:!0,dotenv:!0,jitiOptions:{fsCache:(0,o.joinPaths)(i,`jiti`),moduleCache:!0}})]);return(0,r.default)(u,d.config,c)}function d(e,t){return(0,r.default)({APP_NAME:(0,a.kebabCase)(e.config.name||e.packageJson.name?.replace(`/${e.workspaceConfig.namespace}`,``)),APP_VERSION:e.packageJson.version,BUILD_ID:e.meta.buildId,BUILD_TIMESTAMP:new Date(e.meta.timestamp).toISOString(),BUILD_CHECKSUM:e.meta.checksum,RELEASE_ID:e.meta.releaseId,RELEASE_TAG:`${(0,a.kebabCase)(e.config.name)}@${e.packageJson.version}`,DEFAULT_LOCALE:e.workspaceConfig.locale,DEFAULT_TIMEZONE:e.workspaceConfig.timezone,LOG_LEVEL:e.config.logLevel,ERROR_URL:e.workspaceConfig.error?.url,ORGANIZATION:(0,i.isSetString)(e.workspaceConfig.organization)?e.workspaceConfig.organization:e.workspaceConfig.organization?.name,PLATFORM:e.config.build.platform,MODE:e.workspaceConfig.mode,DEBUG:e.workspaceConfig.mode===`development`,STACKTRACE:e.workspaceConfig.mode===`development`,ENVIRONMENT:e.environment},(0,n.isSetObject)(e?.env?.types?.env)?e.env.types.env?.getProperties().reduce((e,n)=>(e[n.name]=t[n.name]??n.getDefaultValue(),e),{}):{})}async function f(e,t){let[n,i,a]=await Promise.all([u(t,e.config.projectRoot,e.config.mode,e.cachePath,e.packageJson,e.workspaceConfig),u(t,e.workspaceConfig.workspaceRoot,e.config.mode,e.cachePath,e.packageJson,e.workspaceConfig),u(t,e.envPaths.config,e.config.mode,e.cachePath,e.packageJson,e.workspaceConfig)]);return(0,r.default)(d(e,process.env),n,i,a)}exports.loadEnv=f,exports.loadEnvFromContext=d;
1
+ const require_rolldown_runtime = require('../../../_virtual/rolldown_runtime.cjs');
2
+ const require_source_file_env = require('./source-file-env.cjs');
3
+ let __stryke_type_checks_is_set_object = require("@stryke/type-checks/is-set-object");
4
+ let defu = require("defu");
5
+ defu = require_rolldown_runtime.__toESM(defu);
6
+ let __stryke_type_checks_is_set_string = require("@stryke/type-checks/is-set-string");
7
+ let __stryke_string_format_kebab_case = require("@stryke/string-format/kebab-case");
8
+ let __stryke_path_join_paths = require("@stryke/path/join-paths");
9
+ let c12 = require("c12");
10
+ let __stryke_env_load_env = require("@stryke/env/load-env");
11
+
12
+ //#region ../plugin-env/src/helpers/load.ts
13
+ async function loadEnvFiles(options, mode, cwd) {
14
+ let env = await (0, __stryke_env_load_env.loadEnv)(cwd, mode);
15
+ if (options.additionalFiles && options.additionalFiles?.length > 0) {
16
+ const additionalEnvFiles = await Promise.all(options.additionalFiles.map(async (additionalEnvFile) => (0, __stryke_env_load_env.loadEnvFile)(additionalEnvFile, cwd)));
17
+ for (const additionalEnvFile of additionalEnvFiles) env = (0, defu.default)(additionalEnvFile, env);
18
+ }
19
+ return require_source_file_env.removeEnvPrefix(env);
20
+ }
21
+ async function loadEnvDirectory(options, directory, mode, cacheDir, packageJson, workspaceConfig) {
22
+ const [envResult, c12Result] = await Promise.all([loadEnvFiles(options, mode, directory), (0, c12.loadConfig)({
23
+ cwd: directory,
24
+ name: "storm",
25
+ envName: mode,
26
+ defaults: {
27
+ NAME: packageJson.name?.replace(`@${workspaceConfig.namespace}/`, ""),
28
+ MODE: mode,
29
+ ORG: workspaceConfig.organization
30
+ },
31
+ globalRc: true,
32
+ packageJson: true,
33
+ dotenv: true,
34
+ jitiOptions: {
35
+ fsCache: (0, __stryke_path_join_paths.joinPaths)(cacheDir, "jiti"),
36
+ moduleCache: true
37
+ }
38
+ })]);
39
+ return (0, defu.default)(envResult, c12Result.config, workspaceConfig);
40
+ }
41
+ /**
42
+ * Retrieves various dotenv configuration parameters from the context.
43
+ *
44
+ * @param context - The context to retrieve the dotenv configuration from.
45
+ * @param parsed - The parsed dotenv configuration.
46
+ * @returns An object containing the dotenv configuration.
47
+ */
48
+ function loadEnvFromContext(context, parsed) {
49
+ return (0, defu.default)({
50
+ APP_NAME: (0, __stryke_string_format_kebab_case.kebabCase)(context.config.name || context.packageJson.name?.replace(`/${context.workspaceConfig.namespace}`, "")),
51
+ APP_VERSION: context.packageJson.version,
52
+ BUILD_ID: context.meta.buildId,
53
+ BUILD_TIMESTAMP: new Date(context.meta.timestamp).toISOString(),
54
+ BUILD_CHECKSUM: context.meta.checksum,
55
+ RELEASE_ID: context.meta.releaseId,
56
+ RELEASE_TAG: `${(0, __stryke_string_format_kebab_case.kebabCase)(context.config.name)}@${context.packageJson.version}`,
57
+ DEFAULT_LOCALE: context.workspaceConfig.locale,
58
+ DEFAULT_TIMEZONE: context.workspaceConfig.timezone,
59
+ LOG_LEVEL: context.config.logLevel,
60
+ ERROR_URL: context.workspaceConfig.error?.url,
61
+ ORGANIZATION: (0, __stryke_type_checks_is_set_string.isSetString)(context.workspaceConfig.organization) ? context.workspaceConfig.organization : context.workspaceConfig.organization?.name,
62
+ PLATFORM: context.config.build.platform,
63
+ MODE: context.workspaceConfig.mode,
64
+ DEBUG: context.workspaceConfig.mode === "development",
65
+ STACKTRACE: context.workspaceConfig.mode === "development",
66
+ ENVIRONMENT: context.environment
67
+ }, (0, __stryke_type_checks_is_set_object.isSetObject)(context?.env?.types?.env) ? context.env.types.env?.getProperties().reduce((ret, prop) => {
68
+ ret[prop.name] = parsed[prop.name] ?? prop.getDefaultValue();
69
+ return ret;
70
+ }, {}) : {});
71
+ }
72
+ async function loadEnv(context, options) {
73
+ const [project, workspace, config] = await Promise.all([
74
+ loadEnvDirectory(options, context.config.projectRoot, context.config.mode, context.cachePath, context.packageJson, context.workspaceConfig),
75
+ loadEnvDirectory(options, context.workspaceConfig.workspaceRoot, context.config.mode, context.cachePath, context.packageJson, context.workspaceConfig),
76
+ loadEnvDirectory(options, context.envPaths.config, context.config.mode, context.cachePath, context.packageJson, context.workspaceConfig)
77
+ ]);
78
+ return (0, defu.default)(loadEnvFromContext(context, process.env), project, workspace, config);
79
+ }
80
+
81
+ //#endregion
82
+ exports.loadEnv = loadEnv;
83
+ exports.loadEnvFromContext = loadEnvFromContext;
@@ -1 +1,80 @@
1
- import{removeEnvPrefix as e}from"./source-file-env.mjs";import{isSetObject as t}from"@stryke/type-checks/is-set-object";import n from"defu";import{isSetString as r}from"@stryke/type-checks/is-set-string";import{kebabCase as i}from"@stryke/string-format/kebab-case";import{joinPaths as a}from"@stryke/path/join-paths";import{loadConfig as o}from"c12";import{loadEnv as s,loadEnvFile as c}from"@stryke/env/load-env";async function l(t,r,i){let a=await s(i,r);if(t.additionalFiles&&t.additionalFiles?.length>0){let e=await Promise.all(t.additionalFiles.map(async e=>c(e,i)));for(let t of e)a=n(t,a)}return e(a)}async function u(e,t,r,i,s,c){let[u,d]=await Promise.all([l(e,r,t),o({cwd:t,name:`storm`,envName:r,defaults:{NAME:s.name?.replace(`@${c.namespace}/`,``),MODE:r,ORG:c.organization},globalRc:!0,packageJson:!0,dotenv:!0,jitiOptions:{fsCache:a(i,`jiti`),moduleCache:!0}})]);return n(u,d.config,c)}function d(e,a){return n({APP_NAME:i(e.config.name||e.packageJson.name?.replace(`/${e.workspaceConfig.namespace}`,``)),APP_VERSION:e.packageJson.version,BUILD_ID:e.meta.buildId,BUILD_TIMESTAMP:new Date(e.meta.timestamp).toISOString(),BUILD_CHECKSUM:e.meta.checksum,RELEASE_ID:e.meta.releaseId,RELEASE_TAG:`${i(e.config.name)}@${e.packageJson.version}`,DEFAULT_LOCALE:e.workspaceConfig.locale,DEFAULT_TIMEZONE:e.workspaceConfig.timezone,LOG_LEVEL:e.config.logLevel,ERROR_URL:e.workspaceConfig.error?.url,ORGANIZATION:r(e.workspaceConfig.organization)?e.workspaceConfig.organization:e.workspaceConfig.organization?.name,PLATFORM:e.config.build.platform,MODE:e.workspaceConfig.mode,DEBUG:e.workspaceConfig.mode===`development`,STACKTRACE:e.workspaceConfig.mode===`development`,ENVIRONMENT:e.environment},t(e?.env?.types?.env)?e.env.types.env?.getProperties().reduce((e,t)=>(e[t.name]=a[t.name]??t.getDefaultValue(),e),{}):{})}async function f(e,t){let[r,i,a]=await Promise.all([u(t,e.config.projectRoot,e.config.mode,e.cachePath,e.packageJson,e.workspaceConfig),u(t,e.workspaceConfig.workspaceRoot,e.config.mode,e.cachePath,e.packageJson,e.workspaceConfig),u(t,e.envPaths.config,e.config.mode,e.cachePath,e.packageJson,e.workspaceConfig)]);return n(d(e,process.env),r,i,a)}export{f as loadEnv,d as loadEnvFromContext};
1
+ import { removeEnvPrefix } from "./source-file-env.mjs";
2
+ import { isSetObject } from "@stryke/type-checks/is-set-object";
3
+ import defu from "defu";
4
+ import { isSetString } from "@stryke/type-checks/is-set-string";
5
+ import { kebabCase } from "@stryke/string-format/kebab-case";
6
+ import { joinPaths } from "@stryke/path/join-paths";
7
+ import { loadConfig } from "c12";
8
+ import { loadEnv, loadEnvFile } from "@stryke/env/load-env";
9
+
10
+ //#region ../plugin-env/src/helpers/load.ts
11
+ async function loadEnvFiles(options, mode, cwd) {
12
+ let env = await loadEnv(cwd, mode);
13
+ if (options.additionalFiles && options.additionalFiles?.length > 0) {
14
+ const additionalEnvFiles = await Promise.all(options.additionalFiles.map(async (additionalEnvFile) => loadEnvFile(additionalEnvFile, cwd)));
15
+ for (const additionalEnvFile of additionalEnvFiles) env = defu(additionalEnvFile, env);
16
+ }
17
+ return removeEnvPrefix(env);
18
+ }
19
+ async function loadEnvDirectory(options, directory, mode, cacheDir, packageJson, workspaceConfig) {
20
+ const [envResult, c12Result] = await Promise.all([loadEnvFiles(options, mode, directory), loadConfig({
21
+ cwd: directory,
22
+ name: "storm",
23
+ envName: mode,
24
+ defaults: {
25
+ NAME: packageJson.name?.replace(`@${workspaceConfig.namespace}/`, ""),
26
+ MODE: mode,
27
+ ORG: workspaceConfig.organization
28
+ },
29
+ globalRc: true,
30
+ packageJson: true,
31
+ dotenv: true,
32
+ jitiOptions: {
33
+ fsCache: joinPaths(cacheDir, "jiti"),
34
+ moduleCache: true
35
+ }
36
+ })]);
37
+ return defu(envResult, c12Result.config, workspaceConfig);
38
+ }
39
+ /**
40
+ * Retrieves various dotenv configuration parameters from the context.
41
+ *
42
+ * @param context - The context to retrieve the dotenv configuration from.
43
+ * @param parsed - The parsed dotenv configuration.
44
+ * @returns An object containing the dotenv configuration.
45
+ */
46
+ function loadEnvFromContext(context, parsed) {
47
+ return defu({
48
+ APP_NAME: kebabCase(context.config.name || context.packageJson.name?.replace(`/${context.workspaceConfig.namespace}`, "")),
49
+ APP_VERSION: context.packageJson.version,
50
+ BUILD_ID: context.meta.buildId,
51
+ BUILD_TIMESTAMP: new Date(context.meta.timestamp).toISOString(),
52
+ BUILD_CHECKSUM: context.meta.checksum,
53
+ RELEASE_ID: context.meta.releaseId,
54
+ RELEASE_TAG: `${kebabCase(context.config.name)}@${context.packageJson.version}`,
55
+ DEFAULT_LOCALE: context.workspaceConfig.locale,
56
+ DEFAULT_TIMEZONE: context.workspaceConfig.timezone,
57
+ LOG_LEVEL: context.config.logLevel,
58
+ ERROR_URL: context.workspaceConfig.error?.url,
59
+ ORGANIZATION: isSetString(context.workspaceConfig.organization) ? context.workspaceConfig.organization : context.workspaceConfig.organization?.name,
60
+ PLATFORM: context.config.build.platform,
61
+ MODE: context.workspaceConfig.mode,
62
+ DEBUG: context.workspaceConfig.mode === "development",
63
+ STACKTRACE: context.workspaceConfig.mode === "development",
64
+ ENVIRONMENT: context.environment
65
+ }, isSetObject(context?.env?.types?.env) ? context.env.types.env?.getProperties().reduce((ret, prop) => {
66
+ ret[prop.name] = parsed[prop.name] ?? prop.getDefaultValue();
67
+ return ret;
68
+ }, {}) : {});
69
+ }
70
+ async function loadEnv$1(context, options) {
71
+ const [project, workspace, config] = await Promise.all([
72
+ loadEnvDirectory(options, context.config.projectRoot, context.config.mode, context.cachePath, context.packageJson, context.workspaceConfig),
73
+ loadEnvDirectory(options, context.workspaceConfig.workspaceRoot, context.config.mode, context.cachePath, context.packageJson, context.workspaceConfig),
74
+ loadEnvDirectory(options, context.envPaths.config, context.config.mode, context.cachePath, context.packageJson, context.workspaceConfig)
75
+ ]);
76
+ return defu(loadEnvFromContext(context, process.env), project, workspace, config);
77
+ }
78
+
79
+ //#endregion
80
+ export { loadEnv$1 as loadEnv, loadEnvFromContext };
@@ -1 +1,200 @@
1
- const e=require(`../../../_virtual/rolldown_runtime.cjs`),t=require(`../../../deepkit/src/vendor/type.cjs`),n=require(`../../../deepkit/src/capnp.cjs`),r=require(`../../../deepkit/schemas/reflection2.cjs`),i=require(`../../../deepkit/src/resolve-reflections.cjs`),a=require(`./reflect.cjs`);let o=require(`@stryke/path/join-paths`),s=require(`@stryke/capnp`);s=e.__toESM(s);let c=require(`@stryke/fs/buffer`),l=require(`node:fs`),u=require(`@stryke/fs/resolve`),d=require(`@stryke/type-checks/is-empty-object`);async function f(e){return(0,u.resolvePackage)(`@powerlines/plugin-env/types/runtime`,{paths:[e.workspaceConfig.workspaceRoot,(0,o.joinPaths)(e.workspaceConfig.workspaceRoot,e.config.projectRoot)]})}async function p(e){return{file:await f(e),name:`EnvInterface`}}async function m(e){return{file:await f(e),name:`SecretsInterface`}}function h(e,t=`env`){return(0,o.joinPaths)(i.getReflectionsPath(e),`env`,`${t}-types.bin`)}async function g(e,i=`env`){let o=h(e,i);if(!(0,l.existsSync)(o)){if(!e.env.types.env||(0,d.isEmptyObject)(e.env.types.env)){let t=a.createEnvReflection(e),n=new s.Message;t.messageRoot=n.initRoot(r.SerializedTypes),t.dataBuffer=n.toArrayBuffer(),e.env.types.env=t,await _(e,e.env.types.env,i)}return e.env.types.env}let u=await(0,c.readFileBuffer)(o),f=new s.Message(u,!1).getRoot(r.SerializedTypes),p=(0,t.type_exports.resolveClassType)((0,t.type_exports.deserializeType)(n.convertFromCapnp(f.types)));return e.env.types[i]=p,e.env.types[i].messageRoot=f,e.env.types[i].dataBuffer=u,p}async function _(e,t,i=`env`){let a=t.serializeType(),o=new s.Message;n.convertToCapnp(a,o.initRoot(r.SerializedTypes)._initTypes(a.length)),await(0,c.writeFileBuffer)(h(e,i),o.toArrayBuffer())}function v(e,t){return(0,o.joinPaths)(i.getReflectionsPath(e),`env`,`${t}.bin`)}async function y(e){let i=v(e,`env`);if(!(0,l.existsSync)(i)){if(e.env.types.env||(e.env.types.env=await g(e,`env`)),!e.env.used.env||(0,d.isEmptyObject)(e.env.used.env)){let n=a.createEnvReflection(e,{type:{kind:t.type_exports.ReflectionKind.objectLiteral,typeName:`Env`,description:`An object containing the environment configuration parameters that are used (at least once) by the ${e.config.name?`${e.config.name} application`:`application`}.`,types:[]},superReflection:e.env.types.env});n.name=`Env`;let i=new s.Message;n.messageRoot=i.initRoot(r.SerializedTypes),n.dataBuffer=i.toArrayBuffer(),e.env.used.env=n,await x(e,e.env.used.env,`env`)}return e.env.used.env}let o=await(0,c.readFileBuffer)(i),u=new s.Message(o,!1).getRoot(r.SerializedTypes),f=(0,t.type_exports.resolveClassType)((0,t.type_exports.deserializeType)(n.convertFromCapnp(u.types)));return e.env.used.env=f,e.env.used.env.messageRoot=u,e.env.used.env.dataBuffer=o,f}async function b(e){let i=v(e,`secrets`);if(!(0,l.existsSync)(i)){if(e.env.types.secrets||(e.env.types.secrets=await g(e,`secrets`)),!e.env.used.secrets||(0,d.isEmptyObject)(e.env.used.secrets)){let n=a.createEnvReflection(e,{type:{kind:t.type_exports.ReflectionKind.objectLiteral,typeName:`Secrets`,description:`An object containing the secret configuration parameters that are used (at least once) by the ${e.config.name?`${e.config.name} application`:`application`}.`,types:[]},superReflection:e.env.types.secrets});n.name=`Secrets`;let i=new s.Message;n.messageRoot=i.initRoot(r.SerializedTypes),n.dataBuffer=i.toArrayBuffer(),e.env.used.secrets=n,await x(e,e.env.used.secrets,`secrets`)}return e.env.used.secrets}let o=await(0,c.readFileBuffer)(i),u=new s.Message(o,!1).getRoot(r.SerializedTypes),f=(0,t.type_exports.resolveClassType)((0,t.type_exports.deserializeType)(n.convertFromCapnp(u.types)));return e.env.used.secrets=f,e.env.used.secrets.messageRoot=u,e.env.used.secrets.dataBuffer=o,f}async function x(e,t,i=`env`){let a=t.serializeType(),o=new s.Message;n.convertToCapnp(a,o.initRoot(r.SerializedTypes)._initTypes(a.length)),await(0,c.writeFileBuffer)(v(e,i),o.toArrayBuffer())}exports.getEnvDefaultTypeDefinition=p,exports.getEnvReflectionsPath=v,exports.getEnvTypeReflectionsPath=h,exports.getSecretsDefaultTypeDefinition=m,exports.readEnvReflection=y,exports.readEnvTypeReflection=g,exports.readSecretsReflection=b,exports.resolveRuntimeTypeFile=f,exports.writeEnvReflection=x,exports.writeEnvTypeReflection=_;
1
+ const require_rolldown_runtime = require('../../../_virtual/rolldown_runtime.cjs');
2
+ const require_type = require('../../../deepkit/src/vendor/type.cjs');
3
+ const require_capnp = require('../../../deepkit/src/capnp.cjs');
4
+ const require_reflection = require('../../../deepkit/schemas/reflection2.cjs');
5
+ const require_resolve_reflections = require('../../../deepkit/src/resolve-reflections.cjs');
6
+ const require_reflect = require('./reflect.cjs');
7
+ let __stryke_path_join_paths = require("@stryke/path/join-paths");
8
+ let __stryke_capnp = require("@stryke/capnp");
9
+ __stryke_capnp = require_rolldown_runtime.__toESM(__stryke_capnp);
10
+ let __stryke_fs_buffer = require("@stryke/fs/buffer");
11
+ let node_fs = require("node:fs");
12
+ let __stryke_fs_resolve = require("@stryke/fs/resolve");
13
+ let __stryke_type_checks_is_empty_object = require("@stryke/type-checks/is-empty-object");
14
+
15
+ //#region ../plugin-env/src/helpers/persistence.ts
16
+ /**
17
+ * Resolves the runtime type definition file for the environment variables.
18
+ *
19
+ * @param context - The plugin context.
20
+ * @returns The runtime type definition file for the environment variables.
21
+ */
22
+ async function resolveRuntimeTypeFile(context) {
23
+ return (0, __stryke_fs_resolve.resolvePackage)("@powerlines/plugin-env/types/runtime", { paths: [context.workspaceConfig.workspaceRoot, (0, __stryke_path_join_paths.joinPaths)(context.workspaceConfig.workspaceRoot, context.config.projectRoot)] });
24
+ }
25
+ /**
26
+ * Gets the default type definition for the environment variables.
27
+ *
28
+ * @param context - The plugin context.
29
+ * @returns The default type definition for the environment variables.
30
+ */
31
+ async function getEnvDefaultTypeDefinition(context) {
32
+ return {
33
+ file: await resolveRuntimeTypeFile(context),
34
+ name: "EnvInterface"
35
+ };
36
+ }
37
+ /** Gets the default type definition for the environment secrets.
38
+ *
39
+ * @param context - The plugin context.
40
+ * @returns The default type definition for the environment secrets.
41
+ */
42
+ async function getSecretsDefaultTypeDefinition(context) {
43
+ return {
44
+ file: await resolveRuntimeTypeFile(context),
45
+ name: "SecretsInterface"
46
+ };
47
+ }
48
+ /**
49
+ * Gets the path to the environment type reflections.
50
+ *
51
+ * @param context - The plugin context.
52
+ * @param name - The name of the type reflections.
53
+ * @returns The path to the environment type reflections.
54
+ */
55
+ function getEnvTypeReflectionsPath(context, name = "env") {
56
+ return (0, __stryke_path_join_paths.joinPaths)(require_resolve_reflections.getReflectionsPath(context), "env", `${name}-types.bin`);
57
+ }
58
+ /**
59
+ * Reads the environment type reflection from the file system.
60
+ *
61
+ * @param context - The plugin context.
62
+ * @param name - The name of the type reflections.
63
+ * @returns The environment type reflection.
64
+ */
65
+ async function readEnvTypeReflection(context, name = "env") {
66
+ const filePath = getEnvTypeReflectionsPath(context, name);
67
+ if (!(0, node_fs.existsSync)(filePath)) {
68
+ if (!context.env.types.env || (0, __stryke_type_checks_is_empty_object.isEmptyObject)(context.env.types.env)) {
69
+ const reflection$1 = require_reflect.createEnvReflection(context);
70
+ const message = new __stryke_capnp.Message();
71
+ reflection$1.messageRoot = message.initRoot(require_reflection.SerializedTypes);
72
+ reflection$1.dataBuffer = message.toArrayBuffer();
73
+ context.env.types.env = reflection$1;
74
+ await writeEnvTypeReflection(context, context.env.types.env, name);
75
+ }
76
+ return context.env.types.env;
77
+ }
78
+ const buffer = await (0, __stryke_fs_buffer.readFileBuffer)(filePath);
79
+ const messageRoot = new __stryke_capnp.Message(buffer, false).getRoot(require_reflection.SerializedTypes);
80
+ const reflection = (0, require_type.type_exports.resolveClassType)((0, require_type.type_exports.deserializeType)(require_capnp.convertFromCapnp(messageRoot.types)));
81
+ context.env.types[name] = reflection;
82
+ context.env.types[name].messageRoot = messageRoot;
83
+ context.env.types[name].dataBuffer = buffer;
84
+ return reflection;
85
+ }
86
+ /**
87
+ * Writes the environment type reflection to the file system.
88
+ *
89
+ * @param context - The plugin context.
90
+ * @param reflection - The environment type reflection to write.
91
+ * @param name - The name of the type reflections.
92
+ */
93
+ async function writeEnvTypeReflection(context, reflection, name = "env") {
94
+ const serialized = reflection.serializeType();
95
+ const message = new __stryke_capnp.Message();
96
+ require_capnp.convertToCapnp(serialized, message.initRoot(require_reflection.SerializedTypes)._initTypes(serialized.length));
97
+ await (0, __stryke_fs_buffer.writeFileBuffer)(getEnvTypeReflectionsPath(context, name), message.toArrayBuffer());
98
+ }
99
+ function getEnvReflectionsPath(context, name) {
100
+ return (0, __stryke_path_join_paths.joinPaths)(require_resolve_reflections.getReflectionsPath(context), "env", `${name}.bin`);
101
+ }
102
+ /**
103
+ * Reads the environment reflection data from the file system.
104
+ *
105
+ * @param context - The plugin context.
106
+ * @returns The environment reflection data.
107
+ */
108
+ async function readEnvReflection(context) {
109
+ const filePath = getEnvReflectionsPath(context, "env");
110
+ if (!(0, node_fs.existsSync)(filePath)) {
111
+ if (!context.env.types.env) context.env.types.env = await readEnvTypeReflection(context, "env");
112
+ if (!context.env.used.env || (0, __stryke_type_checks_is_empty_object.isEmptyObject)(context.env.used.env)) {
113
+ const reflection$1 = require_reflect.createEnvReflection(context, {
114
+ type: {
115
+ kind: require_type.type_exports.ReflectionKind.objectLiteral,
116
+ typeName: "Env",
117
+ description: `An object containing the environment configuration parameters that are used (at least once) by the ${context.config.name ? `${context.config.name} application` : "application"}.`,
118
+ types: []
119
+ },
120
+ superReflection: context.env.types.env
121
+ });
122
+ reflection$1.name = "Env";
123
+ const message = new __stryke_capnp.Message();
124
+ reflection$1.messageRoot = message.initRoot(require_reflection.SerializedTypes);
125
+ reflection$1.dataBuffer = message.toArrayBuffer();
126
+ context.env.used.env = reflection$1;
127
+ await writeEnvReflection(context, context.env.used.env, "env");
128
+ }
129
+ return context.env.used.env;
130
+ }
131
+ const buffer = await (0, __stryke_fs_buffer.readFileBuffer)(filePath);
132
+ const messageRoot = new __stryke_capnp.Message(buffer, false).getRoot(require_reflection.SerializedTypes);
133
+ const reflection = (0, require_type.type_exports.resolveClassType)((0, require_type.type_exports.deserializeType)(require_capnp.convertFromCapnp(messageRoot.types)));
134
+ context.env.used.env = reflection;
135
+ context.env.used.env.messageRoot = messageRoot;
136
+ context.env.used.env.dataBuffer = buffer;
137
+ return reflection;
138
+ }
139
+ /**
140
+ * Reads the secret environment reflection data from the file system.
141
+ *
142
+ * @param context - The plugin context.
143
+ * @returns The environment reflection data.
144
+ */
145
+ async function readSecretsReflection(context) {
146
+ const filePath = getEnvReflectionsPath(context, "secrets");
147
+ if (!(0, node_fs.existsSync)(filePath)) {
148
+ if (!context.env.types.secrets) context.env.types.secrets = await readEnvTypeReflection(context, "secrets");
149
+ if (!context.env.used.secrets || (0, __stryke_type_checks_is_empty_object.isEmptyObject)(context.env.used.secrets)) {
150
+ const reflection$1 = require_reflect.createEnvReflection(context, {
151
+ type: {
152
+ kind: require_type.type_exports.ReflectionKind.objectLiteral,
153
+ typeName: "Secrets",
154
+ description: `An object containing the secret configuration parameters that are used (at least once) by the ${context.config.name ? `${context.config.name} application` : "application"}.`,
155
+ types: []
156
+ },
157
+ superReflection: context.env.types.secrets
158
+ });
159
+ reflection$1.name = "Secrets";
160
+ const message = new __stryke_capnp.Message();
161
+ reflection$1.messageRoot = message.initRoot(require_reflection.SerializedTypes);
162
+ reflection$1.dataBuffer = message.toArrayBuffer();
163
+ context.env.used.secrets = reflection$1;
164
+ await writeEnvReflection(context, context.env.used.secrets, "secrets");
165
+ }
166
+ return context.env.used.secrets;
167
+ }
168
+ const buffer = await (0, __stryke_fs_buffer.readFileBuffer)(filePath);
169
+ const messageRoot = new __stryke_capnp.Message(buffer, false).getRoot(require_reflection.SerializedTypes);
170
+ const reflection = (0, require_type.type_exports.resolveClassType)((0, require_type.type_exports.deserializeType)(require_capnp.convertFromCapnp(messageRoot.types)));
171
+ context.env.used.secrets = reflection;
172
+ context.env.used.secrets.messageRoot = messageRoot;
173
+ context.env.used.secrets.dataBuffer = buffer;
174
+ return reflection;
175
+ }
176
+ /**
177
+ * Writes the environment reflection data to the file system.
178
+ *
179
+ * @param context - The plugin context.
180
+ * @param reflection - The reflection data to write.
181
+ * @param name - The name of the reflection (either "env" or "secrets").
182
+ */
183
+ async function writeEnvReflection(context, reflection, name = "env") {
184
+ const serialized = reflection.serializeType();
185
+ const message = new __stryke_capnp.Message();
186
+ require_capnp.convertToCapnp(serialized, message.initRoot(require_reflection.SerializedTypes)._initTypes(serialized.length));
187
+ await (0, __stryke_fs_buffer.writeFileBuffer)(getEnvReflectionsPath(context, name), message.toArrayBuffer());
188
+ }
189
+
190
+ //#endregion
191
+ exports.getEnvDefaultTypeDefinition = getEnvDefaultTypeDefinition;
192
+ exports.getEnvReflectionsPath = getEnvReflectionsPath;
193
+ exports.getEnvTypeReflectionsPath = getEnvTypeReflectionsPath;
194
+ exports.getSecretsDefaultTypeDefinition = getSecretsDefaultTypeDefinition;
195
+ exports.readEnvReflection = readEnvReflection;
196
+ exports.readEnvTypeReflection = readEnvTypeReflection;
197
+ exports.readSecretsReflection = readSecretsReflection;
198
+ exports.resolveRuntimeTypeFile = resolveRuntimeTypeFile;
199
+ exports.writeEnvReflection = writeEnvReflection;
200
+ exports.writeEnvTypeReflection = writeEnvTypeReflection;
@@ -1 +1,189 @@
1
- import{type_exports as e}from"../../../deepkit/src/vendor/type.mjs";import{convertFromCapnp as t,convertToCapnp as n}from"../../../deepkit/src/capnp.mjs";import{SerializedTypes as r}from"../../../deepkit/schemas/reflection2.mjs";import{getReflectionsPath as i}from"../../../deepkit/src/resolve-reflections.mjs";import{createEnvReflection as a}from"./reflect.mjs";import{joinPaths as o}from"@stryke/path/join-paths";import*as s from"@stryke/capnp";import{readFileBuffer as c,writeFileBuffer as l}from"@stryke/fs/buffer";import{existsSync as u}from"node:fs";import{resolvePackage as d}from"@stryke/fs/resolve";import{isEmptyObject as f}from"@stryke/type-checks/is-empty-object";async function p(e){return d(`@powerlines/plugin-env/types/runtime`,{paths:[e.workspaceConfig.workspaceRoot,o(e.workspaceConfig.workspaceRoot,e.config.projectRoot)]})}async function m(e){return{file:await p(e),name:`EnvInterface`}}async function h(e){return{file:await p(e),name:`SecretsInterface`}}function g(e,t=`env`){return o(i(e),`env`,`${t}-types.bin`)}async function _(n,i=`env`){let o=g(n,i);if(!u(o)){if(!n.env.types.env||f(n.env.types.env)){let e=a(n),t=new s.Message;e.messageRoot=t.initRoot(r),e.dataBuffer=t.toArrayBuffer(),n.env.types.env=e,await v(n,n.env.types.env,i)}return n.env.types.env}let l=await c(o),d=new s.Message(l,!1).getRoot(r),p=(0,e.resolveClassType)((0,e.deserializeType)(t(d.types)));return n.env.types[i]=p,n.env.types[i].messageRoot=d,n.env.types[i].dataBuffer=l,p}async function v(e,t,i=`env`){let a=t.serializeType(),o=new s.Message;n(a,o.initRoot(r)._initTypes(a.length)),await l(g(e,i),o.toArrayBuffer())}function y(e,t){return o(i(e),`env`,`${t}.bin`)}async function b(n){let i=y(n,`env`);if(!u(i)){if(n.env.types.env||(n.env.types.env=await _(n,`env`)),!n.env.used.env||f(n.env.used.env)){let t=a(n,{type:{kind:e.ReflectionKind.objectLiteral,typeName:`Env`,description:`An object containing the environment configuration parameters that are used (at least once) by the ${n.config.name?`${n.config.name} application`:`application`}.`,types:[]},superReflection:n.env.types.env});t.name=`Env`;let i=new s.Message;t.messageRoot=i.initRoot(r),t.dataBuffer=i.toArrayBuffer(),n.env.used.env=t,await S(n,n.env.used.env,`env`)}return n.env.used.env}let o=await c(i),l=new s.Message(o,!1).getRoot(r),d=(0,e.resolveClassType)((0,e.deserializeType)(t(l.types)));return n.env.used.env=d,n.env.used.env.messageRoot=l,n.env.used.env.dataBuffer=o,d}async function x(n){let i=y(n,`secrets`);if(!u(i)){if(n.env.types.secrets||(n.env.types.secrets=await _(n,`secrets`)),!n.env.used.secrets||f(n.env.used.secrets)){let t=a(n,{type:{kind:e.ReflectionKind.objectLiteral,typeName:`Secrets`,description:`An object containing the secret configuration parameters that are used (at least once) by the ${n.config.name?`${n.config.name} application`:`application`}.`,types:[]},superReflection:n.env.types.secrets});t.name=`Secrets`;let i=new s.Message;t.messageRoot=i.initRoot(r),t.dataBuffer=i.toArrayBuffer(),n.env.used.secrets=t,await S(n,n.env.used.secrets,`secrets`)}return n.env.used.secrets}let o=await c(i),l=new s.Message(o,!1).getRoot(r),d=(0,e.resolveClassType)((0,e.deserializeType)(t(l.types)));return n.env.used.secrets=d,n.env.used.secrets.messageRoot=l,n.env.used.secrets.dataBuffer=o,d}async function S(e,t,i=`env`){let a=t.serializeType(),o=new s.Message;n(a,o.initRoot(r)._initTypes(a.length)),await l(y(e,i),o.toArrayBuffer())}export{m as getEnvDefaultTypeDefinition,y as getEnvReflectionsPath,g as getEnvTypeReflectionsPath,h as getSecretsDefaultTypeDefinition,b as readEnvReflection,_ as readEnvTypeReflection,x as readSecretsReflection,p as resolveRuntimeTypeFile,S as writeEnvReflection,v as writeEnvTypeReflection};
1
+ import { type_exports } from "../../../deepkit/src/vendor/type.mjs";
2
+ import { convertFromCapnp, convertToCapnp } from "../../../deepkit/src/capnp.mjs";
3
+ import { SerializedTypes } from "../../../deepkit/schemas/reflection2.mjs";
4
+ import { getReflectionsPath } from "../../../deepkit/src/resolve-reflections.mjs";
5
+ import { createEnvReflection } from "./reflect.mjs";
6
+ import { joinPaths } from "@stryke/path/join-paths";
7
+ import * as capnp from "@stryke/capnp";
8
+ import { readFileBuffer, writeFileBuffer } from "@stryke/fs/buffer";
9
+ import { existsSync } from "node:fs";
10
+ import { resolvePackage } from "@stryke/fs/resolve";
11
+ import { isEmptyObject } from "@stryke/type-checks/is-empty-object";
12
+
13
+ //#region ../plugin-env/src/helpers/persistence.ts
14
+ /**
15
+ * Resolves the runtime type definition file for the environment variables.
16
+ *
17
+ * @param context - The plugin context.
18
+ * @returns The runtime type definition file for the environment variables.
19
+ */
20
+ async function resolveRuntimeTypeFile(context) {
21
+ return resolvePackage("@powerlines/plugin-env/types/runtime", { paths: [context.workspaceConfig.workspaceRoot, joinPaths(context.workspaceConfig.workspaceRoot, context.config.projectRoot)] });
22
+ }
23
+ /**
24
+ * Gets the default type definition for the environment variables.
25
+ *
26
+ * @param context - The plugin context.
27
+ * @returns The default type definition for the environment variables.
28
+ */
29
+ async function getEnvDefaultTypeDefinition(context) {
30
+ return {
31
+ file: await resolveRuntimeTypeFile(context),
32
+ name: "EnvInterface"
33
+ };
34
+ }
35
+ /** Gets the default type definition for the environment secrets.
36
+ *
37
+ * @param context - The plugin context.
38
+ * @returns The default type definition for the environment secrets.
39
+ */
40
+ async function getSecretsDefaultTypeDefinition(context) {
41
+ return {
42
+ file: await resolveRuntimeTypeFile(context),
43
+ name: "SecretsInterface"
44
+ };
45
+ }
46
+ /**
47
+ * Gets the path to the environment type reflections.
48
+ *
49
+ * @param context - The plugin context.
50
+ * @param name - The name of the type reflections.
51
+ * @returns The path to the environment type reflections.
52
+ */
53
+ function getEnvTypeReflectionsPath(context, name = "env") {
54
+ return joinPaths(getReflectionsPath(context), "env", `${name}-types.bin`);
55
+ }
56
+ /**
57
+ * Reads the environment type reflection from the file system.
58
+ *
59
+ * @param context - The plugin context.
60
+ * @param name - The name of the type reflections.
61
+ * @returns The environment type reflection.
62
+ */
63
+ async function readEnvTypeReflection(context, name = "env") {
64
+ const filePath = getEnvTypeReflectionsPath(context, name);
65
+ if (!existsSync(filePath)) {
66
+ if (!context.env.types.env || isEmptyObject(context.env.types.env)) {
67
+ const reflection$1 = createEnvReflection(context);
68
+ const message = new capnp.Message();
69
+ reflection$1.messageRoot = message.initRoot(SerializedTypes);
70
+ reflection$1.dataBuffer = message.toArrayBuffer();
71
+ context.env.types.env = reflection$1;
72
+ await writeEnvTypeReflection(context, context.env.types.env, name);
73
+ }
74
+ return context.env.types.env;
75
+ }
76
+ const buffer = await readFileBuffer(filePath);
77
+ const messageRoot = new capnp.Message(buffer, false).getRoot(SerializedTypes);
78
+ const reflection = (0, type_exports.resolveClassType)((0, type_exports.deserializeType)(convertFromCapnp(messageRoot.types)));
79
+ context.env.types[name] = reflection;
80
+ context.env.types[name].messageRoot = messageRoot;
81
+ context.env.types[name].dataBuffer = buffer;
82
+ return reflection;
83
+ }
84
+ /**
85
+ * Writes the environment type reflection to the file system.
86
+ *
87
+ * @param context - The plugin context.
88
+ * @param reflection - The environment type reflection to write.
89
+ * @param name - The name of the type reflections.
90
+ */
91
+ async function writeEnvTypeReflection(context, reflection, name = "env") {
92
+ const serialized = reflection.serializeType();
93
+ const message = new capnp.Message();
94
+ convertToCapnp(serialized, message.initRoot(SerializedTypes)._initTypes(serialized.length));
95
+ await writeFileBuffer(getEnvTypeReflectionsPath(context, name), message.toArrayBuffer());
96
+ }
97
+ function getEnvReflectionsPath(context, name) {
98
+ return joinPaths(getReflectionsPath(context), "env", `${name}.bin`);
99
+ }
100
+ /**
101
+ * Reads the environment reflection data from the file system.
102
+ *
103
+ * @param context - The plugin context.
104
+ * @returns The environment reflection data.
105
+ */
106
+ async function readEnvReflection(context) {
107
+ const filePath = getEnvReflectionsPath(context, "env");
108
+ if (!existsSync(filePath)) {
109
+ if (!context.env.types.env) context.env.types.env = await readEnvTypeReflection(context, "env");
110
+ if (!context.env.used.env || isEmptyObject(context.env.used.env)) {
111
+ const reflection$1 = createEnvReflection(context, {
112
+ type: {
113
+ kind: type_exports.ReflectionKind.objectLiteral,
114
+ typeName: "Env",
115
+ description: `An object containing the environment configuration parameters that are used (at least once) by the ${context.config.name ? `${context.config.name} application` : "application"}.`,
116
+ types: []
117
+ },
118
+ superReflection: context.env.types.env
119
+ });
120
+ reflection$1.name = "Env";
121
+ const message = new capnp.Message();
122
+ reflection$1.messageRoot = message.initRoot(SerializedTypes);
123
+ reflection$1.dataBuffer = message.toArrayBuffer();
124
+ context.env.used.env = reflection$1;
125
+ await writeEnvReflection(context, context.env.used.env, "env");
126
+ }
127
+ return context.env.used.env;
128
+ }
129
+ const buffer = await readFileBuffer(filePath);
130
+ const messageRoot = new capnp.Message(buffer, false).getRoot(SerializedTypes);
131
+ const reflection = (0, type_exports.resolveClassType)((0, type_exports.deserializeType)(convertFromCapnp(messageRoot.types)));
132
+ context.env.used.env = reflection;
133
+ context.env.used.env.messageRoot = messageRoot;
134
+ context.env.used.env.dataBuffer = buffer;
135
+ return reflection;
136
+ }
137
+ /**
138
+ * Reads the secret environment reflection data from the file system.
139
+ *
140
+ * @param context - The plugin context.
141
+ * @returns The environment reflection data.
142
+ */
143
+ async function readSecretsReflection(context) {
144
+ const filePath = getEnvReflectionsPath(context, "secrets");
145
+ if (!existsSync(filePath)) {
146
+ if (!context.env.types.secrets) context.env.types.secrets = await readEnvTypeReflection(context, "secrets");
147
+ if (!context.env.used.secrets || isEmptyObject(context.env.used.secrets)) {
148
+ const reflection$1 = createEnvReflection(context, {
149
+ type: {
150
+ kind: type_exports.ReflectionKind.objectLiteral,
151
+ typeName: "Secrets",
152
+ description: `An object containing the secret configuration parameters that are used (at least once) by the ${context.config.name ? `${context.config.name} application` : "application"}.`,
153
+ types: []
154
+ },
155
+ superReflection: context.env.types.secrets
156
+ });
157
+ reflection$1.name = "Secrets";
158
+ const message = new capnp.Message();
159
+ reflection$1.messageRoot = message.initRoot(SerializedTypes);
160
+ reflection$1.dataBuffer = message.toArrayBuffer();
161
+ context.env.used.secrets = reflection$1;
162
+ await writeEnvReflection(context, context.env.used.secrets, "secrets");
163
+ }
164
+ return context.env.used.secrets;
165
+ }
166
+ const buffer = await readFileBuffer(filePath);
167
+ const messageRoot = new capnp.Message(buffer, false).getRoot(SerializedTypes);
168
+ const reflection = (0, type_exports.resolveClassType)((0, type_exports.deserializeType)(convertFromCapnp(messageRoot.types)));
169
+ context.env.used.secrets = reflection;
170
+ context.env.used.secrets.messageRoot = messageRoot;
171
+ context.env.used.secrets.dataBuffer = buffer;
172
+ return reflection;
173
+ }
174
+ /**
175
+ * Writes the environment reflection data to the file system.
176
+ *
177
+ * @param context - The plugin context.
178
+ * @param reflection - The reflection data to write.
179
+ * @param name - The name of the reflection (either "env" or "secrets").
180
+ */
181
+ async function writeEnvReflection(context, reflection, name = "env") {
182
+ const serialized = reflection.serializeType();
183
+ const message = new capnp.Message();
184
+ convertToCapnp(serialized, message.initRoot(SerializedTypes)._initTypes(serialized.length));
185
+ await writeFileBuffer(getEnvReflectionsPath(context, name), message.toArrayBuffer());
186
+ }
187
+
188
+ //#endregion
189
+ export { getEnvDefaultTypeDefinition, getEnvReflectionsPath, getEnvTypeReflectionsPath, getSecretsDefaultTypeDefinition, readEnvReflection, readEnvTypeReflection, readSecretsReflection, resolveRuntimeTypeFile, writeEnvReflection, writeEnvTypeReflection };