@powerlines/plugin-env 0.16.234 → 0.16.236
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 +23 -71
- package/dist/babel/plugin.d.cts.map +1 -1
- package/dist/babel/plugin.d.mts.map +1 -1
- package/dist/babel/plugin.mjs +23 -71
- package/dist/babel/plugin.mjs.map +1 -1
- package/dist/components/docs.cjs +14 -14
- package/dist/components/docs.d.cts +0 -2
- package/dist/components/docs.d.cts.map +1 -1
- package/dist/components/docs.d.mts +0 -2
- package/dist/components/docs.d.mts.map +1 -1
- package/dist/components/docs.mjs +14 -14
- package/dist/components/docs.mjs.map +1 -1
- package/dist/components/env-builtin.cjs +233 -426
- package/dist/components/env-builtin.d.cts +1 -4
- package/dist/components/env-builtin.d.cts.map +1 -1
- package/dist/components/env-builtin.d.mts +1 -4
- package/dist/components/env-builtin.d.mts.map +1 -1
- package/dist/components/env-builtin.mjs +236 -428
- package/dist/components/env-builtin.mjs.map +1 -1
- package/dist/helpers/index.cjs +9 -26
- package/dist/helpers/index.d.cts +3 -5
- package/dist/helpers/index.d.mts +3 -5
- package/dist/helpers/index.mjs +3 -5
- package/dist/helpers/load.cjs +8 -7
- package/dist/helpers/load.d.cts +3 -3
- package/dist/helpers/load.d.cts.map +1 -1
- package/dist/helpers/load.d.mts +3 -3
- package/dist/helpers/load.d.mts.map +1 -1
- package/dist/helpers/load.mjs +7 -6
- package/dist/helpers/load.mjs.map +1 -1
- package/dist/helpers/schema.cjs +206 -0
- package/dist/helpers/schema.d.cts +53 -0
- package/dist/helpers/schema.d.cts.map +1 -0
- package/dist/helpers/schema.d.mts +53 -0
- package/dist/helpers/schema.d.mts.map +1 -0
- package/dist/helpers/schema.mjs +199 -0
- package/dist/helpers/schema.mjs.map +1 -0
- package/dist/index.cjs +23 -201
- package/dist/index.d.cts +2 -2
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +2 -2
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +25 -203
- package/dist/index.mjs.map +1 -1
- package/dist/types/index.cjs +1 -0
- package/dist/types/index.d.cts +2 -2
- package/dist/types/index.d.mts +2 -2
- package/dist/types/index.mjs +2 -2
- package/dist/types/plugin.cjs +16 -24
- package/dist/types/plugin.d.cts +23 -57
- package/dist/types/plugin.d.cts.map +1 -1
- package/dist/types/plugin.d.mts +23 -57
- package/dist/types/plugin.d.mts.map +1 -1
- package/dist/types/plugin.mjs +16 -25
- package/dist/types/plugin.mjs.map +1 -1
- package/package.json +12 -26
- package/dist/helpers/create-reflection-resource.cjs +0 -23
- package/dist/helpers/create-reflection-resource.d.cts +0 -13
- package/dist/helpers/create-reflection-resource.d.cts.map +0 -1
- package/dist/helpers/create-reflection-resource.d.mts +0 -13
- package/dist/helpers/create-reflection-resource.d.mts.map +0 -1
- package/dist/helpers/create-reflection-resource.mjs +0 -23
- package/dist/helpers/create-reflection-resource.mjs.map +0 -1
- package/dist/helpers/persistence.cjs +0 -309
- package/dist/helpers/persistence.d.cts +0 -84
- package/dist/helpers/persistence.d.cts.map +0 -1
- package/dist/helpers/persistence.d.mts +0 -84
- package/dist/helpers/persistence.d.mts.map +0 -1
- package/dist/helpers/persistence.mjs +0 -297
- package/dist/helpers/persistence.mjs.map +0 -1
- package/dist/helpers/reflect.cjs +0 -290
- package/dist/helpers/reflect.d.cts +0 -68
- package/dist/helpers/reflect.d.cts.map +0 -1
- package/dist/helpers/reflect.d.mts +0 -68
- package/dist/helpers/reflect.d.mts.map +0 -1
- package/dist/helpers/reflect.mjs +0 -281
- package/dist/helpers/reflect.mjs.map +0 -1
- package/dist/helpers/template-helpers.cjs +0 -70
- package/dist/helpers/template-helpers.d.cts +0 -15
- package/dist/helpers/template-helpers.d.cts.map +0 -1
- package/dist/helpers/template-helpers.d.mts +0 -15
- package/dist/helpers/template-helpers.d.mts.map +0 -1
- package/dist/helpers/template-helpers.mjs +0 -69
- package/dist/helpers/template-helpers.mjs.map +0 -1
|
@@ -1,19 +1,17 @@
|
|
|
1
1
|
import { __ΩEnvPluginContext } from "../types/plugin.mjs";
|
|
2
2
|
import { loadEnvFromContext } from "../helpers/load.mjs";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import defu from "defu";
|
|
6
|
-
import { createComponent, createIntrinsic, memo, mergeProps } from "@alloy-js/core/jsx-runtime";
|
|
3
|
+
import { getProperties } from "@powerlines/schema/helpers";
|
|
4
|
+
import { createComponent, createIntrinsic, mergeProps } from "@alloy-js/core/jsx-runtime";
|
|
7
5
|
import { For, Show, code, computed, splitProps } from "@alloy-js/core";
|
|
8
6
|
import { Spacing } from "@powerlines/plugin-alloy/core/components/spacing";
|
|
9
7
|
import { usePowerlines } from "@powerlines/plugin-alloy/core/contexts/context";
|
|
10
|
-
import {
|
|
8
|
+
import { ElseIfClause, FunctionDeclaration, IfStatement, InterfaceDeclaration, InterfaceMember, VarDeclaration } from "@alloy-js/typescript";
|
|
11
9
|
import { refkey } from "@powerlines/plugin-alloy/helpers/refkey";
|
|
12
10
|
import { BuiltinFile } from "@powerlines/plugin-alloy/typescript/components/builtin-file";
|
|
13
11
|
import { InterfaceDeclaration as InterfaceDeclaration$1 } from "@powerlines/plugin-alloy/typescript/components/interface-declaration";
|
|
14
12
|
import { ObjectDeclaration } from "@powerlines/plugin-alloy/typescript/components/object-declaration";
|
|
15
|
-
import { TSDoc,
|
|
16
|
-
import {
|
|
13
|
+
import { TSDoc, TSDocParam, TSDocRemarks, TSDocReturns } from "@powerlines/plugin-alloy/typescript/components/tsdoc";
|
|
14
|
+
import { TSDocSchemaProperty } from "@powerlines/plugin-alloy/typescript/components/tsdoc-schema";
|
|
17
15
|
import { getUnique } from "@stryke/helpers/get-unique";
|
|
18
16
|
|
|
19
17
|
//#region src/components/env-builtin.tsx
|
|
@@ -44,14 +42,14 @@ function __assignType(fn, args) {
|
|
|
44
42
|
/**
|
|
45
43
|
* Generates the environment configuration typescript definition for the Powerlines project.
|
|
46
44
|
*/
|
|
47
|
-
function EnvTypeDefinition(
|
|
48
|
-
const [{ defaultValue, reflection }] = splitProps(props, ["defaultValue", "reflection"]);
|
|
45
|
+
function EnvTypeDefinition() {
|
|
49
46
|
const context = (usePowerlines.Ω = [[() => __ΩEnvPluginContext, "n!"]], usePowerlines());
|
|
50
47
|
return [
|
|
51
48
|
createComponent(InterfaceDeclaration$1, {
|
|
52
49
|
name: "UnprefixedEnv",
|
|
53
|
-
|
|
54
|
-
|
|
50
|
+
get schema() {
|
|
51
|
+
return context.env.vars.schema;
|
|
52
|
+
},
|
|
55
53
|
"export": true
|
|
56
54
|
}),
|
|
57
55
|
createComponent(Spacing, {}),
|
|
@@ -78,7 +76,7 @@ function EnvTypeDefinition(props) {
|
|
|
78
76
|
get children() {
|
|
79
77
|
return __assignType((prefix) => createComponent(For, {
|
|
80
78
|
get each() {
|
|
81
|
-
return
|
|
79
|
+
return Object.values(getProperties(context.env.vars.schema)).filter(__assignType((property) => !property.metadata?.isIgnored, [
|
|
82
80
|
"property",
|
|
83
81
|
"",
|
|
84
82
|
"P\"2!\"/\""
|
|
@@ -86,15 +84,15 @@ function EnvTypeDefinition(props) {
|
|
|
86
84
|
},
|
|
87
85
|
doubleHardline: true,
|
|
88
86
|
get children() {
|
|
89
|
-
return __assignType((property) => [createComponent(
|
|
87
|
+
return __assignType((property) => [createComponent(TSDocSchemaProperty, { schema: property }), createComponent(InterfaceMember, {
|
|
90
88
|
get name() {
|
|
91
|
-
return `${prefix}_${property.
|
|
89
|
+
return `${prefix}_${property.metadata?.name}`;
|
|
92
90
|
},
|
|
93
91
|
get type() {
|
|
94
|
-
return `UnprefixedEnv["${property.
|
|
92
|
+
return `UnprefixedEnv["${property.metadata?.name}"]`;
|
|
95
93
|
},
|
|
96
|
-
get
|
|
97
|
-
return property.isReadonly
|
|
94
|
+
get isReadonly() {
|
|
95
|
+
return property.metadata?.isReadonly;
|
|
98
96
|
}
|
|
99
97
|
})], [
|
|
100
98
|
"property",
|
|
@@ -115,12 +113,9 @@ function EnvTypeDefinition(props) {
|
|
|
115
113
|
];
|
|
116
114
|
}
|
|
117
115
|
EnvTypeDefinition.__type = [
|
|
118
|
-
() => __ΩOmit,
|
|
119
|
-
"name",
|
|
120
|
-
"props",
|
|
121
116
|
"EnvTypeDefinition",
|
|
122
117
|
"Generates the environment configuration typescript definition for the Powerlines project.",
|
|
123
|
-
"P
|
|
118
|
+
"P\"/!?\""
|
|
124
119
|
];
|
|
125
120
|
const __ΩConfigPropertyConditionalProps = [
|
|
126
121
|
() => __ΩEnvPluginContext,
|
|
@@ -152,31 +147,31 @@ const __ΩConfigPropertyProps = [
|
|
|
152
147
|
"index",
|
|
153
148
|
() => __ΩEnvPluginContext,
|
|
154
149
|
"context",
|
|
150
|
+
"name",
|
|
155
151
|
"property",
|
|
156
152
|
"ConfigPropertyProps",
|
|
157
|
-
"P!'4!n\"4
|
|
153
|
+
"P!'4!n\"4#&4$!4%Mw&y"
|
|
158
154
|
];
|
|
159
155
|
function ConfigPropertyGet(props) {
|
|
160
|
-
const [{ context, property, index }] = splitProps(props, [
|
|
156
|
+
const [{ context, name, property, index }] = splitProps(props, [
|
|
161
157
|
"context",
|
|
158
|
+
"name",
|
|
162
159
|
"property",
|
|
163
160
|
"index"
|
|
164
161
|
]);
|
|
165
162
|
return [index === 0 ? createComponent(IfStatement, {
|
|
166
163
|
get condition() {
|
|
167
164
|
return [createComponent(ConfigPropertyConditional, {
|
|
168
|
-
|
|
169
|
-
return property.getNameAsString();
|
|
170
|
-
},
|
|
165
|
+
name,
|
|
171
166
|
context
|
|
172
167
|
}), createComponent(Show, {
|
|
173
168
|
get when() {
|
|
174
|
-
return
|
|
169
|
+
return property.metadata?.alias && property.metadata?.alias.length > 0;
|
|
175
170
|
},
|
|
176
171
|
get children() {
|
|
177
172
|
return [code` || `, createComponent(For, {
|
|
178
173
|
get each() {
|
|
179
|
-
return property.
|
|
174
|
+
return property.metadata?.alias ?? [];
|
|
180
175
|
},
|
|
181
176
|
joiner: code` || `,
|
|
182
177
|
get children() {
|
|
@@ -193,24 +188,20 @@ function ConfigPropertyGet(props) {
|
|
|
193
188
|
}
|
|
194
189
|
})];
|
|
195
190
|
},
|
|
196
|
-
|
|
197
|
-
return code`return target["${property.getNameAsString()}"];`;
|
|
198
|
-
}
|
|
191
|
+
children: code`return target["${name}"];`
|
|
199
192
|
}) : createComponent(ElseIfClause, {
|
|
200
193
|
get condition() {
|
|
201
194
|
return [createComponent(ConfigPropertyConditional, {
|
|
202
|
-
|
|
203
|
-
return property.getNameAsString();
|
|
204
|
-
},
|
|
195
|
+
name,
|
|
205
196
|
context
|
|
206
197
|
}), createComponent(Show, {
|
|
207
198
|
get when() {
|
|
208
|
-
return
|
|
199
|
+
return property.metadata?.alias && property.metadata?.alias.length > 0;
|
|
209
200
|
},
|
|
210
201
|
get children() {
|
|
211
202
|
return [code` || `, createComponent(For, {
|
|
212
203
|
get each() {
|
|
213
|
-
return property.
|
|
204
|
+
return property.metadata?.alias ?? [];
|
|
214
205
|
},
|
|
215
206
|
joiner: code` || `,
|
|
216
207
|
get children() {
|
|
@@ -227,9 +218,7 @@ function ConfigPropertyGet(props) {
|
|
|
227
218
|
}
|
|
228
219
|
})];
|
|
229
220
|
},
|
|
230
|
-
|
|
231
|
-
return code`return target["${property.getNameAsString()}"];`;
|
|
232
|
-
}
|
|
221
|
+
children: code`return target["${name}"];`
|
|
233
222
|
})];
|
|
234
223
|
}
|
|
235
224
|
ConfigPropertyGet.__type = [
|
|
@@ -239,26 +228,25 @@ ConfigPropertyGet.__type = [
|
|
|
239
228
|
"Pn!2\"\"/#"
|
|
240
229
|
];
|
|
241
230
|
function ConfigPropertySet(props) {
|
|
242
|
-
const [{ context, property, index }] = splitProps(props, [
|
|
231
|
+
const [{ context, name, property, index }] = splitProps(props, [
|
|
243
232
|
"context",
|
|
233
|
+
"name",
|
|
244
234
|
"property",
|
|
245
235
|
"index"
|
|
246
236
|
]);
|
|
247
237
|
return [index === 0 ? createComponent(IfStatement, {
|
|
248
238
|
get condition() {
|
|
249
239
|
return [createComponent(ConfigPropertyConditional, {
|
|
250
|
-
|
|
251
|
-
return property.getNameAsString();
|
|
252
|
-
},
|
|
240
|
+
name,
|
|
253
241
|
context
|
|
254
242
|
}), createComponent(Show, {
|
|
255
243
|
get when() {
|
|
256
|
-
return
|
|
244
|
+
return property.metadata?.alias && property.metadata?.alias.length > 0;
|
|
257
245
|
},
|
|
258
246
|
get children() {
|
|
259
247
|
return [code` || `, createComponent(For, {
|
|
260
248
|
get each() {
|
|
261
|
-
return property.
|
|
249
|
+
return property.metadata?.alias ?? [];
|
|
262
250
|
},
|
|
263
251
|
joiner: code` || `,
|
|
264
252
|
get children() {
|
|
@@ -275,27 +263,23 @@ function ConfigPropertySet(props) {
|
|
|
275
263
|
}
|
|
276
264
|
})];
|
|
277
265
|
},
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
target["${property.getNameAsString()}"] = newValue;
|
|
266
|
+
children: code`
|
|
267
|
+
target["${name}"] = newValue;
|
|
281
268
|
return true;
|
|
282
|
-
|
|
283
|
-
}
|
|
269
|
+
`
|
|
284
270
|
}) : createComponent(ElseIfClause, {
|
|
285
271
|
get condition() {
|
|
286
272
|
return [createComponent(ConfigPropertyConditional, {
|
|
287
|
-
|
|
288
|
-
return property.getNameAsString();
|
|
289
|
-
},
|
|
273
|
+
name,
|
|
290
274
|
context
|
|
291
275
|
}), createComponent(Show, {
|
|
292
276
|
get when() {
|
|
293
|
-
return
|
|
277
|
+
return property.metadata?.alias && property.metadata?.alias.length > 0;
|
|
294
278
|
},
|
|
295
279
|
get children() {
|
|
296
280
|
return [code` || `, createComponent(For, {
|
|
297
281
|
get each() {
|
|
298
|
-
return property.
|
|
282
|
+
return property.metadata?.alias ?? [];
|
|
299
283
|
},
|
|
300
284
|
joiner: code` || `,
|
|
301
285
|
get children() {
|
|
@@ -312,12 +296,10 @@ function ConfigPropertySet(props) {
|
|
|
312
296
|
}
|
|
313
297
|
})];
|
|
314
298
|
},
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
target["${property.getNameAsString()}"] = newValue;
|
|
299
|
+
children: code`
|
|
300
|
+
target["${name}"] = newValue;
|
|
318
301
|
return true;
|
|
319
|
-
|
|
320
|
-
}
|
|
302
|
+
`
|
|
321
303
|
})];
|
|
322
304
|
}
|
|
323
305
|
ConfigPropertySet.__type = [
|
|
@@ -331,58 +313,33 @@ const __ΩEnvBuiltinProps = [
|
|
|
331
313
|
"id",
|
|
332
314
|
"Children",
|
|
333
315
|
"defaultConfig",
|
|
334
|
-
"reflection",
|
|
335
316
|
"EnvBuiltinProps",
|
|
336
|
-
"P!.\"o!#\"w#4$
|
|
317
|
+
"P!.\"o!#\"w#4$8Mw%y"
|
|
337
318
|
];
|
|
338
319
|
const createEnvRefkey = refkey("createEnv");
|
|
339
320
|
const envRefkey = refkey("env");
|
|
340
|
-
const envSerializerRefkey = refkey("EnvSerializer");
|
|
341
321
|
/**
|
|
342
322
|
* Generates the environment configuration module for the Powerlines project.
|
|
343
323
|
*/
|
|
344
324
|
function EnvBuiltin(props) {
|
|
345
|
-
const [{ defaultConfig,
|
|
346
|
-
"defaultConfig",
|
|
347
|
-
"reflection",
|
|
348
|
-
"children"
|
|
349
|
-
]);
|
|
325
|
+
const [{ defaultConfig, children }, rest] = splitProps(props, ["defaultConfig", "children"]);
|
|
350
326
|
const context = (usePowerlines.Ω = [[() => __ΩEnvPluginContext, "n!"]], usePowerlines());
|
|
351
327
|
const defaultValue = computed(() => context && loadEnvFromContext(context, process.env));
|
|
352
|
-
const
|
|
353
|
-
const result = new ReflectionClass({
|
|
354
|
-
kind: ReflectionKind.objectLiteral,
|
|
355
|
-
description: `The initial environment configuration state for the ${titleCase(context?.config?.name)} project.`,
|
|
356
|
-
types: []
|
|
357
|
-
}, reflection);
|
|
358
|
-
result.getProperties().filter(__assignType((property) => property.isRuntime() || property.getTags().runtime === true, [
|
|
359
|
-
"property",
|
|
360
|
-
"",
|
|
361
|
-
"P\"2!\"/\""
|
|
362
|
-
])).forEach(__assignType((property) => {
|
|
363
|
-
result.removeProperty(property.getNameAsString());
|
|
364
|
-
}, [
|
|
365
|
-
"property",
|
|
366
|
-
"",
|
|
367
|
-
"P\"2!\"/\""
|
|
368
|
-
]));
|
|
369
|
-
return result;
|
|
370
|
-
});
|
|
371
|
-
const reflectionGetProperties = computed(() => reflection?.getProperties().filter(__assignType((property) => !property.isIgnored(), [
|
|
328
|
+
const reflectionGetProperties = computed(() => Object.values(getProperties(context.env.vars.schema)).filter(__assignType((property) => !property.metadata?.isIgnored, [
|
|
372
329
|
"property",
|
|
373
330
|
"",
|
|
374
331
|
"P\"2!\"/\""
|
|
375
|
-
])).sort(__assignType((a, b) => a.
|
|
332
|
+
])).sort(__assignType((a, b) => !a.metadata?.name && !b.metadata?.name ? 0 : !a.metadata?.name ? 1 : !b.metadata?.name ? -1 : a.metadata?.name.localeCompare(b.metadata?.name), [
|
|
376
333
|
"a",
|
|
377
334
|
"b",
|
|
378
335
|
"",
|
|
379
336
|
"P\"2!\"2\"\"/#"
|
|
380
337
|
])) ?? []);
|
|
381
|
-
const reflectionSetProperties = computed(() =>
|
|
338
|
+
const reflectionSetProperties = computed(() => Object.values(getProperties(context.env.vars.schema)).filter(__assignType((property) => !property.metadata?.isIgnored && !property.metadata?.isReadonly, [
|
|
382
339
|
"property",
|
|
383
340
|
"",
|
|
384
341
|
"P\"2!\"/\""
|
|
385
|
-
])).sort(__assignType((a, b) => a.
|
|
342
|
+
])).sort(__assignType((a, b) => !a.metadata?.name && !b.metadata?.name ? 0 : !a.metadata?.name ? 1 : !b.metadata?.name ? -1 : a.metadata?.name.localeCompare(b.metadata?.name), [
|
|
386
343
|
"a",
|
|
387
344
|
"b",
|
|
388
345
|
"",
|
|
@@ -391,219 +348,60 @@ function EnvBuiltin(props) {
|
|
|
391
348
|
return createComponent(BuiltinFile, mergeProps({
|
|
392
349
|
id: "env",
|
|
393
350
|
description: "The environment configuration module provides an interface to define environment configuration parameters."
|
|
394
|
-
}, rest, {
|
|
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
|
-
|
|
447
|
-
|
|
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");
|
|
456
|
-
|
|
457
|
-
this.deserializeRegistry.register(
|
|
458
|
-
ReflectionKind.boolean,
|
|
459
|
-
(type: Type, state: TemplateState) => {
|
|
460
|
-
state.addSetter(
|
|
461
|
-
\`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()}\`
|
|
462
|
-
);
|
|
463
|
-
}
|
|
464
|
-
); `
|
|
465
|
-
});
|
|
466
|
-
}
|
|
467
|
-
}),
|
|
468
|
-
createComponent(Spacing, {}),
|
|
469
|
-
createComponent(VarDeclaration, {
|
|
470
|
-
name: "envNamingStrategy",
|
|
471
|
-
"const": true,
|
|
472
|
-
doc: "The environment naming strategy for the runtime.",
|
|
473
|
-
get initializer() {
|
|
474
|
-
return code`new class extends NamingStrategy {
|
|
475
|
-
constructor() {
|
|
476
|
-
super("env");
|
|
477
|
-
}
|
|
478
|
-
|
|
479
|
-
getPropertyName(type: TypeProperty | TypePropertySignature, forSerializer: string): string | undefined {
|
|
480
|
-
const name = super.getPropertyName(type, forSerializer);
|
|
481
|
-
if (!name) {
|
|
482
|
-
return name;
|
|
483
|
-
}
|
|
484
|
-
|
|
485
|
-
return name.replace(/^(${getUnique(context.config.env.prefix).map(__assignType((prefix) => prefix.replace(/_$/, ""), [
|
|
486
|
-
"prefix",
|
|
487
|
-
"",
|
|
488
|
-
"P\"2!\"/\""
|
|
489
|
-
])).join("|")})_/, "");
|
|
490
|
-
}
|
|
491
|
-
}; `;
|
|
492
|
-
}
|
|
493
|
-
}),
|
|
494
|
-
createComponent(Spacing, {}),
|
|
495
|
-
createComponent(TSDoc, {
|
|
496
|
-
heading: "A {@link EnvSerializer | environment configuration serializer} instance for the Powerlines application.",
|
|
497
|
-
get children() {
|
|
498
|
-
return [
|
|
499
|
-
createComponent(TSDocLink, { children: `https://deepkit.io/docs/serialization/serializers` }),
|
|
500
|
-
createComponent(TSDocLink, { children: `https://github.com/marcj/untitled-code/blob/master/packages/type/src/serializer.ts#L1918` }),
|
|
501
|
-
createComponent(TSDocRemarks, { children: `This serializer is used to serialize and deserialize the Powerlines environment configuration.` })
|
|
502
|
-
];
|
|
503
|
-
}
|
|
504
|
-
}),
|
|
505
|
-
createComponent(VarDeclaration, {
|
|
506
|
-
name: "envSerializer",
|
|
507
|
-
"const": true,
|
|
508
|
-
get initializer() {
|
|
509
|
-
return createComponent(NewExpression, {
|
|
510
|
-
args: [],
|
|
511
|
-
target: "EnvSerializer"
|
|
512
|
-
});
|
|
513
|
-
}
|
|
514
|
-
}),
|
|
515
|
-
createComponent(Spacing, {}),
|
|
516
|
-
createComponent(VarDeclaration, {
|
|
517
|
-
name: "_serializeEnv",
|
|
518
|
-
"const": true,
|
|
519
|
-
initializer: "serializeFunction<Env>(envSerializer, envNamingStrategy)"
|
|
520
|
-
}),
|
|
521
|
-
createComponent(Spacing, {}),
|
|
522
|
-
createComponent(TSDoc, {
|
|
523
|
-
heading: "Serialize a environment configuration object to JSON data objects (not a JSON string).",
|
|
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: [{
|
|
542
|
-
name: "input",
|
|
543
|
-
type: "Env"
|
|
544
|
-
}],
|
|
545
|
-
children: code` return _serializeEnv(input, { loosely: true }); `
|
|
546
|
-
}),
|
|
547
|
-
createComponent(Spacing, {}),
|
|
548
|
-
createComponent(VarDeclaration, {
|
|
549
|
-
name: "_deserializeEnv",
|
|
550
|
-
"const": true,
|
|
551
|
-
initializer: "deserializeFunction<Env>(envSerializer, envNamingStrategy)"
|
|
552
|
-
}),
|
|
553
|
-
createComponent(Spacing, {}),
|
|
554
|
-
createComponent(TSDoc, {
|
|
555
|
-
heading: "Deserialize a environment configuration object from JSON data objects to JavaScript objects, without running any validators.",
|
|
556
|
-
get children() {
|
|
557
|
-
return [
|
|
558
|
-
createComponent(TSDocRemarks, { children: `Types that are already correct will be used as-is.` }),
|
|
559
|
-
createComponent(TSDocExample, { children: `const env = deserializeEnv(json);` }),
|
|
560
|
-
createComponent(TSDocThrows, { children: `ValidationError when deserialization fails.` })
|
|
561
|
-
];
|
|
562
|
-
}
|
|
563
|
-
}),
|
|
564
|
-
createComponent(FunctionDeclaration, {
|
|
565
|
-
name: "deserializeEnv",
|
|
566
|
-
"export": true,
|
|
567
|
-
parameters: [{
|
|
568
|
-
name: "input",
|
|
569
|
-
type: "Env"
|
|
570
|
-
}],
|
|
571
|
-
children: code` return _deserializeEnv(input, { loosely: true }); `
|
|
572
|
-
}),
|
|
573
|
-
createComponent(Spacing, {}),
|
|
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`
|
|
351
|
+
}, rest, { get children() {
|
|
352
|
+
return [
|
|
353
|
+
createComponent(Show, {
|
|
354
|
+
get when() {
|
|
355
|
+
return Boolean(context.env.vars.schema);
|
|
356
|
+
},
|
|
357
|
+
get children() {
|
|
358
|
+
return [createComponent(EnvTypeDefinition, { defaultValue }), createComponent(Spacing, {})];
|
|
359
|
+
}
|
|
360
|
+
}),
|
|
361
|
+
createComponent(ObjectDeclaration, {
|
|
362
|
+
name: "initialEnv",
|
|
363
|
+
type: "Partial<Env>",
|
|
364
|
+
get schema() {
|
|
365
|
+
return context.env.vars.schema;
|
|
366
|
+
},
|
|
367
|
+
"export": true,
|
|
368
|
+
"const": true,
|
|
369
|
+
doc: "The initial environment configuration object values for the runtime."
|
|
370
|
+
}),
|
|
371
|
+
createComponent(Spacing, {}),
|
|
372
|
+
createComponent(TSDoc, {
|
|
373
|
+
heading: "Initializes the Powerlines environment configuration module.",
|
|
374
|
+
get children() {
|
|
375
|
+
return [
|
|
376
|
+
createComponent(TSDocRemarks, { children: `This function initializes the Powerlines environment configuration object.` }),
|
|
377
|
+
createComponent(TSDocParam, {
|
|
378
|
+
name: "environmentConfig",
|
|
379
|
+
children: `The dynamic/runtime configuration - this could include the current environment variables or any other environment-specific settings provided by the runtime.`
|
|
380
|
+
}),
|
|
381
|
+
createComponent(TSDocReturns, { children: `The initialized Powerlines configuration object.` })
|
|
382
|
+
];
|
|
383
|
+
}
|
|
384
|
+
}),
|
|
385
|
+
createComponent(Show, {
|
|
386
|
+
get when() {
|
|
387
|
+
return Boolean(context?.entryPath);
|
|
388
|
+
},
|
|
389
|
+
get children() {
|
|
390
|
+
return createComponent(FunctionDeclaration, {
|
|
391
|
+
refkey: createEnvRefkey,
|
|
392
|
+
async: false,
|
|
393
|
+
"export": true,
|
|
394
|
+
name: "createEnv",
|
|
395
|
+
parameters: [{
|
|
396
|
+
name: "environmentConfig",
|
|
397
|
+
type: `Partial<Env>`,
|
|
398
|
+
optional: false,
|
|
399
|
+
default: "{}"
|
|
400
|
+
}],
|
|
401
|
+
returnType: "Env",
|
|
402
|
+
get children() {
|
|
403
|
+
return [
|
|
404
|
+
code`
|
|
607
405
|
return new Proxy<Env>(
|
|
608
406
|
deserializeEnv({
|
|
609
407
|
...initialEnv,
|
|
@@ -611,80 +409,91 @@ function EnvBuiltin(props) {
|
|
|
611
409
|
} as Env),
|
|
612
410
|
{
|
|
613
411
|
get: (target: UnprefixedEnv, propertyName: string) => { `,
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
412
|
+
createIntrinsic("hbr", {}),
|
|
413
|
+
createComponent(For, {
|
|
414
|
+
get each() {
|
|
415
|
+
return reflectionGetProperties.value;
|
|
416
|
+
},
|
|
417
|
+
get children() {
|
|
418
|
+
return __assignType((property, index) => createComponent(ConfigPropertyGet, {
|
|
419
|
+
index,
|
|
420
|
+
context,
|
|
421
|
+
get name() {
|
|
422
|
+
return property.name;
|
|
423
|
+
},
|
|
424
|
+
property
|
|
425
|
+
}), [
|
|
426
|
+
"name",
|
|
427
|
+
"property",
|
|
428
|
+
"index",
|
|
429
|
+
"",
|
|
430
|
+
"PP!P&4!MK2\"'2#\"/$"
|
|
431
|
+
]);
|
|
432
|
+
}
|
|
433
|
+
}),
|
|
434
|
+
code`
|
|
631
435
|
return undefined;
|
|
632
436
|
}, `,
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
437
|
+
createComponent(Spacing, {}),
|
|
438
|
+
code` set: (target: UnprefixedEnv, propertyName: string, newValue: any) => { `,
|
|
439
|
+
createIntrinsic("hbr", {}),
|
|
440
|
+
createComponent(For, {
|
|
441
|
+
get each() {
|
|
442
|
+
return reflectionSetProperties.value;
|
|
443
|
+
},
|
|
444
|
+
ender: code` else `,
|
|
445
|
+
get children() {
|
|
446
|
+
return __assignType((property, index) => createComponent(ConfigPropertySet, {
|
|
447
|
+
index,
|
|
448
|
+
context,
|
|
449
|
+
get name() {
|
|
450
|
+
return property.name;
|
|
451
|
+
},
|
|
452
|
+
property
|
|
453
|
+
}), [
|
|
454
|
+
"name",
|
|
455
|
+
"property",
|
|
456
|
+
"index",
|
|
457
|
+
"",
|
|
458
|
+
"PP!P&4!MK2\"'2#\"/$"
|
|
459
|
+
]);
|
|
460
|
+
}
|
|
461
|
+
}),
|
|
462
|
+
createIntrinsic("hbr", {}),
|
|
463
|
+
code`return false;
|
|
654
464
|
}
|
|
655
465
|
}
|
|
656
466
|
);
|
|
657
467
|
`
|
|
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
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
initializer: code`Boolean(
|
|
468
|
+
];
|
|
469
|
+
}
|
|
470
|
+
});
|
|
471
|
+
}
|
|
472
|
+
}),
|
|
473
|
+
createComponent(Spacing, {}),
|
|
474
|
+
createComponent(TSDoc, {
|
|
475
|
+
heading: "The environment configuration object.",
|
|
476
|
+
get children() {
|
|
477
|
+
return createComponent(TSDocRemarks, { children: `This object provides access to the environment configuration parameters in the application runtime.` });
|
|
478
|
+
}
|
|
479
|
+
}),
|
|
480
|
+
createComponent(VarDeclaration, {
|
|
481
|
+
refkey: envRefkey,
|
|
482
|
+
name: "env",
|
|
483
|
+
type: "Env",
|
|
484
|
+
"export": true,
|
|
485
|
+
"const": true,
|
|
486
|
+
get initializer() {
|
|
487
|
+
return [code`createEnv(${defaultConfig || "{}"} as Partial<Env>);`];
|
|
488
|
+
}
|
|
489
|
+
}),
|
|
490
|
+
createComponent(Spacing, {}),
|
|
491
|
+
createComponent(VarDeclaration, {
|
|
492
|
+
"export": true,
|
|
493
|
+
"const": true,
|
|
494
|
+
name: "isCI",
|
|
495
|
+
doc: "Detect if the application is running in a continuous integration (CI) environment.",
|
|
496
|
+
initializer: code`Boolean(
|
|
688
497
|
env.CI ||
|
|
689
498
|
env.RUN_ID ||
|
|
690
499
|
env.AGOLA_GIT_REF ||
|
|
@@ -737,66 +546,65 @@ function EnvBuiltin(props) {
|
|
|
737
546
|
env.CI_XCODE_PROJECT ||
|
|
738
547
|
env.XCS || false
|
|
739
548
|
); `
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
549
|
+
}),
|
|
550
|
+
createComponent(Spacing, {}),
|
|
551
|
+
createComponent(TSDoc, {
|
|
552
|
+
heading: "Detect the \\`mode\\` of the current runtime environment.",
|
|
553
|
+
get children() {
|
|
554
|
+
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:
|
|
746
555
|
- \`production\`
|
|
747
556
|
- \`test\`
|
|
748
557
|
- \`development\`
|
|
749
558
|
` });
|
|
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
|
-
}));
|
|
559
|
+
}
|
|
560
|
+
}),
|
|
561
|
+
createComponent(VarDeclaration, {
|
|
562
|
+
"export": true,
|
|
563
|
+
"const": true,
|
|
564
|
+
name: "mode",
|
|
565
|
+
initializer: code`String(env.MODE) || "production"; `
|
|
566
|
+
}),
|
|
567
|
+
createComponent(Spacing, {}),
|
|
568
|
+
createComponent(VarDeclaration, {
|
|
569
|
+
"export": true,
|
|
570
|
+
"const": true,
|
|
571
|
+
name: "isProduction",
|
|
572
|
+
doc: "Detect if the application is running in `\"production\"` mode",
|
|
573
|
+
initializer: code`["prd", "prod", "production"].includes(mode.toLowerCase()); `
|
|
574
|
+
}),
|
|
575
|
+
createComponent(Spacing, {}),
|
|
576
|
+
createComponent(VarDeclaration, {
|
|
577
|
+
"export": true,
|
|
578
|
+
"const": true,
|
|
579
|
+
name: "isTest",
|
|
580
|
+
doc: "Detect if the application is running in `\"test\"` mode",
|
|
581
|
+
initializer: code`["tst", "test", "testing", "stg", "stage", "staging"].includes(mode.toLowerCase()) || env.TEST; `
|
|
582
|
+
}),
|
|
583
|
+
createComponent(Spacing, {}),
|
|
584
|
+
createComponent(VarDeclaration, {
|
|
585
|
+
"export": true,
|
|
586
|
+
"const": true,
|
|
587
|
+
name: "isDevelopment",
|
|
588
|
+
doc: "Detect if the application is running in `\"development\"` mode",
|
|
589
|
+
initializer: code`["dev", "development"].includes(mode.toLowerCase()); `
|
|
590
|
+
}),
|
|
591
|
+
createComponent(Spacing, {}),
|
|
592
|
+
createComponent(VarDeclaration, {
|
|
593
|
+
"export": true,
|
|
594
|
+
"const": true,
|
|
595
|
+
name: "isDebug",
|
|
596
|
+
doc: "Detect if the application is currently being debugged",
|
|
597
|
+
initializer: code`Boolean(isDevelopment && env.DEBUG); `
|
|
598
|
+
}),
|
|
599
|
+
createComponent(Spacing, {}),
|
|
600
|
+
createComponent(Show, {
|
|
601
|
+
get when() {
|
|
602
|
+
return Boolean(children);
|
|
603
|
+
},
|
|
604
|
+
children
|
|
605
|
+
})
|
|
606
|
+
];
|
|
607
|
+
} }));
|
|
800
608
|
}
|
|
801
609
|
EnvBuiltin.__type = [
|
|
802
610
|
() => __ΩEnvBuiltinProps,
|