@powerlines/plugin-env 0.16.63 → 0.16.65
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.
- package/dist/components/docs.cjs +37 -22
- package/dist/components/docs.mjs +37 -22
- package/dist/components/docs.mjs.map +1 -1
- package/dist/components/env-builtin.cjs +328 -218
- package/dist/components/env-builtin.mjs +328 -218
- package/dist/components/env-builtin.mjs.map +1 -1
- package/dist/index.cjs +9 -2
- package/dist/index.mjs +9 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +9 -9
|
@@ -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
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
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
|
-
|
|
39
|
-
|
|
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
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
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
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
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
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
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
|
-
|
|
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
|
|
136
|
-
"
|
|
137
|
-
"
|
|
138
|
-
|
|
139
|
-
"
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
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
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
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
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
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
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
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
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
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
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
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
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
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
|