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