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