@powerlines/plugin-env 0.16.115 → 0.16.117

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 +2 -5
  2. package/dist/babel/plugin.mjs +2 -5
  3. package/dist/babel/plugin.mjs.map +1 -1
  4. package/dist/components/docs.cjs +1 -1
  5. package/dist/components/docs.mjs +1 -1
  6. package/dist/components/docs.mjs.map +1 -1
  7. package/dist/components/env-builtin.cjs +4 -3
  8. package/dist/components/env-builtin.d.cts.map +1 -1
  9. package/dist/components/env-builtin.d.mts.map +1 -1
  10. package/dist/components/env-builtin.mjs +4 -3
  11. package/dist/components/env-builtin.mjs.map +1 -1
  12. package/dist/helpers/automd-generator.cjs +1 -3
  13. package/dist/helpers/automd-generator.d.mts +1 -1
  14. package/dist/helpers/automd-generator.mjs +1 -3
  15. package/dist/helpers/automd-generator.mjs.map +1 -1
  16. package/dist/helpers/load.cjs +1 -3
  17. package/dist/helpers/load.d.cts +20 -1
  18. package/dist/helpers/load.d.cts.map +1 -1
  19. package/dist/helpers/load.d.mts +20 -1
  20. package/dist/helpers/load.d.mts.map +1 -1
  21. package/dist/helpers/load.mjs +1 -3
  22. package/dist/helpers/load.mjs.map +1 -1
  23. package/dist/helpers/persistence.cjs +11 -26
  24. package/dist/helpers/persistence.mjs +12 -27
  25. package/dist/helpers/persistence.mjs.map +1 -1
  26. package/dist/helpers/reflect.cjs +6 -15
  27. package/dist/helpers/reflect.mjs +6 -15
  28. package/dist/helpers/reflect.mjs.map +1 -1
  29. package/dist/helpers/template-helpers.cjs +1 -3
  30. package/dist/helpers/template-helpers.mjs +1 -3
  31. package/dist/helpers/template-helpers.mjs.map +1 -1
  32. package/dist/index.cjs +3 -3
  33. package/dist/index.mjs +2 -2
  34. package/dist/index.mjs.map +1 -1
  35. package/dist/types/plugin.cjs +4 -26
  36. package/dist/types/plugin.d.mts +4 -4
  37. package/dist/types/plugin.mjs +4 -26
  38. package/dist/types/plugin.mjs.map +1 -1
  39. package/dist/types/runtime.d.cts +144 -0
  40. package/dist/types/runtime.d.cts.map +1 -1
  41. package/dist/types/runtime.d.mts +144 -0
  42. package/dist/types/runtime.d.mts.map +1 -1
  43. package/dist/types/runtime.mjs.map +1 -1
  44. package/package.json +13 -13
  45. package/dist/node_modules/.pnpm/@stryke_helpers@0.10.8/node_modules/@stryke/helpers/dist/get-unique.cjs +0 -14
  46. package/dist/node_modules/.pnpm/@stryke_helpers@0.10.8/node_modules/@stryke/helpers/dist/get-unique.mjs +0 -14
  47. package/dist/node_modules/.pnpm/@stryke_helpers@0.10.8/node_modules/@stryke/helpers/dist/get-unique.mjs.map +0 -1
