@powerlines/plugin-env 0.16.66 → 0.16.67

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/dist/babel/plugin.cjs +83 -11
  2. package/dist/babel/plugin.mjs +83 -11
  3. package/dist/babel/plugin.mjs.map +1 -1
  4. package/dist/components/env-builtin.cjs +1 -1
  5. package/dist/components/env-builtin.mjs +1 -1
  6. package/dist/helpers/automd-generator.cjs +14 -4
  7. package/dist/helpers/automd-generator.d.mts +1 -1
  8. package/dist/helpers/automd-generator.mjs +14 -4
  9. package/dist/helpers/automd-generator.mjs.map +1 -1
  10. package/dist/helpers/create-reflection-resource.cjs +8 -0
  11. package/dist/helpers/create-reflection-resource.mjs +9 -0
  12. package/dist/helpers/create-reflection-resource.mjs.map +1 -1
  13. package/dist/helpers/docs-helper.cjs +8 -0
  14. package/dist/helpers/docs-helper.mjs +8 -0
  15. package/dist/helpers/docs-helper.mjs.map +1 -1
  16. package/dist/helpers/index.cjs +1 -0
  17. package/dist/helpers/index.mjs +2 -2
  18. package/dist/helpers/load.cjs +58 -7
  19. package/dist/helpers/load.mjs +58 -7
  20. package/dist/helpers/load.mjs.map +1 -1
  21. package/dist/helpers/persistence.cjs +108 -1
  22. package/dist/helpers/persistence.mjs +108 -1
  23. package/dist/helpers/persistence.mjs.map +1 -1
  24. package/dist/helpers/reflect.cjs +156 -3
  25. package/dist/helpers/reflect.mjs +156 -4
  26. package/dist/helpers/reflect.mjs.map +1 -1
  27. package/dist/helpers/source-file-env.cjs +34 -4
  28. package/dist/helpers/source-file-env.mjs +34 -4
  29. package/dist/helpers/source-file-env.mjs.map +1 -1
  30. package/dist/helpers/template-helpers.cjs +33 -5
  31. package/dist/helpers/template-helpers.mjs +33 -5
  32. package/dist/helpers/template-helpers.mjs.map +1 -1
  33. package/dist/node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/_chunks/rolldown-runtime.mjs +2 -0
  34. package/dist/node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/_chunks/rolldown-runtime.mjs.map +1 -1
  35. package/dist/node_modules/.pnpm/giget@2.0.0/node_modules/giget/dist/index.mjs +4 -0
  36. package/dist/node_modules/.pnpm/giget@2.0.0/node_modules/giget/dist/shared/giget.OCaTp9b-.mjs +1 -0
  37. package/dist/node_modules/.pnpm/giget@2.0.0/node_modules/giget/dist/shared/giget.OCaTp9b-.mjs.map +1 -1
  38. package/dist/types/index.cjs +11 -0
  39. package/dist/types/index.mjs +4 -1
  40. package/dist/types/plugin.cjs +137 -0
  41. package/dist/types/plugin.d.mts +4 -4
  42. package/dist/types/plugin.mjs +132 -1
  43. package/dist/types/plugin.mjs.map +1 -0
  44. package/dist/types/runtime.cjs +244 -0
  45. package/dist/types/runtime.mjs +242 -1
  46. package/dist/types/runtime.mjs.map +1 -0
  47. package/package.json +9 -9
@@ -1 +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":";;;;;;;;;;;;;;;;;;AAoDA,eAAsB,uBACpB,SACiB;CACjB,MAAM,WAAW,MAAM,QAAQ,GAAG,QAChC,uCACD;AACD,KAAI,CAAC,SACH,OAAM,IAAI,MACR,0JACD;AAGH,QAAO;;;;;;;;AAST,eAAsB,4BACpB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BACJ,sBAAsB,SAAS,KAAK,EACpC,QAAQ,eAAe,CACxB;;;;;;;;;AAUH,SAAgB,uBACd,SACA,YACA,OAAgB,OAChB;CACA,MAAM,aAAa,WAAW,eAAe;CAE7C,MAAM,UAAU,IAAI,MAAM,SAAS;AAGnC,gBAAe,YAFF,QAAQ,SAAS,gBAAgB,CAEd,WAAW,WAAW,OAAO,CAAC;AAE9D,qBACE,sBAAsB,SAAS,KAAK,EACpC,QAAQ,eAAe,CACxB"}
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;CAAA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AkB,SAAW;OAAA;CAAA;OAAA;CAAA;OAAA;CAAA;OAAA;CAAA;CAAA;CAAA;CAAA"}
@@ -1,19 +1,60 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
  const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
