@powerlines/plugin-env 0.16.183 → 0.16.184

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.
Files changed (51) hide show
  1. package/dist/_virtual/_rolldown/runtime.cjs +29 -1
  2. package/dist/babel/index.cjs +4 -1
  3. package/dist/babel/index.mjs +3 -1
  4. package/dist/babel/plugin.cjs +137 -4
  5. package/dist/babel/plugin.mjs +135 -4
  6. package/dist/babel/plugin.mjs.map +1 -1
  7. package/dist/components/docs.cjs +111 -1
  8. package/dist/components/docs.mjs +108 -1
  9. package/dist/components/docs.mjs.map +1 -1
  10. package/dist/components/env-builtin.cjs +730 -13
  11. package/dist/components/env-builtin.mjs +726 -11
  12. package/dist/components/env-builtin.mjs.map +1 -1
  13. package/dist/components/index.cjs +9 -1
  14. package/dist/components/index.mjs +4 -1
  15. package/dist/helpers/automd-generator.cjs +32 -1
  16. package/dist/helpers/automd-generator.mjs +30 -1
  17. package/dist/helpers/automd-generator.mjs.map +1 -1
  18. package/dist/helpers/create-reflection-resource.cjs +23 -1
  19. package/dist/helpers/create-reflection-resource.mjs +22 -1
  20. package/dist/helpers/create-reflection-resource.mjs.map +1 -1
  21. package/dist/helpers/index.cjs +34 -1
  22. package/dist/helpers/index.mjs +8 -1
  23. package/dist/helpers/load.cjs +141 -1
  24. package/dist/helpers/load.d.cts +1 -1
  25. package/dist/helpers/load.d.mts +1 -1
  26. package/dist/helpers/load.mjs +137 -1
  27. package/dist/helpers/load.mjs.map +1 -1
  28. package/dist/helpers/persistence.cjs +308 -1
  29. package/dist/helpers/persistence.mjs +295 -1
  30. package/dist/helpers/persistence.mjs.map +1 -1
  31. package/dist/helpers/reflect.cjs +290 -1
  32. package/dist/helpers/reflect.mjs +280 -1
  33. package/dist/helpers/reflect.mjs.map +1 -1
  34. package/dist/helpers/source-file-env.cjs +59 -1
  35. package/dist/helpers/source-file-env.mjs +56 -1
  36. package/dist/helpers/source-file-env.mjs.map +1 -1
  37. package/dist/helpers/template-helpers.cjs +70 -1
  38. package/dist/helpers/template-helpers.mjs +68 -1
  39. package/dist/helpers/template-helpers.mjs.map +1 -1
  40. package/dist/index.cjs +310 -7
  41. package/dist/index.mjs +296 -7
  42. package/dist/index.mjs.map +1 -1
  43. package/dist/types/env.cjs +541 -1
  44. package/dist/types/env.mjs +538 -1
  45. package/dist/types/env.mjs.map +1 -1
  46. package/dist/types/index.cjs +11 -1
  47. package/dist/types/index.mjs +4 -1
  48. package/dist/types/plugin.cjs +115 -1
  49. package/dist/types/plugin.mjs +109 -1
  50. package/dist/types/plugin.mjs.map +1 -1
  51. package/package.json +9 -9
