@powerlines/plugin-env 0.14.4 → 0.14.5

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 (230) hide show
  1. package/dist/{_virtual/rolldown_runtime.mjs → chunk-D1UamjDs.mjs} +1 -1
  2. package/dist/components/docs.cjs +1 -1
  3. package/dist/components/docs.d.cts +1 -8
  4. package/dist/components/docs.d.mts +1 -8
  5. package/dist/components/docs.mjs +1 -1
  6. package/dist/components/env.cjs +1 -34
  7. package/dist/components/env.d.cts +1 -19
  8. package/dist/components/env.d.mts +1 -19
  9. package/dist/components/env.mjs +1 -31
  10. package/dist/components/index.cjs +1 -1
  11. package/dist/components/index.d.cts +3 -2
  12. package/dist/components/index.d.mts +3 -2
  13. package/dist/components/index.mjs +1 -1
  14. package/dist/components-ByVHjWXF.mjs +1 -0
  15. package/dist/components-C9bYrQVK.cjs +0 -0
  16. package/dist/create-reflection-resource-D6mTRo2f.mjs +17 -0
  17. package/dist/create-reflection-resource-I684bqD1.cjs +17 -0
  18. package/dist/docs-BEsuuE9f.mjs +1 -0
  19. package/dist/docs-CKCRAUnO.d.mts +9 -0
  20. package/dist/docs-CdtUw4WA.d.cts +9 -0
  21. package/dist/docs-qvDyetF0.cjs +1 -0
  22. package/dist/env-CHnpBV7X.mjs +31 -0
  23. package/dist/env-COWzTupf.d.cts +20 -0
  24. package/dist/env-CgSzbXBL.cjs +34 -0
  25. package/dist/env-DqPOEUEu.d.mts +20 -0
  26. package/dist/index-B_e8BwCm.d.cts +1 -0
  27. package/dist/index-CW2WHUXP.d.mts +1 -0
  28. package/dist/index-DCQ5Y2ED.d.mts +1 -0
  29. package/dist/index-DWPDThxu.d.cts +1 -0
  30. package/dist/index.cjs +8 -4
  31. package/dist/index.d.cts +185 -12
  32. package/dist/index.d.mts +185 -17
  33. package/dist/index.mjs +8 -4
  34. package/dist/{deepkit/schemas/reflection.d.cts → plugin-CPy0CKXL.d.cts} +237 -1
  35. package/dist/plugin-CyRU_Pln.mjs +1 -0
  36. package/dist/{deepkit/schemas/reflection.d.mts → plugin-Cz3MZ6FL.d.mts} +239 -1
  37. package/dist/plugin-D5qyQPqC.cjs +0 -0
  38. package/dist/runtime-B7kcxFAf.d.mts +2499 -0
  39. package/dist/runtime-Bisl_1Ja.cjs +0 -0
  40. package/dist/runtime-Bo02eIQ-.d.cts +2497 -0
  41. package/dist/runtime-g_eXGBBi.mjs +1 -0
  42. package/dist/types/index.cjs +1 -0
  43. package/dist/types/index.d.cts +3 -2
  44. package/dist/types/index.d.mts +3 -2
  45. package/dist/types/index.mjs +1 -1
  46. package/dist/types/plugin.cjs +1 -0
  47. package/dist/types/plugin.d.cts +2 -148
  48. package/dist/types/plugin.d.mts +2 -149
  49. package/dist/types/plugin.mjs +1 -1
  50. package/dist/types/runtime.cjs +1 -0
  51. package/dist/types/runtime.d.cts +1 -793
  52. package/dist/types/runtime.d.mts +1 -793
  53. package/dist/types/runtime.mjs +1 -1
  54. package/dist/types-DMh7K7VC.mjs +1 -0
  55. package/dist/types-MYBaygjr.cjs +0 -0
  56. package/package.json +10 -8
  57. package/dist/_virtual/rolldown_runtime.cjs +0 -1
  58. package/dist/alloy/src/core/components/output.cjs +0 -1
  59. package/dist/alloy/src/core/components/output.mjs +0 -1
  60. package/dist/alloy/src/core/components/single-line-comment.cjs +0 -1
  61. package/dist/alloy/src/core/components/single-line-comment.mjs +0 -1
  62. package/dist/alloy/src/core/components/source-file.cjs +0 -1
  63. package/dist/alloy/src/core/components/source-file.d.cts +0 -22
  64. package/dist/alloy/src/core/components/source-file.d.mts +0 -22
  65. package/dist/alloy/src/core/components/source-file.mjs +0 -1
  66. package/dist/alloy/src/core/contexts/context.cjs +0 -1
  67. package/dist/alloy/src/core/contexts/context.mjs +0 -1
  68. package/dist/alloy/src/core/contexts/reflection.cjs +0 -1
  69. package/dist/alloy/src/core/contexts/reflection.mjs +0 -1
  70. package/dist/alloy/src/create-plugin.cjs +0 -2
  71. package/dist/alloy/src/create-plugin.mjs +0 -2
  72. package/dist/alloy/src/helpers/refkey.cjs +0 -1
  73. package/dist/alloy/src/helpers/refkey.mjs +0 -1
  74. package/dist/alloy/src/markdown/components/markdown-file.cjs +0 -1
  75. package/dist/alloy/src/markdown/components/markdown-file.mjs +0 -1
  76. package/dist/alloy/src/markdown/components/markdown-table.cjs +0 -1
  77. package/dist/alloy/src/markdown/components/markdown-table.mjs +0 -1
  78. package/dist/alloy/src/markdown/contexts/markdown-table.cjs +0 -1
  79. package/dist/alloy/src/markdown/contexts/markdown-table.mjs +0 -1
  80. package/dist/alloy/src/types/components.d.cts +0 -19
  81. package/dist/alloy/src/types/components.d.mts +0 -23
  82. package/dist/alloy/src/typescript/components/builtin-file.cjs +0 -1
  83. package/dist/alloy/src/typescript/components/builtin-file.d.cts +0 -25
  84. package/dist/alloy/src/typescript/components/builtin-file.d.mts +0 -26
  85. package/dist/alloy/src/typescript/components/builtin-file.mjs +0 -1
  86. package/dist/alloy/src/typescript/components/tsdoc-reflection.cjs +0 -1
  87. package/dist/alloy/src/typescript/components/tsdoc-reflection.mjs +0 -1
  88. package/dist/alloy/src/typescript/components/tsdoc.cjs +0 -1
  89. package/dist/alloy/src/typescript/components/tsdoc.d.cts +0 -27
  90. package/dist/alloy/src/typescript/components/tsdoc.d.mts +0 -28
  91. package/dist/alloy/src/typescript/components/tsdoc.mjs +0 -1
  92. package/dist/alloy/src/typescript/components/typescript-file.cjs +0 -1
  93. package/dist/alloy/src/typescript/components/typescript-file.d.cts +0 -14
  94. package/dist/alloy/src/typescript/components/typescript-file.d.mts +0 -15
  95. package/dist/alloy/src/typescript/components/typescript-file.mjs +0 -1
  96. package/dist/alloy/src/typescript/components/typescript-interface.cjs +0 -1
  97. package/dist/alloy/src/typescript/components/typescript-interface.d.cts +0 -11
  98. package/dist/alloy/src/typescript/components/typescript-interface.d.mts +0 -12
  99. package/dist/alloy/src/typescript/components/typescript-interface.mjs +0 -1
  100. package/dist/alloy/src/typescript/components/typescript-object.cjs +0 -1
  101. package/dist/alloy/src/typescript/components/typescript-object.mjs +0 -1
  102. package/dist/babel/index.cjs +0 -1
  103. package/dist/babel/index.d.cts +0 -2
  104. package/dist/babel/index.d.mts +0 -2
  105. package/dist/babel/index.mjs +0 -1
  106. package/dist/babel/plugin.cjs +0 -5
  107. package/dist/babel/plugin.d.cts +0 -7
  108. package/dist/babel/plugin.d.mts +0 -9
  109. package/dist/babel/plugin.mjs +0 -5
  110. package/dist/deepkit/schemas/reflection.cjs +0 -1
  111. package/dist/deepkit/schemas/reflection.mjs +0 -1
  112. package/dist/deepkit/schemas/reflection2.cjs +0 -1
  113. package/dist/deepkit/schemas/reflection2.mjs +0 -1
  114. package/dist/deepkit/src/capnp.cjs +0 -1
  115. package/dist/deepkit/src/capnp.mjs +0 -1
  116. package/dist/deepkit/src/esbuild-plugin.cjs +0 -4
  117. package/dist/deepkit/src/esbuild-plugin.mjs +0 -4
  118. package/dist/deepkit/src/reflect-type.cjs +0 -1
  119. package/dist/deepkit/src/reflect-type.mjs +0 -1
  120. package/dist/deepkit/src/resolve-reflections.cjs +0 -1
  121. package/dist/deepkit/src/resolve-reflections.mjs +0 -1
  122. package/dist/deepkit/src/transformer.cjs +0 -1
  123. package/dist/deepkit/src/transformer.mjs +0 -1
  124. package/dist/deepkit/src/transpile.cjs +0 -1
  125. package/dist/deepkit/src/transpile.mjs +0 -1
  126. package/dist/deepkit/src/types.d.cts +0 -10
  127. package/dist/deepkit/src/types.d.mts +0 -10
  128. package/dist/deepkit/src/utilities.cjs +0 -1
  129. package/dist/deepkit/src/utilities.mjs +0 -1
  130. package/dist/deepkit/src/vendor/type-compiler/index.cjs +0 -1
  131. package/dist/deepkit/src/vendor/type-compiler/index.mjs +0 -1
  132. package/dist/deepkit/src/vendor/type.cjs +0 -1
  133. package/dist/deepkit/src/vendor/type.d.cts +0 -7
  134. package/dist/deepkit/src/vendor/type.d.mts +0 -7
  135. package/dist/deepkit/src/vendor/type.mjs +0 -1
  136. package/dist/helpers/automd-generator.cjs +0 -1
  137. package/dist/helpers/automd-generator.d.cts +0 -14
  138. package/dist/helpers/automd-generator.d.mts +0 -14
  139. package/dist/helpers/automd-generator.mjs +0 -1
  140. package/dist/helpers/create-reflection-resource.cjs +0 -1
  141. package/dist/helpers/create-reflection-resource.d.cts +0 -15
  142. package/dist/helpers/create-reflection-resource.d.mts +0 -15
  143. package/dist/helpers/create-reflection-resource.mjs +0 -1
  144. package/dist/helpers/index.cjs +0 -1
  145. package/dist/helpers/index.d.cts +0 -7
  146. package/dist/helpers/index.d.mts +0 -7
  147. package/dist/helpers/index.mjs +0 -1
  148. package/dist/helpers/load.cjs +0 -1
  149. package/dist/helpers/load.d.cts +0 -35
  150. package/dist/helpers/load.d.mts +0 -36
  151. package/dist/helpers/load.mjs +0 -1
  152. package/dist/helpers/persistence.cjs +0 -1
  153. package/dist/helpers/persistence.d.cts +0 -84
  154. package/dist/helpers/persistence.d.mts +0 -84
  155. package/dist/helpers/persistence.mjs +0 -1
  156. package/dist/helpers/reflect.cjs +0 -1
  157. package/dist/helpers/reflect.d.cts +0 -46
  158. package/dist/helpers/reflect.d.mts +0 -46
  159. package/dist/helpers/reflect.mjs +0 -1
  160. package/dist/helpers/source-file-env.cjs +0 -1
  161. package/dist/helpers/source-file-env.d.cts +0 -8
  162. package/dist/helpers/source-file-env.d.mts +0 -8
  163. package/dist/helpers/source-file-env.mjs +0 -1
  164. package/dist/helpers/template-helpers.cjs +0 -1
  165. package/dist/helpers/template-helpers.d.cts +0 -15
  166. package/dist/helpers/template-helpers.d.mts +0 -15
  167. package/dist/helpers/template-helpers.mjs +0 -1
  168. package/dist/plugin-automd/src/index.cjs +0 -1
  169. package/dist/plugin-automd/src/index.mjs +0 -1
  170. package/dist/plugin-automd/src/types/plugin.d.cts +0 -38
  171. package/dist/plugin-automd/src/types/plugin.d.mts +0 -40
  172. package/dist/plugin-automd/src/types/toc.d.cts +0 -33
  173. package/dist/plugin-automd/src/types/toc.d.mts +0 -33
  174. package/dist/plugin-babel/src/helpers/ast-utils.cjs +0 -1
  175. package/dist/plugin-babel/src/helpers/ast-utils.mjs +0 -1
  176. package/dist/plugin-babel/src/helpers/create-plugin.cjs +0 -1
  177. package/dist/plugin-babel/src/helpers/create-plugin.mjs +0 -1
  178. package/dist/plugin-babel/src/helpers/filters.cjs +0 -1
  179. package/dist/plugin-babel/src/helpers/filters.mjs +0 -1
  180. package/dist/plugin-babel/src/helpers/index.cjs +0 -1
  181. package/dist/plugin-babel/src/helpers/index.mjs +0 -1
  182. package/dist/plugin-babel/src/helpers/module-helpers.cjs +0 -1
  183. package/dist/plugin-babel/src/helpers/module-helpers.mjs +0 -1
  184. package/dist/plugin-babel/src/helpers/options.cjs +0 -1
  185. package/dist/plugin-babel/src/helpers/options.mjs +0 -1
  186. package/dist/plugin-babel/src/index.cjs +0 -1
  187. package/dist/plugin-babel/src/index.mjs +0 -1
  188. package/dist/plugin-babel/src/types/index.d.mts +0 -1
  189. package/dist/plugin-babel/src/types/plugin.d.cts +0 -15
  190. package/dist/plugin-babel/src/types/plugin.d.mts +0 -15
  191. package/dist/powerlines/schemas/fs.d.mts +0 -1
  192. package/dist/powerlines/src/api.d.mts +0 -7
  193. package/dist/powerlines/src/index.d.mts +0 -12
  194. package/dist/powerlines/src/internal/helpers/hooks.d.mts +0 -5
  195. package/dist/powerlines/src/lib/build/esbuild.cjs +0 -14
  196. package/dist/powerlines/src/lib/build/esbuild.mjs +0 -14
  197. package/dist/powerlines/src/lib/entry.cjs +0 -1
  198. package/dist/powerlines/src/lib/entry.mjs +0 -1
  199. package/dist/powerlines/src/lib/logger.cjs +0 -1
  200. package/dist/powerlines/src/lib/logger.mjs +0 -1
  201. package/dist/powerlines/src/lib/utilities/bundle.cjs +0 -1
  202. package/dist/powerlines/src/lib/utilities/bundle.mjs +0 -1
  203. package/dist/powerlines/src/lib/utilities/resolve.cjs +0 -1
  204. package/dist/powerlines/src/lib/utilities/resolve.mjs +0 -1
  205. package/dist/powerlines/src/plugin-utils/helpers.cjs +0 -1
  206. package/dist/powerlines/src/plugin-utils/helpers.mjs +0 -1
  207. package/dist/powerlines/src/plugin-utils/paths.cjs +0 -1
  208. package/dist/powerlines/src/plugin-utils/paths.mjs +0 -1
  209. package/dist/powerlines/src/types/api.d.mts +0 -5
  210. package/dist/powerlines/src/types/babel.d.cts +0 -23
  211. package/dist/powerlines/src/types/babel.d.mts +0 -23
  212. package/dist/powerlines/src/types/build.d.cts +0 -145
  213. package/dist/powerlines/src/types/build.d.mts +0 -147
  214. package/dist/powerlines/src/types/commands.d.cts +0 -8
  215. package/dist/powerlines/src/types/commands.d.mts +0 -9
  216. package/dist/powerlines/src/types/config.d.cts +0 -368
  217. package/dist/powerlines/src/types/config.d.mts +0 -369
  218. package/dist/powerlines/src/types/context.d.cts +0 -373
  219. package/dist/powerlines/src/types/context.d.mts +0 -375
  220. package/dist/powerlines/src/types/fs.d.cts +0 -458
  221. package/dist/powerlines/src/types/fs.d.mts +0 -458
  222. package/dist/powerlines/src/types/hooks.d.mts +0 -2
  223. package/dist/powerlines/src/types/index.d.mts +0 -12
  224. package/dist/powerlines/src/types/plugin.d.cts +0 -232
  225. package/dist/powerlines/src/types/plugin.d.mts +0 -232
  226. package/dist/powerlines/src/types/resolved.d.cts +0 -82
  227. package/dist/powerlines/src/types/resolved.d.mts +0 -83
  228. package/dist/powerlines/src/types/tsconfig.d.cts +0 -69
  229. package/dist/powerlines/src/types/tsconfig.d.mts +0 -69
  230. package/dist/powerlines/src/types/unplugin.d.mts +0 -7