3
+ const require_types_runtime = require('../types/runtime.cjs');
4
+ const require_types_plugin = require('../types/plugin.cjs');
3
5
  const require_helpers_persistence = require('./persistence.cjs');
4
- let _stryke_string_format_title_case = require("@stryke/string-format/title-case");
5
6
  let _powerlines_deepkit_vendor_type = require("@powerlines/deepkit/vendor/type");
7
+ let _stryke_string_format_title_case = require("@stryke/string-format/title-case");
6
8
  let _stryke_path_join_paths = require("@stryke/path/join-paths");
7
9
  let _powerlines_deepkit_reflect_type = require("@powerlines/deepkit/reflect-type");
8
10
  let _stryke_path_is_parent_path = require("@stryke/path/is-parent-path");
9
11
 
10
12
  //#region src/helpers/reflect.ts
13
+ function __assignType(fn, args) {
14
+ fn.__type = args;
15
+ return fn;
16
+ }
11
17
  function mergeEnvReflections(context, reflections) {
12
- return createEnvReflection(context, { type: (0, _powerlines_deepkit_vendor_type.merge)(reflections.map((reflection) => reflection.type)) });
18
+ return createEnvReflection(context, { type: (0, _powerlines_deepkit_vendor_type.merge)(reflections.map(__assignType((reflection) => reflection.type, [
19
+ "reflection",
20
+ "",
21
+ "P\"2!\"/\""
22
+ ]))) });
13
23
  }
24
+ mergeEnvReflections.__type = [
25
+ () => require_types_plugin.__ΩEnvPluginContext,
26
+ "context",
27
+ () => _powerlines_deepkit_vendor_type.ReflectionClass,
28
+ "reflections",
29
+ () => _powerlines_deepkit_vendor_type.ReflectionClass,
30
+ "mergeEnvReflections",
31
+ "Pn!2\"P\"7#F2$P\"7%/&"
32
+ ];
14
33
  function mergeSecretsReflections(context, reflections) {
15
- return createSecretsReflection(context, { type: (0, _powerlines_deepkit_vendor_type.merge)(reflections.map((reflection) => reflection.type)) });
34
+ return createSecretsReflection(context, { type: (0, _powerlines_deepkit_vendor_type.merge)(reflections.map(__assignType((reflection) => reflection.type, [
35
+ "reflection",
36
+ "",
37
+ "P\"2!\"/\""
38
+ ]))) });
16
39
  }
