@powerlines/plugin-env 0.16.125 → 0.16.126
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/babel/plugin.cjs +2 -3
- package/dist/babel/plugin.d.cts +1 -1
- package/dist/babel/plugin.d.cts.map +1 -1
- package/dist/babel/plugin.d.mts +1 -1
- package/dist/babel/plugin.d.mts.map +1 -1
- package/dist/babel/plugin.mjs +2 -3
- package/dist/babel/plugin.mjs.map +1 -1
- package/dist/components/docs.cjs +39 -49
- package/dist/components/docs.mjs +40 -50
- package/dist/components/docs.mjs.map +1 -1
- package/dist/components/env-builtin.cjs +397 -513
- package/dist/components/env-builtin.mjs +398 -514
- package/dist/components/env-builtin.mjs.map +1 -1
- package/dist/helpers/load.cjs +1 -1
- package/dist/helpers/load.d.cts +5 -5
- package/dist/helpers/load.d.mts +5 -5
- package/dist/helpers/load.mjs +1 -1
- package/dist/helpers/load.mjs.map +1 -1
- package/dist/helpers/reflect.cjs +2 -2
- package/dist/helpers/reflect.mjs +2 -2
- package/dist/helpers/reflect.mjs.map +1 -1
- package/dist/index.cjs +3 -6
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +4 -7
- package/dist/index.mjs.map +1 -1
- package/package.json +11 -11
|
@@ -3,7 +3,7 @@ import { loadEnvFromContext } from "../helpers/load.mjs";
|
|
|
3
3
|
import { titleCase } from "@stryke/string-format/title-case";
|
|
4
4
|
import { ReflectionClass, ReflectionKind } from "@powerlines/deepkit/vendor/type";
|
|
5
5
|
import defu from "defu";
|
|
6
|
-
import {
|
|
6
|
+
import { Fragment, jsx, jsxs } from "@alloy-js/core/jsx-runtime";
|
|
7
7
|
import { For, Show, code, computed, splitProps } from "@alloy-js/core";
|
|
8
8
|
import { Spacing } from "@powerlines/plugin-alloy/core/components/spacing";
|
|
9
9
|
import { usePowerlines } from "@powerlines/plugin-alloy/core/contexts/context";
|
|
@@ -47,72 +47,54 @@ function __assignType(fn, args) {
|
|
|
47
47
|
function EnvTypeDefinition(props) {
|
|
48
48
|
const [{ defaultValue, reflection }] = splitProps(props, ["defaultValue", "reflection"]);
|
|
49
49
|
const context = (usePowerlines.Ω = [[() => __ΩEnvPluginContext, "n!"]], usePowerlines());
|
|
50
|
-
return [
|
|
51
|
-
|
|
50
|
+
return jsxs(Fragment, { children: [
|
|
51
|
+
jsx(InterfaceDeclaration$1, {
|
|
52
52
|
name: "UnprefixedEnv",
|
|
53
53
|
defaultValue,
|
|
54
54
|
reflection,
|
|
55
|
-
|
|
55
|
+
export: true
|
|
56
56
|
}),
|
|
57
|
-
|
|
58
|
-
|
|
57
|
+
jsx(Spacing, {}),
|
|
58
|
+
jsx(TSDoc, {
|
|
59
59
|
heading: "The environment configuration object with prefixed keys.",
|
|
60
|
-
|
|
61
|
-
return createComponent(TSDocRemarks, { children: `The \`Env\` type extends the \`UnprefixedEnv\` 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.` });
|
|
62
|
-
}
|
|
60
|
+
children: jsx(TSDocRemarks, { children: `The \`Env\` type extends the \`UnprefixedEnv\` 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.` })
|
|
63
61
|
}),
|
|
64
|
-
|
|
62
|
+
jsx(InterfaceDeclaration, {
|
|
65
63
|
name: "Env",
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
64
|
+
export: true,
|
|
65
|
+
extends: "UnprefixedEnv",
|
|
66
|
+
children: jsx(For, {
|
|
67
|
+
each: getUnique(context.config.env.prefix).map(__assignType((prefix) => prefix.replace(/_$/, ""), [
|
|
68
|
+
"prefix",
|
|
69
|
+
"",
|
|
70
|
+
"P\"2!\"/\""
|
|
71
|
+
])),
|
|
72
|
+
doubleHardline: true,
|
|
73
|
+
children: __assignType((prefix) => jsx(For, {
|
|
74
|
+
each: reflection?.getProperties().filter(__assignType((property) => !property.isIgnored(), [
|
|
75
|
+
"property",
|
|
76
|
+
"",
|
|
77
|
+
"P\"2!\"/\""
|
|
78
|
+
])) ?? [],
|
|
77
79
|
doubleHardline: true,
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
get type() {
|
|
94
|
-
return `UnprefixedEnv["${property.getNameAsString()}"]`;
|
|
95
|
-
},
|
|
96
|
-
get readonly() {
|
|
97
|
-
return property.isReadonly();
|
|
98
|
-
}
|
|
99
|
-
})], [
|
|
100
|
-
"property",
|
|
101
|
-
"",
|
|
102
|
-
"P\"2!\"/\""
|
|
103
|
-
]);
|
|
104
|
-
}
|
|
105
|
-
}), [
|
|
106
|
-
"prefix",
|
|
107
|
-
"",
|
|
108
|
-
"P\"2!\"/\""
|
|
109
|
-
]);
|
|
110
|
-
}
|
|
111
|
-
});
|
|
112
|
-
}
|
|
80
|
+
children: __assignType((property) => jsxs(Fragment, { children: [jsx(TSDocReflectionProperty, { reflection: property }), jsx(InterfaceMember, {
|
|
81
|
+
name: `${prefix}_${property.getNameAsString()}`,
|
|
82
|
+
type: `UnprefixedEnv["${property.getNameAsString()}"]`,
|
|
83
|
+
readonly: property.isReadonly()
|
|
84
|
+
})] }), [
|
|
85
|
+
"property",
|
|
86
|
+
"",
|
|
87
|
+
"P\"2!\"/\""
|
|
88
|
+
])
|
|
89
|
+
}), [
|
|
90
|
+
"prefix",
|
|
91
|
+
"",
|
|
92
|
+
"P\"2!\"/\""
|
|
93
|
+
])
|
|
94
|
+
})
|
|
113
95
|
}),
|
|
114
|
-
|
|
115
|
-
];
|
|
96
|
+
jsx(Spacing, {})
|
|
97
|
+
] });
|
|
116
98
|
}
|
|
117
99
|
EnvTypeDefinition.__type = [
|
|
118
100
|
() => __ΩOmit,
|
|
@@ -162,75 +144,47 @@ function ConfigPropertyGet(props) {
|
|
|
162
144
|
"property",
|
|
163
145
|
"index"
|
|
164
146
|
]);
|
|
165
|
-
return
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
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
|
-
}), createComponent(Show, {
|
|
207
|
-
get when() {
|
|
208
|
-
return memo(() => !!property.getAlias())() && property.getAlias().length > 0;
|
|
209
|
-
},
|
|
210
|
-
get children() {
|
|
211
|
-
return [code` || `, createComponent(For, {
|
|
212
|
-
get each() {
|
|
213
|
-
return property.getAlias();
|
|
214
|
-
},
|
|
215
|
-
joiner: code` || `,
|
|
216
|
-
get children() {
|
|
217
|
-
return __assignType((alias) => createComponent(ConfigPropertyConditional, {
|
|
218
|
-
name: alias,
|
|
219
|
-
context
|
|
220
|
-
}), [
|
|
221
|
-
"alias",
|
|
222
|
-
"",
|
|
223
|
-
"P\"2!\"/\""
|
|
224
|
-
]);
|
|
225
|
-
}
|
|
226
|
-
})];
|
|
227
|
-
}
|
|
228
|
-
})];
|
|
229
|
-
},
|
|
230
|
-
get children() {
|
|
231
|
-
return code`return target["${property.getNameAsString()}"];`;
|
|
232
|
-
}
|
|
233
|
-
})];
|
|
147
|
+
return jsx(Fragment, { children: index === 0 ? jsx(IfStatement, {
|
|
148
|
+
condition: jsxs(Fragment, { children: [jsx(ConfigPropertyConditional, {
|
|
149
|
+
name: property.getNameAsString(),
|
|
150
|
+
context
|
|
151
|
+
}), jsxs(Show, {
|
|
152
|
+
when: property.getAlias() && property.getAlias().length > 0,
|
|
153
|
+
children: [code` || `, jsx(For, {
|
|
154
|
+
each: property.getAlias(),
|
|
155
|
+
joiner: code` || `,
|
|
156
|
+
children: __assignType((alias) => jsx(ConfigPropertyConditional, {
|
|
157
|
+
name: alias,
|
|
158
|
+
context
|
|
159
|
+
}), [
|
|
160
|
+
"alias",
|
|
161
|
+
"",
|
|
162
|
+
"P\"2!\"/\""
|
|
163
|
+
])
|
|
164
|
+
})]
|
|
165
|
+
})] }),
|
|
166
|
+
children: code`return target["${property.getNameAsString()}"];`
|
|
167
|
+
}) : jsx(ElseIfClause, {
|
|
168
|
+
condition: jsxs(Fragment, { children: [jsx(ConfigPropertyConditional, {
|
|
169
|
+
name: property.getNameAsString(),
|
|
170
|
+
context
|
|
171
|
+
}), jsxs(Show, {
|
|
172
|
+
when: property.getAlias() && property.getAlias().length > 0,
|
|
173
|
+
children: [code` || `, jsx(For, {
|
|
174
|
+
each: property.getAlias(),
|
|
175
|
+
joiner: code` || `,
|
|
176
|
+
children: __assignType((alias) => jsx(ConfigPropertyConditional, {
|
|
177
|
+
name: alias,
|
|
178
|
+
context
|
|
179
|
+
}), [
|
|
180
|
+
"alias",
|
|
181
|
+
"",
|
|
182
|
+
"P\"2!\"/\""
|
|
183
|
+
])
|
|
184
|
+
})]
|
|
185
|
+
})] }),
|
|
186
|
+
children: code`return target["${property.getNameAsString()}"];`
|
|
187
|
+
}) });
|
|
234
188
|
}
|
|
235
189
|
ConfigPropertyGet.__type = [
|
|
236
190
|
() => __ΩConfigPropertyProps,
|
|
@@ -244,81 +198,53 @@ function ConfigPropertySet(props) {
|
|
|
244
198
|
"property",
|
|
245
199
|
"index"
|
|
246
200
|
]);
|
|
247
|
-
return
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
context
|
|
268
|
-
}), [
|
|
269
|
-
"alias",
|
|
270
|
-
"",
|
|
271
|
-
"P\"2!\"/\""
|
|
272
|
-
]);
|
|
273
|
-
}
|
|
274
|
-
})];
|
|
275
|
-
}
|
|
276
|
-
})];
|
|
277
|
-
},
|
|
278
|
-
get children() {
|
|
279
|
-
return code`
|
|
201
|
+
return jsx(Fragment, { children: index === 0 ? jsx(IfStatement, {
|
|
202
|
+
condition: jsxs(Fragment, { children: [jsx(ConfigPropertyConditional, {
|
|
203
|
+
name: property.getNameAsString(),
|
|
204
|
+
context
|
|
205
|
+
}), jsxs(Show, {
|
|
206
|
+
when: property.getAlias() && property.getAlias().length > 0,
|
|
207
|
+
children: [code` || `, jsx(For, {
|
|
208
|
+
each: property.getAlias(),
|
|
209
|
+
joiner: code` || `,
|
|
210
|
+
children: __assignType((alias) => jsx(ConfigPropertyConditional, {
|
|
211
|
+
name: alias,
|
|
212
|
+
context
|
|
213
|
+
}), [
|
|
214
|
+
"alias",
|
|
215
|
+
"",
|
|
216
|
+
"P\"2!\"/\""
|
|
217
|
+
])
|
|
218
|
+
})]
|
|
219
|
+
})] }),
|
|
220
|
+
children: code`
|
|
280
221
|
target["${property.getNameAsString()}"] = newValue;
|
|
281
222
|
return true;
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
name: alias,
|
|
304
|
-
context
|
|
305
|
-
}), [
|
|
306
|
-
"alias",
|
|
307
|
-
"",
|
|
308
|
-
"P\"2!\"/\""
|
|
309
|
-
]);
|
|
310
|
-
}
|
|
311
|
-
})];
|
|
312
|
-
}
|
|
313
|
-
})];
|
|
314
|
-
},
|
|
315
|
-
get children() {
|
|
316
|
-
return code`
|
|
223
|
+
`
|
|
224
|
+
}) : jsx(ElseIfClause, {
|
|
225
|
+
condition: jsxs(Fragment, { children: [jsx(ConfigPropertyConditional, {
|
|
226
|
+
name: property.getNameAsString(),
|
|
227
|
+
context
|
|
228
|
+
}), jsxs(Show, {
|
|
229
|
+
when: property.getAlias() && property.getAlias().length > 0,
|
|
230
|
+
children: [code` || `, jsx(For, {
|
|
231
|
+
each: property.getAlias(),
|
|
232
|
+
joiner: code` || `,
|
|
233
|
+
children: __assignType((alias) => jsx(ConfigPropertyConditional, {
|
|
234
|
+
name: alias,
|
|
235
|
+
context
|
|
236
|
+
}), [
|
|
237
|
+
"alias",
|
|
238
|
+
"",
|
|
239
|
+
"P\"2!\"/\""
|
|
240
|
+
])
|
|
241
|
+
})]
|
|
242
|
+
})] }),
|
|
243
|
+
children: code`
|
|
317
244
|
target["${property.getNameAsString()}"] = newValue;
|
|
318
245
|
return true;
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
})];
|
|
246
|
+
`
|
|
247
|
+
}) });
|
|
322
248
|
}
|
|
323
249
|
ConfigPropertySet.__type = [
|
|
324
250
|
() => __ΩConfigPropertyProps,
|
|
@@ -388,71 +314,61 @@ function EnvBuiltin(props) {
|
|
|
388
314
|
"",
|
|
389
315
|
"P\"2!\"2\"\"/#"
|
|
390
316
|
])) ?? []);
|
|
391
|
-
return
|
|
317
|
+
return jsxs(BuiltinFile, {
|
|
392
318
|
id: "env",
|
|
393
|
-
description: "The environment configuration module provides an interface to define environment configuration parameters."
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
},
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
refkey: envSerializerRefkey,
|
|
447
|
-
name: "EnvSerializer",
|
|
448
|
-
"extends": "Serializer",
|
|
449
|
-
"export": true,
|
|
450
|
-
get children() {
|
|
451
|
-
return createComponent(ClassMethod, {
|
|
452
|
-
name: "constructor",
|
|
453
|
-
"public": true,
|
|
454
|
-
doc: "Initializes a new instance of the `EnvSerializer` class.",
|
|
455
|
-
children: code`super("env");
|
|
319
|
+
description: "The environment configuration module provides an interface to define environment configuration parameters.",
|
|
320
|
+
...rest,
|
|
321
|
+
imports: defu({ "@powerlines/deepkit/vendor/type": [
|
|
322
|
+
"serializeFunction",
|
|
323
|
+
"deserializeFunction",
|
|
324
|
+
"ReflectionKind",
|
|
325
|
+
"Serializer",
|
|
326
|
+
"NamingStrategy",
|
|
327
|
+
"TemplateState",
|
|
328
|
+
"Type",
|
|
329
|
+
"TypeProperty",
|
|
330
|
+
"TypePropertySignature"
|
|
331
|
+
] }, rest.imports ?? {}),
|
|
332
|
+
children: [
|
|
333
|
+
jsxs(Show, {
|
|
334
|
+
when: Boolean(reflection),
|
|
335
|
+
children: [
|
|
336
|
+
jsx(EnvTypeDefinition, {
|
|
337
|
+
defaultValue,
|
|
338
|
+
reflection
|
|
339
|
+
}),
|
|
340
|
+
jsx("hbr", {}),
|
|
341
|
+
jsx("hbr", {})
|
|
342
|
+
]
|
|
343
|
+
}),
|
|
344
|
+
jsx(ObjectDeclaration, {
|
|
345
|
+
name: "initialEnv",
|
|
346
|
+
type: "Partial<Env>",
|
|
347
|
+
defaultValue,
|
|
348
|
+
reflection: envInstance,
|
|
349
|
+
export: true,
|
|
350
|
+
const: true,
|
|
351
|
+
doc: "The initial environment configuration object values for the runtime."
|
|
352
|
+
}),
|
|
353
|
+
jsx(Spacing, {}),
|
|
354
|
+
jsxs(TSDoc, {
|
|
355
|
+
heading: "The environment configuration serializer for the Powerlines application.",
|
|
356
|
+
children: [
|
|
357
|
+
jsx(TSDocLink, { children: `https://deepkit.io/docs/serialization/serializers` }),
|
|
358
|
+
jsx(TSDocLink, { children: `https://github.com/marcj/untitled-code/blob/master/packages/type/src/serializer.ts#L1918` }),
|
|
359
|
+
jsx(TSDocRemarks, { children: `This serializer is used to serialize and deserialize the Powerlines environment configuration.` })
|
|
360
|
+
]
|
|
361
|
+
}),
|
|
362
|
+
jsx(ClassDeclaration, {
|
|
363
|
+
refkey: envSerializerRefkey,
|
|
364
|
+
name: "EnvSerializer",
|
|
365
|
+
extends: "Serializer",
|
|
366
|
+
export: true,
|
|
367
|
+
children: jsx(ClassMethod, {
|
|
368
|
+
name: "constructor",
|
|
369
|
+
public: true,
|
|
370
|
+
doc: "Initializes a new instance of the `EnvSerializer` class.",
|
|
371
|
+
children: code`super("env");
|
|
456
372
|
|
|
457
373
|
this.deserializeRegistry.register(
|
|
458
374
|
ReflectionKind.boolean,
|
|
@@ -462,16 +378,14 @@ function EnvBuiltin(props) {
|
|
|
462
378
|
);
|
|
463
379
|
}
|
|
464
380
|
); `
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
get initializer() {
|
|
474
|
-
return code`new class extends NamingStrategy {
|
|
381
|
+
})
|
|
382
|
+
}),
|
|
383
|
+
jsx(Spacing, {}),
|
|
384
|
+
jsx(VarDeclaration, {
|
|
385
|
+
name: "envNamingStrategy",
|
|
386
|
+
const: true,
|
|
387
|
+
doc: "The environment naming strategy for the runtime.",
|
|
388
|
+
initializer: code`new class extends NamingStrategy {
|
|
475
389
|
constructor() {
|
|
476
390
|
super("env");
|
|
477
391
|
}
|
|
@@ -483,127 +397,112 @@ function EnvBuiltin(props) {
|
|
|
483
397
|
}
|
|
484
398
|
|
|
485
399
|
return name.replace(/^(${getUnique(context.config.env.prefix).map(__assignType((prefix) => prefix.replace(/_$/, ""), [
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
400
|
+
"prefix",
|
|
401
|
+
"",
|
|
402
|
+
"P\"2!\"/\""
|
|
403
|
+
])).join("|")})_/, "");
|
|
490
404
|
}
|
|
491
|
-
};
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
"
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
get children() {
|
|
525
|
-
return [
|
|
526
|
-
createComponent(TSDocRemarks, { children: `The resulting JSON object can be stringified using \`JSON.stringify()\`.` }),
|
|
527
|
-
createComponent(TSDocExample, { children: `const json = serializeEnv(env);` }),
|
|
528
|
-
createComponent(Spacing, {}),
|
|
529
|
-
createComponent(TSDocParam, {
|
|
530
|
-
name: "input",
|
|
531
|
-
children: `The environment configuration object to serialize.`
|
|
532
|
-
}),
|
|
533
|
-
createComponent(TSDocReturns, { children: `The serialized environment configuration as JSON data objects.` }),
|
|
534
|
-
createComponent(TSDocThrows, { children: `ValidationError when serialization or validation fails.` })
|
|
535
|
-
];
|
|
536
|
-
}
|
|
537
|
-
}),
|
|
538
|
-
createComponent(FunctionDeclaration, {
|
|
539
|
-
name: "serializeEnv",
|
|
540
|
-
"export": true,
|
|
541
|
-
parameters: [{
|
|
405
|
+
}; `
|
|
406
|
+
}),
|
|
407
|
+
jsx(Spacing, {}),
|
|
408
|
+
jsxs(TSDoc, {
|
|
409
|
+
heading: "A {@link EnvSerializer | environment configuration serializer} instance for the Powerlines application.",
|
|
410
|
+
children: [
|
|
411
|
+
jsx(TSDocLink, { children: `https://deepkit.io/docs/serialization/serializers` }),
|
|
412
|
+
jsx(TSDocLink, { children: `https://github.com/marcj/untitled-code/blob/master/packages/type/src/serializer.ts#L1918` }),
|
|
413
|
+
jsx(TSDocRemarks, { children: `This serializer is used to serialize and deserialize the Powerlines environment configuration.` })
|
|
414
|
+
]
|
|
415
|
+
}),
|
|
416
|
+
jsx(VarDeclaration, {
|
|
417
|
+
name: "envSerializer",
|
|
418
|
+
const: true,
|
|
419
|
+
initializer: jsx(NewExpression, {
|
|
420
|
+
args: [],
|
|
421
|
+
target: "EnvSerializer"
|
|
422
|
+
})
|
|
423
|
+
}),
|
|
424
|
+
jsx(Spacing, {}),
|
|
425
|
+
jsx(VarDeclaration, {
|
|
426
|
+
name: "_serializeEnv",
|
|
427
|
+
const: true,
|
|
428
|
+
initializer: "serializeFunction<Env>(envSerializer, envNamingStrategy)"
|
|
429
|
+
}),
|
|
430
|
+
jsx(Spacing, {}),
|
|
431
|
+
jsxs(TSDoc, {
|
|
432
|
+
heading: "Serialize a environment configuration object to JSON data objects (not a JSON string).",
|
|
433
|
+
children: [
|
|
434
|
+
jsx(TSDocRemarks, { children: `The resulting JSON object can be stringified using \`JSON.stringify()\`.` }),
|
|
435
|
+
jsx(TSDocExample, { children: `const json = serializeEnv(env);` }),
|
|
436
|
+
jsx(Spacing, {}),
|
|
437
|
+
jsx(TSDocParam, {
|
|
542
438
|
name: "input",
|
|
543
|
-
|
|
544
|
-
}
|
|
545
|
-
children:
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
439
|
+
children: `The environment configuration object to serialize.`
|
|
440
|
+
}),
|
|
441
|
+
jsx(TSDocReturns, { children: `The serialized environment configuration as JSON data objects.` }),
|
|
442
|
+
jsx(TSDocThrows, { children: `ValidationError when serialization or validation fails.` })
|
|
443
|
+
]
|
|
444
|
+
}),
|
|
445
|
+
jsx(FunctionDeclaration, {
|
|
446
|
+
name: "serializeEnv",
|
|
447
|
+
export: true,
|
|
448
|
+
parameters: [{
|
|
449
|
+
name: "input",
|
|
450
|
+
type: "Env"
|
|
451
|
+
}],
|
|
452
|
+
children: code` return _serializeEnv(input, { loosely: true }); `
|
|
453
|
+
}),
|
|
454
|
+
jsx(Spacing, {}),
|
|
455
|
+
jsx(VarDeclaration, {
|
|
456
|
+
name: "_deserializeEnv",
|
|
457
|
+
const: true,
|
|
458
|
+
initializer: "deserializeFunction<Env>(envSerializer, envNamingStrategy)"
|
|
459
|
+
}),
|
|
460
|
+
jsx(Spacing, {}),
|
|
461
|
+
jsxs(TSDoc, {
|
|
462
|
+
heading: "Deserialize a environment configuration object from JSON data objects to JavaScript objects, without running any validators.",
|
|
463
|
+
children: [
|
|
464
|
+
jsx(TSDocRemarks, { children: `Types that are already correct will be used as-is.` }),
|
|
465
|
+
jsx(TSDocExample, { children: `const env = deserializeEnv(json);` }),
|
|
466
|
+
jsx(TSDocThrows, { children: `ValidationError when deserialization fails.` })
|
|
467
|
+
]
|
|
468
|
+
}),
|
|
469
|
+
jsx(FunctionDeclaration, {
|
|
470
|
+
name: "deserializeEnv",
|
|
471
|
+
export: true,
|
|
472
|
+
parameters: [{
|
|
473
|
+
name: "input",
|
|
474
|
+
type: "Env"
|
|
475
|
+
}],
|
|
476
|
+
children: code` return _deserializeEnv(input, { loosely: true }); `
|
|
477
|
+
}),
|
|
478
|
+
jsx(Spacing, {}),
|
|
479
|
+
jsxs(TSDoc, {
|
|
480
|
+
heading: "Initializes the Powerlines environment configuration module.",
|
|
481
|
+
children: [
|
|
482
|
+
jsx(TSDocRemarks, { children: `This function initializes the Powerlines environment configuration object.` }),
|
|
483
|
+
jsx(TSDocParam, {
|
|
484
|
+
name: "environmentConfig",
|
|
485
|
+
children: `The dynamic/runtime configuration - this could include the current environment variables or any other environment-specific settings provided by the runtime.`
|
|
486
|
+
}),
|
|
487
|
+
jsx(TSDocReturns, { children: `The initialized Powerlines configuration object.` })
|
|
488
|
+
]
|
|
489
|
+
}),
|
|
490
|
+
jsx(Show, {
|
|
491
|
+
when: Boolean(context?.entryPath),
|
|
492
|
+
children: jsxs(FunctionDeclaration, {
|
|
493
|
+
refkey: createEnvRefkey,
|
|
494
|
+
async: false,
|
|
495
|
+
export: true,
|
|
496
|
+
name: "createEnv",
|
|
567
497
|
parameters: [{
|
|
568
|
-
name: "
|
|
569
|
-
type:
|
|
498
|
+
name: "environmentConfig",
|
|
499
|
+
type: `Partial<Env>`,
|
|
500
|
+
optional: false,
|
|
501
|
+
default: "{}"
|
|
570
502
|
}],
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
createComponent(TSDoc, {
|
|
575
|
-
heading: "Initializes the Powerlines environment configuration module.",
|
|
576
|
-
get children() {
|
|
577
|
-
return [
|
|
578
|
-
createComponent(TSDocRemarks, { children: `This function initializes the Powerlines environment configuration object.` }),
|
|
579
|
-
createComponent(TSDocParam, {
|
|
580
|
-
name: "environmentConfig",
|
|
581
|
-
children: `The dynamic/runtime configuration - this could include the current environment variables or any other environment-specific settings provided by the runtime.`
|
|
582
|
-
}),
|
|
583
|
-
createComponent(TSDocReturns, { children: `The initialized Powerlines configuration object.` })
|
|
584
|
-
];
|
|
585
|
-
}
|
|
586
|
-
}),
|
|
587
|
-
createComponent(Show, {
|
|
588
|
-
get when() {
|
|
589
|
-
return Boolean(context?.entryPath);
|
|
590
|
-
},
|
|
591
|
-
get children() {
|
|
592
|
-
return createComponent(FunctionDeclaration, {
|
|
593
|
-
refkey: createEnvRefkey,
|
|
594
|
-
async: false,
|
|
595
|
-
"export": true,
|
|
596
|
-
name: "createEnv",
|
|
597
|
-
parameters: [{
|
|
598
|
-
name: "environmentConfig",
|
|
599
|
-
type: `Partial<Env>`,
|
|
600
|
-
optional: false,
|
|
601
|
-
default: "{}"
|
|
602
|
-
}],
|
|
603
|
-
returnType: "Env",
|
|
604
|
-
get children() {
|
|
605
|
-
return [
|
|
606
|
-
code`
|
|
503
|
+
returnType: "Env",
|
|
504
|
+
children: [
|
|
505
|
+
code`
|
|
607
506
|
return new Proxy<Env>(
|
|
608
507
|
deserializeEnv({
|
|
609
508
|
...initialEnv,
|
|
@@ -611,80 +510,70 @@ function EnvBuiltin(props) {
|
|
|
611
510
|
} as Env),
|
|
612
511
|
{
|
|
613
512
|
get: (target: UnprefixedEnv, propertyName: string) => { `,
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
}),
|
|
630
|
-
code`
|
|
513
|
+
jsx("hbr", {}),
|
|
514
|
+
jsx(For, {
|
|
515
|
+
each: reflectionGetProperties,
|
|
516
|
+
children: __assignType((property, index) => jsx(ConfigPropertyGet, {
|
|
517
|
+
index,
|
|
518
|
+
context,
|
|
519
|
+
property
|
|
520
|
+
}), [
|
|
521
|
+
"property",
|
|
522
|
+
"index",
|
|
523
|
+
"",
|
|
524
|
+
"P!2!'2\"\"/#"
|
|
525
|
+
])
|
|
526
|
+
}),
|
|
527
|
+
code`
|
|
631
528
|
return undefined;
|
|
632
529
|
}, `,
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
createIntrinsic("hbr", {}),
|
|
653
|
-
code`return false;
|
|
530
|
+
jsx(Spacing, {}),
|
|
531
|
+
code` set: (target: UnprefixedEnv, propertyName: string, newValue: any) => { `,
|
|
532
|
+
jsx("hbr", {}),
|
|
533
|
+
jsx(For, {
|
|
534
|
+
each: reflectionSetProperties,
|
|
535
|
+
ender: code` else `,
|
|
536
|
+
children: __assignType((property, index) => jsx(ConfigPropertySet, {
|
|
537
|
+
index,
|
|
538
|
+
context,
|
|
539
|
+
property
|
|
540
|
+
}), [
|
|
541
|
+
"property",
|
|
542
|
+
"index",
|
|
543
|
+
"",
|
|
544
|
+
"P!2!'2\"\"/#"
|
|
545
|
+
])
|
|
546
|
+
}),
|
|
547
|
+
jsx("hbr", {}),
|
|
548
|
+
code`return false;
|
|
654
549
|
}
|
|
655
550
|
}
|
|
656
551
|
);
|
|
657
552
|
`
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
createComponent(VarDeclaration, {
|
|
683
|
-
"export": true,
|
|
684
|
-
"const": true,
|
|
685
|
-
name: "isCI",
|
|
686
|
-
doc: "Detect if the application is running in a continuous integration (CI) environment.",
|
|
687
|
-
initializer: code`Boolean(
|
|
553
|
+
]
|
|
554
|
+
})
|
|
555
|
+
}),
|
|
556
|
+
jsx(Spacing, {}),
|
|
557
|
+
jsx("hbr", {}),
|
|
558
|
+
jsx(TSDoc, {
|
|
559
|
+
heading: "The environment configuration object.",
|
|
560
|
+
children: jsx(TSDocRemarks, { children: `This object provides access to the environment configuration parameters in the application runtime.` })
|
|
561
|
+
}),
|
|
562
|
+
jsx(VarDeclaration, {
|
|
563
|
+
refkey: envRefkey,
|
|
564
|
+
name: "env",
|
|
565
|
+
type: "Env",
|
|
566
|
+
export: true,
|
|
567
|
+
const: true,
|
|
568
|
+
initializer: jsx(Fragment, { children: code`createEnv(${defaultConfig || "{}"} as Partial<Env>);` })
|
|
569
|
+
}),
|
|
570
|
+
jsx(Spacing, {}),
|
|
571
|
+
jsx(VarDeclaration, {
|
|
572
|
+
export: true,
|
|
573
|
+
const: true,
|
|
574
|
+
name: "isCI",
|
|
575
|
+
doc: "Detect if the application is running in a continuous integration (CI) environment.",
|
|
576
|
+
initializer: code`Boolean(
|
|
688
577
|
env.CI ||
|
|
689
578
|
env.RUN_ID ||
|
|
690
579
|
env.AGOLA_GIT_REF ||
|
|
@@ -737,66 +626,61 @@ function EnvBuiltin(props) {
|
|
|
737
626
|
env.CI_XCODE_PROJECT ||
|
|
738
627
|
env.XCS || false
|
|
739
628
|
); `
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
return createComponent(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:
|
|
629
|
+
}),
|
|
630
|
+
jsx(Spacing, {}),
|
|
631
|
+
jsx(TSDoc, {
|
|
632
|
+
heading: "Detect the \\`mode\\` of the current runtime environment.",
|
|
633
|
+
children: 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:
|
|
746
634
|
- \`production\`
|
|
747
635
|
- \`test\`
|
|
748
636
|
- \`development\`
|
|
749
|
-
` })
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
})
|
|
797
|
-
];
|
|
798
|
-
}
|
|
799
|
-
}));
|
|
637
|
+
` })
|
|
638
|
+
}),
|
|
639
|
+
jsx(VarDeclaration, {
|
|
640
|
+
export: true,
|
|
641
|
+
const: true,
|
|
642
|
+
name: "mode",
|
|
643
|
+
initializer: code`String(env.MODE) || "production"; `
|
|
644
|
+
}),
|
|
645
|
+
jsx(Spacing, {}),
|
|
646
|
+
jsx(VarDeclaration, {
|
|
647
|
+
export: true,
|
|
648
|
+
const: true,
|
|
649
|
+
name: "isProduction",
|
|
650
|
+
doc: "Detect if the application is running in `\"production\"` mode",
|
|
651
|
+
initializer: code`["prd", "prod", "production"].includes(mode.toLowerCase()); `
|
|
652
|
+
}),
|
|
653
|
+
jsx(Spacing, {}),
|
|
654
|
+
jsx(VarDeclaration, {
|
|
655
|
+
export: true,
|
|
656
|
+
const: true,
|
|
657
|
+
name: "isTest",
|
|
658
|
+
doc: "Detect if the application is running in `\"test\"` mode",
|
|
659
|
+
initializer: code`["tst", "test", "testing", "stg", "stage", "staging"].includes(mode.toLowerCase()) || env.TEST; `
|
|
660
|
+
}),
|
|
661
|
+
jsx(Spacing, {}),
|
|
662
|
+
jsx(VarDeclaration, {
|
|
663
|
+
export: true,
|
|
664
|
+
const: true,
|
|
665
|
+
name: "isDevelopment",
|
|
666
|
+
doc: "Detect if the application is running in `\"development\"` mode",
|
|
667
|
+
initializer: code`["dev", "development"].includes(mode.toLowerCase()); `
|
|
668
|
+
}),
|
|
669
|
+
jsx(Spacing, {}),
|
|
670
|
+
jsx(VarDeclaration, {
|
|
671
|
+
export: true,
|
|
672
|
+
const: true,
|
|
673
|
+
name: "isDebug",
|
|
674
|
+
doc: "Detect if the application is currently being debugged",
|
|
675
|
+
initializer: code`Boolean(isDevelopment && env.DEBUG); `
|
|
676
|
+
}),
|
|
677
|
+
jsx(Spacing, {}),
|
|
678
|
+
jsx(Show, {
|
|
679
|
+
when: Boolean(children),
|
|
680
|
+
children
|
|
681
|
+
})
|
|
682
|
+
]
|
|
683
|
+
});
|
|
800
684
|
}
|
|
801
685
|
EnvBuiltin.__type = [
|
|
802
686
|
() => __ΩEnvBuiltinProps,
|