@powerlines/plugin-env 0.16.68 → 0.16.70
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/README.md +1 -1
- package/dist/components/docs.cjs +37 -27
- package/dist/components/docs.mjs +37 -27
- package/dist/components/docs.mjs.map +1 -1
- package/dist/components/env-builtin.cjs +404 -314
- package/dist/components/env-builtin.mjs +404 -314
- package/dist/components/env-builtin.mjs.map +1 -1
- package/dist/index.cjs +6 -3
- package/dist/index.mjs +7 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +18 -18
|
@@ -5,10 +5,10 @@ let _powerlines_deepkit_vendor_type = require("@powerlines/deepkit/vendor/type")
|
|
|
5
5
|
let _stryke_string_format_title_case = require("@stryke/string-format/title-case");
|
|
6
6
|
let defu = require("defu");
|
|
7
7
|
defu = require_runtime.__toESM(defu);
|
|
8
|
+
let _alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
|
|
8
9
|
let _alloy_js_core = require("@alloy-js/core");
|
|
9
10
|
let _powerlines_plugin_alloy_core_components_spacing = require("@powerlines/plugin-alloy/core/components/spacing");
|
|
10
11
|
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");
|
|
12
12
|
let _alloy_js_typescript = require("@alloy-js/typescript");
|
|
13
13
|
let _powerlines_plugin_alloy_helpers_refkey = require("@powerlines/plugin-alloy/helpers/refkey");
|
|
14
14
|
let _powerlines_plugin_alloy_typescript_components_builtin_file = require("@powerlines/plugin-alloy/typescript/components/builtin-file");
|
|
@@ -23,28 +23,32 @@ let _powerlines_plugin_alloy_typescript_components_tsdoc = require("@powerlines/
|
|
|
23
23
|
function EnvTypeDefinition(props) {
|
|
24
24
|
const [{ defaultValue, reflection }] = (0, _alloy_js_core.splitProps)(props, ["defaultValue", "reflection"]);
|
|
25
25
|
const context = (0, _powerlines_plugin_alloy_core_contexts_context.usePowerlines)();
|
|
26
|
-
return
|
|
27
|
-
|
|
26
|
+
return [
|
|
27
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceDeclaration, {
|
|
28
28
|
name: " EnvBase",
|
|
29
29
|
defaultValue,
|
|
30
30
|
reflection,
|
|
31
|
-
export: true
|
|
31
|
+
"export": true
|
|
32
32
|
}),
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
34
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
|
|
35
35
|
heading: "The environment configuration object with prefixed keys.",
|
|
36
|
-
children
|
|
36
|
+
get children() {
|
|
37
|
+
return (0, _alloy_js_core_jsx_runtime.createComponent)(_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.` });
|
|
38
|
+
}
|
|
37
39
|
}),
|
|
38
|
-
|
|
40
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.TypeDeclaration, {
|
|
39
41
|
name: "Env",
|
|
40
|
-
export: true,
|
|
41
|
-
children
|
|
42
|
+
"export": true,
|
|
43
|
+
get children() {
|
|
44
|
+
return _alloy_js_core.code` {
|
|
42
45
|
[Key in keyof EnvBase as Key ${context.config.env.prefix.map((prefix) => `| \`${prefix.replace(/_$/g, "")}_\${Key}\``).join(" ")}]: EnvBase[Key];
|
|
43
46
|
}
|
|
44
|
-
|
|
47
|
+
`;
|
|
48
|
+
}
|
|
45
49
|
}),
|
|
46
|
-
|
|
47
|
-
]
|
|
50
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {})
|
|
51
|
+
];
|
|
48
52
|
}
|
|
49
53
|
function ConfigPropertyConditional(props) {
|
|
50
54
|
const [{ context, name }] = (0, _alloy_js_core.splitProps)(props, ["context", "name"]);
|
|
@@ -56,39 +60,63 @@ function ConfigPropertyGet(props) {
|
|
|
56
60
|
"property",
|
|
57
61
|
"index"
|
|
58
62
|
]);
|
|
59
|
-
return
|
|
60
|
-
condition
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
63
|
+
return [index === 0 ? (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.IfStatement, {
|
|
64
|
+
get condition() {
|
|
65
|
+
return [(0, _alloy_js_core_jsx_runtime.createComponent)(ConfigPropertyConditional, {
|
|
66
|
+
get name() {
|
|
67
|
+
return property.getNameAsString();
|
|
68
|
+
},
|
|
69
|
+
context
|
|
70
|
+
}), (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Show, {
|
|
71
|
+
get when() {
|
|
72
|
+
return (0, _alloy_js_core_jsx_runtime.memo)(() => !!property.getAlias())() && property.getAlias().length > 0;
|
|
73
|
+
},
|
|
74
|
+
get children() {
|
|
75
|
+
return [_alloy_js_core.code` || `, (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.For, {
|
|
76
|
+
get each() {
|
|
77
|
+
return property.getAlias();
|
|
78
|
+
},
|
|
79
|
+
joiner: _alloy_js_core.code` || `,
|
|
80
|
+
children: (alias) => (0, _alloy_js_core_jsx_runtime.createComponent)(ConfigPropertyConditional, {
|
|
81
|
+
name: alias,
|
|
82
|
+
context
|
|
83
|
+
})
|
|
84
|
+
})];
|
|
85
|
+
}
|
|
86
|
+
})];
|
|
87
|
+
},
|
|
88
|
+
get children() {
|
|
89
|
+
return _alloy_js_core.code`return target["${property.getNameAsString()}"];`;
|
|
90
|
+
}
|
|
91
|
+
}) : (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.ElseIfClause, {
|
|
92
|
+
get condition() {
|
|
93
|
+
return [(0, _alloy_js_core_jsx_runtime.createComponent)(ConfigPropertyConditional, {
|
|
94
|
+
get name() {
|
|
95
|
+
return property.getNameAsString();
|
|
96
|
+
},
|
|
97
|
+
context
|
|
98
|
+
}), (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Show, {
|
|
99
|
+
get when() {
|
|
100
|
+
return (0, _alloy_js_core_jsx_runtime.memo)(() => !!property.getAlias())() && property.getAlias().length > 0;
|
|
101
|
+
},
|
|
102
|
+
get children() {
|
|
103
|
+
return [_alloy_js_core.code` || `, (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.For, {
|
|
104
|
+
get each() {
|
|
105
|
+
return property.getAlias();
|
|
106
|
+
},
|
|
107
|
+
joiner: _alloy_js_core.code` || `,
|
|
108
|
+
children: (alias) => (0, _alloy_js_core_jsx_runtime.createComponent)(ConfigPropertyConditional, {
|
|
109
|
+
name: alias,
|
|
110
|
+
context
|
|
111
|
+
})
|
|
112
|
+
})];
|
|
113
|
+
}
|
|
114
|
+
})];
|
|
115
|
+
},
|
|
116
|
+
get children() {
|
|
117
|
+
return _alloy_js_core.code`return target["${property.getNameAsString()}"];`;
|
|
118
|
+
}
|
|
119
|
+
})];
|
|
92
120
|
}
|
|
93
121
|
function ConfigPropertySet(props) {
|
|
94
122
|
const [{ context, property, index }] = (0, _alloy_js_core.splitProps)(props, [
|
|
@@ -96,45 +124,69 @@ function ConfigPropertySet(props) {
|
|
|
96
124
|
"property",
|
|
97
125
|
"index"
|
|
98
126
|
]);
|
|
99
|
-
return
|
|
100
|
-
condition
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
127
|
+
return [index === 0 ? (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.IfStatement, {
|
|
128
|
+
get condition() {
|
|
129
|
+
return [(0, _alloy_js_core_jsx_runtime.createComponent)(ConfigPropertyConditional, {
|
|
130
|
+
get name() {
|
|
131
|
+
return property.getNameAsString();
|
|
132
|
+
},
|
|
133
|
+
context
|
|
134
|
+
}), (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Show, {
|
|
135
|
+
get when() {
|
|
136
|
+
return (0, _alloy_js_core_jsx_runtime.memo)(() => !!property.getAlias())() && property.getAlias().length > 0;
|
|
137
|
+
},
|
|
138
|
+
get children() {
|
|
139
|
+
return [_alloy_js_core.code` || `, (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.For, {
|
|
140
|
+
get each() {
|
|
141
|
+
return property.getAlias();
|
|
142
|
+
},
|
|
143
|
+
joiner: _alloy_js_core.code` || `,
|
|
144
|
+
children: (alias) => (0, _alloy_js_core_jsx_runtime.createComponent)(ConfigPropertyConditional, {
|
|
145
|
+
name: alias,
|
|
146
|
+
context
|
|
147
|
+
})
|
|
148
|
+
})];
|
|
149
|
+
}
|
|
150
|
+
})];
|
|
151
|
+
},
|
|
152
|
+
get children() {
|
|
153
|
+
return _alloy_js_core.code`
|
|
115
154
|
target["${property.getNameAsString()}"] = newValue;
|
|
116
155
|
return true;
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
156
|
+
`;
|
|
157
|
+
}
|
|
158
|
+
}) : (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.ElseIfClause, {
|
|
159
|
+
get condition() {
|
|
160
|
+
return [(0, _alloy_js_core_jsx_runtime.createComponent)(ConfigPropertyConditional, {
|
|
161
|
+
get name() {
|
|
162
|
+
return property.getNameAsString();
|
|
163
|
+
},
|
|
164
|
+
context
|
|
165
|
+
}), (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Show, {
|
|
166
|
+
get when() {
|
|
167
|
+
return (0, _alloy_js_core_jsx_runtime.memo)(() => !!property.getAlias())() && property.getAlias().length > 0;
|
|
168
|
+
},
|
|
169
|
+
get children() {
|
|
170
|
+
return [_alloy_js_core.code` || `, (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.For, {
|
|
171
|
+
get each() {
|
|
172
|
+
return property.getAlias();
|
|
173
|
+
},
|
|
174
|
+
joiner: _alloy_js_core.code` || `,
|
|
175
|
+
children: (alias) => (0, _alloy_js_core_jsx_runtime.createComponent)(ConfigPropertyConditional, {
|
|
176
|
+
name: alias,
|
|
177
|
+
context
|
|
178
|
+
})
|
|
179
|
+
})];
|
|
180
|
+
}
|
|
181
|
+
})];
|
|
182
|
+
},
|
|
183
|
+
get children() {
|
|
184
|
+
return _alloy_js_core.code`
|
|
134
185
|
target["${property.getNameAsString()}"] = newValue;
|
|
135
186
|
return true;
|
|
136
|
-
|
|
137
|
-
|
|
187
|
+
`;
|
|
188
|
+
}
|
|
189
|
+
})];
|
|
138
190
|
}
|
|
139
191
|
const createEnvRefkey = (0, _powerlines_plugin_alloy_helpers_refkey.refkey)("createEnv");
|
|
140
192
|
const envRefkey = (0, _powerlines_plugin_alloy_helpers_refkey.refkey)("env");
|
|
@@ -159,62 +211,74 @@ function EnvBuiltin(props) {
|
|
|
159
211
|
});
|
|
160
212
|
const reflectionGetProperties = (0, _alloy_js_core.computed)(() => reflection?.getProperties().filter((property) => !property.isIgnored()).sort((a, b) => a.getNameAsString().localeCompare(b.getNameAsString())) ?? []);
|
|
161
213
|
const reflectionSetProperties = (0, _alloy_js_core.computed)(() => reflection?.getProperties().filter((property) => !property.isIgnored() && !property.isReadonly()).sort((a, b) => a.getNameAsString().localeCompare(b.getNameAsString())) ?? []);
|
|
162
|
-
return
|
|
214
|
+
return (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_builtin_file.BuiltinFile, (0, _alloy_js_core_jsx_runtime.mergeProps)({
|
|
163
215
|
id: "env",
|
|
164
|
-
description: "The environment configuration module provides an interface to define environment configuration parameters."
|
|
165
|
-
|
|
166
|
-
imports
|
|
167
|
-
"
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
reflection
|
|
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
|
-
|
|
216
|
+
description: "The environment configuration module provides an interface to define environment configuration parameters."
|
|
217
|
+
}, rest, {
|
|
218
|
+
get imports() {
|
|
219
|
+
return (0, defu.default)({ "@powerlines/deepkit/vendor/type": [
|
|
220
|
+
"stringify",
|
|
221
|
+
"serializer",
|
|
222
|
+
"serializeFunction",
|
|
223
|
+
"deserializeFunction",
|
|
224
|
+
"ReflectionKind",
|
|
225
|
+
"Serializer",
|
|
226
|
+
"TemplateState",
|
|
227
|
+
"Type",
|
|
228
|
+
"TypeProperty",
|
|
229
|
+
"TypePropertySignature"
|
|
230
|
+
] }, rest.imports ?? {});
|
|
231
|
+
},
|
|
232
|
+
get children() {
|
|
233
|
+
return [
|
|
234
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Show, {
|
|
235
|
+
get when() {
|
|
236
|
+
return Boolean(reflection);
|
|
237
|
+
},
|
|
238
|
+
get children() {
|
|
239
|
+
return [
|
|
240
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(EnvTypeDefinition, {
|
|
241
|
+
get defaultValue() {
|
|
242
|
+
return defaultValue.value;
|
|
243
|
+
},
|
|
244
|
+
reflection
|
|
245
|
+
}),
|
|
246
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
247
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {})
|
|
248
|
+
];
|
|
249
|
+
}
|
|
250
|
+
}),
|
|
251
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_object_declaration.ObjectDeclaration, {
|
|
252
|
+
name: "initialEnv",
|
|
253
|
+
type: "Partial<EnvBase>",
|
|
254
|
+
defaultValue,
|
|
255
|
+
reflection: envInstance,
|
|
256
|
+
"export": true,
|
|
257
|
+
"const": true,
|
|
258
|
+
doc: "The initial environment configuration object values for the runtime."
|
|
259
|
+
}),
|
|
260
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
261
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
|
|
262
|
+
heading: "The environment configuration serializer for the Powerlines application.",
|
|
263
|
+
get children() {
|
|
264
|
+
return [
|
|
265
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocLink, { children: `https://deepkit.io/docs/serialization/serializers` }),
|
|
266
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocLink, { children: `https://github.com/marcj/untitled-code/blob/master/packages/type/src/serializer.ts#L1918` }),
|
|
267
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocRemarks, { children: `This serializer is used to serialize and deserialize the Powerlines environment configuration.` })
|
|
268
|
+
];
|
|
269
|
+
}
|
|
270
|
+
}),
|
|
271
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.ClassDeclaration, {
|
|
272
|
+
refkey: envSerializerRefkey,
|
|
273
|
+
name: "EnvSerializer",
|
|
274
|
+
"extends": "Serializer",
|
|
275
|
+
"export": true,
|
|
276
|
+
get children() {
|
|
277
|
+
return (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.ClassMethod, {
|
|
278
|
+
name: "constructor",
|
|
279
|
+
"public": true,
|
|
280
|
+
doc: "Initializes a new instance of the `EnvSerializer` class.",
|
|
281
|
+
children: _alloy_js_core.code`super("env");
|
|
218
282
|
|
|
219
283
|
this.deserializeRegistry.register(
|
|
220
284
|
ReflectionKind.boolean,
|
|
@@ -224,84 +288,99 @@ function EnvBuiltin(props) {
|
|
|
224
288
|
);
|
|
225
289
|
}
|
|
226
290
|
); `
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
291
|
+
});
|
|
292
|
+
}
|
|
293
|
+
}),
|
|
294
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
295
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
|
|
296
|
+
heading: "A {@link EnvSerializer | environment configuration serializer} instance for the Powerlines application.",
|
|
297
|
+
get children() {
|
|
298
|
+
return [
|
|
299
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocLink, { children: `https://deepkit.io/docs/serialization/serializers` }),
|
|
300
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocLink, { children: `https://github.com/marcj/untitled-code/blob/master/packages/type/src/serializer.ts#L1918` }),
|
|
301
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocRemarks, { children: `This serializer is used to serialize and deserialize the Powerlines environment configuration.` })
|
|
302
|
+
];
|
|
303
|
+
}
|
|
304
|
+
}),
|
|
305
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.VarDeclaration, {
|
|
306
|
+
name: "envSerializer",
|
|
307
|
+
"export": false,
|
|
308
|
+
"const": true,
|
|
309
|
+
get initializer() {
|
|
310
|
+
return (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.NewExpression, {
|
|
311
|
+
args: [],
|
|
312
|
+
target: "EnvSerializer"
|
|
313
|
+
});
|
|
314
|
+
}
|
|
315
|
+
}),
|
|
316
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
317
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
|
|
318
|
+
heading: "Serialize a environment configuration object to JSON data objects (not a JSON string).",
|
|
319
|
+
get children() {
|
|
320
|
+
return [
|
|
321
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocRemarks, { children: `The resulting JSON object can be stringified using \`JSON.stringify()\`.` }),
|
|
322
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocExample, { children: `const json = serializeEnv(env);` }),
|
|
323
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocThrows, { children: `ValidationError when serialization or validation fails.` })
|
|
324
|
+
];
|
|
325
|
+
}
|
|
326
|
+
}),
|
|
327
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.VarDeclaration, {
|
|
328
|
+
name: "serializeEnv",
|
|
329
|
+
"export": true,
|
|
330
|
+
"const": true,
|
|
331
|
+
initializer: "serializeFunction<EnvBase>(envSerializer)"
|
|
332
|
+
}),
|
|
333
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
334
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
|
|
335
|
+
heading: "Deserialize a environment configuration object from JSON data objects to JavaScript objects, without running any validators.",
|
|
336
|
+
get children() {
|
|
337
|
+
return [
|
|
338
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocRemarks, { children: `Types that are already correct will be used as-is.` }),
|
|
339
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocExample, { children: `const env = deserializeEnv(json);` }),
|
|
340
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocThrows, { children: `ValidationError when deserialization fails.` })
|
|
341
|
+
];
|
|
342
|
+
}
|
|
343
|
+
}),
|
|
344
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.VarDeclaration, {
|
|
345
|
+
name: "deserializeEnv",
|
|
346
|
+
"export": true,
|
|
347
|
+
"const": true,
|
|
348
|
+
initializer: "deserializeFunction<EnvBase>(envSerializer)"
|
|
349
|
+
}),
|
|
350
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
351
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
|
|
352
|
+
heading: "Initializes the Powerlines environment configuration module.",
|
|
353
|
+
get children() {
|
|
354
|
+
return [
|
|
355
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocRemarks, { children: `This function initializes the Powerlines environment configuration object.` }),
|
|
356
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam, {
|
|
357
|
+
name: "environmentConfig",
|
|
358
|
+
children: `The dynamic/runtime configuration - this could include the current environment variables or any other environment-specific settings provided by the runtime.`
|
|
359
|
+
}),
|
|
360
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocReturns, { children: `The initialized Powerlines configuration object.` })
|
|
361
|
+
];
|
|
362
|
+
}
|
|
363
|
+
}),
|
|
364
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Show, {
|
|
365
|
+
get when() {
|
|
366
|
+
return Boolean(context?.entryPath);
|
|
367
|
+
},
|
|
368
|
+
get children() {
|
|
369
|
+
return (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
|
|
370
|
+
refkey: createEnvRefkey,
|
|
371
|
+
async: false,
|
|
372
|
+
"export": true,
|
|
373
|
+
name: "createEnv",
|
|
374
|
+
parameters: [{
|
|
375
|
+
name: "environmentConfig",
|
|
376
|
+
type: `Partial<Env>`,
|
|
377
|
+
optional: false,
|
|
378
|
+
default: "{}"
|
|
379
|
+
}],
|
|
380
|
+
returnType: "Env",
|
|
381
|
+
get children() {
|
|
382
|
+
return [
|
|
383
|
+
_alloy_js_core.code`
|
|
305
384
|
return new Proxy<Env>(
|
|
306
385
|
deserializeEnv({
|
|
307
386
|
...initialEnv,
|
|
@@ -309,60 +388,66 @@ function EnvBuiltin(props) {
|
|
|
309
388
|
}) as Env,
|
|
310
389
|
{
|
|
311
390
|
get: (target: EnvBase, propertyName: string) => { `,
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
391
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
392
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.For, {
|
|
393
|
+
each: reflectionGetProperties,
|
|
394
|
+
children: (property, index) => (0, _alloy_js_core_jsx_runtime.createComponent)(ConfigPropertyGet, {
|
|
395
|
+
index,
|
|
396
|
+
context,
|
|
397
|
+
property
|
|
398
|
+
})
|
|
399
|
+
}),
|
|
400
|
+
_alloy_js_core.code`
|
|
322
401
|
return undefined;
|
|
323
402
|
}, `,
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
403
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
404
|
+
_alloy_js_core.code` set: (target: EnvBase, propertyName: string, newValue: any) => { `,
|
|
405
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
406
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.For, {
|
|
407
|
+
each: reflectionSetProperties,
|
|
408
|
+
ender: _alloy_js_core.code` else `,
|
|
409
|
+
children: (property, index) => (0, _alloy_js_core_jsx_runtime.createComponent)(ConfigPropertySet, {
|
|
410
|
+
index,
|
|
411
|
+
context,
|
|
412
|
+
property
|
|
413
|
+
})
|
|
414
|
+
}),
|
|
415
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
416
|
+
_alloy_js_core.code`return false;
|
|
338
417
|
}
|
|
339
418
|
}
|
|
340
419
|
);
|
|
341
420
|
`
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
421
|
+
];
|
|
422
|
+
}
|
|
423
|
+
});
|
|
424
|
+
}
|
|
425
|
+
}),
|
|
426
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
427
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
428
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
|
|
429
|
+
heading: "The environment configuration object.",
|
|
430
|
+
get children() {
|
|
431
|
+
return (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocRemarks, { children: `This object provides access to the environment configuration parameters in the application runtime.` });
|
|
432
|
+
}
|
|
433
|
+
}),
|
|
434
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.VarDeclaration, {
|
|
435
|
+
refkey: envRefkey,
|
|
436
|
+
name: "env",
|
|
437
|
+
type: "Env",
|
|
438
|
+
"export": true,
|
|
439
|
+
"const": true,
|
|
440
|
+
get initializer() {
|
|
441
|
+
return [_alloy_js_core.code`createEnv(${defaultConfig || "{}"} as Partial<Env>);`];
|
|
442
|
+
}
|
|
443
|
+
}),
|
|
444
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
445
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.VarDeclaration, {
|
|
446
|
+
"export": true,
|
|
447
|
+
"const": true,
|
|
448
|
+
name: "isCI",
|
|
449
|
+
doc: "Detect if the application is running in a continuous integration (CI) environment.",
|
|
450
|
+
initializer: _alloy_js_core.code`Boolean(
|
|
366
451
|
env.CI ||
|
|
367
452
|
env.RUN_ID ||
|
|
368
453
|
env.AGOLA_GIT_REF ||
|
|
@@ -416,61 +501,66 @@ function EnvBuiltin(props) {
|
|
|
416
501
|
env.XCS || false
|
|
417
502
|
);
|
|
418
503
|
`
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
504
|
+
}),
|
|
505
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
506
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
|
|
507
|
+
heading: "Detect the \\`mode\\` of the current runtime environment.",
|
|
508
|
+
get children() {
|
|
509
|
+
return (0, _alloy_js_core_jsx_runtime.createComponent)(_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:
|
|
424
510
|
- \`production\`
|
|
425
511
|
- \`test\`
|
|
426
512
|
- \`development\`
|
|
427
|
-
` })
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
513
|
+
` });
|
|
514
|
+
}
|
|
515
|
+
}),
|
|
516
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.VarDeclaration, {
|
|
517
|
+
"export": true,
|
|
518
|
+
"const": true,
|
|
519
|
+
name: "mode",
|
|
520
|
+
initializer: _alloy_js_core.code`String(env.MODE) || "production"; `
|
|
521
|
+
}),
|
|
522
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
523
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.VarDeclaration, {
|
|
524
|
+
"export": true,
|
|
525
|
+
"const": true,
|
|
526
|
+
name: "isProduction",
|
|
527
|
+
doc: "Detect if the application is running in `\"production\"` mode",
|
|
528
|
+
initializer: _alloy_js_core.code`["prd", "prod", "production"].includes(mode.toLowerCase()); `
|
|
529
|
+
}),
|
|
530
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
531
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.VarDeclaration, {
|
|
532
|
+
"export": true,
|
|
533
|
+
"const": true,
|
|
534
|
+
name: "isTest",
|
|
535
|
+
doc: "Detect if the application is running in `\"test\"` mode",
|
|
536
|
+
initializer: _alloy_js_core.code`["tst", "test", "testing", "stg", "stage", "staging"].includes(mode.toLowerCase()) || env.TEST; `
|
|
537
|
+
}),
|
|
538
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
539
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.VarDeclaration, {
|
|
540
|
+
"export": true,
|
|
541
|
+
"const": true,
|
|
542
|
+
name: "isDevelopment",
|
|
543
|
+
doc: "Detect if the application is running in `\"development\"` mode",
|
|
544
|
+
initializer: _alloy_js_core.code`["dev", "development"].includes(mode.toLowerCase()); `
|
|
545
|
+
}),
|
|
546
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
547
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.VarDeclaration, {
|
|
548
|
+
"export": true,
|
|
549
|
+
"const": true,
|
|
550
|
+
name: "isDebug",
|
|
551
|
+
doc: "Detect if the application is currently being debugged",
|
|
552
|
+
initializer: _alloy_js_core.code`Boolean(isDevelopment && env.DEBUG); `
|
|
553
|
+
}),
|
|
554
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
555
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Show, {
|
|
556
|
+
get when() {
|
|
557
|
+
return Boolean(children);
|
|
558
|
+
},
|
|
559
|
+
children
|
|
560
|
+
})
|
|
561
|
+
];
|
|
562
|
+
}
|
|
563
|
+
}));
|
|
474
564
|
}
|
|
475
565
|
|
|
476
566
|
//#endregion
|