@@ -0,0 +1,34 @@
1
+ const e=require(`./create-reflection-resource-I684bqD1.cjs`);let t=require(`defu`);t=e.O(t);let n=require(`@stryke/string-format/title-case`),r=require(`@stryke/type-checks/is-null`),i=require(`@alloy-js/core`),a=require(`@alloy-js/typescript`),o=require(`@powerlines/alloy/core/contexts/context`),s=require(`@powerlines/alloy/helpers/refkey`),c=require(`@powerlines/alloy/typescript/components/builtin-file`),l=require(`@powerlines/alloy/typescript/components/tsdoc`),u=require(`@powerlines/alloy/typescript/components/typescript-interface`),d=require(`@powerlines/alloy/typescript/components/typescript-object`),f=require(`@alloy-js/core/jsx-runtime`);function p(e){let[{defaultValue:t,reflection:n}]=(0,i.splitProps)(e,[`defaultValue`,`reflection`]),r=(0,o.usePowerlines)();return(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(u.TypeScriptInterface,{name:` EnvBase`,extends:[`EnvInterface`],defaultValue:t,reflection:n,export:!0}),(0,f.jsx)(`hbr`,{}),(0,f.jsx)(`hbr`,{}),(0,f.jsx)(a.TypeDeclaration,{name:`Env`,export:!0,children:i.code` {
2
+ [Key in keyof EnvBase as Key ${r?.config.env.prefix.map(e=>`| \`${e.replace(/_$/g,``)}_\${Key}\``).join(` `)}]: EnvBase[Key];
3
+ }
4
+ `})]})}function m(e){let[{context:t,name:n}]=(0,i.splitProps)(e,[`context`,`name`]);return t?i.code`propertyName === "${n}" || propertyName.replace(/^(${t.config.env.prefix.sort((e,t)=>e.startsWith(t)?-1:t.startsWith(e)?1:e.localeCompare(t)).map(e=>`${e.replace(/_$/,``)}_`).join(`|`)})/g, "").toLowerCase().replace(/[\\s\\-_]+/g, "") === "${n.toLowerCase().replace(/[\s\-_]+/g,``)}"`:null}function h(e){let[{context:t,property:n,index:r}]=(0,i.splitProps)(e,[`context`,`property`,`index`]);return t?(0,f.jsx)(f.Fragment,{children:r===0?(0,f.jsx)(a.IfStatement,{condition:(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(m,{name:n.getNameAsString(),context:t}),(0,f.jsxs)(i.Show,{when:n.getAlias()&&n.getAlias().length>0,children:[i.code` || `,(0,f.jsx)(i.For,{each:n.getAlias(),joiner:i.code` || `,children:e=>(0,f.jsx)(m,{name:e,context:t})})]})]}),children:i.code`return target["${n.getNameAsString()}"];`}):(0,f.jsx)(a.ElseIfClause,{condition:(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(m,{name:n.getNameAsString(),context:t}),(0,f.jsxs)(i.Show,{when:n.getAlias()&&n.getAlias().length>0,children:[i.code` || `,(0,f.jsx)(i.For,{each:n.getAlias(),joiner:i.code` || `,children:e=>(0,f.jsx)(m,{name:e,context:t})})]})]}),children:i.code`return target["${n.getNameAsString()}"];`})}):null}function g(e){let[{context:t,property:n,index:r}]=(0,i.splitProps)(e,[`context`,`property`,`index`]);return t?(0,f.jsx)(f.Fragment,{children:r===0?(0,f.jsx)(a.IfStatement,{condition:(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(m,{name:n.getNameAsString(),context:t}),(0,f.jsxs)(i.Show,{when:n.getAlias()&&n.getAlias().length>0,children:[i.code` || `,(0,f.jsx)(i.For,{each:n.getAlias(),joiner:i.code` || `,children:e=>(0,f.jsx)(m,{name:e,context:t})})]})]}),children:i.code`
5
+ target["${n.getNameAsString()}"] = newValue;
6
+ return true;
7
+ `}):(0,f.jsx)(a.ElseIfClause,{condition:(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(m,{name:n.getNameAsString(),context:t}),(0,f.jsxs)(i.Show,{when:n.getAlias()&&n.getAlias().length>0,children:[i.code` || `,(0,f.jsx)(i.For,{each:n.getAlias(),joiner:i.code` || `,children:e=>(0,f.jsx)(m,{name:e,context:t})})]})]}),children:i.code`
8
+ target["${n.getNameAsString()}"] = newValue;
9
+ return true;
10
+ `})}):null}const _=(0,s.refkey)(`createEnv`),v=(0,s.refkey)(`env`),y=(0,s.refkey)(`EnvSerializer`);function b(s){let[{defaultConfig:u},m]=(0,i.splitProps)(s,[`defaultConfig`]),b=(0,o.usePowerlines)(),x=(0,i.computed)(()=>b&&e.r(b,process.env)),S=e.t(b),C=(0,i.computed)(()=>new e.D.ReflectionClass({kind:e.D.ReflectionKind.objectLiteral,description:`The initial environment configuration state for the ${(0,n.titleCase)(b?.config?.name)} project.`,types:[]},S.data??void 0)),w=(0,i.computed)(()=>S.data?.getProperties().filter(e=>!e.isIgnored()).sort((e,t)=>e.getNameAsString().localeCompare(t.getNameAsString()))??[]),T=(0,i.computed)(()=>S.data?.getProperties().filter(e=>!e.isIgnored()&&!e.isReadonly()).sort((e,t)=>e.getNameAsString().localeCompare(t.getNameAsString()))??[]);return(0,f.jsxs)(c.BuiltinFile,{...m,id:`env`,description:`The Powerlines environment configuration module provides an interface to define environment configuration parameters.`,imports:(0,t.default)({"@powerlines/deepkit/vendor/type":[`Type`,`stringify`,`serializer`,`serializeFunction`,`deserializeFunction`,`ReflectionKind`,`TemplateState`,`Serializer`,`TypeProperty`,`TypePropertySignature`],"@powerlines/plugin-env/types/runtime":[{name:`EnvInterface`}]},m.imports??{}),children:[(0,f.jsxs)(i.Show,{when:!(0,r.isNull)(S.data),children:[(0,f.jsx)(p,{defaultValue:x.value,reflection:S.data}),(0,f.jsx)(`hbr`,{}),(0,f.jsx)(`hbr`,{})]}),(0,f.jsx)(d.TypescriptObject,{name:`initialEnv`,type:`Partial<EnvBase>`,defaultValue:x,reflection:C,export:!0,const:!0}),(0,f.jsx)(`hbr`,{}),(0,f.jsx)(`hbr`,{}),(0,f.jsxs)(l.TSDoc,{heading:`The environment configuration serializer for the Powerlines application.`,children:[(0,f.jsx)(l.TSDocLink,{children:`https://deepkit.io/docs/serialization/serializers`}),(0,f.jsx)(l.TSDocLink,{children:`https://github.com/marcj/untitled-code/blob/master/packages/type/src/serializer.ts#L1918`}),(0,f.jsx)(l.TSDocRemarks,{children:`This serializer is used to serialize and deserialize the Powerlines environment configuration.`})]}),(0,f.jsx)(a.ClassDeclaration,{refkey:y,name:`EnvSerializer`,extends:`Serializer`,export:!0,children:(0,f.jsx)(a.ClassMethod,{name:`constructor`,public:!0,children:i.code`
11
+ super("env");
12
+
13
+ this.deserializeRegistry.register(
14
+ ReflectionKind.boolean,
15
+ (type: Type, state: TemplateState) => {
16
+ state.addSetter(
17
+ \`typeof \${state.accessor.toString()} !== "boolean" ? \${state.accessor.toString()} === 1 || \${state.accessor.toString()} === "1" || \${state.accessor.toString()}.toLowerCase() === "t" || \${state.accessor.toString()}.toLowerCase() === "true" || \${state.accessor.toString()}.toLowerCase() === "y" || \${state.accessor.toString()}.toLowerCase() === "yes" : \${state.accessor.toString()}\`
18
+ );
19
+ }
20
+ );
21
+ `})}),(0,f.jsx)(`hbr`,{}),(0,f.jsx)(`hbr`,{}),(0,f.jsxs)(l.TSDoc,{heading:`A {@link EnvSerializer | environment configuration serializer} instance for the Powerlines application.`,children:[(0,f.jsx)(l.TSDocLink,{children:`https://deepkit.io/docs/serialization/serializers`}),(0,f.jsx)(l.TSDocLink,{children:`https://github.com/marcj/untitled-code/blob/master/packages/type/src/serializer.ts#L1918`}),(0,f.jsx)(l.TSDocRemarks,{children:`This serializer is used to serialize and deserialize the Powerlines environment configuration.`})]}),(0,f.jsx)(a.VarDeclaration,{name:`envSerializer`,export:!1,const:!0,initializer:(0,f.jsx)(a.NewExpression,{args:[],target:`EnvSerializer`})}),(0,f.jsx)(`hbr`,{}),(0,f.jsx)(`hbr`,{}),(0,f.jsxs)(l.TSDoc,{heading:`Serialize a environment configuration object to JSON data objects (not a JSON string).`,children:[(0,f.jsx)(l.TSDocRemarks,{children:`The resulting JSON object can be stringified using JSON.stringify().`}),(0,f.jsx)(l.TSDocExample,{children:`const json = serializeEnv(env);`}),(0,f.jsx)(l.TSDocThrows,{children:`ValidationError when serialization or validation fails.`})]}),(0,f.jsx)(a.VarDeclaration,{name:`serializeEnv`,export:!0,const:!0,initializer:`serializeFunction<EnvBase>(envSerializer)`}),(0,f.jsx)(`hbr`,{}),(0,f.jsx)(`hbr`,{}),(0,f.jsxs)(l.TSDoc,{heading:`Deserialize a environment configuration object from JSON data objects to JavaScript objects, without running any validators.`,children:[(0,f.jsx)(l.TSDocRemarks,{children:`Types that are already correct will be used as-is.`}),(0,f.jsx)(l.TSDocExample,{children:`const env = deserializeEnv(json);`}),(0,f.jsx)(l.TSDocThrows,{children:`ValidationError when deserialization fails.`})]}),(0,f.jsx)(a.VarDeclaration,{name:`deserializeEnv`,export:!0,const:!0,initializer:`deserializeFunction<EnvBase>(envSerializer)`}),(0,f.jsx)(`hbr`,{}),(0,f.jsx)(`hbr`,{}),(0,f.jsxs)(l.TSDoc,{heading:`Initializes the Powerlines environment configuration module.`,children:[(0,f.jsx)(l.TSDocRemarks,{children:`This function initializes the Powerlines environment configuration object.`}),(0,f.jsx)(l.TSDocParam,{name:`environmentConfig`,children:`The dynamic/runtime configuration - this could include the current environment variables or any other environment-specific settings provided by the runtime.`}),(0,f.jsx)(l.TSDocReturns,{children:`The initialized Powerlines configuration object.`})]}),(0,f.jsx)(i.Show,{when:!!b?.entryPath,children:(0,f.jsxs)(a.FunctionDeclaration,{refkey:_,async:!1,export:!0,name:`createEnv`,parameters:[{name:`environmentConfig`,type:`Partial<Env>`,optional:!1,default:`{}`}],returnType:`Env`,children:[i.code`
22
+ return new Proxy<Env>(
23
+ deserializeEnv({
24
+ ...initialEnv,
25
+ ...environmentConfig
26
+ }) as Env,
27
+ {
28
+ get: (target: EnvBase, propertyName: string) => { `,(0,f.jsx)(`hbr`,{}),(0,f.jsx)(i.For,{each:w,children:(e,t)=>(0,f.jsx)(h,{index:t,context:b,property:e})}),i.code`
29
+ return undefined;
30
+ }, `,(0,f.jsx)(`hbr`,{}),(0,f.jsx)(`hbr`,{}),i.code` set: (target: EnvBase, propertyName: string, newValue: any) => { `,(0,f.jsx)(`hbr`,{}),(0,f.jsx)(i.For,{each:T,ender:i.code` else `,children:(e,t)=>(0,f.jsx)(g,{index:t,context:b,property:e})}),(0,f.jsx)(`hbr`,{}),i.code`return false;
31
+ }
32
+ }
33
+ );
34
+ `]})}),(0,f.jsx)(`hbr`,{}),(0,f.jsx)(`hbr`,{}),(0,f.jsx)(`hbr`,{}),(0,f.jsx)(a.VarDeclaration,{refkey:v,name:`env`,type:`Env`,export:!0,const:!0,initializer:(0,f.jsxs)(f.Fragment,{children:[i.code`createEnv(`,u||`{}`,i.code` as Partial<Env>)`]})})]})}Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return p}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return b}});
@@ -0,0 +1,20 @@
1
+ import { Children } from "@alloy-js/core";
2
+ import { BuiltinFileProps } from "@powerlines/alloy/typescript/components/builtin-file";
3
+ import { TypeScriptInterfaceProps } from "@powerlines/alloy/typescript/components/typescript-interface";
4
+
5
+ //#region src/components/env.d.ts
6
+
7
+ /**
8
+ * Generates the environment configuration typescript definition for the Powerlines project.
9
+ */
10
+ declare function EnvTypeDefinition(props: Omit<TypeScriptInterfaceProps, "name">): Children;
11
+ interface EnvBuiltinProps extends Omit<BuiltinFileProps, "id"> {
12
+ defaultConfig?: Children;
13
+ }
14
+ /**
15
+ * Generates the environment configuration module for the Powerlines project.
16
+ */
17
+ declare function EnvBuiltin(props: EnvBuiltinProps): Children;
18
+ declare type __ΩEnvBuiltinProps = any[];
19
+ //#endregion
20
+ export { __ΩEnvBuiltinProps as i, EnvBuiltinProps as n, EnvTypeDefinition as r, EnvBuiltin as t };
@@ -0,0 +1 @@
1
+ export { };
@@ -0,0 +1 @@
1
+ export { };
@@ -0,0 +1 @@
1
+ export { };
@@ -0,0 +1 @@
1
+ export { };
package/dist/index.cjs CHANGED
@@ -1,10 +1,14 @@
1
- Object.defineProperty(exports,`__esModule`,{value:!0});const e=require(`./_virtual/rolldown_runtime.cjs`),t=require(`./deepkit/src/vendor/type.cjs`),n=require(`./helpers/reflect.cjs`),r=require(`./helpers/persistence.cjs`),i=require(`./helpers/template-helpers.cjs`),a=require(`./helpers/source-file-env.cjs`),o=require(`./helpers/load.cjs`),s=require(`./helpers/create-reflection-resource.cjs`);require(`./helpers/index.cjs`);const c=require(`./helpers/automd-generator.cjs`),l=require(`./components/docs.cjs`),u=require(`./components/env.cjs`);require(`./components/index.cjs`);const d=require(`./babel/plugin.cjs`);require(`./babel/index.cjs`);const f=require(`./alloy/src/create-plugin.cjs`),p=require(`./plugin-automd/src/index.cjs`),m=require(`./plugin-babel/src/index.cjs`);let h=require(`@stryke/string-format/title-case`),g=require(`defu`);g=e.__toESM(g);let _=require(`@stryke/convert/parse-type-definition`),v=require(`@storm-software/config-tools/types`),y=require(`@stryke/convert/to-array`),b=require(`@stryke/path/is-parent-path`),x=require(`@stryke/env/types`),S=require(`@alloy-js/core/jsx-runtime`),C=require(`@stryke/path/join`),w=require(`@stryke/fs/exists`),T=require(`@stryke/fs/helpers`),E=require(`@stryke/string-format/constant-case`);const D=f.createAlloyPlugin((e={})=>({name:`env`,async config(){this.log(v.LogLevelLabel.TRACE,"Providing default configuration for the Powerlines `env` build plugin.");let t={env:(0,g.default)(e,{types:{},prefix:[]}),transform:{babel:{plugins:[d.envBabelPlugin]}}};if(t.env.types)t.env.types=(0,_.parseTypeDefinition)(t.env.types);else{this.log(v.LogLevelLabel.WARN,"The `env.types` configuration parameter was not provided. Please ensure this is expected.");let e=await r.getEnvDefaultTypeDefinition(this);t.env.types=(0,_.parseTypeDefinition)(`${e.file}#${e.name}`)}if(t.env.secrets)t.env.secrets=(0,_.parseTypeDefinition)(t.env.secrets);else{let e=await r.getSecretsDefaultTypeDefinition(this);t.env.secrets=(0,_.parseTypeDefinition)(`${e.file}#${e.name}`)}return t.env.prefix=(0,y.toArray)(t.env.prefix??[]).reduce((e,t)=>{let n=(0,E.constantCase)(t);return e.includes(n)||e.push(n),e},[...x.ENV_PREFIXES,`POWERLINES_`]),t.env.prefix=t.env.prefix.reduce((e,t)=>(e.includes(t.replace(/_$/g,``))||e.push(t.replace(/_$/g,``)),e),[]),t},async configResolved(){if(this.log(v.LogLevelLabel.TRACE,`Environment plugin configuration has been resolved for the Powerlines project.`),this.config.env.inject??=this.config.projectType===`application`,this.env=(0,g.default)({parsed:await o.loadEnv(this,this.config.env)},this.env??{},{types:{env:{}},used:{env:{},secrets:{}},parsed:{},injected:{}}),this.config.command!==`prepare`&&this.persistedMeta?.checksum===this.meta.checksum&&(0,w.existsSync)(r.getEnvTypeReflectionsPath(this,`env`)))this.log(v.LogLevelLabel.TRACE,`Skipping reflection initialization as the meta checksum has not changed.`),this.env.types.env=await r.readEnvTypeReflection(this,`env`),(0,w.existsSync)(r.getEnvReflectionsPath(this,`env`))&&(this.env.used.env=await r.readEnvReflection(this)),(0,w.existsSync)(r.getEnvTypeReflectionsPath(this,`secrets`))&&(this.env.types.secrets=await r.readEnvTypeReflection(this,`secrets`)),(0,w.existsSync)(r.getEnvReflectionsPath(this,`secrets`))&&(this.env.used.secrets=await r.readSecretsReflection(this));else{if(this.env.types.env=await n.reflectEnv(this,this.config.env.types?.file?(0,b.isParentPath)(this.config.env.types?.file,this.workspaceConfig.workspaceRoot)?this.config.env.types?.file:(0,C.joinPaths)(this.config.projectRoot,this.config.env.types?.file):void 0,this.config.env.types?.name),!this.env.types.env)throw Error(`Failed to find the environment configuration type reflection in the context.`);if(await r.writeEnvTypeReflection(this,this.env.types.env,`env`),this.env.types.secrets=await n.reflectSecrets(this,this.config.env.secrets?.file?(0,b.isParentPath)(this.config.env.secrets?.file,this.workspaceConfig.workspaceRoot)?this.config.env.secrets?.file:(0,C.joinPaths)(this.config.projectRoot,this.config.env.secrets?.file):void 0,this.config.env.secrets?.name),!this.env.types.secrets)throw Error(`Failed to find the secrets configuration type reflection in the context.`);await r.writeEnvTypeReflection(this,this.env.types.secrets,`secrets`),this.log(v.LogLevelLabel.TRACE,`Resolved ${this.env.types.env.getProperties().length??0} environment configuration parameters and ${this.env.types.secrets?.getProperties().length??0} secret configuration parameters`);let e=this.env.types.env.getProperties().filter(e=>e.getAlias().length>0);Object.entries(await o.loadEnv(this,this.config.env)).forEach(([t,n])=>{let r=this.config.env.prefix.reduce((e,n)=>t.replace(/_$/g,``).startsWith(n)?t.replace(/_$/g,``).slice(n.length):e,t),i=e.find(e=>e?.getAlias().reverse().includes(r));(this.env.types.env?.hasProperty(r)||i)&&this.env.types.env.getProperty(r).setDefaultValue(n)}),this.env.used.env=new t.type_exports.ReflectionClass({kind:t.type_exports.ReflectionKind.objectLiteral,typeName:`Env`,description:`An object containing the environment configuration parameters used by the ${this.config.name?`${this.config.name} application`:`application`}.`,types:[]},this.env.types.env),await r.writeEnvReflection(this,this.env.used.env,`env`),this.env.types.secrets&&(await r.writeEnvTypeReflection(this,this.env.types.secrets,`secrets`),this.env.used.secrets=new t.type_exports.ReflectionClass({kind:t.type_exports.ReflectionKind.objectLiteral,typeName:`Secrets`,description:`An object containing the secret configuration parameters used by the ${this.config.name?`${this.config.name} application`:`application`}.`,types:[]},this.env.types.secrets),await r.writeEnvReflection(this,this.env.used.secrets,`secrets`))}},render(){let e=this;return this.log(v.LogLevelLabel.TRACE,`Preparing the Environment runtime artifacts for the Powerlines project.`),(0,S.createComponent)(u.EnvBuiltin,{get defaultConfig(){return e.config.env.defaultConfig}})},async docs(){this.log(v.LogLevelLabel.TRACE,`Writing Environment documentation for the Powerlines project artifacts.`);let e=(0,C.joinPaths)(this.config.projectRoot,`docs`,`generated`);(0,w.existsSync)(e)||await(0,T.createDirectory)(e);let n=await r.readEnvTypeReflection(this,`env`),i=(0,C.joinPaths)(e,`env.md`);this.log(v.LogLevelLabel.TRACE,`Documenting environment variables configuration in "${i}"`),await this.fs.write(i,`<!-- Generated by ${(0,h.titleCase)(this.config.framework)||`Powerlines`} -->
1
+ Object.defineProperty(exports,`__esModule`,{value:!0});const e=require(`./create-reflection-resource-I684bqD1.cjs`),t=require(`./env-CgSzbXBL.cjs`),n=require(`./docs-qvDyetF0.cjs`);require(`./components-C9bYrQVK.cjs`),require(`./plugin-D5qyQPqC.cjs`),require(`./runtime-Bisl_1Ja.cjs`),require(`./types-MYBaygjr.cjs`);let r=require(`@stryke/convert/to-array`),i=require(`@stryke/fs/is-file`),a=require(`@stryke/fs/list-files`),o=require(`@stryke/path/append`),s=require(`@stryke/path/is-type`),c=require(`@stryke/path/join-paths`),ee=require(`@stryke/path/replace`),l=require(`automd`),u=require(`c12`),d=require(`defu`);d=e.O(d);let f=require(`markdown-toc`);f=e.O(f);let p=require(`@babel/core`),m=require(`@storm-software/config-tools/types`),h=require(`@stryke/path/file-path-fns`),g=require(`@stryke/path/is-parent-path`),_=require(`@stryke/type-checks/is-set-object`),v=require(`@stryke/type-checks/is-function`);require(`@stryke/type-checks/is-object`);let te=require(`@stryke/type-checks/is-set-string`),y=require(`chalk`);y=e.O(y);let b=require(`@babel/generator`);b=e.O(b),require(`@babel/parser`);let x=require(`@babel/helper-plugin-utils`);require(`@storm-software/config-tools/logger`),require(`@storm-software/config-tools/utilities/colors`),require(`@stryke/helpers/noop`);let S=require(`@stryke/string-format/title-case`),C=require(`@babel/types`);C=e.O(C);let w=require(`@stryke/type-checks/is-string`),T=require(`@stryke/convert/parse-type-definition`),E=require(`@stryke/env/types`),D=require(`@stryke/fs/exists`),O=require(`@stryke/fs/helpers`),k=require(`@stryke/path/join`),A=require(`@stryke/string-format/constant-case`),j=require(`@stryke/capnp`);j=e.O(j);let M=require(`@stryke/helpers/get-unique`),N=require(`@stryke/json/storm-json`),ne=require(`@stryke/type-checks/is-null`),re=require(`@stryke/type-checks/is-undefined`),ie=require(`@stryke/fs/buffer`),P=require(`node:fs`),F=require(`@alloy-js/core/jsx-runtime`);const I=(e={})=>({name:`automd`,async config(){let t=await(0,l.loadConfig)((0,c.joinPaths)(this.workspaceConfig.workspaceRoot,this.config.projectRoot),e);return(!t.prefix||!Array.isArray(t.prefix))&&(t.prefix=(0,r.toArray)(t.prefix??[])),t.prefix.includes(`automd`)||t.prefix.push(`automd`),t.prefix.includes(`powerlines`)||t.prefix.push(`powerlines`),{automd:(0,d.default)(t??{},{configFile:e.configFile,allowIssues:!0,dir:this.config.projectRoot,watch:!1,input:`README.md`,toc:{maxDepth:6,bullets:`-`}})}},async configResolved(){if(this.config.framework&&!(0,r.toArray)(this.config.automd.prefix).includes(this.config.framework)&&(this.config.automd.prefix=(0,r.toArray)(this.config.automd.prefix).concat(this.config.framework)),this.config.automd.configFile){let{config:e}=await(0,u.loadConfig)({cwd:this.config.automd.dir,configFile:this.config.automd.configFile,defaults:{ignore:[`**/node_modules`,`**/dist`,`**/.*`],dir:this.config.automd.dir}});this.config.automd=(0,l.resolveConfig)((0,d.default)(this.config.automd,{...e,prefix:(0,r.toArray)(e.prefix??[])}))}this.config.automd.input=(await Promise.all((0,r.toArray)(this.config.automd.input).map(async e=>e.includes(`*`)?(0,a.listFiles)((0,s.isAbsolutePath)(e)?e:(0,o.appendPath)(e,this.config.projectRoot),{ignore:this.config.automd.ignore}):(0,s.isAbsolutePath)(e)?e:(0,o.appendPath)(e,this.config.projectRoot)))).flat(),this.config.automd.output&&!(0,s.isAbsolutePath)(this.config.automd.output)&&(this.config.automd.output=(0,o.appendPath)(this.config.automd.output,this.config.projectRoot)),this.config.automd.generators??={},this.config.automd.toc!==!1&&(this.config.automd.generators.toc??={name:`toc`,generate:e=>{let t=this.config.automd.toc??{};return{contents:(0,f.default)(e.block.md,{...t,maxdepth:t.maxDepth,first1:t.firstH1}).content}}})},async docs(){await Promise.all((0,r.toArray)(this.config.automd.input).map(async e=>{let t=await this.fs.read(e);if(t){let n=await(0,l.transform)(t,this.config.automd);if(n.hasIssues&&this.config.automd.allowIssues===!1)throw Error(`AutoMD found issues in file "${e}". Please resolve the issues or set \`allowIssues\` to true in the plugin configuration to ignore them.`);n.hasChanged&&await this.fs.write((0,o.appendPath)(this.config.automd.output?(0,i.isDirectory)(this.config.automd.output)?(0,ee.replacePath)(e,this.config.automd.output):this.config.automd.output:e,this.config.projectRoot),n.contents)}}))}});var L=I;function R(e){return(0,te.isSetString)(e)?e:Array.isArray(e)&&e.length>0?R(e[0]):e.$$name||e.name?e.$$name||e.name:void 0}function z(e,t){return!!(R(t)&&e.some(e=>Array.isArray(e)&&R(e[0])===R(t)))}function B(e,t){try{return Array.isArray(t)&&t.length>0&&t[0]?(0,v.isFunction)(t[0])?t[0](e):t[0]:(0,v.isFunction)(t)?t(e):t}catch{return t[0]}}function V(e,t,n,r){if(Array.isArray(r)&&r.length>0&&r[0]){if(r.length>2&&r[2]&&(0,v.isFunction)(r[2])&&!r[2](t,n)){e.log(m.LogLevelLabel.TRACE,`Skipping filtered Babel plugin ${y.default.bold.cyanBright(R(r)||`unnamed`)} for ${n}`);return}return r.length>2?[B(e,r),r[1],r[2]]:[B(e,r),r[1],null]}return[B(e,r),{},null]}let H=b.default;`default`in H&&(H=H.default);const U=[`#00A0DD`,`#6FCE4E`,`#FBBF24`,`#F43F5E`,`#3B82F6`,`#A855F7`,`#469592`,`#288EDF`,`#10B981`,`#EF4444`,`#F0EC56`,`#F472B6`,`#22D3EE`,`#EAB308`,`#84CC16`,`#F87171`,`#0EA5E9`,`#D946EF`,`#FACC15`,`#34D399`],W=(e,t)=>(n,...r)=>e(n,` ${y.default.inverse.hex(U[t.split(``).map(e=>e.charCodeAt(0)).reduce((e,t)=>e+t,0)%U.length]||U[0])(` ${(0,S.titleCase)(t)} `)} ${r.join(` `)} `);function G(e,t){let n=n=>(0,x.declare)((r,i,a)=>{r.cache.using(()=>n.meta.checksum),r.assertVersion(`^7.0.0-0`);let o=W(n.log,e);o(m.LogLevelLabel.TRACE,`Initializing the ${y.default.bold.cyanBright(e)} Babel plugin`);let s=t({log:o,name:e,api:r,options:i,context:n,dirname:a});return s.name=e,o(m.LogLevelLabel.TRACE,`Completed initialization of the ${y.default.bold.cyanBright(e)} Babel plugin`),s});return n.$$name=e,n}function K(e,t){ae(e.scope.getProgramParent().path,t)}function q(e){return e.get(`specifiers`).filter(Boolean).every(e=>e?.isImportSpecifier())&&e.node.importKind!==`type`&&e.node.importKind!==`typeof`}function J(e){let t=new Map;return e.traverse({ImportDeclaration(e){q(e)&&t.set(e.node.source.value,e)}}),t}function ae(e,t){J(e).get(t.module)||e.unshiftContainer(`body`,C.importDeclaration([C.importSpecifier(C.identifier(t.name||t.imported),C.identifier(t.imported))],C.stringLiteral(t.module)))}const oe=(e={})=>({name:`babel`,config(){if((0,_.isSetObject)(e))return{transform:{babel:e}}},configResolved:{order:`pre`,handler(){this.devDependencies[`@babel/core`]=`^7.28.4`,this.config.transform.babel=(0,d.default)(this.config.transform.babel??{},{plugins:[],presets:[]})}},async transform(t,n){if((0,g.isParentPath)(n,this.powerlinesPath)||t.includes(`/* @storm-ignore */`)||t.includes(`/* @storm-disable */`))return this.log(m.LogLevelLabel.TRACE,`Skipping Babel transformation for: ${n}`),{code:t,id:n};this.log(m.LogLevelLabel.TRACE,`Babel transforming file: ${n}`);let r=this.config.transform.babel.plugins.map(e=>V(this,t,n,e)).filter((e,t,n)=>e&&!z(n,e)),i=this.config.transform.babel.presets.map(e=>V(this,t,n,e)).filter((e,t,n)=>e&&!z(n,e));if(Array.isArray(r)&&r.length===0&&Array.isArray(i)&&i.length===0)return{code:t,id:n};[`ts`,`cts`,`mts`,`tsx`].includes((0,h.findFileExtensionSafe)(n))&&!z(r,`@babel/plugin-syntax-typescript`)&&!z(i,`@babel/preset-typescript`)&&r.unshift([`@babel/plugin-syntax-typescript`,{isTSX:(0,h.findFileExtension)(n)===`.tsx`}]);let a=await(0,p.transformAsync)(t,{highlightCode:!0,code:!0,ast:!1,cloneInputAst:!1,comments:!0,sourceType:`module`,configFile:!1,babelrc:!1,envName:this.config.mode,caller:{name:this.config.framework},...this.config.transform.babel??{},filename:n,plugins:r.map(t=>Array.isArray(t)&&t.length>=2?[t[0],(0,d.default)(t.length>1&&t[1]?t[1]:{},{options:e})]:t).filter(Boolean),presets:i.map(t=>Array.isArray(t)&&t.length>=2?[t[0],(0,d.default)(t.length>1&&t[1]?t[1]:{},{options:e})]:t).filter(Boolean)});if(!a?.code)throw Error(`Powerlines - Babel plugin failed to compile ${n}`);return{code:a.code,id:n}}});var se=oe;function ce(e,t){return X(e.type,t??e.getDefaultValue())}function Y(e){return`"${String(e).replaceAll(`"`,`\\"`)}"`}function X(t,n){return(0,re.isUndefined)(n)?`undefined`:(0,ne.isNull)(n)?`null`:t.kind===e.D.ReflectionKind.boolean?String(n).trim().toLowerCase()===`true`?`true`:`false`:t.kind===e.D.ReflectionKind.string||t.kind===e.D.ReflectionKind.literal&&(0,w.isString)(t.literal)?Y(n):t.kind===e.D.ReflectionKind.enum?Z(t).kind===e.D.ReflectionKind.string?Y(n):`${String(n)}`:t.kind===e.D.ReflectionKind.union?ue(t)?Y(n):`${String(n)}`:t.kind===e.D.ReflectionKind.array?Y(N.StormJSON.stringify(n)):t.kind===e.D.ReflectionKind.object||t.kind===e.D.ReflectionKind.objectLiteral?N.StormJSON.stringify(n):t.kind===e.D.ReflectionKind.property||t.kind===e.D.ReflectionKind.parameter?X(t.type,n):String(n)}function Z(t){if(t.kind!==e.D.ReflectionKind.enum)throw Error(`Expected a TypeEnum, but received ${t.kind}.`);let n=(0,M.getUniqueBy)(t.values.filter(e=>e!=null),t=>(0,w.isString)(t)?{kind:e.D.ReflectionKind.string}:{kind:e.D.ReflectionKind.number});if(n.length===0)throw Error(`No valid enum members could be found.`);return n[0]&&(0,w.isString)(n[0])?{kind:e.D.ReflectionKind.string}:{kind:e.D.ReflectionKind.number}}function le(t){if(t.kind===e.D.ReflectionKind.union&&t.types.length>0)return(0,M.getUniqueBy)(t.types,e=>e.kind);throw Error(`Expected a TypeUnion, but received ${t.kind}.`)}function ue(t){return le(t).some(t=>t.kind===e.D.ReflectionKind.string||t.kind===e.D.ReflectionKind.literal&&(0,w.isString)(t.literal))}const Q=G(`env`,({log:t,context:n})=>{function r(e,r,i=!1){let a=n.env.types.env?.getProperties().filter(e=>e.getAlias().length>0);if(e.name){let o=n.config.env.prefix.find(t=>e.name&&e.name.startsWith(t)&&(n.env.types.env?.hasProperty(e.name.replace(`${t}_`,``))||a.some(n=>n.getAlias().includes(e.name.replace(`${t}_`,``))))),s=e.name;if(o&&(s=e.name.replace(`${o}_`,``)),t(m.LogLevelLabel.TRACE,`Environment variable ${s} found in ${r.filename||`unknown file`}.`),n.env.types.env?.hasProperty(s)||a.some(e=>e.getAlias().includes(s))){let e=n.env.types.env.hasProperty(s)?n.env.types.env.getProperty(s):a.find(e=>e.getAlias().includes(s));if(!e||e.isIgnored())return;if(n.env.used.env.hasProperty(s)||n.env.used.env.addProperty(e.property),n.config.env.inject&&i){let t=n.env.parsed?.[s];if(t===void 0){let e=n.config.env.prefix.find(e=>n.env.parsed[`${e.replace(/_$/g,``)}_${s}`]);e&&(t=n.env.parsed[`${e.replace(/_$/g,``)}_${s}`])}if(t??=e.getDefaultValue(),e.isValueRequired()&&t===void 0)throw Error(`Environment variable \`${s}\` is not defined in the .env configuration files`);return ce(e,t)}}else throw Error(`The "${s}" environment variable is not defined in the \`env\` type definition, but is used in the source code file ${r.filename?r.filename:`unknown`}.
2
+
3
+ The following environment configuration names are defined in the \`env\` type definition: \n${n.env.types.env?.getPropertyNames().sort((e,t)=>String(e).localeCompare(String(t))).map(e=>` - ${String(e)} ${a.some(t=>t.getNameAsString()===String(e)&&t.getAlias().length>0)?`(Alias: ${a?.find(t=>t.getNameAsString()===String(e))?.getAlias().join(`, `)})`:``}`).join(`
4
+ `)} \n\nUsing the following env prefix: \n${n.config.env.prefix.map(e=>` - ${e}`).join(`
5
+ `)} \n\nPlease check your \`env\` configuration option. If you are using a custom dotenv type definition, please make sure that the configuration names match the ones in the code. \n\n`)}}return{visitor:{MemberExpression(e,t){if(e.get(`object`)?.get(`property`)?.isIdentifier({name:`env`})&&e.get(`object`)?.get(`object`)?.isIdentifier({name:`$storm`})&&e.get(`property`)?.isIdentifier()){let n=e.get(`property`)?.node;r(n,t,!1),e.replaceWithSourceString(`env.${n.name}`),K(e,{module:`storm:env`,name:`env`,imported:`env`})}else if(e.get(`object`)?.get(`property`)?.isIdentifier({name:`env`})&&e.get(`object`)?.get(`object`)?.isCallExpression({callee:{name:`useStorm`,type:`Identifier`}})&&e.get(`property`)?.isIdentifier()){let n=e.get(`property`)?.node;r(n,t,!1),e.replaceWithSourceString(`env.${n.name}`),K(e,{module:`storm:env`,name:`env`,imported:`env`})}else if(e.get(`object`)?.get(`property`)?.isIdentifier({name:`env`})&&e.get(`object`)?.get(`object`)?.isIdentifier({name:`process`})&&e.get(`property`)?.isIdentifier()){let n=e.get(`property`)?.node;if(!n.name)return;r(n,t,!1),e.replaceWithSourceString(`env.${n.name}`),K(e,{module:`storm:env`,name:`env`,imported:`env`})}else if(e.get(`object`)?.get(`property`)?.isIdentifier({name:`env`})&&e.get(`object`)?.get(`object`)?.isMetaProperty()&&e.get(`property`)?.isIdentifier()){let n=e.get(`property`)?.node;if(!n.name)return;r(n,t,!1),e.replaceWithSourceString(`env.${n.name}`),K(e,{module:`storm:env`,name:`env`,imported:`env`})}}},post(){t(m.LogLevelLabel.TRACE,`Adding environment variables from ${this.filename||`unknown file`} to env.json.`);let r=e.D.ReflectionClass.from({kind:e.D.ReflectionKind.objectLiteral,description:`An object containing the environment variables used by the application.`,types:[]}),i=e.s(n,`env`);i&&(0,P.existsSync)(i)&&(t(m.LogLevelLabel.TRACE,`Environment reflection file found at ${i}, reading existing reflection.`),r=(0,e.D.resolveClassType)((0,e.D.deserializeType)(e.E(new j.Message((0,ie.readFileBufferSync)(i),!1).getRoot(e.T).types)))),t(m.LogLevelLabel.TRACE,`Adding new variables to env reflection at ${i}.`),r.getProperties().filter(e=>e.getNameAsString()&&!n.env.used.env.hasProperty(e.getNameAsString())).forEach(e=>{n.env.used.env.addProperty({...e,name:e.getNameAsString(),description:e.getDescription()??`The ${e.getNameAsString()} variable.`,default:e.getDefaultValue(),optional:e.isOptional()?!0:void 0,readonly:e.isReadonly()?!0:void 0,visibility:e.getVisibility(),type:e.getType(),tags:e.getTags()})})}}}),de=e=>(0,l.defineGenerator)({name:`env`,async generate(){let t=(0,c.joinPaths)(e.config.projectRoot,`docs`,`generated`,`env.md`);return e.fs.existsSync(t)?{contents:await e.fs.read(t)||``}:{contents:``}}});async function fe(t,n){let r=await e.d(t,n);return r.getProperties().forEach(e=>{e.getAlias().filter(Boolean).forEach(t=>{r.addProperty({name:t,optional:e.isOptional()?!0:void 0,readonly:e.isReadonly()?!0:void 0,description:e.getDescription(),visibility:e.getVisibility(),type:e.getType(),default:e.getDefaultValue(),tags:{hidden:e.isHidden(),ignore:e.isIgnored(),internal:e.isInternal(),alias:e.getAlias().filter(e=>e!==t).concat(e.name),title:e.getTitle()||(0,S.titleCase)(e.name),readonly:e.isReadonly(),permission:e.getPermission(),domain:e.getDomain()}})})}),r}const $=(n={})=>[se(n.babel),{name:`env`,async config(){this.log(m.LogLevelLabel.TRACE,"Providing default configuration for the Powerlines `env` build plugin.");let t={env:(0,d.default)(n,{types:{},prefix:[]}),transform:{babel:{plugins:[Q]}}};if(t.env.types)t.env.types=(0,T.parseTypeDefinition)(t.env.types);else{this.log(m.LogLevelLabel.WARN,"The `env.types` configuration parameter was not provided. Please ensure this is expected.");let n=await e.o(this);t.env.types=(0,T.parseTypeDefinition)(`${n.file}#${n.name}`)}if(t.env.secrets)t.env.secrets=(0,T.parseTypeDefinition)(t.env.secrets);else{let n=await e.l(this);t.env.secrets=(0,T.parseTypeDefinition)(`${n.file}#${n.name}`)}return t.env.prefix=(0,r.toArray)(t.env.prefix??[]).reduce((e,t)=>{let n=(0,A.constantCase)(t);return e.includes(n)||e.push(n),e},[...E.ENV_PREFIXES,`POWERLINES_`]),t.env.prefix=t.env.prefix.reduce((e,t)=>(e.includes(t.replace(/_$/g,``))||e.push(t.replace(/_$/g,``)),e),[]),t},async configResolved(){if(this.log(m.LogLevelLabel.TRACE,`Environment plugin configuration has been resolved for the Powerlines project.`),this.config.env.inject??=this.config.projectType===`application`,this.env=(0,d.default)({parsed:await e.n(this,this.config.env)},this.env??{},{types:{env:{}},used:{env:{},secrets:{}},parsed:{},injected:{}}),this.config.command!==`prepare`&&this.persistedMeta?.checksum===this.meta.checksum&&(0,D.existsSync)(e.c(this,`env`)))this.log(m.LogLevelLabel.TRACE,`Skipping reflection initialization as the meta checksum has not changed.`),this.env.types.env=await e.d(this,`env`),(0,D.existsSync)(e.s(this,`env`))&&(this.env.used.env=await e.u(this)),(0,D.existsSync)(e.c(this,`secrets`))&&(this.env.types.secrets=await e.d(this,`secrets`)),(0,D.existsSync)(e.s(this,`secrets`))&&(this.env.used.secrets=await e.f(this));else{if(this.env.types.env=await e.C(this,this.config.env.types?.file?(0,g.isParentPath)(this.config.env.types?.file,this.workspaceConfig.workspaceRoot)?this.config.env.types?.file:(0,k.joinPaths)(this.config.projectRoot,this.config.env.types?.file):void 0,this.config.env.types?.name),!this.env.types.env)throw Error(`Failed to find the environment configuration type reflection in the context.`);if(await e.g(this,this.env.types.env,`env`),this.env.types.secrets=await e.w(this,this.config.env.secrets?.file?(0,g.isParentPath)(this.config.env.secrets?.file,this.workspaceConfig.workspaceRoot)?this.config.env.secrets?.file:(0,k.joinPaths)(this.config.projectRoot,this.config.env.secrets?.file):void 0,this.config.env.secrets?.name),!this.env.types.secrets)throw Error(`Failed to find the secrets configuration type reflection in the context.`);await e.g(this,this.env.types.secrets,`secrets`),this.log(m.LogLevelLabel.TRACE,`Resolved ${this.env.types.env.getProperties().length??0} environment configuration parameters and ${this.env.types.secrets?.getProperties().length??0} secret configuration parameters`);let t=this.env.types.env.getProperties().filter(e=>e.getAlias().length>0);Object.entries(await e.n(this,this.config.env)).forEach(([e,n])=>{let r=this.config.env.prefix.reduce((t,n)=>e.replace(/_$/g,``).startsWith(n)?e.replace(/_$/g,``).slice(n.length):t,e),i=t.find(e=>e?.getAlias().reverse().includes(r));(this.env.types.env?.hasProperty(r)||i)&&this.env.types.env.getProperty(r).setDefaultValue(n)}),this.env.used.env=new e.D.ReflectionClass({kind:e.D.ReflectionKind.objectLiteral,typeName:`Env`,description:`An object containing the environment configuration parameters used by the ${this.config.name?`${this.config.name} application`:`application`}.`,types:[]},this.env.types.env),await e.m(this,this.env.used.env,`env`),this.env.types.secrets&&(await e.g(this,this.env.types.secrets,`secrets`),this.env.used.secrets=new e.D.ReflectionClass({kind:e.D.ReflectionKind.objectLiteral,typeName:`Secrets`,description:`An object containing the secret configuration parameters used by the ${this.config.name?`${this.config.name} application`:`application`}.`,types:[]},this.env.types.secrets),await e.m(this,this.env.used.secrets,`secrets`))}},async prepare(){return this.log(m.LogLevelLabel.TRACE,`Preparing the Environment runtime artifacts for the Powerlines project.`),this.render((0,F.jsx)(t.t,{defaultConfig:this.config.env.defaultConfig}))},async docs(){this.log(m.LogLevelLabel.TRACE,`Writing Environment documentation for the Powerlines project artifacts.`);let t=(0,k.joinPaths)(this.config.projectRoot,`docs`,`generated`);(0,D.existsSync)(t)||await(0,O.createDirectory)(t);let n=await e.d(this,`env`),r=(0,k.joinPaths)(t,`env.md`);this.log(m.LogLevelLabel.TRACE,`Documenting environment variables configuration in "${r}"`),await this.fs.write(r,`<!-- Generated by ${(0,S.titleCase)(this.config.framework)||`Powerlines`} -->
2
6
 
3
7
  Below is a list of environment variables used by the [${this.packageJson.name}](https://www.npmjs.com/package/${this.packageJson.name}) package. These values can be updated in the \`.env\` file in the root of the project. The variables in the list below are used as configuration parameters to drive the processing of the application. The data contained in these variables are **not** considered sensitive or confidential. Any values provided in these variables will be available in plain text to the public.
4
8
 
5
9
  | Name | Description | Type | Default Value | Required |
6
10
  | ---- | ----------- | ---- | ------------- | :------: |
7
- ${n.getProperties().filter(e=>e.getNameAsString()!==`__POWERLINES_INJECTED__`).sort((e,t)=>e.getNameAsString().localeCompare(t.getNameAsString())).map(e=>`| ${e.getNameAsString().trim()} | ${(e.getDescription()?.replaceAll(`\r`,``)?.replaceAll(`
8
- `,``)??``).trim()} | ${(0,t.type_exports.stringifyType)(e.getType()).trim().replaceAll(` | `,`, or `)} | ${e.hasDefault()?String(e.getDefaultValue())?.includes(`"`)?e.getDefaultValue():`\`${e.getDefaultValue()}\``:``} | ${e.isValueRequired()?``:`✔`} |`).join(`
11
+ ${n.getProperties().filter(e=>e.getNameAsString()!==`__POWERLINES_INJECTED__`).sort((e,t)=>e.getNameAsString().localeCompare(t.getNameAsString())).map(t=>`| ${t.getNameAsString().trim()} | ${(t.getDescription()?.replaceAll(`\r`,``)?.replaceAll(`
12
+ `,``)??``).trim()} | ${(0,e.D.stringifyType)(t.getType()).trim().replaceAll(` | `,`, or `)} | ${t.hasDefault()?String(t.getDefaultValue())?.includes(`"`)?t.getDefaultValue():`\`${t.getDefaultValue()}\``:``} | ${t.isValueRequired()?``:`✔`} |`).join(`
9
13
  `)}
10
- `)},async buildEnd(){let e=r.getEnvReflectionsPath(this,`env`);this.log(v.LogLevelLabel.TRACE,`Writing env reflection types to ${e}.`),await r.writeEnvReflection(this,this.env.used.env,`env`)}})),O=(e={})=>[m.default(e.babel),D(e),{name:`env:automd-generator`,config(){return{automd:(0,g.default)(e.automd??{},{generators:{env:c.env(this)}})}}},{name:`env:vite`,vite:{configResolved(){return{envPrefix:this.config?.env?.prefix}}}},p.default(e.automd)];var k=O;exports.BaseEnv=n.BaseEnv,exports.BaseSecrets=n.BaseSecrets,exports.EnvBuiltin=u.EnvBuiltin,exports.EnvDocs=l.EnvDocs,exports.EnvTypeDefinition=u.EnvTypeDefinition,exports.createEnvReflection=n.createEnvReflection,exports.createReflectionResource=s.createReflectionResource,exports.createSecretsReflection=n.createSecretsReflection,exports.createTemplateReflection=i.createTemplateReflection,exports.default=k,exports.envBabelPlugin=d.envBabelPlugin,exports.formatEnvField=a.formatEnvField,exports.getEnvDefaultTypeDefinition=r.getEnvDefaultTypeDefinition,exports.getEnvReflectionsPath=r.getEnvReflectionsPath,exports.getEnvTypeReflectionsPath=r.getEnvTypeReflectionsPath,exports.getSecretsDefaultTypeDefinition=r.getSecretsDefaultTypeDefinition,exports.loadEnv=o.loadEnv,exports.loadEnvFromContext=o.loadEnvFromContext,exports.mergeEnvReflections=n.mergeEnvReflections,exports.mergeSecretsReflections=n.mergeSecretsReflections,exports.plugin=O,exports.readEnvReflection=r.readEnvReflection,exports.readEnvTypeReflection=r.readEnvTypeReflection,exports.readSecretsReflection=r.readSecretsReflection,exports.reflectEnv=n.reflectEnv,exports.reflectSecrets=n.reflectSecrets,exports.removeEnvPrefix=a.removeEnvPrefix,exports.resolveRuntimeTypeFile=r.resolveRuntimeTypeFile,exports.writeEnvReflection=r.writeEnvReflection,exports.writeEnvReflectionSync=r.writeEnvReflectionSync,exports.writeEnvTypeReflection=r.writeEnvTypeReflection;
14
+ `)},async buildEnd(){let t=e.s(this,`env`);this.log(m.LogLevelLabel.TRACE,`Writing env reflection types to ${t}.`),await e.m(this,this.env.used.env,`env`)}},{name:`env:automd-generator`,config(){return{automd:(0,d.default)(n.automd??{},{generators:{env:de(this)}})}}},{name:`env:vite`,vite:{configResolved(){return{envPrefix:this.config?.env?.prefix}}}},L(n.automd)];var pe=$;exports.BaseEnv=e._,exports.BaseSecrets=e.v,exports.EnvBuiltin=t.t,exports.EnvDocs=n.t,exports.EnvTypeDefinition=t.n,exports.createEnvReflection=e.y,exports.createReflectionResource=e.t,exports.createSecretsReflection=e.b,exports.createTemplateReflection=fe,exports.default=pe,exports.envBabelPlugin=Q,exports.formatEnvField=e.i,exports.getEnvDefaultTypeDefinition=e.o,exports.getEnvReflectionsPath=e.s,exports.getEnvTypeReflectionsPath=e.c,exports.getSecretsDefaultTypeDefinition=e.l,exports.loadEnv=e.n,exports.loadEnvFromContext=e.r,exports.mergeEnvReflections=e.x,exports.mergeSecretsReflections=e.S,exports.plugin=$,exports.readEnvReflection=e.u,exports.readEnvTypeReflection=e.d,exports.readSecretsReflection=e.f,exports.reflectEnv=e.C,exports.reflectSecrets=e.w,exports.removeEnvPrefix=e.a,exports.resolveRuntimeTypeFile=e.p,exports.writeEnvReflection=e.m,exports.writeEnvReflectionSync=e.h,exports.writeEnvTypeReflection=e.g;
package/dist/index.d.cts CHANGED
@@ -1,16 +1,189 @@
1
- import { Plugin } from "./powerlines/src/types/plugin.cjs";
2
- import { EnvInterface, SecretsInterface, __ΩEnvInterface, __ΩSecretsInterface } from "./types/runtime.cjs";
3
- import { EnvPluginContext, EnvPluginOptions, EnvPluginResolvedConfig, EnvPluginUserConfig, EnvType, __ΩEnvPluginContext, __ΩEnvPluginOptions, __ΩEnvPluginResolvedConfig, __ΩEnvPluginUserConfig, __ΩEnvType } from "./types/plugin.cjs";
4
- import { EnvDocs } from "./components/docs.cjs";
5
- import { EnvBuiltin, EnvBuiltinProps, EnvTypeDefinition, __ΩEnvBuiltinProps } from "./components/env.cjs";
6
- import { createReflectionResource } from "./helpers/create-reflection-resource.cjs";
7
- import { loadEnv, loadEnvFromContext } from "./helpers/load.cjs";
8
- import { getEnvDefaultTypeDefinition, getEnvReflectionsPath, getEnvTypeReflectionsPath, getSecretsDefaultTypeDefinition, readEnvReflection, readEnvTypeReflection, readSecretsReflection, resolveRuntimeTypeFile, writeEnvReflection, writeEnvReflectionSync, writeEnvTypeReflection } from "./helpers/persistence.cjs";
9
- import { BaseEnv, BaseSecrets, CreateEnvReflectionOptions, __ΩCreateEnvReflectionOptions, createEnvReflection, createSecretsReflection, mergeEnvReflections, mergeSecretsReflections, reflectEnv, reflectSecrets } from "./helpers/reflect.cjs";
10
- import { formatEnvField, removeEnvPrefix } from "./helpers/source-file-env.cjs";
11
- import { createTemplateReflection } from "./helpers/template-helpers.cjs";
12
- import { envBabelPlugin } from "./babel/plugin.cjs";
1
+ import { a as EnvType, c as __ΩEnvPluginResolvedConfig, d as type_d_exports, i as EnvPluginUserConfig, l as __ΩEnvPluginUserConfig, n as EnvPluginOptions, o as __ΩEnvPluginContext, r as EnvPluginResolvedConfig, s as __ΩEnvPluginOptions, t as EnvPluginContext, u as __ΩEnvType } from "./plugin-CPy0CKXL.cjs";
2
+ import { t as EnvDocs } from "./docs-CdtUw4WA.cjs";
3
+ import { i as __ΩEnvBuiltinProps, n as EnvBuiltinProps, r as EnvTypeDefinition, t as EnvBuiltin } from "./env-COWzTupf.cjs";
4
+ import "./index-DWPDThxu.cjs";
5
+ import { d as UnresolvedContext, i as __ΩSecretsInterface, l as Context, n as SecretsInterface, r as __ΩEnvInterface, t as EnvInterface } from "./runtime-Bo02eIQ-.cjs";
6
+ import "./index-B_e8BwCm.cjs";
7
+ import * as _alloy_js_core0 from "@alloy-js/core";
8
+ import * as powerlines0 from "powerlines";
9
+ import { Plugin } from "powerlines";
10
+ import { TypeDefinition } from "@stryke/types/configuration";
11
+ import { DotenvParseOutput } from "@stryke/env/types";
13
12
 
13
+ //#region src/babel/plugin.d.ts
14
+ declare const envBabelPlugin: powerlines0.DeclareBabelTransformPluginReturn<EnvPluginContext<EnvPluginResolvedConfig>, Record<string, any>>;
15
+ //#endregion
16
+ //#region src/helpers/create-reflection-resource.d.ts
17
+ /**
18
+ * Creates a reflection resource for the environment configuration.
19
+ *
20
+ * @param context - The environment plugin context.
21
+ * @returns A resource that provides the reflection of the environment configuration.
22
+ */
23
+ declare function createReflectionResource(context?: EnvPluginContext): _alloy_js_core0.Resource<type_d_exports.ReflectionClass<Record<string, any>>>;
24
+ //#endregion
25
+ //#region src/helpers/load.d.ts
26
+ /**
27
+ * Retrieves various dotenv configuration parameters from the context.
28
+ *
29
+ * @param context - The context to retrieve the dotenv configuration from.
30
+ * @param parsed - The parsed dotenv configuration.
31
+ * @returns An object containing the dotenv configuration.
32
+ */
33
+ declare function loadEnvFromContext(context: EnvPluginContext, parsed: DotenvParseOutput): {
34
+ APP_NAME: string | undefined;
35
+ APP_VERSION: string | undefined;
36
+ BUILD_ID: string;
37
+ BUILD_TIMESTAMP: string;
38
+ BUILD_CHECKSUM: string;
39
+ RELEASE_ID: string;
40
+ RELEASE_TAG: string;
41
+ DEFAULT_LOCALE: string | undefined;
42
+ DEFAULT_TIMEZONE: string | undefined;
43
+ LOG_LEVEL: "error" | "warn" | "info" | "debug" | "trace" | null;
44
+ ERROR_URL: string | undefined;
45
+ ORGANIZATION: string | undefined;
46
+ PLATFORM: "node" | "browser" | "neutral" | undefined;
47
+ MODE: "test" | "development" | "production" | undefined;
48
+ DEBUG: boolean;
49
+ STACKTRACE: boolean;
50
+ ENVIRONMENT: powerlines0.EnvironmentResolvedConfig;
51
+ };
52
+ declare function loadEnv<TEnv extends DotenvParseOutput = DotenvParseOutput>(context: EnvPluginContext, options: EnvPluginOptions): Promise<TEnv>;
53
+ //#endregion
54
+ //#region src/helpers/persistence.d.ts
55
+ /**
56
+ * Resolves the runtime type definition file for the environment variables.
57
+ *
58
+ * @param context - The plugin context.
59
+ * @returns The runtime type definition file for the environment variables.
60
+ */
61
+ declare function resolveRuntimeTypeFile(context: UnresolvedContext<EnvPluginResolvedConfig>): Promise<string>;
62
+ /**
63
+ * Gets the default type definition for the environment variables.
64
+ *
65
+ * @param context - The plugin context.
66
+ * @returns The default type definition for the environment variables.
67
+ */
68
+ declare function getEnvDefaultTypeDefinition(context: UnresolvedContext<EnvPluginResolvedConfig>): Promise<TypeDefinition>;
69
+ /** Gets the default type definition for the environment secrets.
70
+ *
71
+ * @param context - The plugin context.
72
+ * @returns The default type definition for the environment secrets.
73
+ */
74
+ declare function getSecretsDefaultTypeDefinition(context: UnresolvedContext<EnvPluginResolvedConfig>): Promise<TypeDefinition>;
75
+ /**
76
+ * Gets the path to the environment type reflections.
77
+ *
78
+ * @param context - The plugin context.
79
+ * @param name - The name of the type reflections.
80
+ * @returns The path to the environment type reflections.
81
+ */
82
+ declare function getEnvTypeReflectionsPath(context: Context<EnvPluginResolvedConfig>, name?: EnvType): string;
83
+ /**
84
+ * Reads the environment type reflection from the file system.
85
+ *
86
+ * @param context - The plugin context.
87
+ * @param name - The name of the type reflections.
88
+ * @returns The environment type reflection.
89
+ */
90
+ declare function readEnvTypeReflection(context: EnvPluginContext, name?: EnvType): Promise<type_d_exports.ReflectionClass<any>>;
91
+ /**
92
+ * Writes the environment type reflection to the file system.
93
+ *
94
+ * @param context - The plugin context.
95
+ * @param reflection - The environment type reflection to write.
96
+ * @param name - The name of the type reflections.
97
+ */
98
+ declare function writeEnvTypeReflection(context: EnvPluginContext, reflection: type_d_exports.ReflectionClass<any>, name?: EnvType): Promise<void>;
99
+ declare function getEnvReflectionsPath(context: EnvPluginContext, name: EnvType): string;
100
+ /**
101
+ * Reads the environment reflection data from the file system.
102
+ *
103
+ * @param context - The plugin context.
104
+ * @returns The environment reflection data.
105
+ */
106
+ declare function readEnvReflection(context: EnvPluginContext): Promise<type_d_exports.ReflectionClass<any>>;
107
+ /**
108
+ * Reads the secret environment reflection data from the file system.
109
+ *
110
+ * @param context - The plugin context.
111
+ * @returns The environment reflection data.
112
+ */
113
+ declare function readSecretsReflection(context: EnvPluginContext): Promise<type_d_exports.ReflectionClass<any>>;
114
+ /**
115
+ * Writes the environment reflection data to the file system.
116
+ *
117
+ * @param context - The plugin context.
118
+ * @param reflection - The reflection data to write.
119
+ * @param name - The name of the reflection (either "env" or "secrets").
120
+ */
121
+ declare function writeEnvReflection(context: EnvPluginContext, reflection: type_d_exports.ReflectionClass<any>, name?: EnvType): Promise<void>;
122
+ /**
123
+ * Writes the environment reflection data to the file system.
124
+ *
125
+ * @param context - The plugin context.
126
+ * @param reflection - The reflection data to write.
127
+ * @param name - The name of the reflection (either "env" or "secrets").
128
+ */
129
+ declare function writeEnvReflectionSync(context: EnvPluginContext, reflection: type_d_exports.ReflectionClass<any>, name?: EnvType): void;
130
+ //#endregion
131
+ //#region src/helpers/reflect.d.ts
132
+ declare function mergeEnvReflections(context: EnvPluginContext, reflections: type_d_exports.ReflectionClass<any>[]): type_d_exports.ReflectionClass<any>;
133
+ declare function mergeSecretsReflections(context: EnvPluginContext, reflections: type_d_exports.ReflectionClass<any>[]): type_d_exports.ReflectionClass<any>;
134
+ interface CreateEnvReflectionOptions {
135
+ type?: type_d_exports.TypeObjectLiteral | type_d_exports.TypeClass;
136
+ superReflection?: type_d_exports.ReflectionClass<any>;
137
+ }
138
+ declare class BaseEnv implements EnvInterface {
139
+ APP_NAME: string;
140
+ APP_VERSION: string;
141
+ BUILD_ID: string;
142
+ BUILD_TIMESTAMP: string;
143
+ BUILD_CHECKSUM: string;
144
+ RELEASE_ID: string;
145
+ RELEASE_TAG: string;
146
+ ORGANIZATION: string;
147
+ PLATFORM: "node" | "browser" | "neutral";
148
+ MODE: "development" | "test" | "production";
149
+ ENVIRONMENT: string;
150
+ DEBUG: boolean;
151
+ TEST: boolean;
152
+ MINIMAL: boolean;
153
+ NO_COLOR: boolean;
154
+ FORCE_COLOR: number | boolean;
155
+ FORCE_HYPERLINK: number | boolean;
156
+ STACKTRACE: boolean;
157
+ INCLUDE_ERROR_DATA: boolean;
158
+ ERROR_URL: string;
159
+ DEFAULT_TIMEZONE: string;
160
+ DEFAULT_LOCALE: string;
161
+ CI: boolean;
162
+ }
163
+ declare class BaseSecrets implements SecretsInterface {
164
+ ENCRYPTION_KEY: string;
165
+ }
166
+ declare function createEnvReflection(context: EnvPluginContext, options?: CreateEnvReflectionOptions): type_d_exports.ReflectionClass<any>;
167
+ declare function createSecretsReflection(context: EnvPluginContext, options?: CreateEnvReflectionOptions): type_d_exports.ReflectionClass<any>;
168
+ declare function reflectEnv(context: EnvPluginContext, file?: string, name?: string): Promise<type_d_exports.ReflectionClass<any>>;
169
+ declare function reflectSecrets(context: EnvPluginContext, file?: string, name?: string): Promise<type_d_exports.ReflectionClass<any>>;
170
+ declare type __ΩCreateEnvReflectionOptions = any[];
171
+ //#endregion
172
+ //#region src/helpers/source-file-env.d.ts
173
+ type TReturned<TEnv> = TEnv extends string ? string : DotenvParseOutput;
174
+ declare function removeEnvPrefix<TEnv extends DotenvParseOutput | string>(env: TEnv): TReturned<TEnv>;
175
+ declare function formatEnvField(key: string): string;
176
+ //#endregion
177
+ //#region src/helpers/template-helpers.d.ts
178
+ /**
179
+ * Creates the reflection data used when generating runtime template files.
180
+ *
181
+ * @param context - The context for the configuration plugin.
182
+ * @param name - The name of the configuration template.
183
+ * @returns The reflection for the specified configuration template.
184
+ */
185
+ declare function createTemplateReflection(context: EnvPluginContext, name?: EnvType): Promise<type_d_exports.ReflectionClass<any>>;
186
+ //#endregion
14
187
  //#region src/index.d.ts
15
188
  /**
16
189
  * A Powerlines plugin to inject environment variables into the source code.
package/dist/index.d.mts CHANGED
@@ -1,21 +1,189 @@
1
- import { Plugin } from "./powerlines/src/types/plugin.mjs";
2
- import "./powerlines/src/index.mjs";
3
- import { EnvInterface, SecretsInterface, __ΩEnvInterface, __ΩSecretsInterface } from "./types/runtime.mjs";
4
- import { EnvPluginContext, EnvPluginOptions, EnvPluginResolvedConfig, EnvPluginUserConfig, EnvType, __ΩEnvPluginContext, __ΩEnvPluginOptions, __ΩEnvPluginResolvedConfig, __ΩEnvPluginUserConfig, __ΩEnvType } from "./types/plugin.mjs";
5
- import { EnvDocs } from "./components/docs.mjs";
6
- import { EnvBuiltin, EnvBuiltinProps, EnvTypeDefinition, __ΩEnvBuiltinProps } from "./components/env.mjs";
7
- import "./components/index.mjs";
8
- import { createReflectionResource } from "./helpers/create-reflection-resource.mjs";
9
- import { loadEnv, loadEnvFromContext } from "./helpers/load.mjs";
10
- import { getEnvDefaultTypeDefinition, getEnvReflectionsPath, getEnvTypeReflectionsPath, getSecretsDefaultTypeDefinition, readEnvReflection, readEnvTypeReflection, readSecretsReflection, resolveRuntimeTypeFile, writeEnvReflection, writeEnvReflectionSync, writeEnvTypeReflection } from "./helpers/persistence.mjs";
11
- import { BaseEnv, BaseSecrets, CreateEnvReflectionOptions, __ΩCreateEnvReflectionOptions, createEnvReflection, createSecretsReflection, mergeEnvReflections, mergeSecretsReflections, reflectEnv, reflectSecrets } from "./helpers/reflect.mjs";
12
- import { formatEnvField, removeEnvPrefix } from "./helpers/source-file-env.mjs";
13
- import { createTemplateReflection } from "./helpers/template-helpers.mjs";
14
- import "./helpers/index.mjs";
15
- import "./types/index.mjs";
16
- import { envBabelPlugin } from "./babel/plugin.mjs";
17
- import "./babel/index.mjs";
1
+ import { t as EnvDocs } from "./docs-CKCRAUnO.mjs";
2
+ import { i as __ΩEnvBuiltinProps, n as EnvBuiltinProps, r as EnvTypeDefinition, t as EnvBuiltin } from "./env-DqPOEUEu.mjs";
3
+ import "./index-CW2WHUXP.mjs";
4
+ import { a as EnvType, c as __ΩEnvPluginResolvedConfig, d as type_d_exports, i as EnvPluginUserConfig, l as __ΩEnvPluginUserConfig, n as EnvPluginOptions, o as __ΩEnvPluginContext, r as EnvPluginResolvedConfig, s as __ΩEnvPluginOptions, t as EnvPluginContext, u as __ΩEnvType } from "./plugin-Cz3MZ6FL.mjs";
5
+ import { d as UnresolvedContext, i as __ΩSecretsInterface, l as Context, n as SecretsInterface, r as __ΩEnvInterface, t as EnvInterface } from "./runtime-B7kcxFAf.mjs";
6
+ import "./index-DCQ5Y2ED.mjs";
7
+ import { DotenvParseOutput } from "@stryke/env/types";
8
+ import * as _alloy_js_core0 from "@alloy-js/core";
9
+ import * as powerlines0 from "powerlines";
10
+ import { Plugin } from "powerlines";
11
+ import { TypeDefinition } from "@stryke/types/configuration";
18
12
 
13
+ //#region src/babel/plugin.d.ts
14
+ declare const envBabelPlugin: powerlines0.DeclareBabelTransformPluginReturn<EnvPluginContext<EnvPluginResolvedConfig>, Record<string, any>>;
15
+ //#endregion
16
+ //#region src/helpers/create-reflection-resource.d.ts
17
+ /**
18
+ * Creates a reflection resource for the environment configuration.
19
+ *
20
+ * @param context - The environment plugin context.
21
+ * @returns A resource that provides the reflection of the environment configuration.
22
+ */
23
+ declare function createReflectionResource(context?: EnvPluginContext): _alloy_js_core0.Resource<type_d_exports.ReflectionClass<Record<string, any>>>;
24
+ //#endregion
25
+ //#region src/helpers/load.d.ts
26
+ /**
27
+ * Retrieves various dotenv configuration parameters from the context.
28
+ *
29
+ * @param context - The context to retrieve the dotenv configuration from.
30
+ * @param parsed - The parsed dotenv configuration.
31
+ * @returns An object containing the dotenv configuration.
32
+ */
33
+ declare function loadEnvFromContext(context: EnvPluginContext, parsed: DotenvParseOutput): {
34
+ APP_NAME: string | undefined;
35
+ APP_VERSION: string | undefined;
36
+ BUILD_ID: string;
37
+ BUILD_TIMESTAMP: string;
38
+ BUILD_CHECKSUM: string;
39
+ RELEASE_ID: string;
40
+ RELEASE_TAG: string;
41
+ DEFAULT_LOCALE: string | undefined;
42
+ DEFAULT_TIMEZONE: string | undefined;
43
+ LOG_LEVEL: "error" | "warn" | "info" | "debug" | "trace" | null;
44
+ ERROR_URL: string | undefined;
45
+ ORGANIZATION: string | undefined;
46
+ PLATFORM: "node" | "browser" | "neutral" | undefined;
47
+ MODE: "test" | "development" | "production" | undefined;
48
+ DEBUG: boolean;
49
+ STACKTRACE: boolean;
50
+ ENVIRONMENT: powerlines0.EnvironmentResolvedConfig;
51
+ };
52
+ declare function loadEnv<TEnv extends DotenvParseOutput = DotenvParseOutput>(context: EnvPluginContext, options: EnvPluginOptions): Promise<TEnv>;
53
+ //#endregion
54
+ //#region src/helpers/persistence.d.ts
55
+ /**
56
+ * Resolves the runtime type definition file for the environment variables.
57
+ *
58
+ * @param context - The plugin context.
59
+ * @returns The runtime type definition file for the environment variables.
60
+ */
61
+ declare function resolveRuntimeTypeFile(context: UnresolvedContext<EnvPluginResolvedConfig>): Promise<string>;
62
+ /**
63
+ * Gets the default type definition for the environment variables.
64
+ *
65
+ * @param context - The plugin context.
66
+ * @returns The default type definition for the environment variables.
67
+ */
68
+ declare function getEnvDefaultTypeDefinition(context: UnresolvedContext<EnvPluginResolvedConfig>): Promise<TypeDefinition>;
69
+ /** Gets the default type definition for the environment secrets.
70
+ *
71
+ * @param context - The plugin context.
72
+ * @returns The default type definition for the environment secrets.
73
+ */
74
+ declare function getSecretsDefaultTypeDefinition(context: UnresolvedContext<EnvPluginResolvedConfig>): Promise<TypeDefinition>;
75
+ /**
76
+ * Gets the path to the environment type reflections.
77
+ *
78
+ * @param context - The plugin context.
79
+ * @param name - The name of the type reflections.
80
+ * @returns The path to the environment type reflections.
81
+ */
82
+ declare function getEnvTypeReflectionsPath(context: Context<EnvPluginResolvedConfig>, name?: EnvType): string;
83
+ /**
84
+ * Reads the environment type reflection from the file system.
85
+ *
86
+ * @param context - The plugin context.
87
+ * @param name - The name of the type reflections.
88
+ * @returns The environment type reflection.
89
+ */
90
+ declare function readEnvTypeReflection(context: EnvPluginContext, name?: EnvType): Promise<type_d_exports.ReflectionClass<any>>;
91
+ /**
92
+ * Writes the environment type reflection to the file system.
93
+ *
94
+ * @param context - The plugin context.
95
+ * @param reflection - The environment type reflection to write.
96
+ * @param name - The name of the type reflections.
97
+ */
98
+ declare function writeEnvTypeReflection(context: EnvPluginContext, reflection: type_d_exports.ReflectionClass<any>, name?: EnvType): Promise<void>;
99
+ declare function getEnvReflectionsPath(context: EnvPluginContext, name: EnvType): string;
100
+ /**
101
+ * Reads the environment reflection data from the file system.
102
+ *
103
+ * @param context - The plugin context.
104
+ * @returns The environment reflection data.
105
+ */
106
+ declare function readEnvReflection(context: EnvPluginContext): Promise<type_d_exports.ReflectionClass<any>>;
107
+ /**
108
+ * Reads the secret environment reflection data from the file system.
109
+ *
110
+ * @param context - The plugin context.
111
+ * @returns The environment reflection data.
112
+ */
113
+ declare function readSecretsReflection(context: EnvPluginContext): Promise<type_d_exports.ReflectionClass<any>>;
114
+ /**
115
+ * Writes the environment reflection data to the file system.
116
+ *
117
+ * @param context - The plugin context.
118
+ * @param reflection - The reflection data to write.
119
+ * @param name - The name of the reflection (either "env" or "secrets").
120
+ */
121
+ declare function writeEnvReflection(context: EnvPluginContext, reflection: type_d_exports.ReflectionClass<any>, name?: EnvType): Promise<void>;
122
+ /**
123
+ * Writes the environment reflection data to the file system.
124
+ *
125
+ * @param context - The plugin context.
126
+ * @param reflection - The reflection data to write.
127
+ * @param name - The name of the reflection (either "env" or "secrets").
128
+ */
129
+ declare function writeEnvReflectionSync(context: EnvPluginContext, reflection: type_d_exports.ReflectionClass<any>, name?: EnvType): void;
130
+ //#endregion
131
+ //#region src/helpers/reflect.d.ts
132
+ declare function mergeEnvReflections(context: EnvPluginContext, reflections: type_d_exports.ReflectionClass<any>[]): type_d_exports.ReflectionClass<any>;
133
+ declare function mergeSecretsReflections(context: EnvPluginContext, reflections: type_d_exports.ReflectionClass<any>[]): type_d_exports.ReflectionClass<any>;
134
+ interface CreateEnvReflectionOptions {
135
+ type?: type_d_exports.TypeObjectLiteral | type_d_exports.TypeClass;
136
+ superReflection?: type_d_exports.ReflectionClass<any>;
137
+ }
138
+ declare class BaseEnv implements EnvInterface {
139
+ APP_NAME: string;
140
+ APP_VERSION: string;
141
+ BUILD_ID: string;
142
+ BUILD_TIMESTAMP: string;
143
+ BUILD_CHECKSUM: string;
144
+ RELEASE_ID: string;
145
+ RELEASE_TAG: string;
146
+ ORGANIZATION: string;
147
+ PLATFORM: "node" | "browser" | "neutral";
148
+ MODE: "development" | "test" | "production";
149
+ ENVIRONMENT: string;
150
+ DEBUG: boolean;
151
+ TEST: boolean;
152
+ MINIMAL: boolean;
153
+ NO_COLOR: boolean;
154
+ FORCE_COLOR: number | boolean;
155
+ FORCE_HYPERLINK: number | boolean;
156
+ STACKTRACE: boolean;
157
+ INCLUDE_ERROR_DATA: boolean;
158
+ ERROR_URL: string;
159
+ DEFAULT_TIMEZONE: string;
160
+ DEFAULT_LOCALE: string;
161
+ CI: boolean;
162
+ }
163
+ declare class BaseSecrets implements SecretsInterface {
164
+ ENCRYPTION_KEY: string;
165
+ }
166
+ declare function createEnvReflection(context: EnvPluginContext, options?: CreateEnvReflectionOptions): type_d_exports.ReflectionClass<any>;
167
+ declare function createSecretsReflection(context: EnvPluginContext, options?: CreateEnvReflectionOptions): type_d_exports.ReflectionClass<any>;
168
+ declare function reflectEnv(context: EnvPluginContext, file?: string, name?: string): Promise<type_d_exports.ReflectionClass<any>>;
169
+ declare function reflectSecrets(context: EnvPluginContext, file?: string, name?: string): Promise<type_d_exports.ReflectionClass<any>>;
170
+ declare type __ΩCreateEnvReflectionOptions = any[];
171
+ //#endregion
172
+ //#region src/helpers/source-file-env.d.ts
173
+ type TReturned<TEnv> = TEnv extends string ? string : DotenvParseOutput;
174
+ declare function removeEnvPrefix<TEnv extends DotenvParseOutput | string>(env: TEnv): TReturned<TEnv>;
175
+ declare function formatEnvField(key: string): string;
176
+ //#endregion
177
+ //#region src/helpers/template-helpers.d.ts
178
+ /**
179
+ * Creates the reflection data used when generating runtime template files.
180
+ *
181
+ * @param context - The context for the configuration plugin.
182
+ * @param name - The name of the configuration template.
183
+ * @returns The reflection for the specified configuration template.
184
+ */
185
+ declare function createTemplateReflection(context: EnvPluginContext, name?: EnvType): Promise<type_d_exports.ReflectionClass<any>>;
186
+ //#endregion
19
187
  //#region src/index.d.ts
20
188
  /**
21
189
  * A Powerlines plugin to inject environment variables into the source code.