@powerlines/plugin-env 0.13.5 → 0.13.7

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 (63) hide show
  1. package/dist/babel/index.cjs +1 -0
  2. package/dist/babel/index.d.cts +30 -0
  3. package/dist/babel/index.d.ts +30 -0
  4. package/dist/babel/index.js +1 -0
  5. package/dist/babel/plugin.cjs +19 -0
  6. package/dist/babel/plugin.d.cts +33 -0
  7. package/dist/babel/plugin.d.ts +33 -0
  8. package/dist/babel/plugin.js +19 -0
  9. package/dist/chunk-FBBMZ4NC.cjs +7 -0
  10. package/dist/chunk-UCUR73HG.js +7 -0
  11. package/dist/components/env.cjs +40 -0
  12. package/dist/components/env.d.cts +106 -0
  13. package/dist/components/env.d.ts +106 -0
  14. package/dist/components/env.js +40 -0
  15. package/dist/components/index.cjs +1 -0
  16. package/dist/components/index.d.cts +10 -0
  17. package/dist/components/index.d.ts +10 -0
  18. package/dist/components/index.js +1 -0
  19. package/dist/helpers/index.cjs +1 -0
  20. package/dist/helpers/index.d.cts +34 -0
  21. package/dist/helpers/index.d.ts +34 -0
  22. package/dist/helpers/index.js +1 -0
  23. package/dist/helpers/load.cjs +7 -0
  24. package/dist/helpers/load.d.cts +59 -0
  25. package/dist/helpers/load.d.ts +59 -0
  26. package/dist/helpers/load.js +7 -0
  27. package/dist/helpers/persistence.cjs +7 -0
  28. package/dist/helpers/persistence.d.cts +107 -0
  29. package/dist/helpers/persistence.d.ts +107 -0
  30. package/dist/helpers/persistence.js +7 -0
  31. package/dist/helpers/reflect.cjs +7 -0
  32. package/dist/helpers/reflect.d.cts +71 -0
  33. package/dist/helpers/reflect.d.ts +71 -0
  34. package/dist/helpers/reflect.js +7 -0
  35. package/dist/helpers/source-file-env.cjs +7 -0
  36. package/dist/helpers/source-file-env.d.cts +7 -0
  37. package/dist/helpers/source-file-env.d.ts +7 -0
  38. package/dist/helpers/source-file-env.js +7 -0
  39. package/dist/helpers/template-helpers.cjs +7 -0
  40. package/dist/helpers/template-helpers.d.cts +40 -0
  41. package/dist/helpers/template-helpers.d.ts +40 -0
  42. package/dist/helpers/template-helpers.js +7 -0
  43. package/dist/index.cjs +22 -0
  44. package/dist/index.d.cts +70 -0
  45. package/dist/index.d.ts +70 -0
  46. package/dist/index.js +22 -0
  47. package/dist/runtime-CUeIsMV9.d.ts +1753 -0
  48. package/dist/runtime-DEhb6gxi.d.cts +1753 -0
  49. package/dist/types/index.cjs +1 -0
  50. package/dist/types/index.d.cts +29 -0
  51. package/dist/types/index.d.ts +29 -0
  52. package/dist/types/index.js +1 -0
  53. package/dist/types/plugin.cjs +1 -0
  54. package/dist/types/plugin.d.cts +1727 -0
  55. package/dist/types/plugin.d.ts +1727 -0
  56. package/dist/types/plugin.js +0 -0
  57. package/dist/types/runtime.cjs +1 -0
  58. package/dist/types/runtime.d.cts +24 -0
  59. package/dist/types/runtime.d.ts +24 -0
  60. package/dist/types/runtime.js +0 -0
  61. package/dist/vfs-Bl84Hw2V.d.cts +393 -0
  62. package/dist/vfs-Bl84Hw2V.d.ts +393 -0
  63. package/package.json +75 -81
