@powerlines/plugin-env 0.14.21 → 0.14.23
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/_virtual/rolldown_runtime.cjs +37 -1
- package/dist/_virtual/rolldown_runtime.mjs +29 -1
- package/dist/babel/index.cjs +1 -1
- package/dist/babel/index.mjs +3 -1
- package/dist/babel/plugin.cjs +120 -4
- package/dist/babel/plugin.d.cts +2 -3
- package/dist/babel/plugin.d.mts +3 -2
- package/dist/babel/plugin.mjs +118 -4
- package/dist/components/docs.cjs +71 -1
- package/dist/components/docs.mjs +70 -1
- package/dist/components/env.cjs +432 -11
- package/dist/components/env.mjs +430 -9
- package/dist/components/index.cjs +6 -1
- package/dist/components/index.mjs +4 -1
- package/dist/deepkit/schemas/reflection.cjs +3940 -1
- package/dist/deepkit/schemas/reflection.mjs +3938 -1
- package/dist/deepkit/schemas/reflection2.cjs +4112 -1
- package/dist/deepkit/schemas/reflection2.mjs +4110 -1
- package/dist/deepkit/src/capnp.cjs +913 -1
- package/dist/deepkit/src/capnp.mjs +911 -1
- package/dist/deepkit/src/esbuild-plugin.cjs +47 -4
- package/dist/deepkit/src/esbuild-plugin.mjs +46 -4
- package/dist/deepkit/src/reflect-type.cjs +22 -1
- package/dist/deepkit/src/reflect-type.mjs +20 -1
- package/dist/deepkit/src/resolve-reflections.cjs +16 -1
- package/dist/deepkit/src/resolve-reflections.mjs +15 -1
- package/dist/deepkit/src/transformer.cjs +52 -1
- package/dist/deepkit/src/transformer.mjs +49 -1
- package/dist/deepkit/src/transpile.cjs +29 -1
- package/dist/deepkit/src/transpile.mjs +27 -1
- package/dist/deepkit/src/utilities.cjs +66 -1
- package/dist/deepkit/src/utilities.mjs +65 -1
- package/dist/deepkit/src/vendor/type-compiler/index.cjs +38 -1
- package/dist/deepkit/src/vendor/type-compiler/index.mjs +19 -1
- package/dist/deepkit/src/vendor/type.cjs +20 -1
- package/dist/deepkit/src/vendor/type.mjs +11 -1
- package/dist/helpers/automd-generator.cjs +22 -1
- package/dist/helpers/automd-generator.mjs +21 -1
- package/dist/helpers/create-reflection-resource.cjs +55 -1
- package/dist/helpers/create-reflection-resource.mjs +54 -1
- package/dist/helpers/index.cjs +6 -1
- package/dist/helpers/index.mjs +8 -1
- package/dist/helpers/load.cjs +83 -1
- package/dist/helpers/load.d.cts +2 -2
- package/dist/helpers/load.d.mts +3 -2
- package/dist/helpers/load.mjs +80 -1
- package/dist/helpers/persistence.cjs +214 -1
- package/dist/helpers/persistence.d.cts +1 -1
- package/dist/helpers/persistence.d.mts +1 -1
- package/dist/helpers/persistence.mjs +202 -1
- package/dist/helpers/reflect.cjs +111 -1
- package/dist/helpers/reflect.mjs +103 -1
- package/dist/helpers/source-file-env.cjs +28 -1
- package/dist/helpers/source-file-env.mjs +26 -1
- package/dist/helpers/template-helpers.cjs +42 -1
- package/dist/helpers/template-helpers.mjs +41 -1
- package/dist/index.cjs +203 -5
- package/dist/index.d.cts +1 -3
- package/dist/index.d.mts +2 -1
- package/dist/index.mjs +170 -5
- package/dist/plugin-alloy/src/core/components/output.cjs +45 -1
- package/dist/plugin-alloy/src/core/components/output.mjs +44 -1
- package/dist/plugin-alloy/src/core/contexts/context.cjs +11 -1
- package/dist/plugin-alloy/src/core/contexts/context.mjs +10 -1
- package/dist/plugin-alloy/src/index.cjs +93 -1
- package/dist/plugin-alloy/src/index.mjs +91 -1
- package/dist/plugin-alloy/src/types/plugin.d.cts +2 -2
- package/dist/plugin-alloy/src/types/plugin.d.mts +2 -2
- package/dist/plugin-automd/src/index.cjs +101 -1
- package/dist/plugin-automd/src/index.mjs +98 -1
- package/dist/plugin-automd/src/types/plugin.d.mts +2 -2
- package/dist/plugin-babel/src/helpers/ast-utils.cjs +10 -1
- package/dist/plugin-babel/src/helpers/ast-utils.mjs +9 -1
- package/dist/plugin-babel/src/helpers/create-plugin.cjs +41 -1
- package/dist/plugin-babel/src/helpers/create-plugin.mjs +39 -1
- package/dist/plugin-babel/src/helpers/filters.cjs +23 -1
- package/dist/plugin-babel/src/helpers/filters.mjs +21 -1
- package/dist/plugin-babel/src/helpers/index.cjs +5 -1
- package/dist/plugin-babel/src/helpers/index.mjs +7 -1
- package/dist/plugin-babel/src/helpers/module-helpers.cjs +38 -1
- package/dist/plugin-babel/src/helpers/module-helpers.mjs +35 -1
- package/dist/plugin-babel/src/helpers/options.cjs +50 -1
- package/dist/plugin-babel/src/helpers/options.mjs +47 -1
- package/dist/plugin-babel/src/index.cjs +91 -1
- package/dist/plugin-babel/src/index.mjs +89 -1
- package/dist/plugin-babel/src/types/plugin.d.cts +2 -2
- package/dist/plugin-babel/src/types/plugin.d.mts +2 -2
- package/dist/powerlines/schemas/fs.d.mts +1 -0
- package/dist/powerlines/src/api.d.mts +7 -0
- package/dist/powerlines/src/index.d.mts +12 -0
- package/dist/powerlines/src/internal/helpers/hooks.d.mts +5 -0
- package/dist/powerlines/src/lib/build/esbuild.cjs +102 -14
- package/dist/powerlines/src/lib/build/esbuild.mjs +100 -14
- package/dist/powerlines/src/lib/entry.cjs +12 -1
- package/dist/powerlines/src/lib/entry.mjs +14 -1
- package/dist/powerlines/src/lib/logger.cjs +41 -1
- package/dist/powerlines/src/lib/logger.mjs +39 -1
- package/dist/powerlines/src/lib/utilities/bundle.cjs +35 -1
- package/dist/powerlines/src/lib/utilities/bundle.mjs +34 -1
- package/dist/powerlines/src/lib/utilities/resolve.cjs +30 -1
- package/dist/powerlines/src/lib/utilities/resolve.mjs +29 -1
- package/dist/powerlines/src/plugin-utils/paths.cjs +1 -1
- package/dist/powerlines/src/plugin-utils/paths.mjs +3 -1
- package/dist/powerlines/src/types/api.d.mts +5 -0
- package/dist/powerlines/src/types/babel.d.cts +3 -2
- package/dist/powerlines/src/types/babel.d.mts +3 -2
- package/dist/powerlines/src/types/commands.d.cts +1 -1
- package/dist/powerlines/src/types/commands.d.mts +2 -2
- package/dist/powerlines/src/types/config.d.cts +5 -5
- package/dist/powerlines/src/types/config.d.mts +6 -6
- package/dist/powerlines/src/types/context.d.cts +28 -4
- package/dist/powerlines/src/types/context.d.mts +30 -6
- package/dist/powerlines/src/types/fs.d.cts +1 -1
- package/dist/powerlines/src/types/fs.d.mts +1 -1
- package/dist/powerlines/src/types/index.d.mts +12 -0
- package/dist/powerlines/src/types/plugin.d.cts +3 -3
- package/dist/powerlines/src/types/plugin.d.mts +4 -4
- package/dist/powerlines/src/types/resolved.d.cts +1 -1
- package/dist/powerlines/src/types/resolved.d.mts +2 -2
- package/dist/powerlines/src/types/tsconfig.d.mts +1 -1
- package/dist/powerlines/src/types/unplugin.d.mts +7 -0
- package/dist/types/index.mjs +1 -1
- package/dist/types/plugin.d.cts +1 -1
- package/dist/types/plugin.mjs +1 -1
- package/dist/types/runtime.mjs +1 -1
- package/package.json +16 -16
- package/dist/babel/index.d.cts +0 -1
- package/dist/helpers/index.d.cts +0 -6
package/dist/components/env.mjs
CHANGED
|
@@ -1,10 +1,280 @@
|
|
|
1
|
-
import{type_exports
|
|
2
|
-
|
|
1
|
+
import { type_exports } from "../deepkit/src/vendor/type.mjs";
|
|
2
|
+
import { loadEnvFromContext } from "../helpers/load.mjs";
|
|
3
|
+
import { createReflectionResource } from "../helpers/create-reflection-resource.mjs";
|
|
4
|
+
import { createComponent, createIntrinsic, memo, mergeProps } from "@alloy-js/core/jsx-runtime";
|
|
5
|
+
import { For, Show, code, computed, splitProps } from "@alloy-js/core";
|
|
6
|
+
import defu from "defu";
|
|
7
|
+
import { titleCase } from "@stryke/string-format/title-case";
|
|
8
|
+
import { isNull } from "@stryke/type-checks/is-null";
|
|
9
|
+
import { ClassDeclaration, ClassMethod, ElseIfClause, FunctionDeclaration, IfStatement, NewExpression, TypeDeclaration, VarDeclaration } from "@alloy-js/typescript";
|
|
10
|
+
import { usePowerlines } from "@powerlines/alloy/core/contexts/context";
|
|
11
|
+
import { refkey } from "@powerlines/alloy/helpers/refkey";
|
|
12
|
+
import { BuiltinFile } from "@powerlines/alloy/typescript/components/builtin-file";
|
|
13
|
+
import { TSDoc, TSDocExample, TSDocLink, TSDocParam, TSDocRemarks, TSDocReturns, TSDocThrows } from "@powerlines/alloy/typescript/components/tsdoc";
|
|
14
|
+
import { TypeScriptInterface } from "@powerlines/alloy/typescript/components/typescript-interface";
|
|
15
|
+
import { TypescriptObject } from "@powerlines/alloy/typescript/components/typescript-object";
|
|
16
|
+
|
|
17
|
+
//#region src/components/env.tsx
|
|
18
|
+
/**
|
|
19
|
+
* Generates the environment configuration typescript definition for the Powerlines project.
|
|
20
|
+
*/
|
|
21
|
+
function EnvTypeDefinition(props) {
|
|
22
|
+
const [{ defaultValue, reflection }] = splitProps(props, ["defaultValue", "reflection"]);
|
|
23
|
+
const context = usePowerlines();
|
|
24
|
+
return [
|
|
25
|
+
createComponent(TypeScriptInterface, {
|
|
26
|
+
name: " EnvBase",
|
|
27
|
+
"extends": ["EnvInterface"],
|
|
28
|
+
defaultValue,
|
|
29
|
+
reflection,
|
|
30
|
+
"export": true
|
|
31
|
+
}),
|
|
32
|
+
createIntrinsic("hbr", {}),
|
|
33
|
+
createIntrinsic("hbr", {}),
|
|
34
|
+
createComponent(TypeDeclaration, {
|
|
35
|
+
name: "Env",
|
|
36
|
+
"export": true,
|
|
37
|
+
get children() {
|
|
38
|
+
return code` {
|
|
39
|
+
[Key in keyof EnvBase as Key ${context?.config.env.prefix.map((prefix) => `| \`${prefix.replace(/_$/g, "")}_\${Key}\``).join(" ")}]: EnvBase[Key];
|
|
40
|
+
}
|
|
41
|
+
`;
|
|
42
|
+
}
|
|
43
|
+
})
|
|
44
|
+
];
|
|
45
|
+
}
|
|
46
|
+
function ConfigPropertyConditional(props) {
|
|
47
|
+
const [{ context, name }] = splitProps(props, ["context", "name"]);
|
|
48
|
+
if (!context) return null;
|
|
49
|
+
return code`propertyName === "${name}" || propertyName.replace(/^(${context.config.env.prefix.sort((a, b) => a.startsWith(b) ? -1 : b.startsWith(a) ? 1 : a.localeCompare(b)).map((prefix) => `${prefix.replace(/_$/, "")}_`).join("|")})/g, "").toLowerCase().replace(/[\\s\\-_]+/g, "") === "${name.toLowerCase().replace(/[\s\-_]+/g, "")}"`;
|
|
50
|
+
}
|
|
51
|
+
function ConfigPropertyGet(props) {
|
|
52
|
+
const [{ context, property, index }] = splitProps(props, [
|
|
53
|
+
"context",
|
|
54
|
+
"property",
|
|
55
|
+
"index"
|
|
56
|
+
]);
|
|
57
|
+
if (!context) return null;
|
|
58
|
+
return [index === 0 ? createComponent(IfStatement, {
|
|
59
|
+
get condition() {
|
|
60
|
+
return [createComponent(ConfigPropertyConditional, {
|
|
61
|
+
get name() {
|
|
62
|
+
return property.getNameAsString();
|
|
63
|
+
},
|
|
64
|
+
context
|
|
65
|
+
}), createComponent(Show, {
|
|
66
|
+
get when() {
|
|
67
|
+
return memo(() => !!property.getAlias())() && property.getAlias().length > 0;
|
|
68
|
+
},
|
|
69
|
+
get children() {
|
|
70
|
+
return [code` || `, createComponent(For, {
|
|
71
|
+
get each() {
|
|
72
|
+
return property.getAlias();
|
|
73
|
+
},
|
|
74
|
+
joiner: code` || `,
|
|
75
|
+
children: (alias) => createComponent(ConfigPropertyConditional, {
|
|
76
|
+
name: alias,
|
|
77
|
+
context
|
|
78
|
+
})
|
|
79
|
+
})];
|
|
80
|
+
}
|
|
81
|
+
})];
|
|
82
|
+
},
|
|
83
|
+
get children() {
|
|
84
|
+
return code`return target["${property.getNameAsString()}"];`;
|
|
85
|
+
}
|
|
86
|
+
}) : createComponent(ElseIfClause, {
|
|
87
|
+
get condition() {
|
|
88
|
+
return [createComponent(ConfigPropertyConditional, {
|
|
89
|
+
get name() {
|
|
90
|
+
return property.getNameAsString();
|
|
91
|
+
},
|
|
92
|
+
context
|
|
93
|
+
}), createComponent(Show, {
|
|
94
|
+
get when() {
|
|
95
|
+
return memo(() => !!property.getAlias())() && property.getAlias().length > 0;
|
|
96
|
+
},
|
|
97
|
+
get children() {
|
|
98
|
+
return [code` || `, createComponent(For, {
|
|
99
|
+
get each() {
|
|
100
|
+
return property.getAlias();
|
|
101
|
+
},
|
|
102
|
+
joiner: code` || `,
|
|
103
|
+
children: (alias) => createComponent(ConfigPropertyConditional, {
|
|
104
|
+
name: alias,
|
|
105
|
+
context
|
|
106
|
+
})
|
|
107
|
+
})];
|
|
108
|
+
}
|
|
109
|
+
})];
|
|
110
|
+
},
|
|
111
|
+
get children() {
|
|
112
|
+
return code`return target["${property.getNameAsString()}"];`;
|
|
113
|
+
}
|
|
114
|
+
})];
|
|
3
115
|
}
|
|
4
|
-
|
|
5
|
-
|
|
116
|
+
function ConfigPropertySet(props) {
|
|
117
|
+
const [{ context, property, index }] = splitProps(props, [
|
|
118
|
+
"context",
|
|
119
|
+
"property",
|
|
120
|
+
"index"
|
|
121
|
+
]);
|
|
122
|
+
if (!context) return null;
|
|
123
|
+
return [index === 0 ? createComponent(IfStatement, {
|
|
124
|
+
get condition() {
|
|
125
|
+
return [createComponent(ConfigPropertyConditional, {
|
|
126
|
+
get name() {
|
|
127
|
+
return property.getNameAsString();
|
|
128
|
+
},
|
|
129
|
+
context
|
|
130
|
+
}), createComponent(Show, {
|
|
131
|
+
get when() {
|
|
132
|
+
return memo(() => !!property.getAlias())() && property.getAlias().length > 0;
|
|
133
|
+
},
|
|
134
|
+
get children() {
|
|
135
|
+
return [code` || `, createComponent(For, {
|
|
136
|
+
get each() {
|
|
137
|
+
return property.getAlias();
|
|
138
|
+
},
|
|
139
|
+
joiner: code` || `,
|
|
140
|
+
children: (alias) => createComponent(ConfigPropertyConditional, {
|
|
141
|
+
name: alias,
|
|
142
|
+
context
|
|
143
|
+
})
|
|
144
|
+
})];
|
|
145
|
+
}
|
|
146
|
+
})];
|
|
147
|
+
},
|
|
148
|
+
get children() {
|
|
149
|
+
return code`
|
|
150
|
+
target["${property.getNameAsString()}"] = newValue;
|
|
6
151
|
return true;
|
|
7
|
-
|
|
152
|
+
`;
|
|
153
|
+
}
|
|
154
|
+
}) : createComponent(ElseIfClause, {
|
|
155
|
+
get condition() {
|
|
156
|
+
return [createComponent(ConfigPropertyConditional, {
|
|
157
|
+
get name() {
|
|
158
|
+
return property.getNameAsString();
|
|
159
|
+
},
|
|
160
|
+
context
|
|
161
|
+
}), createComponent(Show, {
|
|
162
|
+
get when() {
|
|
163
|
+
return memo(() => !!property.getAlias())() && property.getAlias().length > 0;
|
|
164
|
+
},
|
|
165
|
+
get children() {
|
|
166
|
+
return [code` || `, createComponent(For, {
|
|
167
|
+
get each() {
|
|
168
|
+
return property.getAlias();
|
|
169
|
+
},
|
|
170
|
+
joiner: code` || `,
|
|
171
|
+
children: (alias) => createComponent(ConfigPropertyConditional, {
|
|
172
|
+
name: alias,
|
|
173
|
+
context
|
|
174
|
+
})
|
|
175
|
+
})];
|
|
176
|
+
}
|
|
177
|
+
})];
|
|
178
|
+
},
|
|
179
|
+
get children() {
|
|
180
|
+
return code`
|
|
181
|
+
target["${property.getNameAsString()}"] = newValue;
|
|
182
|
+
return true;
|
|
183
|
+
`;
|
|
184
|
+
}
|
|
185
|
+
})];
|
|
186
|
+
}
|
|
187
|
+
const createEnvRefkey = refkey("createEnv");
|
|
188
|
+
const envRefkey = refkey("env");
|
|
189
|
+
const envSerializerRefkey = refkey("EnvSerializer");
|
|
190
|
+
/**
|
|
191
|
+
* Generates the environment configuration module for the Powerlines project.
|
|
192
|
+
*/
|
|
193
|
+
function EnvBuiltin(props) {
|
|
194
|
+
const [{ defaultConfig }, rest] = splitProps(props, ["defaultConfig"]);
|
|
195
|
+
const context = usePowerlines();
|
|
196
|
+
const defaultValue = computed(() => context && loadEnvFromContext(context, process.env));
|
|
197
|
+
const reflection = createReflectionResource(context);
|
|
198
|
+
const envInstance = computed(() => {
|
|
199
|
+
return new type_exports.ReflectionClass({
|
|
200
|
+
kind: type_exports.ReflectionKind.objectLiteral,
|
|
201
|
+
description: `The initial environment configuration state for the ${titleCase(context?.config?.name)} project.`,
|
|
202
|
+
types: []
|
|
203
|
+
}, reflection.data ?? void 0);
|
|
204
|
+
});
|
|
205
|
+
const reflectionGetProperties = computed(() => reflection.data?.getProperties().filter((property) => !property.isIgnored()).sort((a, b) => a.getNameAsString().localeCompare(b.getNameAsString())) ?? []);
|
|
206
|
+
const reflectionSetProperties = computed(() => reflection.data?.getProperties().filter((property) => !property.isIgnored() && !property.isReadonly()).sort((a, b) => a.getNameAsString().localeCompare(b.getNameAsString())) ?? []);
|
|
207
|
+
return createComponent(BuiltinFile, mergeProps(rest, {
|
|
208
|
+
id: "env",
|
|
209
|
+
description: "The Powerlines environment configuration module provides an interface to define environment configuration parameters.",
|
|
210
|
+
get imports() {
|
|
211
|
+
return defu({
|
|
212
|
+
"@powerlines/deepkit/vendor/type": [
|
|
213
|
+
"Type",
|
|
214
|
+
"stringify",
|
|
215
|
+
"serializer",
|
|
216
|
+
"serializeFunction",
|
|
217
|
+
"deserializeFunction",
|
|
218
|
+
"ReflectionKind",
|
|
219
|
+
"TemplateState",
|
|
220
|
+
"Serializer",
|
|
221
|
+
"TypeProperty",
|
|
222
|
+
"TypePropertySignature"
|
|
223
|
+
],
|
|
224
|
+
"@powerlines/plugin-env/types/runtime": [{ name: "EnvInterface" }]
|
|
225
|
+
}, rest.imports ?? {});
|
|
226
|
+
},
|
|
227
|
+
get children() {
|
|
228
|
+
return [
|
|
229
|
+
createComponent(Show, {
|
|
230
|
+
get when() {
|
|
231
|
+
return !isNull(reflection.data);
|
|
232
|
+
},
|
|
233
|
+
get children() {
|
|
234
|
+
return [
|
|
235
|
+
createComponent(EnvTypeDefinition, {
|
|
236
|
+
get defaultValue() {
|
|
237
|
+
return defaultValue.value;
|
|
238
|
+
},
|
|
239
|
+
get reflection() {
|
|
240
|
+
return reflection.data;
|
|
241
|
+
}
|
|
242
|
+
}),
|
|
243
|
+
createIntrinsic("hbr", {}),
|
|
244
|
+
createIntrinsic("hbr", {})
|
|
245
|
+
];
|
|
246
|
+
}
|
|
247
|
+
}),
|
|
248
|
+
createComponent(TypescriptObject, {
|
|
249
|
+
name: "initialEnv",
|
|
250
|
+
type: "Partial<EnvBase>",
|
|
251
|
+
defaultValue,
|
|
252
|
+
reflection: envInstance,
|
|
253
|
+
"export": true,
|
|
254
|
+
"const": true
|
|
255
|
+
}),
|
|
256
|
+
createIntrinsic("hbr", {}),
|
|
257
|
+
createIntrinsic("hbr", {}),
|
|
258
|
+
createComponent(TSDoc, {
|
|
259
|
+
heading: "The environment configuration serializer for the Powerlines application.",
|
|
260
|
+
get children() {
|
|
261
|
+
return [
|
|
262
|
+
createComponent(TSDocLink, { children: `https://deepkit.io/docs/serialization/serializers` }),
|
|
263
|
+
createComponent(TSDocLink, { children: `https://github.com/marcj/untitled-code/blob/master/packages/type/src/serializer.ts#L1918` }),
|
|
264
|
+
createComponent(TSDocRemarks, { children: `This serializer is used to serialize and deserialize the Powerlines environment configuration.` })
|
|
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
|
+
children: code`
|
|
8
278
|
super("env");
|
|
9
279
|
|
|
10
280
|
this.deserializeRegistry.register(
|
|
@@ -15,17 +285,168 @@ import{type_exports as e}from"../deepkit/src/vendor/type.mjs";import{loadEnvFrom
|
|
|
15
285
|
);
|
|
16
286
|
}
|
|
17
287
|
);
|
|
18
|
-
`
|
|
288
|
+
`
|
|
289
|
+
});
|
|
290
|
+
}
|
|
291
|
+
}),
|
|
292
|
+
createIntrinsic("hbr", {}),
|
|
293
|
+
createIntrinsic("hbr", {}),
|
|
294
|
+
createComponent(TSDoc, {
|
|
295
|
+
heading: "A {@link EnvSerializer | environment configuration serializer} instance for the Powerlines application.",
|
|
296
|
+
get children() {
|
|
297
|
+
return [
|
|
298
|
+
createComponent(TSDocLink, { children: `https://deepkit.io/docs/serialization/serializers` }),
|
|
299
|
+
createComponent(TSDocLink, { children: `https://github.com/marcj/untitled-code/blob/master/packages/type/src/serializer.ts#L1918` }),
|
|
300
|
+
createComponent(TSDocRemarks, { children: `This serializer is used to serialize and deserialize the Powerlines environment configuration.` })
|
|
301
|
+
];
|
|
302
|
+
}
|
|
303
|
+
}),
|
|
304
|
+
createComponent(VarDeclaration, {
|
|
305
|
+
name: "envSerializer",
|
|
306
|
+
"export": false,
|
|
307
|
+
"const": true,
|
|
308
|
+
get initializer() {
|
|
309
|
+
return createComponent(NewExpression, {
|
|
310
|
+
args: [],
|
|
311
|
+
target: "EnvSerializer"
|
|
312
|
+
});
|
|
313
|
+
}
|
|
314
|
+
}),
|
|
315
|
+
createIntrinsic("hbr", {}),
|
|
316
|
+
createIntrinsic("hbr", {}),
|
|
317
|
+
createComponent(TSDoc, {
|
|
318
|
+
heading: "Serialize a environment configuration object to JSON data objects (not a JSON string).",
|
|
319
|
+
get children() {
|
|
320
|
+
return [
|
|
321
|
+
createComponent(TSDocRemarks, { children: `The resulting JSON object can be stringified using JSON.stringify().` }),
|
|
322
|
+
createComponent(TSDocExample, { children: `const json = serializeEnv(env);` }),
|
|
323
|
+
createComponent(TSDocThrows, { children: `ValidationError when serialization or validation fails.` })
|
|
324
|
+
];
|
|
325
|
+
}
|
|
326
|
+
}),
|
|
327
|
+
createComponent(VarDeclaration, {
|
|
328
|
+
name: "serializeEnv",
|
|
329
|
+
"export": true,
|
|
330
|
+
"const": true,
|
|
331
|
+
initializer: "serializeFunction<EnvBase>(envSerializer)"
|
|
332
|
+
}),
|
|
333
|
+
createIntrinsic("hbr", {}),
|
|
334
|
+
createIntrinsic("hbr", {}),
|
|
335
|
+
createComponent(TSDoc, {
|
|
336
|
+
heading: "Deserialize a environment configuration object from JSON data objects to JavaScript objects, without running any validators.",
|
|
337
|
+
get children() {
|
|
338
|
+
return [
|
|
339
|
+
createComponent(TSDocRemarks, { children: `Types that are already correct will be used as-is.` }),
|
|
340
|
+
createComponent(TSDocExample, { children: `const env = deserializeEnv(json);` }),
|
|
341
|
+
createComponent(TSDocThrows, { children: `ValidationError when deserialization fails.` })
|
|
342
|
+
];
|
|
343
|
+
}
|
|
344
|
+
}),
|
|
345
|
+
createComponent(VarDeclaration, {
|
|
346
|
+
name: "deserializeEnv",
|
|
347
|
+
"export": true,
|
|
348
|
+
"const": true,
|
|
349
|
+
initializer: "deserializeFunction<EnvBase>(envSerializer)"
|
|
350
|
+
}),
|
|
351
|
+
createIntrinsic("hbr", {}),
|
|
352
|
+
createIntrinsic("hbr", {}),
|
|
353
|
+
createComponent(TSDoc, {
|
|
354
|
+
heading: "Initializes the Powerlines environment configuration module.",
|
|
355
|
+
get children() {
|
|
356
|
+
return [
|
|
357
|
+
createComponent(TSDocRemarks, { children: `This function initializes the Powerlines environment configuration object.` }),
|
|
358
|
+
createComponent(TSDocParam, {
|
|
359
|
+
name: "environmentConfig",
|
|
360
|
+
children: `The dynamic/runtime configuration - this could include the current environment variables or any other environment-specific settings provided by the runtime.`
|
|
361
|
+
}),
|
|
362
|
+
createComponent(TSDocReturns, { children: `The initialized Powerlines configuration object.` })
|
|
363
|
+
];
|
|
364
|
+
}
|
|
365
|
+
}),
|
|
366
|
+
createComponent(Show, {
|
|
367
|
+
get when() {
|
|
368
|
+
return Boolean(context?.entryPath);
|
|
369
|
+
},
|
|
370
|
+
get children() {
|
|
371
|
+
return createComponent(FunctionDeclaration, {
|
|
372
|
+
refkey: createEnvRefkey,
|
|
373
|
+
async: false,
|
|
374
|
+
"export": true,
|
|
375
|
+
name: "createEnv",
|
|
376
|
+
parameters: [{
|
|
377
|
+
name: "environmentConfig",
|
|
378
|
+
type: `Partial<Env>`,
|
|
379
|
+
optional: false,
|
|
380
|
+
default: "{}"
|
|
381
|
+
}],
|
|
382
|
+
returnType: "Env",
|
|
383
|
+
get children() {
|
|
384
|
+
return [
|
|
385
|
+
code`
|
|
19
386
|
return new Proxy<Env>(
|
|
20
387
|
deserializeEnv({
|
|
21
388
|
...initialEnv,
|
|
22
389
|
...environmentConfig
|
|
23
390
|
}) as Env,
|
|
24
391
|
{
|
|
25
|
-
get: (target: EnvBase, propertyName: string) => { `,
|
|
392
|
+
get: (target: EnvBase, propertyName: string) => { `,
|
|
393
|
+
createIntrinsic("hbr", {}),
|
|
394
|
+
createComponent(For, {
|
|
395
|
+
each: reflectionGetProperties,
|
|
396
|
+
children: (property, index) => createComponent(ConfigPropertyGet, {
|
|
397
|
+
index,
|
|
398
|
+
context,
|
|
399
|
+
property
|
|
400
|
+
})
|
|
401
|
+
}),
|
|
402
|
+
code`
|
|
26
403
|
return undefined;
|
|
27
|
-
}, `,
|
|
404
|
+
}, `,
|
|
405
|
+
createIntrinsic("hbr", {}),
|
|
406
|
+
createIntrinsic("hbr", {}),
|
|
407
|
+
code` set: (target: EnvBase, propertyName: string, newValue: any) => { `,
|
|
408
|
+
createIntrinsic("hbr", {}),
|
|
409
|
+
createComponent(For, {
|
|
410
|
+
each: reflectionSetProperties,
|
|
411
|
+
ender: code` else `,
|
|
412
|
+
children: (property, index) => createComponent(ConfigPropertySet, {
|
|
413
|
+
index,
|
|
414
|
+
context,
|
|
415
|
+
property
|
|
416
|
+
})
|
|
417
|
+
}),
|
|
418
|
+
createIntrinsic("hbr", {}),
|
|
419
|
+
code`return false;
|
|
28
420
|
}
|
|
29
421
|
}
|
|
30
422
|
);
|
|
31
|
-
`
|
|
423
|
+
`
|
|
424
|
+
];
|
|
425
|
+
}
|
|
426
|
+
});
|
|
427
|
+
}
|
|
428
|
+
}),
|
|
429
|
+
createIntrinsic("hbr", {}),
|
|
430
|
+
createIntrinsic("hbr", {}),
|
|
431
|
+
createIntrinsic("hbr", {}),
|
|
432
|
+
createComponent(VarDeclaration, {
|
|
433
|
+
refkey: envRefkey,
|
|
434
|
+
name: "env",
|
|
435
|
+
type: "Env",
|
|
436
|
+
"export": true,
|
|
437
|
+
"const": true,
|
|
438
|
+
get initializer() {
|
|
439
|
+
return [
|
|
440
|
+
code`createEnv(`,
|
|
441
|
+
defaultConfig || "{}",
|
|
442
|
+
code` as Partial<Env>)`
|
|
443
|
+
];
|
|
444
|
+
}
|
|
445
|
+
})
|
|
446
|
+
];
|
|
447
|
+
}
|
|
448
|
+
}));
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
//#endregion
|
|
452
|
+
export { EnvBuiltin, EnvTypeDefinition };
|
|
@@ -1 +1,6 @@
|
|
|
1
|
-
const
|
|
1
|
+
const require_components_env = require('./env.cjs');
|
|
2
|
+
const require_components_docs = require('./docs.cjs');
|
|
3
|
+
|
|
4
|
+
exports.EnvBuiltin = require_components_env.EnvBuiltin;
|
|
5
|
+
exports.EnvDocs = require_components_docs.EnvDocs;
|
|
6
|
+
exports.EnvTypeDefinition = require_components_env.EnvTypeDefinition;
|
|
@@ -1 +1,4 @@
|
|
|
1
|
-
import{EnvBuiltin
|
|
1
|
+
import { EnvBuiltin, EnvTypeDefinition } from "./env.mjs";
|
|
2
|
+
import { EnvDocs } from "./docs.mjs";
|
|
3
|
+
|
|
4
|
+
export { EnvBuiltin, EnvDocs, EnvTypeDefinition };
|