@powerlines/plugin-env 0.3.0 → 0.5.0

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/package.json +11 -11
  2. package/dist/babel/index.cjs +0 -1
  3. package/dist/babel/index.d.cts +0 -28
  4. package/dist/babel/index.d.ts +0 -28
  5. package/dist/babel/index.js +0 -1
  6. package/dist/babel/plugin.cjs +0 -19
  7. package/dist/babel/plugin.d.cts +0 -31
  8. package/dist/babel/plugin.d.ts +0 -31
  9. package/dist/babel/plugin.js +0 -19
  10. package/dist/chunk-FBBMZ4NC.cjs +0 -7
  11. package/dist/chunk-UCUR73HG.js +0 -7
  12. package/dist/components/env.cjs +0 -40
  13. package/dist/components/env.d.cts +0 -106
  14. package/dist/components/env.d.ts +0 -106
  15. package/dist/components/env.js +0 -40
  16. package/dist/components/index.cjs +0 -1
  17. package/dist/components/index.d.cts +0 -9
  18. package/dist/components/index.d.ts +0 -9
  19. package/dist/components/index.js +0 -1
  20. package/dist/helpers/index.cjs +0 -1
  21. package/dist/helpers/index.d.cts +0 -32
  22. package/dist/helpers/index.d.ts +0 -32
  23. package/dist/helpers/index.js +0 -1
  24. package/dist/helpers/load.cjs +0 -7
  25. package/dist/helpers/load.d.cts +0 -57
  26. package/dist/helpers/load.d.ts +0 -57
  27. package/dist/helpers/load.js +0 -7
  28. package/dist/helpers/persistence.cjs +0 -7
  29. package/dist/helpers/persistence.d.cts +0 -98
  30. package/dist/helpers/persistence.d.ts +0 -98
  31. package/dist/helpers/persistence.js +0 -7
  32. package/dist/helpers/reflect.cjs +0 -7
  33. package/dist/helpers/reflect.d.cts +0 -70
  34. package/dist/helpers/reflect.d.ts +0 -70
  35. package/dist/helpers/reflect.js +0 -7
  36. package/dist/helpers/source-file-env.cjs +0 -7
  37. package/dist/helpers/source-file-env.d.cts +0 -7
  38. package/dist/helpers/source-file-env.d.ts +0 -7
  39. package/dist/helpers/source-file-env.js +0 -7
  40. package/dist/helpers/template-helpers.cjs +0 -7
  41. package/dist/helpers/template-helpers.d.cts +0 -38
  42. package/dist/helpers/template-helpers.d.ts +0 -38
  43. package/dist/helpers/template-helpers.js +0 -7
  44. package/dist/index.cjs +0 -22
  45. package/dist/index.d.cts +0 -76
  46. package/dist/index.d.ts +0 -76
  47. package/dist/index.js +0 -22
  48. package/dist/runtime-2DL8LKdD.d.cts +0 -3294
  49. package/dist/runtime-Cij6nHdf.d.ts +0 -3294
  50. package/dist/types/index.cjs +0 -1
  51. package/dist/types/index.d.cts +0 -27
  52. package/dist/types/index.d.ts +0 -27
  53. package/dist/types/index.js +0 -1
  54. package/dist/types/plugin.cjs +0 -1
  55. package/dist/types/plugin.d.cts +0 -169
  56. package/dist/types/plugin.d.ts +0 -169
  57. package/dist/types/plugin.js +0 -0
  58. package/dist/types/runtime.cjs +0 -1
  59. package/dist/types/runtime.d.cts +0 -24
  60. package/dist/types/runtime.d.ts +0 -24
  61. package/dist/types/runtime.js +0 -0
  62. package/dist/vfs-COoZkq8D.d.cts +0 -358
  63. package/dist/vfs-COoZkq8D.d.ts +0 -358
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@powerlines/plugin-env",
3
- "version": "0.3.0",
3
+ "version": "0.5.0",
4
4
  "type": "module",
5
5
  "description": "A package containing a Powerlines plugin for injecting static .env configuration values to the code so that they're accessible at runtime.",
6
6
  "repository": {
@@ -185,29 +185,29 @@
185
185
  "@alloy-js/typescript": "^0.20.0",
186
186
  "@babel/core": "^7.28.4",
187
187
  "@babel/types": "^7.28.4",
188
- "@powerlines/alloy": "^0.3.0",
189
- "@powerlines/plugin-babel": "^0.4.0",
190
- "@powerlines/plugin-plugin": "^0.4.0",
188
+ "@powerlines/alloy": "^0.5.0",
189
+ "@powerlines/plugin-babel": "^0.6.0",
190
+ "@powerlines/plugin-plugin": "^0.6.0",
191
191
  "@storm-software/config-tools": "^1.188.6",
192
- "@stryke/capnp": "^0.11.24",
193
- "@stryke/env": "^0.19.12",
194
- "@stryke/fs": "^0.31.4",
192
+ "@stryke/capnp": "^0.12.2",
193
+ "@stryke/env": "^0.20.2",
194
+ "@stryke/fs": "^0.32.2",
195
195
  "@stryke/json": "^0.9.3",
196
196
  "@stryke/string-format": "^0.12.0",
197
197
  "@stryke/type-checks": "^0.3.10",
198
198
  "@stryke/types": "^0.10.0",
199
- "powerlines": "^0.4.0"
199
+ "powerlines": "^0.5.0"
200
200
  },
