@powerlines/plugin-env 0.16.66 → 0.16.68
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 +0 -2
- package/dist/_virtual/_rolldown/runtime.mjs +2 -31
- package/dist/babel/plugin.cjs +83 -11
- package/dist/babel/plugin.mjs +83 -11
- package/dist/babel/plugin.mjs.map +1 -1
- package/dist/components/env-builtin.cjs +1 -1
- package/dist/components/env-builtin.mjs +1 -1
- package/dist/helpers/automd-generator.cjs +14 -4
- package/dist/helpers/automd-generator.d.mts +1 -1
- package/dist/helpers/automd-generator.mjs +14 -4
- package/dist/helpers/automd-generator.mjs.map +1 -1
- package/dist/helpers/create-reflection-resource.cjs +8 -0
- package/dist/helpers/create-reflection-resource.mjs +9 -0
- package/dist/helpers/create-reflection-resource.mjs.map +1 -1
- package/dist/helpers/docs-helper.cjs +8 -0
- package/dist/helpers/docs-helper.mjs +8 -0
- package/dist/helpers/docs-helper.mjs.map +1 -1
- package/dist/helpers/index.cjs +1 -0
- package/dist/helpers/index.mjs +2 -2
- package/dist/helpers/load.cjs +61 -10
- package/dist/helpers/load.mjs +60 -9
- package/dist/helpers/load.mjs.map +1 -1
- package/dist/helpers/persistence.cjs +108 -1
- package/dist/helpers/persistence.mjs +108 -1
- package/dist/helpers/persistence.mjs.map +1 -1
- package/dist/helpers/reflect.cjs +156 -3
- package/dist/helpers/reflect.mjs +156 -4
- package/dist/helpers/reflect.mjs.map +1 -1
- package/dist/helpers/source-file-env.cjs +34 -4
- package/dist/helpers/source-file-env.mjs +34 -4
- package/dist/helpers/source-file-env.mjs.map +1 -1
- package/dist/helpers/template-helpers.cjs +33 -5
- package/dist/helpers/template-helpers.mjs +33 -5
- package/dist/helpers/template-helpers.mjs.map +1 -1
- package/dist/types/index.cjs +11 -0
- package/dist/types/index.mjs +4 -1
- package/dist/types/plugin.cjs +137 -0
- package/dist/types/plugin.d.mts +4 -4
- package/dist/types/plugin.mjs +132 -1
- package/dist/types/plugin.mjs.map +1 -0
- package/dist/types/runtime.cjs +244 -0
- package/dist/types/runtime.mjs +242 -1
- package/dist/types/runtime.mjs.map +1 -0
- package/package.json +11 -26
- package/dist/node_modules/.pnpm/c12@3.3.3_magicast@0.5.2/node_modules/c12/dist/index.cjs +0 -346
- package/dist/node_modules/.pnpm/c12@3.3.3_magicast@0.5.2/node_modules/c12/dist/index.mjs +0 -347
- package/dist/node_modules/.pnpm/c12@3.3.3_magicast@0.5.2/node_modules/c12/dist/index.mjs.map +0 -1
- package/dist/node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/_chunks/_format.cjs +0 -23
- package/dist/node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/_chunks/_format.mjs +0 -23
- package/dist/node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/_chunks/_format.mjs.map +0 -1
- package/dist/node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/_chunks/json.cjs +0 -10
- package/dist/node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/_chunks/json.mjs +0 -11
- package/dist/node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/_chunks/json.mjs.map +0 -1
- package/dist/node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/_chunks/libs/js-yaml.cjs +0 -1060
- package/dist/node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/_chunks/libs/js-yaml.mjs +0 -1060
- package/dist/node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/_chunks/libs/js-yaml.mjs.map +0 -1
- package/dist/node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/_chunks/libs/json5.cjs +0 -761
- package/dist/node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/_chunks/libs/json5.mjs +0 -761
- package/dist/node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/_chunks/libs/json5.mjs.map +0 -1
- package/dist/node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/_chunks/libs/jsonc-parser.cjs +0 -388
- package/dist/node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/_chunks/libs/jsonc-parser.mjs +0 -388
- package/dist/node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/_chunks/libs/jsonc-parser.mjs.map +0 -1
- package/dist/node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/_chunks/libs/smol-toml.cjs +0 -639
- package/dist/node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/_chunks/libs/smol-toml.mjs +0 -639
- package/dist/node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/_chunks/libs/smol-toml.mjs.map +0 -1
- package/dist/node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/_chunks/rolldown-runtime.cjs +0 -17
- package/dist/node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/_chunks/rolldown-runtime.mjs +0 -15
- package/dist/node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/_chunks/rolldown-runtime.mjs.map +0 -1
- package/dist/node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/json5.cjs +0 -13
- package/dist/node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/json5.mjs +0 -14
- package/dist/node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/json5.mjs.map +0 -1
- package/dist/node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/jsonc.cjs +0 -11
- package/dist/node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/jsonc.mjs +0 -12
- package/dist/node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/jsonc.mjs.map +0 -1
- package/dist/node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/toml.cjs +0 -11
- package/dist/node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/toml.mjs +0 -12
- package/dist/node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/toml.mjs.map +0 -1
- package/dist/node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/yaml.cjs +0 -11
- package/dist/node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/yaml.mjs +0 -12
- package/dist/node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/yaml.mjs.map +0 -1
- package/dist/node_modules/.pnpm/destr@2.0.5/node_modules/destr/dist/index.cjs +0 -46
- package/dist/node_modules/.pnpm/destr@2.0.5/node_modules/destr/dist/index.mjs +0 -46
- package/dist/node_modules/.pnpm/destr@2.0.5/node_modules/destr/dist/index.mjs.map +0 -1
- package/dist/node_modules/.pnpm/dotenv@17.3.1/node_modules/dotenv/lib/main.cjs +0 -285
- package/dist/node_modules/.pnpm/dotenv@17.3.1/node_modules/dotenv/lib/main.mjs +0 -283
- package/dist/node_modules/.pnpm/dotenv@17.3.1/node_modules/dotenv/lib/main.mjs.map +0 -1
- package/dist/node_modules/.pnpm/dotenv@17.3.1/node_modules/dotenv/package.cjs +0 -71
- package/dist/node_modules/.pnpm/dotenv@17.3.1/node_modules/dotenv/package.mjs +0 -69
- package/dist/node_modules/.pnpm/dotenv@17.3.1/node_modules/dotenv/package.mjs.map +0 -1
- package/dist/node_modules/.pnpm/exsolve@1.0.8/node_modules/exsolve/dist/index.cjs +0 -1013
- package/dist/node_modules/.pnpm/exsolve@1.0.8/node_modules/exsolve/dist/index.mjs +0 -1008
- package/dist/node_modules/.pnpm/exsolve@1.0.8/node_modules/exsolve/dist/index.mjs.map +0 -1
- package/dist/node_modules/.pnpm/giget@2.0.0/node_modules/giget/dist/index.cjs +0 -23
- package/dist/node_modules/.pnpm/giget@2.0.0/node_modules/giget/dist/index.mjs +0 -10
- package/dist/node_modules/.pnpm/giget@2.0.0/node_modules/giget/dist/index.mjs.map +0 -1
- package/dist/node_modules/.pnpm/giget@2.0.0/node_modules/giget/dist/shared/giget.OCaTp9b-.cjs +0 -2695
- package/dist/node_modules/.pnpm/giget@2.0.0/node_modules/giget/dist/shared/giget.OCaTp9b-.mjs +0 -2682
- package/dist/node_modules/.pnpm/giget@2.0.0/node_modules/giget/dist/shared/giget.OCaTp9b-.mjs.map +0 -1
- package/dist/node_modules/.pnpm/jiti@2.6.1/node_modules/jiti/dist/jiti.cjs +0 -4457
- package/dist/node_modules/.pnpm/jiti@2.6.1/node_modules/jiti/dist/jiti.mjs +0 -4455
- package/dist/node_modules/.pnpm/jiti@2.6.1/node_modules/jiti/dist/jiti.mjs.map +0 -1
- package/dist/node_modules/.pnpm/jiti@2.6.1/node_modules/jiti/lib/jiti.cjs +0 -29
- package/dist/node_modules/.pnpm/jiti@2.6.1/node_modules/jiti/lib/jiti.mjs +0 -30
- package/dist/node_modules/.pnpm/jiti@2.6.1/node_modules/jiti/lib/jiti.mjs.map +0 -1
- package/dist/node_modules/.pnpm/node-fetch-native@1.6.7/node_modules/node-fetch-native/dist/chunks/multipart-parser.cjs +0 -181
- package/dist/node_modules/.pnpm/node-fetch-native@1.6.7/node_modules/node-fetch-native/dist/chunks/multipart-parser.mjs +0 -177
- package/dist/node_modules/.pnpm/node-fetch-native@1.6.7/node_modules/node-fetch-native/dist/chunks/multipart-parser.mjs.map +0 -1
- package/dist/node_modules/.pnpm/node-fetch-native@1.6.7/node_modules/node-fetch-native/dist/index.cjs +0 -22
- package/dist/node_modules/.pnpm/node-fetch-native@1.6.7/node_modules/node-fetch-native/dist/index.mjs +0 -18
- package/dist/node_modules/.pnpm/node-fetch-native@1.6.7/node_modules/node-fetch-native/dist/index.mjs.map +0 -1
- package/dist/node_modules/.pnpm/node-fetch-native@1.6.7/node_modules/node-fetch-native/dist/node.cjs +0 -3967
- package/dist/node_modules/.pnpm/node-fetch-native@1.6.7/node_modules/node-fetch-native/dist/node.mjs +0 -3963
- package/dist/node_modules/.pnpm/node-fetch-native@1.6.7/node_modules/node-fetch-native/dist/node.mjs.map +0 -1
- package/dist/node_modules/.pnpm/node-fetch-native@1.6.7/node_modules/node-fetch-native/dist/proxy.cjs +0 -11766
- package/dist/node_modules/.pnpm/node-fetch-native@1.6.7/node_modules/node-fetch-native/dist/proxy.mjs +0 -11762
- package/dist/node_modules/.pnpm/node-fetch-native@1.6.7/node_modules/node-fetch-native/dist/proxy.mjs.map +0 -1
- package/dist/node_modules/.pnpm/node-fetch-native@1.6.7/node_modules/node-fetch-native/dist/shared/node-fetch-native.DhEqb06g.cjs +0 -25
- package/dist/node_modules/.pnpm/node-fetch-native@1.6.7/node_modules/node-fetch-native/dist/shared/node-fetch-native.DhEqb06g.mjs +0 -21
- package/dist/node_modules/.pnpm/node-fetch-native@1.6.7/node_modules/node-fetch-native/dist/shared/node-fetch-native.DhEqb06g.mjs.map +0 -1
- package/dist/node_modules/.pnpm/node-fetch-native@1.6.7/node_modules/node-fetch-native/lib/index.cjs +0 -20
- package/dist/node_modules/.pnpm/node-fetch-native@1.6.7/node_modules/node-fetch-native/lib/index.mjs +0 -18
- package/dist/node_modules/.pnpm/node-fetch-native@1.6.7/node_modules/node-fetch-native/lib/index.mjs.map +0 -1
- package/dist/node_modules/.pnpm/nypm@0.6.5/node_modules/nypm/dist/index.cjs +0 -178
- package/dist/node_modules/.pnpm/nypm@0.6.5/node_modules/nypm/dist/index.mjs +0 -176
- package/dist/node_modules/.pnpm/nypm@0.6.5/node_modules/nypm/dist/index.mjs.map +0 -1
- package/dist/node_modules/.pnpm/ohash@2.0.11/node_modules/ohash/dist/crypto/node/index.cjs +0 -13
- package/dist/node_modules/.pnpm/ohash@2.0.11/node_modules/ohash/dist/crypto/node/index.mjs +0 -13
- package/dist/node_modules/.pnpm/ohash@2.0.11/node_modules/ohash/dist/crypto/node/index.mjs.map +0 -1
- package/dist/node_modules/.pnpm/ohash@2.0.11/node_modules/ohash/dist/index.cjs +0 -3
- package/dist/node_modules/.pnpm/ohash@2.0.11/node_modules/ohash/dist/index.mjs +0 -3
- package/dist/node_modules/.pnpm/pathe@2.0.3/node_modules/pathe/dist/shared/pathe.M-eThtNZ.cjs +0 -145
- package/dist/node_modules/.pnpm/pathe@2.0.3/node_modules/pathe/dist/shared/pathe.M-eThtNZ.mjs +0 -139
- package/dist/node_modules/.pnpm/pathe@2.0.3/node_modules/pathe/dist/shared/pathe.M-eThtNZ.mjs.map +0 -1
- package/dist/node_modules/.pnpm/pkg-types@2.3.0/node_modules/pkg-types/dist/index.cjs +0 -128
- package/dist/node_modules/.pnpm/pkg-types@2.3.0/node_modules/pkg-types/dist/index.mjs +0 -127
- package/dist/node_modules/.pnpm/pkg-types@2.3.0/node_modules/pkg-types/dist/index.mjs.map +0 -1
- package/dist/node_modules/.pnpm/rc9@2.1.2/node_modules/rc9/dist/index.cjs +0 -138
- package/dist/node_modules/.pnpm/rc9@2.1.2/node_modules/rc9/dist/index.mjs +0 -137
- package/dist/node_modules/.pnpm/rc9@2.1.2/node_modules/rc9/dist/index.mjs.map +0 -1
- package/dist/node_modules/.pnpm/tinyexec@1.0.2/node_modules/tinyexec/dist/main.cjs +0 -629
- package/dist/node_modules/.pnpm/tinyexec@1.0.2/node_modules/tinyexec/dist/main.mjs +0 -628
- package/dist/node_modules/.pnpm/tinyexec@1.0.2/node_modules/tinyexec/dist/main.mjs.map +0 -1
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import { __ΩEnvPluginContext, __ΩEnvPluginResolvedConfig, __ΩEnvType } from "../types/plugin.mjs";
|
|
1
2
|
import { createEnvReflection } from "./reflect.mjs";
|
|
3
|
+
import { ReflectionClass, ReflectionKind, deserializeType, resolveClassType } from "@powerlines/deepkit/vendor/type";
|
|
4
|
+
import { __ΩContext, __ΩUnresolvedContext } from "powerlines";
|
|
2
5
|
import { convertFromCapnp, convertToCapnp } from "@powerlines/deepkit/capnp";
|
|
3
6
|
import { getReflectionsPath } from "@powerlines/deepkit/resolve-reflections";
|
|
4
7
|
import { SerializedTypes } from "@powerlines/deepkit/schemas/reflection";
|
|
5
|
-
import { ReflectionKind, deserializeType, resolveClassType } from "@powerlines/deepkit/vendor/type";
|
|
6
8
|
import * as capnp from "@stryke/capnp";
|
|
7
9
|
import { readFileBuffer, writeFileBuffer, writeFileBufferSync } from "@stryke/fs/buffer";
|
|
8
10
|
import { joinPaths } from "@stryke/path/join-paths";
|
|
@@ -21,6 +23,14 @@ async function resolveRuntimeTypeFile(context) {
|
|
|
21
23
|
if (!resolved) throw new Error(`Failed to resolve the runtime type definition file for the environment variables. Please ensure that the "@powerlines/plugin-env" package is installed.`);
|
|
22
24
|
return resolved;
|
|
23
25
|
}
|
|
26
|
+
resolveRuntimeTypeFile.__type = [
|
|
27
|
+
() => __ΩUnresolvedContext,
|
|
28
|
+
() => __ΩEnvPluginResolvedConfig,
|
|
29
|
+
"context",
|
|
30
|
+
"resolveRuntimeTypeFile",
|
|
31
|
+
"Resolves the runtime type definition file for the environment variables.",
|
|
32
|
+
"Pn\"o!\"2#&`/$?%"
|
|
33
|
+
];
|
|
24
34
|
/**
|
|
25
35
|
* Gets the default type definition for the environment variables.
|
|
26
36
|
*
|
|
@@ -33,6 +43,14 @@ async function getEnvDefaultTypeDefinition(context) {
|
|
|
33
43
|
name: "EnvInterface"
|
|
34
44
|
};
|
|
35
45
|
}
|
|
46
|
+
getEnvDefaultTypeDefinition.__type = [
|
|
47
|
+
() => __ΩUnresolvedContext,
|
|
48
|
+
() => __ΩEnvPluginResolvedConfig,
|
|
49
|
+
"context",
|
|
50
|
+
"getEnvDefaultTypeDefinition",
|
|
51
|
+
"Gets the default type definition for the environment variables.",
|
|
52
|
+
"Pn\"o!\"2#!`/$?%"
|
|
53
|
+
];
|
|
36
54
|
/** Gets the default type definition for the environment secrets.
|
|
37
55
|
*
|
|
38
56
|
* @param context - The plugin context.
|
|
@@ -44,6 +62,13 @@ async function getSecretsDefaultTypeDefinition(context) {
|
|
|
44
62
|
name: "SecretsInterface"
|
|
45
63
|
};
|
|
46
64
|
}
|
|
65
|
+
getSecretsDefaultTypeDefinition.__type = [
|
|
66
|
+
() => __ΩUnresolvedContext,
|
|
67
|
+
() => __ΩEnvPluginResolvedConfig,
|
|
68
|
+
"context",
|
|
69
|
+
"getSecretsDefaultTypeDefinition",
|
|
70
|
+
"Pn\"o!\"2#!`/$"
|
|
71
|
+
];
|
|
47
72
|
/**
|
|
48
73
|
* Gets the path to the environment type reflections.
|
|
49
74
|
*
|
|
@@ -54,6 +79,17 @@ async function getSecretsDefaultTypeDefinition(context) {
|
|
|
54
79
|
function getEnvTypeReflectionsPath(context, name = "env") {
|
|
55
80
|
return joinPaths(getReflectionsPath(context), "env", `${name}-types.bin`);
|
|
56
81
|
}
|
|
82
|
+
getEnvTypeReflectionsPath.__type = [
|
|
83
|
+
() => __ΩContext,
|
|
84
|
+
() => __ΩEnvPluginResolvedConfig,
|
|
85
|
+
"context",
|
|
86
|
+
() => __ΩEnvType,
|
|
87
|
+
"name",
|
|
88
|
+
() => "env",
|
|
89
|
+
"getEnvTypeReflectionsPath",
|
|
90
|
+
"Gets the path to the environment type reflections.",
|
|
91
|
+
"Pn\"o!\"2#n$2%>&&/'?("
|
|
92
|
+
];
|
|
57
93
|
/**
|
|
58
94
|
* Reads the environment type reflection from the file system.
|
|
59
95
|
*
|
|
@@ -82,6 +118,17 @@ async function readEnvTypeReflection(context, name = "env") {
|
|
|
82
118
|
context.env.types[name].dataBuffer = buffer;
|
|
83
119
|
return reflection;
|
|
84
120
|
}
|
|
121
|
+
readEnvTypeReflection.__type = [
|
|
122
|
+
() => __ΩEnvPluginContext,
|
|
123
|
+
"context",
|
|
124
|
+
() => __ΩEnvType,
|
|
125
|
+
"name",
|
|
126
|
+
() => "env",
|
|
127
|
+
() => ReflectionClass,
|
|
128
|
+
"readEnvTypeReflection",
|
|
129
|
+
"Reads the environment type reflection from the file system.",
|
|
130
|
+
"Pn!2\"n#2$>%P\"7&`/'?("
|
|
131
|
+
];
|
|
85
132
|
/**
|
|
86
133
|
* Writes the environment type reflection to the file system.
|
|
87
134
|
*
|
|
@@ -95,9 +142,29 @@ async function writeEnvTypeReflection(context, reflection, name = "env") {
|
|
|
95
142
|
convertToCapnp(serialized, message.initRoot(SerializedTypes)._initTypes(serialized.length));
|
|
96
143
|
await writeFileBuffer(getEnvTypeReflectionsPath(context, name), message.toArrayBuffer());
|
|
97
144
|
}
|
|
145
|
+
writeEnvTypeReflection.__type = [
|
|
146
|
+
() => __ΩEnvPluginContext,
|
|
147
|
+
"context",
|
|
148
|
+
() => ReflectionClass,
|
|
149
|
+
"reflection",
|
|
150
|
+
() => __ΩEnvType,
|
|
151
|
+
"name",
|
|
152
|
+
() => "env",
|
|
153
|
+
"writeEnvTypeReflection",
|
|
154
|
+
"Writes the environment type reflection to the file system.",
|
|
155
|
+
"Pn!2\"P\"7#2$n%2&>'\"/(?)"
|
|
156
|
+
];
|
|
98
157
|
function getEnvReflectionsPath(context, name) {
|
|
99
158
|
return joinPaths(getReflectionsPath(context), "env", `${name}.bin`);
|
|
100
159
|
}
|
|
160
|
+
getEnvReflectionsPath.__type = [
|
|
161
|
+
() => __ΩEnvPluginContext,
|
|
162
|
+
"context",
|
|
163
|
+
() => __ΩEnvType,
|
|
164
|
+
"name",
|
|
165
|
+
"getEnvReflectionsPath",
|
|
166
|
+
"Pn!2\"n#2$&/%"
|
|
167
|
+
];
|
|
101
168
|
/**
|
|
102
169
|
* Reads the environment reflection data from the file system.
|
|
103
170
|
*
|
|
@@ -135,6 +202,14 @@ async function readEnvReflection(context) {
|
|
|
135
202
|
context.env.used.env.dataBuffer = buffer;
|
|
136
203
|
return reflection;
|
|
137
204
|
}
|
|
205
|
+
readEnvReflection.__type = [
|
|
206
|
+
() => __ΩEnvPluginContext,
|
|
207
|
+
"context",
|
|
208
|
+
() => ReflectionClass,
|
|
209
|
+
"readEnvReflection",
|
|
210
|
+
"Reads the environment reflection data from the file system.",
|
|
211
|
+
"Pn!2\"P\"7#`/$?%"
|
|
212
|
+
];
|
|
138
213
|
/**
|
|
139
214
|
* Reads the secret environment reflection data from the file system.
|
|
140
215
|
*
|
|
@@ -172,6 +247,14 @@ async function readSecretsReflection(context) {
|
|
|
172
247
|
context.env.used.secrets.dataBuffer = buffer;
|
|
173
248
|
return reflection;
|
|
174
249
|
}
|
|
250
|
+
readSecretsReflection.__type = [
|
|
251
|
+
() => __ΩEnvPluginContext,
|
|
252
|
+
"context",
|
|
253
|
+
() => ReflectionClass,
|
|
254
|
+
"readSecretsReflection",
|
|
255
|
+
"Reads the secret environment reflection data from the file system.",
|
|
256
|
+
"Pn!2\"P\"7#`/$?%"
|
|
257
|
+
];
|
|
175
258
|
/**
|
|
176
259
|
* Writes the environment reflection data to the file system.
|
|
177
260
|
*
|
|
@@ -185,6 +268,18 @@ async function writeEnvReflection(context, reflection, name = "env") {
|
|
|
185
268
|
convertToCapnp(serialized, message.initRoot(SerializedTypes)._initTypes(serialized.length));
|
|
186
269
|
await writeFileBuffer(getEnvReflectionsPath(context, name), message.toArrayBuffer());
|
|
187
270
|
}
|
|
271
|
+
writeEnvReflection.__type = [
|
|
272
|
+
() => __ΩEnvPluginContext,
|
|
273
|
+
"context",
|
|
274
|
+
() => ReflectionClass,
|
|
275
|
+
"reflection",
|
|
276
|
+
() => __ΩEnvType,
|
|
277
|
+
"name",
|
|
278
|
+
() => "env",
|
|
279
|
+
"writeEnvReflection",
|
|
280
|
+
"Writes the environment reflection data to the file system.",
|
|
281
|
+
"Pn!2\"P\"7#2$n%2&>'\"/(?)"
|
|
282
|
+
];
|
|
188
283
|
/**
|
|
189
284
|
* Writes the environment reflection data to the file system.
|
|
190
285
|
*
|
|
@@ -198,6 +293,18 @@ function writeEnvReflectionSync(context, reflection, name = "env") {
|
|
|
198
293
|
convertToCapnp(serialized, message.initRoot(SerializedTypes)._initTypes(serialized.length));
|
|
199
294
|
writeFileBufferSync(getEnvReflectionsPath(context, name), message.toArrayBuffer());
|
|
200
295
|
}
|
|
296
|
+
writeEnvReflectionSync.__type = [
|
|
297
|
+
() => __ΩEnvPluginContext,
|
|
298
|
+
"context",
|
|
299
|
+
() => ReflectionClass,
|
|
300
|
+
"reflection",
|
|
301
|
+
() => __ΩEnvType,
|
|
302
|
+
"name",
|
|
303
|
+
() => "env",
|
|
304
|
+
"writeEnvReflectionSync",
|
|
305
|
+
"Writes the environment reflection data to the file system.",
|
|
306
|
+
"Pn!2\"P\"7#2$n%2&>'\"/(?)"
|
|
307
|
+
];
|
|
201
308
|
|
|
202
309
|
//#endregion
|
|
203
310
|
export { getEnvDefaultTypeDefinition, getEnvReflectionsPath, getEnvTypeReflectionsPath, getSecretsDefaultTypeDefinition, readEnvReflection, readEnvTypeReflection, readSecretsReflection, resolveRuntimeTypeFile, writeEnvReflection, writeEnvReflectionSync, writeEnvTypeReflection };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"persistence.mjs","names":[],"sources":["../../src/helpers/persistence.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { convertFromCapnp, convertToCapnp } from \"@powerlines/deepkit/capnp\";\nimport { getReflectionsPath } from \"@powerlines/deepkit/resolve-reflections\";\nimport { SerializedTypes } from \"@powerlines/deepkit/schemas/reflection\";\nimport { Reflection } from \"@powerlines/deepkit/types\";\nimport {\n deserializeType,\n ReflectionClass,\n ReflectionKind,\n resolveClassType\n} from \"@powerlines/deepkit/vendor/type\";\nimport * as capnp from \"@stryke/capnp\";\nimport {\n readFileBuffer,\n writeFileBuffer,\n writeFileBufferSync\n} from \"@stryke/fs/buffer\";\nimport { joinPaths } from \"@stryke/path/join-paths\";\nimport { isEmptyObject } from \"@stryke/type-checks/is-empty-object\";\nimport type { TypeDefinition } from \"@stryke/types/configuration\";\nimport { existsSync } from \"node:fs\";\nimport { Context, UnresolvedContext } from \"powerlines\";\nimport {\n EnvPluginContext,\n EnvPluginResolvedConfig,\n EnvType\n} from \"../types/plugin\";\nimport { createEnvReflection } from \"./reflect\";\n\n/**\n * Resolves the runtime type definition file for the environment variables.\n *\n * @param context - The plugin context.\n * @returns The runtime type definition file for the environment variables.\n */\nexport async function resolveRuntimeTypeFile(\n context: UnresolvedContext<EnvPluginResolvedConfig>\n): Promise<string> {\n const resolved = await context.fs.resolve(\n \"@powerlines/plugin-env/types/runtime\"\n );\n if (!resolved) {\n throw new Error(\n `Failed to resolve the runtime type definition file for the environment variables. Please ensure that the \"@powerlines/plugin-env\" package is installed.`\n );\n }\n\n return resolved;\n}\n\n/**\n * Gets the default type definition for the environment variables.\n *\n * @param context - The plugin context.\n * @returns The default type definition for the environment variables.\n */\nexport async function getEnvDefaultTypeDefinition(\n context: UnresolvedContext<EnvPluginResolvedConfig>\n): Promise<TypeDefinition> {\n return {\n file: await resolveRuntimeTypeFile(context),\n name: \"EnvInterface\"\n };\n}\n\n/** Gets the default type definition for the environment secrets.\n *\n * @param context - The plugin context.\n * @returns The default type definition for the environment secrets.\n */\nexport async function getSecretsDefaultTypeDefinition(\n context: UnresolvedContext<EnvPluginResolvedConfig>\n): Promise<TypeDefinition> {\n return {\n file: await resolveRuntimeTypeFile(context),\n name: \"SecretsInterface\"\n };\n}\n\n/**\n * Gets the path to the environment type reflections.\n *\n * @param context - The plugin context.\n * @param name - The name of the type reflections.\n * @returns The path to the environment type reflections.\n */\nexport function getEnvTypeReflectionsPath(\n context: Context<EnvPluginResolvedConfig>,\n name: EnvType = \"env\"\n): string {\n return joinPaths(getReflectionsPath(context), \"env\", `${name}-types.bin`);\n}\n\n/**\n * Reads the environment type reflection from the file system.\n *\n * @param context - The plugin context.\n * @param name - The name of the type reflections.\n * @returns The environment type reflection.\n */\nexport async function readEnvTypeReflection(\n context: EnvPluginContext,\n name: EnvType = \"env\"\n): Promise<ReflectionClass<any>> {\n const filePath = getEnvTypeReflectionsPath(context, name);\n if (!existsSync(filePath)) {\n if (!context.env.types.env || isEmptyObject(context.env.types.env)) {\n const reflection = createEnvReflection(context) as Reflection;\n\n const message = new capnp.Message();\n reflection.messageRoot = message.initRoot(SerializedTypes);\n reflection.dataBuffer = message.toArrayBuffer();\n\n context.env.types.env = reflection;\n await writeEnvTypeReflection(context, context.env.types.env, name);\n }\n\n return context.env.types.env;\n }\n\n const buffer = await readFileBuffer(filePath);\n const message = new capnp.Message(buffer, false);\n const messageRoot = message.getRoot(SerializedTypes);\n\n const reflection = resolveClassType(\n deserializeType(convertFromCapnp(messageRoot.types))\n );\n\n context.env.types[name] = reflection;\n context.env.types[name].messageRoot = messageRoot;\n context.env.types[name].dataBuffer = buffer;\n\n return reflection;\n}\n\n/**\n * Writes the environment type reflection to the file system.\n *\n * @param context - The plugin context.\n * @param reflection - The environment type reflection to write.\n * @param name - The name of the type reflections.\n */\nexport async function writeEnvTypeReflection(\n context: EnvPluginContext,\n reflection: ReflectionClass<any>,\n name: EnvType = \"env\"\n) {\n const serialized = reflection.serializeType();\n\n const message = new capnp.Message();\n const root = message.initRoot(SerializedTypes);\n\n convertToCapnp(serialized, root._initTypes(serialized.length));\n\n await writeFileBuffer(\n getEnvTypeReflectionsPath(context, name),\n message.toArrayBuffer()\n );\n}\n\nexport function getEnvReflectionsPath(\n context: EnvPluginContext,\n name: EnvType\n): string {\n return joinPaths(getReflectionsPath(context), \"env\", `${name}.bin`);\n}\n\n/**\n * Reads the environment reflection data from the file system.\n *\n * @param context - The plugin context.\n * @returns The environment reflection data.\n */\nexport async function readEnvReflection(\n context: EnvPluginContext\n): Promise<ReflectionClass<any>> {\n const filePath = getEnvReflectionsPath(context, \"env\");\n if (!existsSync(filePath)) {\n if (!context.env.types.env) {\n context.env.types.env = await readEnvTypeReflection(context, \"env\");\n }\n\n if (!context.env.used.env || isEmptyObject(context.env.used.env)) {\n const reflection = createEnvReflection(context, {\n type: {\n kind: ReflectionKind.objectLiteral,\n typeName: \"Env\",\n description: `An object containing the environment configuration parameters that are used (at least once) by the ${\n context.config.name\n ? `${context.config.name} application`\n : \"application\"\n }.`,\n types: []\n },\n superReflection: context.env.types.env\n }) as Reflection;\n reflection.name = \"Env\";\n\n const message = new capnp.Message();\n reflection.messageRoot = message.initRoot(SerializedTypes);\n reflection.dataBuffer = message.toArrayBuffer();\n\n context.env.used.env = reflection;\n await writeEnvReflection(context, context.env.used.env, \"env\");\n }\n\n return context.env.used.env;\n }\n\n const buffer = await readFileBuffer(filePath);\n const message = new capnp.Message(buffer, false);\n const messageRoot = message.getRoot(SerializedTypes);\n\n const reflection = resolveClassType(\n deserializeType(convertFromCapnp(messageRoot.types))\n );\n\n context.env.used.env = reflection;\n context.env.used.env.messageRoot = messageRoot;\n context.env.used.env.dataBuffer = buffer;\n\n return reflection;\n}\n\n/**\n * Reads the secret environment reflection data from the file system.\n *\n * @param context - The plugin context.\n * @returns The environment reflection data.\n */\nexport async function readSecretsReflection(\n context: EnvPluginContext\n): Promise<ReflectionClass<any>> {\n const filePath = getEnvReflectionsPath(context, \"secrets\");\n if (!existsSync(filePath)) {\n if (!context.env.types.secrets) {\n context.env.types.secrets = await readEnvTypeReflection(\n context,\n \"secrets\"\n );\n }\n\n if (!context.env.used.secrets || isEmptyObject(context.env.used.secrets)) {\n const reflection = createEnvReflection(context, {\n type: {\n kind: ReflectionKind.objectLiteral,\n typeName: \"Secrets\",\n description: `An object containing the secret configuration parameters that are used (at least once) by the ${\n context.config.name\n ? `${context.config.name} application`\n : \"application\"\n }.`,\n types: []\n },\n superReflection: context.env.types.secrets\n }) as Reflection;\n reflection.name = \"Secrets\";\n\n const message = new capnp.Message();\n reflection.messageRoot = message.initRoot(SerializedTypes);\n reflection.dataBuffer = message.toArrayBuffer();\n\n context.env.used.secrets = reflection;\n await writeEnvReflection(context, context.env.used.secrets, \"secrets\");\n }\n\n return context.env.used.secrets;\n }\n\n const buffer = await readFileBuffer(filePath);\n const message = new capnp.Message(buffer, false);\n const messageRoot = message.getRoot(SerializedTypes);\n\n const reflection = resolveClassType(\n deserializeType(convertFromCapnp(messageRoot.types))\n );\n\n context.env.used.secrets = reflection;\n context.env.used.secrets.messageRoot = messageRoot;\n context.env.used.secrets.dataBuffer = buffer;\n\n return reflection;\n}\n\n/**\n * Writes the environment reflection data to the file system.\n *\n * @param context - The plugin context.\n * @param reflection - The reflection data to write.\n * @param name - The name of the reflection (either \"env\" or \"secrets\").\n */\nexport async function writeEnvReflection(\n context: EnvPluginContext,\n reflection: ReflectionClass<any>,\n name: EnvType = \"env\"\n) {\n const serialized = reflection.serializeType();\n\n const message = new capnp.Message();\n const root = message.initRoot(SerializedTypes);\n\n convertToCapnp(serialized, root._initTypes(serialized.length));\n\n await writeFileBuffer(\n getEnvReflectionsPath(context, name),\n message.toArrayBuffer()\n );\n}\n\n/**\n * Writes the environment reflection data to the file system.\n *\n * @param context - The plugin context.\n * @param reflection - The reflection data to write.\n * @param name - The name of the reflection (either \"env\" or \"secrets\").\n */\nexport function writeEnvReflectionSync(\n context: EnvPluginContext,\n reflection: ReflectionClass<any>,\n name: EnvType = \"env\"\n) {\n const serialized = reflection.serializeType();\n\n const message = new capnp.Message();\n const root = message.initRoot(SerializedTypes);\n\n convertToCapnp(serialized, root._initTypes(serialized.length));\n\n writeFileBufferSync(\n getEnvReflectionsPath(context, name),\n message.toArrayBuffer()\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAoDA,eAAsB,uBACpB,SACiB;CACjB,MAAM,WAAW,MAAM,QAAQ,GAAG,QAChC,uCACD;AACD,KAAI,CAAC,SACH,OAAM,IAAI,MACR,0JACD;AAGH,QAAO;;;;;;;;AAST,eAAsB,4BACpB,SACyB;AACzB,QAAO;EACL,MAAM,MAAM,uBAAuB,QAAQ;EAC3C,MAAM;EACP;;;;;;;AAQH,eAAsB,gCACpB,SACyB;AACzB,QAAO;EACL,MAAM,MAAM,uBAAuB,QAAQ;EAC3C,MAAM;EACP;;;;;;;;;AAUH,SAAgB,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,QAAQ,SAAS,gBAAgB,CAEd,WAAW,WAAW,OAAO,CAAC;AAE9D,qBACE,sBAAsB,SAAS,KAAK,EACpC,QAAQ,eAAe,CACxB"}
|
|
1
|
+
{"version":3,"file":"persistence.mjs","names":[],"sources":["../../src/helpers/persistence.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { convertFromCapnp, convertToCapnp } from \"@powerlines/deepkit/capnp\";\nimport { getReflectionsPath } from \"@powerlines/deepkit/resolve-reflections\";\nimport { SerializedTypes } from \"@powerlines/deepkit/schemas/reflection\";\nimport { Reflection } from \"@powerlines/deepkit/types\";\nimport {\n deserializeType,\n ReflectionClass,\n ReflectionKind,\n resolveClassType\n} from \"@powerlines/deepkit/vendor/type\";\nimport * as capnp from \"@stryke/capnp\";\nimport {\n readFileBuffer,\n writeFileBuffer,\n writeFileBufferSync\n} from \"@stryke/fs/buffer\";\nimport { joinPaths } from \"@stryke/path/join-paths\";\nimport { isEmptyObject } from \"@stryke/type-checks/is-empty-object\";\nimport type { TypeDefinition } from \"@stryke/types/configuration\";\nimport { existsSync } from \"node:fs\";\nimport { Context, UnresolvedContext } from \"powerlines\";\nimport {\n EnvPluginContext,\n EnvPluginResolvedConfig,\n EnvType\n} from \"../types/plugin\";\nimport { createEnvReflection } from \"./reflect\";\n\n/**\n * Resolves the runtime type definition file for the environment variables.\n *\n * @param context - The plugin context.\n * @returns The runtime type definition file for the environment variables.\n */\nexport async function resolveRuntimeTypeFile(\n context: UnresolvedContext<EnvPluginResolvedConfig>\n): Promise<string> {\n const resolved = await context.fs.resolve(\n \"@powerlines/plugin-env/types/runtime\"\n );\n if (!resolved) {\n throw new Error(\n `Failed to resolve the runtime type definition file for the environment variables. Please ensure that the \"@powerlines/plugin-env\" package is installed.`\n );\n }\n\n return resolved;\n}\n\n/**\n * Gets the default type definition for the environment variables.\n *\n * @param context - The plugin context.\n * @returns The default type definition for the environment variables.\n */\nexport async function getEnvDefaultTypeDefinition(\n context: UnresolvedContext<EnvPluginResolvedConfig>\n): Promise<TypeDefinition> {\n return {\n file: await resolveRuntimeTypeFile(context),\n name: \"EnvInterface\"\n };\n}\n\n/** Gets the default type definition for the environment secrets.\n *\n * @param context - The plugin context.\n * @returns The default type definition for the environment secrets.\n */\nexport async function getSecretsDefaultTypeDefinition(\n context: UnresolvedContext<EnvPluginResolvedConfig>\n): Promise<TypeDefinition> {\n return {\n file: await resolveRuntimeTypeFile(context),\n name: \"SecretsInterface\"\n };\n}\n\n/**\n * Gets the path to the environment type reflections.\n *\n * @param context - The plugin context.\n * @param name - The name of the type reflections.\n * @returns The path to the environment type reflections.\n */\nexport function getEnvTypeReflectionsPath(\n context: Context<EnvPluginResolvedConfig>,\n name: EnvType = \"env\"\n): string {\n return joinPaths(getReflectionsPath(context), \"env\", `${name}-types.bin`);\n}\n\n/**\n * Reads the environment type reflection from the file system.\n *\n * @param context - The plugin context.\n * @param name - The name of the type reflections.\n * @returns The environment type reflection.\n */\nexport async function readEnvTypeReflection(\n context: EnvPluginContext,\n name: EnvType = \"env\"\n): Promise<ReflectionClass<any>> {\n const filePath = getEnvTypeReflectionsPath(context, name);\n if (!existsSync(filePath)) {\n if (!context.env.types.env || isEmptyObject(context.env.types.env)) {\n const reflection = createEnvReflection(context) as Reflection;\n\n const message = new capnp.Message();\n reflection.messageRoot = message.initRoot(SerializedTypes);\n reflection.dataBuffer = message.toArrayBuffer();\n\n context.env.types.env = reflection;\n await writeEnvTypeReflection(context, context.env.types.env, name);\n }\n\n return context.env.types.env;\n }\n\n const buffer = await readFileBuffer(filePath);\n const message = new capnp.Message(buffer, false);\n const messageRoot = message.getRoot(SerializedTypes);\n\n const reflection = resolveClassType(\n deserializeType(convertFromCapnp(messageRoot.types))\n );\n\n context.env.types[name] = reflection;\n context.env.types[name].messageRoot = messageRoot;\n context.env.types[name].dataBuffer = buffer;\n\n return reflection;\n}\n\n/**\n * Writes the environment type reflection to the file system.\n *\n * @param context - The plugin context.\n * @param reflection - The environment type reflection to write.\n * @param name - The name of the type reflections.\n */\nexport async function writeEnvTypeReflection(\n context: EnvPluginContext,\n reflection: ReflectionClass<any>,\n name: EnvType = \"env\"\n) {\n const serialized = reflection.serializeType();\n\n const message = new capnp.Message();\n const root = message.initRoot(SerializedTypes);\n\n convertToCapnp(serialized, root._initTypes(serialized.length));\n\n await writeFileBuffer(\n getEnvTypeReflectionsPath(context, name),\n message.toArrayBuffer()\n );\n}\n\nexport function getEnvReflectionsPath(\n context: EnvPluginContext,\n name: EnvType\n): string {\n return joinPaths(getReflectionsPath(context), \"env\", `${name}.bin`);\n}\n\n/**\n * Reads the environment reflection data from the file system.\n *\n * @param context - The plugin context.\n * @returns The environment reflection data.\n */\nexport async function readEnvReflection(\n context: EnvPluginContext\n): Promise<ReflectionClass<any>> {\n const filePath = getEnvReflectionsPath(context, \"env\");\n if (!existsSync(filePath)) {\n if (!context.env.types.env) {\n context.env.types.env = await readEnvTypeReflection(context, \"env\");\n }\n\n if (!context.env.used.env || isEmptyObject(context.env.used.env)) {\n const reflection = createEnvReflection(context, {\n type: {\n kind: ReflectionKind.objectLiteral,\n typeName: \"Env\",\n description: `An object containing the environment configuration parameters that are used (at least once) by the ${\n context.config.name\n ? `${context.config.name} application`\n : \"application\"\n }.`,\n types: []\n },\n superReflection: context.env.types.env\n }) as Reflection;\n reflection.name = \"Env\";\n\n const message = new capnp.Message();\n reflection.messageRoot = message.initRoot(SerializedTypes);\n reflection.dataBuffer = message.toArrayBuffer();\n\n context.env.used.env = reflection;\n await writeEnvReflection(context, context.env.used.env, \"env\");\n }\n\n return context.env.used.env;\n }\n\n const buffer = await readFileBuffer(filePath);\n const message = new capnp.Message(buffer, false);\n const messageRoot = message.getRoot(SerializedTypes);\n\n const reflection = resolveClassType(\n deserializeType(convertFromCapnp(messageRoot.types))\n );\n\n context.env.used.env = reflection;\n context.env.used.env.messageRoot = messageRoot;\n context.env.used.env.dataBuffer = buffer;\n\n return reflection;\n}\n\n/**\n * Reads the secret environment reflection data from the file system.\n *\n * @param context - The plugin context.\n * @returns The environment reflection data.\n */\nexport async function readSecretsReflection(\n context: EnvPluginContext\n): Promise<ReflectionClass<any>> {\n const filePath = getEnvReflectionsPath(context, \"secrets\");\n if (!existsSync(filePath)) {\n if (!context.env.types.secrets) {\n context.env.types.secrets = await readEnvTypeReflection(\n context,\n \"secrets\"\n );\n }\n\n if (!context.env.used.secrets || isEmptyObject(context.env.used.secrets)) {\n const reflection = createEnvReflection(context, {\n type: {\n kind: ReflectionKind.objectLiteral,\n typeName: \"Secrets\",\n description: `An object containing the secret configuration parameters that are used (at least once) by the ${\n context.config.name\n ? `${context.config.name} application`\n : \"application\"\n }.`,\n types: []\n },\n superReflection: context.env.types.secrets\n }) as Reflection;\n reflection.name = \"Secrets\";\n\n const message = new capnp.Message();\n reflection.messageRoot = message.initRoot(SerializedTypes);\n reflection.dataBuffer = message.toArrayBuffer();\n\n context.env.used.secrets = reflection;\n await writeEnvReflection(context, context.env.used.secrets, \"secrets\");\n }\n\n return context.env.used.secrets;\n }\n\n const buffer = await readFileBuffer(filePath);\n const message = new capnp.Message(buffer, false);\n const messageRoot = message.getRoot(SerializedTypes);\n\n const reflection = resolveClassType(\n deserializeType(convertFromCapnp(messageRoot.types))\n );\n\n context.env.used.secrets = reflection;\n context.env.used.secrets.messageRoot = messageRoot;\n context.env.used.secrets.dataBuffer = buffer;\n\n return reflection;\n}\n\n/**\n * Writes the environment reflection data to the file system.\n *\n * @param context - The plugin context.\n * @param reflection - The reflection data to write.\n * @param name - The name of the reflection (either \"env\" or \"secrets\").\n */\nexport async function writeEnvReflection(\n context: EnvPluginContext,\n reflection: ReflectionClass<any>,\n name: EnvType = \"env\"\n) {\n const serialized = reflection.serializeType();\n\n const message = new capnp.Message();\n const root = message.initRoot(SerializedTypes);\n\n convertToCapnp(serialized, root._initTypes(serialized.length));\n\n await writeFileBuffer(\n getEnvReflectionsPath(context, name),\n message.toArrayBuffer()\n );\n}\n\n/**\n * Writes the environment reflection data to the file system.\n *\n * @param context - The plugin context.\n * @param reflection - The reflection data to write.\n * @param name - The name of the reflection (either \"env\" or \"secrets\").\n */\nexport function writeEnvReflectionSync(\n context: EnvPluginContext,\n reflection: ReflectionClass<any>,\n name: EnvType = \"env\"\n) {\n const serialized = reflection.serializeType();\n\n const message = new capnp.Message();\n const root = message.initRoot(SerializedTypes);\n\n convertToCapnp(serialized, root._initTypes(serialized.length));\n\n writeFileBufferSync(\n getEnvReflectionsPath(context, name),\n message.toArrayBuffer()\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AA2CA,eAAiB,uBAAO,SAAA;CACxB,MAAS,WAAA,MAAA,QAA0B,GAAG,QAAQ,uCAAC;eAE7C,OAAA,IAAA,MAAA,0JAAA;AAED,QAAA;;AAED,uBAAuB,SAAM;OAAU;OAA0B;CAAS;CAAA;CAAA;CAAA;CAAA;;;;;;;AAO1E,eAAG,4BAAA,SAAA;AACC,QAAG;EACH,MAAU,MAAK,uBAAA,QAAA;EACZ,MAAO;EACT;;;;;;;;;;;;;;;AAQL,eAAC,gCAAA,SAAA;AACG,QAAM;EACN,MAAQ,MAAI,uBAA2B,QAAK;EAC9C,MAAA;EACF;;AAEA,gCAA2B,SAAA;OAAA;OAAA;CAAA;CAAA;CAAA;CAAA;;;;;;;;AAQ3B,SAAC,0BAAA,SAAA,OAAA,OAAA;AACG,QAAM,UAAU,mBAAkB,QAAA,EAAA,OAAA,GAAA,KAAA,YAAA;;AAEtC,0BAAE,SAAA;OAAA;OAAA;CAAA;OAAA;CAAA;O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' });
|
|
2
2
|
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
3
|
+
const require_types_runtime = require('../types/runtime.cjs');
|
|
4
|
+
const require_types_plugin = require('../types/plugin.cjs');
|
|
3
5
|
const require_helpers_persistence = require('./persistence.cjs');
|
|
4
|
-
let _stryke_string_format_title_case = require("@stryke/string-format/title-case");
|
|
5
6
|
let _powerlines_deepkit_vendor_type = require("@powerlines/deepkit/vendor/type");
|
|
7
|
+
let _stryke_string_format_title_case = require("@stryke/string-format/title-case");
|
|
6
8
|
let _stryke_path_join_paths = require("@stryke/path/join-paths");
|
|
7
9
|
let _powerlines_deepkit_reflect_type = require("@powerlines/deepkit/reflect-type");
|
|
8
10
|
let _stryke_path_is_parent_path = require("@stryke/path/is-parent-path");
|
|
9
11
|
|
|
10
12
|
//#region src/helpers/reflect.ts
|
|
13
|
+
function __assignType(fn, args) {
|
|
14
|
+
fn.__type = args;
|
|
15
|
+
return fn;
|
|
16
|
+
}
|
|
11
17
|
function mergeEnvReflections(context, reflections) {
|
|
12
|
-
return createEnvReflection(context, { type: (0, _powerlines_deepkit_vendor_type.merge)(reflections.map((reflection) => reflection.type
|
|
18
|
+
return createEnvReflection(context, { type: (0, _powerlines_deepkit_vendor_type.merge)(reflections.map(__assignType((reflection) => reflection.type, [
|
|
19
|
+
"reflection",
|
|
20
|
+
"",
|
|
21
|
+
"P\"2!\"/\""
|
|
22
|
+
]))) });
|
|
13
23
|
}
|
|
24
|
+
mergeEnvReflections.__type = [
|
|
25
|
+
() => require_types_plugin.__ΩEnvPluginContext,
|
|
26
|
+
"context",
|
|
27
|
+
() => _powerlines_deepkit_vendor_type.ReflectionClass,
|
|
28
|
+
"reflections",
|
|
29
|
+
() => _powerlines_deepkit_vendor_type.ReflectionClass,
|
|
30
|
+
"mergeEnvReflections",
|
|
31
|
+
"Pn!2\"P\"7#F2$P\"7%/&"
|
|
32
|
+
];
|
|
14
33
|
function mergeSecretsReflections(context, reflections) {
|
|
15
|
-
return createSecretsReflection(context, { type: (0, _powerlines_deepkit_vendor_type.merge)(reflections.map((reflection) => reflection.type
|
|
34
|
+
return createSecretsReflection(context, { type: (0, _powerlines_deepkit_vendor_type.merge)(reflections.map(__assignType((reflection) => reflection.type, [
|
|
35
|
+
"reflection",
|
|
36
|
+
"",
|
|
37
|
+
"P\"2!\"/\""
|
|
38
|
+
]))) });
|
|
16
39
|
}
|
|
40
|
+
mergeSecretsReflections.__type = [
|
|
41
|
+
() => require_types_plugin.__ΩEnvPluginContext,
|
|
42
|
+
"context",
|
|
43
|
+
() => _powerlines_deepkit_vendor_type.ReflectionClass,
|
|
44
|
+
"reflections",
|
|
45
|
+
() => _powerlines_deepkit_vendor_type.ReflectionClass,
|
|
46
|
+
"mergeSecretsReflections",
|
|
47
|
+
"Pn!2\"P\"7#F2$P\"7%/&"
|
|
48
|
+
];
|
|
49
|
+
const __ΩCreateEnvReflectionOptions = [
|
|
50
|
+
() => _powerlines_deepkit_vendor_type.__ΩTypeObjectLiteral,
|
|
51
|
+
() => _powerlines_deepkit_vendor_type.__ΩTypeClass,
|
|
52
|
+
"type",
|
|
53
|
+
() => _powerlines_deepkit_vendor_type.ReflectionClass,
|
|
54
|
+
"superReflection",
|
|
55
|
+
"CreateEnvReflectionOptions",
|
|
56
|
+
"PPn!n\"J4#8P\"7$4%8Mw&y"
|
|
57
|
+
];
|
|
17
58
|
var BaseEnv = class {
|
|
18
59
|
APP_NAME;
|
|
19
60
|
APP_VERSION;
|
|
@@ -38,9 +79,82 @@ var BaseEnv = class {
|
|
|
38
79
|
DEFAULT_TIMEZONE;
|
|
39
80
|
DEFAULT_LOCALE;
|
|
40
81
|
CI = false;
|
|
82
|
+
static __type = [
|
|
83
|
+
"APP_NAME",
|
|
84
|
+
"APP_VERSION",
|
|
85
|
+
"BUILD_ID",
|
|
86
|
+
"BUILD_TIMESTAMP",
|
|
87
|
+
"BUILD_CHECKSUM",
|
|
88
|
+
"RELEASE_ID",
|
|
89
|
+
"RELEASE_TAG",
|
|
90
|
+
"ORGANIZATION",
|
|
91
|
+
"node",
|
|
92
|
+
"browser",
|
|
93
|
+
"neutral",
|
|
94
|
+
"PLATFORM",
|
|
95
|
+
function() {
|
|
96
|
+
return "neutral";
|
|
97
|
+
},
|
|
98
|
+
"development",
|
|
99
|
+
"test",
|
|
100
|
+
"production",
|
|
101
|
+
"MODE",
|
|
102
|
+
function() {
|
|
103
|
+
return "production";
|
|
104
|
+
},
|
|
105
|
+
"ENVIRONMENT",
|
|
106
|
+
"DEBUG",
|
|
107
|
+
function() {
|
|
108
|
+
return false;
|
|
109
|
+
},
|
|
110
|
+
"TEST",
|
|
111
|
+
function() {
|
|
112
|
+
return false;
|
|
113
|
+
},
|
|
114
|
+
"MINIMAL",
|
|
115
|
+
function() {
|
|
116
|
+
return false;
|
|
117
|
+
},
|
|
118
|
+
"NO_COLOR",
|
|
119
|
+
function() {
|
|
120
|
+
return false;
|
|
121
|
+
},
|
|
122
|
+
"FORCE_COLOR",
|
|
123
|
+
function() {
|
|
124
|
+
return false;
|
|
125
|
+
},
|
|
126
|
+
"FORCE_HYPERLINK",
|
|
127
|
+
function() {
|
|
128
|
+
return false;
|
|
129
|
+
},
|
|
130
|
+
"STACKTRACE",
|
|
131
|
+
function() {
|
|
132
|
+
return false;
|
|
133
|
+
},
|
|
134
|
+
"INCLUDE_ERROR_DATA",
|
|
135
|
+
function() {
|
|
136
|
+
return false;
|
|
137
|
+
},
|
|
138
|
+
"ERROR_URL",
|
|
139
|
+
"DEFAULT_TIMEZONE",
|
|
140
|
+
"DEFAULT_LOCALE",
|
|
141
|
+
"CI",
|
|
142
|
+
function() {
|
|
143
|
+
return false;
|
|
144
|
+
},
|
|
145
|
+
() => require_types_runtime.__ΩEnvInterface,
|
|
146
|
+
"BaseEnv",
|
|
147
|
+
"&3!&3\"&3#&3$&3%&3&&3'&3(P.).*.+J3,>-P.../.0J31>2&33)34>5)36>7)38>9)3:>;P')J3<>=P')J3>>?)3@>A)3B>C&3D&3E&3F)3G>H5nIx\"wJ"
|
|
148
|
+
];
|
|
41
149
|
};
|
|
42
150
|
var BaseSecrets = class {
|
|
43
151
|
ENCRYPTION_KEY;
|
|
152
|
+
static __type = [
|
|
153
|
+
"ENCRYPTION_KEY",
|
|
154
|
+
() => require_types_runtime.__ΩSecretsInterface,
|
|
155
|
+
"BaseSecrets",
|
|
156
|
+
"&3!5n\"x\"w#"
|
|
157
|
+
];
|
|
44
158
|
};
|
|
45
159
|
function createEnvReflection(context, options = {}) {
|
|
46
160
|
const parent = options.superReflection ?? new _powerlines_deepkit_vendor_type.ReflectionClass({
|
|
@@ -65,6 +179,16 @@ function createEnvReflection(context, options = {}) {
|
|
|
65
179
|
result.name = "Env";
|
|
66
180
|
return result;
|
|
67
181
|
}
|
|
182
|
+
createEnvReflection.__type = [
|
|
183
|
+
() => require_types_plugin.__ΩEnvPluginContext,
|
|
184
|
+
"context",
|
|
185
|
+
() => __ΩCreateEnvReflectionOptions,
|
|
186
|
+
"options",
|
|
187
|
+
() => ({}),
|
|
188
|
+
() => _powerlines_deepkit_vendor_type.ReflectionClass,
|
|
189
|
+
"createEnvReflection",
|
|
190
|
+
"Pn!2\"n#2$>%P\"7&/'"
|
|
191
|
+
];
|
|
68
192
|
function createSecretsReflection(context, options = {}) {
|
|
69
193
|
const parent = options.superReflection ?? new _powerlines_deepkit_vendor_type.ReflectionClass({
|
|
70
194
|
kind: _powerlines_deepkit_vendor_type.ReflectionKind.class,
|
|
@@ -88,6 +212,16 @@ function createSecretsReflection(context, options = {}) {
|
|
|
88
212
|
result.name = "Secrets";
|
|
89
213
|
return result;
|
|
90
214
|
}
|
|
215
|
+
createSecretsReflection.__type = [
|
|
216
|
+
() => require_types_plugin.__ΩEnvPluginContext,
|
|
217
|
+
"context",
|
|
218
|
+
() => __ΩCreateEnvReflectionOptions,
|
|
219
|
+
"options",
|
|
220
|
+
() => ({}),
|
|
221
|
+
() => _powerlines_deepkit_vendor_type.ReflectionClass,
|
|
222
|
+
"createSecretsReflection",
|
|
223
|
+
"Pn!2\"n#2$>%P\"7&/'"
|
|
224
|
+
];
|
|
91
225
|
/**
|
|
92
226
|
* Reflects the environment configuration type definition from the provided file and name, and merges it with the default environment configuration reflection and the currently used environment configuration reflection.
|
|
93
227
|
*
|
|
@@ -111,6 +245,15 @@ async function reflectEnv(context, file, name) {
|
|
|
111
245
|
(0, _powerlines_deepkit_vendor_type.resolveClassType)(await (0, _powerlines_deepkit_reflect_type.reflectType)(context, await require_helpers_persistence.getEnvDefaultTypeDefinition(context)))
|
|
112
246
|
].filter(Boolean));
|
|
113
247
|
}
|
|
248
|
+
reflectEnv.__type = [
|
|
249
|
+
() => require_types_plugin.__ΩEnvPluginContext,
|
|
250
|
+
"context",
|
|
251
|
+
"file",
|
|
252
|
+
"name",
|
|
253
|
+
"reflectEnv",
|
|
254
|
+
"Reflects the environment configuration type definition from the provided file and name, and merges it with the default environment configuration reflection and the currently used environment configuration reflection.",
|
|
255
|
+
"Pn!2\"&2#8&2$8\"/%?&"
|
|
256
|
+
];
|
|
114
257
|
/**
|
|
115
258
|
* Reflects the secrets configuration type definition from the provided file and name, and merges it with the default secrets configuration reflection and the currently used secrets configuration reflection.
|
|
116
259
|
*
|
|
@@ -134,10 +277,20 @@ async function reflectSecrets(context, file, name) {
|
|
|
134
277
|
(0, _powerlines_deepkit_vendor_type.resolveClassType)(await (0, _powerlines_deepkit_reflect_type.reflectType)(context, await require_helpers_persistence.getSecretsDefaultTypeDefinition(context)))
|
|
135
278
|
].filter(Boolean));
|
|
136
279
|
}
|
|
280
|
+
reflectSecrets.__type = [
|
|
281
|
+
() => require_types_plugin.__ΩEnvPluginContext,
|
|
282
|
+
"context",
|
|
283
|
+
"file",
|
|
284
|
+
"name",
|
|
285
|
+
"reflectSecrets",
|
|
286
|
+
"Reflects the secrets configuration type definition from the provided file and name, and merges it with the default secrets configuration reflection and the currently used secrets configuration reflection.",
|
|
287
|
+
"Pn!2\"&2#8&2$8\"/%?&"
|
|
288
|
+
];
|
|
137
289
|
|
|
138
290
|
//#endregion
|
|
139
291
|
exports.BaseEnv = BaseEnv;
|
|
140
292
|
exports.BaseSecrets = BaseSecrets;
|
|
293
|
+
exports.__ΩCreateEnvReflectionOptions = __ΩCreateEnvReflectionOptions;
|
|
141
294
|
exports.createEnvReflection = createEnvReflection;
|
|
142
295
|
exports.createSecretsReflection = createSecretsReflection;
|
|
143
296
|
exports.mergeEnvReflections = mergeEnvReflections;
|
package/dist/helpers/reflect.mjs
CHANGED
|
@@ -1,17 +1,58 @@
|
|
|
1
|
+
import { __ΩEnvInterface, __ΩSecretsInterface } from "../types/runtime.mjs";
|
|
2
|
+
import { __ΩEnvPluginContext } from "../types/plugin.mjs";
|
|
1
3
|
import { getEnvDefaultTypeDefinition, getSecretsDefaultTypeDefinition, readEnvTypeReflection, readSecretsReflection } from "./persistence.mjs";
|
|
4
|
+
import { ReflectionClass, ReflectionKind, __ΩTypeClass, __ΩTypeObjectLiteral, merge, resolveClassType } from "@powerlines/deepkit/vendor/type";
|
|
2
5
|
import { titleCase } from "@stryke/string-format/title-case";
|
|
3
|
-
import { ReflectionClass, ReflectionKind, merge, resolveClassType } from "@powerlines/deepkit/vendor/type";
|
|
4
6
|
import { joinPaths } from "@stryke/path/join-paths";
|
|
5
7
|
import { reflectType } from "@powerlines/deepkit/reflect-type";
|
|
6
8
|
import { isParentPath } from "@stryke/path/is-parent-path";
|
|
7
9
|
|
|
8
10
|
//#region src/helpers/reflect.ts
|
|
11
|
+
function __assignType(fn, args) {
|
|
12
|
+
fn.__type = args;
|
|
13
|
+
return fn;
|
|
14
|
+
}
|
|
9
15
|
function mergeEnvReflections(context, reflections) {
|
|
10
|
-
return createEnvReflection(context, { type: merge(reflections.map((reflection) => reflection.type
|
|
16
|
+
return createEnvReflection(context, { type: merge(reflections.map(__assignType((reflection) => reflection.type, [
|
|
17
|
+
"reflection",
|
|
18
|
+
"",
|
|
19
|
+
"P\"2!\"/\""
|
|
20
|
+
]))) });
|
|
11
21
|
}
|
|
22
|
+
mergeEnvReflections.__type = [
|
|
23
|
+
() => __ΩEnvPluginContext,
|
|
24
|
+
"context",
|
|
25
|
+
() => ReflectionClass,
|
|
26
|
+
"reflections",
|
|
27
|
+
() => ReflectionClass,
|
|
28
|
+
"mergeEnvReflections",
|
|
29
|
+
"Pn!2\"P\"7#F2$P\"7%/&"
|
|
30
|
+
];
|
|
12
31
|
function mergeSecretsReflections(context, reflections) {
|
|
13
|
-
return createSecretsReflection(context, { type: merge(reflections.map((reflection) => reflection.type
|
|
32
|
+
return createSecretsReflection(context, { type: merge(reflections.map(__assignType((reflection) => reflection.type, [
|
|
33
|
+
"reflection",
|
|
34
|
+
"",
|
|
35
|
+
"P\"2!\"/\""
|
|
36
|
+
]))) });
|
|
14
37
|
}
|
|
38
|
+
mergeSecretsReflections.__type = [
|
|
39
|
+
() => __ΩEnvPluginContext,
|
|
40
|
+
"context",
|
|
41
|
+
() => ReflectionClass,
|
|
42
|
+
"reflections",
|
|
43
|
+
() => ReflectionClass,
|
|
44
|
+
"mergeSecretsReflections",
|
|
45
|
+
"Pn!2\"P\"7#F2$P\"7%/&"
|
|
46
|
+
];
|
|
47
|
+
const __ΩCreateEnvReflectionOptions = [
|
|
48
|
+
() => __ΩTypeObjectLiteral,
|
|
49
|
+
() => __ΩTypeClass,
|
|
50
|
+
"type",
|
|
51
|
+
() => ReflectionClass,
|
|
52
|
+
"superReflection",
|
|
53
|
+
"CreateEnvReflectionOptions",
|
|
54
|
+
"PPn!n\"J4#8P\"7$4%8Mw&y"
|
|
55
|
+
];
|
|
15
56
|
var BaseEnv = class {
|
|
16
57
|
APP_NAME;
|
|
17
58
|
APP_VERSION;
|
|
@@ -36,9 +77,82 @@ var BaseEnv = class {
|
|
|
36
77
|
DEFAULT_TIMEZONE;
|
|
37
78
|
DEFAULT_LOCALE;
|
|
38
79
|
CI = false;
|
|
80
|
+
static __type = [
|
|
81
|
+
"APP_NAME",
|
|
82
|
+
"APP_VERSION",
|
|
83
|
+
"BUILD_ID",
|
|
84
|
+
"BUILD_TIMESTAMP",
|
|
85
|
+
"BUILD_CHECKSUM",
|
|
86
|
+
"RELEASE_ID",
|
|
87
|
+
"RELEASE_TAG",
|
|
88
|
+
"ORGANIZATION",
|
|
89
|
+
"node",
|
|
90
|
+
"browser",
|
|
91
|
+
"neutral",
|
|
92
|
+
"PLATFORM",
|
|
93
|
+
function() {
|
|
94
|
+
return "neutral";
|
|
95
|
+
},
|
|
96
|
+
"development",
|
|
97
|
+
"test",
|
|
98
|
+
"production",
|
|
99
|
+
"MODE",
|
|
100
|
+
function() {
|
|
101
|
+
return "production";
|
|
102
|
+
},
|
|
103
|
+
"ENVIRONMENT",
|
|
104
|
+
"DEBUG",
|
|
105
|
+
function() {
|
|
106
|
+
return false;
|
|
107
|
+
},
|
|
108
|
+
"TEST",
|
|
109
|
+
function() {
|
|
110
|
+
return false;
|
|
111
|
+
},
|
|
112
|
+
"MINIMAL",
|
|
113
|
+
function() {
|
|
114
|
+
return false;
|
|
115
|
+
},
|
|
116
|
+
"NO_COLOR",
|
|
117
|
+
function() {
|
|
118
|
+
return false;
|
|
119
|
+
},
|
|
120
|
+
"FORCE_COLOR",
|
|
121
|
+
function() {
|
|
122
|
+
return false;
|
|
123
|
+
},
|
|
124
|
+
"FORCE_HYPERLINK",
|
|
125
|
+
function() {
|
|
126
|
+
return false;
|
|
127
|
+
},
|
|
128
|
+
"STACKTRACE",
|
|
129
|
+
function() {
|
|
130
|
+
return false;
|
|
131
|
+
},
|
|
132
|
+
"INCLUDE_ERROR_DATA",
|
|
133
|
+
function() {
|
|
134
|
+
return false;
|
|
135
|
+
},
|
|
136
|
+
"ERROR_URL",
|
|
137
|
+
"DEFAULT_TIMEZONE",
|
|
138
|
+
"DEFAULT_LOCALE",
|
|
139
|
+
"CI",
|
|
140
|
+
function() {
|
|
141
|
+
return false;
|
|
142
|
+
},
|
|
143
|
+
() => __ΩEnvInterface,
|
|
144
|
+
"BaseEnv",
|
|
145
|
+
"&3!&3\"&3#&3$&3%&3&&3'&3(P.).*.+J3,>-P.../.0J31>2&33)34>5)36>7)38>9)3:>;P')J3<>=P')J3>>?)3@>A)3B>C&3D&3E&3F)3G>H5nIx\"wJ"
|
|
146
|
+
];
|
|
39
147
|
};
|
|
40
148
|
var BaseSecrets = class {
|
|
41
149
|
ENCRYPTION_KEY;
|
|
150
|
+
static __type = [
|
|
151
|
+
"ENCRYPTION_KEY",
|
|
152
|
+
() => __ΩSecretsInterface,
|
|
153
|
+
"BaseSecrets",
|
|
154
|
+
"&3!5n\"x\"w#"
|
|
155
|
+
];
|
|
42
156
|
};
|
|
43
157
|
function createEnvReflection(context, options = {}) {
|
|
44
158
|
const parent = options.superReflection ?? new ReflectionClass({
|
|
@@ -63,6 +177,16 @@ function createEnvReflection(context, options = {}) {
|
|
|
63
177
|
result.name = "Env";
|
|
64
178
|
return result;
|
|
65
179
|
}
|
|
180
|
+
createEnvReflection.__type = [
|
|
181
|
+
() => __ΩEnvPluginContext,
|
|
182
|
+
"context",
|
|
183
|
+
() => __ΩCreateEnvReflectionOptions,
|
|
184
|
+
"options",
|
|
185
|
+
() => ({}),
|
|
186
|
+
() => ReflectionClass,
|
|
187
|
+
"createEnvReflection",
|
|
188
|
+
"Pn!2\"n#2$>%P\"7&/'"
|
|
189
|
+
];
|
|
66
190
|
function createSecretsReflection(context, options = {}) {
|
|
67
191
|
const parent = options.superReflection ?? new ReflectionClass({
|
|
68
192
|
kind: ReflectionKind.class,
|
|
@@ -86,6 +210,16 @@ function createSecretsReflection(context, options = {}) {
|
|
|
86
210
|
result.name = "Secrets";
|
|
87
211
|
return result;
|
|
88
212
|
}
|
|
213
|
+
createSecretsReflection.__type = [
|
|
214
|
+
() => __ΩEnvPluginContext,
|
|
215
|
+
"context",
|
|
216
|
+
() => __ΩCreateEnvReflectionOptions,
|
|
217
|
+
"options",
|
|
218
|
+
() => ({}),
|
|
219
|
+
() => ReflectionClass,
|
|
220
|
+
"createSecretsReflection",
|
|
221
|
+
"Pn!2\"n#2$>%P\"7&/'"
|
|
222
|
+
];
|
|
89
223
|
/**
|
|
90
224
|
* Reflects the environment configuration type definition from the provided file and name, and merges it with the default environment configuration reflection and the currently used environment configuration reflection.
|
|
91
225
|
*
|
|
@@ -109,6 +243,15 @@ async function reflectEnv(context, file, name) {
|
|
|
109
243
|
resolveClassType(await reflectType(context, await getEnvDefaultTypeDefinition(context)))
|
|
110
244
|
].filter(Boolean));
|
|
111
245
|
}
|
|
246
|
+
reflectEnv.__type = [
|
|
247
|
+
() => __ΩEnvPluginContext,
|
|
248
|
+
"context",
|
|
249
|
+
"file",
|
|
250
|
+
"name",
|
|
251
|
+
"reflectEnv",
|
|
252
|
+
"Reflects the environment configuration type definition from the provided file and name, and merges it with the default environment configuration reflection and the currently used environment configuration reflection.",
|
|
253
|
+
"Pn!2\"&2#8&2$8\"/%?&"
|
|
254
|
+
];
|
|
112
255
|
/**
|
|
113
256
|
* Reflects the secrets configuration type definition from the provided file and name, and merges it with the default secrets configuration reflection and the currently used secrets configuration reflection.
|
|
114
257
|
*
|
|
@@ -132,7 +275,16 @@ async function reflectSecrets(context, file, name) {
|
|
|
132
275
|
resolveClassType(await reflectType(context, await getSecretsDefaultTypeDefinition(context)))
|
|
133
276
|
].filter(Boolean));
|
|
134
277
|
}
|
|
278
|
+
reflectSecrets.__type = [
|
|
279
|
+
() => __ΩEnvPluginContext,
|
|
280
|
+
"context",
|
|
281
|
+
"file",
|
|
282
|
+
"name",
|
|
283
|
+
"reflectSecrets",
|
|
284
|
+
"Reflects the secrets configuration type definition from the provided file and name, and merges it with the default secrets configuration reflection and the currently used secrets configuration reflection.",
|
|
285
|
+
"Pn!2\"&2#8&2$8\"/%?&"
|
|
286
|
+
];
|
|
135
287
|
|
|
136
288
|
//#endregion
|
|
137
|
-
export { BaseEnv, BaseSecrets, createEnvReflection, createSecretsReflection, mergeEnvReflections, mergeSecretsReflections, reflectEnv, reflectSecrets };
|
|
289
|
+
export { BaseEnv, BaseSecrets, __ΩCreateEnvReflectionOptions, createEnvReflection, createSecretsReflection, mergeEnvReflections, mergeSecretsReflections, reflectEnv, reflectSecrets };
|
|
138
290
|
//# sourceMappingURL=reflect.mjs.map
|