@@ -1 +1,290 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../_virtual/_rolldown/runtime.cjs`);const e=require(`../types/plugin.cjs`),t=require(`../types/env.cjs`),n=require(`./persistence.cjs`);let r=require(`@stryke/string-format/title-case`),i=require(`@powerlines/deepkit/vendor/type`),a=require(`@stryke/path/join-paths`),o=require(`@powerlines/deepkit/reflect-type`),s=require(`@stryke/path/is-parent-path`);function c(e,t){return e.__type=t,e}function l(e,t){return m(e,{type:(0,i.merge)(t.map(c(e=>e.type,[`reflection`,``,`P"2!"/"`])))})}l.__type=[()=>e.__ΩEnvPluginContext,`context`,`reflections`,`mergeEnvReflections`,`Pn!2"!F2#!/$`];function u(e,t){return h(e,{type:(0,i.merge)(t.map(c(e=>e.type,[`reflection`,``,`P"2!"/"`])))})}u.__type=[()=>e.__ΩEnvPluginContext,`context`,`reflections`,`mergeSecretsReflections`,`Pn!2"!F2#!/$`];const d=[`type`,`superReflection`,`CreateEnvReflectionOptions`,`PP!!J4!8!4"8Mw#y`];var f=class{APP_NAME;APP_VERSION;BUILD_ID;BUILD_TIMESTAMP;BUILD_CHECKSUM;RELEASE_ID;RELEASE_TAG;ORGANIZATION;PLATFORM=`neutral`;MODE=`production`;ENVIRONMENT;DEBUG=!1;TEST=!1;MINIMAL=!1;NO_COLOR=!1;FORCE_COLOR=!1;FORCE_HYPERLINK=!1;STACKTRACE=!1;INCLUDE_ERROR_DATA=!1;ERROR_URL;DEFAULT_TIMEZONE;DEFAULT_LOCALE;CI=!1;static __type=[`APP_NAME`,`APP_VERSION`,`BUILD_ID`,`BUILD_TIMESTAMP`,`BUILD_CHECKSUM`,`RELEASE_ID`,`RELEASE_TAG`,`ORGANIZATION`,`node`,`browser`,`neutral`,`PLATFORM`,function(){return`neutral`},`development`,`test`,`production`,`MODE`,function(){return`production`},`ENVIRONMENT`,`DEBUG`,function(){return!1},`TEST`,function(){return!1},`MINIMAL`,function(){return!1},`NO_COLOR`,function(){return!1},`FORCE_COLOR`,function(){return!1},`FORCE_HYPERLINK`,function(){return!1},`STACKTRACE`,function(){return!1},`INCLUDE_ERROR_DATA`,function(){return!1},`ERROR_URL`,`DEFAULT_TIMEZONE`,`DEFAULT_LOCALE`,`CI`,function(){return!1},()=>t.__ΩEnvInterface,`BaseEnv`,`&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`]},p=class{ENCRYPTION_KEY;static __type=[`ENCRYPTION_KEY`,()=>t.__ΩSecretsInterface,`BaseSecrets`,`&3!5n"x"w#`]};function m(e,t={}){let n=t.superReflection??new i.ReflectionClass({kind:i.ReflectionKind.class,description:`The base environment configuration definition for the ${(0,r.titleCase)(e.config.name)} project.`,classType:f,types:[],implements:[{kind:i.ReflectionKind.objectLiteral,typeName:`EnvInterface`,description:`The environment configuration interface definition for the ${(0,r.titleCase)(e.config.name)} project.`,types:[]}]});n.name=`Env`;let a=new i.ReflectionClass(t.type??{kind:i.ReflectionKind.objectLiteral,typeName:`Env`,description:`A schema describing the list of available environment variables that can be used by the ${e.config.name?`${(0,r.titleCase)(e.config.name)} application`:`application`}.`,types:[]},n);return a.name=`Env`,a}m.__type=[()=>e.__ΩEnvPluginContext,`context`,()=>d,`options`,()=>({}),`createEnvReflection`,`Pn!2"n#2$>%!/&`];function h(e,t={}){let n=t.superReflection??new i.ReflectionClass({kind:i.ReflectionKind.class,description:`The base secrets configuration definition for the ${(0,r.titleCase)(e.config.name)} project.`,classType:p,types:[],implements:[{kind:i.ReflectionKind.objectLiteral,typeName:`SecretsInterface`,description:`The secrets configuration interface definition for the ${(0,r.titleCase)(e.config.name)} project.`,types:[]}]});n.name=`Secrets`;let a=new i.ReflectionClass(t.type??{kind:i.ReflectionKind.objectLiteral,typeName:`Secrets`,description:`A schema describing the list of available environment secrets that can be used by the ${e.config.name?`${(0,r.titleCase)(e.config.name)} application`:`application`}.`,types:[]},n);return a.name=`Secrets`,a}h.__type=[()=>e.__ΩEnvPluginContext,`context`,()=>d,`options`,()=>({}),`createSecretsReflection`,`Pn!2"n#2$>%!/&`];async function g(e,t,r){let c;return t&&(c=(0,i.resolveClassType)(await(0,o.reflectType)(e,{file:(0,s.isParentPath)(t,e.config.cwd)?t:(0,a.joinPaths)(e.config.cwd,t),name:r}))),l(e,[await n.readEnvTypeReflection(e,`env`),c,(0,i.resolveClassType)(await(0,o.reflectType)(e,await n.getEnvDefaultTypeDefinition(e)))].filter(Boolean))}g.__type=[()=>e.__ΩEnvPluginContext,`context`,`file`,`name`,`reflectEnv`,`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.`,`Pn!2"&2#8&2$8"/%?&`];async function _(e,t,r){let c;return t&&(c=(0,i.resolveClassType)(await(0,o.reflectType)(e,{file:(0,s.isParentPath)(t,e.config.cwd)?t:(0,a.joinPaths)(e.config.cwd,t),name:r}))),u(e,[await n.readSecretsReflection(e),c,(0,i.resolveClassType)(await(0,o.reflectType)(e,await n.getSecretsDefaultTypeDefinition(e)))].filter(Boolean))}_.__type=[()=>e.__ΩEnvPluginContext,`context`,`file`,`name`,`reflectSecrets`,`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.`,`Pn!2"&2#8&2$8"/%?&`],exports.BaseEnv=f,exports.BaseSecrets=p,exports.__ΩCreateEnvReflectionOptions=d,exports.createEnvReflection=m,exports.createSecretsReflection=h,exports.mergeEnvReflections=l,exports.mergeSecretsReflections=u,exports.reflectEnv=g,exports.reflectSecrets=_;
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
3
+ const require_types_plugin = require('../types/plugin.cjs');
4
+ const require_types_env = require('../types/env.cjs');
5
+ const require_helpers_persistence = require('./persistence.cjs');
6
+ let _stryke_string_format_title_case = require("@stryke/string-format/title-case");
7
+ let _powerlines_deepkit_vendor_type = require("@powerlines/deepkit/vendor/type");
8
+ let _stryke_path_join_paths = require("@stryke/path/join-paths");
9
+ let _powerlines_deepkit_reflect_type = require("@powerlines/deepkit/reflect-type");
10
+ let _stryke_path_is_parent_path = require("@stryke/path/is-parent-path");
11
+
12
+ //#region src/helpers/reflect.ts
13
+ function __assignType(fn, args) {
14
+ fn.__type = args;
15
+ return fn;
16
+ }
17
+ function mergeEnvReflections(context, reflections) {
18
+ return createEnvReflection(context, { type: (0, _powerlines_deepkit_vendor_type.merge)(reflections.map(__assignType((reflection) => reflection.type, [
19
+ "reflection",
20
+ "",
21
+ "P\"2!\"/\""
22
+ ]))) });
23
+ }
24
+ mergeEnvReflections.__type = [
25
+ () => require_types_plugin.__ΩEnvPluginContext,
26
+ "context",
27
+ "reflections",
28
+ "mergeEnvReflections",
29
+ "Pn!2\"!F2#!/$"
30
+ ];
31
+ function mergeSecretsReflections(context, reflections) {
32
+ return createSecretsReflection(context, { type: (0, _powerlines_deepkit_vendor_type.merge)(reflections.map(__assignType((reflection) => reflection.type, [
33
+ "reflection",
34
+ "",
35
+ "P\"2!\"/\""
36
+ ]))) });
37
+ }
38
+ mergeSecretsReflections.__type = [
39
+ () => require_types_plugin.__ΩEnvPluginContext,
40
+ "context",
41
+ "reflections",
42
+ "mergeSecretsReflections",
43
+ "Pn!2\"!F2#!/$"
44
+ ];
45
+ const __ΩCreateEnvReflectionOptions = [
46
+ "type",
47
+ "superReflection",
48
+ "CreateEnvReflectionOptions",
49
+ "PP!!J4!8!4\"8Mw#y"
50
+ ];
51
+ var BaseEnv = class {
52
+ APP_NAME;
53
+ APP_VERSION;
54
+ BUILD_ID;
55
+ BUILD_TIMESTAMP;
56
+ BUILD_CHECKSUM;
57
+ RELEASE_ID;
58
+ RELEASE_TAG;
59
+ ORGANIZATION;
60
+ PLATFORM = "neutral";
61
+ MODE = "production";
62
+ ENVIRONMENT;
63
+ DEBUG = false;
64
+ TEST = false;
65
+ MINIMAL = false;
66
+ NO_COLOR = false;
67
+ FORCE_COLOR = false;
68
+ FORCE_HYPERLINK = false;
69
+ STACKTRACE = false;
70
+ INCLUDE_ERROR_DATA = false;
71
+ ERROR_URL;
72
+ DEFAULT_TIMEZONE;
73
+ DEFAULT_LOCALE;
74
+ CI = false;
75
+ static __type = [
76
+ "APP_NAME",
77
+ "APP_VERSION",
78
+ "BUILD_ID",
79
+ "BUILD_TIMESTAMP",
80
+ "BUILD_CHECKSUM",
81
+ "RELEASE_ID",
82
+ "RELEASE_TAG",
83
+ "ORGANIZATION",
84
+ "node",
85
+ "browser",
86
+ "neutral",
87
+ "PLATFORM",
88
+ function() {
89
+ return "neutral";
90
+ },
91
+ "development",
92
+ "test",
93
+ "production",
94
+ "MODE",
95
+ function() {
96
+ return "production";
97
+ },
98
+ "ENVIRONMENT",
99
+ "DEBUG",
100
+ function() {
101
+ return false;
102
+ },
103
+ "TEST",
104
+ function() {
105
+ return false;
106
+ },
107
+ "MINIMAL",
108
+ function() {
109
+ return false;
110
+ },
111
+ "NO_COLOR",
112
+ function() {
113
+ return false;
114
+ },
115
+ "FORCE_COLOR",
116
+ function() {
117
+ return false;
118
+ },
119
+ "FORCE_HYPERLINK",
120
+ function() {
121
+ return false;
122
+ },
123
+ "STACKTRACE",
124
+ function() {
125
+ return false;
126
+ },
127
+ "INCLUDE_ERROR_DATA",
128
+ function() {
129
+ return false;
130
+ },
131
+ "ERROR_URL",
132
+ "DEFAULT_TIMEZONE",
133
+ "DEFAULT_LOCALE",
134
+ "CI",
135
+ function() {
136
+ return false;
137
+ },
138
+ () => require_types_env.__ΩEnvInterface,
139
+ "BaseEnv",
140
+ "&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"
141
+ ];
142
+ };
143
+ var BaseSecrets = class {
144
+ ENCRYPTION_KEY;
145
+ static __type = [
146
+ "ENCRYPTION_KEY",
147
+ () => require_types_env.__ΩSecretsInterface,
148
+ "BaseSecrets",
149
+ "&3!5n\"x\"w#"
150
+ ];
151
+ };
152
+ function createEnvReflection(context, options = {}) {
153
+ const parent = options.superReflection ?? new _powerlines_deepkit_vendor_type.ReflectionClass({
154
+ kind: _powerlines_deepkit_vendor_type.ReflectionKind.class,
155
+ description: `The base environment configuration definition for the ${(0, _stryke_string_format_title_case.titleCase)(context.config.name)} project.`,
156
+ classType: BaseEnv,
157
+ types: [],
158
+ implements: [{
159
+ kind: _powerlines_deepkit_vendor_type.ReflectionKind.objectLiteral,
160
+ typeName: "EnvInterface",
161
+ description: `The environment configuration interface definition for the ${(0, _stryke_string_format_title_case.titleCase)(context.config.name)} project.`,
162
+ types: []
163
+ }]
164
+ });
165
+ parent.name = "Env";
166
+ const result = new _powerlines_deepkit_vendor_type.ReflectionClass(options.type ?? {
167
+ kind: _powerlines_deepkit_vendor_type.ReflectionKind.objectLiteral,
168
+ typeName: "Env",
169
+ description: `A schema describing the list of available environment variables that can be used by the ${context.config.name ? `${(0, _stryke_string_format_title_case.titleCase)(context.config.name)} application` : "application"}.`,
170
+ types: []
171
+ }, parent);
172
+ result.name = "Env";
173
+ return result;
174
+ }
175
+ createEnvReflection.__type = [
176
+ () => require_types_plugin.__ΩEnvPluginContext,
177
+ "context",
178
+ () => __ΩCreateEnvReflectionOptions,
179
+ "options",
180
+ () => ({}),
181
+ "createEnvReflection",
182
+ "Pn!2\"n#2$>%!/&"
183
+ ];
184
+ function createSecretsReflection(context, options = {}) {
185
+ const parent = options.superReflection ?? new _powerlines_deepkit_vendor_type.ReflectionClass({
186
+ kind: _powerlines_deepkit_vendor_type.ReflectionKind.class,
187
+ description: `The base secrets configuration definition for the ${(0, _stryke_string_format_title_case.titleCase)(context.config.name)} project.`,
188
+ classType: BaseSecrets,
189
+ types: [],
190
+ implements: [{
191
+ kind: _powerlines_deepkit_vendor_type.ReflectionKind.objectLiteral,
192
+ typeName: "SecretsInterface",
193
+ description: `The secrets configuration interface definition for the ${(0, _stryke_string_format_title_case.titleCase)(context.config.name)} project.`,
194
+ types: []
195
+ }]
196
+ });
197
+ parent.name = "Secrets";
198
+ const result = new _powerlines_deepkit_vendor_type.ReflectionClass(options.type ?? {
199
+ kind: _powerlines_deepkit_vendor_type.ReflectionKind.objectLiteral,
200
+ typeName: "Secrets",
201
+ description: `A schema describing the list of available environment secrets that can be used by the ${context.config.name ? `${(0, _stryke_string_format_title_case.titleCase)(context.config.name)} application` : "application"}.`,
202
+ types: []
203
+ }, parent);
204
+ result.name = "Secrets";
205
+ return result;
206
+ }
207
+ createSecretsReflection.__type = [
208
+ () => require_types_plugin.__ΩEnvPluginContext,
209
+ "context",
210
+ () => __ΩCreateEnvReflectionOptions,
211
+ "options",
212
+ () => ({}),
213
+ "createSecretsReflection",
214
+ "Pn!2\"n#2$>%!/&"
215
+ ];
216
+ /**
217
+ * 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.
218
+ *
219
+ * @remarks
220
+ * The resulting reflection will contain the structure of the expected environment variables as defined by the type definitions provided in the plugin configuration, as well as any additional properties that are currently used in the source code and defined in the default environment configuration reflection.
221
+ *
222
+ * @param context - The plugin context
223
+ * @param file - The file path to reflect the environment configuration type definition from
224
+ * @param name - The name of the type definition to reflect the environment configuration from, if the file contains multiple type definitions. If not provided, the first type definition found in the file will be used.
225
+ * @returns A reflection of the environment configuration type definition, merged with the default environment configuration reflection and the currently used environment configuration reflection. The resulting reflection will contain the structure of the expected environment variables as defined by the type definitions provided in the plugin configuration, as well as any additional properties that are currently used in the source code and defined in the default environment configuration reflection.
226
+ */
227
+ async function reflectEnv(context, file, name) {
228
+ let config;
229
+ if (file) config = (0, _powerlines_deepkit_vendor_type.resolveClassType)(await (0, _powerlines_deepkit_reflect_type.reflectType)(context, {
230
+ file: !(0, _stryke_path_is_parent_path.isParentPath)(file, context.config.cwd) ? (0, _stryke_path_join_paths.joinPaths)(context.config.cwd, file) : file,
231
+ name
232
+ }));
233
+ return mergeEnvReflections(context, [
234
+ await require_helpers_persistence.readEnvTypeReflection(context, "env"),
235
+ config,
236
+ (0, _powerlines_deepkit_vendor_type.resolveClassType)(await (0, _powerlines_deepkit_reflect_type.reflectType)(context, await require_helpers_persistence.getEnvDefaultTypeDefinition(context)))
237
+ ].filter(Boolean));
238
+ }
239
+ reflectEnv.__type = [
240
+ () => require_types_plugin.__ΩEnvPluginContext,
241
+ "context",
242
+ "file",
243
+ "name",
244
+ "reflectEnv",
245
+ "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.",
246
+ "Pn!2\"&2#8&2$8\"/%?&"
247
+ ];
248
+ /**
249
+ * 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.
250
+ *
251
+ * @remarks
252
+ * The resulting reflection will contain the structure of the expected environment secrets as defined by the type definitions provided in the plugin configuration, as well as any additional properties that are currently used in the source code and defined in the default secrets configuration reflection.
253
+ *
254
+ * @param context - The plugin context
255
+ * @param file - The file path to reflect the secrets configuration type definition from
256
+ * @param name - The name of the type definition to reflect the secrets configuration from, if the file contains multiple type definitions. If not provided, the first type definition found in the file will be used.
257
+ * @returns A reflection of the secrets configuration type definition, merged with the default secrets configuration reflection and the currently used secrets configuration reflection. The resulting reflection will contain the structure of the expected environment secrets as defined by the type definitions provided in the plugin configuration, as well as any additional properties that are currently used in the source code and defined in the default secrets configuration reflection.
258
+ */
259
+ async function reflectSecrets(context, file, name) {
260
+ let config;
261
+ if (file) config = (0, _powerlines_deepkit_vendor_type.resolveClassType)(await (0, _powerlines_deepkit_reflect_type.reflectType)(context, {
262
+ file: !(0, _stryke_path_is_parent_path.isParentPath)(file, context.config.cwd) ? (0, _stryke_path_join_paths.joinPaths)(context.config.cwd, file) : file,
263
+ name
264
+ }));
265
+ return mergeSecretsReflections(context, [
266
+ await require_helpers_persistence.readSecretsReflection(context),
267
+ config,
268
+ (0, _powerlines_deepkit_vendor_type.resolveClassType)(await (0, _powerlines_deepkit_reflect_type.reflectType)(context, await require_helpers_persistence.getSecretsDefaultTypeDefinition(context)))
269
+ ].filter(Boolean));
270
+ }
271
+ reflectSecrets.__type = [
272
+ () => require_types_plugin.__ΩEnvPluginContext,
273
+ "context",
274
+ "file",
275
+ "name",
276
+ "reflectSecrets",
277
+ "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.",
278
+ "Pn!2\"&2#8&2$8\"/%?&"
279
+ ];
280
+
281
+ //#endregion
282
+ exports.BaseEnv = BaseEnv;
283
+ exports.BaseSecrets = BaseSecrets;
284
+ exports.__ΩCreateEnvReflectionOptions = __ΩCreateEnvReflectionOptions;
285
+ exports.createEnvReflection = createEnvReflection;
286
+ exports.createSecretsReflection = createSecretsReflection;
287
+ exports.mergeEnvReflections = mergeEnvReflections;
288
+ exports.mergeSecretsReflections = mergeSecretsReflections;
289
+ exports.reflectEnv = reflectEnv;
290
+ exports.reflectSecrets = reflectSecrets;
@@ -1,2 +1,281 @@
1
- import{__ΩEnvPluginContext as e}from"../types/plugin.mjs";import{__ΩEnvInterface as t,__ΩSecretsInterface as n}from"../types/env.mjs";import{getEnvDefaultTypeDefinition as r,getSecretsDefaultTypeDefinition as i,readEnvTypeReflection as a,readSecretsReflection as o}from"./persistence.mjs";import{titleCase as s}from"@stryke/string-format/title-case";import{ReflectionClass as c,ReflectionKind as l,merge as u,resolveClassType as d}from"@powerlines/deepkit/vendor/type";import{joinPaths as f}from"@stryke/path/join-paths";import{reflectType as p}from"@powerlines/deepkit/reflect-type";import{isParentPath as m}from"@stryke/path/is-parent-path";function h(e,t){return e.__type=t,e}function g(e,t){return x(e,{type:u(t.map(h(e=>e.type,[`reflection`,``,`P"2!"/"`])))})}g.__type=[()=>e,`context`,`reflections`,`mergeEnvReflections`,`Pn!2"!F2#!/$`];function _(e,t){return S(e,{type:u(t.map(h(e=>e.type,[`reflection`,``,`P"2!"/"`])))})}_.__type=[()=>e,`context`,`reflections`,`mergeSecretsReflections`,`Pn!2"!F2#!/$`];const v=[`type`,`superReflection`,`CreateEnvReflectionOptions`,`PP!!J4!8!4"8Mw#y`];var y=class{APP_NAME;APP_VERSION;BUILD_ID;BUILD_TIMESTAMP;BUILD_CHECKSUM;RELEASE_ID;RELEASE_TAG;ORGANIZATION;PLATFORM=`neutral`;MODE=`production`;ENVIRONMENT;DEBUG=!1;TEST=!1;MINIMAL=!1;NO_COLOR=!1;FORCE_COLOR=!1;FORCE_HYPERLINK=!1;STACKTRACE=!1;INCLUDE_ERROR_DATA=!1;ERROR_URL;DEFAULT_TIMEZONE;DEFAULT_LOCALE;CI=!1;static __type=[`APP_NAME`,`APP_VERSION`,`BUILD_ID`,`BUILD_TIMESTAMP`,`BUILD_CHECKSUM`,`RELEASE_ID`,`RELEASE_TAG`,`ORGANIZATION`,`node`,`browser`,`neutral`,`PLATFORM`,function(){return`neutral`},`development`,`test`,`production`,`MODE`,function(){return`production`},`ENVIRONMENT`,`DEBUG`,function(){return!1},`TEST`,function(){return!1},`MINIMAL`,function(){return!1},`NO_COLOR`,function(){return!1},`FORCE_COLOR`,function(){return!1},`FORCE_HYPERLINK`,function(){return!1},`STACKTRACE`,function(){return!1},`INCLUDE_ERROR_DATA`,function(){return!1},`ERROR_URL`,`DEFAULT_TIMEZONE`,`DEFAULT_LOCALE`,`CI`,function(){return!1},()=>t,`BaseEnv`,`&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`]},b=class{ENCRYPTION_KEY;static __type=[`ENCRYPTION_KEY`,()=>n,`BaseSecrets`,`&3!5n"x"w#`]};function x(e,t={}){let n=t.superReflection??new c({kind:l.class,description:`The base environment configuration definition for the ${s(e.config.name)} project.`,classType:y,types:[],implements:[{kind:l.objectLiteral,typeName:`EnvInterface`,description:`The environment configuration interface definition for the ${s(e.config.name)} project.`,types:[]}]});n.name=`Env`;let r=new c(t.type??{kind:l.objectLiteral,typeName:`Env`,description:`A schema describing the list of available environment variables that can be used by the ${e.config.name?`${s(e.config.name)} application`:`application`}.`,types:[]},n);return r.name=`Env`,r}x.__type=[()=>e,`context`,()=>v,`options`,()=>({}),`createEnvReflection`,`Pn!2"n#2$>%!/&`];function S(e,t={}){let n=t.superReflection??new c({kind:l.class,description:`The base secrets configuration definition for the ${s(e.config.name)} project.`,classType:b,types:[],implements:[{kind:l.objectLiteral,typeName:`SecretsInterface`,description:`The secrets configuration interface definition for the ${s(e.config.name)} project.`,types:[]}]});n.name=`Secrets`;let r=new c(t.type??{kind:l.objectLiteral,typeName:`Secrets`,description:`A schema describing the list of available environment secrets that can be used by the ${e.config.name?`${s(e.config.name)} application`:`application`}.`,types:[]},n);return r.name=`Secrets`,r}S.__type=[()=>e,`context`,()=>v,`options`,()=>({}),`createSecretsReflection`,`Pn!2"n#2$>%!/&`];async function C(e,t,n){let i;return t&&(i=d(await p(e,{file:m(t,e.config.cwd)?t:f(e.config.cwd,t),name:n}))),g(e,[await a(e,`env`),i,d(await p(e,await r(e)))].filter(Boolean))}C.__type=[()=>e,`context`,`file`,`name`,`reflectEnv`,`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.`,`Pn!2"&2#8&2$8"/%?&`];async function w(e,t,n){let r;return t&&(r=d(await p(e,{file:m(t,e.config.cwd)?t:f(e.config.cwd,t),name:n}))),_(e,[await o(e),r,d(await p(e,await i(e)))].filter(Boolean))}w.__type=[()=>e,`context`,`file`,`name`,`reflectSecrets`,`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.`,`Pn!2"&2#8&2$8"/%?&`];export{y as BaseEnv,b as BaseSecrets,v as __ΩCreateEnvReflectionOptions,x as createEnvReflection,S as createSecretsReflection,g as mergeEnvReflections,_ as mergeSecretsReflections,C as reflectEnv,w as reflectSecrets};
1
+ import { __ΩEnvPluginContext } from "../types/plugin.mjs";
2
+ import { __ΩEnvInterface, __ΩSecretsInterface } from "../types/env.mjs";
3
+ import { getEnvDefaultTypeDefinition, getSecretsDefaultTypeDefinition, readEnvTypeReflection, readSecretsReflection } from "./persistence.mjs";
4
+ import { titleCase } from "@stryke/string-format/title-case";
5
+ import { ReflectionClass, ReflectionKind, merge, resolveClassType } from "@powerlines/deepkit/vendor/type";
6
+ import { joinPaths } from "@stryke/path/join-paths";
7
+ import { reflectType } from "@powerlines/deepkit/reflect-type";
8
+ import { isParentPath } from "@stryke/path/is-parent-path";
9
+
10
+ //#region src/helpers/reflect.ts
11
+ function __assignType(fn, args) {
12
+ fn.__type = args;
13
+ return fn;
14
+ }
15
+ function mergeEnvReflections(context, reflections) {
16
+ return createEnvReflection(context, { type: merge(reflections.map(__assignType((reflection) => reflection.type, [
17
+ "reflection",
18
+ "",
19
+ "P\"2!\"/\""
20
+ ]))) });
21
+ }
22
+ mergeEnvReflections.__type = [
23
+ () => __ΩEnvPluginContext,
24
+ "context",
25
+ "reflections",
26
+ "mergeEnvReflections",
27
+ "Pn!2\"!F2#!/$"
28
+ ];
29
+ function mergeSecretsReflections(context, reflections) {
30
+ return createSecretsReflection(context, { type: merge(reflections.map(__assignType((reflection) => reflection.type, [
31
+ "reflection",
32
+ "",
33
+ "P\"2!\"/\""
34
+ ]))) });
35
+ }
36
+ mergeSecretsReflections.__type = [
37
+ () => __ΩEnvPluginContext,
38
+ "context",
39
+ "reflections",
40
+ "mergeSecretsReflections",
41
+ "Pn!2\"!F2#!/$"
42
+ ];
43
+ const __ΩCreateEnvReflectionOptions = [
44
+ "type",
45
+ "superReflection",
46
+ "CreateEnvReflectionOptions",
47
+ "PP!!J4!8!4\"8Mw#y"
48
+ ];
49
+ var BaseEnv = class {
50
+ APP_NAME;
51
+ APP_VERSION;
52
+ BUILD_ID;
53
+ BUILD_TIMESTAMP;
54
+ BUILD_CHECKSUM;
55
+ RELEASE_ID;
56
+ RELEASE_TAG;
57
+ ORGANIZATION;
58
+ PLATFORM = "neutral";
59
+ MODE = "production";
60
+ ENVIRONMENT;
61
+ DEBUG = false;
62
+ TEST = false;
63
+ MINIMAL = false;
64
+ NO_COLOR = false;
65
+ FORCE_COLOR = false;
66
+ FORCE_HYPERLINK = false;
67
+ STACKTRACE = false;
68
+ INCLUDE_ERROR_DATA = false;
69
+ ERROR_URL;
70
+ DEFAULT_TIMEZONE;
71
+ DEFAULT_LOCALE;
72
+ CI = false;
73
+ static __type = [
74
+ "APP_NAME",
75
+ "APP_VERSION",
76
+ "BUILD_ID",
77
+ "BUILD_TIMESTAMP",
78
+ "BUILD_CHECKSUM",
79
+ "RELEASE_ID",
80
+ "RELEASE_TAG",
81
+ "ORGANIZATION",
82
+ "node",
83
+ "browser",
84
+ "neutral",
85
+ "PLATFORM",
86
+ function() {
87
+ return "neutral";
88
+ },
89
+ "development",
90
+ "test",
91
+ "production",
92
+ "MODE",
93
+ function() {
94
+ return "production";
95
+ },
96
+ "ENVIRONMENT",
97
+ "DEBUG",
98
+ function() {
99
+ return false;
100
+ },
101
+ "TEST",
102
+ function() {
103
+ return false;
104
+ },
105
+ "MINIMAL",
106
+ function() {
107
+ return false;
108
+ },
109
+ "NO_COLOR",
110
+ function() {
111
+ return false;
112
+ },
113
+ "FORCE_COLOR",
114
+ function() {
115
+ return false;
116
+ },
117
+ "FORCE_HYPERLINK",
118
+ function() {
119
+ return false;
120
+ },
121
+ "STACKTRACE",
122
+ function() {
123
+ return false;
124
+ },
125
+ "INCLUDE_ERROR_DATA",
126
+ function() {
127
+ return false;
128
+ },
129
+ "ERROR_URL",
130
+ "DEFAULT_TIMEZONE",
131
+ "DEFAULT_LOCALE",
132
+ "CI",
133
+ function() {
134
+ return false;
135
+ },
136
+ () => __ΩEnvInterface,
137
+ "BaseEnv",
138
+ "&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"
139
+ ];
140
+ };
141
+ var BaseSecrets = class {
142
+ ENCRYPTION_KEY;
143
+ static __type = [
144
+ "ENCRYPTION_KEY",
145
+ () => __ΩSecretsInterface,
146
+ "BaseSecrets",
147
+ "&3!5n\"x\"w#"
148
+ ];
149
+ };
150
+ function createEnvReflection(context, options = {}) {
151
+ const parent = options.superReflection ?? new ReflectionClass({
152
+ kind: ReflectionKind.class,
153
+ description: `The base environment configuration definition for the ${titleCase(context.config.name)} project.`,
154
+ classType: BaseEnv,
155
+ types: [],
156
+ implements: [{
157
+ kind: ReflectionKind.objectLiteral,
158
+ typeName: "EnvInterface",
159
+ description: `The environment configuration interface definition for the ${titleCase(context.config.name)} project.`,
160
+ types: []
161
+ }]
162
+ });
163
+ parent.name = "Env";
164
+ const result = new ReflectionClass(options.type ?? {
165
+ kind: ReflectionKind.objectLiteral,
166
+ typeName: "Env",
167
+ description: `A schema describing the list of available environment variables that can be used by the ${context.config.name ? `${titleCase(context.config.name)} application` : "application"}.`,
168
+ types: []
169
+ }, parent);
170
+ result.name = "Env";
171
+ return result;
172
+ }
173
+ createEnvReflection.__type = [
174
+ () => __ΩEnvPluginContext,
175
+ "context",
176
+ () => __ΩCreateEnvReflectionOptions,
177
+ "options",
178
+ () => ({}),
179
+ "createEnvReflection",
180
+ "Pn!2\"n#2$>%!/&"
181
+ ];
182
+ function createSecretsReflection(context, options = {}) {
183
+ const parent = options.superReflection ?? new ReflectionClass({
184
+ kind: ReflectionKind.class,
185
+ description: `The base secrets configuration definition for the ${titleCase(context.config.name)} project.`,
186
+ classType: BaseSecrets,
187
+ types: [],
188
+ implements: [{
189
+ kind: ReflectionKind.objectLiteral,
190
+ typeName: "SecretsInterface",
191
+ description: `The secrets configuration interface definition for the ${titleCase(context.config.name)} project.`,
192
+ types: []
193
+ }]
194
+ });
195
+ parent.name = "Secrets";
196
+ const result = new ReflectionClass(options.type ?? {
197
+ kind: ReflectionKind.objectLiteral,
198
+ typeName: "Secrets",
199
+ description: `A schema describing the list of available environment secrets that can be used by the ${context.config.name ? `${titleCase(context.config.name)} application` : "application"}.`,
200
+ types: []
201
+ }, parent);
202
+ result.name = "Secrets";
203
+ return result;
204
+ }
205
+ createSecretsReflection.__type = [
206
+ () => __ΩEnvPluginContext,
207
+ "context",
208
+ () => __ΩCreateEnvReflectionOptions,
209
+ "options",
210
+ () => ({}),
211
+ "createSecretsReflection",
212
+ "Pn!2\"n#2$>%!/&"
213
+ ];
214
+ /**
215
+ * 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.
216
+ *
217
+ * @remarks
218
+ * The resulting reflection will contain the structure of the expected environment variables as defined by the type definitions provided in the plugin configuration, as well as any additional properties that are currently used in the source code and defined in the default environment configuration reflection.
219
+ *
220
+ * @param context - The plugin context
221
+ * @param file - The file path to reflect the environment configuration type definition from
222
+ * @param name - The name of the type definition to reflect the environment configuration from, if the file contains multiple type definitions. If not provided, the first type definition found in the file will be used.
223
+ * @returns A reflection of the environment configuration type definition, merged with the default environment configuration reflection and the currently used environment configuration reflection. The resulting reflection will contain the structure of the expected environment variables as defined by the type definitions provided in the plugin configuration, as well as any additional properties that are currently used in the source code and defined in the default environment configuration reflection.
224
+ */
225
+ async function reflectEnv(context, file, name) {
226
+ let config;
227
+ if (file) config = resolveClassType(await reflectType(context, {
228
+ file: !isParentPath(file, context.config.cwd) ? joinPaths(context.config.cwd, file) : file,
229
+ name
230
+ }));
231
+ return mergeEnvReflections(context, [
232
+ await readEnvTypeReflection(context, "env"),
233
+ config,
234
+ resolveClassType(await reflectType(context, await getEnvDefaultTypeDefinition(context)))
235
+ ].filter(Boolean));
236
+ }
237
+ reflectEnv.__type = [
238
+ () => __ΩEnvPluginContext,
239
+ "context",
240
+ "file",
241
+ "name",
242
+ "reflectEnv",
243
+ "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.",
244
+ "Pn!2\"&2#8&2$8\"/%?&"
245
+ ];
246
+ /**
247
+ * 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.
248
+ *
249
+ * @remarks
250
+ * The resulting reflection will contain the structure of the expected environment secrets as defined by the type definitions provided in the plugin configuration, as well as any additional properties that are currently used in the source code and defined in the default secrets configuration reflection.
251
+ *
252
+ * @param context - The plugin context
253
+ * @param file - The file path to reflect the secrets configuration type definition from
254
+ * @param name - The name of the type definition to reflect the secrets configuration from, if the file contains multiple type definitions. If not provided, the first type definition found in the file will be used.
255
+ * @returns A reflection of the secrets configuration type definition, merged with the default secrets configuration reflection and the currently used secrets configuration reflection. The resulting reflection will contain the structure of the expected environment secrets as defined by the type definitions provided in the plugin configuration, as well as any additional properties that are currently used in the source code and defined in the default secrets configuration reflection.
256
+ */
257
+ async function reflectSecrets(context, file, name) {
258
+ let config;
259
+ if (file) config = resolveClassType(await reflectType(context, {
260
+ file: !isParentPath(file, context.config.cwd) ? joinPaths(context.config.cwd, file) : file,
261
+ name
262
+ }));
263
+ return mergeSecretsReflections(context, [
264
+ await readSecretsReflection(context),
265
+ config,
266
+ resolveClassType(await reflectType(context, await getSecretsDefaultTypeDefinition(context)))
267
+ ].filter(Boolean));
268
+ }
269
+ reflectSecrets.__type = [
270
+ () => __ΩEnvPluginContext,
271
+ "context",
272
+ "file",
273
+ "name",
274
+ "reflectSecrets",
275
+ "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.",
276
+ "Pn!2\"&2#8&2$8\"/%?&"
277
+ ];
278
+
279
+ //#endregion
280
+ export { BaseEnv, BaseSecrets, __ΩCreateEnvReflectionOptions, createEnvReflection, createSecretsReflection, mergeEnvReflections, mergeSecretsReflections, reflectEnv, reflectSecrets };
2
281
  //# sourceMappingURL=reflect.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"reflect.mjs","names":[],"sources":["../../src/helpers/reflect.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 { reflectType } from \"@powerlines/deepkit/reflect-type\";\nimport {\n merge,\n ReflectionClass,\n ReflectionKind,\n resolveClassType,\n TypeClass,\n TypeObjectLiteral\n} from \"@powerlines/deepkit/vendor/type\";\nimport { isParentPath } from \"@stryke/path/is-parent-path\";\nimport { joinPaths } from \"@stryke/path/join-paths\";\nimport { titleCase } from \"@stryke/string-format/title-case\";\nimport { EnvInterface, SecretsInterface } from \"../types/env\";\nimport { EnvPluginContext } from \"../types/plugin\";\nimport {\n getEnvDefaultTypeDefinition,\n getSecretsDefaultTypeDefinition,\n readEnvTypeReflection,\n readSecretsReflection\n} from \"./persistence\";\n\nexport function mergeEnvReflections(\n context: EnvPluginContext,\n reflections: ReflectionClass<any>[]\n): ReflectionClass<any> {\n const reflection = createEnvReflection(context, {\n type: merge(reflections.map(reflection => reflection.type))\n });\n\n return reflection;\n}\n\nexport function mergeSecretsReflections(\n context: EnvPluginContext,\n reflections: ReflectionClass<any>[]\n): ReflectionClass<any> {\n const reflection = createSecretsReflection(context, {\n type: merge(reflections.map(reflection => reflection.type))\n });\n\n return reflection;\n}\n\nexport interface CreateEnvReflectionOptions {\n type?: TypeObjectLiteral | TypeClass;\n superReflection?: ReflectionClass<any>;\n}\n\nexport class BaseEnv implements EnvInterface {\n APP_NAME!: string;\n\n APP_VERSION!: string;\n\n BUILD_ID!: string;\n\n BUILD_TIMESTAMP!: string;\n\n BUILD_CHECKSUM!: string;\n\n RELEASE_ID!: string;\n\n RELEASE_TAG!: string;\n\n ORGANIZATION!: string;\n\n PLATFORM: \"node\" | \"browser\" | \"neutral\" = \"neutral\";\n\n MODE: \"development\" | \"test\" | \"production\" = \"production\";\n\n ENVIRONMENT!: string;\n\n DEBUG: boolean = false;\n\n TEST: boolean = false;\n\n MINIMAL: boolean = false;\n\n NO_COLOR: boolean = false;\n\n FORCE_COLOR: number | boolean = false;\n\n FORCE_HYPERLINK: number | boolean = false;\n\n STACKTRACE: boolean = false;\n\n INCLUDE_ERROR_DATA: boolean = false;\n\n ERROR_URL!: string;\n\n DEFAULT_TIMEZONE!: string;\n\n DEFAULT_LOCALE!: string;\n\n CI: boolean = false;\n}\n\nexport class BaseSecrets implements SecretsInterface {\n ENCRYPTION_KEY!: string;\n}\n\nexport function createEnvReflection(\n context: EnvPluginContext,\n options: CreateEnvReflectionOptions = {}\n): ReflectionClass<any> {\n const parent =\n options.superReflection ??\n new ReflectionClass({\n kind: ReflectionKind.class,\n description: `The base environment configuration definition for the ${titleCase(\n context.config.name\n )} project.`,\n classType: BaseEnv,\n types: [],\n implements: [\n {\n kind: ReflectionKind.objectLiteral,\n typeName: \"EnvInterface\",\n description: `The environment configuration interface definition for the ${titleCase(\n context.config.name\n )} project.`,\n types: []\n }\n ]\n });\n parent.name = \"Env\";\n\n const result = new ReflectionClass(\n options.type ?? {\n kind: ReflectionKind.objectLiteral,\n typeName: \"Env\",\n description: `A schema describing the list of available environment variables that can be used by the ${\n context.config.name\n ? `${titleCase(context.config.name)} application`\n : \"application\"\n }.`,\n types: []\n },\n parent\n );\n result.name = \"Env\";\n\n return result;\n}\n\nexport function createSecretsReflection(\n context: EnvPluginContext,\n options: CreateEnvReflectionOptions = {}\n): ReflectionClass<any> {\n const parent =\n options.superReflection ??\n new ReflectionClass({\n kind: ReflectionKind.class,\n description: `The base secrets configuration definition for the ${titleCase(\n context.config.name\n )} project.`,\n classType: BaseSecrets,\n types: [],\n implements: [\n {\n kind: ReflectionKind.objectLiteral,\n typeName: \"SecretsInterface\",\n description: `The secrets configuration interface definition for the ${titleCase(\n context.config.name\n )} project.`,\n types: []\n }\n ]\n });\n parent.name = \"Secrets\";\n\n const result = new ReflectionClass(\n options.type ?? {\n kind: ReflectionKind.objectLiteral,\n typeName: \"Secrets\",\n description: `A schema describing the list of available environment secrets that can be used by the ${\n context.config.name\n ? `${titleCase(context.config.name)} application`\n : \"application\"\n }.`,\n types: []\n },\n parent\n );\n result.name = \"Secrets\";\n\n return result;\n}\n\n/**\n * 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.\n *\n * @remarks\n * The resulting reflection will contain the structure of the expected environment variables as defined by the type definitions provided in the plugin configuration, as well as any additional properties that are currently used in the source code and defined in the default environment configuration reflection.\n *\n * @param context - The plugin context\n * @param file - The file path to reflect the environment configuration type definition from\n * @param name - The name of the type definition to reflect the environment configuration from, if the file contains multiple type definitions. If not provided, the first type definition found in the file will be used.\n * @returns A reflection of the environment configuration type definition, merged with the default environment configuration reflection and the currently used environment configuration reflection. The resulting reflection will contain the structure of the expected environment variables as defined by the type definitions provided in the plugin configuration, as well as any additional properties that are currently used in the source code and defined in the default environment configuration reflection.\n */\nexport async function reflectEnv(\n context: EnvPluginContext,\n file?: string,\n name?: string\n) {\n let config: ReflectionClass<any> | undefined;\n if (file) {\n const configType = await reflectType(context, {\n file: !isParentPath(file, context.config.cwd)\n ? joinPaths(context.config.cwd, file)\n : file,\n name\n });\n\n config = resolveClassType(configType);\n }\n\n return mergeEnvReflections(\n context,\n [\n await readEnvTypeReflection(context, \"env\"),\n config,\n resolveClassType(\n await reflectType(context, await getEnvDefaultTypeDefinition(context))\n )\n ].filter(Boolean) as ReflectionClass<any>[]\n );\n}\n\n/**\n * 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.\n *\n * @remarks\n * The resulting reflection will contain the structure of the expected environment secrets as defined by the type definitions provided in the plugin configuration, as well as any additional properties that are currently used in the source code and defined in the default secrets configuration reflection.\n *\n * @param context - The plugin context\n * @param file - The file path to reflect the secrets configuration type definition from\n * @param name - The name of the type definition to reflect the secrets configuration from, if the file contains multiple type definitions. If not provided, the first type definition found in the file will be used.\n * @returns A reflection of the secrets configuration type definition, merged with the default secrets configuration reflection and the currently used secrets configuration reflection. The resulting reflection will contain the structure of the expected environment secrets as defined by the type definitions provided in the plugin configuration, as well as any additional properties that are currently used in the source code and defined in the default secrets configuration reflection.\n */\nexport async function reflectSecrets(\n context: EnvPluginContext,\n file?: string,\n name?: string\n) {\n let config: ReflectionClass<any> | undefined;\n if (file) {\n const configType = await reflectType(context, {\n file: !isParentPath(file, context.config.cwd)\n ? joinPaths(context.config.cwd, file)\n : file,\n name\n });\n\n config = resolveClassType(configType);\n }\n\n return mergeSecretsReflections(\n context,\n [\n await readSecretsReflection(context),\n config,\n resolveClassType(\n await reflectType(\n context,\n await getSecretsDefaultTypeDefinition(context)\n )\n )\n ].filter(Boolean) as ReflectionClass<any>[]\n );\n}\n"],"mappings":"moBAMA,SAAS,EAAY,EAAI,EAAO,OAC/B,GAAI,OAAS,IA0Bd,SAAE,EAA2B,EAAA,EAAA,CAI3B,OAHA,EAA+B,EAAA,CAC/B,KAAA,EAAA,EAAqB,IAAA,EAAA,GAAA,EAAA,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AI,EAQJ,OAPI,IAKF,EAAQ,EAAe,MAJF,EAAA,EAAA,4CAEvB,OACE,CAAA,CACoC,EAElC,EAAuB,EAAW,CAAG,MAAM,EAAa,EAAY,CAAO,EAAM,EAAmB,MAAC,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,CAAA,CAAA,CAAA,OAAA,QAAA,CAAA,CAE3G,EAAe,OAAS,KAAC,EAAsB,UAAW,OAAA,OAAA,iBAAA,+MAAA,qBAAA"}