201
201
  "devDependencies": {
202
202
  "@alloy-js/babel-preset": "^0.2.1",
203
203
  "@babel/preset-typescript": "^7.27.1",
204
- "@powerlines/nx": "^0.4.0",
204
+ "@powerlines/nx": "^0.5.0",
205
205
  "@storm-software/tsup": "^0.2.4",
206
- "@types/node": "^22.18.11",
206
+ "@types/node": "^22.18.12",
207
207
  "tsup": "8.4.0",
208
208
  "typescript": "^5.9.3",
209
209
  "vite": "^7.1.11"
210
210
  },
211
211
  "publishConfig": { "access": "public" },
212
- "gitHead": "f4d0c8a8f0036ac8de46ac96afd9336a390a7268"
212
+ "gitHead": "8ec5ff52ffc87cfbf2807e077209ea5745a95d43"
213
213
  }
@@ -1 +0,0 @@
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]}})});
@@ -1,28 +0,0 @@
1
- export { envBabelPlugin } from './plugin.cjs';
2
- import '../runtime-2DL8LKdD.cjs';
3
- import '@stryke/env/get-env-paths';
4
- import '@stryke/types/package-json';
5
- import 'jiti';
6
- import '@deepkit/type';
7
- import 'semver';
8
- import 'unplugin';
9
- import '@stryke/capnp';
10
- import '@storm-software/config-tools/types';
11
- import '@stryke/types/base';
12
- import '@stryke/types/configuration';
13
- import '@stryke/types/file';
14
- import 'vite';
15
- import '@babel/core';
16
- import '@storm-software/build-tools/types';
17
- import '@storm-software/config/types';
18
- import '@babel/helper-plugin-utils';
19
- import '@stryke/types/array';
20
- import '@stryke/types/tsconfig';
21
- import 'typescript';
22
- import '../vfs-COoZkq8D.cjs';
23
- import 'memfs';
24
- import 'node:fs';
25
- import 'unionfs';
26
- import '../types/plugin.cjs';
27
- import '@alloy-js/core/jsx-runtime';
28
- import '@stryke/env/types';
@@ -1,28 +0,0 @@
1
- export { envBabelPlugin } from './plugin.js';
2
- import '../runtime-Cij6nHdf.js';
3
- import '@stryke/env/get-env-paths';
4
- import '@stryke/types/package-json';
5
- import 'jiti';
6
- import '@deepkit/type';
7
- import 'semver';
8
- import 'unplugin';
9
- import '@stryke/capnp';
10
- import '@storm-software/config-tools/types';
11
- import '@stryke/types/base';
12
- import '@stryke/types/configuration';
13
- import '@stryke/types/file';
14
- import 'vite';
15
- import '@babel/core';
16
- import '@storm-software/build-tools/types';
17
- import '@storm-software/config/types';
18
- import '@babel/helper-plugin-utils';
19
- import '@stryke/types/array';
20
- import '@stryke/types/tsconfig';
21
- import 'typescript';
22
- import '../vfs-COoZkq8D.js';
23
- import 'memfs';
24
- import 'node:fs';
25
- import 'unionfs';
26
- import '../types/plugin.js';
27
- import '@alloy-js/core/jsx-runtime';
28
- import '@stryke/env/types';
@@ -1 +0,0 @@
1
- export*from'./plugin';
@@ -1,19 +0,0 @@
1
- 'use strict';var chunkFBBMZ4NC_cjs=require('../chunk-FBBMZ4NC.cjs'),createPlugin=require('@powerlines/plugin-babel/helpers/create-plugin'),moduleHelpers=require('@powerlines/plugin-babel/helpers/module-helpers'),types=require('@storm-software/config-tools/types'),y=require('@stryke/capnp'),buffer=require('@stryke/fs/buffer'),node_fs=require('node:fs'),type=require('powerlines/deepkit/type'),capnp=require('powerlines/lib/capnp'),utilities=require('powerlines/lib/deepkit/utilities'),reflection=require('powerlines/schemas/reflection'),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 y__namespace=/*#__PURE__*/_interopNamespace(y);/*****************************************
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 y__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;
@@ -1,31 +0,0 @@
1
- import { D as DeclareBabelTransformPluginReturn } from '../runtime-2DL8LKdD.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 '@deepkit/type';
7
- import 'semver';
8
- import 'unplugin';
9
- import '@stryke/capnp';
10
- import '@storm-software/config-tools/types';
11
- import '@stryke/types/base';
12
- import '@stryke/types/configuration';
13
- import '@stryke/types/file';
14
- import 'vite';
15
- import '@babel/core';
16
- import '@storm-software/build-tools/types';
17
- import '@storm-software/config/types';
18
- import '@babel/helper-plugin-utils';
19
- import '@stryke/types/array';
20
- import '@stryke/types/tsconfig';
21
- import 'typescript';
22
- import '../vfs-COoZkq8D.cjs';
23
- import 'memfs';
24
- import 'node:fs';
25
- import 'unionfs';
26
- import '@alloy-js/core/jsx-runtime';
27
- import '@stryke/env/types';
28
-
29
- declare const envBabelPlugin: DeclareBabelTransformPluginReturn<EnvPluginContext<EnvPluginResolvedConfig>, Record<string, any>>;
30
-
31
- export { envBabelPlugin };
@@ -1,31 +0,0 @@
1
- import { D as DeclareBabelTransformPluginReturn } from '../runtime-Cij6nHdf.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 '@deepkit/type';
7
- import 'semver';
8
- import 'unplugin';
9
- import '@stryke/capnp';
10
- import '@storm-software/config-tools/types';
11
- import '@stryke/types/base';
12
- import '@stryke/types/configuration';
13
- import '@stryke/types/file';
14
- import 'vite';
15
- import '@babel/core';
16
- import '@storm-software/build-tools/types';
17
- import '@storm-software/config/types';
18
- import '@babel/helper-plugin-utils';
19
- import '@stryke/types/array';
20
- import '@stryke/types/tsconfig';
21
- import 'typescript';
22
- import '../vfs-COoZkq8D.js';
23
- import 'memfs';
24
- import 'node:fs';
25
- import 'unionfs';
26
- import '@alloy-js/core/jsx-runtime';
27
- import '@stryke/env/types';
28
-
29
- declare const envBabelPlugin: DeclareBabelTransformPluginReturn<EnvPluginContext<EnvPluginResolvedConfig>, Record<string, any>>;
30
-
31
- export { envBabelPlugin };
@@ -1,19 +0,0 @@
1
- import {a}from'../chunk-UCUR73HG.js';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 y from'@stryke/capnp';import {readFileBufferSync}from'@stryke/fs/buffer';import {existsSync}from'node:fs';import {ReflectionClass,ReflectionKind,resolveClassType,deserializeType}from'powerlines/deepkit/type';import {convertFromCapnp}from'powerlines/lib/capnp';import {stringifyDefaultValue}from'powerlines/lib/deepkit/utilities';import {SerializedTypes}from'powerlines/schemas/reflection';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 y.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};
@@ -1,7 +0,0 @@
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;
@@ -1,7 +0,0 @@
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};
@@ -1,40 +0,0 @@
1
- 'use strict';var chunkFBBMZ4NC_cjs=require('../chunk-FBBMZ4NC.cjs'),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'),titleCase=require('@stryke/string-format/title-case'),isNull=require('@stryke/type-checks/is-null'),W=require('defu'),type=require('powerlines/deepkit/type'),load=require('../helpers/load'),persistence=require('../helpers/persistence');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var W__default=/*#__PURE__*/_interopDefault(W);/*****************************************
2
- *
3
- * ⚡ Built by Storm Software
4
- *
5
- *****************************************/
6
-
7
- function Q(s){const[{defaultValue:r,reflection:t}]=core.splitProps(s,["defaultValue","reflection"]),i=context.usePowerlines();return React.createElement(React.Fragment,null,React.createElement(typescriptInterface.TypeScriptInterface,{name:" EnvBase",extends:["EnvInterface"],defaultValue:r,reflection:t,export:true}),React.createElement("hbr",null),React.createElement("hbr",null),React.createElement(typescript.TypeDeclaration,{name:"Env",export:true},core.code` {
8
- [Key in keyof EnvBase as Key ${i?.value?.config.env.prefix.map(o=>`| \`${o.replace(/_$/g,"")}_\${Key}\``).join(" ")}]: EnvBase[Key];
9
- }
10
- `))}chunkFBBMZ4NC_cjs.a(Q,"EnvTypeDefinition");function l(s){const[{context:r,name:t}]=core.splitProps(s,["context","name"]);return r?core.code`propertyName === "${t}" || propertyName.replace(/^(${r.config.env.prefix.sort((i,o)=>i.startsWith(o)?-1:o.startsWith(i)?1:i.localeCompare(o)).map(i=>`${i.replace(/_$/,"")}_`).join("|")})/g, "").toLowerCase().replace(/[\\s\\-_]+/g, "") === "${t.toLowerCase().replace(/[\s\-_]+/g,"")}"`:null}chunkFBBMZ4NC_cjs.a(l,"ConfigPropertyConditional");function U(s){const[{context:r,property:t,index:i}]=core.splitProps(s,["context","property","index"]);return r?React.createElement(React.Fragment,null,i===0?React.createElement(typescript.IfStatement,{condition:React.createElement(React.Fragment,null,React.createElement(l,{name:t.getNameAsString(),context:r}),React.createElement(core.Show,{when:t.getAlias()&&t.getAlias().length>0},core.code` || `,React.createElement(core.For,{each:t.getAlias(),joiner:core.code` || `},o=>React.createElement(l,{name:o,context:r}))))},core.code`return target["${t.getNameAsString()}"];`):React.createElement(typescript.ElseIfClause,{condition:React.createElement(React.Fragment,null,React.createElement(l,{name:t.getNameAsString(),context:r}),React.createElement(core.Show,{when:t.getAlias()&&t.getAlias().length>0},core.code` || `,React.createElement(core.For,{each:t.getAlias(),joiner:core.code` || `},o=>React.createElement(l,{name:o,context:r}))))},core.code`return target["${t.getNameAsString()}"];`)):null}chunkFBBMZ4NC_cjs.a(U,"ConfigPropertyGet");function X(s){const[{context:r,property:t,index:i}]=core.splitProps(s,["context","property","index"]);return r?React.createElement(React.Fragment,null,i===0?React.createElement(typescript.IfStatement,{condition:React.createElement(React.Fragment,null,React.createElement(l,{name:t.getNameAsString(),context:r}),React.createElement(core.Show,{when:t.getAlias()&&t.getAlias().length>0},core.code` || `,React.createElement(core.For,{each:t.getAlias(),joiner:core.code` || `},o=>React.createElement(l,{name:o,context:r}))))},core.code`
11
- target["${t.getNameAsString()}"] = newValue;
12
- return true;
13
- `):React.createElement(typescript.ElseIfClause,{condition:React.createElement(React.Fragment,null,React.createElement(l,{name:t.getNameAsString(),context:r}),React.createElement(core.Show,{when:t.getAlias()&&t.getAlias().length>0},core.code` || `,React.createElement(core.For,{each:t.getAlias(),joiner:core.code` || `},o=>React.createElement(l,{name:o,context:r}))))},core.code`
14
- target["${t.getNameAsString()}"] = newValue;
15
- return true;
16
- `)):null}chunkFBBMZ4NC_cjs.a(X,"ConfigPropertySet");const Y=refkey.refkey("createEnv"),Z=refkey.refkey("env"),ee=refkey.refkey("EnvSerializer");function be(s){const[{defaultConfig:r},t]=core.splitProps(s,["defaultConfig"]),i=context.usePowerlines(),o=core.computed(()=>i&&load.loadEnvFromContext(i.value,process.env)),f=core.createResource(async()=>{if(!i?.value)return new type.ReflectionClass({kind:type.ReflectionKind.objectLiteral,description:"The initial environment configuration state for the Powerlines project.",types:[]});const a=await persistence.readEnvTypeReflection(i?.value,"env");return a.getProperties().forEach(e=>{e.getAlias().filter(Boolean).forEach(h=>{a.addProperty({name:h,optional:e.isOptional()?true:void 0,readonly:e.isReadonly()?true: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(j=>j!==h).concat(e.name),title:e.getTitle()||titleCase.titleCase(e.name),readonly:e.isReadonly(),permission:e.getPermission(),domain:e.getDomain()}});});}),a.getProperties().forEach(e=>{e.setDefaultValue(o.value?.[e.getNameAsString()]??e.getAlias().reduce((T,h)=>T??o.value?.[h],void 0)??e.getDefaultValue());}),a}),k=core.computed(()=>new type.ReflectionClass({kind:type.ReflectionKind.objectLiteral,description:`The initial environment configuration state for the ${titleCase.titleCase(i?.value?.config?.name)} project.`,types:[]},f.data??void 0)),R=core.computed(()=>f.data?.getProperties().filter(a=>!a.isIgnored()).sort((a,e)=>a.getNameAsString().localeCompare(e.getNameAsString()))??[]),N=core.computed(()=>f.data?.getProperties().filter(a=>!a.isIgnored()&&!a.isReadonly()).sort((a,e)=>a.getNameAsString().localeCompare(e.getNameAsString()))??[]);return React.createElement(builtinFile.BuiltinFile,{...t,id:"env",description:"The Powerlines environment configuration module provides an interface to define environment configuration parameters.",imports:W__default.default({"powerlines/deepkit/type":["Type","stringify","serializer","serializeFunction","deserializeFunction","ReflectionKind","TemplateState","Serializer","TypeProperty","TypePropertySignature"],"@powerlines/plugin-env/types/runtime":[{name:"EnvInterface"}]},t.imports??{})},React.createElement(core.Show,{when:!isNull.isNull(f.data)},React.createElement(Q,{defaultValue:o.value,reflection:f.data}),React.createElement("hbr",null),React.createElement("hbr",null)),React.createElement(typescriptObject.TypescriptObject,{name:"initialEnv",type:"Partial<EnvBase>",defaultValue:o,reflection:k,export:true,const:true}),React.createElement("hbr",null),React.createElement("hbr",null),React.createElement(tsdoc.TSDoc,{heading:"The environment configuration serializer for the Powerlines application."},React.createElement(tsdoc.TSDocLink,null,"https://deepkit.io/docs/serialization/serializers"),React.createElement(tsdoc.TSDocLink,null,"https://github.com/marcj/untitled-code/blob/master/packages/type/src/serializer.ts#L1918"),React.createElement(tsdoc.TSDocRemarks,null,"This serializer is used to serialize and deserialize the Powerlines environment configuration.")),React.createElement(typescript.ClassDeclaration,{refkey:ee,name:"EnvSerializer",extends:"Serializer",export:true},React.createElement(typescript.ClassMethod,{name:"constructor",public:true},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
- `)),React.createElement("hbr",null),React.createElement("hbr",null),React.createElement(tsdoc.TSDoc,{heading:"A {@link EnvSerializer | environment configuration serializer} instance for the Powerlines application."},React.createElement(tsdoc.TSDocLink,null,"https://deepkit.io/docs/serialization/serializers"),React.createElement(tsdoc.TSDocLink,null,"https://github.com/marcj/untitled-code/blob/master/packages/type/src/serializer.ts#L1918"),React.createElement(tsdoc.TSDocRemarks,null,"This serializer is used to serialize and deserialize the Powerlines environment configuration.")),React.createElement(typescript.VarDeclaration,{name:"envSerializer",export:false,const:true,initializer:React.createElement(typescript.NewExpression,{args:[],target:"EnvSerializer"})}),React.createElement("hbr",null),React.createElement("hbr",null),React.createElement(tsdoc.TSDoc,{heading:"Serialize a environment configuration object to JSON data objects (not a JSON string)."},React.createElement(tsdoc.TSDocRemarks,null,"The resulting JSON object can be stringified using JSON.stringify()."),React.createElement(tsdoc.TSDocExample,null,"const json = serializeEnv(env);"),React.createElement(tsdoc.TSDocThrows,null,"ValidationError when serialization or validation fails.")),React.createElement(typescript.VarDeclaration,{name:"serializeEnv",export:true,const:true,initializer:"serializeFunction<EnvBase>(envSerializer)"}),React.createElement("hbr",null),React.createElement("hbr",null),React.createElement(tsdoc.TSDoc,{heading:"Deserialize a environment configuration object from JSON data objects to JavaScript objects, without running any validators."},React.createElement(tsdoc.TSDocRemarks,null,"Types that are already correct will be used as-is."),React.createElement(tsdoc.TSDocExample,null,"const env = deserializeEnv(json);"),React.createElement(tsdoc.TSDocThrows,null,"ValidationError when deserialization fails.")),React.createElement(typescript.VarDeclaration,{name:"deserializeEnv",export:true,const:true,initializer:"deserializeFunction<EnvBase>(envSerializer)"}),React.createElement("hbr",null),React.createElement("hbr",null),React.createElement(tsdoc.TSDoc,{heading:"Initializes the Powerlines environment configuration module."},React.createElement(tsdoc.TSDocRemarks,null,"This function initializes the Powerlines environment configuration object."),React.createElement(tsdoc.TSDocParam,{name:"environmentConfig"},"The dynamic/runtime configuration - this could include the current environment variables or any other environment-specific settings provided by the runtime."),React.createElement(tsdoc.TSDocReturns,null,"The initialized Powerlines configuration object.")),React.createElement(core.Show,{when:!!i?.value?.entryPath},React.createElement(typescript.FunctionDeclaration,{refkey:Y,async:false,export:true,name:"createEnv",parameters:[{name:"environmentConfig",type:"Partial<Env>",optional:false,default:"{}"}],returnType:"Env"},core.code`
28
- return new Proxy<Env>(
29
- deserializeEnv({
30
- ...initialEnv,
31
- ...environmentConfig
32
- }) as Env,
33
- {
34
- get: (target: EnvBase, propertyName: string) => { `,React.createElement("hbr",null),React.createElement(core.For,{each:R},(a,e)=>React.createElement(U,{index:e,context:i?.value,property:a})),core.code`
35
- return undefined;
36
- }, `,React.createElement("hbr",null),React.createElement("hbr",null),core.code` set: (target: EnvBase, propertyName: string, newValue: any) => { `,React.createElement("hbr",null),React.createElement(core.For,{each:N,ender:core.code` else `},(a,e)=>React.createElement(X,{index:e,context:i?.value,property:a})),React.createElement("hbr",null),core.code`return false;
37
- }
38
- }
39
- );
40
- `)),React.createElement("hbr",null),React.createElement("hbr",null),React.createElement("hbr",null),React.createElement(typescript.VarDeclaration,{refkey:Z,name:"env",type:"Env",export:true,const:true,initializer:React.createElement(React.Fragment,null,core.code`createEnv(`,r||"{}",core.code` as Partial<Env>)`)}))}chunkFBBMZ4NC_cjs.a(be,"EnvBuiltin");exports.EnvBuiltin=be;exports.EnvTypeDefinition=Q;
@@ -1,106 +0,0 @@
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-COoZkq8D.cjs';
4
- import { InterfaceDeclarationProps } from '@alloy-js/typescript';
5
- import { ReflectionClass } from '@deepkit/type';
6
- import 'memfs';
7
- import 'node:fs';
8
- import 'unionfs';
9
-
10
- /**
11
- * A type that represents the props of a component that can have children.
12
- */
13
- interface ComponentProps {
14
- children?: Children;
15
- }
16
- interface TypescriptFileImportItem {
17
- name: string;
18
- default?: boolean;
19
- alias?: string;
20
- type?: boolean;
21
- }
22
- type TypescriptFileImports = Record<string, null | Array<TypescriptFileImportItem | string>>;
23
-
24
- interface TSDocModuleProps extends ComponentProps {
25
- /**
26
- * the prefix for the builtin module name
27
- *
28
- * @defaultValue "storm"
29
- */
30
- prefix?: string;
31
- /**
32
- * The name of the module
33
- *
34
- * @remarks
35
- * This will be used in the `@module` tag as well as the import path for the module, e.g. `storm:<name>`.
36
- *
37
- * @example
38
- * ```ts
39
- * import { MyModule } from "storm:my-module";
40
- * ```
41
- */
42
- name: Children$1;
43
- }
44
-
45
- type SourceFileProps = SourceFileProps$1 & ComponentProps & {
46
- /**
47
- * If true, indicates that the file is virtual and should not be written to disk.
48
- *
49
- * @defaultValue false
50
- */
51
- mode?: OutputModeType;
52
- /**
53
- * The metadata associated with the source file.
54
- *
55
- * @remarks
56
- * The values stored in the metadata will be available in the rendering context.
57
- */
58
- meta?: Record<string, any>;
59
- };
60
-
61
- type TypescriptFileProps = Omit<SourceFileProps, "filetype"> & ComponentProps & {
62
- header?: Children$1;
63
- imports?: TypescriptFileImports;
64
- export?: boolean | string;
65
- tsx?: boolean;
66
- };
67
-
68
- type BuiltinFileProps = Omit<TypescriptFileProps, "path"> & Omit<TSDocModuleProps, "name"> & {
69
- /**
70
- * The runtime module identifier.
71
- *
72
- * @remarks
73
- * This value will be included after the \`storm:\` prefix in the import statement.
74
- */
75
- id: string;
76
- /**
77
- * The description for the builtin module.
78
- */
79
- description?: string;
80
- /**
81
- * Whether the file is a TSX file.
82
- *
83
- * @defaultValue false
84
- */
85
- tsx?: boolean;
86
- };
87
-
88
- interface TypeScriptInterfaceProps<T extends Record<string, any> = Record<string, any>> extends InterfaceDeclarationProps, ComponentProps {
89
- reflection: ReflectionClass<T>;
90
- defaultValue?: Partial<T>;
91
- }
92
-
93
- /**
94
- * Generates the environment configuration typescript definition for the Powerlines project.
95
- */
96
- declare function EnvTypeDefinition(props: Omit<TypeScriptInterfaceProps, "name">): Children$1;
97
- interface EnvBuiltinProps extends Omit<BuiltinFileProps, "id"> {
98
- defaultConfig?: Children$1;
99
- }
100
- /**
101
- * Generates the environment configuration module for the Powerlines project.
102
- */
103
- declare function EnvBuiltin(props: EnvBuiltinProps): Children$1;
104
- declare type __ΩEnvBuiltinProps = any[];
105
-
106
- export { EnvBuiltin, type EnvBuiltinProps, EnvTypeDefinition, type __ΩEnvBuiltinProps };
@@ -1,106 +0,0 @@
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-COoZkq8D.js';
4
- import { InterfaceDeclarationProps } from '@alloy-js/typescript';
5
- import { ReflectionClass } from '@deepkit/type';
6
- import 'memfs';
7
- import 'node:fs';
8
- import 'unionfs';
9
-
10
- /**
11
- * A type that represents the props of a component that can have children.
12
- */
13
- interface ComponentProps {
14
- children?: Children;
15
- }
16
- interface TypescriptFileImportItem {
17
- name: string;
18
- default?: boolean;
19
- alias?: string;
20
- type?: boolean;
21
- }
22
- type TypescriptFileImports = Record<string, null | Array<TypescriptFileImportItem | string>>;
23
-
24
- interface TSDocModuleProps extends ComponentProps {
25
- /**
26
- * the prefix for the builtin module name
27
- *
28
- * @defaultValue "storm"
29
- */
30
- prefix?: string;
31
- /**
32
- * The name of the module
33
- *
34
- * @remarks
35
- * This will be used in the `@module` tag as well as the import path for the module, e.g. `storm:<name>`.
36
- *
37
- * @example
38
- * ```ts
39
- * import { MyModule } from "storm:my-module";
40
- * ```
41
- */
42
- name: Children$1;
43
- }
44
-
45
- type SourceFileProps = SourceFileProps$1 & ComponentProps & {
46
- /**
47
- * If true, indicates that the file is virtual and should not be written to disk.
48
- *
49
- * @defaultValue false
50
- */
51
- mode?: OutputModeType;
52
- /**
53
- * The metadata associated with the source file.
54
- *
55
- * @remarks
56
- * The values stored in the metadata will be available in the rendering context.
57
- */
58
- meta?: Record<string, any>;
59
- };
60
-
61
- type TypescriptFileProps = Omit<SourceFileProps, "filetype"> & ComponentProps & {
62
- header?: Children$1;
63
- imports?: TypescriptFileImports;
64
- export?: boolean | string;
65
- tsx?: boolean;
66
- };
67
-
68
- type BuiltinFileProps = Omit<TypescriptFileProps, "path"> & Omit<TSDocModuleProps, "name"> & {
69
- /**
70
- * The runtime module identifier.
71
- *
72
- * @remarks
73
- * This value will be included after the \`storm:\` prefix in the import statement.
74
- */
75
- id: string;
76
- /**
77
- * The description for the builtin module.
78
- */
79
- description?: string;
80
- /**
81
- * Whether the file is a TSX file.
82
- *
83
- * @defaultValue false
84
- */
85
- tsx?: boolean;
86
- };
87
-
88
- interface TypeScriptInterfaceProps<T extends Record<string, any> = Record<string, any>> extends InterfaceDeclarationProps, ComponentProps {
89
- reflection: ReflectionClass<T>;
90
- defaultValue?: Partial<T>;
91
- }
92
-
93
- /**
94
- * Generates the environment configuration typescript definition for the Powerlines project.
95
- */
96
- declare function EnvTypeDefinition(props: Omit<TypeScriptInterfaceProps, "name">): Children$1;
97
- interface EnvBuiltinProps extends Omit<BuiltinFileProps, "id"> {
98
- defaultConfig?: Children$1;
99
- }
100
- /**
101
- * Generates the environment configuration module for the Powerlines project.
102
- */
103
- declare function EnvBuiltin(props: EnvBuiltinProps): Children$1;
104
- declare type __ΩEnvBuiltinProps = any[];
105
-
106
- export { EnvBuiltin, type EnvBuiltinProps, EnvTypeDefinition, type __ΩEnvBuiltinProps };
@@ -1,40 +0,0 @@
1
- import {a}from'../chunk-UCUR73HG.js';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 {titleCase}from'@stryke/string-format/title-case';import {isNull}from'@stryke/type-checks/is-null';import W from'defu';import {ReflectionClass,ReflectionKind}from'powerlines/deepkit/type';import {loadEnvFromContext}from'../helpers/load';import {readEnvTypeReflection}from'../helpers/persistence';/*****************************************
2
- *
3
- * ⚡ Built by Storm Software
4
- *
5
- *****************************************/
6
-
7
- function Q(s){const[{defaultValue:r,reflection:t}]=splitProps(s,["defaultValue","reflection"]),i=usePowerlines();return React.createElement(React.Fragment,null,React.createElement(TypeScriptInterface,{name:" EnvBase",extends:["EnvInterface"],defaultValue:r,reflection:t,export:true}),React.createElement("hbr",null),React.createElement("hbr",null),React.createElement(TypeDeclaration,{name:"Env",export:true},code` {
8
- [Key in keyof EnvBase as Key ${i?.value?.config.env.prefix.map(o=>`| \`${o.replace(/_$/g,"")}_\${Key}\``).join(" ")}]: EnvBase[Key];
9
- }
10
- `))}a(Q,"EnvTypeDefinition");function l(s){const[{context:r,name:t}]=splitProps(s,["context","name"]);return r?code`propertyName === "${t}" || propertyName.replace(/^(${r.config.env.prefix.sort((i,o)=>i.startsWith(o)?-1:o.startsWith(i)?1:i.localeCompare(o)).map(i=>`${i.replace(/_$/,"")}_`).join("|")})/g, "").toLowerCase().replace(/[\\s\\-_]+/g, "") === "${t.toLowerCase().replace(/[\s\-_]+/g,"")}"`:null}a(l,"ConfigPropertyConditional");function U(s){const[{context:r,property:t,index:i}]=splitProps(s,["context","property","index"]);return r?React.createElement(React.Fragment,null,i===0?React.createElement(IfStatement,{condition:React.createElement(React.Fragment,null,React.createElement(l,{name:t.getNameAsString(),context:r}),React.createElement(Show,{when:t.getAlias()&&t.getAlias().length>0},code` || `,React.createElement(For,{each:t.getAlias(),joiner:code` || `},o=>React.createElement(l,{name:o,context:r}))))},code`return target["${t.getNameAsString()}"];`):React.createElement(ElseIfClause,{condition:React.createElement(React.Fragment,null,React.createElement(l,{name:t.getNameAsString(),context:r}),React.createElement(Show,{when:t.getAlias()&&t.getAlias().length>0},code` || `,React.createElement(For,{each:t.getAlias(),joiner:code` || `},o=>React.createElement(l,{name:o,context:r}))))},code`return target["${t.getNameAsString()}"];`)):null}a(U,"ConfigPropertyGet");function X(s){const[{context:r,property:t,index:i}]=splitProps(s,["context","property","index"]);return r?React.createElement(React.Fragment,null,i===0?React.createElement(IfStatement,{condition:React.createElement(React.Fragment,null,React.createElement(l,{name:t.getNameAsString(),context:r}),React.createElement(Show,{when:t.getAlias()&&t.getAlias().length>0},code` || `,React.createElement(For,{each:t.getAlias(),joiner:code` || `},o=>React.createElement(l,{name:o,context:r}))))},code`
11
- target["${t.getNameAsString()}"] = newValue;
12
- return true;
13
- `):React.createElement(ElseIfClause,{condition:React.createElement(React.Fragment,null,React.createElement(l,{name:t.getNameAsString(),context:r}),React.createElement(Show,{when:t.getAlias()&&t.getAlias().length>0},code` || `,React.createElement(For,{each:t.getAlias(),joiner:code` || `},o=>React.createElement(l,{name:o,context:r}))))},code`
14
- target["${t.getNameAsString()}"] = newValue;
15
- return true;
16
- `)):null}a(X,"ConfigPropertySet");const Y=refkey("createEnv"),Z=refkey("env"),ee=refkey("EnvSerializer");function we(s){const[{defaultConfig:r},t]=splitProps(s,["defaultConfig"]),i=usePowerlines(),o=computed(()=>i&&loadEnvFromContext(i.value,process.env)),f=createResource(async()=>{if(!i?.value)return new ReflectionClass({kind:ReflectionKind.objectLiteral,description:"The initial environment configuration state for the Powerlines project.",types:[]});const a=await readEnvTypeReflection(i?.value,"env");return a.getProperties().forEach(e=>{e.getAlias().filter(Boolean).forEach(h=>{a.addProperty({name:h,optional:e.isOptional()?true:void 0,readonly:e.isReadonly()?true: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(j=>j!==h).concat(e.name),title:e.getTitle()||titleCase(e.name),readonly:e.isReadonly(),permission:e.getPermission(),domain:e.getDomain()}});});}),a.getProperties().forEach(e=>{e.setDefaultValue(o.value?.[e.getNameAsString()]??e.getAlias().reduce((T,h)=>T??o.value?.[h],void 0)??e.getDefaultValue());}),a}),k=computed(()=>new ReflectionClass({kind:ReflectionKind.objectLiteral,description:`The initial environment configuration state for the ${titleCase(i?.value?.config?.name)} project.`,types:[]},f.data??void 0)),R=computed(()=>f.data?.getProperties().filter(a=>!a.isIgnored()).sort((a,e)=>a.getNameAsString().localeCompare(e.getNameAsString()))??[]),N=computed(()=>f.data?.getProperties().filter(a=>!a.isIgnored()&&!a.isReadonly()).sort((a,e)=>a.getNameAsString().localeCompare(e.getNameAsString()))??[]);return React.createElement(BuiltinFile,{...t,id:"env",description:"The Powerlines environment configuration module provides an interface to define environment configuration parameters.",imports:W({"powerlines/deepkit/type":["Type","stringify","serializer","serializeFunction","deserializeFunction","ReflectionKind","TemplateState","Serializer","TypeProperty","TypePropertySignature"],"@powerlines/plugin-env/types/runtime":[{name:"EnvInterface"}]},t.imports??{})},React.createElement(Show,{when:!isNull(f.data)},React.createElement(Q,{defaultValue:o.value,reflection:f.data}),React.createElement("hbr",null),React.createElement("hbr",null)),React.createElement(TypescriptObject,{name:"initialEnv",type:"Partial<EnvBase>",defaultValue:o,reflection:k,export:true,const:true}),React.createElement("hbr",null),React.createElement("hbr",null),React.createElement(TSDoc,{heading:"The environment configuration serializer for the Powerlines application."},React.createElement(TSDocLink,null,"https://deepkit.io/docs/serialization/serializers"),React.createElement(TSDocLink,null,"https://github.com/marcj/untitled-code/blob/master/packages/type/src/serializer.ts#L1918"),React.createElement(TSDocRemarks,null,"This serializer is used to serialize and deserialize the Powerlines environment configuration.")),React.createElement(ClassDeclaration,{refkey:ee,name:"EnvSerializer",extends:"Serializer",export:true},React.createElement(ClassMethod,{name:"constructor",public:true},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
- `)),React.createElement("hbr",null),React.createElement("hbr",null),React.createElement(TSDoc,{heading:"A {@link EnvSerializer | environment configuration serializer} instance for the Powerlines application."},React.createElement(TSDocLink,null,"https://deepkit.io/docs/serialization/serializers"),React.createElement(TSDocLink,null,"https://github.com/marcj/untitled-code/blob/master/packages/type/src/serializer.ts#L1918"),React.createElement(TSDocRemarks,null,"This serializer is used to serialize and deserialize the Powerlines environment configuration.")),React.createElement(VarDeclaration,{name:"envSerializer",export:false,const:true,initializer:React.createElement(NewExpression,{args:[],target:"EnvSerializer"})}),React.createElement("hbr",null),React.createElement("hbr",null),React.createElement(TSDoc,{heading:"Serialize a environment configuration object to JSON data objects (not a JSON string)."},React.createElement(TSDocRemarks,null,"The resulting JSON object can be stringified using JSON.stringify()."),React.createElement(TSDocExample,null,"const json = serializeEnv(env);"),React.createElement(TSDocThrows,null,"ValidationError when serialization or validation fails.")),React.createElement(VarDeclaration,{name:"serializeEnv",export:true,const:true,initializer:"serializeFunction<EnvBase>(envSerializer)"}),React.createElement("hbr",null),React.createElement("hbr",null),React.createElement(TSDoc,{heading:"Deserialize a environment configuration object from JSON data objects to JavaScript objects, without running any validators."},React.createElement(TSDocRemarks,null,"Types that are already correct will be used as-is."),React.createElement(TSDocExample,null,"const env = deserializeEnv(json);"),React.createElement(TSDocThrows,null,"ValidationError when deserialization fails.")),React.createElement(VarDeclaration,{name:"deserializeEnv",export:true,const:true,initializer:"deserializeFunction<EnvBase>(envSerializer)"}),React.createElement("hbr",null),React.createElement("hbr",null),React.createElement(TSDoc,{heading:"Initializes the Powerlines environment configuration module."},React.createElement(TSDocRemarks,null,"This function initializes the Powerlines environment configuration object."),React.createElement(TSDocParam,{name:"environmentConfig"},"The dynamic/runtime configuration - this could include the current environment variables or any other environment-specific settings provided by the runtime."),React.createElement(TSDocReturns,null,"The initialized Powerlines configuration object.")),React.createElement(Show,{when:!!i?.value?.entryPath},React.createElement(FunctionDeclaration,{refkey:Y,async:false,export:true,name:"createEnv",parameters:[{name:"environmentConfig",type:"Partial<Env>",optional:false,default:"{}"}],returnType:"Env"},code`
28
- return new Proxy<Env>(
29
- deserializeEnv({
30
- ...initialEnv,
31
- ...environmentConfig
32
- }) as Env,
33
- {
34
- get: (target: EnvBase, propertyName: string) => { `,React.createElement("hbr",null),React.createElement(For,{each:R},(a,e)=>React.createElement(U,{index:e,context:i?.value,property:a})),code`
35
- return undefined;
36
- }, `,React.createElement("hbr",null),React.createElement("hbr",null),code` set: (target: EnvBase, propertyName: string, newValue: any) => { `,React.createElement("hbr",null),React.createElement(For,{each:N,ender:code` else `},(a,e)=>React.createElement(X,{index:e,context:i?.value,property:a})),React.createElement("hbr",null),code`return false;
37
- }
38
- }
39
- );
40
- `)),React.createElement("hbr",null),React.createElement("hbr",null),React.createElement("hbr",null),React.createElement(VarDeclaration,{refkey:Z,name:"env",type:"Env",export:true,const:true,initializer:React.createElement(React.Fragment,null,code`createEnv(`,r||"{}",code` as Partial<Env>)`)}))}a(we,"EnvBuiltin");export{we as EnvBuiltin,Q as EnvTypeDefinition};
@@ -1 +0,0 @@
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]}})});
@@ -1,9 +0,0 @@
1
- export { EnvBuiltin, EnvBuiltinProps, EnvTypeDefinition, __ΩEnvBuiltinProps } from './env.cjs';
2
- import '@alloy-js/core';
3
- import '@alloy-js/core/jsx-runtime';
4
- import '../vfs-COoZkq8D.cjs';
5
- import 'memfs';
6
- import 'node:fs';
7
- import 'unionfs';
8
- import '@alloy-js/typescript';
9
- import '@deepkit/type';
@@ -1,9 +0,0 @@
1
- export { EnvBuiltin, EnvBuiltinProps, EnvTypeDefinition, __ΩEnvBuiltinProps } from './env.js';
2
- import '@alloy-js/core';
3
- import '@alloy-js/core/jsx-runtime';
4
- import '../vfs-COoZkq8D.js';
5
- import 'memfs';
6
- import 'node:fs';
7
- import 'unionfs';
8
- import '@alloy-js/typescript';
9
- import '@deepkit/type';
@@ -1 +0,0 @@
1
- export*from'./env';
@@ -1 +0,0 @@
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]}})});