40
+ mergeSecretsReflections.__type = [
41
+ () => require_types_plugin.__ΩEnvPluginContext,
42
+ "context",
43
+ () => _powerlines_deepkit_vendor_type.ReflectionClass,
44
+ "reflections",
45
+ () => _powerlines_deepkit_vendor_type.ReflectionClass,
46
+ "mergeSecretsReflections",
47
+ "Pn!2\"P\"7#F2$P\"7%/&"
48
+ ];
49
+ const __ΩCreateEnvReflectionOptions = [
50
+ () => _powerlines_deepkit_vendor_type.__ΩTypeObjectLiteral,
51
+ () => _powerlines_deepkit_vendor_type.__ΩTypeClass,
52
+ "type",
53
+ () => _powerlines_deepkit_vendor_type.ReflectionClass,
54
+ "superReflection",
55
+ "CreateEnvReflectionOptions",
56
+ "PPn!n\"J4#8P\"7$4%8Mw&y"
57
+ ];
17
58
  var BaseEnv = class {
18
59
  APP_NAME;
19
60
  APP_VERSION;
@@ -38,9 +79,82 @@ var BaseEnv = class {
38
79
  DEFAULT_TIMEZONE;
39
80
  DEFAULT_LOCALE;
40
81
  CI = false;
82
+ static __type = [
83
+ "APP_NAME",
84
+ "APP_VERSION",
85
+ "BUILD_ID",
86
+ "BUILD_TIMESTAMP",
87
+ "BUILD_CHECKSUM",
88
+ "RELEASE_ID",
89
+ "RELEASE_TAG",
90
+ "ORGANIZATION",
91
+ "node",
92
+ "browser",
93
+ "neutral",
94
+ "PLATFORM",
95
+ function() {
96
+ return "neutral";
97
+ },
98
+ "development",
99
+ "test",
100
+ "production",
101
+ "MODE",
102
+ function() {
103
+ return "production";
104
+ },
105
+ "ENVIRONMENT",
106
+ "DEBUG",
107
+ function() {
108
+ return false;
109
+ },
110
+ "TEST",
111
+ function() {
112
+ return false;
113
+ },
114
+ "MINIMAL",
115
+ function() {
116
+ return false;
117
+ },
118
+ "NO_COLOR",
119
+ function() {
120
+ return false;
121
+ },
122
+ "FORCE_COLOR",
123
+ function() {
124
+ return false;
125
+ },
126
+ "FORCE_HYPERLINK",
127
+ function() {
128
+ return false;
129
+ },
130
+ "STACKTRACE",
131
+ function() {
132
+ return false;
133
+ },
134
+ "INCLUDE_ERROR_DATA",
135
+ function() {
136
+ return false;
137
+ },
138
+ "ERROR_URL",
139
+ "DEFAULT_TIMEZONE",
140
+ "DEFAULT_LOCALE",
141
+ "CI",
142
+ function() {
143
+ return false;
144
+ },
145
+ () => require_types_runtime.__ΩEnvInterface,
146
+ "BaseEnv",
147
+ "&3!&3\"&3#&3$&3%&3&&3'&3(P.).*.+J3,>-P.../.0J31>2&33)34>5)36>7)38>9)3:>;P')J3<>=P')J3>>?)3@>A)3B>C&3D&3E&3F)3G>H5nIx\"wJ"
148
+ ];
41
149
  };
42
150
  var BaseSecrets = class {
43
151
  ENCRYPTION_KEY;
152
+ static __type = [
153
+ "ENCRYPTION_KEY",
154
+ () => require_types_runtime.__ΩSecretsInterface,
155
+ "BaseSecrets",
156
+ "&3!5n\"x\"w#"
157
+ ];
44
158
  };
45
159
  function createEnvReflection(context, options = {}) {
46
160
  const parent = options.superReflection ?? new _powerlines_deepkit_vendor_type.ReflectionClass({
@@ -65,6 +179,16 @@ function createEnvReflection(context, options = {}) {
65
179
  result.name = "Env";
66
180
  return result;
67
181
  }
182
+ createEnvReflection.__type = [
183
+ () => require_types_plugin.__ΩEnvPluginContext,
184
+ "context",
185
+ () => __ΩCreateEnvReflectionOptions,
186
+ "options",
187
+ () => ({}),
188
+ () => _powerlines_deepkit_vendor_type.ReflectionClass,
189
+ "createEnvReflection",
190
+ "Pn!2\"n#2$>%P\"7&/'"
191
+ ];
68
192
  function createSecretsReflection(context, options = {}) {
69
193
  const parent = options.superReflection ?? new _powerlines_deepkit_vendor_type.ReflectionClass({
70
194
  kind: _powerlines_deepkit_vendor_type.ReflectionKind.class,
@@ -88,6 +212,16 @@ function createSecretsReflection(context, options = {}) {
88
212
  result.name = "Secrets";
89
213
  return result;
90
214
  }
215
+ createSecretsReflection.__type = [
216
+ () => require_types_plugin.__ΩEnvPluginContext,
217
+ "context",
218
+ () => __ΩCreateEnvReflectionOptions,
219
+ "options",
220
+ () => ({}),
221
+ () => _powerlines_deepkit_vendor_type.ReflectionClass,
222
+ "createSecretsReflection",
223
+ "Pn!2\"n#2$>%P\"7&/'"
224
+ ];
91
225
  /**
92
226
  * 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.
93
227
  *
@@ -111,6 +245,15 @@ async function reflectEnv(context, file, name) {
111
245
  (0, _powerlines_deepkit_vendor_type.resolveClassType)(await (0, _powerlines_deepkit_reflect_type.reflectType)(context, await require_helpers_persistence.getEnvDefaultTypeDefinition(context)))
112
246
  ].filter(Boolean));
113
247
  }
248
+ reflectEnv.__type = [
249
+ () => require_types_plugin.__ΩEnvPluginContext,
250
+ "context",
251
+ "file",
252
+ "name",
253
+ "reflectEnv",
254
+ "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.",
255
+ "Pn!2\"&2#8&2$8\"/%?&"
256
+ ];
114
257
  /**
115
258
  * 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.
116
259
  *
@@ -134,10 +277,20 @@ async function reflectSecrets(context, file, name) {
134
277
  (0, _powerlines_deepkit_vendor_type.resolveClassType)(await (0, _powerlines_deepkit_reflect_type.reflectType)(context, await require_helpers_persistence.getSecretsDefaultTypeDefinition(context)))
135
278
  ].filter(Boolean));
136
279
  }
280
+ reflectSecrets.__type = [
281
+ () => require_types_plugin.__ΩEnvPluginContext,
282
+ "context",
283
+ "file",
284
+ "name",
285
+ "reflectSecrets",
286
+ "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.",
287
+ "Pn!2\"&2#8&2$8\"/%?&"
288
+ ];
137
289
 
138
290
  //#endregion
139
291
  exports.BaseEnv = BaseEnv;
140
292
  exports.BaseSecrets = BaseSecrets;
293
+ exports.__ΩCreateEnvReflectionOptions = __ΩCreateEnvReflectionOptions;
141
294
  exports.createEnvReflection = createEnvReflection;
142
295
  exports.createSecretsReflection = createSecretsReflection;
143
296
  exports.mergeEnvReflections = mergeEnvReflections;
@@ -1,17 +1,58 @@
1
+ import { __ΩEnvInterface, __ΩSecretsInterface } from "../types/runtime.mjs";
2
+ import { __ΩEnvPluginContext } from "../types/plugin.mjs";
1
3
  import { getEnvDefaultTypeDefinition, getSecretsDefaultTypeDefinition, readEnvTypeReflection, readSecretsReflection } from "./persistence.mjs";
4
+ import { ReflectionClass, ReflectionKind, __ΩTypeClass, __ΩTypeObjectLiteral, merge, resolveClassType } from "@powerlines/deepkit/vendor/type";
2
5
  import { titleCase } from "@stryke/string-format/title-case";
3
- import { ReflectionClass, ReflectionKind, merge, resolveClassType } from "@powerlines/deepkit/vendor/type";
4
6
  import { joinPaths } from "@stryke/path/join-paths";
5
7
  import { reflectType } from "@powerlines/deepkit/reflect-type";
6
8
  import { isParentPath } from "@stryke/path/is-parent-path";
7
9
 
8
10
  //#region src/helpers/reflect.ts
11
+ function __assignType(fn, args) {
12
+ fn.__type = args;
13
+ return fn;
14
+ }
9
15
  function mergeEnvReflections(context, reflections) {
10
- return createEnvReflection(context, { type: merge(reflections.map((reflection) => reflection.type)) });
16
+ return createEnvReflection(context, { type: merge(reflections.map(__assignType((reflection) => reflection.type, [
17
+ "reflection",
18
+ "",
19
+ "P\"2!\"/\""
20
+ ]))) });
11
21
  }
22
+ mergeEnvReflections.__type = [
23
+ () => __ΩEnvPluginContext,
24
+ "context",
25
+ () => ReflectionClass,
26
+ "reflections",
27
+ () => ReflectionClass,
28
+ "mergeEnvReflections",
29
+ "Pn!2\"P\"7#F2$P\"7%/&"
30
+ ];
12
31
  function mergeSecretsReflections(context, reflections) {
13
- return createSecretsReflection(context, { type: merge(reflections.map((reflection) => reflection.type)) });
32
+ return createSecretsReflection(context, { type: merge(reflections.map(__assignType((reflection) => reflection.type, [
33
+ "reflection",
34
+ "",
35
+ "P\"2!\"/\""
36
+ ]))) });
14
37
  }
38
+ mergeSecretsReflections.__type = [
39
+ () => __ΩEnvPluginContext,
40
+ "context",
41
+ () => ReflectionClass,
42
+ "reflections",
43
+ () => ReflectionClass,
44
+ "mergeSecretsReflections",
45
+ "Pn!2\"P\"7#F2$P\"7%/&"
46
+ ];
47
+ const __ΩCreateEnvReflectionOptions = [
48
+ () => __ΩTypeObjectLiteral,
49
+ () => __ΩTypeClass,
50
+ "type",
51
+ () => ReflectionClass,
52
+ "superReflection",
53
+ "CreateEnvReflectionOptions",
54
+ "PPn!n\"J4#8P\"7$4%8Mw&y"
55
+ ];
15
56
  var BaseEnv = class {
16
57
  APP_NAME;
17
58
  APP_VERSION;
@@ -36,9 +77,82 @@ var BaseEnv = class {
36
77
  DEFAULT_TIMEZONE;
37
78
  DEFAULT_LOCALE;
38
79
  CI = false;
80
+ static __type = [
81
+ "APP_NAME",
82
+ "APP_VERSION",
83
+ "BUILD_ID",
84
+ "BUILD_TIMESTAMP",
85
+ "BUILD_CHECKSUM",
86
+ "RELEASE_ID",
87
+ "RELEASE_TAG",
88
+ "ORGANIZATION",
89
+ "node",
90
+ "browser",
91
+ "neutral",
92
+ "PLATFORM",
93
+ function() {
94
+ return "neutral";
95
+ },
96
+ "development",
97
+ "test",
98
+ "production",
99
+ "MODE",
100
+ function() {
101
+ return "production";
102
+ },
103
+ "ENVIRONMENT",
104
+ "DEBUG",
105
+ function() {
106
+ return false;
107
+ },
108
+ "TEST",
109
+ function() {
110
+ return false;
111
+ },
112
+ "MINIMAL",
113
+ function() {
114
+ return false;
115
+ },
116
+ "NO_COLOR",
117
+ function() {
118
+ return false;
119
+ },
120
+ "FORCE_COLOR",
121
+ function() {
122
+ return false;
123
+ },
124
+ "FORCE_HYPERLINK",
125
+ function() {
126
+ return false;
127
+ },
128
+ "STACKTRACE",
129
+ function() {
130
+ return false;
131
+ },
132
+ "INCLUDE_ERROR_DATA",
133
+ function() {
134
+ return false;
135
+ },
136
+ "ERROR_URL",
137
+ "DEFAULT_TIMEZONE",
138
+ "DEFAULT_LOCALE",
139
+ "CI",
140
+ function() {
141
+ return false;
142
+ },
143
+ () => __ΩEnvInterface,
144
+ "BaseEnv",
145
+ "&3!&3\"&3#&3$&3%&3&&3'&3(P.).*.+J3,>-P.../.0J31>2&33)34>5)36>7)38>9)3:>;P')J3<>=P')J3>>?)3@>A)3B>C&3D&3E&3F)3G>H5nIx\"wJ"
146
+ ];
39
147
  };
40
148
  var BaseSecrets = class {
41
149
  ENCRYPTION_KEY;
150
+ static __type = [
151
+ "ENCRYPTION_KEY",
152
+ () => __ΩSecretsInterface,
153
+ "BaseSecrets",
154
+ "&3!5n\"x\"w#"
155
+ ];
42
156
  };
43
157
  function createEnvReflection(context, options = {}) {
44
158
  const parent = options.superReflection ?? new ReflectionClass({
@@ -63,6 +177,16 @@ function createEnvReflection(context, options = {}) {
63
177
  result.name = "Env";
64
178
  return result;
65
179
  }
180
+ createEnvReflection.__type = [
181
+ () => __ΩEnvPluginContext,
182
+ "context",
183
+ () => __ΩCreateEnvReflectionOptions,
184
+ "options",
185
+ () => ({}),
186
+ () => ReflectionClass,
187
+ "createEnvReflection",
188
+ "Pn!2\"n#2$>%P\"7&/'"
189
+ ];
66
190
  function createSecretsReflection(context, options = {}) {
67
191
  const parent = options.superReflection ?? new ReflectionClass({
68
192
  kind: ReflectionKind.class,
@@ -86,6 +210,16 @@ function createSecretsReflection(context, options = {}) {
86
210
  result.name = "Secrets";
87
211
  return result;
88
212
  }
213
+ createSecretsReflection.__type = [
214
+ () => __ΩEnvPluginContext,
215
+ "context",
216
+ () => __ΩCreateEnvReflectionOptions,
217
+ "options",
218
+ () => ({}),
219
+ () => ReflectionClass,
220
+ "createSecretsReflection",
221
+ "Pn!2\"n#2$>%P\"7&/'"
222
+ ];
89
223
  /**
90
224
  * 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.
91
225
  *
@@ -109,6 +243,15 @@ async function reflectEnv(context, file, name) {
109
243
  resolveClassType(await reflectType(context, await getEnvDefaultTypeDefinition(context)))
110
244
  ].filter(Boolean));
111
245
  }
246
+ reflectEnv.__type = [
247
+ () => __ΩEnvPluginContext,
248
+ "context",
249
+ "file",
250
+ "name",
251
+ "reflectEnv",
252
+ "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.",
253
+ "Pn!2\"&2#8&2$8\"/%?&"
254
+ ];
112
255
  /**
113
256
  * 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.
114
257
  *
@@ -132,7 +275,16 @@ async function reflectSecrets(context, file, name) {
132
275
  resolveClassType(await reflectType(context, await getSecretsDefaultTypeDefinition(context)))
133
276
  ].filter(Boolean));
134
277
  }
278
+ reflectSecrets.__type = [
279
+ () => __ΩEnvPluginContext,
280
+ "context",
281
+ "file",
282
+ "name",
283
+ "reflectSecrets",
284
+ "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.",
285
+ "Pn!2\"&2#8&2$8\"/%?&"
286
+ ];
135
287
 
136
288
  //#endregion
137
- export { BaseEnv, BaseSecrets, createEnvReflection, createSecretsReflection, mergeEnvReflections, mergeSecretsReflections, reflectEnv, reflectSecrets };
289
+ export { BaseEnv, BaseSecrets, __ΩCreateEnvReflectionOptions, createEnvReflection, createSecretsReflection, mergeEnvReflections, mergeSecretsReflections, reflectEnv, reflectSecrets };
138
290
  //# sourceMappingURL=reflect.mjs.map
@@ -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":";;;;;;;;AAuCA,SAAgB,oBACd,SACA,aACsB;AAKtB,QAJmB,oBAAoB,SAAS,EAC9C,MAAM,MAAM,YAAY,KAAI,eAAc,WAAW,KAAK,CAAC,EAC5D,CAAC;;AAKJ,SAAgB,wBACd,SACA,aACsB;AAKtB,QAJmB,wBAAwB,SAAS,EAClD,MAAM,MAAM,YAAY,KAAI,eAAc,WAAW,KAAK,CAAC,EAC5D,CAAC;;AAUJ,IAAa,UAAb,MAA6C;CAC3C;CAEA;CAEA;CAEA;CAEA;CAEA;CAEA;CAEA;CAEA,WAA2C;CAE3C,OAA8C;CAE9C;CAEA,QAAiB;CAEjB,OAAgB;CAEhB,UAAmB;CAEnB,WAAoB;CAEpB,cAAgC;CAEhC,kBAAoC;CAEpC,aAAsB;CAEtB,qBAA8B;CAE9B;CAEA;CAEA;CAEA,KAAc;;AAGhB,IAAa,cAAb,MAAqD;CACnD;;AAGF,SAAgB,oBACd,SACA,UAAsC,EAAE,EAClB;CACtB,MAAM,SACJ,QAAQ,mBACR,IAAI,gBAAgB;EAClB,MAAM,eAAe;EACrB,aAAa,yDAAyD,UACpE,QAAQ,OAAO,K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sBAAsB,SAAS,MAAM;EAC3C;EACA,iBACE,MAAM,YAAY,SAAS,MAAM,4BAA4B,QAAQ,CAAC,CACvE;EACF,CAAC,OAAO,QAAQ,CAClB;;;;;;;;;;;;;AAcH,eAAsB,eACpB,SACA,MACA,MACA;CACA,IAAI;AACJ,KAAI,KAQF,UAAS,iBAPU,MAAM,YAAY,SAAS;EAC5C,MAAM,CAAC,aAAa,MAAM,QAAQ,gBAAgB,cAAc,GAC5D,UAAU,QAAQ,gBAAgB,eAAe,KAAK,GACtD;EACJ;EACD,CAAC,CAEmC;AAGvC,QAAO,wBACL,SACA;EACE,MAAM,sBAAsB,QAAQ;EACpC;EACA,iBACE,MAAM,YACJ,SACA,MAAM,gCAAgC,QAAQ,CAC/C,CACF;EACF,CAAC,OAAO,QAAQ,CAClB"}
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 );\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SAAA;EACzB,MAAS,sBAAA,SAA8B,MAAA;EACtC;EACK,iBAAO,MAAA,YAAA,SAAA,MAAA,4BAAA,QAAA,CAAA,CAAA;EACX,CAAA,OAAQ,QAAA,CAAA;;AAEZ,WAAW,SAAC;OAAe;CAAK;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;;;;;;;;;;;;AAYhC,eAAsB,eAAA,SAAA,MAAA,MAAA;CAClB,IAAI;AACJ,KAAI,KAOF,UAAM,iBANN,MAAA,YAAA,SAAA;EACA,MAAA,CAAA,aAAA,MAAA,QAAA,gBAAA,cAAA,GACW,UAAQ,QAAA,gBAAA,eAAA,KAAA;EAEjB;EACJ,CAAA,CACoC;AAEpC,QAAE,wBAAuB,SAAe;EACpC,MAAA,sBAAe,QAAA;EACf;EACA,iBAAgB,MAAA,YAAA,SAAA,MAAA,gCAAA,QAAA,CAAA,CAAA;EACnB,CAAC,OAAG,QAAA,CAAA;;AAET,eAAK,SAAA;OAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA"}
@@ -5,24 +5,54 @@ let _stryke_string_format_camel_case = require("@stryke/string-format/camel-case
5
5
  let _stryke_type_checks_is_string = require("@stryke/type-checks/is-string");
6
6
 
7
7
  //#region src/helpers/source-file-env.ts
8
+ function __assignType(fn, args) {
9
+ fn.__type = args;
10
+ return fn;
11
+ }
12
+ const __ΩTReturned = [
13
+ "TEnv",
14
+ "TReturned",
15
+ "l2&R!RPe#!&qk#%QRb!Pde\"!p'w\"y"
16
+ ];
8
17
  function removeEnvPrefix(env) {
9
18
  if ((0, _stryke_type_checks_is_string.isString)(env)) {
10
- let name = _stryke_env_types.ENV_PREFIXES.reduce((ret, prefix) => {
19
+ let name = _stryke_env_types.ENV_PREFIXES.reduce(__assignType((ret, prefix) => {
11
20
  if (ret.startsWith(prefix)) ret = ret.slice(prefix.length);
12
21
  return ret;
13
- }, env.toUpperCase());
22
+ }, [
23
+ "ret",
24
+ "prefix",
25
+ "",
26
+ "P\"2!\"2\"\"/#"
27
+ ]), env.toUpperCase());
14
28
  while (name.startsWith("_")) name = name.slice(1);
15
29
  return name;
16
30
  }
17
- return Object.keys(env).reduce((ret, key) => {
31
+ return Object.keys(env).reduce(__assignType((ret, key) => {
18
32
  const name = removeEnvPrefix(key);
19
33
  if (name) ret[name] = env[key];
20
34
  return ret;
21
- }, {});
35
+ }, [
36
+ "ret",
37
+ "key",
38
+ "",
39
+ "P\"2!\"2\"\"/#"
40
+ ]), {});
22
41
  }
42
+ removeEnvPrefix.__type = [
43
+ "env",
44
+ () => __ΩTReturned,
45
+ "removeEnvPrefix",
46
+ "P\"2!\"o\"\"/#"
47
+ ];
23
48
  function formatEnvField(key) {
24
49
  return (0, _stryke_string_format_camel_case.camelCase)(removeEnvPrefix(key));
25
50
  }
51
+ formatEnvField.__type = [
52
+ "key",
53
+ "formatEnvField",
54
+ "P&2!&/\""
55
+ ];
26
56
 
27
57
  //#endregion
28
58
  exports.formatEnvField = formatEnvField;