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