@@ -0,0 +1 @@
1
+ 'use strict';var plugin=require('./plugin');Object.keys(plugin).forEach(function(k){if(k!=='default'&&!Object.prototype.hasOwnProperty.call(exports,k))Object.defineProperty(exports,k,{enumerable:true,get:function(){return plugin[k]}})});
@@ -0,0 +1,30 @@
1
+ export { envBabelPlugin } from './plugin.cjs';
2
+ import '../runtime-DEhb6gxi.cjs';
3
+ import '@stryke/env/get-env-paths';
4
+ import '@stryke/types/package-json';
5
+ import 'jiti';
6
+ import 'oxc-parser';
7
+ import 'semver';
8
+ import 'unplugin';
9
+ import '@babel/core';
10
+ import '@storm-software/build-tools/types';
11
+ import '@storm-software/config-tools/types';
12
+ import '@storm-software/config/types';
13
+ import '@stryke/types/base';
14
+ import '@stryke/types/configuration';
15
+ import '@stryke/types/file';
16
+ import 'vite';
17
+ import '@babel/helper-plugin-utils';
18
+ import '@stryke/types/array';
19
+ import '@stryke/types/tsconfig';
20
+ import 'typescript';
21
+ import '../vfs-Bl84Hw2V.cjs';
22
+ import '@stryke/json/types';
23
+ import 'memfs';
24
+ import 'node:fs';
25
+ import 'unionfs';
26
+ import '../types/plugin.cjs';
27
+ import '@alloy-js/core/jsx-runtime';
28
+ import '@deepkit/type';
29
+ import '@stryke/capnp';
30
+ import '@stryke/env/types';
@@ -0,0 +1,30 @@
1
+ export { envBabelPlugin } from './plugin.js';
2
+ import '../runtime-CUeIsMV9.js';
3
+ import '@stryke/env/get-env-paths';
4
+ import '@stryke/types/package-json';
5
+ import 'jiti';
6
+ import 'oxc-parser';
7
+ import 'semver';
8
+ import 'unplugin';
9
+ import '@babel/core';
10
+ import '@storm-software/build-tools/types';
11
+ import '@storm-software/config-tools/types';
12
+ import '@storm-software/config/types';
13
+ import '@stryke/types/base';
14
+ import '@stryke/types/configuration';
15
+ import '@stryke/types/file';
16
+ import 'vite';
17
+ import '@babel/helper-plugin-utils';
18
+ import '@stryke/types/array';
19
+ import '@stryke/types/tsconfig';
20
+ import 'typescript';
21
+ import '../vfs-Bl84Hw2V.js';
22
+ import '@stryke/json/types';
23
+ import 'memfs';
24
+ import 'node:fs';
25
+ import 'unionfs';
26
+ import '../types/plugin.js';
27
+ import '@alloy-js/core/jsx-runtime';
28
+ import '@deepkit/type';
29
+ import '@stryke/capnp';
30
+ import '@stryke/env/types';
@@ -0,0 +1 @@
1
+ export*from'./plugin';
@@ -0,0 +1,19 @@
1
+ 'use strict';var chunkFBBMZ4NC_cjs=require('../chunk-FBBMZ4NC.cjs'),capnp=require('@powerlines/deepkit/capnp'),reflection=require('@powerlines/deepkit/schemas/reflection'),utilities=require('@powerlines/deepkit/utilities'),type=require('@powerlines/deepkit/vendor/type'),createPlugin=require('@powerlines/plugin-babel/helpers/create-plugin'),moduleHelpers=require('@powerlines/plugin-babel/helpers/module-helpers'),types=require('@storm-software/config-tools/types'),E=require('@stryke/capnp'),buffer=require('@stryke/fs/buffer'),node_fs=require('node:fs'),persistence=require('../helpers/persistence');function _interopNamespace(e){if(e&&e.__esModule)return e;var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}var E__namespace=/*#__PURE__*/_interopNamespace(E);/*****************************************
2
+ *
3
+ * ⚡ Built by Storm Software
4
+ *
5
+ *****************************************/
6
+
7
+ const G=createPlugin.createBabelPlugin("env",({log:f,context:t})=>{function l(e,o,n=false){const a=t.env.types.env?.getProperties().filter(m=>m.getAlias().length>0);if(e.name){const m=t.config.env.prefix.find(i=>e.name&&e.name.startsWith(i)&&(t.env.types.env?.hasProperty(e.name.replace(`${i}_`,""))||a.some(r=>r.getAlias().includes(e.name.replace(`${i}_`,"")))));let s=e.name;if(m&&(s=e.name.replace(`${m}_`,"")),f(types.LogLevelLabel.TRACE,`Environment variable ${s} found in ${o.filename||"unknown file"}.`),t.env.types.env?.hasProperty(s)||a.some(i=>i.getAlias().includes(s))){const i=t.env.types.env.hasProperty(s)?t.env.types.env.getProperty(s):a.find(r=>r.getAlias().includes(s));if(!i||i.isIgnored())return;if(t.env.used.env.hasProperty(s)||t.env.used.env.addProperty(i.property),t.config.env.inject&&n){let r=t.env.parsed?.[s];if(r===void 0){const v=t.config.env.prefix.find(u=>t.env.parsed[`${u.replace(/_$/g,"")}_${s}`]);v&&(r=t.env.parsed[`${v.replace(/_$/g,"")}_${s}`]);}if(r??=i.getDefaultValue(),i.isValueRequired()&&r===void 0)throw new Error(`Environment variable \`${s}\` is not defined in the .env configuration files`);return utilities.stringifyDefaultValue(i,r)}}else throw new Error(`The "${s}" environment variable is not defined in the \`env\` type definition, but is used in the source code file ${o.filename?o.filename:"unknown"}.
8
+
9
+ The following environment configuration names are defined in the \`env\` type definition:
10
+ ${t.env.types.env?.getPropertyNames().sort((i,r)=>String(i).localeCompare(String(r))).map(i=>` - ${String(i)} ${a.some(r=>r.getNameAsString()===String(i)&&r.getAlias().length>0)?`(Alias: ${a?.find(r=>r.getNameAsString()===String(i))?.getAlias().join(", ")})`:""}`).join(`
11
+ `)}
12
+
13
+ Using the following env prefix:
14
+ ${t.config.env.prefix.map(i=>` - ${i}`).join(`
15
+ `)}
16
+
17
+ Please 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.
18
+
19
+ `)}}return chunkFBBMZ4NC_cjs.a(l,"extractEnv"),{visitor:{MemberExpression(e,o){if(e.get("object")?.get("property")?.isIdentifier({name:"env"})&&e.get("object")?.get("object")?.isIdentifier({name:"$storm"})&&e.get("property")?.isIdentifier()){const n=e.get("property")?.node;l(n,o,false),e.replaceWithSourceString(`env.${n.name}`),moduleHelpers.addImport(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()){const n=e.get("property")?.node;l(n,o,false),e.replaceWithSourceString(`env.${n.name}`),moduleHelpers.addImport(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()){const n=e.get("property")?.node;if(!n.name)return;l(n,o,false),e.replaceWithSourceString(`env.${n.name}`),moduleHelpers.addImport(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()){const n=e.get("property")?.node;if(!n.name)return;l(n,o,false),e.replaceWithSourceString(`env.${n.name}`),moduleHelpers.addImport(e,{module:"storm:env",name:"env",imported:"env"});}}},post(){f(types.LogLevelLabel.TRACE,`Adding environment variables from ${this.filename||"unknown file"} to env.json.`);let e=type.ReflectionClass.from({kind:type.ReflectionKind.objectLiteral,description:"An object containing the environment variables used by the application.",types:[]});const o=persistence.getEnvReflectionsPath(t,"env");o&&node_fs.existsSync(o)&&(f(types.LogLevelLabel.TRACE,`Environment reflection file found at ${o}, reading existing reflection.`),e=type.resolveClassType(type.deserializeType(capnp.convertFromCapnp(new E__namespace.Message(buffer.readFileBufferSync(o),false).getRoot(reflection.SerializedTypes).types)))),f(types.LogLevelLabel.TRACE,`Adding new variables to env reflection at ${o}.`),e.getProperties().filter(n=>n.getNameAsString()&&!t.env.used.env.hasProperty(n.getNameAsString())).forEach(n=>{t.env.used.env.addProperty({...n,name:n.getNameAsString(),description:n.getDescription()??`The ${n.getNameAsString()} variable.`,default:n.getDefaultValue(),optional:n.isOptional()?true:void 0,readonly:n.isReadonly()?true:void 0,visibility:n.getVisibility(),type:n.getType(),tags:n.getTags()});});}}});exports.envBabelPlugin=G;
@@ -0,0 +1,33 @@
1
+ import { D as DeclareBabelTransformPluginReturn } from '../runtime-DEhb6gxi.cjs';
2
+ import { EnvPluginContext, EnvPluginResolvedConfig } from '../types/plugin.cjs';
3
+ import '@stryke/env/get-env-paths';
4
+ import '@stryke/types/package-json';
5
+ import 'jiti';
6
+ import 'oxc-parser';
7
+ import 'semver';
8
+ import 'unplugin';
9
+ import '@babel/core';
10
+ import '@storm-software/build-tools/types';
11
+ import '@storm-software/config-tools/types';
12
+ import '@storm-software/config/types';
13
+ import '@stryke/types/base';
14
+ import '@stryke/types/configuration';
15
+ import '@stryke/types/file';
16
+ import 'vite';
17
+ import '@babel/helper-plugin-utils';
18
+ import '@stryke/types/array';
19
+ import '@stryke/types/tsconfig';
20
+ import 'typescript';
21
+ import '../vfs-Bl84Hw2V.cjs';
22
+ import '@stryke/json/types';
23
+ import 'memfs';
24
+ import 'node:fs';
25
+ import 'unionfs';
26
+ import '@alloy-js/core/jsx-runtime';
27
+ import '@deepkit/type';
28
+ import '@stryke/capnp';
29
+ import '@stryke/env/types';
30
+
31
+ declare const envBabelPlugin: DeclareBabelTransformPluginReturn<EnvPluginContext<EnvPluginResolvedConfig>, Record<string, any>>;
32
+
33
+ export { envBabelPlugin };
@@ -0,0 +1,33 @@
1
+ import { D as DeclareBabelTransformPluginReturn } from '../runtime-CUeIsMV9.js';
2
+ import { EnvPluginContext, EnvPluginResolvedConfig } from '../types/plugin.js';
3
+ import '@stryke/env/get-env-paths';
4
+ import '@stryke/types/package-json';
5
+ import 'jiti';
6
+ import 'oxc-parser';
7
+ import 'semver';
8
+ import 'unplugin';
9
+ import '@babel/core';
10
+ import '@storm-software/build-tools/types';
11
+ import '@storm-software/config-tools/types';
12
+ import '@storm-software/config/types';
13
+ import '@stryke/types/base';
14
+ import '@stryke/types/configuration';
15
+ import '@stryke/types/file';
16
+ import 'vite';
17
+ import '@babel/helper-plugin-utils';
18
+ import '@stryke/types/array';
19
+ import '@stryke/types/tsconfig';
20
+ import 'typescript';
21
+ import '../vfs-Bl84Hw2V.js';
22
+ import '@stryke/json/types';
23
+ import 'memfs';
24
+ import 'node:fs';
25
+ import 'unionfs';
26
+ import '@alloy-js/core/jsx-runtime';
27
+ import '@deepkit/type';
28
+ import '@stryke/capnp';
29
+ import '@stryke/env/types';
30
+
31
+ declare const envBabelPlugin: DeclareBabelTransformPluginReturn<EnvPluginContext<EnvPluginResolvedConfig>, Record<string, any>>;
32
+
33
+ export { envBabelPlugin };
@@ -0,0 +1,19 @@
1
+ import {a}from'../chunk-UCUR73HG.js';import {convertFromCapnp}from'@powerlines/deepkit/capnp';import {SerializedTypes}from'@powerlines/deepkit/schemas/reflection';import {stringifyDefaultValue}from'@powerlines/deepkit/utilities';import {ReflectionClass,ReflectionKind,resolveClassType,deserializeType}from'@powerlines/deepkit/vendor/type';import {createBabelPlugin}from'@powerlines/plugin-babel/helpers/create-plugin';import {addImport}from'@powerlines/plugin-babel/helpers/module-helpers';import {LogLevelLabel}from'@storm-software/config-tools/types';import*as E from'@stryke/capnp';import {readFileBufferSync}from'@stryke/fs/buffer';import {existsSync}from'node:fs';import {getEnvReflectionsPath}from'../helpers/persistence';/*****************************************
2
+ *
3
+ * ⚡ Built by Storm Software
4
+ *
5
+ *****************************************/
6
+
7
+ const H=createBabelPlugin("env",({log:f,context:t})=>{function l(e,o,n=false){const a=t.env.types.env?.getProperties().filter(m=>m.getAlias().length>0);if(e.name){const m=t.config.env.prefix.find(i=>e.name&&e.name.startsWith(i)&&(t.env.types.env?.hasProperty(e.name.replace(`${i}_`,""))||a.some(r=>r.getAlias().includes(e.name.replace(`${i}_`,"")))));let s=e.name;if(m&&(s=e.name.replace(`${m}_`,"")),f(LogLevelLabel.TRACE,`Environment variable ${s} found in ${o.filename||"unknown file"}.`),t.env.types.env?.hasProperty(s)||a.some(i=>i.getAlias().includes(s))){const i=t.env.types.env.hasProperty(s)?t.env.types.env.getProperty(s):a.find(r=>r.getAlias().includes(s));if(!i||i.isIgnored())return;if(t.env.used.env.hasProperty(s)||t.env.used.env.addProperty(i.property),t.config.env.inject&&n){let r=t.env.parsed?.[s];if(r===void 0){const v=t.config.env.prefix.find(u=>t.env.parsed[`${u.replace(/_$/g,"")}_${s}`]);v&&(r=t.env.parsed[`${v.replace(/_$/g,"")}_${s}`]);}if(r??=i.getDefaultValue(),i.isValueRequired()&&r===void 0)throw new Error(`Environment variable \`${s}\` is not defined in the .env configuration files`);return stringifyDefaultValue(i,r)}}else throw new Error(`The "${s}" environment variable is not defined in the \`env\` type definition, but is used in the source code file ${o.filename?o.filename:"unknown"}.
8
+
9
+ The following environment configuration names are defined in the \`env\` type definition:
10
+ ${t.env.types.env?.getPropertyNames().sort((i,r)=>String(i).localeCompare(String(r))).map(i=>` - ${String(i)} ${a.some(r=>r.getNameAsString()===String(i)&&r.getAlias().length>0)?`(Alias: ${a?.find(r=>r.getNameAsString()===String(i))?.getAlias().join(", ")})`:""}`).join(`
11
+ `)}
12
+
13
+ Using the following env prefix:
14
+ ${t.config.env.prefix.map(i=>` - ${i}`).join(`
15
+ `)}
16
+
17
+ Please 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.
18
+
19
+ `)}}return a(l,"extractEnv"),{visitor:{MemberExpression(e,o){if(e.get("object")?.get("property")?.isIdentifier({name:"env"})&&e.get("object")?.get("object")?.isIdentifier({name:"$storm"})&&e.get("property")?.isIdentifier()){const n=e.get("property")?.node;l(n,o,false),e.replaceWithSourceString(`env.${n.name}`),addImport(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()){const n=e.get("property")?.node;l(n,o,false),e.replaceWithSourceString(`env.${n.name}`),addImport(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()){const n=e.get("property")?.node;if(!n.name)return;l(n,o,false),e.replaceWithSourceString(`env.${n.name}`),addImport(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()){const n=e.get("property")?.node;if(!n.name)return;l(n,o,false),e.replaceWithSourceString(`env.${n.name}`),addImport(e,{module:"storm:env",name:"env",imported:"env"});}}},post(){f(LogLevelLabel.TRACE,`Adding environment variables from ${this.filename||"unknown file"} to env.json.`);let e=ReflectionClass.from({kind:ReflectionKind.objectLiteral,description:"An object containing the environment variables used by the application.",types:[]});const o=getEnvReflectionsPath(t,"env");o&&existsSync(o)&&(f(LogLevelLabel.TRACE,`Environment reflection file found at ${o}, reading existing reflection.`),e=resolveClassType(deserializeType(convertFromCapnp(new E.Message(readFileBufferSync(o),false).getRoot(SerializedTypes).types)))),f(LogLevelLabel.TRACE,`Adding new variables to env reflection at ${o}.`),e.getProperties().filter(n=>n.getNameAsString()&&!t.env.used.env.hasProperty(n.getNameAsString())).forEach(n=>{t.env.used.env.addProperty({...n,name:n.getNameAsString(),description:n.getDescription()??`The ${n.getNameAsString()} variable.`,default:n.getDefaultValue(),optional:n.isOptional()?true:void 0,readonly:n.isReadonly()?true:void 0,visibility:n.getVisibility(),type:n.getType(),tags:n.getTags()});});}}});export{H as envBabelPlugin};
@@ -0,0 +1,7 @@
1
+ 'use strict';/*****************************************
2
+ *
3
+ * ⚡ Built by Storm Software
4
+ *
5
+ *****************************************/
6
+
7
+ var c=Object.defineProperty;var d=(a,b)=>c(a,"name",{value:b,configurable:true});exports.a=d;
@@ -0,0 +1,7 @@
1
+ /*****************************************
2
+ *
3
+ * ⚡ Built by Storm Software
4
+ *
5
+ *****************************************/
6
+
7
+ var c=Object.defineProperty;var d=(a,b)=>c(a,"name",{value:b,configurable:true});export{d as a};
@@ -0,0 +1,40 @@
1
+ 'use strict';var chunkFBBMZ4NC_cjs=require('../chunk-FBBMZ4NC.cjs'),jsxRuntime=require('@alloy-js/core/jsx-runtime'),core=require('@alloy-js/core'),typescript=require('@alloy-js/typescript'),context=require('@powerlines/alloy/core/contexts/context'),refkey=require('@powerlines/alloy/helpers/refkey'),builtinFile=require('@powerlines/alloy/typescript/components/builtin-file'),tsdoc=require('@powerlines/alloy/typescript/components/tsdoc'),typescriptInterface=require('@powerlines/alloy/typescript/components/typescript-interface'),typescriptObject=require('@powerlines/alloy/typescript/components/typescript-object'),type=require('@powerlines/deepkit/vendor/type'),titleCase=require('@stryke/string-format/title-case'),isNull=require('@stryke/type-checks/is-null'),U=require('defu'),load=require('../helpers/load'),persistence=require('../helpers/persistence');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var U__default=/*#__PURE__*/_interopDefault(U);/*****************************************
2
+ *
3
+ * ⚡ Built by Storm Software
4
+ *
5
+ *****************************************/
6
+
7
+ function Z(u){const[{defaultValue:o,reflection:r}]=core.splitProps(u,["defaultValue","reflection"]),a=context.usePowerlines();return [jsxRuntime.createComponent(typescriptInterface.TypeScriptInterface,{name:" EnvBase",extends:["EnvInterface"],defaultValue:o,reflection:r,export:true}),jsxRuntime.createIntrinsic("hbr",{}),jsxRuntime.createIntrinsic("hbr",{}),jsxRuntime.createComponent(typescript.TypeDeclaration,{name:"Env",export:true,get children(){return core.code` {
8
+ [Key in keyof EnvBase as Key ${a?.config.env.prefix.map(s=>`| \`${s.replace(/_$/g,"")}_\${Key}\``).join(" ")}]: EnvBase[Key];
9
+ }
10
+ `}})]}chunkFBBMZ4NC_cjs.a(Z,"EnvTypeDefinition");function g(u){const[{context:o,name:r}]=core.splitProps(u,["context","name"]);return o?core.code`propertyName === "${r}" || propertyName.replace(/^(${o.config.env.prefix.sort((a,s)=>a.startsWith(s)?-1:s.startsWith(a)?1:a.localeCompare(s)).map(a=>`${a.replace(/_$/,"")}_`).join("|")})/g, "").toLowerCase().replace(/[\\s\\-_]+/g, "") === "${r.toLowerCase().replace(/[\s\-_]+/g,"")}"`:null}chunkFBBMZ4NC_cjs.a(g,"ConfigPropertyConditional");function ee(u){const[{context:o,property:r,index:a}]=core.splitProps(u,["context","property","index"]);return o?[a===0?jsxRuntime.createComponent(typescript.IfStatement,{get condition(){return [jsxRuntime.createComponent(g,{get name(){return r.getNameAsString()},context:o}),jsxRuntime.createComponent(core.Show,{get when(){return jsxRuntime.memo(()=>!!r.getAlias())()&&r.getAlias().length>0},get children(){return [core.code` || `,jsxRuntime.createComponent(core.For,{get each(){return r.getAlias()},joiner:core.code` || `,children:chunkFBBMZ4NC_cjs.a(s=>jsxRuntime.createComponent(g,{name:s,context:o}),"children")})]}})]},get children(){return core.code`return target["${r.getNameAsString()}"];`}}):jsxRuntime.createComponent(typescript.ElseIfClause,{get condition(){return [jsxRuntime.createComponent(g,{get name(){return r.getNameAsString()},context:o}),jsxRuntime.createComponent(core.Show,{get when(){return jsxRuntime.memo(()=>!!r.getAlias())()&&r.getAlias().length>0},get children(){return [core.code` || `,jsxRuntime.createComponent(core.For,{get each(){return r.getAlias()},joiner:core.code` || `,children:chunkFBBMZ4NC_cjs.a(s=>jsxRuntime.createComponent(g,{name:s,context:o}),"children")})]}})]},get children(){return core.code`return target["${r.getNameAsString()}"];`}})]:null}chunkFBBMZ4NC_cjs.a(ee,"ConfigPropertyGet");function te(u){const[{context:o,property:r,index:a}]=core.splitProps(u,["context","property","index"]);return o?[a===0?jsxRuntime.createComponent(typescript.IfStatement,{get condition(){return [jsxRuntime.createComponent(g,{get name(){return r.getNameAsString()},context:o}),jsxRuntime.createComponent(core.Show,{get when(){return jsxRuntime.memo(()=>!!r.getAlias())()&&r.getAlias().length>0},get children(){return [core.code` || `,jsxRuntime.createComponent(core.For,{get each(){return r.getAlias()},joiner:core.code` || `,children:chunkFBBMZ4NC_cjs.a(s=>jsxRuntime.createComponent(g,{name:s,context:o}),"children")})]}})]},get children(){return core.code`
11
+ target["${r.getNameAsString()}"] = newValue;
12
+ return true;
13
+ `}}):jsxRuntime.createComponent(typescript.ElseIfClause,{get condition(){return [jsxRuntime.createComponent(g,{get name(){return r.getNameAsString()},context:o}),jsxRuntime.createComponent(core.Show,{get when(){return jsxRuntime.memo(()=>!!r.getAlias())()&&r.getAlias().length>0},get children(){return [core.code` || `,jsxRuntime.createComponent(core.For,{get each(){return r.getAlias()},joiner:core.code` || `,children:chunkFBBMZ4NC_cjs.a(s=>jsxRuntime.createComponent(g,{name:s,context:o}),"children")})]}})]},get children(){return core.code`
14
+ target["${r.getNameAsString()}"] = newValue;
15
+ return true;
16
+ `}})]:null}chunkFBBMZ4NC_cjs.a(te,"ConfigPropertySet");const re=refkey.refkey("createEnv"),ne=refkey.refkey("env"),ie=refkey.refkey("EnvSerializer");function ze(u){const[{defaultConfig:o},r]=core.splitProps(u,["defaultConfig"]),a=context.usePowerlines(),s=core.computed(()=>a&&load.loadEnvFromContext(a,process.env)),h=core.createResource(async()=>{if(!a)return new type.ReflectionClass({kind:type.ReflectionKind.objectLiteral,description:"The initial environment configuration state for the Powerlines project.",types:[]});const l=await persistence.readEnvTypeReflection(a,"env");return l.getProperties().forEach(t=>{t.getAlias().filter(Boolean).forEach(y=>{l.addProperty({name:y,optional:t.isOptional()?true:void 0,readonly:t.isReadonly()?true:void 0,description:t.getDescription(),visibility:t.getVisibility(),type:t.getType(),default:t.getDefaultValue(),tags:{hidden:t.isHidden(),ignore:t.isIgnored(),internal:t.isInternal(),alias:t.getAlias().filter(I=>I!==y).concat(t.name),title:t.getTitle()||titleCase.titleCase(t.name),readonly:t.isReadonly(),permission:t.getPermission(),domain:t.getDomain()}});});}),l.getProperties().forEach(t=>{t.setDefaultValue(s.value?.[t.getNameAsString()]??t.getAlias().reduce((w,y)=>w??s.value?.[y],void 0)??t.getDefaultValue());}),l}),D=core.computed(()=>new type.ReflectionClass({kind:type.ReflectionKind.objectLiteral,description:`The initial environment configuration state for the ${titleCase.titleCase(a?.config?.name)} project.`,types:[]},h.data??void 0)),V=core.computed(()=>h.data?.getProperties().filter(l=>!l.isIgnored()).sort((l,t)=>l.getNameAsString().localeCompare(t.getNameAsString()))??[]),R=core.computed(()=>h.data?.getProperties().filter(l=>!l.isIgnored()&&!l.isReadonly()).sort((l,t)=>l.getNameAsString().localeCompare(t.getNameAsString()))??[]);return jsxRuntime.createComponent(builtinFile.BuiltinFile,jsxRuntime.mergeProps(r,{id:"env",description:"The Powerlines environment configuration module provides an interface to define environment configuration parameters.",get imports(){return U__default.default({"@powerlines/deepkit/vendor/type":["Type","stringify","serializer","serializeFunction","deserializeFunction","ReflectionKind","TemplateState","Serializer","TypeProperty","TypePropertySignature"],"@powerlines/plugin-env/types/runtime":[{name:"EnvInterface"}]},r.imports??{})},get children(){return [jsxRuntime.createComponent(core.Show,{get when(){return !isNull.isNull(h.data)},get children(){return [jsxRuntime.createComponent(Z,{get defaultValue(){return s.value},get reflection(){return h.data}}),jsxRuntime.createIntrinsic("hbr",{}),jsxRuntime.createIntrinsic("hbr",{})]}}),jsxRuntime.createComponent(typescriptObject.TypescriptObject,{name:"initialEnv",type:"Partial<EnvBase>",defaultValue:s,reflection:D,export:true,const:true}),jsxRuntime.createIntrinsic("hbr",{}),jsxRuntime.createIntrinsic("hbr",{}),jsxRuntime.createComponent(tsdoc.TSDoc,{heading:"The environment configuration serializer for the Powerlines application.",get children(){return [jsxRuntime.createComponent(tsdoc.TSDocLink,{children:"https://deepkit.io/docs/serialization/serializers"}),jsxRuntime.createComponent(tsdoc.TSDocLink,{children:"https://github.com/marcj/untitled-code/blob/master/packages/type/src/serializer.ts#L1918"}),jsxRuntime.createComponent(tsdoc.TSDocRemarks,{children:"This serializer is used to serialize and deserialize the Powerlines environment configuration."})]}}),jsxRuntime.createComponent(typescript.ClassDeclaration,{refkey:ie,name:"EnvSerializer",extends:"Serializer",export:true,get children(){return jsxRuntime.createComponent(typescript.ClassMethod,{name:"constructor",public:true,children:core.code`
17
+ super("env");
18
+
19
+ this.deserializeRegistry.register(
20
+ ReflectionKind.boolean,
21
+ (type: Type, state: TemplateState) => {
22
+ state.addSetter(
23
+ \`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()}\`
24
+ );
25
+ }
26
+ );
27
+ `})}}),jsxRuntime.createIntrinsic("hbr",{}),jsxRuntime.createIntrinsic("hbr",{}),jsxRuntime.createComponent(tsdoc.TSDoc,{heading:"A {@link EnvSerializer | environment configuration serializer} instance for the Powerlines application.",get children(){return [jsxRuntime.createComponent(tsdoc.TSDocLink,{children:"https://deepkit.io/docs/serialization/serializers"}),jsxRuntime.createComponent(tsdoc.TSDocLink,{children:"https://github.com/marcj/untitled-code/blob/master/packages/type/src/serializer.ts#L1918"}),jsxRuntime.createComponent(tsdoc.TSDocRemarks,{children:"This serializer is used to serialize and deserialize the Powerlines environment configuration."})]}}),jsxRuntime.createComponent(typescript.VarDeclaration,{name:"envSerializer",export:false,const:true,get initializer(){return jsxRuntime.createComponent(typescript.NewExpression,{args:[],target:"EnvSerializer"})}}),jsxRuntime.createIntrinsic("hbr",{}),jsxRuntime.createIntrinsic("hbr",{}),jsxRuntime.createComponent(tsdoc.TSDoc,{heading:"Serialize a environment configuration object to JSON data objects (not a JSON string).",get children(){return [jsxRuntime.createComponent(tsdoc.TSDocRemarks,{children:"The resulting JSON object can be stringified using JSON.stringify()."}),jsxRuntime.createComponent(tsdoc.TSDocExample,{children:"const json = serializeEnv(env);"}),jsxRuntime.createComponent(tsdoc.TSDocThrows,{children:"ValidationError when serialization or validation fails."})]}}),jsxRuntime.createComponent(typescript.VarDeclaration,{name:"serializeEnv",export:true,const:true,initializer:"serializeFunction<EnvBase>(envSerializer)"}),jsxRuntime.createIntrinsic("hbr",{}),jsxRuntime.createIntrinsic("hbr",{}),jsxRuntime.createComponent(tsdoc.TSDoc,{heading:"Deserialize a environment configuration object from JSON data objects to JavaScript objects, without running any validators.",get children(){return [jsxRuntime.createComponent(tsdoc.TSDocRemarks,{children:"Types that are already correct will be used as-is."}),jsxRuntime.createComponent(tsdoc.TSDocExample,{children:"const env = deserializeEnv(json);"}),jsxRuntime.createComponent(tsdoc.TSDocThrows,{children:"ValidationError when deserialization fails."})]}}),jsxRuntime.createComponent(typescript.VarDeclaration,{name:"deserializeEnv",export:true,const:true,initializer:"deserializeFunction<EnvBase>(envSerializer)"}),jsxRuntime.createIntrinsic("hbr",{}),jsxRuntime.createIntrinsic("hbr",{}),jsxRuntime.createComponent(tsdoc.TSDoc,{heading:"Initializes the Powerlines environment configuration module.",get children(){return [jsxRuntime.createComponent(tsdoc.TSDocRemarks,{children:"This function initializes the Powerlines environment configuration object."}),jsxRuntime.createComponent(tsdoc.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."}),jsxRuntime.createComponent(tsdoc.TSDocReturns,{children:"The initialized Powerlines configuration object."})]}}),jsxRuntime.createComponent(core.Show,{get when(){return !!a?.entryPath},get children(){return jsxRuntime.createComponent(typescript.FunctionDeclaration,{refkey:re,async:false,export:true,name:"createEnv",parameters:[{name:"environmentConfig",type:"Partial<Env>",optional:false,default:"{}"}],returnType:"Env",get children(){return [core.code`
28
+ return new Proxy<Env>(
29
+ deserializeEnv({
30
+ ...initialEnv,
31
+ ...environmentConfig
32
+ }) as Env,
33
+ {
34
+ get: (target: EnvBase, propertyName: string) => { `,jsxRuntime.createIntrinsic("hbr",{}),jsxRuntime.createComponent(core.For,{each:V,children:chunkFBBMZ4NC_cjs.a((l,t)=>jsxRuntime.createComponent(ee,{index:t,context:a,property:l}),"children")}),core.code`
35
+ return undefined;
36
+ }, `,jsxRuntime.createIntrinsic("hbr",{}),jsxRuntime.createIntrinsic("hbr",{}),core.code` set: (target: EnvBase, propertyName: string, newValue: any) => { `,jsxRuntime.createIntrinsic("hbr",{}),jsxRuntime.createComponent(core.For,{each:R,ender:core.code` else `,children:chunkFBBMZ4NC_cjs.a((l,t)=>jsxRuntime.createComponent(te,{index:t,context:a,property:l}),"children")}),jsxRuntime.createIntrinsic("hbr",{}),core.code`return false;
37
+ }
38
+ }
39
+ );
40
+ `]}})}}),jsxRuntime.createIntrinsic("hbr",{}),jsxRuntime.createIntrinsic("hbr",{}),jsxRuntime.createIntrinsic("hbr",{}),jsxRuntime.createComponent(typescript.VarDeclaration,{refkey:ne,name:"env",type:"Env",export:true,const:true,get initializer(){return [core.code`createEnv(`,o||"{}",core.code` as Partial<Env>)`]}})]}}))}chunkFBBMZ4NC_cjs.a(ze,"EnvBuiltin");exports.EnvBuiltin=ze;exports.EnvTypeDefinition=Z;
@@ -0,0 +1,106 @@
1
+ import { Children as Children$1, SourceFileProps as SourceFileProps$1 } from '@alloy-js/core';
2
+ import { Children } from '@alloy-js/core/jsx-runtime';
3
+ import { O as OutputModeType } from '../vfs-Bl84Hw2V.cjs';
4
+ import { InterfaceDeclarationProps } from '@alloy-js/typescript';
5
+ import { ReflectionClass } from '@deepkit/type';
6
+ import '@stryke/json/types';
7
+ import 'memfs';
8
+ import 'node:fs';
9
+ import 'unionfs';
10
+
11
+ /**
12
+ * A type that represents the props of a component that can have children.
13
+ */
14
+ interface ComponentProps {
15
+ children?: Children;
16
+ }
17
+ interface TypescriptFileImportItem {
18
+ name: string;
19
+ default?: boolean;
20
+ alias?: string;
21
+ type?: boolean;
22
+ }
23
+ type TypescriptFileImports = Record<string, null | Array<TypescriptFileImportItem | string>>;
24
+
25
+ interface TSDocModuleProps extends ComponentProps {
26
+ /**
27
+ * the prefix for the builtin module name
28
+ *
29
+ * @defaultValue "storm"
30
+ */
31
+ prefix?: string;
32
+ /**
33
+ * The name of the module
34
+ *
35
+ * @remarks
36
+ * This will be used in the `@module` tag as well as the import path for the module, e.g. `storm:<name>`.
37
+ *
38
+ * @example
39
+ * ```ts
40
+ * import { MyModule } from "storm:my-module";
41
+ * ```
42
+ */
43
+ name: Children$1;
44
+ }
45
+
46
+ type SourceFileProps = SourceFileProps$1 & ComponentProps & {
47
+ /**
48
+ * If true, indicates that the file is virtual and should not be written to disk.
49
+ *
50
+ * @defaultValue false
51
+ */
52
+ mode?: OutputModeType;
53
+ /**
54
+ * The metadata associated with the source file.
55
+ *
56
+ * @remarks
57
+ * The values stored in the metadata will be available in the rendering context.
58
+ */
59
+ meta?: Record<string, any>;
60
+ };
61
+
62
+ type TypescriptFileProps = Omit<SourceFileProps, "filetype"> & ComponentProps & {
63
+ header?: Children$1;
64
+ imports?: TypescriptFileImports;
65
+ export?: boolean | string;
66
+ tsx?: boolean;
67
+ };
68
+
69
+ type BuiltinFileProps = Omit<TypescriptFileProps, "path"> & Omit<TSDocModuleProps, "name"> & {
70
+ /**
71
+ * The runtime module identifier.
72
+ *
73
+ * @remarks
74
+ * This value will be included after the \`storm:\` prefix in the import statement.
75
+ */
76
+ id: string;
77
+ /**
78
+ * The description for the builtin module.
79
+ */
80
+ description?: string;
81
+ /**
82
+ * Whether the file is a TSX file.
83
+ *
84
+ * @defaultValue false
85
+ */
86
+ tsx?: boolean;
87
+ };
88
+
89
+ interface TypeScriptInterfaceProps<T extends Record<string, any> = Record<string, any>> extends InterfaceDeclarationProps, ComponentProps {
90
+ reflection: ReflectionClass<T>;
91
+ defaultValue?: Partial<T>;
92
+ }
93
+
94
+ /**
95
+ * Generates the environment configuration typescript definition for the Powerlines project.
96
+ */
97
+ declare function EnvTypeDefinition(props: Omit<TypeScriptInterfaceProps, "name">): Children$1;
98
+ interface EnvBuiltinProps extends Omit<BuiltinFileProps, "id"> {
99
+ defaultConfig?: Children$1;
100
+ }
101
+ /**
102
+ * Generates the environment configuration module for the Powerlines project.
103
+ */
104
+ declare function EnvBuiltin(props: EnvBuiltinProps): Children$1;
105
+
106
+ export { EnvBuiltin, type EnvBuiltinProps, EnvTypeDefinition };
@@ -0,0 +1,106 @@
1
+ import { Children as Children$1, SourceFileProps as SourceFileProps$1 } from '@alloy-js/core';
2
+ import { Children } from '@alloy-js/core/jsx-runtime';
3
+ import { O as OutputModeType } from '../vfs-Bl84Hw2V.js';
4
+ import { InterfaceDeclarationProps } from '@alloy-js/typescript';
5
+ import { ReflectionClass } from '@deepkit/type';
6
+ import '@stryke/json/types';
7
+ import 'memfs';
8
+ import 'node:fs';
9
+ import 'unionfs';
10
+
11
+ /**
12
+ * A type that represents the props of a component that can have children.
13
+ */
14
+ interface ComponentProps {
15
+ children?: Children;
16
+ }
17
+ interface TypescriptFileImportItem {
18
+ name: string;
19
+ default?: boolean;
20
+ alias?: string;
21
+ type?: boolean;
22
+ }
23
+ type TypescriptFileImports = Record<string, null | Array<TypescriptFileImportItem | string>>;
24
+
25
+ interface TSDocModuleProps extends ComponentProps {
26
+ /**
27
+ * the prefix for the builtin module name
28
+ *
29
+ * @defaultValue "storm"
30
+ */
31
+ prefix?: string;
32
+ /**
33
+ * The name of the module
34
+ *
35
+ * @remarks
36
+ * This will be used in the `@module` tag as well as the import path for the module, e.g. `storm:<name>`.
37
+ *
38
+ * @example
39
+ * ```ts
40
+ * import { MyModule } from "storm:my-module";
41
+ * ```
42
+ */
43
+ name: Children$1;
44
+ }
45
+
46
+ type SourceFileProps = SourceFileProps$1 & ComponentProps & {
47
+ /**
48
+ * If true, indicates that the file is virtual and should not be written to disk.
49
+ *
50
+ * @defaultValue false
51
+ */
52
+ mode?: OutputModeType;
53
+ /**
54
+ * The metadata associated with the source file.
55
+ *
56
+ * @remarks
57
+ * The values stored in the metadata will be available in the rendering context.
58
+ */
59
+ meta?: Record<string, any>;
60
+ };
61
+
62
+ type TypescriptFileProps = Omit<SourceFileProps, "filetype"> & ComponentProps & {
63
+ header?: Children$1;
64
+ imports?: TypescriptFileImports;
65
+ export?: boolean | string;
66
+ tsx?: boolean;
67
+ };
68
+
69
+ type BuiltinFileProps = Omit<TypescriptFileProps, "path"> & Omit<TSDocModuleProps, "name"> & {
70
+ /**
71
+ * The runtime module identifier.
72
+ *
73
+ * @remarks
74
+ * This value will be included after the \`storm:\` prefix in the import statement.
75
+ */
76
+ id: string;
77
+ /**
78
+ * The description for the builtin module.
79
+ */
80
+ description?: string;
81
+ /**
82
+ * Whether the file is a TSX file.
83
+ *
84
+ * @defaultValue false
85
+ */
86
+ tsx?: boolean;
87
+ };
88
+
89
+ interface TypeScriptInterfaceProps<T extends Record<string, any> = Record<string, any>> extends InterfaceDeclarationProps, ComponentProps {
90
+ reflection: ReflectionClass<T>;
91
+ defaultValue?: Partial<T>;
92
+ }
93
+
94
+ /**
95
+ * Generates the environment configuration typescript definition for the Powerlines project.
96
+ */
97
+ declare function EnvTypeDefinition(props: Omit<TypeScriptInterfaceProps, "name">): Children$1;
98
+ interface EnvBuiltinProps extends Omit<BuiltinFileProps, "id"> {
99
+ defaultConfig?: Children$1;
100
+ }
101
+ /**
102
+ * Generates the environment configuration module for the Powerlines project.
103
+ */
104
+ declare function EnvBuiltin(props: EnvBuiltinProps): Children$1;
105
+
106
+ export { EnvBuiltin, type EnvBuiltinProps, EnvTypeDefinition };
@@ -0,0 +1,40 @@
1
+ import {a}from'../chunk-UCUR73HG.js';import {createComponent,createIntrinsic,memo,mergeProps}from'@alloy-js/core/jsx-runtime';import {splitProps,code,Show,For,computed,createResource}from'@alloy-js/core';import {TypeDeclaration,IfStatement,ElseIfClause,ClassDeclaration,ClassMethod,VarDeclaration,NewExpression,FunctionDeclaration}from'@alloy-js/typescript';import {usePowerlines}from'@powerlines/alloy/core/contexts/context';import {refkey}from'@powerlines/alloy/helpers/refkey';import {BuiltinFile}from'@powerlines/alloy/typescript/components/builtin-file';import {TSDoc,TSDocLink,TSDocRemarks,TSDocExample,TSDocThrows,TSDocParam,TSDocReturns}from'@powerlines/alloy/typescript/components/tsdoc';import {TypeScriptInterface}from'@powerlines/alloy/typescript/components/typescript-interface';import {TypescriptObject}from'@powerlines/alloy/typescript/components/typescript-object';import {ReflectionClass,ReflectionKind}from'@powerlines/deepkit/vendor/type';import {titleCase}from'@stryke/string-format/title-case';import {isNull}from'@stryke/type-checks/is-null';import U from'defu';import {loadEnvFromContext}from'../helpers/load';import {readEnvTypeReflection}from'../helpers/persistence';/*****************************************
2
+ *
3
+ * ⚡ Built by Storm Software
4
+ *
5
+ *****************************************/
6
+
7
+ function Z(u){const[{defaultValue:o,reflection:r}]=splitProps(u,["defaultValue","reflection"]),a=usePowerlines();return [createComponent(TypeScriptInterface,{name:" EnvBase",extends:["EnvInterface"],defaultValue:o,reflection:r,export:true}),createIntrinsic("hbr",{}),createIntrinsic("hbr",{}),createComponent(TypeDeclaration,{name:"Env",export:true,get children(){return code` {
8
+ [Key in keyof EnvBase as Key ${a?.config.env.prefix.map(s=>`| \`${s.replace(/_$/g,"")}_\${Key}\``).join(" ")}]: EnvBase[Key];
9
+ }
10
+ `}})]}a(Z,"EnvTypeDefinition");function g(u){const[{context:o,name:r}]=splitProps(u,["context","name"]);return o?code`propertyName === "${r}" || propertyName.replace(/^(${o.config.env.prefix.sort((a,s)=>a.startsWith(s)?-1:s.startsWith(a)?1:a.localeCompare(s)).map(a=>`${a.replace(/_$/,"")}_`).join("|")})/g, "").toLowerCase().replace(/[\\s\\-_]+/g, "") === "${r.toLowerCase().replace(/[\s\-_]+/g,"")}"`:null}a(g,"ConfigPropertyConditional");function ee(u){const[{context:o,property:r,index:a$1}]=splitProps(u,["context","property","index"]);return o?[a$1===0?createComponent(IfStatement,{get condition(){return [createComponent(g,{get name(){return r.getNameAsString()},context:o}),createComponent(Show,{get when(){return memo(()=>!!r.getAlias())()&&r.getAlias().length>0},get children(){return [code` || `,createComponent(For,{get each(){return r.getAlias()},joiner:code` || `,children:a(s=>createComponent(g,{name:s,context:o}),"children")})]}})]},get children(){return code`return target["${r.getNameAsString()}"];`}}):createComponent(ElseIfClause,{get condition(){return [createComponent(g,{get name(){return r.getNameAsString()},context:o}),createComponent(Show,{get when(){return memo(()=>!!r.getAlias())()&&r.getAlias().length>0},get children(){return [code` || `,createComponent(For,{get each(){return r.getAlias()},joiner:code` || `,children:a(s=>createComponent(g,{name:s,context:o}),"children")})]}})]},get children(){return code`return target["${r.getNameAsString()}"];`}})]:null}a(ee,"ConfigPropertyGet");function te(u){const[{context:o,property:r,index:a$1}]=splitProps(u,["context","property","index"]);return o?[a$1===0?createComponent(IfStatement,{get condition(){return [createComponent(g,{get name(){return r.getNameAsString()},context:o}),createComponent(Show,{get when(){return memo(()=>!!r.getAlias())()&&r.getAlias().length>0},get children(){return [code` || `,createComponent(For,{get each(){return r.getAlias()},joiner:code` || `,children:a(s=>createComponent(g,{name:s,context:o}),"children")})]}})]},get children(){return code`
11
+ target["${r.getNameAsString()}"] = newValue;
12
+ return true;
13
+ `}}):createComponent(ElseIfClause,{get condition(){return [createComponent(g,{get name(){return r.getNameAsString()},context:o}),createComponent(Show,{get when(){return memo(()=>!!r.getAlias())()&&r.getAlias().length>0},get children(){return [code` || `,createComponent(For,{get each(){return r.getAlias()},joiner:code` || `,children:a(s=>createComponent(g,{name:s,context:o}),"children")})]}})]},get children(){return code`
14
+ target["${r.getNameAsString()}"] = newValue;
15
+ return true;
16
+ `}})]:null}a(te,"ConfigPropertySet");const re=refkey("createEnv"),ne=refkey("env"),ie=refkey("EnvSerializer");function Ee(u){const[{defaultConfig:o},r]=splitProps(u,["defaultConfig"]),a$1=usePowerlines(),s=computed(()=>a$1&&loadEnvFromContext(a$1,process.env)),h=createResource(async()=>{if(!a$1)return new ReflectionClass({kind:ReflectionKind.objectLiteral,description:"The initial environment configuration state for the Powerlines project.",types:[]});const l=await readEnvTypeReflection(a$1,"env");return l.getProperties().forEach(t=>{t.getAlias().filter(Boolean).forEach(y=>{l.addProperty({name:y,optional:t.isOptional()?true:void 0,readonly:t.isReadonly()?true:void 0,description:t.getDescription(),visibility:t.getVisibility(),type:t.getType(),default:t.getDefaultValue(),tags:{hidden:t.isHidden(),ignore:t.isIgnored(),internal:t.isInternal(),alias:t.getAlias().filter(I=>I!==y).concat(t.name),title:t.getTitle()||titleCase(t.name),readonly:t.isReadonly(),permission:t.getPermission(),domain:t.getDomain()}});});}),l.getProperties().forEach(t=>{t.setDefaultValue(s.value?.[t.getNameAsString()]??t.getAlias().reduce((w,y)=>w??s.value?.[y],void 0)??t.getDefaultValue());}),l}),D=computed(()=>new ReflectionClass({kind:ReflectionKind.objectLiteral,description:`The initial environment configuration state for the ${titleCase(a$1?.config?.name)} project.`,types:[]},h.data??void 0)),V=computed(()=>h.data?.getProperties().filter(l=>!l.isIgnored()).sort((l,t)=>l.getNameAsString().localeCompare(t.getNameAsString()))??[]),R=computed(()=>h.data?.getProperties().filter(l=>!l.isIgnored()&&!l.isReadonly()).sort((l,t)=>l.getNameAsString().localeCompare(t.getNameAsString()))??[]);return createComponent(BuiltinFile,mergeProps(r,{id:"env",description:"The Powerlines environment configuration module provides an interface to define environment configuration parameters.",get imports(){return U({"@powerlines/deepkit/vendor/type":["Type","stringify","serializer","serializeFunction","deserializeFunction","ReflectionKind","TemplateState","Serializer","TypeProperty","TypePropertySignature"],"@powerlines/plugin-env/types/runtime":[{name:"EnvInterface"}]},r.imports??{})},get children(){return [createComponent(Show,{get when(){return !isNull(h.data)},get children(){return [createComponent(Z,{get defaultValue(){return s.value},get reflection(){return h.data}}),createIntrinsic("hbr",{}),createIntrinsic("hbr",{})]}}),createComponent(TypescriptObject,{name:"initialEnv",type:"Partial<EnvBase>",defaultValue:s,reflection:D,export:true,const:true}),createIntrinsic("hbr",{}),createIntrinsic("hbr",{}),createComponent(TSDoc,{heading:"The environment configuration serializer for the Powerlines application.",get children(){return [createComponent(TSDocLink,{children:"https://deepkit.io/docs/serialization/serializers"}),createComponent(TSDocLink,{children:"https://github.com/marcj/untitled-code/blob/master/packages/type/src/serializer.ts#L1918"}),createComponent(TSDocRemarks,{children:"This serializer is used to serialize and deserialize the Powerlines environment configuration."})]}}),createComponent(ClassDeclaration,{refkey:ie,name:"EnvSerializer",extends:"Serializer",export:true,get children(){return createComponent(ClassMethod,{name:"constructor",public:true,children:code`
17
+ super("env");
18
+
19
+ this.deserializeRegistry.register(
20
+ ReflectionKind.boolean,
21
+ (type: Type, state: TemplateState) => {
22
+ state.addSetter(
23
+ \`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()}\`
24
+ );
25
+ }
26
+ );
27
+ `})}}),createIntrinsic("hbr",{}),createIntrinsic("hbr",{}),createComponent(TSDoc,{heading:"A {@link EnvSerializer | environment configuration serializer} instance for the Powerlines application.",get children(){return [createComponent(TSDocLink,{children:"https://deepkit.io/docs/serialization/serializers"}),createComponent(TSDocLink,{children:"https://github.com/marcj/untitled-code/blob/master/packages/type/src/serializer.ts#L1918"}),createComponent(TSDocRemarks,{children:"This serializer is used to serialize and deserialize the Powerlines environment configuration."})]}}),createComponent(VarDeclaration,{name:"envSerializer",export:false,const:true,get initializer(){return createComponent(NewExpression,{args:[],target:"EnvSerializer"})}}),createIntrinsic("hbr",{}),createIntrinsic("hbr",{}),createComponent(TSDoc,{heading:"Serialize a environment configuration object to JSON data objects (not a JSON string).",get children(){return [createComponent(TSDocRemarks,{children:"The resulting JSON object can be stringified using JSON.stringify()."}),createComponent(TSDocExample,{children:"const json = serializeEnv(env);"}),createComponent(TSDocThrows,{children:"ValidationError when serialization or validation fails."})]}}),createComponent(VarDeclaration,{name:"serializeEnv",export:true,const:true,initializer:"serializeFunction<EnvBase>(envSerializer)"}),createIntrinsic("hbr",{}),createIntrinsic("hbr",{}),createComponent(TSDoc,{heading:"Deserialize a environment configuration object from JSON data objects to JavaScript objects, without running any validators.",get children(){return [createComponent(TSDocRemarks,{children:"Types that are already correct will be used as-is."}),createComponent(TSDocExample,{children:"const env = deserializeEnv(json);"}),createComponent(TSDocThrows,{children:"ValidationError when deserialization fails."})]}}),createComponent(VarDeclaration,{name:"deserializeEnv",export:true,const:true,initializer:"deserializeFunction<EnvBase>(envSerializer)"}),createIntrinsic("hbr",{}),createIntrinsic("hbr",{}),createComponent(TSDoc,{heading:"Initializes the Powerlines environment configuration module.",get children(){return [createComponent(TSDocRemarks,{children:"This function initializes the Powerlines environment configuration object."}),createComponent(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."}),createComponent(TSDocReturns,{children:"The initialized Powerlines configuration object."})]}}),createComponent(Show,{get when(){return !!a$1?.entryPath},get children(){return createComponent(FunctionDeclaration,{refkey:re,async:false,export:true,name:"createEnv",parameters:[{name:"environmentConfig",type:"Partial<Env>",optional:false,default:"{}"}],returnType:"Env",get children(){return [code`
28
+ return new Proxy<Env>(
29
+ deserializeEnv({
30
+ ...initialEnv,
31
+ ...environmentConfig
32
+ }) as Env,
33
+ {
34
+ get: (target: EnvBase, propertyName: string) => { `,createIntrinsic("hbr",{}),createComponent(For,{each:V,children:a((l,t)=>createComponent(ee,{index:t,context:a$1,property:l}),"children")}),code`
35
+ return undefined;
36
+ }, `,createIntrinsic("hbr",{}),createIntrinsic("hbr",{}),code` set: (target: EnvBase, propertyName: string, newValue: any) => { `,createIntrinsic("hbr",{}),createComponent(For,{each:R,ender:code` else `,children:a((l,t)=>createComponent(te,{index:t,context:a$1,property:l}),"children")}),createIntrinsic("hbr",{}),code`return false;
37
+ }
38
+ }
39
+ );
40
+ `]}})}}),createIntrinsic("hbr",{}),createIntrinsic("hbr",{}),createIntrinsic("hbr",{}),createComponent(VarDeclaration,{refkey:ne,name:"env",type:"Env",export:true,const:true,get initializer(){return [code`createEnv(`,o||"{}",code` as Partial<Env>)`]}})]}}))}a(Ee,"EnvBuiltin");export{Ee as EnvBuiltin,Z as EnvTypeDefinition};
@@ -0,0 +1 @@
1
+ 'use strict';var env=require('./env');Object.keys(env).forEach(function(k){if(k!=='default'&&!Object.prototype.hasOwnProperty.call(exports,k))Object.defineProperty(exports,k,{enumerable:true,get:function(){return env[k]}})});
@@ -0,0 +1,10 @@
1
+ export { EnvBuiltin, EnvBuiltinProps, EnvTypeDefinition } from './env.cjs';
2
+ import '@alloy-js/core';
3
+ import '@alloy-js/core/jsx-runtime';
4
+ import '../vfs-Bl84Hw2V.cjs';
5
+ import '@stryke/json/types';
6
+ import 'memfs';
7
+ import 'node:fs';
8
+ import 'unionfs';
9
+ import '@alloy-js/typescript';
10
+ import '@deepkit/type';
@@ -0,0 +1,10 @@
1
+ export { EnvBuiltin, EnvBuiltinProps, EnvTypeDefinition } from './env.js';
2
+ import '@alloy-js/core';
3
+ import '@alloy-js/core/jsx-runtime';
4
+ import '../vfs-Bl84Hw2V.js';
5
+ import '@stryke/json/types';
6
+ import 'memfs';
7
+ import 'node:fs';
8
+ import 'unionfs';
9
+ import '@alloy-js/typescript';
10
+ import '@deepkit/type';
@@ -0,0 +1 @@
1
+ export*from'./env';
@@ -0,0 +1 @@
1
+ 'use strict';var load=require('./load'),persistence=require('./persistence'),reflect=require('./reflect'),sourceFileEnv=require('./source-file-env'),templateHelpers=require('./template-helpers');Object.keys(load).forEach(function(k){if(k!=='default'&&!Object.prototype.hasOwnProperty.call(exports,k))Object.defineProperty(exports,k,{enumerable:true,get:function(){return load[k]}})});Object.keys(persistence).forEach(function(k){if(k!=='default'&&!Object.prototype.hasOwnProperty.call(exports,k))Object.defineProperty(exports,k,{enumerable:true,get:function(){return persistence[k]}})});Object.keys(reflect).forEach(function(k){if(k!=='default'&&!Object.prototype.hasOwnProperty.call(exports,k))Object.defineProperty(exports,k,{enumerable:true,get:function(){return reflect[k]}})});Object.keys(sourceFileEnv).forEach(function(k){if(k!=='default'&&!Object.prototype.hasOwnProperty.call(exports,k))Object.defineProperty(exports,k,{enumerable:true,get:function(){return sourceFileEnv[k]}})});Object.keys(templateHelpers).forEach(function(k){if(k!=='default'&&!Object.prototype.hasOwnProperty.call(exports,k))Object.defineProperty(exports,k,{enumerable:true,get:function(){return templateHelpers[k]}})});
@@ -0,0 +1,34 @@
1
+ export { loadEnv, loadEnvFromContext } from './load.cjs';
2
+ export { getEnvDefaultTypeDefinition, getEnvReflectionsPath, getEnvTypeReflectionsPath, getSecretsDefaultTypeDefinition, readEnvReflection, readEnvTypeReflection, readSecretsReflection, resolveRuntimeTypeFile, writeEnvReflection, writeEnvReflectionSync, writeEnvTypeReflection } from './persistence.cjs';
3
+ export { BaseEnv, BaseSecrets, CreateEnvReflectionOptions, createEnvReflection, createSecretsReflection, mergeEnvReflections, mergeSecretsReflections, reflectEnv, reflectSecrets } from './reflect.cjs';
4
+ export { formatEnvField, removeEnvPrefix } from './source-file-env.cjs';
5
+ export { createTemplateReflection } from './template-helpers.cjs';
6
+ import '../runtime-DEhb6gxi.cjs';
7
+ import '@stryke/env/get-env-paths';
8
+ import '@stryke/types/package-json';
9
+ import 'jiti';
10
+ import 'oxc-parser';
11
+ import 'semver';
12
+ import 'unplugin';
13
+ import '@babel/core';
14
+ import '@storm-software/build-tools/types';
15
+ import '@storm-software/config-tools/types';
16
+ import '@storm-software/config/types';
17
+ import '@stryke/types/base';
18
+ import '@stryke/types/configuration';
19
+ import '@stryke/types/file';
20
+ import 'vite';
21
+ import '@babel/helper-plugin-utils';
22
+ import '@stryke/types/array';
23
+ import '@stryke/types/tsconfig';
24
+ import 'typescript';
25
+ import '../vfs-Bl84Hw2V.cjs';
26
+ import '@stryke/json/types';
27
+ import 'memfs';
28
+ import 'node:fs';
29
+ import 'unionfs';
30
+ import '@stryke/env/types';
31
+ import '../types/plugin.cjs';
32
+ import '@alloy-js/core/jsx-runtime';
33
+ import '@deepkit/type';
34
+ import '@stryke/capnp';