1
+ {"version":3,"file":"reflect.mjs","names":[],"sources":["../../src/helpers/reflect.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 { reflectType } from \"@powerlines/deepkit/reflect-type\";\nimport {\n merge,\n ReflectionClass,\n ReflectionKind,\n resolveClassType,\n TypeClass,\n TypeObjectLiteral\n} from \"@powerlines/deepkit/vendor/type\";\nimport { isParentPath } from \"@stryke/path/is-parent-path\";\nimport { joinPaths } from \"@stryke/path/join-paths\";\nimport { titleCase } from \"@stryke/string-format/title-case\";\nimport { EnvInterface, SecretsInterface } from \"../types/env\";\nimport { EnvPluginContext } from \"../types/plugin\";\nimport {\n getEnvDefaultTypeDefinition,\n getSecretsDefaultTypeDefinition,\n readEnvTypeReflection,\n readSecretsReflection\n} from \"./persistence\";\n\nexport function mergeEnvReflections(\n context: EnvPluginContext,\n reflections: ReflectionClass<any>[]\n): ReflectionClass<any> {\n const reflection = createEnvReflection(context, {\n type: merge(reflections.map(reflection => reflection.type))\n });\n\n return reflection;\n}\n\nexport function mergeSecretsReflections(\n context: EnvPluginContext,\n reflections: ReflectionClass<any>[]\n): ReflectionClass<any> {\n const reflection = createSecretsReflection(context, {\n type: merge(reflections.map(reflection => reflection.type))\n });\n\n return reflection;\n}\n\nexport interface CreateEnvReflectionOptions {\n type?: TypeObjectLiteral | TypeClass;\n superReflection?: ReflectionClass<any>;\n}\n\nexport class BaseEnv implements EnvInterface {\n APP_NAME!: string;\n\n APP_VERSION!: string;\n\n BUILD_ID!: string;\n\n BUILD_TIMESTAMP!: string;\n\n BUILD_CHECKSUM!: string;\n\n RELEASE_ID!: string;\n\n RELEASE_TAG!: string;\n\n ORGANIZATION!: string;\n\n PLATFORM: \"node\" | \"browser\" | \"neutral\" = \"neutral\";\n\n MODE: \"development\" | \"test\" | \"production\" = \"production\";\n\n ENVIRONMENT!: string;\n\n DEBUG: boolean = false;\n\n TEST: boolean = false;\n\n MINIMAL: boolean = false;\n\n NO_COLOR: boolean = false;\n\n FORCE_COLOR: number | boolean = false;\n\n FORCE_HYPERLINK: number | boolean = false;\n\n STACKTRACE: boolean = false;\n\n INCLUDE_ERROR_DATA: boolean = false;\n\n ERROR_URL!: string;\n\n DEFAULT_TIMEZONE!: string;\n\n DEFAULT_LOCALE!: string;\n\n CI: boolean = false;\n}\n\nexport class BaseSecrets implements SecretsInterface {\n ENCRYPTION_KEY!: string;\n}\n\nexport function createEnvReflection(\n context: EnvPluginContext,\n options: CreateEnvReflectionOptions = {}\n): ReflectionClass<any> {\n const parent =\n options.superReflection ??\n new ReflectionClass({\n kind: ReflectionKind.class,\n description: `The base environment configuration definition for the ${titleCase(\n context.config.name\n )} project.`,\n classType: BaseEnv,\n types: [],\n implements: [\n {\n kind: ReflectionKind.objectLiteral,\n typeName: \"EnvInterface\",\n description: `The environment configuration interface definition for the ${titleCase(\n context.config.name\n )} project.`,\n types: []\n }\n ]\n });\n parent.name = \"Env\";\n\n const result = new ReflectionClass(\n options.type ?? {\n kind: ReflectionKind.objectLiteral,\n typeName: \"Env\",\n description: `A schema describing the list of available environment variables that can be used by the ${\n context.config.name\n ? `${titleCase(context.config.name)} application`\n : \"application\"\n }.`,\n types: []\n },\n parent\n );\n result.name = \"Env\";\n\n return result;\n}\n\nexport function createSecretsReflection(\n context: EnvPluginContext,\n options: CreateEnvReflectionOptions = {}\n): ReflectionClass<any> {\n const parent =\n options.superReflection ??\n new ReflectionClass({\n kind: ReflectionKind.class,\n description: `The base secrets configuration definition for the ${titleCase(\n context.config.name\n )} project.`,\n classType: BaseSecrets,\n types: [],\n implements: [\n {\n kind: ReflectionKind.objectLiteral,\n typeName: \"SecretsInterface\",\n description: `The secrets configuration interface definition for the ${titleCase(\n context.config.name\n )} project.`,\n types: []\n }\n ]\n });\n parent.name = \"Secrets\";\n\n const result = new ReflectionClass(\n options.type ?? {\n kind: ReflectionKind.objectLiteral,\n typeName: \"Secrets\",\n description: `A schema describing the list of available environment secrets that can be used by the ${\n context.config.name\n ? `${titleCase(context.config.name)} application`\n : \"application\"\n }.`,\n types: []\n },\n parent\n );\n result.name = \"Secrets\";\n\n return result;\n}\n\n/**\n * 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.\n *\n * @remarks\n * The resulting reflection will contain the structure of the expected environment variables as defined by the type definitions provided in the plugin configuration, as well as any additional properties that are currently used in the source code and defined in the default environment configuration reflection.\n *\n * @param context - The plugin context\n * @param file - The file path to reflect the environment configuration type definition from\n * @param name - The name of the type definition to reflect the environment configuration from, if the file contains multiple type definitions. If not provided, the first type definition found in the file will be used.\n * @returns A reflection of the environment configuration type definition, merged with the default environment configuration reflection and the currently used environment configuration reflection. The resulting reflection will contain the structure of the expected environment variables as defined by the type definitions provided in the plugin configuration, as well as any additional properties that are currently used in the source code and defined in the default environment configuration reflection.\n */\nexport async function reflectEnv(\n context: EnvPluginContext,\n file?: string,\n name?: string\n) {\n let config: ReflectionClass<any> | undefined;\n if (file) {\n const configType = await reflectType(context, {\n file: !isParentPath(file, context.config.cwd)\n ? joinPaths(context.config.cwd, file)\n : file,\n name\n });\n\n config = resolveClassType(configType);\n }\n\n return mergeEnvReflections(\n context,\n [\n await readEnvTypeReflection(context, \"env\"),\n config,\n resolveClassType(\n await reflectType(context, await getEnvDefaultTypeDefinition(context))\n )\n ].filter(Boolean) as ReflectionClass<any>[]\n );\n}\n\n/**\n * 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.\n *\n * @remarks\n * The resulting reflection will contain the structure of the expected environment secrets as defined by the type definitions provided in the plugin configuration, as well as any additional properties that are currently used in the source code and defined in the default secrets configuration reflection.\n *\n * @param context - The plugin context\n * @param file - The file path to reflect the secrets configuration type definition from\n * @param name - The name of the type definition to reflect the secrets configuration from, if the file contains multiple type definitions. If not provided, the first type definition found in the file will be used.\n * @returns A reflection of the secrets configuration type definition, merged with the default secrets configuration reflection and the currently used secrets configuration reflection. The resulting reflection will contain the structure of the expected environment secrets as defined by the type definitions provided in the plugin configuration, as well as any additional properties that are currently used in the source code and defined in the default secrets configuration reflection.\n */\nexport async function reflectSecrets(\n context: EnvPluginContext,\n file?: string,\n name?: string\n) {\n let config: ReflectionClass<any> | undefined;\n if (file) {\n const configType = await reflectType(context, {\n file: !isParentPath(file, context.config.cwd)\n ? joinPaths(context.config.cwd, file)\n : file,\n name\n });\n\n config = resolveClassType(configType);\n }\n\n return mergeSecretsReflections(\n context,\n [\n await readSecretsReflection(context),\n config,\n resolveClassType(\n await reflectType(\n context,\n await getSecretsDefaultTypeDefinition(context)\n )\n )\n ].filter(Boolean) as ReflectionClass<any>[]\n );\n}\n"],"mappings":";;;;;;;;;;AAMA,SAAS,aAAY,IAAI,MAAO;AAC/B,IAAI,SAAS;;;AA0Bd,SAAE,oBAA2B,SAAA,aAAA;AAI3B,QAHA,oBAA+B,SAAA,EAC/B,MAAA,MAAA,YAAqB,IAAA,cAAA,eAAA,WAAA,MAAA;EAAA;EAAA;EAAA;EAAA,CAAA,CAAA,CAAA,EACrB,CACQ;;AAEV,o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