@@ -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 {\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 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,eAA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,aAAA,QAAA,gBAAA;EACnD,CAAC;AACF,QAAI,KAAQ,mBAAmB,SAAS,QAAQ,IAAI,EAAA,SAAQ,WAAO,OAAQ;;AAE/E,QAAM,SAAA;OAAY;CAAA;OAAA;CAAA;CAAA;CAAA;CAAA"}
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/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 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":";;;;;;;;;;;AAIA,SAAM,aAAS,IAAW,MAAM;AAC5B,IAAA,SAAW;AACd,QAAS;;;CA4BV,IAAM,MAAQ,MAAC,UAAiB,KAAC,KAAQ;AACvC,KAAA,QAAS,mBAAgB,QAAA,iBAAA,SAAA,GAAA;EACnB,MAAM,qBAAA,MAAA,QAAA,IAAA,QAAA,gBAAA,IAAA,aAAA,OAAA,sBAAA,YAAA,mBAAA,IAAA,EAAA;GAAA;GAAA;GAAA;GAAA,CAAA,CAAA,CAAA;AACP,OAAA,MAAA,qBAAA,mBACI,OAAM,KAAA,mB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,SAAkB;EAChC,YAAS,QAAgB,OAAA,SAAA;EACnB,aAAE,CAAA,QAAA,YAAA,QACR,QAAA,YAAA,SAAA,sBACW,QAAA,OAAA,OACT,QAAA,YAAA;EACC,EAAC,YAAU,SAAS,KAAA,OAAA,IAAA,GACjB,QAAQ,IAAM,MAAM,KAAC,eAAA,CAAA,OAAA,cAAA,KAAA,SAAA;AACnB,MAAA,KAAQ,QAAW,OAAO,KAAA,SAAO,KAAA,iBAAA;AAC/B,SAAI;IACL;EAAC;EAAC;EAAA;EAAA;EAAA,CAAA,EAAA,EAAA,CAAA,GACH,EAAA,CAAA;;AAEV,mBAAmB,SAAQ;OAAA;CAAmB;CAAA;CAAA;CAAA;CAAA;CAAA;AAC9C,eAAgB,QAAa,SAAO,SAAA;CAChC,MAAE,CAAA,SAAA,WAAyB,UAAS,MAAK,QAAU,IAAC;GAClD,iBAAgB,IAAQ,CAAA,CAAA,IAAK,CAAA,EAAA,iBAAQ,SAAA,QAAA,OAAA,MAAA,QAAA,OAAA,MAAA,QAAA,WAAA,QAAA,aAAA,QAAA,gBAAA;GACrC,iBAAoB,IAAI,CAAC,CAAA,IAAA,CAAA,EAAA,iBAAS,SAAA,QAAA,gBAAA,eAAA,QAAA,OAAA,MAAA,QAAA,WAAA,QAAA,aAAA,QAAA,gBAAA;GAClC,iBAAgB,IAAA,CAAS,CAAC,IAAA,CAAA,EAAO,iBAAiB,SAAQ,QAAA,SAAY,QAAS,QAAA,OAAA,MAAA,QAAA,WAAA,QAAA,aAAA,QAAA,gBAAA;EAChF,CAAC;AACF,QAAE,KAAA,mBAA0B,SAAA,QAAgB,IAAQ,EAAA,SAAA,WAAA,OAAA;;AAExD,QAAQ,SAAQ;OAAO;CAAsB;OAAW;CAAuB;CAAA;CAAA;CAAA"}
@@ -2,11 +2,10 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
  const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
3
3
  const require_types_plugin = require('../types/plugin.cjs');
4
4
  const require_helpers_reflect = require('./reflect.cjs');
5
- let _powerlines_deepkit_vendor_type = require("@powerlines/deepkit/vendor/type");
6
- let powerlines = require("powerlines");
7
5
  let _powerlines_deepkit_capnp = require("@powerlines/deepkit/capnp");
8
6
  let _powerlines_deepkit_resolve_reflections = require("@powerlines/deepkit/resolve-reflections");
9
7
  let _powerlines_deepkit_schemas_reflection = require("@powerlines/deepkit/schemas/reflection");
8
+ let _powerlines_deepkit_vendor_type = require("@powerlines/deepkit/vendor/type");
10
9
  let _stryke_capnp = require("@stryke/capnp");
11
10
  _stryke_capnp = require_runtime.__toESM(_stryke_capnp);
12
11
  let _stryke_fs_buffer = require("@stryke/fs/buffer");
@@ -27,12 +26,10 @@ async function resolveRuntimeTypeFile(context) {
27
26
  return resolved;
28
27
  }
29
28
  resolveRuntimeTypeFile.__type = [
30
- () => powerlines.__ΩUnresolvedContext,
31
- () => require_types_plugin.__ΩEnvPluginResolvedConfig,
32
29
  "context",
33
30
  "resolveRuntimeTypeFile",
34
31
  "Resolves the runtime type definition file for the environment variables.",
35
- "Pn\"o!\"2#&`/$?%"
32
+ "P!2!&`/\"?#"
36
33
  ];
37
34
  /**
38
35
  * Gets the default type definition for the environment variables.
@@ -47,12 +44,10 @@ async function getEnvDefaultTypeDefinition(context) {
47
44
  };
48
45
  }
49
46
  getEnvDefaultTypeDefinition.__type = [
50
- () => powerlines.__ΩUnresolvedContext,
51
- () => require_types_plugin.__ΩEnvPluginResolvedConfig,
52
47
  "context",
53
48
  "getEnvDefaultTypeDefinition",
54
49
  "Gets the default type definition for the environment variables.",
55
- "Pn\"o!\"2#!`/$?%"
50
+ "P!2!!`/\"?#"
56
51
  ];
57
52
  /** Gets the default type definition for the environment secrets.
58
53
  *
@@ -66,11 +61,9 @@ async function getSecretsDefaultTypeDefinition(context) {
66
61
  };
67
62
  }
68
63
  getSecretsDefaultTypeDefinition.__type = [
69
- () => powerlines.__ΩUnresolvedContext,
70
- () => require_types_plugin.__ΩEnvPluginResolvedConfig,
71
64
  "context",
72
65
  "getSecretsDefaultTypeDefinition",
73
- "Pn\"o!\"2#!`/$"
66
+ "P!2!!`/\""
74
67
  ];
75
68
  /**
76
69
  * Gets the path to the environment type reflections.
@@ -83,15 +76,13 @@ function getEnvTypeReflectionsPath(context, name = "env") {
83
76
  return (0, _stryke_path_join_paths.joinPaths)((0, _powerlines_deepkit_resolve_reflections.getReflectionsPath)(context), "env", `${name}-types.bin`);
84
77
  }
85
78
  getEnvTypeReflectionsPath.__type = [
86
- () => powerlines.__ΩContext,
87
- () => require_types_plugin.__ΩEnvPluginResolvedConfig,
88
79
  "context",
89
80
  () => require_types_plugin.__ΩEnvType,
90
81
  "name",
91
82
  () => "env",
92
83
  "getEnvTypeReflectionsPath",
93
84
  "Gets the path to the environment type reflections.",
94
- "Pn\"o!\"2#n$2%>&&/'?("
85
+ "P!2!n\"2#>$&/%?&"
95
86
  ];
96
87
  /**
97
88
  * Reads the environment type reflection from the file system.
@@ -127,10 +118,9 @@ readEnvTypeReflection.__type = [
127
118
  () => require_types_plugin.__ΩEnvType,
128
119
  "name",
129
120
  () => "env",
130
- () => _powerlines_deepkit_vendor_type.ReflectionClass,
131
121
  "readEnvTypeReflection",
132
122
  "Reads the environment type reflection from the file system.",
133
- "Pn!2\"n#2$>%P\"7&`/'?("
123
+ "Pn!2\"n#2$>%!`/&?'"
134
124
  ];
135
125
  /**
136
126
  * Writes the environment type reflection to the file system.
@@ -148,14 +138,13 @@ async function writeEnvTypeReflection(context, reflection, name = "env") {
148
138
  writeEnvTypeReflection.__type = [
149
139
  () => require_types_plugin.__ΩEnvPluginContext,
150
140
  "context",
151
- () => _powerlines_deepkit_vendor_type.ReflectionClass,
152
141
  "reflection",
153
142
  () => require_types_plugin.__ΩEnvType,
154
143
  "name",
155
144
  () => "env",
156
145
  "writeEnvTypeReflection",
157
146
  "Writes the environment type reflection to the file system.",
158
- "Pn!2\"P\"7#2$n%2&>'\"/(?)"
147
+ "Pn!2\"!2#n$2%>&\"/'?("
159
148
  ];
160
149
  function getEnvReflectionsPath(context, name) {
161
150
  return (0, _stryke_path_join_paths.joinPaths)((0, _powerlines_deepkit_resolve_reflections.getReflectionsPath)(context), "env", `${name}.bin`);
@@ -208,10 +197,9 @@ async function readEnvReflection(context) {
208
197
  readEnvReflection.__type = [
209
198
  () => require_types_plugin.__ΩEnvPluginContext,
210
199
  "context",
211
- () => _powerlines_deepkit_vendor_type.ReflectionClass,
212
200
  "readEnvReflection",
213
201
  "Reads the environment reflection data from the file system.",
214
- "Pn!2\"P\"7#`/$?%"
202
+ "Pn!2\"!`/#?$"
215
203
  ];
216
204
  /**
217
205
  * Reads the secret environment reflection data from the file system.
@@ -253,10 +241,9 @@ async function readSecretsReflection(context) {
253
241
  readSecretsReflection.__type = [
254
242
  () => require_types_plugin.__ΩEnvPluginContext,
255
243
  "context",
256
- () => _powerlines_deepkit_vendor_type.ReflectionClass,
257
244
  "readSecretsReflection",
258
245
  "Reads the secret environment reflection data from the file system.",
259
- "Pn!2\"P\"7#`/$?%"
246
+ "Pn!2\"!`/#?$"
260
247
  ];
261
248
  /**
262
249
  * Writes the environment reflection data to the file system.
@@ -274,14 +261,13 @@ async function writeEnvReflection(context, reflection, name = "env") {
274
261
  writeEnvReflection.__type = [
275
262
  () => require_types_plugin.__ΩEnvPluginContext,
276
263
  "context",
277
- () => _powerlines_deepkit_vendor_type.ReflectionClass,
278
264
  "reflection",
279
265
  () => require_types_plugin.__ΩEnvType,
280
266
  "name",
281
267
  () => "env",
282
268
  "writeEnvReflection",
283
269
  "Writes the environment reflection data to the file system.",
284
- "Pn!2\"P\"7#2$n%2&>'\"/(?)"
270
+ "Pn!2\"!2#n$2%>&\"/'?("
285
271
  ];
286
272
  /**
287
273
  * Writes the environment reflection data to the file system.
@@ -299,14 +285,13 @@ function writeEnvReflectionSync(context, reflection, name = "env") {
299
285
  writeEnvReflectionSync.__type = [
300
286
  () => require_types_plugin.__ΩEnvPluginContext,
301
287
  "context",
302
- () => _powerlines_deepkit_vendor_type.ReflectionClass,
303
288
  "reflection",
304
289
  () => require_types_plugin.__ΩEnvType,
305
290
  "name",
306
291
  () => "env",
307
292
  "writeEnvReflectionSync",
308
293
  "Writes the environment reflection data to the file system.",
309
- "Pn!2\"P\"7#2$n%2&>'\"/(?)"
294
+ "Pn!2\"!2#n$2%>&\"/'?("
310
295
  ];
311
296
 
312
297
  //#endregion
@@ -1,10 +1,9 @@
1
- import { __ΩEnvPluginContext, __ΩEnvPluginResolvedConfig, __ΩEnvType } from "../types/plugin.mjs";
1
+ import { __ΩEnvPluginContext, __ΩEnvType } from "../types/plugin.mjs";
2
2
  import { createEnvReflection } from "./reflect.mjs";
3
- import { ReflectionClass, ReflectionKind, deserializeType, resolveClassType } from "@powerlines/deepkit/vendor/type";
4
- import { __ΩContext, __ΩUnresolvedContext } from "powerlines";
5
3
  import { convertFromCapnp, convertToCapnp } from "@powerlines/deepkit/capnp";
6
4
  import { getReflectionsPath } from "@powerlines/deepkit/resolve-reflections";
7
5
  import { SerializedTypes } from "@powerlines/deepkit/schemas/reflection";
6
+ import { ReflectionKind, deserializeType, resolveClassType } from "@powerlines/deepkit/vendor/type";
8
7
  import * as capnp from "@stryke/capnp";
9
8
  import { readFileBuffer, writeFileBuffer, writeFileBufferSync } from "@stryke/fs/buffer";
10
9
  import { joinPaths } from "@stryke/path/join-paths";
@@ -24,12 +23,10 @@ async function resolveRuntimeTypeFile(context) {
24
23
  return resolved;
25
24
  }
26
25
  resolveRuntimeTypeFile.__type = [
27
- () => __ΩUnresolvedContext,
28
- () => __ΩEnvPluginResolvedConfig,
29
26
  "context",
30
27
  "resolveRuntimeTypeFile",
31
28
  "Resolves the runtime type definition file for the environment variables.",
32
- "Pn\"o!\"2#&`/$?%"
29
+ "P!2!&`/\"?#"
33
30
  ];
34
31
  /**
35
32
  * Gets the default type definition for the environment variables.
@@ -44,12 +41,10 @@ async function getEnvDefaultTypeDefinition(context) {
44
41
  };
45
42
  }
46
43
  getEnvDefaultTypeDefinition.__type = [
47
- () => __ΩUnresolvedContext,
48
- () => __ΩEnvPluginResolvedConfig,
49
44
  "context",
50
45
  "getEnvDefaultTypeDefinition",
51
46
  "Gets the default type definition for the environment variables.",
52
- "Pn\"o!\"2#!`/$?%"
47
+ "P!2!!`/\"?#"
53
48
  ];
54
49
  /** Gets the default type definition for the environment secrets.
55
50
  *
@@ -63,11 +58,9 @@ async function getSecretsDefaultTypeDefinition(context) {
63
58
  };
64
59
  }
65
60
  getSecretsDefaultTypeDefinition.__type = [
66
- () => __ΩUnresolvedContext,
67
- () => __ΩEnvPluginResolvedConfig,
68
61
  "context",
69
62
  "getSecretsDefaultTypeDefinition",
70
- "Pn\"o!\"2#!`/$"
63
+ "P!2!!`/\""
71
64
  ];
72
65
  /**
73
66
  * Gets the path to the environment type reflections.
@@ -80,15 +73,13 @@ function getEnvTypeReflectionsPath(context, name = "env") {
80
73
  return joinPaths(getReflectionsPath(context), "env", `${name}-types.bin`);
81
74
  }
82
75
  getEnvTypeReflectionsPath.__type = [
83
- () => __ΩContext,
84
- () => __ΩEnvPluginResolvedConfig,
85
76
  "context",
86
77
  () => __ΩEnvType,
87
78
  "name",
88
79
  () => "env",
89
80
  "getEnvTypeReflectionsPath",
90
81
  "Gets the path to the environment type reflections.",
91
- "Pn\"o!\"2#n$2%>&&/'?("
82
+ "P!2!n\"2#>$&/%?&"
92
83
  ];
93
84
  /**
94
85
  * Reads the environment type reflection from the file system.
@@ -124,10 +115,9 @@ readEnvTypeReflection.__type = [
124
115
  () => __ΩEnvType,
125
116
  "name",
126
117
  () => "env",
127
- () => ReflectionClass,
128
118
  "readEnvTypeReflection",
129
119
  "Reads the environment type reflection from the file system.",
130
- "Pn!2\"n#2$>%P\"7&`/'?("
120
+ "Pn!2\"n#2$>%!`/&?'"
131
121
  ];
132
122
  /**
133
123
  * Writes the environment type reflection to the file system.
@@ -145,14 +135,13 @@ async function writeEnvTypeReflection(context, reflection, name = "env") {
145
135
  writeEnvTypeReflection.__type = [
146
136
  () => __ΩEnvPluginContext,
147
137
  "context",
148
- () => ReflectionClass,
149
138
  "reflection",
150
139
  () => __ΩEnvType,
151
140
  "name",
152
141
  () => "env",
153
142
  "writeEnvTypeReflection",
154
143
  "Writes the environment type reflection to the file system.",
155
- "Pn!2\"P\"7#2$n%2&>'\"/(?)"
144
+ "Pn!2\"!2#n$2%>&\"/'?("
156
145
  ];
157
146
  function getEnvReflectionsPath(context, name) {
158
147
  return joinPaths(getReflectionsPath(context), "env", `${name}.bin`);
@@ -205,10 +194,9 @@ async function readEnvReflection(context) {
205
194
  readEnvReflection.__type = [
206
195
  () => __ΩEnvPluginContext,
207
196
  "context",
208
- () => ReflectionClass,
209
197
  "readEnvReflection",
210
198
  "Reads the environment reflection data from the file system.",
211
- "Pn!2\"P\"7#`/$?%"
199
+ "Pn!2\"!`/#?$"
212
200
  ];
213
201
  /**
214
202
  * Reads the secret environment reflection data from the file system.
@@ -250,10 +238,9 @@ async function readSecretsReflection(context) {
250
238
  readSecretsReflection.__type = [
251
239
  () => __ΩEnvPluginContext,
252
240
  "context",
253
- () => ReflectionClass,
254
241
  "readSecretsReflection",
255
242
  "Reads the secret environment reflection data from the file system.",
256
- "Pn!2\"P\"7#`/$?%"
243
+ "Pn!2\"!`/#?$"
257
244
  ];
258
245
  /**
259
246
  * Writes the environment reflection data to the file system.
@@ -271,14 +258,13 @@ async function writeEnvReflection(context, reflection, name = "env") {
271
258
  writeEnvReflection.__type = [
272
259
  () => __ΩEnvPluginContext,
273
260
  "context",
274
- () => ReflectionClass,
275
261
  "reflection",
276
262
  () => __ΩEnvType,
277
263
  "name",
278
264
  () => "env",
279
265
  "writeEnvReflection",
280
266
  "Writes the environment reflection data to the file system.",
281
- "Pn!2\"P\"7#2$n%2&>'\"/(?)"
267
+ "Pn!2\"!2#n$2%>&\"/'?("
282
268
  ];
283
269
  /**
284
270
  * Writes the environment reflection data to the file system.
@@ -296,14 +282,13 @@ function writeEnvReflectionSync(context, reflection, name = "env") {
296
282
  writeEnvReflectionSync.__type = [
297
283
  () => __ΩEnvPluginContext,
298
284
  "context",
299
- () => ReflectionClass,
300
285
  "reflection",
301
286
  () => __ΩEnvType,
302
287
  "name",
303
288
  () => "env",
304
289
  "writeEnvReflectionSync",
305
290
  "Writes the environment reflection data to the file system.",
306
- "Pn!2\"P\"7#2$n%2&>'\"/(?)"
291
+ "Pn!2\"!2#n$2%>&\"/'?("
307
292
  ];
308
293
 
309
294
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"persistence.mjs","names":[],"sources":["../../src/helpers/persistence.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 { convertFromCapnp, convertToCapnp } from \"@powerlines/deepkit/capnp\";\nimport { getReflectionsPath } from \"@powerlines/deepkit/resolve-reflections\";\nimport { SerializedTypes } from \"@powerlines/deepkit/schemas/reflection\";\nimport { Reflection } from \"@powerlines/deepkit/types\";\nimport {\n deserializeType,\n ReflectionClass,\n ReflectionKind,\n resolveClassType\n} from \"@powerlines/deepkit/vendor/type\";\nimport * as capnp from \"@stryke/capnp\";\nimport {\n readFileBuffer,\n writeFileBuffer,\n writeFileBufferSync\n} from \"@stryke/fs/buffer\";\nimport { joinPaths } from \"@stryke/path/join-paths\";\nimport { isEmptyObject } from \"@stryke/type-checks/is-empty-object\";\nimport type { TypeDefinition } from \"@stryke/types/configuration\";\nimport { existsSync } from \"node:fs\";\nimport { Context, UnresolvedContext } from \"powerlines\";\nimport {\n EnvPluginContext,\n EnvPluginResolvedConfig,\n EnvType\n} from \"../types/plugin\";\nimport { createEnvReflection } from \"./reflect\";\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 context: UnresolvedContext<EnvPluginResolvedConfig>\n): Promise<string> {\n const resolved = await context.fs.resolve(\n \"@powerlines/plugin-env/types/runtime\"\n );\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 getEnvDefaultTypeDefinition(\n context: UnresolvedContext<EnvPluginResolvedConfig>\n): 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 getSecretsDefaultTypeDefinition(\n context: UnresolvedContext<EnvPluginResolvedConfig>\n): Promise<TypeDefinition> {\n return {\n file: await resolveRuntimeTypeFile(context),\n name: \"SecretsInterface\"\n };\n}\n\n/**\n * Gets the path to the environment type reflections.\n *\n * @param context - The plugin context.\n * @param name - The name of the type reflections.\n * @returns The path to the environment type reflections.\n */\nexport function getEnvTypeReflectionsPath(\n context: Context<EnvPluginResolvedConfig>,\n name: EnvType = \"env\"\n): string {\n return joinPaths(getReflectionsPath(context), \"env\", `${name}-types.bin`);\n}\n\n/**\n * Reads the environment type reflection from the file system.\n *\n * @param context - The plugin context.\n * @param name - The name of the type reflections.\n * @returns The environment type reflection.\n */\nexport async function readEnvTypeReflection(\n context: EnvPluginContext,\n name: EnvType = \"env\"\n): Promise<ReflectionClass<any>> {\n const filePath = getEnvTypeReflectionsPath(context, name);\n if (!existsSync(filePath)) {\n if (!context.env.types.env || isEmptyObject(context.env.types.env)) {\n const reflection = createEnvReflection(context) as Reflection;\n\n const message = new capnp.Message();\n reflection.messageRoot = message.initRoot(SerializedTypes);\n reflection.dataBuffer = message.toArrayBuffer();\n\n context.env.types.env = reflection;\n await writeEnvTypeReflection(context, context.env.types.env, name);\n }\n\n return context.env.types.env;\n }\n\n const buffer = await readFileBuffer(filePath);\n const message = new capnp.Message(buffer, false);\n const messageRoot = message.getRoot(SerializedTypes);\n\n const reflection = resolveClassType(\n deserializeType(convertFromCapnp(messageRoot.types))\n );\n\n context.env.types[name] = reflection;\n context.env.types[name].messageRoot = messageRoot;\n context.env.types[name].dataBuffer = buffer;\n\n return reflection;\n}\n\n/**\n * Writes the environment type reflection to the file system.\n *\n * @param context - The plugin context.\n * @param reflection - The environment type reflection to write.\n * @param name - The name of the type reflections.\n */\nexport async function writeEnvTypeReflection(\n context: EnvPluginContext,\n reflection: ReflectionClass<any>,\n name: EnvType = \"env\"\n) {\n const serialized = reflection.serializeType();\n\n const message = new capnp.Message();\n const root = message.initRoot(SerializedTypes);\n\n convertToCapnp(serialized, root._initTypes(serialized.length));\n\n await writeFileBuffer(\n getEnvTypeReflectionsPath(context, name),\n message.toArrayBuffer()\n );\n}\n\nexport function getEnvReflectionsPath(\n context: EnvPluginContext,\n name: EnvType\n): string {\n return joinPaths(getReflectionsPath(context), \"env\", `${name}.bin`);\n}\n\n/**\n * Reads the environment reflection data from the file system.\n *\n * @param context - The plugin context.\n * @returns The environment reflection data.\n */\nexport async function readEnvReflection(\n context: EnvPluginContext\n): Promise<ReflectionClass<any>> {\n const filePath = getEnvReflectionsPath(context, \"env\");\n if (!existsSync(filePath)) {\n if (!context.env.types.env) {\n context.env.types.env = await readEnvTypeReflection(context, \"env\");\n }\n\n if (!context.env.used.env || isEmptyObject(context.env.used.env)) {\n const reflection = createEnvReflection(context, {\n type: {\n kind: ReflectionKind.objectLiteral,\n typeName: \"Env\",\n description: `An object containing the environment configuration parameters that are used (at least once) by the ${\n context.config.name\n ? `${context.config.name} application`\n : \"application\"\n }.`,\n types: []\n },\n superReflection: context.env.types.env\n }) as Reflection;\n reflection.name = \"Env\";\n\n const message = new capnp.Message();\n reflection.messageRoot = message.initRoot(SerializedTypes);\n reflection.dataBuffer = message.toArrayBuffer();\n\n context.env.used.env = reflection;\n await writeEnvReflection(context, context.env.used.env, \"env\");\n }\n\n return context.env.used.env;\n }\n\n const buffer = await readFileBuffer(filePath);\n const message = new capnp.Message(buffer, false);\n const messageRoot = message.getRoot(SerializedTypes);\n\n const reflection = resolveClassType(\n deserializeType(convertFromCapnp(messageRoot.types))\n );\n\n context.env.used.env = reflection;\n context.env.used.env.messageRoot = messageRoot;\n context.env.used.env.dataBuffer = buffer;\n\n return reflection;\n}\n\n/**\n * Reads the secret environment reflection data from the file system.\n *\n * @param context - The plugin context.\n * @returns The environment reflection data.\n */\nexport async function readSecretsReflection(\n context: EnvPluginContext\n): Promise<ReflectionClass<any>> {\n const filePath = getEnvReflectionsPath(context, \"secrets\");\n if (!existsSync(filePath)) {\n if (!context.env.types.secrets) {\n context.env.types.secrets = await readEnvTypeReflection(\n context,\n \"secrets\"\n );\n }\n\n if (!context.env.used.secrets || isEmptyObject(context.env.used.secrets)) {\n const reflection = createEnvReflection(context, {\n type: {\n kind: ReflectionKind.objectLiteral,\n typeName: \"Secrets\",\n description: `An object containing the secret configuration parameters that are used (at least once) by the ${\n context.config.name\n ? `${context.config.name} application`\n : \"application\"\n }.`,\n types: []\n },\n superReflection: context.env.types.secrets\n }) as Reflection;\n reflection.name = \"Secrets\";\n\n const message = new capnp.Message();\n reflection.messageRoot = message.initRoot(SerializedTypes);\n reflection.dataBuffer = message.toArrayBuffer();\n\n context.env.used.secrets = reflection;\n await writeEnvReflection(context, context.env.used.secrets, \"secrets\");\n }\n\n return context.env.used.secrets;\n }\n\n const buffer = await readFileBuffer(filePath);\n const message = new capnp.Message(buffer, false);\n const messageRoot = message.getRoot(SerializedTypes);\n\n const reflection = resolveClassType(\n deserializeType(convertFromCapnp(messageRoot.types))\n );\n\n context.env.used.secrets = reflection;\n context.env.used.secrets.messageRoot = messageRoot;\n context.env.used.secrets.dataBuffer = buffer;\n\n return reflection;\n}\n\n/**\n * Writes the environment reflection data to the file system.\n *\n * @param context - The plugin context.\n * @param reflection - The reflection data to write.\n * @param name - The name of the reflection (either \"env\" or \"secrets\").\n */\nexport async function writeEnvReflection(\n context: EnvPluginContext,\n reflection: ReflectionClass<any>,\n name: EnvType = \"env\"\n) {\n const serialized = reflection.serializeType();\n\n const message = new capnp.Message();\n const root = message.initRoot(SerializedTypes);\n\n convertToCapnp(serialized, root._initTypes(serialized.length));\n\n await writeFileBuffer(\n getEnvReflectionsPath(context, name),\n message.toArrayBuffer()\n );\n}\n\n/**\n * Writes the environment reflection data to the file system.\n *\n * @param context - The plugin context.\n * @param reflection - The reflection data to write.\n * @param name - The name of the reflection (either \"env\" or \"secrets\").\n */\nexport function writeEnvReflectionSync(\n context: EnvPluginContext,\n reflection: ReflectionClass<any>,\n name: EnvType = \"env\"\n) {\n const serialized = reflection.serializeType();\n\n const message = new capnp.Message();\n const root = message.initRoot(SerializedTypes);\n\n convertToCapnp(serialized, root._initTypes(serialized.length));\n\n writeFileBufferSync(\n getEnvReflectionsPath(context, name),\n message.toArrayBuffer()\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AA2CA,eAAiB,uBAAO,SAAA;CACxB,MAAS,WAAA,MAAA,QAA0B,GAAG,QAAQ,uCAAC;eAE7C,OAAA,IAAA,MAAA,0JAAA;AAED,QAAA;;AAED,uBAAuB,SAAM;OAAU;OAA0B;CAAS;CAAA;CAAA;CAAA;CAAA;;;;;;;AAO1E,eAAG,4BAAA,SAAA;AACC,QAAG;EACH,MAAU,MAAK,uBAAA,QAAA;EACZ,MAAO;EACT;;;;;;;;;;;;;;;AAQL,eAAC,gCAAA,SAAA;AACG,QAAM;EACN,MAAQ,MAAI,uBAA2B,QAAK;EAC9C,MAAA;EACF;;AAEA,gCAA2B,SAAA;OAAA;OAAA;C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uBAAkB,SAAW;OAAA;CAAA;OAAA;CAAA;OAAA;CAAA;OAAA;CAAA;CAAA;CAAA;CAAA"}
1
+ {"version":3,"file":"persistence.mjs","names":[],"sources":["../../src/helpers/persistence.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 { convertFromCapnp, convertToCapnp } from \"@powerlines/deepkit/capnp\";\nimport { getReflectionsPath } from \"@powerlines/deepkit/resolve-reflections\";\nimport { SerializedTypes } from \"@powerlines/deepkit/schemas/reflection\";\nimport { Reflection } from \"@powerlines/deepkit/types\";\nimport {\n deserializeType,\n ReflectionClass,\n ReflectionKind,\n resolveClassType\n} from \"@powerlines/deepkit/vendor/type\";\nimport * as capnp from \"@stryke/capnp\";\nimport {\n readFileBuffer,\n writeFileBuffer,\n writeFileBufferSync\n} from \"@stryke/fs/buffer\";\nimport { joinPaths } from \"@stryke/path/join-paths\";\nimport { isEmptyObject } from \"@stryke/type-checks/is-empty-object\";\nimport type { TypeDefinition } from \"@stryke/types/configuration\";\nimport { existsSync } from \"node:fs\";\nimport { Context, UnresolvedContext } from \"powerlines\";\nimport {\n EnvPluginContext,\n EnvPluginResolvedConfig,\n EnvType\n} from \"../types/plugin\";\nimport { createEnvReflection } from \"./reflect\";\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 context: UnresolvedContext<EnvPluginResolvedConfig>\n): Promise<string> {\n const resolved = await context.fs.resolve(\n \"@powerlines/plugin-env/types/runtime\"\n );\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 getEnvDefaultTypeDefinition(\n context: UnresolvedContext<EnvPluginResolvedConfig>\n): 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 getSecretsDefaultTypeDefinition(\n context: UnresolvedContext<EnvPluginResolvedConfig>\n): Promise<TypeDefinition> {\n return {\n file: await resolveRuntimeTypeFile(context),\n name: \"SecretsInterface\"\n };\n}\n\n/**\n * Gets the path to the environment type reflections.\n *\n * @param context - The plugin context.\n * @param name - The name of the type reflections.\n * @returns The path to the environment type reflections.\n */\nexport function getEnvTypeReflectionsPath(\n context: Context<EnvPluginResolvedConfig>,\n name: EnvType = \"env\"\n): string {\n return joinPaths(getReflectionsPath(context), \"env\", `${name}-types.bin`);\n}\n\n/**\n * Reads the environment type reflection from the file system.\n *\n * @param context - The plugin context.\n * @param name - The name of the type reflections.\n * @returns The environment type reflection.\n */\nexport async function readEnvTypeReflection(\n context: EnvPluginContext,\n name: EnvType = \"env\"\n): Promise<ReflectionClass<any>> {\n const filePath = getEnvTypeReflectionsPath(context, name);\n if (!existsSync(filePath)) {\n if (!context.env.types.env || isEmptyObject(context.env.types.env)) {\n const reflection = createEnvReflection(context) as Reflection;\n\n const message = new capnp.Message();\n reflection.messageRoot = message.initRoot(SerializedTypes);\n reflection.dataBuffer = message.toArrayBuffer();\n\n context.env.types.env = reflection;\n await writeEnvTypeReflection(context, context.env.types.env, name);\n }\n\n return context.env.types.env;\n }\n\n const buffer = await readFileBuffer(filePath);\n const message = new capnp.Message(buffer, false);\n const messageRoot = message.getRoot(SerializedTypes);\n\n const reflection = resolveClassType(\n deserializeType(convertFromCapnp(messageRoot.types))\n );\n\n context.env.types[name] = reflection;\n context.env.types[name].messageRoot = messageRoot;\n context.env.types[name].dataBuffer = buffer;\n\n return reflection;\n}\n\n/**\n * Writes the environment type reflection to the file system.\n *\n * @param context - The plugin context.\n * @param reflection - The environment type reflection to write.\n * @param name - The name of the type reflections.\n */\nexport async function writeEnvTypeReflection(\n context: EnvPluginContext,\n reflection: ReflectionClass<any>,\n name: EnvType = \"env\"\n) {\n const serialized = reflection.serializeType();\n\n const message = new capnp.Message();\n const root = message.initRoot(SerializedTypes);\n\n convertToCapnp(serialized, root._initTypes(serialized.length));\n\n await writeFileBuffer(\n getEnvTypeReflectionsPath(context, name),\n message.toArrayBuffer()\n );\n}\n\nexport function getEnvReflectionsPath(\n context: EnvPluginContext,\n name: EnvType\n): string {\n return joinPaths(getReflectionsPath(context), \"env\", `${name}.bin`);\n}\n\n/**\n * Reads the environment reflection data from the file system.\n *\n * @param context - The plugin context.\n * @returns The environment reflection data.\n */\nexport async function readEnvReflection(\n context: EnvPluginContext\n): Promise<ReflectionClass<any>> {\n const filePath = getEnvReflectionsPath(context, \"env\");\n if (!existsSync(filePath)) {\n if (!context.env.types.env) {\n context.env.types.env = await readEnvTypeReflection(context, \"env\");\n }\n\n if (!context.env.used.env || isEmptyObject(context.env.used.env)) {\n const reflection = createEnvReflection(context, {\n type: {\n kind: ReflectionKind.objectLiteral,\n typeName: \"Env\",\n description: `An object containing the environment configuration parameters that are used (at least once) by the ${\n context.config.name\n ? `${context.config.name} application`\n : \"application\"\n }.`,\n types: []\n },\n superReflection: context.env.types.env\n }) as Reflection;\n reflection.name = \"Env\";\n\n const message = new capnp.Message();\n reflection.messageRoot = message.initRoot(SerializedTypes);\n reflection.dataBuffer = message.toArrayBuffer();\n\n context.env.used.env = reflection;\n await writeEnvReflection(context, context.env.used.env, \"env\");\n }\n\n return context.env.used.env;\n }\n\n const buffer = await readFileBuffer(filePath);\n const message = new capnp.Message(buffer, false);\n const messageRoot = message.getRoot(SerializedTypes);\n\n const reflection = resolveClassType(\n deserializeType(convertFromCapnp(messageRoot.types))\n );\n\n context.env.used.env = reflection;\n context.env.used.env.messageRoot = messageRoot;\n context.env.used.env.dataBuffer = buffer;\n\n return reflection;\n}\n\n/**\n * Reads the secret environment reflection data from the file system.\n *\n * @param context - The plugin context.\n * @returns The environment reflection data.\n */\nexport async function readSecretsReflection(\n context: EnvPluginContext\n): Promise<ReflectionClass<any>> {\n const filePath = getEnvReflectionsPath(context, \"secrets\");\n if (!existsSync(filePath)) {\n if (!context.env.types.secrets) {\n context.env.types.secrets = await readEnvTypeReflection(\n context,\n \"secrets\"\n );\n }\n\n if (!context.env.used.secrets || isEmptyObject(context.env.used.secrets)) {\n const reflection = createEnvReflection(context, {\n type: {\n kind: ReflectionKind.objectLiteral,\n typeName: \"Secrets\",\n description: `An object containing the secret configuration parameters that are used (at least once) by the ${\n context.config.name\n ? `${context.config.name} application`\n : \"application\"\n }.`,\n types: []\n },\n superReflection: context.env.types.secrets\n }) as Reflection;\n reflection.name = \"Secrets\";\n\n const message = new capnp.Message();\n reflection.messageRoot = message.initRoot(SerializedTypes);\n reflection.dataBuffer = message.toArrayBuffer();\n\n context.env.used.secrets = reflection;\n await writeEnvReflection(context, context.env.used.secrets, \"secrets\");\n }\n\n return context.env.used.secrets;\n }\n\n const buffer = await readFileBuffer(filePath);\n const message = new capnp.Message(buffer, false);\n const messageRoot = message.getRoot(SerializedTypes);\n\n const reflection = resolveClassType(\n deserializeType(convertFromCapnp(messageRoot.types))\n );\n\n context.env.used.secrets = reflection;\n context.env.used.secrets.messageRoot = messageRoot;\n context.env.used.secrets.dataBuffer = buffer;\n\n return reflection;\n}\n\n/**\n * Writes the environment reflection data to the file system.\n *\n * @param context - The plugin context.\n * @param reflection - The reflection data to write.\n * @param name - The name of the reflection (either \"env\" or \"secrets\").\n */\nexport async function writeEnvReflection(\n context: EnvPluginContext,\n reflection: ReflectionClass<any>,\n name: EnvType = \"env\"\n) {\n const serialized = reflection.serializeType();\n\n const message = new capnp.Message();\n const root = message.initRoot(SerializedTypes);\n\n convertToCapnp(serialized, root._initTypes(serialized.length));\n\n await writeFileBuffer(\n getEnvReflectionsPath(context, name),\n message.toArrayBuffer()\n );\n}\n\n/**\n * Writes the environment reflection data to the file system.\n *\n * @param context - The plugin context.\n * @param reflection - The reflection data to write.\n * @param name - The name of the reflection (either \"env\" or \"secrets\").\n */\nexport function writeEnvReflectionSync(\n context: EnvPluginContext,\n reflection: ReflectionClass<any>,\n name: EnvType = \"env\"\n) {\n const serialized = reflection.serializeType();\n\n const message = new capnp.Message();\n const root = message.initRoot(SerializedTypes);\n\n convertToCapnp(serialized, root._initTypes(serialized.length));\n\n writeFileBufferSync(\n getEnvReflectionsPath(context, name),\n message.toArrayBuffer()\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAqCA,eAAsB,uBAAc,SAAA;CACpC,MAAS,WAAS,MAAA,QAAiB,GAAG,QAAM,uCAAW;AACvD,KAAO,CAAA,SACL,OAAA,IAAgB,MAAA,0JAAA;AAEhB,QAAA;;AAEF,uBAAS,SAAsB;CAAA;CAAQ;CAAQ;CAAA;CAAA;;;;;;;AAO/C,eAAE,4BAAA,SAAA;AACF,QAAO;EACL,MAAS,MAAA,uBAAkB,QAAA;EAC1B,MAAQ;EACT;;AAEF,4BAAG,SAAA;CAAA;CAAA;CAAA;CAAA;CAAA;;;;;;;AAOD,QAAO;EACT,MAAA,MAAA,uBAAA,QAAA;;EAEE;;AAEF,gCAAC,SAAA;CAAA;CAAA;CAAA;CAAA;;;;;;;;AAQD,SAAgB,0BAAuB,SAAQ,OAAA,OAAA;AAC3C,QAAO,UAAA,mBAAY,QAAA,EAAA,OAAA,GAAA,KAAA,YAAA;;AAEvB,0BAAA,SAAA;CAAA;OAAA;CAAA;OAAA;CAAA;CAAA;CAAA;CAAA;;;;;;;;AAQA,eAA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runtime = require('../types/runtime.cjs');
4
4
  const require_types_plugin = require('../types/plugin.cjs');
5
5
  const require_helpers_persistence = require('./persistence.cjs');
6
- let _powerlines_deepkit_vendor_type = require("@powerlines/deepkit/vendor/type");
7
6
  let _stryke_string_format_title_case = require("@stryke/string-format/title-case");
7
+ let _powerlines_deepkit_vendor_type = require("@powerlines/deepkit/vendor/type");
8
8
  let _stryke_path_join_paths = require("@stryke/path/join-paths");
9
9
  let _powerlines_deepkit_reflect_type = require("@powerlines/deepkit/reflect-type");
10
10
  let _stryke_path_is_parent_path = require("@stryke/path/is-parent-path");
@@ -24,11 +24,9 @@ function mergeEnvReflections(context, reflections) {
24
24
  mergeEnvReflections.__type = [
25
25
  () => require_types_plugin.__ΩEnvPluginContext,
26
26
  "context",
27
- () => _powerlines_deepkit_vendor_type.ReflectionClass,
28
27
  "reflections",
29
- () => _powerlines_deepkit_vendor_type.ReflectionClass,
30
28
  "mergeEnvReflections",
31
- "Pn!2\"P\"7#F2$P\"7%/&"
29
+ "Pn!2\"!F2#!/$"
32
30
  ];
33
31
  function mergeSecretsReflections(context, reflections) {
34
32
  return createSecretsReflection(context, { type: (0, _powerlines_deepkit_vendor_type.merge)(reflections.map(__assignType((reflection) => reflection.type, [
@@ -40,20 +38,15 @@ function mergeSecretsReflections(context, reflections) {
40
38
  mergeSecretsReflections.__type = [
41
39
  () => require_types_plugin.__ΩEnvPluginContext,
42
40
  "context",
43
- () => _powerlines_deepkit_vendor_type.ReflectionClass,
44
41
  "reflections",
45
- () => _powerlines_deepkit_vendor_type.ReflectionClass,
46
42
  "mergeSecretsReflections",
47
- "Pn!2\"P\"7#F2$P\"7%/&"
43
+ "Pn!2\"!F2#!/$"
48
44
  ];
49
45
  const __ΩCreateEnvReflectionOptions = [
50
- "TypeObjectLiteral",
51
- "TypeClass",
52
46
  "type",
53
- () => _powerlines_deepkit_vendor_type.ReflectionClass,
54
47
  "superReflection",
55
48
  "CreateEnvReflectionOptions",
56
- "PP\"w!\"w\"J4#8P\"7$4%8Mw&y"
49
+ "PP!!J4!8!4\"8Mw#y"
57
50
  ];
58
51
  var BaseEnv = class {
59
52
  APP_NAME;
@@ -185,9 +178,8 @@ createEnvReflection.__type = [
185
178
  () => __ΩCreateEnvReflectionOptions,
186
179
  "options",
187
180
  () => ({}),
188
- () => _powerlines_deepkit_vendor_type.ReflectionClass,
189
181
  "createEnvReflection",
190
- "Pn!2\"n#2$>%P\"7&/'"
182
+ "Pn!2\"n#2$>%!/&"
191
183
  ];
192
184
  function createSecretsReflection(context, options = {}) {
193
185
  const parent = options.superReflection ?? new _powerlines_deepkit_vendor_type.ReflectionClass({
@@ -218,9 +210,8 @@ createSecretsReflection.__type = [
218
210
  () => __ΩCreateEnvReflectionOptions,
219
211
  "options",
220
212
  () => ({}),
221
- () => _powerlines_deepkit_vendor_type.ReflectionClass,
222
213
  "createSecretsReflection",
223
- "Pn!2\"n#2$>%P\"7&/'"
214
+ "Pn!2\"n#2$>%!/&"
224
215
  ];
225
216
  /**
226
217
  * Reflects the environment configuration type definition from the provided file and name, and merges it with the default environment configuration reflection and the currently used environment configuration reflection.
@@ -1,8 +1,8 @@
1
1
  import { __ΩEnvInterface, __ΩSecretsInterface } from "../types/runtime.mjs";
2
2
  import { __ΩEnvPluginContext } from "../types/plugin.mjs";
3
3
  import { getEnvDefaultTypeDefinition, getSecretsDefaultTypeDefinition, readEnvTypeReflection, readSecretsReflection } from "./persistence.mjs";
4
- import { ReflectionClass, ReflectionKind, merge, resolveClassType } from "@powerlines/deepkit/vendor/type";
5
4
  import { titleCase } from "@stryke/string-format/title-case";
5
+ import { ReflectionClass, ReflectionKind, merge, resolveClassType } from "@powerlines/deepkit/vendor/type";
6
6
  import { joinPaths } from "@stryke/path/join-paths";
7
7
  import { reflectType } from "@powerlines/deepkit/reflect-type";
8
8
  import { isParentPath } from "@stryke/path/is-parent-path";
@@ -22,11 +22,9 @@ function mergeEnvReflections(context, reflections) {
22
22
  mergeEnvReflections.__type = [
23
23
  () => __ΩEnvPluginContext,
24
24
  "context",
25
- () => ReflectionClass,
26
25
  "reflections",
27
- () => ReflectionClass,
28
26
  "mergeEnvReflections",
29
- "Pn!2\"P\"7#F2$P\"7%/&"
27
+ "Pn!2\"!F2#!/$"
30
28
  ];
31
29
  function mergeSecretsReflections(context, reflections) {
32
30
  return createSecretsReflection(context, { type: merge(reflections.map(__assignType((reflection) => reflection.type, [
@@ -38,20 +36,15 @@ function mergeSecretsReflections(context, reflections) {
38
36
  mergeSecretsReflections.__type = [
39
37
  () => __ΩEnvPluginContext,
40
38
  "context",
41
- () => ReflectionClass,
42
39
  "reflections",
43
- () => ReflectionClass,
44
40
  "mergeSecretsReflections",
45
- "Pn!2\"P\"7#F2$P\"7%/&"
41
+ "Pn!2\"!F2#!/$"
46
42
  ];
47
43
  const __ΩCreateEnvReflectionOptions = [
48
- "TypeObjectLiteral",
49
- "TypeClass",
50
44
  "type",
51
- () => ReflectionClass,
52
45
  "superReflection",
53
46
  "CreateEnvReflectionOptions",
54
- "PP\"w!\"w\"J4#8P\"7$4%8Mw&y"
47
+ "PP!!J4!8!4\"8Mw#y"
55
48
  ];
56
49
  var BaseEnv = class {
57
50
  APP_NAME;
@@ -183,9 +176,8 @@ createEnvReflection.__type = [
183
176
  () => __ΩCreateEnvReflectionOptions,
184
177
  "options",
185
178
  () => ({}),
186
- () => ReflectionClass,
187
179
  "createEnvReflection",
188
- "Pn!2\"n#2$>%P\"7&/'"
180
+ "Pn!2\"n#2$>%!/&"
189
181
  ];
190
182
  function createSecretsReflection(context, options = {}) {
191
183
  const parent = options.superReflection ?? new ReflectionClass({
@@ -216,9 +208,8 @@ createSecretsReflection.__type = [
216
208
  () => __ΩCreateEnvReflectionOptions,
217
209
  "options",
218
210
  () => ({}),
219
- () => ReflectionClass,
220
211
  "createSecretsReflection",
221
- "Pn!2\"n#2$>%P\"7&/'"
212
+ "Pn!2\"n#2$>%!/&"
222
213
  ];
223
214
  /**
224
215
  * Reflects the environment configuration type definition from the provided file and name, and merges it with the default environment configuration reflection and the currently used environment configuration reflection.
@@ -1 +1 @@
1
- {"version":3,"file":"reflect.mjs","names":[],"sources":["../../src/helpers/reflect.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 { reflectType } from \"@powerlines/deepkit/reflect-type\";\nimport {\n merge,\n ReflectionClass,\n ReflectionKind,\n resolveClassType,\n TypeClass,\n TypeObjectLiteral\n} from \"@powerlines/deepkit/vendor/type\";\nimport { isParentPath } from \"@stryke/path/is-parent-path\";\nimport { joinPaths } from \"@stryke/path/join-paths\";\nimport { titleCase } from \"@stryke/string-format/title-case\";\nimport { EnvPluginContext } from \"../types/plugin\";\nimport { EnvInterface, SecretsInterface } from \"../types/runtime\";\nimport {\n getEnvDefaultTypeDefinition,\n getSecretsDefaultTypeDefinition,\n readEnvTypeReflection,\n readSecretsReflection\n} from \"./persistence\";\n\nexport function mergeEnvReflections(\n context: EnvPluginContext,\n reflections: ReflectionClass<any>[]\n): ReflectionClass<any> {\n const reflection = createEnvReflection(context, {\n type: merge(reflections.map(reflection => reflection.type))\n });\n\n return reflection;\n}\n\nexport function mergeSecretsReflections(\n context: EnvPluginContext,\n reflections: ReflectionClass<any>[]\n): ReflectionClass<any> {\n const reflection = createSecretsReflection(context, {\n type: merge(reflections.map(reflection => reflection.type))\n });\n\n return reflection;\n}\n\nexport interface CreateEnvReflectionOptions {\n type?: TypeObjectLiteral | TypeClass;\n superReflection?: ReflectionClass<any>;\n}\n\nexport class BaseEnv implements EnvInterface {\n APP_NAME!: string;\n\n APP_VERSION!: string;\n\n BUILD_ID!: string;\n\n BUILD_TIMESTAMP!: string;\n\n BUILD_CHECKSUM!: string;\n\n RELEASE_ID!: string;\n\n RELEASE_TAG!: string;\n\n ORGANIZATION!: string;\n\n PLATFORM: \"node\" | \"browser\" | \"neutral\" = \"neutral\";\n\n MODE: \"development\" | \"test\" | \"production\" = \"production\";\n\n ENVIRONMENT!: string;\n\n DEBUG: boolean = false;\n\n TEST: boolean = false;\n\n MINIMAL: boolean = false;\n\n NO_COLOR: boolean = false;\n\n FORCE_COLOR: number | boolean = false;\n\n FORCE_HYPERLINK: number | boolean = false;\n\n STACKTRACE: boolean = false;\n\n INCLUDE_ERROR_DATA: boolean = false;\n\n ERROR_URL!: string;\n\n DEFAULT_TIMEZONE!: string;\n\n DEFAULT_LOCALE!: string;\n\n CI: boolean = false;\n}\n\nexport class BaseSecrets implements SecretsInterface {\n ENCRYPTION_KEY!: string;\n}\n\nexport function createEnvReflection(\n context: EnvPluginContext,\n options: CreateEnvReflectionOptions = {}\n): ReflectionClass<any> {\n const parent =\n options.superReflection ??\n new ReflectionClass({\n kind: ReflectionKind.class,\n description: `The base environment configuration definition for the ${titleCase(\n context.config.name\n )} project.`,\n classType: BaseEnv,\n types: [],\n implements: [\n {\n kind: ReflectionKind.objectLiteral,\n typeName: \"EnvInterface\",\n description: `The environment configuration interface definition for the ${titleCase(\n context.config.name\n )} project.`,\n types: []\n }\n ]\n });\n parent.name = \"Env\";\n\n const result = new ReflectionClass(\n options.type ?? {\n kind: ReflectionKind.objectLiteral,\n typeName: \"Env\",\n description: `A schema describing the list of available environment variables that can be used by the ${\n context.config.name\n ? `${titleCase(context.config.name)} application`\n : \"application\"\n }.`,\n types: []\n },\n parent\n );\n result.name = \"Env\";\n\n return result;\n}\n\nexport function createSecretsReflection(\n context: EnvPluginContext,\n options: CreateEnvReflectionOptions = {}\n): ReflectionClass<any> {\n const parent =\n options.superReflection ??\n new ReflectionClass({\n kind: ReflectionKind.class,\n description: `The base secrets configuration definition for the ${titleCase(\n context.config.name\n )} project.`,\n classType: BaseSecrets,\n types: [],\n implements: [\n {\n kind: ReflectionKind.objectLiteral,\n typeName: \"SecretsInterface\",\n description: `The secrets configuration interface definition for the ${titleCase(\n context.config.name\n )} project.`,\n types: []\n }\n ]\n });\n parent.name = \"Secrets\";\n\n const result = new ReflectionClass(\n options.type ?? {\n kind: ReflectionKind.objectLiteral,\n typeName: \"Secrets\",\n description: `A schema describing the list of available environment secrets that can be used by the ${\n context.config.name\n ? `${titleCase(context.config.name)} application`\n : \"application\"\n }.`,\n types: []\n },\n parent\n );\n result.name = \"Secrets\";\n\n return result;\n}\n\n/**\n * Reflects the environment configuration type definition from the provided file and name, and merges it with the default environment configuration reflection and the currently used environment configuration reflection.\n *\n * @remarks\n * The resulting reflection will contain the structure of the expected environment variables as defined by the type definitions provided in the plugin configuration, as well as any additional properties that are currently used in the source code and defined in the default environment configuration reflection.\n *\n * @param context - The plugin context\n * @param file - The file path to reflect the environment configuration type definition from\n * @param name - The name of the type definition to reflect the environment configuration from, if the file contains multiple type definitions. If not provided, the first type definition found in the file will be used.\n * @returns A reflection of the environment configuration type definition, merged with the default environment configuration reflection and the currently used environment configuration reflection. The resulting reflection will contain the structure of the expected environment variables as defined by the type definitions provided in the plugin configuration, as well as any additional properties that are currently used in the source code and defined in the default environment configuration reflection.\n */\nexport async function reflectEnv(\n context: EnvPluginContext,\n file?: string,\n name?: string\n) {\n let config: ReflectionClass<any> | undefined;\n if (file) {\n const configType = await reflectType(context, {\n file: !isParentPath(file, context.workspaceConfig.workspaceRoot)\n ? joinPaths(context.workspaceConfig.workspaceRoot, file)\n : file,\n name\n });\n\n config = resolveClassType(configType);\n }\n\n return mergeEnvReflections(\n context,\n [\n await readEnvTypeReflection(context, \"env\"),\n config,\n resolveClassType(\n await reflectType(context, await getEnvDefaultTypeDefinition(context))\n )\n ].filter(Boolean) as ReflectionClass<any>[]\n );\n}\n\n/**\n * Reflects the secrets configuration type definition from the provided file and name, and merges it with the default secrets configuration reflection and the currently used secrets configuration reflection.\n *\n * @remarks\n * The resulting reflection will contain the structure of the expected environment secrets as defined by the type definitions provided in the plugin configuration, as well as any additional properties that are currently used in the source code and defined in the default secrets configuration reflection.\n *\n * @param context - The plugin context\n * @param file - The file path to reflect the secrets configuration type definition from\n * @param name - The name of the type definition to reflect the secrets configuration from, if the file contains multiple type definitions. If not provided, the first type definition found in the file will be used.\n * @returns A reflection of the secrets configuration type definition, merged with the default secrets configuration reflection and the currently used secrets configuration reflection. The resulting reflection will contain the structure of the expected environment secrets as defined by the type definitions provided in the plugin configuration, as well as any additional properties that are currently used in the source code and defined in the default secrets configuration reflection.\n */\nexport async function reflectSecrets(\n context: EnvPluginContext,\n file?: string,\n name?: string\n) {\n let config: ReflectionClass<any> | undefined;\n if (file) {\n const configType = await reflectType(context, {\n file: !isParentPath(file, context.workspaceConfig.workspaceRoot)\n ? joinPaths(context.workspaceConfig.workspaceRoot, file)\n : file,\n name\n });\n\n config = resolveClassType(configType);\n }\n\n return mergeSecretsReflections(\n context,\n [\n await readSecretsReflection(context),\n config,\n resolveClassType(\n await reflectType(\n context,\n await getSecretsDefaultTypeDefinition(context)\n )\n )\n ].filter(Boolean) as ReflectionClass<any>[]\n );\n}\n"],"mappings":";;;;;;;;;;AAMA,SAAS,aAAY,IAAI,MAAO;AAC5B,IAAC,SAAU;;;AA0Bf,SAAE,oBAA2B,SAAA,aAAA;AAI3B,QAHA,oBAA+B,SAAA,EAC/B,MAAA,MAAA,YAAqB,IAAA,cAAA,eAAA,WAAA,MAAA;EAAA;EAAA;EAAA;EAAA,CAAA,CAAA,CAAA,EACrB,CAAA;;AAGF,oBAAgB,SAAA;OAAmB;CAAA;OAAA;CAAA;OAAA;CAAA;CAAA;CAAA;AACnC,SAAW,wBAAgB,SAAA,aAAA;AAIvB,QAHW,wBAAqB,SAAA,EACjC,MAAA,MAAgB,YAAK,IAAA,cAAA,eAAA,WAAA,MAAA;EAAA;EAAA;EAA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AAEvB,QAAM,wBAAa,SAAe;EAChC,MAAQ,sBAAQ,QAAA;EACd;EACA,iBAAmB,MAAA,YAAA,SAAA,MAAA,gCAAA,QAAA,CAAA,CAAA;EACpB,CAAC,OAAA,QAAe,CAAC;;AAEtB,eAAe,SAAS;OAAC;CAAsB;CAAW;CAAA;CAAA;CAAA;CAAA;CAAA"}
1
+ {"version":3,"file":"reflect.mjs","names":[],"sources":["../../src/helpers/reflect.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 { reflectType } from \"@powerlines/deepkit/reflect-type\";\nimport {\n merge,\n ReflectionClass,\n ReflectionKind,\n resolveClassType,\n TypeClass,\n TypeObjectLiteral\n} from \"@powerlines/deepkit/vendor/type\";\nimport { isParentPath } from \"@stryke/path/is-parent-path\";\nimport { joinPaths } from \"@stryke/path/join-paths\";\nimport { titleCase } from \"@stryke/string-format/title-case\";\nimport { EnvPluginContext } from \"../types/plugin\";\nimport { EnvInterface, SecretsInterface } from \"../types/runtime\";\nimport {\n getEnvDefaultTypeDefinition,\n getSecretsDefaultTypeDefinition,\n readEnvTypeReflection,\n readSecretsReflection\n} from \"./persistence\";\n\nexport function mergeEnvReflections(\n context: EnvPluginContext,\n reflections: ReflectionClass<any>[]\n): ReflectionClass<any> {\n const reflection = createEnvReflection(context, {\n type: merge(reflections.map(reflection => reflection.type))\n });\n\n return reflection;\n}\n\nexport function mergeSecretsReflections(\n context: EnvPluginContext,\n reflections: ReflectionClass<any>[]\n): ReflectionClass<any> {\n const reflection = createSecretsReflection(context, {\n type: merge(reflections.map(reflection => reflection.type))\n });\n\n return reflection;\n}\n\nexport interface CreateEnvReflectionOptions {\n type?: TypeObjectLiteral | TypeClass;\n superReflection?: ReflectionClass<any>;\n}\n\nexport class BaseEnv implements EnvInterface {\n APP_NAME!: string;\n\n APP_VERSION!: string;\n\n BUILD_ID!: string;\n\n BUILD_TIMESTAMP!: string;\n\n BUILD_CHECKSUM!: string;\n\n RELEASE_ID!: string;\n\n RELEASE_TAG!: string;\n\n ORGANIZATION!: string;\n\n PLATFORM: \"node\" | \"browser\" | \"neutral\" = \"neutral\";\n\n MODE: \"development\" | \"test\" | \"production\" = \"production\";\n\n ENVIRONMENT!: string;\n\n DEBUG: boolean = false;\n\n TEST: boolean = false;\n\n MINIMAL: boolean = false;\n\n NO_COLOR: boolean = false;\n\n FORCE_COLOR: number | boolean = false;\n\n FORCE_HYPERLINK: number | boolean = false;\n\n STACKTRACE: boolean = false;\n\n INCLUDE_ERROR_DATA: boolean = false;\n\n ERROR_URL!: string;\n\n DEFAULT_TIMEZONE!: string;\n\n DEFAULT_LOCALE!: string;\n\n CI: boolean = false;\n}\n\nexport class BaseSecrets implements SecretsInterface {\n ENCRYPTION_KEY!: string;\n}\n\nexport function createEnvReflection(\n context: EnvPluginContext,\n options: CreateEnvReflectionOptions = {}\n): ReflectionClass<any> {\n const parent =\n options.superReflection ??\n new ReflectionClass({\n kind: ReflectionKind.class,\n description: `The base environment configuration definition for the ${titleCase(\n context.config.name\n )} project.`,\n classType: BaseEnv,\n types: [],\n implements: [\n {\n kind: ReflectionKind.objectLiteral,\n typeName: \"EnvInterface\",\n description: `The environment configuration interface definition for the ${titleCase(\n context.config.name\n )} project.`,\n types: []\n }\n ]\n });\n parent.name = \"Env\";\n\n const result = new ReflectionClass(\n options.type ?? {\n kind: ReflectionKind.objectLiteral,\n typeName: \"Env\",\n description: `A schema describing the list of available environment variables that can be used by the ${\n context.config.name\n ? `${titleCase(context.config.name)} application`\n : \"application\"\n }.`,\n types: []\n },\n parent\n );\n result.name = \"Env\";\n\n return result;\n}\n\nexport function createSecretsReflection(\n context: EnvPluginContext,\n options: CreateEnvReflectionOptions = {}\n): ReflectionClass<any> {\n const parent =\n options.superReflection ??\n new ReflectionClass({\n kind: ReflectionKind.class,\n description: `The base secrets configuration definition for the ${titleCase(\n context.config.name\n )} project.`,\n classType: BaseSecrets,\n types: [],\n implements: [\n {\n kind: ReflectionKind.objectLiteral,\n typeName: \"SecretsInterface\",\n description: `The secrets configuration interface definition for the ${titleCase(\n context.config.name\n )} project.`,\n types: []\n }\n ]\n });\n parent.name = \"Secrets\";\n\n const result = new ReflectionClass(\n options.type ?? {\n kind: ReflectionKind.objectLiteral,\n typeName: \"Secrets\",\n description: `A schema describing the list of available environment secrets that can be used by the ${\n context.config.name\n ? `${titleCase(context.config.name)} application`\n : \"application\"\n }.`,\n types: []\n },\n parent\n );\n result.name = \"Secrets\";\n\n return result;\n}\n\n/**\n * Reflects the environment configuration type definition from the provided file and name, and merges it with the default environment configuration reflection and the currently used environment configuration reflection.\n *\n * @remarks\n * The resulting reflection will contain the structure of the expected environment variables as defined by the type definitions provided in the plugin configuration, as well as any additional properties that are currently used in the source code and defined in the default environment configuration reflection.\n *\n * @param context - The plugin context\n * @param file - The file path to reflect the environment configuration type definition from\n * @param name - The name of the type definition to reflect the environment configuration from, if the file contains multiple type definitions. If not provided, the first type definition found in the file will be used.\n * @returns A reflection of the environment configuration type definition, merged with the default environment configuration reflection and the currently used environment configuration reflection. The resulting reflection will contain the structure of the expected environment variables as defined by the type definitions provided in the plugin configuration, as well as any additional properties that are currently used in the source code and defined in the default environment configuration reflection.\n */\nexport async function reflectEnv(\n context: EnvPluginContext,\n file?: string,\n name?: string\n) {\n let config: ReflectionClass<any> | undefined;\n if (file) {\n const configType = await reflectType(context, {\n file: !isParentPath(file, context.workspaceConfig.workspaceRoot)\n ? joinPaths(context.workspaceConfig.workspaceRoot, file)\n : file,\n name\n });\n\n config = resolveClassType(configType);\n }\n\n return mergeEnvReflections(\n context,\n [\n await readEnvTypeReflection(context, \"env\"),\n config,\n resolveClassType(\n await reflectType(context, await getEnvDefaultTypeDefinition(context))\n )\n ].filter(Boolean) as ReflectionClass<any>[]\n );\n}\n\n/**\n * Reflects the secrets configuration type definition from the provided file and name, and merges it with the default secrets configuration reflection and the currently used secrets configuration reflection.\n *\n * @remarks\n * The resulting reflection will contain the structure of the expected environment secrets as defined by the type definitions provided in the plugin configuration, as well as any additional properties that are currently used in the source code and defined in the default secrets configuration reflection.\n *\n * @param context - The plugin context\n * @param file - The file path to reflect the secrets configuration type definition from\n * @param name - The name of the type definition to reflect the secrets configuration from, if the file contains multiple type definitions. If not provided, the first type definition found in the file will be used.\n * @returns A reflection of the secrets configuration type definition, merged with the default secrets configuration reflection and the currently used secrets configuration reflection. The resulting reflection will contain the structure of the expected environment secrets as defined by the type definitions provided in the plugin configuration, as well as any additional properties that are currently used in the source code and defined in the default secrets configuration reflection.\n */\nexport async function reflectSecrets(\n context: EnvPluginContext,\n file?: string,\n name?: string\n) {\n let config: ReflectionClass<any> | undefined;\n if (file) {\n const configType = await reflectType(context, {\n file: !isParentPath(file, context.workspaceConfig.workspaceRoot)\n ? joinPaths(context.workspaceConfig.workspaceRoot, file)\n : file,\n name\n });\n\n config = resolveClassType(configType);\n }\n\n return mergeSecretsReflections(\n context,\n [\n await readSecretsReflection(context),\n config,\n resolveClassType(\n await reflectType(\n context,\n await getSecretsDefaultTypeDefinition(context)\n )\n )\n ].filter(Boolean) as ReflectionClass<any>[]\n );\n}\n"],"mappings":";;;;;;;;;;AAMA,SAAS,aAAY,IAAI,MAAO;AAC5B,IAAC,SAAU;;;AA0Bf,SAAE,oBAA2B,SAAA,aAAA;AAI3B,QAHA,oBAA+B,SAAA,EAC/B,MAAA,MAAA,YAAqB,IAAA,cAAA,eAAA,WAAA,MAAA;EAAA;EAAA;EAAA;EAAA,CAAA,CAAA,CAAA,EACrB,CAAA;;AAGF,oBAAgB,SAAA;OAAmB;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