@powerlines/plugin-env 0.16.63 → 0.16.64

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.
@@ -8,6 +8,7 @@ defu = require_runtime.__toESM(defu);
8
8
  let _alloy_js_core = require("@alloy-js/core");
9
9
  let _powerlines_plugin_alloy_core_components_spacing = require("@powerlines/plugin-alloy/core/components/spacing");
10
10
  let _powerlines_plugin_alloy_core_contexts_context = require("@powerlines/plugin-alloy/core/contexts/context");
11
+ let _alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
11
12
  let _alloy_js_typescript = require("@alloy-js/typescript");
12
13
  let _powerlines_plugin_alloy_helpers_refkey = require("@powerlines/plugin-alloy/helpers/refkey");
13
14
  let _powerlines_plugin_alloy_typescript_components_builtin_file = require("@powerlines/plugin-alloy/typescript/components/builtin-file");
@@ -22,22 +23,28 @@ let _powerlines_plugin_alloy_typescript_components_tsdoc = require("@powerlines/
22
23
  function EnvTypeDefinition(props) {
23
24
  const [{ defaultValue, reflection }] = (0, _alloy_js_core.splitProps)(props, ["defaultValue", "reflection"]);
24
25
  const context = (0, _powerlines_plugin_alloy_core_contexts_context.usePowerlines)();
25
- return <>
26
- <_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceDeclaration name=" EnvBase" defaultValue={defaultValue} reflection={reflection} export={true} />
27
- <_powerlines_plugin_alloy_core_components_spacing.Spacing />
28
- <_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc heading="The environment configuration object with prefixed keys.">
29
- <_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocRemarks>
30
- {`The \`Env\` type extends the \`EnvBase\` interface by including additional keys that are prefixed according to the project's configuration. This allows for flexibility in accessing environment variables with different naming conventions.`}
31
- </_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocRemarks>
32
- </_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc>
33
- <_alloy_js_typescript.TypeDeclaration name="Env" export={true}>
34
- {_alloy_js_core.code` {
26
+ return /* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsxs)(_alloy_js_core_jsx_runtime.Fragment, { children: [
27
+ /* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsx)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceDeclaration, {
28
+ name: " EnvBase",
29
+ defaultValue,
30
+ reflection,
31
+ export: true
32
+ }),
33
+ /* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsx)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
34
+ /* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsx)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
35
+ heading: "The environment configuration object with prefixed keys.",
36
+ children: /* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsx)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocRemarks, { children: `The \`Env\` type extends the \`EnvBase\` interface by including additional keys that are prefixed according to the project's configuration. This allows for flexibility in accessing environment variables with different naming conventions.` })
37
+ }),
38
+ /* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsx)(_alloy_js_typescript.TypeDeclaration, {
39
+ name: "Env",
40
+ export: true,
41
+ children: _alloy_js_core.code` {
35
42
  [Key in keyof EnvBase as Key ${context.config.env.prefix.map((prefix) => `| \`${prefix.replace(/_$/g, "")}_\${Key}\``).join(" ")}]: EnvBase[Key];
36
43
  }
37
- `}
38
- </_alloy_js_typescript.TypeDeclaration>
39
- <_powerlines_plugin_alloy_core_components_spacing.Spacing />
40
- </>;
44
+ `
45
+ }),
46
+ /* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsx)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {})
47
+ ] });
41
48
  }
42
49
  function ConfigPropertyConditional(props) {
43
50
  const [{ context, name }] = (0, _alloy_js_core.splitProps)(props, ["context", "name"]);
@@ -49,29 +56,39 @@ function ConfigPropertyGet(props) {
49
56
  "property",
50
57
  "index"
51
58
  ]);
52
- return <>
53
- {index === 0 ? <_alloy_js_typescript.IfStatement condition={<>
54
- <ConfigPropertyConditional name={property.getNameAsString()} context={context} />
55
- <_alloy_js_core.Show when={property.getAlias() && property.getAlias().length > 0}>
56
- {_alloy_js_core.code` || `}
57
- <_alloy_js_core.For each={property.getAlias()} joiner={_alloy_js_core.code` || `}>
58
- {(alias) => <ConfigPropertyConditional name={alias} context={context} />}
59
- </_alloy_js_core.For>
60
- </_alloy_js_core.Show>
61
- </>}>
62
- {_alloy_js_core.code`return target["${property.getNameAsString()}"];`}
63
- </_alloy_js_typescript.IfStatement> : <_alloy_js_typescript.ElseIfClause condition={<>
64
- <ConfigPropertyConditional name={property.getNameAsString()} context={context} />
65
- <_alloy_js_core.Show when={property.getAlias() && property.getAlias().length > 0}>
66
- {_alloy_js_core.code` || `}
67
- <_alloy_js_core.For each={property.getAlias()} joiner={_alloy_js_core.code` || `}>
68
- {(alias) => <ConfigPropertyConditional name={alias} context={context} />}
69
- </_alloy_js_core.For>
70
- </_alloy_js_core.Show>
71
- </>}>
72
- {_alloy_js_core.code`return target["${property.getNameAsString()}"];`}
73
- </_alloy_js_typescript.ElseIfClause>}
74
- </>;
59
+ return /* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsx)(_alloy_js_core_jsx_runtime.Fragment, { children: index === 0 ? /* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsx)(_alloy_js_typescript.IfStatement, {
60
+ condition: /* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsxs)(_alloy_js_core_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsx)(ConfigPropertyConditional, {
61
+ name: property.getNameAsString(),
62
+ context
63
+ }), /* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsxs)(_alloy_js_core.Show, {
64
+ when: property.getAlias() && property.getAlias().length > 0,
65
+ children: [_alloy_js_core.code` || `, /* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsx)(_alloy_js_core.For, {
66
+ each: property.getAlias(),
67
+ joiner: _alloy_js_core.code` || `,
68
+ children: (alias) => /* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsx)(ConfigPropertyConditional, {
69
+ name: alias,
70
+ context
71
+ })
72
+ })]
73
+ })] }),
74
+ children: _alloy_js_core.code`return target["${property.getNameAsString()}"];`
75
+ }) : /* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsx)(_alloy_js_typescript.ElseIfClause, {
76
+ condition: /* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsxs)(_alloy_js_core_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsx)(ConfigPropertyConditional, {
77
+ name: property.getNameAsString(),
78
+ context
79
+ }), /* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsxs)(_alloy_js_core.Show, {
80
+ when: property.getAlias() && property.getAlias().length > 0,
81
+ children: [_alloy_js_core.code` || `, /* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsx)(_alloy_js_core.For, {
82
+ each: property.getAlias(),
83
+ joiner: _alloy_js_core.code` || `,
84
+ children: (alias) => /* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsx)(ConfigPropertyConditional, {
85
+ name: alias,
86
+ context
87
+ })
88
+ })]
89
+ })] }),
90
+ children: _alloy_js_core.code`return target["${property.getNameAsString()}"];`
91
+ }) });
75
92
  }
76
93
  function ConfigPropertySet(props) {
77
94
  const [{ context, property, index }] = (0, _alloy_js_core.splitProps)(props, [
@@ -79,35 +96,45 @@ function ConfigPropertySet(props) {
79
96
  "property",
80
97
  "index"
81
98
  ]);
82
- return <>
83
- {index === 0 ? <_alloy_js_typescript.IfStatement condition={<>
84
- <ConfigPropertyConditional name={property.getNameAsString()} context={context} />
85
- <_alloy_js_core.Show when={property.getAlias() && property.getAlias().length > 0}>
86
- {_alloy_js_core.code` || `}
87
- <_alloy_js_core.For each={property.getAlias()} joiner={_alloy_js_core.code` || `}>
88
- {(alias) => <ConfigPropertyConditional name={alias} context={context} />}
89
- </_alloy_js_core.For>
90
- </_alloy_js_core.Show>
91
- </>}>
92
- {_alloy_js_core.code`
99
+ return /* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsx)(_alloy_js_core_jsx_runtime.Fragment, { children: index === 0 ? /* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsx)(_alloy_js_typescript.IfStatement, {
100
+ condition: /* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsxs)(_alloy_js_core_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsx)(ConfigPropertyConditional, {
101
+ name: property.getNameAsString(),
102
+ context
103
+ }), /* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsxs)(_alloy_js_core.Show, {
104
+ when: property.getAlias() && property.getAlias().length > 0,
105
+ children: [_alloy_js_core.code` || `, /* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsx)(_alloy_js_core.For, {
106
+ each: property.getAlias(),
107
+ joiner: _alloy_js_core.code` || `,
108
+ children: (alias) => /* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsx)(ConfigPropertyConditional, {
109
+ name: alias,
110
+ context
111
+ })
112
+ })]
113
+ })] }),
114
+ children: _alloy_js_core.code`
93
115
  target["${property.getNameAsString()}"] = newValue;
94
116
  return true;
95
- `}
96
- </_alloy_js_typescript.IfStatement> : <_alloy_js_typescript.ElseIfClause condition={<>
97
- <ConfigPropertyConditional name={property.getNameAsString()} context={context} />
98
- <_alloy_js_core.Show when={property.getAlias() && property.getAlias().length > 0}>
99
- {_alloy_js_core.code` || `}
100
- <_alloy_js_core.For each={property.getAlias()} joiner={_alloy_js_core.code` || `}>
101
- {(alias) => <ConfigPropertyConditional name={alias} context={context} />}
102
- </_alloy_js_core.For>
103
- </_alloy_js_core.Show>
104
- </>}>
105
- {_alloy_js_core.code`
117
+ `
118
+ }) : /* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsx)(_alloy_js_typescript.ElseIfClause, {
119
+ condition: /* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsxs)(_alloy_js_core_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsx)(ConfigPropertyConditional, {
120
+ name: property.getNameAsString(),
121
+ context
122
+ }), /* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsxs)(_alloy_js_core.Show, {
123
+ when: property.getAlias() && property.getAlias().length > 0,
124
+ children: [_alloy_js_core.code` || `, /* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsx)(_alloy_js_core.For, {
125
+ each: property.getAlias(),
126
+ joiner: _alloy_js_core.code` || `,
127
+ children: (alias) => /* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsx)(ConfigPropertyConditional, {
128
+ name: alias,
129
+ context
130
+ })
131
+ })]
132
+ })] }),
133
+ children: _alloy_js_core.code`
106
134
  target["${property.getNameAsString()}"] = newValue;
107
135
  return true;
108
- `}
109
- </_alloy_js_typescript.ElseIfClause>}
110
- </>;
136
+ `
137
+ }) });
111
138
  }
112
139
  const createEnvRefkey = (0, _powerlines_plugin_alloy_helpers_refkey.refkey)("createEnv");
113
140
  const envRefkey = (0, _powerlines_plugin_alloy_helpers_refkey.refkey)("env");
@@ -132,41 +159,62 @@ function EnvBuiltin(props) {
132
159
  });
133
160
  const reflectionGetProperties = (0, _alloy_js_core.computed)(() => reflection?.getProperties().filter((property) => !property.isIgnored()).sort((a, b) => a.getNameAsString().localeCompare(b.getNameAsString())) ?? []);
134
161
  const reflectionSetProperties = (0, _alloy_js_core.computed)(() => reflection?.getProperties().filter((property) => !property.isIgnored() && !property.isReadonly()).sort((a, b) => a.getNameAsString().localeCompare(b.getNameAsString())) ?? []);
135
- return <_powerlines_plugin_alloy_typescript_components_builtin_file.BuiltinFile id="env" description="The environment configuration module provides an interface to define environment configuration parameters." {...rest} imports={(0, defu.default)({ "@powerlines/deepkit/vendor/type": [
136
- "stringify",
137
- "serializer",
138
- "serializeFunction",
139
- "deserializeFunction",
140
- "ReflectionKind",
141
- "Serializer",
142
- "TemplateState",
143
- "Type",
144
- "TypeProperty",
145
- "TypePropertySignature"
146
- ] }, rest.imports ?? {})}>
147
- <_alloy_js_core.Show when={Boolean(reflection)}>
148
- <EnvTypeDefinition defaultValue={defaultValue.value} reflection={reflection} />
149
- <hbr />
150
- <hbr />
151
- </_alloy_js_core.Show>
152
-
153
- <_powerlines_plugin_alloy_typescript_components_object_declaration.ObjectDeclaration name="initialEnv" type="Partial<EnvBase>" defaultValue={defaultValue} reflection={envInstance} export={true} const={true} doc="The initial environment configuration object values for the runtime." />
154
- <_powerlines_plugin_alloy_core_components_spacing.Spacing />
155
-
156
- <_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc heading="The environment configuration serializer for the Powerlines application.">
157
- <_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocLink>
158
- {`https://deepkit.io/docs/serialization/serializers`}
159
- </_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocLink>
160
- <_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocLink>
161
- {`https://github.com/marcj/untitled-code/blob/master/packages/type/src/serializer.ts#L1918`}
162
- </_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocLink>
163
- <_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocRemarks>
164
- {`This serializer is used to serialize and deserialize the Powerlines environment configuration.`}
165
- </_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocRemarks>
166
- </_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc>
167
- <_alloy_js_typescript.ClassDeclaration refkey={envSerializerRefkey} name="EnvSerializer" extends="Serializer" export={true}>
168
- <_alloy_js_typescript.ClassMethod name="constructor" public={true} doc="Initializes a new instance of the `EnvSerializer` class.">
169
- {_alloy_js_core.code`super("env");
162
+ return /* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsxs)(_powerlines_plugin_alloy_typescript_components_builtin_file.BuiltinFile, {
163
+ id: "env",
164
+ description: "The environment configuration module provides an interface to define environment configuration parameters.",
165
+ ...rest,
166
+ imports: (0, defu.default)({ "@powerlines/deepkit/vendor/type": [
167
+ "stringify",
168
+ "serializer",
169
+ "serializeFunction",
170
+ "deserializeFunction",
171
+ "ReflectionKind",
172
+ "Serializer",
173
+ "TemplateState",
174
+ "Type",
175
+ "TypeProperty",
176
+ "TypePropertySignature"
177
+ ] }, rest.imports ?? {}),
178
+ children: [
179
+ /* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsxs)(_alloy_js_core.Show, {
180
+ when: Boolean(reflection),
181
+ children: [
182
+ /* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsx)(EnvTypeDefinition, {
183
+ defaultValue: defaultValue.value,
184
+ reflection
185
+ }),
186
+ /* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsx)("hbr", {}),
187
+ /* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsx)("hbr", {})
188
+ ]
189
+ }),
190
+ /* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsx)(_powerlines_plugin_alloy_typescript_components_object_declaration.ObjectDeclaration, {
191
+ name: "initialEnv",
192
+ type: "Partial<EnvBase>",
193
+ defaultValue,
194
+ reflection: envInstance,
195
+ export: true,
196
+ const: true,
197
+ doc: "The initial environment configuration object values for the runtime."
198
+ }),
199
+ /* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsx)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
200
+ /* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsxs)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
201
+ heading: "The environment configuration serializer for the Powerlines application.",
202
+ children: [
203
+ /* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsx)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocLink, { children: `https://deepkit.io/docs/serialization/serializers` }),
204
+ /* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsx)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocLink, { children: `https://github.com/marcj/untitled-code/blob/master/packages/type/src/serializer.ts#L1918` }),
205
+ /* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsx)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocRemarks, { children: `This serializer is used to serialize and deserialize the Powerlines environment configuration.` })
206
+ ]
207
+ }),
208
+ /* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsx)(_alloy_js_typescript.ClassDeclaration, {
209
+ refkey: envSerializerRefkey,
210
+ name: "EnvSerializer",
211
+ extends: "Serializer",
212
+ export: true,
213
+ children: /* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsx)(_alloy_js_typescript.ClassMethod, {
214
+ name: "constructor",
215
+ public: true,
216
+ doc: "Initializes a new instance of the `EnvSerializer` class.",
217
+ children: _alloy_js_core.code`super("env");
170
218
 
171
219
  this.deserializeRegistry.register(
172
220
  ReflectionKind.boolean,
@@ -175,112 +223,146 @@ function EnvBuiltin(props) {
175
223
  \`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()}\`
176
224
  );
177
225
  }
178
- ); `}
179
- </_alloy_js_typescript.ClassMethod>
180
- </_alloy_js_typescript.ClassDeclaration>
181
- <_powerlines_plugin_alloy_core_components_spacing.Spacing />
182
-
183
- <_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc heading="A {@link EnvSerializer | environment configuration serializer} instance for the Powerlines application.">
184
- <_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocLink>
185
- {`https://deepkit.io/docs/serialization/serializers`}
186
- </_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocLink>
187
- <_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocLink>
188
- {`https://github.com/marcj/untitled-code/blob/master/packages/type/src/serializer.ts#L1918`}
189
- </_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocLink>
190
- <_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocRemarks>
191
- {`This serializer is used to serialize and deserialize the Powerlines environment configuration.`}
192
- </_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocRemarks>
193
- </_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc>
194
- <_alloy_js_typescript.VarDeclaration name="envSerializer" export={false} const={true} initializer={<_alloy_js_typescript.NewExpression args={[]} target="EnvSerializer" />} />
195
- <_powerlines_plugin_alloy_core_components_spacing.Spacing />
196
-
197
- <_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc heading="Serialize a environment configuration object to JSON data objects (not a JSON string).">
198
- <_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocRemarks>
199
- {`The resulting JSON object can be stringified using \`JSON.stringify()\`.`}
200
- </_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocRemarks>
201
- <_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocExample>{`const json = serializeEnv(env);`}</_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocExample>
202
- <_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocThrows>
203
- {`ValidationError when serialization or validation fails.`}
204
- </_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocThrows>
205
- </_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc>
206
- <_alloy_js_typescript.VarDeclaration name="serializeEnv" export={true} const={true} initializer={"serializeFunction<EnvBase>(envSerializer)"} />
207
- <_powerlines_plugin_alloy_core_components_spacing.Spacing />
208
-
209
- <_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc heading="Deserialize a environment configuration object from JSON data objects to JavaScript objects, without running any validators.">
210
- <_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocRemarks>
211
- {`Types that are already correct will be used as-is.`}
212
- </_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocRemarks>
213
- <_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocExample>{`const env = deserializeEnv(json);`}</_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocExample>
214
- <_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocThrows>
215
- {`ValidationError when deserialization fails.`}
216
- </_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocThrows>
217
- </_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc>
218
- <_alloy_js_typescript.VarDeclaration name="deserializeEnv" export={true} const={true} initializer="deserializeFunction<EnvBase>(envSerializer)" />
219
- <_powerlines_plugin_alloy_core_components_spacing.Spacing />
220
-
221
- <_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc heading="Initializes the Powerlines environment configuration module.">
222
- <_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocRemarks>
223
- {`This function initializes the Powerlines environment configuration object.`}
224
- </_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocRemarks>
225
- <_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam name="environmentConfig">
226
- {`The dynamic/runtime configuration - this could include the current environment variables or any other environment-specific settings provided by the runtime.`}
227
- </_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam>
228
- <_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocReturns>
229
- {`The initialized Powerlines configuration object.`}
230
- </_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocReturns>
231
- </_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc>
232
- <_alloy_js_core.Show when={Boolean(context?.entryPath)}>
233
- <_alloy_js_typescript.FunctionDeclaration refkey={createEnvRefkey} async={false} export={true} name="createEnv" parameters={[{
234
- name: "environmentConfig",
235
- type: `Partial<Env>`,
236
- optional: false,
237
- default: "{}"
238
- }]} returnType="Env">
239
- {_alloy_js_core.code`
226
+ ); `
227
+ })
228
+ }),
229
+ /* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsx)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
230
+ /* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsxs)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
231
+ heading: "A {@link EnvSerializer | environment configuration serializer} instance for the Powerlines application.",
232
+ children: [
233
+ /* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsx)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocLink, { children: `https://deepkit.io/docs/serialization/serializers` }),
234
+ /* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsx)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocLink, { children: `https://github.com/marcj/untitled-code/blob/master/packages/type/src/serializer.ts#L1918` }),
235
+ /* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsx)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocRemarks, { children: `This serializer is used to serialize and deserialize the Powerlines environment configuration.` })
236
+ ]
237
+ }),
238
+ /* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsx)(_alloy_js_typescript.VarDeclaration, {
239
+ name: "envSerializer",
240
+ export: false,
241
+ const: true,
242
+ initializer: /* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsx)(_alloy_js_typescript.NewExpression, {
243
+ args: [],
244
+ target: "EnvSerializer"
245
+ })
246
+ }),
247
+ /* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsx)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
248
+ /* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsxs)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
249
+ heading: "Serialize a environment configuration object to JSON data objects (not a JSON string).",
250
+ children: [
251
+ /* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsx)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocRemarks, { children: `The resulting JSON object can be stringified using \`JSON.stringify()\`.` }),
252
+ /* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsx)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocExample, { children: `const json = serializeEnv(env);` }),
253
+ /* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsx)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocThrows, { children: `ValidationError when serialization or validation fails.` })
254
+ ]
255
+ }),
256
+ /* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsx)(_alloy_js_typescript.VarDeclaration, {
257
+ name: "serializeEnv",
258
+ export: true,
259
+ const: true,
260
+ initializer: "serializeFunction<EnvBase>(envSerializer)"
261
+ }),
262
+ /* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsx)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
263
+ /* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsxs)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
264
+ heading: "Deserialize a environment configuration object from JSON data objects to JavaScript objects, without running any validators.",
265
+ children: [
266
+ /* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsx)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocRemarks, { children: `Types that are already correct will be used as-is.` }),
267
+ /* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsx)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocExample, { children: `const env = deserializeEnv(json);` }),
268
+ /* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsx)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocThrows, { children: `ValidationError when deserialization fails.` })
269
+ ]
270
+ }),
271
+ /* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsx)(_alloy_js_typescript.VarDeclaration, {
272
+ name: "deserializeEnv",
273
+ export: true,
274
+ const: true,
275
+ initializer: "deserializeFunction<EnvBase>(envSerializer)"
276
+ }),
277
+ /* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsx)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
278
+ /* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsxs)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
279
+ heading: "Initializes the Powerlines environment configuration module.",
280
+ children: [
281
+ /* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsx)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocRemarks, { children: `This function initializes the Powerlines environment configuration object.` }),
282
+ /* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsx)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam, {
283
+ name: "environmentConfig",
284
+ children: `The dynamic/runtime configuration - this could include the current environment variables or any other environment-specific settings provided by the runtime.`
285
+ }),
286
+ /* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsx)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocReturns, { children: `The initialized Powerlines configuration object.` })
287
+ ]
288
+ }),
289
+ /* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsx)(_alloy_js_core.Show, {
290
+ when: Boolean(context?.entryPath),
291
+ children: /* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsxs)(_alloy_js_typescript.FunctionDeclaration, {
292
+ refkey: createEnvRefkey,
293
+ async: false,
294
+ export: true,
295
+ name: "createEnv",
296
+ parameters: [{
297
+ name: "environmentConfig",
298
+ type: `Partial<Env>`,
299
+ optional: false,
300
+ default: "{}"
301
+ }],
302
+ returnType: "Env",
303
+ children: [
304
+ _alloy_js_core.code`
240
305
  return new Proxy<Env>(
241
306
  deserializeEnv({
242
307
  ...initialEnv,
243
308
  ...environmentConfig
244
309
  }) as Env,
245
310
  {
246
- get: (target: EnvBase, propertyName: string) => { `}
247
- <hbr />
248
-
249
- <_alloy_js_core.For each={reflectionGetProperties}>
250
- {(property, index) => <ConfigPropertyGet index={index} context={context} property={property} />}
251
- </_alloy_js_core.For>
252
- {_alloy_js_core.code`
311
+ get: (target: EnvBase, propertyName: string) => { `,
312
+ /* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsx)("hbr", {}),
313
+ /* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsx)(_alloy_js_core.For, {
314
+ each: reflectionGetProperties,
315
+ children: (property, index) => /* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsx)(ConfigPropertyGet, {
316
+ index,
317
+ context,
318
+ property
319
+ })
320
+ }),
321
+ _alloy_js_core.code`
253
322
  return undefined;
254
- }, `}
255
-
256
- <_powerlines_plugin_alloy_core_components_spacing.Spacing />
257
- {_alloy_js_core.code` set: (target: EnvBase, propertyName: string, newValue: any) => { `}
258
- <hbr />
259
-
260
- <_alloy_js_core.For each={reflectionSetProperties} ender={_alloy_js_core.code` else `}>
261
- {(property, index) => <ConfigPropertySet index={index} context={context} property={property} />}
262
- </_alloy_js_core.For>
263
-
264
- <hbr />
265
- {_alloy_js_core.code`return false;
323
+ }, `,
324
+ /* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsx)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
325
+ _alloy_js_core.code` set: (target: EnvBase, propertyName: string, newValue: any) => { `,
326
+ /* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsx)("hbr", {}),
327
+ /* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsx)(_alloy_js_core.For, {
328
+ each: reflectionSetProperties,
329
+ ender: _alloy_js_core.code` else `,
330
+ children: (property, index) => /* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsx)(ConfigPropertySet, {
331
+ index,
332
+ context,
333
+ property
334
+ })
335
+ }),
336
+ /* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsx)("hbr", {}),
337
+ _alloy_js_core.code`return false;
266
338
  }
267
339
  }
268
340
  );
269
- `}
270
- </_alloy_js_typescript.FunctionDeclaration>
271
- </_alloy_js_core.Show>
272
- <_powerlines_plugin_alloy_core_components_spacing.Spacing />
273
- <hbr />
274
-
275
- <_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc heading="The environment configuration object.">
276
- <_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocRemarks>
277
- {`This object provides access to the environment configuration parameters in the application runtime.`}
278
- </_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocRemarks>
279
- </_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc>
280
- <_alloy_js_typescript.VarDeclaration refkey={envRefkey} name="env" type="Env" export={true} const={true} initializer={<>{_alloy_js_core.code`createEnv(${defaultConfig || "{}"} as Partial<Env>);`}</>} />
281
- <_powerlines_plugin_alloy_core_components_spacing.Spacing />
282
-
283
- <_alloy_js_typescript.VarDeclaration export const name="isCI" doc="Detect if the application is running in a continuous integration (CI) environment." initializer={_alloy_js_core.code`Boolean(
341
+ `
342
+ ]
343
+ })
344
+ }),
345
+ /* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsx)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
346
+ /* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsx)("hbr", {}),
347
+ /* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsx)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
348
+ heading: "The environment configuration object.",
349
+ children: /* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsx)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocRemarks, { children: `This object provides access to the environment configuration parameters in the application runtime.` })
350
+ }),
351
+ /* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsx)(_alloy_js_typescript.VarDeclaration, {
352
+ refkey: envRefkey,
353
+ name: "env",
354
+ type: "Env",
355
+ export: true,
356
+ const: true,
357
+ initializer: /* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsx)(_alloy_js_core_jsx_runtime.Fragment, { children: _alloy_js_core.code`createEnv(${defaultConfig || "{}"} as Partial<Env>);` })
358
+ }),
359
+ /* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsx)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
360
+ /* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsx)(_alloy_js_typescript.VarDeclaration, {
361
+ export: true,
362
+ const: true,
363
+ name: "isCI",
364
+ doc: "Detect if the application is running in a continuous integration (CI) environment.",
365
+ initializer: _alloy_js_core.code`Boolean(
284
366
  env.CI ||
285
367
  env.RUN_ID ||
286
368
  env.AGOLA_GIT_REF ||
@@ -333,34 +415,62 @@ function EnvBuiltin(props) {
333
415
  env.CI_XCODE_PROJECT ||
334
416
  env.XCS || false
335
417
  );
336
- `} />
337
- <_powerlines_plugin_alloy_core_components_spacing.Spacing />
338
-
339
- <_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc heading="Detect the \`mode\` of the current runtime environment.">
340
- <_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocRemarks>
341
- {_alloy_js_core.code`The \`mode\` is determined by the \`MODE\` environment variable, or falls back to the \`NEXT_PUBLIC_VERCEL_ENV\`, \`NODE_ENV\`, or defaults to \`production\`. While the value can potentially be any string, it is generally recommended to only allow a value in the following list:
418
+ `
419
+ }),
420
+ /* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsx)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
421
+ /* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsx)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
422
+ heading: "Detect the \\`mode\\` of the current runtime environment.",
423
+ children: /* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsx)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocRemarks, { children: _alloy_js_core.code`The \`mode\` is determined by the \`MODE\` environment variable, or falls back to the \`NEXT_PUBLIC_VERCEL_ENV\`, \`NODE_ENV\`, or defaults to \`production\`. While the value can potentially be any string, it is generally recommended to only allow a value in the following list:
342
424
  - \`production\`
343
425
  - \`test\`
344
426
  - \`development\`
345
- `}
346
- </_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocRemarks>
347
- </_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc>
348
- <_alloy_js_typescript.VarDeclaration export const name="mode" initializer={_alloy_js_core.code`String(env.MODE) || "production"; `} />
349
- <_powerlines_plugin_alloy_core_components_spacing.Spacing />
350
-
351
- <_alloy_js_typescript.VarDeclaration export const name="isProduction" doc='Detect if the application is running in `"production"` mode' initializer={_alloy_js_core.code`["prd", "prod", "production"].includes(mode.toLowerCase()); `} />
352
- <_powerlines_plugin_alloy_core_components_spacing.Spacing />
353
-
354
- <_alloy_js_typescript.VarDeclaration export const name="isTest" doc='Detect if the application is running in `"test"` mode' initializer={_alloy_js_core.code`["tst", "test", "testing", "stg", "stage", "staging"].includes(mode.toLowerCase()) || env.TEST; `} />
355
- <_powerlines_plugin_alloy_core_components_spacing.Spacing />
356
-
357
- <_alloy_js_typescript.VarDeclaration export const name="isDevelopment" doc='Detect if the application is running in `"development"` mode' initializer={_alloy_js_core.code`["dev", "development"].includes(mode.toLowerCase()); `} />
358
- <_powerlines_plugin_alloy_core_components_spacing.Spacing />
359
-
360
- <_alloy_js_typescript.VarDeclaration export const name="isDebug" doc="Detect if the application is currently being debugged" initializer={_alloy_js_core.code`Boolean(isDevelopment && env.DEBUG); `} />
361
- <_powerlines_plugin_alloy_core_components_spacing.Spacing />
362
- <_alloy_js_core.Show when={Boolean(children)}>{children}</_alloy_js_core.Show>
363
- </_powerlines_plugin_alloy_typescript_components_builtin_file.BuiltinFile>;
427
+ ` })
428
+ }),
429
+ /* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsx)(_alloy_js_typescript.VarDeclaration, {
430
+ export: true,
431
+ const: true,
432
+ name: "mode",
433
+ initializer: _alloy_js_core.code`String(env.MODE) || "production"; `
434
+ }),
435
+ /* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsx)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
436
+ /* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsx)(_alloy_js_typescript.VarDeclaration, {
437
+ export: true,
438
+ const: true,
439
+ name: "isProduction",
440
+ doc: "Detect if the application is running in `\"production\"` mode",
441
+ initializer: _alloy_js_core.code`["prd", "prod", "production"].includes(mode.toLowerCase()); `
442
+ }),
443
+ /* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsx)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
444
+ /* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsx)(_alloy_js_typescript.VarDeclaration, {
445
+ export: true,
446
+ const: true,
447
+ name: "isTest",
448
+ doc: "Detect if the application is running in `\"test\"` mode",
449
+ initializer: _alloy_js_core.code`["tst", "test", "testing", "stg", "stage", "staging"].includes(mode.toLowerCase()) || env.TEST; `
450
+ }),
451
+ /* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsx)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
452
+ /* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsx)(_alloy_js_typescript.VarDeclaration, {
453
+ export: true,
454
+ const: true,
455
+ name: "isDevelopment",
456
+ doc: "Detect if the application is running in `\"development\"` mode",
457
+ initializer: _alloy_js_core.code`["dev", "development"].includes(mode.toLowerCase()); `
458
+ }),
459
+ /* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsx)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
460
+ /* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsx)(_alloy_js_typescript.VarDeclaration, {
461
+ export: true,
462
+ const: true,
463
+ name: "isDebug",
464
+ doc: "Detect if the application is currently being debugged",
465
+ initializer: _alloy_js_core.code`Boolean(isDevelopment && env.DEBUG); `
466
+ }),
467
+ /* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsx)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
468
+ /* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsx)(_alloy_js_core.Show, {
469
+ when: Boolean(children),
470
+ children
471
+ })
472
+ ]
473
+ });
364
474
  }
365
475
 
366
476
  //#endregion